diff --git a/cumulus_library/studies/core/builder_condition.py b/cumulus_library/studies/core/builder_condition.py index 1492f509..0602973c 100644 --- a/cumulus_library/studies/core/builder_condition.py +++ b/cumulus_library/studies/core/builder_condition.py @@ -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 + "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( diff --git a/cumulus_library/studies/core/builder_encounter.py b/cumulus_library/studies/core/builder_encounter.py index cd3552cd..ebcf68ab 100644 --- a/cumulus_library/studies/core/builder_encounter.py +++ b/cumulus_library/studies/core/builder_encounter.py @@ -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, }, @@ -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, }, @@ -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, }, @@ -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", + # EPIC specific systems + "urn:oid:1.2.840.114350.1.13.71.2.7.2.728286", ], "has_data": False, }, diff --git a/cumulus_library/studies/discovery/code_detection.py b/cumulus_library/studies/discovery/code_detection.py index f73d96d7..5642c97d 100644 --- a/cumulus_library/studies/discovery/code_detection.py +++ b/cumulus_library/studies/discovery/code_detection.py @@ -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"]: diff --git a/cumulus_library/template_sql/codeable_concept_denormalize.sql.jinja b/cumulus_library/template_sql/codeable_concept_denormalize.sql.jinja index e954cd57..a0ac8b92 100644 --- a/cumulus_library/template_sql/codeable_concept_denormalize.sql.jinja +++ b/cumulus_library/template_sql/codeable_concept_denormalize.sql.jinja @@ -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 %} diff --git a/cumulus_library/template_sql/sql_utils.py b/cumulus_library/template_sql/sql_utils.py index 797bc330..e07c00b6 100644 --- a/cumulus_library/template_sql/sql_utils.py +++ b/cumulus_library/template_sql/sql_utils.py @@ -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 @@ -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 """ diff --git a/tests/test_templates.py b/tests/test_templates.py index ab89b3ec..a546ecb2 100644 --- a/tests/test_templates.py +++ b/tests/test_templates.py @@ -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 ( @@ -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 (