Code inventory¶
Stage 7 writes code_inventory.csv next to dashboard_data.json. It lists every distinct vocabulary and code in the bundle, how many records and patients have it, the display name seen most often, and which bundle tables it appears in.
Columns¶
| Column | Contents |
|---|---|
vocabulary |
Vocabulary name as the pipeline normalizes it (SNOMED-CT, ICD-10-CM, RxNorm, LOINC, CVX, CPT-4, FHIR encounter class and others) |
code |
The code |
display_name |
The display name seen most often for the code |
n_references |
Number of records with the code, across all tables |
n_unique_patients |
Number of patients with at least one such record |
source_categories |
Bundle tables the code appears in, separated by semicolons (for example problems;diagnostic_reports) |
How codes are counted¶
For each record in problems, medications, procedures, allergies, immunizations, labs_vitals, diagnostic_reports, document_references and encounters, every entry in all_codings is counted. A problem coded in SNOMED CT with an ICD-10-CM translation therefore adds to two rows. When a record has no all_codings, its code and code_system are used.
labs and vitals are not counted separately, because their rows are already in labs_vitals.
Reading it¶
The file is sorted by vocabulary, then by number of records (highest first), then by code.
import pandas as pd
inv = pd.read_csv('code_inventory.csv')
print(inv['vocabulary'].value_counts()) # codes per vocabulary
print(inv.sort_values('n_references', ascending=False).head(20)) # most frequent codes
The inventory is useful for quality checks (codes whose display names differ between records), for deciding which vocabularies to download from Athena for the OMOP module, and for spotting local codes that need mapping.
Exact counts
The inventory keeps exact counts, including counts of 1, so the team can see every code. It is an identified working file: it stays in the approved environment, and any summary built from it for sharing needs small counts held back.