Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expanded code system preference lists #178

Merged
merged 5 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 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,12 @@ def denormalize_codes(self):
"http://snomed.info/sct",
"http://hl7.org/fhir/sid/icd-10-cm",
"http://hl7.org/fhir/sid/icd-9-cm",
"http://hl7.org/fhir/sid/icd-9-cm/diagnosis",
# EPIC specific systems
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing we can't say anything else about them? But it'd be nice if we could distinguish what these two mean even a little bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, hard agree!

"urn:oid:1.2.840.114350.1.13.71.2.7.2.728286",
"urn:oid:1.2.840.114350.1.13.71.2.7.4.698084.10375",
# Spec allowed code of last resort
"http://terminology.hl7.org/CodeSystem/data-absent-reason",
],
)
self.queries.append(
Expand Down
23 changes: 22 additions & 1 deletion cumulus_library/studies/core/builder_encounter.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ 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",
# Cerner specific systems
"https://fhir.cerner.com/%/codeSet/71",
# EPIC specific systems
"urn:oid:1.2.840.114350.1.13.71.2.7.10.698084.10110",
"urn:oid:1.2.840.114350.1.13.71.2.7.10.698084.18875",
"urn:oid:1.2.840.114350.1.13.71.2.7.10.698084.30",
"urn:oid:1.2.840.114350.1.13.71.2.7.2.808267",
],
"has_data": False,
},
Expand All @@ -49,8 +56,12 @@ def denormalize_codes(self, schema, cursor):
"filter_priority": True,
"code_systems": [
"http://terminology.hl7.org/CodeSystem/service-type",
"urn:oid:2.16.840.1.113883.4.642.3.518",
"http://snomed.info/sct",
# Cerner specific systems
"https://fhir.cerner.com/%/codeSet/34",
# EPIC specific systems
"urn:oid:2.16.840.1.113883.4.642.3.518",
"urn:oid:1.2.840.114350.1.13.71.2.7.10.698084.18886",
],
"has_data": False,
},
Expand All @@ -61,6 +72,10 @@ def denormalize_codes(self, schema, cursor):
"code_systems": [
"http://terminology.hl7.org/CodeSystem/v3-ActPriority",
"http://snomed.info/sct",
# Cerner specific systems
"https://fhir.cerner.com/%/codeSet/3",
# EPIC specific systems
"urn:oid:1.2.840.114350.1.13.71.2.7.10.698084.410",
],
"has_data": False,
},
Expand All @@ -71,6 +86,12 @@ 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",
# Cerner specific systems
"https://fhir.cerner.com/%/nomenclature",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔

# EPIC specific systems
"urn:oid:1.2.840.114350.1.13.71.2.7.2.728286",
],
"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):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to have tests for this study - #179

"""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
Loading