Domain 3 /

How do you run data quality checks?

By the endChoose data quality checks that test stated requirements, read each result against its threshold, and flag outliers with box-plot fences.

A check tests one requirement

A data quality check, sometimes called a data quality rule, tests whether data conform to a given requirement. A script that flags a patient whose recorded age is 141 is a check. The age may come from a wrong birth year or from a death that was never recorded.

The frameworks earlier in this module say what good data look like. Checks measure it. The Observational Health Data Sciences and Informatics (OHDSI) community files each check under one of Kahn's three categories, conformance, completeness and plausibility, so results can be counted by category.

Checks serve two kinds of assessment. A general assessment asks whether the data are fit for observational research at all. A study-specific assessment asks whether they are fit for one study. General checks should run before the data are used for research. Because they are run whatever the research question, OHDSI also recommends study-specific checks.

Checks you can run, filed by OHDSI category
CategoryWhat the check asksExample
Conformance: valueDo recorded values match the specified format?Is every provider's medical specialty a valid specialty?
Conformance: relationalDo records meet relational constraints?Does each provider ID on a drug exposure record have a matching record in the provider table?
Conformance: computationDo computations on the data give the intended result?Does body mass index (BMI) computed from height and weight equal the BMI recorded?
CompletenessIs the variable present, and does it hold all its values?Is weight measured in the office recorded? Does every person have a known gender?
Plausibility: uniquenessDoes each thing appear once?Does each person ID occur only once in the person table?
Plausibility: atemporalDo values and distributions agree with what is expected?Is the diabetes prevalence the data imply in line with the known prevalence?
Plausibility: temporalDo values change over time as expected?Are immunization sequences in line with recommendations?

Each category can be evaluated by verification, against local knowledge and constraints, or by validation, against an external benchmark.

Automated checks run against a threshold

OHDSI's Data Quality Dashboard (DQD) goes table by table and field by field through data converted to OHDSI's Common Data Model (CDM). It counts the records that fail to conform to the specifications. It runs over 1,500 checks, each filed under a Kahn category.

Each check's result is compared to a threshold. The check fails when the percentage of violating rows is above that threshold. A check with a 5% threshold passes with 4% of rows violating and fails with 6%.

The checks work at three levels. Table checks ask whether all required tables are present. Field checks test every field of every table, for example that each primary key is unique. Concept checks look at individual codes, for example that a gender-specific concept such as prostate cancer is not recorded for a female patient.

A second OHDSI tool, ACHILLES (Automated Characterization of Health Information at Large-scale Longitudinal Evidence Systems), describes and charts the database instead of counting rule violations. It precomputes more than 170 characterization analyses, such as the distribution of age at death by gender.

Worked example

Three checks on a visit table

A team runs three checks on a converted visit table of 20,000 rows. A check fails when the percentage of violating rows is above its threshold. Check A finds 1,200 rows whose visit end date falls before the start date, threshold 5%. Check B finds 900 rows whose provider ID has no record in the provider table, threshold 5%. Check C finds no duplicate visit IDs, threshold 0%. Give each percentage to one decimal place.

  1. 1

    Formula

    Percentage of violating rows = violating rows ÷ rows checked × 100.

  2. 2

    Check A

    1,200 ÷ 20,000 × 100 = 6.0%. That is above 5%, so the check fails.

  3. 3

    Check B

    900 ÷ 20,000 × 100 = 4.5%. That is not above 5%, so the check passes, with 900 rows still worth a look.

  4. 4

    Check C

    0 ÷ 20,000 × 100 = 0.0%. That is not above 0%, so the check passes.

Result: Check A fails and checks B and C pass. Check B passes with 900 violating rows, so a pass can still leave rows to fix.

A failure can come from the conversion or the source

A problem found in converted data may come from the conversion itself or may already be in the source data. If the conversion is at fault, the team can usually fix it. If the source data are at fault, the only course left may be to delete the offending records.

OHDSI reports that a properly executed conversion to its CDM adds little to no error. A failed check can still point to either one.

Look at the data over time

Charts of the data over time show problems that a check on single rows will miss. In one OHDSI example, a data density plot shows that the bulk of the data starts in 2005, with a few records from around 1961. Those few records are likely an error.

In another, the monthly rate of a diabetes diagnosis code jumps in the month the country's reimbursement rules changed. The new rules led to more diagnoses, probably without a true rise in prevalence. A sudden change in how often a code appears may hint at a data quality problem or at a change in how the data are made.

Study-specific checks

General checks run whatever the question. These checks are written for one study.

A rule the study needs

A study can impose its own rule, such as requiring that at least 90% of the records for the exposure of interest give the length of exposure.

The study's codes over time

Review the concepts the study's cohort definitions use. A sudden change in the rate at which a code appears may hint at a problem.

Cohorts against clinical knowledge

A new drug should be absent before it reached the market and will likely rise after. An outcome's prevalence should be in line with what is known of the condition in the population.

Databases against each other

A cohort that is common in one database and missing in another may point to a data quality problem. It may also mean the cohort definition misses the health state, or that the populations really differ.

HCUP reviews each source with summary statistics

The Healthcare Cost and Utilization Project (HCUP) assesses the quality of the annual and quarterly data from each data source that takes part in it. Its quality control procedures are one data steward's practice; other data sets set their own rules.

For each year and data source, an independent contractor calculates and reviews a set of statistics. For every year or quarter and every HCUP database, HCUP also counts the edit failures and their percentages, and uses them to judge each source's data quality.

HCUP's quality review statistics

All numeric data elements

Means, the number of missing and nonmissing values, the minimum and the maximum.

Continuous variables

For variables such as length of stay and charges: mean, median and extreme values.

Categorical data elements

Frequency distributions, for all categorical and some continuous data elements.

Closely related data elements

Cross frequencies, such as point of origin compared with admission type.

Data element arrays

The number of elements provided in the array, such as the diagnosis fields, and the frequency distribution of how many are filled.

HCUP's automated checks on each discharge record

HCUP applies these procedures to every discharge record. What it does with a value that fails is a cleaning question.

Validity

Numeric data must be numeric and fall within the legal values the data source documents and within standard norms: length of stay is not negative, and age in years is between 0 and 124, the maximum the Medicare Severity Diagnosis Related Group (MS-DRG) grouper allows. Diagnosis and procedure codes are checked against norms.

Internal consistency

Related data elements must agree. The admission date should come before the discharge date.

Consistency with norms

Values are compared with an established norm. A neonatal diagnosis should not appear with an age above zero years.

Longitudinal consistency

Distributions in the current data year are compared with the prior two data years. Distributions in the current quarter are compared with the latest available quarter and the same quarter of the prior year.

Hospital-level reporting

HCUP identifies new hospitals and hospitals not submitting data, and compares the volume of hospitals between years or quarters.

Screen numeric variables for outliers

The National Institute of Standards and Technology (NIST) e-Handbook of Statistical Methods defines an outlier as an observation that lies an abnormal distance from other values in a random sample from a population. The analyst decides what counts as abnormal, so normal observations must be described first.

Two activities describe a data set. Look at the overall shape of the graphed data, including symmetry and departures from assumptions. Then look for unusual observations far from the mass of the data. Scatter plots and box plots show them.

Box-plot fences

Q1 is the lower quartile (25th percentile) and Q3 the upper quartile (75th percentile). The interquartile range, IQ, is Q3 − Q1.

Inner fences

Lower: Q1 − 1.5 × IQ. Upper: Q3 + 1.5 × IQ. A point beyond an inner fence is a mild outlier.

Outer fences

Lower: Q1 − 3 × IQ. Upper: Q3 + 3 × IQ. A point beyond an outer fence is an extreme outlier.

Worked example

Fences on eleven lengths of stay

Eleven discharges in one diagnosis group had lengths of stay of 1, 2, 2, 3, 3, 4, 4, 5, 6, 14 and 30 days, already in order. Find the quartiles by NIST's rule, then the fences, and classify the two longest stays.

  1. 1

    Quartiles

    NIST takes the lower quartile as the 0.25 × (N + 1)th ordered value and the upper quartile as the 0.75 × (N + 1)th. With N = 11, those are the 3rd and 9th values: Q1 = 2 days and Q3 = 6 days.

  2. 2

    Interquartile range

    IQ = 6 − 2 = 4 days.

  3. 3

    Inner fences

    Lower: 2 − 1.5 × 4 = −4 days. Upper: 6 + 1.5 × 4 = 12 days.

  4. 4

    Outer fences

    Lower: 2 − 3 × 4 = −10 days. Upper: 6 + 3 × 4 = 18 days.

  5. 5

    Classify

    14 days is beyond the upper inner fence of 12 but not the outer fence of 18, so it is a mild outlier. 30 days is beyond 18, so it is an extreme outlier. No stay is below the lower fences.

Result: The 14-day stay is a mild outlier and the 30-day stay an extreme outlier. Both are flags to investigate.

Z-scores and modified z-scores

Z-score

  • The z-score is (value − sample mean) ÷ sample standard deviation: how many standard deviations a value lies from the mean.
  • It can mislead, especially in small samples, because the largest possible z-score is (n − 1) ÷ √n.
  • With 9 values, no z-score can exceed 8 ÷ 3 = 2.67, so a rule that flags z-scores above 3 can never flag anything.

Modified z-score

  • The modified z-score is 0.6745 × (value − median) ÷ MAD, where MAD is the median absolute deviation.
  • Iglewicz and Hoaglin recommend labeling values with a modified z-score above 3.5 in absolute value as potential outliers.

Formal outlier tests

The tests NIST describes assume the data follow an approximately normal distribution. Check that first with a normal probability plot. Data that are approximately lognormal can be log-transformed and then tested.

Grubbs' test

For univariate data with an approximately normal distribution, the recommended test for a single outlier. Running it again after each outlier it finds is not appropriate, because masking by a second outlier can make the first test find none.

Tietjen-Moore test

For univariate data with an approximately normal distribution, it extends Grubbs' test to more than one outlier, but the number of outliers must be specified exactly.

Generalized extreme studentized deviate (ESD) test

For univariate data with an approximately normal distribution, it needs only an upper bound on the number of suspected outliers. It is the recommended test when the exact number is not known.

Try it

Pick the checks

A health system loads one year of outpatient visits from 12 clinics into a new analytics table. Name a check for each of these requirements: the visit type must be one of the allowed values; each visit's provider must exist in the provider table; each visit ID must appear once; and each clinic must keep sending its usual volume. For the last, say what you would compare.

Hint: Match each requirement to the OHDSI category it tests, then borrow HCUP's reporting check for the volumes.

02 / Questions

Answer 8 questions

Check 1 of 8scenario · easy

An analyst's script runs over a full patient table and flags every record whose recorded age is 141. In the terms of the Observational Health Data Sciences and Informatics (OHDSI) book's data quality chapter, what is this script?

Check 2 of 8scenario · medium

A team runs the Data Quality Dashboard (DQD) on a converted visit table of 8,000 rows. One check finds 360 rows whose visit end date falls before the visit start date. The check's threshold is 5%, and the dashboard reports FAIL when the percentage of violating rows is above the threshold. What is the percentage of violating rows, to one decimal place, and the result?

Check 3 of 8scenario · medium

A team converts a hospital's records to the Observational Health Data Sciences and Informatics (OHDSI) Common Data Model (CDM). The Data Quality Dashboard (DQD), run on the converted data, fails a check. According to the OHDSI book, what can the team conclude before it investigates?

Check 4 of 8scenario · medium

An analyst charts the monthly rate of a diabetes diagnosis code in a database and sees a sudden rise that starts in the month the country's reimbursement rules changed. Following the Observational Health Data Sciences and Informatics (OHDSI) book's reading of this pattern, what is the most likely explanation?

Check 5 of 8recall · easy

In the Healthcare Cost and Utilization Project (HCUP) quality review, an independent contractor calculates statistics for each year and data source. Which statistics does HCUP list for continuous variables such as length of stay and charges?

Check 6 of 8scenario · medium

An analyst applies the Healthcare Cost and Utilization Project (HCUP) Quality Control Procedures' longitudinal consistency check to one quarter of discharge data. What does HCUP compare that quarter's distributions of data elements with?

Check 7 of 8scenario · hard

An analyst screens the length of stay (LOS) of 11 discharges in one diagnosis group with box-plot fences as the National Institute of Standards and Technology (NIST) e-Handbook of Statistical Methods defines them. The lower quartile (Q1) is 2 days and the upper quartile (Q3) is 6 days. Two stays stand out, one of 14 days and one of 30 days. How do the fences classify them?

Check 8 of 8recall · hard

An analyst suspects that a variable with an approximately normal distribution holds several outliers but cannot say exactly how many. Which formal test does the National Institute of Standards and Technology (NIST) e-Handbook of Statistical Methods recommend for this case?

03 / Recall

Answer without looking back

Name four things you can do to check a data set before analysis, and say what decides whether a Data Quality Dashboard check fails and where the 'mild outlier' line is on a box plot.

Primary reading

Read the relevant section

The Book of OHDSI, Chapter 15: Data Quality · 15.2.1 Data Quality Checks ↗
Sources used in this lesson
  1. The Book of OHDSI, Chapter 15: Data Quality, 15.3 Study-Specific Checks ↗Observational Health Data Sciences and Informatics (OHDSI)
  2. HCUP Quality Control Procedures, Automated Quality Control Procedures, hospital-level reporting, printed p. 2 ↗Agency for Healthcare Research and Quality, Healthcare Cost and Utilization Project
  3. NIST/SEMATECH e-Handbook of Statistical Methods, 7.1.6 What are outliers in the data?, 7.1.6, Box plots with fences and outlier detection criteria ↗National Institute of Standards and Technology
  4. NIST/SEMATECH e-Handbook of Statistical Methods, 1.3.5.17 Detection of Outliers, 1.3.5.17, Z-Scores and Modified Z-Scores ↗National Institute of Standards and Technology
  5. Original Medicare Claims and Part D Events Maturity: Information and Guidance for CCW Data Users, V1.0, 1.0 Background and 1.3 Objectives, printed p. 1 ↗Centers for Medicare & Medicaid Services, Chronic Conditions Warehouse (hosted by ResDAC)
Glossary terms used in this lesson
Medicare
A national program the federal government administers, made up of Part A (Hospital Insurance), Part B (Medical Insurance), Part C (Medicare Advantage) and Part D (Prescription Drug Benefit).
Original Medicare
One of the two ways a beneficiary can get Medicare Part A and Part B services; the other is a Medicare Advantage plan. Drug coverage is optional, through an approved stand-alone Part D drug plan, and Medigap supplemental insurance can expand coverage.
MS-DRGMedicare Severity Diagnosis-Related Group
Under the IPPS, a group of similar clinical conditions and services requiring similar resource use, to which each inpatient discharge is assigned. Principal diagnosis, secondary diagnoses, procedures, sex, age and discharge status determine the assignment; there are 768 MS-DRGs for FY 2027.
grouper
The MS-DRG GROUPER: software that classifies a patient's hospital stay into an established MS-DRG from data elements the hospital reports, including admit date, discharge date, principal diagnosis, specific secondary diagnoses, procedures, sex and discharge status.
HCUPHealthcare Cost and Utilization Project
AHRQ's databases: nationwide databases (NIS, KID, NASS, NEDS and NRD) and state-specific databases (SID, SASD and SEDD), used to identify, track and analyze trends in health care utilization, access, charges, quality and outcomes.
CCWChronic Conditions Warehouse
The source for national CMS Medicare and Medicaid research data. Its April 2026 guidance for data users reports how Original Medicare claims and Part D events mature after the service month.
run-out
Time allowed after services for claims to be processed before a claims file is treated as complete. In CCW's April 2026 analysis, 12 months of run-out meant July 2023 services were considered complete as of August 2024, with no later updates accepted.
CDMCommon Data Model
In OHDSI, the OMOP Common Data Model: the target structure into which native or raw data are restructured by an extract, transform and load (ETL) process that also adds mappings to the Standardized Vocabularies.
data quality
The state of completeness, validity, consistency, timeliness and accuracy that makes data appropriate for a specific use. It cannot be observed directly, but methods have been developed to assess it.
completeness
In the Kahn data quality framework, whether a particular variable is present, such as a weight measured in the doctor's office, and whether variables contain all recorded values, such as a known gender for every person.
conformance
In the Kahn data quality framework, whether data values adhere to specified standards and formats. Its three subtypes are value, relational and computation conformance.
plausibility
In the Kahn data quality framework, whether data values are believable. Its three subtypes are uniqueness, atemporal plausibility and temporal plausibility.
timeliness
In the FCSM data quality framework, the length of time between the event or phenomenon the data describe and their availability. It is a dimension of the utility domain.
primary key
A candidate key that the database designer selects as the identifying mechanism for a table. It must uniquely identify the rows and must not be null.
prevalence
The proportion of persons in a population who have a particular disease or attribute at a specified point in time or over a specified period of time. It includes all cases, both new and preexisting.
standard deviation
The most common measure of variation, or spread: a number that measures how far data values are from their mean.
median
The number that splits ordered data into two equal parts. It is generally a better measure of the center than the mean when there are extreme values or outliers.
interquartile range
A number that indicates the spread of the middle half of the data: the third quartile (Q3) minus the first quartile (Q1).
NISTNational Institute of Standards and Technology
The institute responsible, under the Federal Information Security Modernization Act, for developing information security standards and guidelines, including minimum requirements for federal information systems.
data steward
As NCVHS describes it, an overseer or guardian with final authority and accountability for appropriate use of health data. The steward may be a formal position or an assigned accountability.