Skip to content

Commit

Permalink
Expanded code system preference lists
Browse files Browse the repository at this point in the history
  • Loading branch information
dogversioning committed Feb 8, 2024
1 parent becfbad commit 6eece1f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 7 deletions.
3 changes: 3 additions & 0 deletions cumulus_library/studies/core/builder_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def denormalize_codes(self):
"http://snomed.info/sct",
"http://hl7.org/fhir/sid/icd-10-cm",
"http://hl7.org/fhir/sid/icd-9-cm",
"urn:oid:1.2.840.114350.1.13.71.2.7.2",
"urn:oid:1.2.840.114350.1.13.71.2.7.4",
"http://terminology.hl7.org/CodeSystem/data-absent-reason",
],
)
self.queries.append(
Expand Down
11 changes: 11 additions & 0 deletions cumulus_library/studies/core/builder_encounter.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ def denormalize_codes(self, schema, cursor):
"http://terminology.hl7.org/CodeSystem/v2-0004",
"urn:oid:2.16.840.1.113883.4.642.3.248",
"http://snomed.info/sct",
"https://fhir.cerner.com/96976f07-eccb-424c-9825-e0d0b887148b/codeSet/71",
"urn:oid:1.2.840.114350.1.13.71.2.7.10",
"urn:oid:1.2.840.114350.1.13.71.2.7.2",
],
"has_data": False,
},
Expand All @@ -51,6 +54,8 @@ def denormalize_codes(self, schema, cursor):
"http://terminology.hl7.org/CodeSystem/service-type",
"urn:oid:2.16.840.1.113883.4.642.3.518",
"http://snomed.info/sct",
"https://fhir.cerner.com/96976f07-eccb-424c-9825-e0d0b887148b/codeSet/34",
"urn:oid:1.2.840.114350.1.13.71.2.7.10",
],
"has_data": False,
},
Expand All @@ -61,6 +66,8 @@ def denormalize_codes(self, schema, cursor):
"code_systems": [
"http://terminology.hl7.org/CodeSystem/v3-ActPriority",
"http://snomed.info/sct",
"https://fhir.cerner.com/96976f07-eccb-424c-9825-e0d0b887148b/codeSet/3",
"urn:oid:1.2.840.114350.1.13.71.2.7.10",
],
"has_data": False,
},
Expand All @@ -71,6 +78,10 @@ def denormalize_codes(self, schema, cursor):
"code_systems": [
"http://terminology.hl7.org/CodeSystem/v3-ActPriority",
"http://snomed.info/sct",
"http://hl7.org/fhir/sid/icd-10-cm",
"http://hl7.org/fhir/sid/icd-9-cm",
"https://fhir.cerner.com/96976f07-eccb-424c-9825-e0d0b887148b/nomenclature",
"urn:oid:1.2.840.114350.1.13.71.2.7.2",
],
"has_data": False,
},
Expand Down
2 changes: 1 addition & 1 deletion cumulus_library/studies/discovery/code_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class CodeDetectionBuilder(base_table_builder.BaseTableBuilder):
display_text = "Selecting unique code systems..."

def _check_coding_against_db(code_source, schema, cursor):
def _check_coding_against_db(self, code_source, schema, cursor):
"""selects the appropriate DB query to run"""

if code_source["is_array"]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ CREATE TABLE {{ target_table }} AS (
{%- endif %}
{%- if filter_priority %}
WHERE
u.codeable_concept.system = '{{ system }}'
u.codeable_concept.system LIKE '{{ system }}%'
{%- endif %}
), --noqa: LT07
{%- endfor %}
Expand Down
7 changes: 4 additions & 3 deletions cumulus_library/template_sql/sql_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ class CodeableConceptConfig:
:param source_id: the id field to use in the new table (default: 'id')
:param filter_priority: If true, will use code systems to select a single code,
in preference order, for use as a display value.
:param code_systems: a list of systems, in preference order, for selecting data
for filtering. This should not be set if filter_priority is false.
:param code_systems: a list of strings matching the start of the systems field,
in preference order, for selecting data for filtering. This should not be set
if filter_priority is false.
"""

column_name: str
Expand All @@ -50,7 +51,7 @@ class ExtensionConfig:
:param target_table: the name of the table to create
:param target_col_prefix: the string to prepend code/display column names with
:param fhir_extension: the URL of the FHIR resource to select
:param code_systems: a list of codes, in preference order, to use to select data
:param ext_systems: a list of codes, in preference order, to use to select data
:param is_array: a boolean indicating if the targeted field is an array type
"""

Expand Down
4 changes: 2 additions & 2 deletions tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_codeable_concept_denormalize_filter_creation():
source AS s,
UNNEST(s.code_col.coding) AS u (codeable_concept)
WHERE
u.codeable_concept.system = 'http://snomed.info/sct'
u.codeable_concept.system LIKE 'http://snomed.info/sct%'
), --noqa: LT07
system_code_col_1 AS (
Expand All @@ -91,7 +91,7 @@ def test_codeable_concept_denormalize_filter_creation():
source AS s,
UNNEST(s.code_col.coding) AS u (codeable_concept)
WHERE
u.codeable_concept.system = 'http://hl7.org/fhir/sid/icd-10-cm'
u.codeable_concept.system LIKE 'http://hl7.org/fhir/sid/icd-10-cm%'
), --noqa: LT07
union_table AS (
Expand Down

0 comments on commit 6eece1f

Please sign in to comment.