DataQualityDashboard (DQD)

repository·main·Indexed 41 days ago

https://github.com/ohdsi/dataqualitydashboard

An open-source R package for evaluating the quality of observational data in an OMOP Common Data Model (CDM). Based on the Kahn Framework, it executes parameterized table, field, and concept-level checks and visualizes results via an RShiny application. Supports OMOP CDM versions 5.3 and 5.4, requiring R 3.2.2+ and DatabaseConnector 2.0.2+.

Tokens
2.6K
Snippets
5
Records
11
Agent score
52%

What's inside DataQualityDashboard

  1. How DataQualityDashboard evaluates data quality

    main

    DataQualityDashboard uses a systematic approach based on the Kahn Framework, which organizes checks into categories and contexts.

    Instead of individual checks, the tool uses "data quality check types". These are parameterized templates where OMOP tables, fields, and concepts are substituted.

    Checks are categorized into three levels:

    1. Table-level checks: Evaluate tables at a high level (e.g., checking if required tables are present).
    2. Field-level checks: Evaluate specific fields within a table (e.g., primary key relationships or domain conformity). This is the most common type.
    3. Concept-level checks: Related to individual concepts (e.g., checking for gender-specific concepts in the wrong gender).

    The R package runs these checks against an OMOP CDM instance, evaluates them against configurable thresholds, and produces a JSON object. This JSON object is then read into an RShiny application for visualization.

  2. Follow the Pull Request process for DQD

    main

    When contributing changes to DataQualityDashboard, follow this workflow:

    1. Branching: Sync your fork's develop branch with upstream. Create a new branch for your specific issue or feature. For large features, split work into multiple sub-branches.
    2. Testing Requirements:
      • New Functionality: You must add unit tests covering the new code.
      • Bug Fixes: You must add a unit test that reproduces the regression.
    3. Validation Steps:
      • Run R CMD Check and resolve all errors, warnings, and notes (the package size NOTE can be ignored).
      • Run the specific test file: test_file(path = "tests/testthat/test-executeDqChecks.R") to resolve snapshot test failures.
      • Build and install the package locally, then run DQD against your local Postgres database to verify results.
    4. Submission:
      • Push changes to GitHub and open a PR targeting the develop branch of the parent OHDSI/DataQualityDashboard repository.
      • Wait for automated checks. If they fail, address errors by repeating the validation steps.
      • Once approved by a maintainer, you may merge into develop.
    # Run specific tests to resolve snapshot failures
    test_file(path = "tests/testthat/test-executeDqChecks.R")
  3. Install DataQualityDashboard

    main

    DataQualityDashboard is an R package. Before installation, ensure your R environment is configured with RTools and Java as per the Hades R setup guide.

    To install the stable version from CRAN, use install.packages(). To install the development version from GitHub, use the remotes package.

    # Install from CRAN
    install.packages("DataQualityDashboard")
    
    # Install from GitHub
    install.packages("remotes")
    remotes::install_github("OHDSI/DataQualityDashboard")
  4. Access DataQualityDashboard documentation and vignettes

    main

    Detailed documentation and specific task guides are available via the package website or through the following PDF vignettes:

    • Add a New Data Quality Check: How to extend the tool with new checks.
    • Check Status Descriptions: Understanding the meaning of check results.
    • Running the DQD on a Cohort: Specific guidance for cohort-based analysis.
    • Failure Thresholds and How to Change Them: How to configure what constitutes a 'failed' check.
    • SqlOnly Mode: Using the tool without the RShiny interface.
    • Package Manual: The full technical manual.
  5. Set up a local development environment for DQD

    main

    To develop for DataQualityDashboard, follow these setup steps:

    1. R Setup: Follow the standard OHDSI Hades R setup instructions: https://ohdsi.github.io/Hades/rSetup.html
    2. Local OMOP CDM Setup: You need a local database to test DQD. If you don't have one, follow these steps:
      • Install Postgres and create a localhost server.
      • Create a new database and a schema for the CDM tables.
      • Use the CDMConnector package to populate the database:
        • Download a sample OMOP CDM into a DuckDB database (see CDMConnector::eunomiaDir).
        • Copy the CDM from DuckDB to your local Postgres database (see CDMConnector::copy_cdm_to).
    3. Repository Setup: Fork the ohdsi/dataqualitydashboard repository and clone your fork to your local machine.
  6. System requirements for DataQualityDashboard

    main

    To run DataQualityDashboard, your environment must meet the following requirements:

    • R: version 3.2.2 or higher.
    • DatabaseConnector: version 2.0.2 or higher.
    • Database Platform: Various platforms are supported (see Hades supported platforms).

    Note: While threshold files exist for OMOP CDM versions 5.2, 5.3, and 5.4, the package is currently only tested against versions 5.3 and 5.4.

  7. Populate the CDM_SOURCE table for DataQualityDashboard

    main

    Prior to executing data quality checks, the CDM_SOURCE table must be properly populated. This table provides metadata about the CDM instance used for the checks. The following fields are expected:

    cdmFieldNameuserGuidance
    cdm_source_nameThe name of the CDM instance.
    cdm_source_abbreviationThe abbreviation of the CDM instance.
    cdm_holderThe holder of the CDM instance (institution).
    source_descriptionDescription of the CDM instance to help analysts determine suitability.
    source_documentation_referenceReference/URL to find documentation about the source data.
    cdm_etl_referenceReference to documentation about the ETL into OMOP CDM.
    source_release_dateThe release date of the source data.
    cdm_release_dateThe release date of the CDM instance.
    cdm_versionNumeric portion of the version (e.g., 5.4).
    cdm_version_concept_idThe Concept Id representing the version of the CDM.
    vocabulary_versionThe vocabulary version used in the ETL.
  8. Use the <dq-metadata> custom element to render data source metadata

    main

    The <dq-metadata> custom element is a web component used within the Data Quality Dashboard UI to render a structured view of data source metadata. It expects a JSON string passed to the data-results attribute.

    When the data-results attribute is updated, the component automatically re-renders using a Handlebars template.

    Expected JSON Schema

    The data-results attribute must contain a JSON object with the following keys:

    • cdmSourceName: Name of the CDM source
    • sourceDescription: Description of the source
    • cdmHolder: Entity licensed to hold the data
    • sourceReleaseDate: Release date of the source
    • cdmReleaseDate: Release date of the CDM
    • cdmVersion: Version of the CDM
    • vocabularyVersion: Version of the vocabulary used
    • sourceDocumentationReference: Reference to source documentation
    • cdmEtlReference: Reference to the ETL process
    <!-- Example usage in HTML -->
    <dq-metadata data-results='{"cdmSourceName": "OMOP CDM", "sourceDescription": "Example Source", "cdmHolder": "Example Org", "sourceReleaseDate": "2023-01-01", "cdmReleaseDate": "2023-01-01", "cdmVersion": "5.4", "vocabularyVersion": "2023-01-01", "sourceDocumentationReference": "http://example.com", "cdmEtlReference": "http://etl.example.com"}'></dq-metadata>
  9. Use the <dq-dashboard> custom element

    main

    The dq-dashboard is a custom HTML element used to render a summary dashboard of data quality results. It accepts a JSON array of check results via the data-results attribute and automatically calculates and displays pass/fail statistics across different contexts (Verification, Validation) and categories (Plausibility, Conformance, Completeness).

    To use it, include the component in your HTML and provide the results as a JSON string in the data-results attribute.

    <dq-dashboard data-results='[{"context": "Verification", "category": "Plausibility", "passed": 1}, {"context": "Validation", "category": "Conformance", "failed": 1}]'></dq-dashboard>
  10. Data format for the dq-dashboard data-results attribute

    main

    The data-results attribute expects a JSON array of objects. Each object represents a single data quality check result. The component uses the following properties to aggregate statistics:

    PropertyTypeDescription
    contextstringThe context of the check: "Verification" or "Validation".
    categorystringThe category of the check: "Plausibility", "Conformance", or "Completeness".
    passednumber(Optional) 1 if the check passed.
    notApplicablenumber(Optional) 1 if the check is Not Applicable (NA).
    failednumber(Optional) 1 if the check failed.
    isErrornumber(Optional) 1 if the check resulted in a SQL error.

    Note on Pass/Fail Logic:

    • A check is considered Passed if it has passed == 1 OR notApplicable == 1. If those properties are missing, it is considered passed if failed == 0.
    • A check is considered Failed if it has failed == 1 OR isError == 1. If those properties are missing, it is considered failed if failed == 1.
    [
      {
        "context": "Verification",
        "category": "Plausibility",
        "passed": 1
      },
      {
        "context": "Validation",
        "category": "Conformance",
        "failed": 1,
        "isError": 1
      }
    ]