Skip to content

Commit

Permalink
discovery cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dogversioning committed Mar 21, 2024
1 parent f965d00 commit 81ad97a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 19 deletions.
8 changes: 4 additions & 4 deletions cumulus_library/studies/discovery/code_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def _check_coding_against_db(self, code_source, schema, cursor):
return sql_utils.is_field_populated(
schema=schema,
source_table=code_source["table_name"],
hierarchy=[(code_source["column_name"], list), ("coding", list)],
expected=[code_source["column_name"], *sql_utils.CODING],
hierarchy=[(code_source["column_name"], list)],
expected=sql_utils.CODEABLE_CONCEPT,
cursor=cursor,
)
elif code_source["is_bare_coding"]:
Expand All @@ -30,8 +30,8 @@ def _check_coding_against_db(self, code_source, schema, cursor):
return sql_utils.is_field_populated(
schema=schema,
source_table=code_source["table_name"],
hierarchy=[(code_source["column_name"], dict), ("coding", list)],
expected=[code_source["column_name"], *sql_utils.CODING],
hierarchy=[(code_source["column_name"], dict)],
expected=sql_utils.CODEABLE_CONCEPT,
cursor=cursor,
)

Expand Down
43 changes: 35 additions & 8 deletions tests/test_data/discovery/discovery__code_sources.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
condition,category,,,
condition,category,encounter-diagnosis,Encounter Diagnosis,http://terminology.hl7.org/CodeSystem/condition-category
condition,code,10509002,Acute bronchitis (disorder),http://snomed.info/sct
condition,code,160903007,Full-time employment (finding),http://snomed.info/sct
condition,code,195662009,Acute viral pharyngitis (disorder),http://snomed.info/sct
Expand All @@ -10,21 +10,48 @@ condition,code,44465007,Sprain of ankle,http://snomed.info/sct
condition,code,444814009,Viral sinusitis (disorder),http://snomed.info/sct
condition,code,73595000,Stress (finding),http://snomed.info/sct
condition,code,741062008,Not in labor force (finding),http://snomed.info/sct
documentreference,category,,,
documentreference,type,,,
documentreference,category,clinical-note,Clinical Note,http://hl7.org/fhir/us/core/CodeSystem/us-core-documentreference-category
documentreference,type,34111-5,Emergency department note,http://loinc.org
documentreference,type,51847-2,Evaluation + Plan note,http://loinc.org
encounter,class,AMB,None,http://terminology.hl7.org/CodeSystem/v3-ActCode
encounter,class,EMER,None,http://terminology.hl7.org/CodeSystem/v3-ActCode
encounter,hospitalization.dischargedisposition,,,
encounter,priority,,,
encounter,reasoncode,,,
encounter,reasoncode,10509002,Acute bronchitis (disorder),http://snomed.info/sct
encounter,reasoncode,161665007,History of renal transplant (situation),http://snomed.info/sct
encounter,reasoncode,195662009,Acute viral pharyngitis (disorder),http://snomed.info/sct
encounter,reasoncode,271737000,Anemia (disorder),http://snomed.info/sct
encounter,reasoncode,431857002,Chronic kidney disease stage 4 (disorder),http://snomed.info/sct
encounter,reasoncode,444814009,Viral sinusitis (disorder),http://snomed.info/sct
encounter,reasoncode,55680006,Drug overdose,http://snomed.info/sct
encounter,reasoncode,72892002,Normal pregnancy,http://snomed.info/sct
encounter,reasoncode,88805009,Chronic congestive heart failure (disorder),http://snomed.info/sct
encounter,servicetype,,,
encounter,type,,,
encounter,type,162673000,General examination of patient (procedure),http://snomed.info/sct
encounter,type,185345009,Encounter for symptom,http://snomed.info/sct
encounter,type,185347001,Encounter for problem,http://snomed.info/sct
encounter,type,185347001,Encounter for problem (procedure),http://snomed.info/sct
encounter,type,185349003,Encounter for check up,http://snomed.info/sct
encounter,type,185349003,Encounter for check up (procedure),http://snomed.info/sct
encounter,type,308335008,Patient encounter procedure,http://snomed.info/sct
encounter,type,371883000,Outpatient procedure,http://snomed.info/sct
encounter,type,410620009,Well child visit (procedure),http://snomed.info/sct
encounter,type,424619006,Prenatal visit,http://snomed.info/sct
encounter,type,439740005,Postoperative follow-up visit (procedure),http://snomed.info/sct
encounter,type,448337001,Telemedicine consultation with patient,http://snomed.info/sct
encounter,type,50849002,Emergency room admission (procedure),http://snomed.info/sct
encounter,type,698314001,Consultation for treatment,http://snomed.info/sct
encounter,type,702927004,Urgent care clinic (environment),http://snomed.info/sct
medication,codecodeableconcept ,,,
medication,medicationcode,,,
observation,category,,,
observation,category,laboratory,Laboratory,http://terminology.hl7.org/CodeSystem/observation-category
observation,code,34533-0,Odor of Urine,http://loinc.org
observation,code,5778-6,Color of Urine,http://loinc.org
observation,dataabsentreason,,,
observation,interpretation,,,
observation,valuecodeableconcept,,,
patient,maritalstatus,,,
observation,valuecodeableconcept,167248002,Urine smell ammoniacal (finding),http://snomed.info/sct
observation,valuecodeableconcept,371254008,Brown color (qualifier value),http://snomed.info/sct
patient,maritalstatus,D,Divorced,http://terminology.hl7.org/CodeSystem/v3-MaritalStatus
patient,maritalstatus,M,Married,http://terminology.hl7.org/CodeSystem/v3-MaritalStatus
patient,maritalstatus,S,Never Married,http://terminology.hl7.org/CodeSystem/v3-MaritalStatus
patient,maritalstatus,W,Widowed,http://terminology.hl7.org/CodeSystem/v3-MaritalStatus
14 changes: 7 additions & 7 deletions tests/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ def test_discovery(tmp_path):
table_rows = conftest.get_sorted_table_data(cursor, "discovery__code_sources")

# For regenerating test data
with open(
f"{pathlib.Path(__file__).resolve().parents[0]}"
"/test_data/discovery/discovery__code_sources.txt",
"w",
) as f:
for row in table_rows:
f.write(f"{','.join(str(x) for x in row)}\n")
# with open(
# f"{pathlib.Path(__file__).resolve().parents[0]}"
# "/test_data/discovery/discovery__code_sources.txt",
# "w",
# ) as f:
# for row in table_rows:
# f.write(f"{','.join(str(x) for x in row)}\n")

with open(
f"{pathlib.Path(__file__).resolve().parents[0]}"
Expand Down

0 comments on commit 81ad97a

Please sign in to comment.