diff --git a/cumulus_library/.sqlfluff b/cumulus_library/.sqlfluff index b18c5420..100251c6 100644 --- a/cumulus_library/.sqlfluff +++ b/cumulus_library/.sqlfluff @@ -96,6 +96,7 @@ join_cols_by_table = join_id = subject_ref neg_source_table = neg_source_table output_table_name = 'created_table' +parent_field = 'parent' prefix = Test primary_ref = encounter_ref pos_source_table = pos_source_table diff --git a/cumulus_library/studies/core/builder_condition.py b/cumulus_library/studies/core/builder_condition.py index 0602973c..d94ecbfb 100644 --- a/cumulus_library/studies/core/builder_condition.py +++ b/cumulus_library/studies/core/builder_condition.py @@ -46,8 +46,7 @@ def denormalize_codes(self): preferred_config = sql_utils.CodeableConceptConfig( source_table="condition", source_id="id", - column_name="code", - is_array=False, + column_hierarchy=[("code", dict)], target_table="core__condition_codable_concepts_display", filter_priority=True, code_systems=[ @@ -69,8 +68,7 @@ def denormalize_codes(self): all_config = sql_utils.CodeableConceptConfig( source_table="condition", source_id="id", - column_name="code", - is_array=False, + column_hierarchy=[("code", dict)], target_table="core__condition_codable_concepts_all", filter_priority=False, ) diff --git a/cumulus_library/studies/core/builder_documentreference.py b/cumulus_library/studies/core/builder_documentreference.py index 9b7c93ab..c5757837 100644 --- a/cumulus_library/studies/core/builder_documentreference.py +++ b/cumulus_library/studies/core/builder_documentreference.py @@ -26,15 +26,14 @@ def prepare_queries( parser: databases.DatabaseParser = None, **kwargs, ): - self.queries += sql_utils.denormalize_codes( + self.queries = sql_utils.denormalize_complex_objects( schema, cursor, [ sql_utils.CodeableConceptConfig( source_table="documentreference", source_id="id", - column_name="type", - is_array=False, + column_hierarchy=[("type", dict)], target_table="core__documentreference_dn_type", ), # TODO: The US core profile allows an extensible code for category, but @@ -47,19 +46,17 @@ def prepare_queries( sql_utils.CodeableConceptConfig( source_table="documentreference", source_id="id", - column_name="category", - is_array=True, + column_hierarchy=[("category", list)], filter_priority=True, target_table="core__documentreference_dn_category", code_systems=[ "http://hl7.org/fhir/us/core/ValueSet/us-core-documentreference-category" ], ), - sql_utils.CodeableConceptConfig( + sql_utils.CodingConfig( source_table="documentreference", source_id="id", - column_name="content.format", - is_array=False, + column_hierarchy=[("content", list), ("format", dict)], target_table="core__documentreference_dn_format", ), ], diff --git a/cumulus_library/studies/core/builder_encounter.py b/cumulus_library/studies/core/builder_encounter.py index 03913471..8c90ac79 100644 --- a/cumulus_library/studies/core/builder_encounter.py +++ b/cumulus_library/studies/core/builder_encounter.py @@ -35,7 +35,7 @@ class EncConfig(sql_utils.CodeableConceptConfig): source_table: str = "encounter" def __post_init__(self): - self.target_table = f"core__encounter_dn_{self.column_name.split('.')[-1]}" + self.target_table = f"core__encounter_dn_{self.column_hierarchy[-1][0]}" class CoreEncounterBuilder(base_table_builder.BaseTableBuilder): @@ -44,8 +44,7 @@ class CoreEncounterBuilder(base_table_builder.BaseTableBuilder): def denormalize_codes(self, schema, cursor): code_configs = [ EncConfig( - column_name="type", - is_array=True, + column_hierarchy=[("type", list)], filter_priority=True, code_systems=[ "http://terminology.hl7.org/CodeSystem/encounter-type", @@ -62,8 +61,7 @@ def denormalize_codes(self, schema, cursor): ], ), EncConfig( - column_name="servicetype", - is_array=False, + column_hierarchy=[("servicetype", dict)], filter_priority=True, code_systems=[ "http://terminology.hl7.org/CodeSystem/service-type", @@ -76,8 +74,7 @@ def denormalize_codes(self, schema, cursor): ], ), EncConfig( - column_name="priority", - is_array=False, + column_hierarchy=[("priority", dict)], filter_priority=True, code_systems=[ "http://terminology.hl7.org/CodeSystem/v3-ActPriority", @@ -89,8 +86,7 @@ def denormalize_codes(self, schema, cursor): ], ), EncConfig( - column_name="reasoncode", - is_array=True, + column_hierarchy=[("reasoncode", list)], filter_priority=True, code_systems=[ "http://terminology.hl7.org/CodeSystem/v3-ActPriority", @@ -104,12 +100,16 @@ def denormalize_codes(self, schema, cursor): ], ), EncConfig( - column_name="hospitalization.dischargedisposition", - is_array=False, + column_hierarchy=[ + ("hospitalization", dict), + ("dischargedisposition", dict), + ], filter_priority=False, ), ] - self.queries += sql_utils.denormalize_codes(schema, cursor, code_configs) + self.queries += sql_utils.denormalize_complex_objects( + schema, cursor, code_configs + ) def prepare_queries( self, diff --git a/cumulus_library/studies/core/builder_medication.py b/cumulus_library/studies/core/builder_medication.py index c85690b4..3f40a150 100644 --- a/cumulus_library/studies/core/builder_medication.py +++ b/cumulus_library/studies/core/builder_medication.py @@ -24,20 +24,23 @@ def _check_data_in_fields(self, cursor, schema: str): } table = "medicationrequest" - base_col = "medicationcodeableconcept" + inline_col = "medicationcodeableconcept" with base_utils.get_progress_bar(transient=True) as progress: task = progress.add_task( "Detecting available medication sources...", - total=7, + total=3, ) # inline medications from FHIR medication - data_types["inline"] = sql_utils.is_codeable_concept_populated( - schema, table, base_col, cursor + data_types["inline"] = sql_utils.is_field_populated( + schema=schema, + source_table=table, + hierarchy=[(inline_col, dict), ("coding", list)], + cursor=cursor, ) if data_types["inline"]: query = base_templates.get_column_datatype_query( - schema, table, [base_col] + schema, table, [inline_col] ) cursor.execute(query) progress.advance(task) @@ -47,27 +50,15 @@ def _check_data_in_fields(self, cursor, schema: str): has_userselected = True else: has_userselected = False - # Validating presence of FHIR medication requests - query = base_templates.get_is_table_not_empty_query( - "medicationrequest", "medicationreference" - ) - cursor.execute(query) - progress.advance(task) - if cursor.fetchone() is None: - return data_types, has_userselected - query = base_templates.get_column_datatype_query( - schema, "medicationrequest", ["medicationreference"] - ) - cursor.execute(query) progress.advance(task) - if "reference" not in cursor.fetchone()[0]: - return data_types, has_userselected - query = base_templates.get_is_table_not_empty_query( - "medicationrequest", "medicationreference.reference" - ) - cursor.execute(query) - progress.advance(task) - if cursor.fetchone() is None: + # Validating presence of FHIR medication requests + if not sql_utils.is_field_populated( + schema=schema, + source_table=table, + hierarchy=[("medicationreference", dict), ("reference", dict)], + expected=["reference"], + cursor=cursor, + ): return data_types, has_userselected # checking med ref contents for our two linkage cases diff --git a/cumulus_library/studies/core/builder_medicationrequest.py b/cumulus_library/studies/core/builder_medicationrequest.py index 890a9dc2..e5892026 100644 --- a/cumulus_library/studies/core/builder_medicationrequest.py +++ b/cumulus_library/studies/core/builder_medicationrequest.py @@ -43,19 +43,19 @@ def prepare_queries( sql_utils.CodeableConceptConfig( source_table="medicationrequest", source_id="id", - column_name="category", - is_array=True, + column_hierarchy=[("category", list)], target_table="core__medicationrequest_dn_category", ), sql_utils.CodeableConceptConfig( source_table="medicationrequest", source_id="id", - column_name="medicationcodeableconcept", - is_array=False, + column_hierarchy=[("medicationcodeableconcept", dict)], target_table="core__medicationrequest_dn_medication", ), ] - self.queries += sql_utils.denormalize_codes(schema, cursor, code_sources) + self.queries += sql_utils.denormalize_complex_objects( + schema, cursor, code_sources + ) validated_schema = core_templates.validate_schema( cursor, schema, expected_table_cols, parser ) diff --git a/cumulus_library/studies/core/builder_observation.py b/cumulus_library/studies/core/builder_observation.py index 9caa4114..ad2737c3 100644 --- a/cumulus_library/studies/core/builder_observation.py +++ b/cumulus_library/studies/core/builder_observation.py @@ -37,7 +37,7 @@ class ObsConfig(sql_utils.CodeableConceptConfig): source_table: str = "observation" def __post_init__(self): - self.target_table = f"core__observation_dn_{self.column_name}" + self.target_table = f"core__observation_dn_{self.column_hierarchy[-1][0]}" class ObservationBuilder(base_table_builder.BaseTableBuilder): @@ -57,24 +57,24 @@ def prepare_queries( :param schema: the schema/db name, matching the cursor """ code_sources = [ - ObsConfig(column_name="category", is_array=True, filter_priority=False), - ObsConfig(column_name="code", is_array=False, filter_priority=False), + ObsConfig(column_hierarchy=[("category", list)], filter_priority=False), + ObsConfig(column_hierarchy=[("code", dict)], filter_priority=False), ObsConfig( - column_name="interpretation", is_array=True, filter_priority=False + column_hierarchy=[("interpretation", list)], filter_priority=False ), ObsConfig( - column_name="valuecodeableconcept", - is_array=False, + column_hierarchy=[("valuecodeableconcept", dict)], filter_priority=False, ), ObsConfig( - column_name="dataabsentreason", - is_array=False, + column_hierarchy=[("dataabsentreason", dict)], filter_priority=False, ), ] - self.queries += sql_utils.denormalize_codes(schema, cursor, code_sources) + self.queries += sql_utils.denormalize_complex_objects( + schema, cursor, code_sources + ) validated_schema = core_templates.validate_schema( cursor, schema, expected_table_cols, parser ) diff --git a/cumulus_library/studies/core/builder_patient.py b/cumulus_library/studies/core/builder_patient.py index f6c62e20..984fe871 100644 --- a/cumulus_library/studies/core/builder_patient.py +++ b/cumulus_library/studies/core/builder_patient.py @@ -44,12 +44,12 @@ def prepare_queries( for extension in extension_types: config = sql_utils.ExtensionConfig( - "patient", - "id", - f"core__patient_ext_{extension['name']}", - extension["name"], - extension["fhirpath"], - ["ombCategory", "detailed", "text"], + source_table="patient", + source_id="id", + target_table=f"core__patient_ext_{extension['name']}", + target_col_prefix=extension["name"], + fhir_extension=extension["fhirpath"], + ext_systems=["ombCategory", "detailed", "text"], is_array=True, ) self.queries.append(base_templates.get_extension_denormalize_query(config)) diff --git a/cumulus_library/studies/core/reference_sql/builder_condition.sql b/cumulus_library/studies/core/reference_sql/builder_condition.sql index 26546bb1..c4f6946c 100644 --- a/cumulus_library/studies/core/reference_sql/builder_condition.sql +++ b/cumulus_library/studies/core/reference_sql/builder_condition.sql @@ -13,8 +13,8 @@ CREATE TABLE core__condition_codable_concepts_display AS ( SELECT DISTINCT s.id AS id, '0' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM condition AS s, @@ -27,8 +27,8 @@ CREATE TABLE core__condition_codable_concepts_display AS ( SELECT DISTINCT s.id AS id, '1' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM condition AS s, @@ -41,8 +41,8 @@ CREATE TABLE core__condition_codable_concepts_display AS ( SELECT DISTINCT s.id AS id, '2' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM condition AS s, @@ -55,8 +55,8 @@ CREATE TABLE core__condition_codable_concepts_display AS ( SELECT DISTINCT s.id AS id, '3' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM condition AS s, @@ -69,8 +69,8 @@ CREATE TABLE core__condition_codable_concepts_display AS ( SELECT DISTINCT s.id AS id, '4' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM condition AS s, @@ -83,8 +83,8 @@ CREATE TABLE core__condition_codable_concepts_display AS ( SELECT DISTINCT s.id AS id, '5' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM condition AS s, @@ -97,8 +97,8 @@ CREATE TABLE core__condition_codable_concepts_display AS ( SELECT DISTINCT s.id AS id, '6' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM condition AS s, @@ -201,8 +201,8 @@ CREATE TABLE core__condition_codable_concepts_all AS ( system_code_0 AS ( SELECT DISTINCT s.id AS id, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM condition AS s, diff --git a/cumulus_library/studies/core/reference_sql/builder_documentreference.sql b/cumulus_library/studies/core/reference_sql/builder_documentreference.sql index 0bb5b4a9..8f84c486 100644 --- a/cumulus_library/studies/core/reference_sql/builder_documentreference.sql +++ b/cumulus_library/studies/core/reference_sql/builder_documentreference.sql @@ -12,8 +12,8 @@ CREATE TABLE core__documentreference_dn_type AS ( system_type_0 AS ( SELECT DISTINCT s.id AS id, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM documentreference AS s, @@ -47,8 +47,8 @@ CREATE TABLE core__documentreference_dn_category AS ( SELECT DISTINCT s.id AS id, '0' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM documentreference AS s, @@ -98,15 +98,38 @@ CREATE TABLE core__documentreference_dn_category AS ( -- ########################################################### -CREATE TABLE IF NOT EXISTS "main"."core__documentreference_dn_format" -AS ( - SELECT * FROM ( - VALUES - (cast(NULL AS varchar),cast(NULL AS varchar),cast(NULL AS varchar),cast(NULL AS varchar)) +CREATE TABLE core__documentreference_dn_format AS ( + WITH + + system_format_0 AS ( + SELECT DISTINCT + s.id AS id, + u.parent_col.format.code, + u.parent_col.format.display, + u.parent_col.format.system AS code_system + FROM + documentreference AS s, + UNNEST(s.content) AS u (parent_col) + ), --noqa: LT07 + + union_table AS ( + SELECT + id, + code_system, + code, + display + FROM system_format_0 + ) - AS t ("id","code","code_system","display") + SELECT + id, + code, + code_system, + display + FROM union_table ); + -- ########################################################### diff --git a/cumulus_library/studies/core/reference_sql/builder_encounter.sql b/cumulus_library/studies/core/reference_sql/builder_encounter.sql index 30b9330f..e813bdaf 100644 --- a/cumulus_library/studies/core/reference_sql/builder_encounter.sql +++ b/cumulus_library/studies/core/reference_sql/builder_encounter.sql @@ -13,8 +13,8 @@ CREATE TABLE core__encounter_dn_type AS ( SELECT DISTINCT s.id AS id, '0' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM encounter AS s, @@ -28,8 +28,8 @@ CREATE TABLE core__encounter_dn_type AS ( SELECT DISTINCT s.id AS id, '1' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM encounter AS s, @@ -43,8 +43,8 @@ CREATE TABLE core__encounter_dn_type AS ( SELECT DISTINCT s.id AS id, '2' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM encounter AS s, @@ -58,8 +58,8 @@ CREATE TABLE core__encounter_dn_type AS ( SELECT DISTINCT s.id AS id, '3' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM encounter AS s, @@ -73,8 +73,8 @@ CREATE TABLE core__encounter_dn_type AS ( SELECT DISTINCT s.id AS id, '4' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM encounter AS s, @@ -88,8 +88,8 @@ CREATE TABLE core__encounter_dn_type AS ( SELECT DISTINCT s.id AS id, '5' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM encounter AS s, @@ -103,8 +103,8 @@ CREATE TABLE core__encounter_dn_type AS ( SELECT DISTINCT s.id AS id, '6' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM encounter AS s, @@ -118,8 +118,8 @@ CREATE TABLE core__encounter_dn_type AS ( SELECT DISTINCT s.id AS id, '7' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM encounter AS s, @@ -133,8 +133,8 @@ CREATE TABLE core__encounter_dn_type AS ( SELECT DISTINCT s.id AS id, '8' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM encounter AS s, @@ -277,8 +277,8 @@ CREATE TABLE core__encounter_dn_reasoncode AS ( SELECT DISTINCT s.id AS id, '0' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM encounter AS s, @@ -292,8 +292,8 @@ CREATE TABLE core__encounter_dn_reasoncode AS ( SELECT DISTINCT s.id AS id, '1' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM encounter AS s, @@ -307,8 +307,8 @@ CREATE TABLE core__encounter_dn_reasoncode AS ( SELECT DISTINCT s.id AS id, '2' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM encounter AS s, @@ -322,8 +322,8 @@ CREATE TABLE core__encounter_dn_reasoncode AS ( SELECT DISTINCT s.id AS id, '3' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM encounter AS s, @@ -337,8 +337,8 @@ CREATE TABLE core__encounter_dn_reasoncode AS ( SELECT DISTINCT s.id AS id, '4' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM encounter AS s, @@ -352,8 +352,8 @@ CREATE TABLE core__encounter_dn_reasoncode AS ( SELECT DISTINCT s.id AS id, '5' AS priority, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM encounter AS s, @@ -443,15 +443,38 @@ CREATE TABLE core__encounter_dn_reasoncode AS ( -- ########################################################### -CREATE TABLE IF NOT EXISTS "main"."core__encounter_dn_dischargedisposition" -AS ( - SELECT * FROM ( - VALUES - (cast(NULL AS varchar),cast(NULL AS varchar),cast(NULL AS varchar),cast(NULL AS varchar)) +CREATE TABLE core__encounter_dn_dischargedisposition AS ( + WITH + + system_dischargedisposition_0 AS ( + SELECT DISTINCT + s.id AS id, + u.codeable_concept.code, + u.codeable_concept.display, + u.codeable_concept.system AS code_system + FROM + encounter AS s, + UNNEST(s.hospitalization.dischargedisposition.coding) AS u (codeable_concept) + ), --noqa: LT07 + + union_table AS ( + SELECT + id, + code_system, + code, + display + FROM system_dischargedisposition_0 + ) - AS t ("id","code","code_system","display") + SELECT + id, + code, + code_system, + display + FROM union_table ); + -- ########################################################### CREATE TABLE core__encounter AS diff --git a/cumulus_library/studies/core/reference_sql/builder_medicationrequest.sql b/cumulus_library/studies/core/reference_sql/builder_medicationrequest.sql index 0eedc6a6..738379c7 100644 --- a/cumulus_library/studies/core/reference_sql/builder_medicationrequest.sql +++ b/cumulus_library/studies/core/reference_sql/builder_medicationrequest.sql @@ -12,8 +12,8 @@ CREATE TABLE core__medicationrequest_dn_category AS ( system_category_0 AS ( SELECT DISTINCT s.id AS id, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM medicationrequest AS s, @@ -47,8 +47,8 @@ CREATE TABLE core__medicationrequest_dn_medication AS ( system_medicationcodeableconcept_0 AS ( SELECT DISTINCT s.id AS id, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM medicationrequest AS s, @@ -88,14 +88,14 @@ WITH temp_mr AS ( AS authoredon_month, cast(NULL as varchar) AS display, mr.reportedboolean, + mr.dosageinstruction, mr.subject.reference AS subject_ref, mr.encounter.reference AS encounter_ref, mrc.code AS category_code, mrc.code_system AS category_code_system, - mrm.code as medication_code, + mrm.code AS medication_code, mrm.code_system AS medication_code_system, - mrm.display AS medication_display, - mr.dosageinstruction + mrm.display AS medication_display FROM medicationrequest AS mr LEFT JOIN core__medicationrequest_dn_category AS mrc ON mr.id = mrc.id LEFT JOIN core__medicationrequest_dn_medication AS mrm ON mr.id = mrm.id @@ -103,19 +103,19 @@ WITH temp_mr AS ( ) SELECT - id, - status, - intent, - category_code, - category_code_system, - reportedboolean, - medication_code_system, - medication_code, - medication_display, - authoredon, - authoredon_month, + mr.id, + mr.status, + mr.intent, + mr.category_code, + mr.category_code_system, + mr.reportedboolean, + mr.medication_code_system, + mr.medication_code, + mr.medication_display, + mr.authoredon, + mr.authoredon_month, dose_row.dose_col.text AS doseageinstruction_text, - subject_ref, - encounter_ref -FROM temp_mr, -UNNEST(dosageinstruction) as dose_row(dose_col) + mr.subject_ref, + mr.encounter_ref +FROM temp_mr AS mr, + UNNEST(dosageinstruction) AS dose_row (dose_col) diff --git a/cumulus_library/studies/core/reference_sql/builder_observation.sql b/cumulus_library/studies/core/reference_sql/builder_observation.sql index 171976b9..0b5f2b28 100644 --- a/cumulus_library/studies/core/reference_sql/builder_observation.sql +++ b/cumulus_library/studies/core/reference_sql/builder_observation.sql @@ -12,8 +12,8 @@ CREATE TABLE core__observation_dn_category AS ( system_category_0 AS ( SELECT DISTINCT s.id AS id, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM observation AS s, @@ -47,8 +47,8 @@ CREATE TABLE core__observation_dn_code AS ( system_code_0 AS ( SELECT DISTINCT s.id AS id, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM observation AS s, @@ -92,8 +92,8 @@ CREATE TABLE core__observation_dn_valuecodeableconcept AS ( system_valuecodeableconcept_0 AS ( SELECT DISTINCT s.id AS id, - u.codeable_concept.code AS code, - u.codeable_concept.display AS display, + u.codeable_concept.code, + u.codeable_concept.display, u.codeable_concept.system AS code_system FROM observation AS s, diff --git a/cumulus_library/studies/discovery/code_detection.py b/cumulus_library/studies/discovery/code_detection.py index 5642c97d..4c5a4951 100644 --- a/cumulus_library/studies/discovery/code_detection.py +++ b/cumulus_library/studies/discovery/code_detection.py @@ -12,24 +12,27 @@ def _check_coding_against_db(self, code_source, schema, cursor): """selects the appropriate DB query to run""" if code_source["is_array"]: - return sql_utils.is_codeable_concept_array_populated( - schema, - code_source["table_name"], - code_source["column_name"], - cursor, + return sql_utils.is_field_populated( + schema=schema, + source_table=code_source["table_name"], + hierarchy=[(code_source["column_name"], list)], + expected=sql_utils.CODEABLE_CONCEPT, + cursor=cursor, ) elif code_source["is_bare_coding"]: - return sql_utils.is_code_populated( - schema, - code_source["table_name"], - code_source["column_name"], - cursor, + return sql_utils.is_field_populated( + schema=schema, + source_table=code_source["table_name"], + hierarchy=[(code_source["column_name"], dict)], + expected=sql_utils.CODING, + cursor=cursor, ) - return sql_utils.is_codeable_concept_populated( - schema, - code_source["table_name"], - code_source["column_name"], - cursor, + return sql_utils.is_field_populated( + schema=schema, + source_table=code_source["table_name"], + hierarchy=[(code_source["column_name"], dict)], + expected=sql_utils.CODEABLE_CONCEPT, + cursor=cursor, ) def _check_codes_in_fields(self, code_sources: list[dict], schema, cursor) -> dict: @@ -72,7 +75,6 @@ def prepare_queries(self, cursor: object, schema: str, *args, **kwargs): for key in code_definition.keys(): code_source[key] = code_definition[key] code_sources.append(code_source) - code_sources = self._check_codes_in_fields(code_sources, schema, cursor) query = base_templates.get_code_system_pairs( "discovery__code_sources", code_sources diff --git a/cumulus_library/template_sql/base_templates.py b/cumulus_library/template_sql/base_templates.py index 331ce42c..85e19926 100644 --- a/cumulus_library/template_sql/base_templates.py +++ b/cumulus_library/template_sql/base_templates.py @@ -74,6 +74,7 @@ def get_codeable_concept_denormalize_query( :param config: a CodableConeptConfig """ + assert len(config.column_hierarchy) <= 2 # If we get a None for code systems, we want one dummy value so the jinja # for loop will do a single pass. This implicitly means that we're not # filtering, so this parameter will be otherwise ignored @@ -82,8 +83,42 @@ def get_codeable_concept_denormalize_query( "codeable_concept_denormalize", source_table=config.source_table, source_id=config.source_id, - column_name=config.column_name, - is_array=config.is_array, + column_name=config.column_hierarchy[-1][0], + parent_field=None + if len(config.column_hierarchy) == 1 + else config.column_hierarchy[0][0], + is_array=(config.column_hierarchy[0][1] == list), + target_table=config.target_table, + filter_priority=config.filter_priority, + code_systems=config.code_systems, + ) + + +def get_coding_denormalize_query( + config: sql_utils.CodingConfig, +) -> str: + """extracts codings from a specified table. + + This function reimplements get_codeable_concept_denormalize_query targeted + at a bare coding element + + TODO: this is temporary and this should be replaced by a generic DN + query. + + :param config: a CodingConfig + """ + + assert len(config.column_hierarchy) == 2 + # If we get a None for code systems, we want one dummy value so the jinja + # for loop will do a single pass. This implicitly means that we're not + # filtering, so this parameter will be otherwise ignored + config.code_systems = config.code_systems or ["all"] + return get_base_template( + "coding_denormalize", + source_table=config.source_table, + source_id=config.source_id, + column_name=config.column_hierarchy[1][0], + parent_field=config.column_hierarchy[0][0], target_table=config.target_table, filter_priority=config.filter_priority, code_systems=config.code_systems, diff --git a/cumulus_library/template_sql/code_system_pairs.sql.jinja b/cumulus_library/template_sql/code_system_pairs.sql.jinja index 43f0369b..8d08f9d3 100644 --- a/cumulus_library/template_sql/code_system_pairs.sql.jinja +++ b/cumulus_library/template_sql/code_system_pairs.sql.jinja @@ -33,13 +33,11 @@ UNNEST({{ source.column_name }}.coding) AS t (row) SELECT * FROM ( VALUES ( - ( - '{{ source.table_name }}', - '{{ source.column_name }}', - '', - '', - '' - ) + '{{ source.table_name }}', + '{{ source.column_name }}', + '', + '', + '' ) ) AS t (table_name, column_name, code, display, system) diff --git a/cumulus_library/template_sql/codeable_concept_denormalize.sql.jinja b/cumulus_library/template_sql/codeable_concept_denormalize.sql.jinja index 15e53498..e9e18dc4 100644 --- a/cumulus_library/template_sql/codeable_concept_denormalize.sql.jinja +++ b/cumulus_library/template_sql/codeable_concept_denormalize.sql.jinja @@ -13,6 +13,16 @@ CREATE TABLE {{ target_table }} AS ( u.codeable_concept.display, u.codeable_concept.system AS code_system FROM + {#- Temp workaround - to be reworked by generic DN -#} + {%- if parent_field != None %} + {{ source_table }} AS s, + {%- if is_array %} + UNNEST(s.{{ parent_field }}) AS parent (parent_row), + UNNEST(parent.parent_row.{{ column_name }}.coding) AS u (codeable_concept) + {%- else %} + UNNEST(s.{{ parent_field }}.{{ column_name }}.coding) AS u (codeable_concept) + {%- endif %} + {%- else %} {{ source_table }} AS s, {%- if is_array %} UNNEST(s.{{ column_name }}) AS cc (cc_row), @@ -20,6 +30,7 @@ CREATE TABLE {{ target_table }} AS ( {%- else %} UNNEST(s.{{ column_name }}.coding) AS u (codeable_concept) {%- endif %} + {%- endif %} {%- if filter_priority %} WHERE u.codeable_concept.system LIKE '{{ system }}' diff --git a/cumulus_library/template_sql/coding_denormalize.sql.jinja b/cumulus_library/template_sql/coding_denormalize.sql.jinja new file mode 100644 index 00000000..44c6ba65 --- /dev/null +++ b/cumulus_library/template_sql/coding_denormalize.sql.jinja @@ -0,0 +1,74 @@ +{%- import 'syntax.sql.jinja' as syntax -%} +CREATE TABLE {{ target_table }} AS ( + WITH + {%- for system in code_systems %} + + system_{{ column_name }}_{{ loop.index0 }} AS ( + SELECT DISTINCT + s.{{ source_id }} AS id, + {%- if filter_priority %} + '{{ loop.index0 }}' AS priority, + {%- endif %} + u.parent_col.{{ column_name }}.code, + u.parent_col.{{ column_name }}.display, + u.parent_col.{{ column_name }}.system AS code_system + FROM + {{ source_table }} AS s, + UNNEST(s.{{ parent_field }}) AS u (parent_col) + {%- if filter_priority %} + WHERE + u.parent_col.{{ column_name }}.system LIKE '{{ system }}' + {%- endif %} + ), --noqa: LT07 + {%- endfor %} + + union_table AS ( + {%- for system in code_systems %} + SELECT + id, + {%- if filter_priority %} + priority, + {%- endif %} + code_system, + code, + display + FROM system_{{ column_name }}_{{ loop.index0 }} + {{ syntax.union_delineate(loop) }} + {%- endfor %} + ) + {%- if filter_priority -%}, + + partitioned_table AS ( + SELECT + id, + code, + code_system, + display, + priority, + ROW_NUMBER() + OVER ( + PARTITION BY id + ORDER BY priority ASC + ) AS available_priority + FROM union_table + GROUP BY id, priority, code_system, code, display + ORDER BY priority ASC + ) + + SELECT + id, + code, + code_system, + display + FROM partitioned_table + WHERE available_priority = 1 +); +{% else %} + SELECT + id, + code, + code_system, + display + FROM union_table +); +{% endif %} diff --git a/cumulus_library/template_sql/sql_utils.py b/cumulus_library/template_sql/sql_utils.py index e1849996..48ba71fb 100644 --- a/cumulus_library/template_sql/sql_utils.py +++ b/cumulus_library/template_sql/sql_utils.py @@ -8,57 +8,72 @@ - Data with deep missing elements - Data which may or may not be in an array depending on context """ - -from dataclasses import dataclass - -import duckdb +import abc +from dataclasses import dataclass, field from cumulus_library import base_utils, databases from cumulus_library.template_sql import base_templates +# TODO: this should be reworked as part of an evenutal typesystem refactor/FHIRClient +# cutover, possibly tied to a database parser update + +CODING = ["code", "system", "display"] +CODEABLE_CONCEPT = ["coding", "code", "system", "display"] + + +@dataclass(kw_only=True) +class BaseConfig(abc.ABC): + """Abstract ase class for handling table detection/denormalization""" + + source_table: str = None + source_id: str = "id" + target_table: str = None + has_data: bool = False + @dataclass(kw_only=True) -class CodeableConceptConfig: +class CodeableConceptConfig(BaseConfig): """Holds parameters for generating codableconcept tables. - :param column_name: the column containing the codeableConcept you want to extract. - :param is_array: whether the codeableConcept is 0...1 or 0..* in the FHIR spec - :param source_table: the table to extract extensions from - :param target_table: the name of the table to create - :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, + :keyword column_name: the column containing the codeableConcept you want to extract. + :keyword is_array: whether the codeableConcept is 0...1 or 0..* in the FHIR spec + :keyword source_table: the table to extract extensions from + :keyword target_table: the name of the table to create + :keyword source_id: the id field to use in the new table (default: 'id') + :keyword 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 strings matching the start of the systems field, + :keyword 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 - is_array: bool - source_table: str = None - target_table: str = None - source_id: str = "id" + column_hierarchy: list[tuple] filter_priority: bool = False code_systems: list = None - has_data: bool = False + expected: list = field(default_factory=lambda: CODEABLE_CONCEPT) + + +@dataclass(kw_only=True) +class CodingConfig(BaseConfig): + column_hierarchy: list[tuple] + filter_priority: bool = False + code_systems: list = None + expected: list = field(default_factory=lambda: CODING) -@dataclass -class ExtensionConfig: +@dataclass(kw_only=True) +class ExtensionConfig(BaseConfig): """convenience class for holding parameters for generating extension tables. - :param source_table: the table to extract extensions from - :param source_id: the id column to treat as a foreign key - :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 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 + :keyword source_table: the table to extract extensions from + :keyword source_id: the id column to treat as a foreign key + :keyword target_table: the name of the table to create + :keyword target_col_prefix: the string to prepend code/display column names with + :keyword fhir_extension: the URL of the FHIR resource to select + :keyword ext_systems: a list of codes, in preference order, to use to select data + :keyword is_array: a boolean indicating if the targeted field is an array type """ - source_table: str - source_id: str - target_table: str target_col_prefix: str fhir_extension: str ext_systems: list[str] @@ -66,8 +81,8 @@ class ExtensionConfig: def _check_data_in_fields( - schema, - cursor, + schema: str, + cursor: databases.DatabaseCursor, code_sources: list[CodeableConceptConfig], ) -> dict: """checks if CodeableConcept fields actually have data available @@ -97,197 +112,164 @@ def _check_data_in_fields( total=len(code_sources), ) for code_source in code_sources: - if code_source.is_array: - code_source.has_data = is_codeable_concept_array_populated( - schema, code_source.source_table, code_source.column_name, cursor - ) - else: - code_source.has_data = is_codeable_concept_populated( - schema, code_source.source_table, code_source.column_name, cursor - ) + code_source.has_data = is_field_populated( + schema=schema, + cursor=cursor, + source_table=code_source.source_table, + hierarchy=code_source.column_hierarchy, + expected=code_source.expected, + ) progress.advance(task) return code_sources -def denormalize_codes( +def denormalize_complex_objects( schema: str, cursor: databases.DatabaseCursor, - code_sources: list[CodeableConceptConfig], + code_sources: list[BaseConfig], ): queries = [] code_sources = _check_data_in_fields(schema, cursor, code_sources) for code_source in code_sources: - if code_source.has_data: - queries.append( - base_templates.get_codeable_concept_denormalize_query(code_source) - ) - else: - queries.append( - base_templates.get_ctas_empty_query( - schema_name=schema, - table_name=code_source.target_table, - table_cols=["id", "code", "code_system", "display"], - ) - ) - return queries + # TODO: This method of pairing classed config objects to + # specific queries should be considered temporary. This should be + # replaced at some point by a more generic table schema traversal/ + # generic jinja template approach. + match code_source: + case CodeableConceptConfig(): + if code_source.has_data: + queries.append( + base_templates.get_codeable_concept_denormalize_query( + code_source + ) + ) + else: + queries.append( + base_templates.get_ctas_empty_query( + schema_name=schema, + table_name=code_source.target_table, + table_cols=["id", "code", "code_system", "display"], + ) + ) + case CodingConfig(): + if code_source.has_data: + queries.append( + base_templates.get_coding_denormalize_query(code_source) + ) + else: + queries.append( + base_templates.get_ctas_empty_query( + schema_name=schema, + table_name=code_source.target_table, + table_cols=["id", "code", "code_system", "display"], + ) + ) - -def is_codeable_concept_populated( - schema: str, - table: str, - base_col: str, - cursor, - coding_element="coding", -) -> bool: - """Check db to see if codeableconcept data exists. - - Will execute several exploratory queries to see if the column in question - can be queried naively. - - :param schema: The schema/database name - :param table: The table to query against - :param base_col: the place to start validation from. - This can be a nested element, like column.object.code - :param cursor: a PEP-249 compliant database cursor - :param coding_element: the place inside the code element to look for coding info. - default: 'coding' (and :hopefully: this is always right) - :returns: a boolean indicating if valid data is present. - """ - try: - if not _check_schema_if_exists(schema, table, base_col, cursor, coding_element): - return False - - query = base_templates.get_is_table_not_empty_query( - table, - "t1.row1", - [ - { - "source_col": f"{base_col}.coding", - "table_alias": "t1", - "row_alias": "row1", - } - ], - ) - cursor.execute(query) - if cursor.fetchone() is None: - return False - return True - except duckdb.duckdb.BinderException: - return False - - -def is_codeable_concept_array_populated( - schema: str, - table: str, - base_col: str, - cursor, - coding_element="coding", -) -> bool: - """Check db to see if an array of codeableconcept data exists. - - Will execute several exploratory queries to see if the column in question - can be queried naively. Will advance the associated progress's task by 3 steps. - - :param schema: The schema/database name - :param table: The table to query against - :param base_col: the place to start validation from. - This can be a nested element, like column.object.code - :param cursor: a PEP-249 compliant database cursor - :param coding_element: the place inside the code element to look for coding info. - default: 'coding' (and :hopefully: this is always right) - :returns: a boolean indicating if valid data is present. - """ - try: - if not _check_schema_if_exists(schema, table, base_col, cursor, coding_element): - return False - query = base_templates.get_is_table_not_empty_query( - table, - "t2.row2", - [ - { - "source_col": base_col, - "table_alias": "t1", - "row_alias": "row1", - }, - { - "source_col": "row1.coding", - "table_alias": "t2", - "row_alias": "row2", - }, - ], - ) - cursor.execute(query) - if cursor.fetchone() is None: - return False - return True - except duckdb.duckdb.BinderException: - return False + return queries -def is_code_populated( +def is_field_populated( + *, schema: str, - table: str, - base_col: str, - cursor, + cursor: databases.DatabaseCursor, + source_table: str, + hierarchy: list[tuple], + expected: list | None = None, ) -> bool: - """Check db to see if a bare code exists and is populated. - - Will execute several exploratory queries to see if the column in question - can be queried naively. - - :param schema: The schema/database name - :param table: The table to query against - :param base_col: the place to start validation from. - This can be a nested element, like column.object.code - :param cursor: a PEP-249 compliant database cursor + """Traverses a complex field and determines if it exists and has data + + :keyword schema: The schema/database name + :keyword cursor: a PEP-249 compliant database cursor + :keyword source_table: The table to query against + :keyword hierarchy: a list of tuples defining the FHIR path to the element. + Each tuple should be of the form ('element_name', dict | list), where + a dict is a bare nested object and a list is an array object + :keyword expected: a list of elements that should be present in the field. + If none, we assume it is a CodeableConcept. :returns: a boolean indicating if valid data is present. """ - if not _check_schema_if_exists( - schema, table, base_col, cursor, "coding", check_missing=True + schema=schema, + cursor=cursor, + source_table=source_table, + source_col=hierarchy[0][0], + expected=expected, + nested_field=hierarchy[-1][0] if len(hierarchy) > 1 else None, ): return False + unnests = [] + source_field = [] + last_table_alias = None + last_row_alias = None + for element in hierarchy: + if element[1] == list: + unnests.append( + { + "source_col": ".".join([*source_field, element[0]]), + "table_alias": f"{element[0]}_table", + "row_alias": f"{element[0]}_row", + }, + ) + last_table_alias = f"{element[0]}_table" + last_row_alias = f"{element[0]}_row" + source_field = [last_table_alias, last_row_alias] + elif element[1] == dict: + source_field.append(element[0]) + else: + raise ValueError( + "sql_utils.is_field_populated: Unexpected type " + f"{element[1]} for field {element[0]}" + ) query = base_templates.get_is_table_not_empty_query( - table, - base_col, + source_table=source_table, field=".".join(source_field), unnests=unnests ) - cursor.execute(query) - if cursor.fetchone() is None: + res = cursor.execute(query).fetchall() + if len(res) == 0: return False return True def _check_schema_if_exists( + *, schema: str, - table: str, - base_col: str, - cursor, - coding_element: str, - check_missing: bool = False, + cursor: databases.DatabaseCursor, + source_table: str, + source_col: str, + expected: str | None = None, + nested_field: str | None = None, ) -> bool: - """Validation check for a column existing, and having the expected schema""" + """Validation check for a column existing, and having the expected schema + + :keyword schema: The schema/database name + :keyword cursor: a PEP-249 compliant database cursor + :keyword source_table: The table to query against + :keyword source_col: The column to check the schema against + :keyword expected: a list of elements that should be present in source_col. + If none, we assume it is a CodeableConcept. + :returns: a boolean indicating if the schema was found. + """ try: - query = base_templates.get_is_table_not_empty_query(table, base_col) + query = base_templates.get_is_table_not_empty_query(source_table, source_col) cursor.execute(query) - if cursor.fetchone() is None: return False - query = base_templates.get_column_datatype_query(schema, table, [base_col]) + query = base_templates.get_column_datatype_query( + schema, source_table, [source_col] + ) cursor.execute(query) schema_str = str(cursor.fetchone()[1]) - if check_missing: - # This check is for a bare coding, so we're looking for an exclusion of the - # coding element, but still the things that are in a code - required_fields = ["code", "system", "display"] - if any(x not in schema_str for x in required_fields): - return False - if coding_element in schema_str: - return False - else: - required_fields = [coding_element, "code", "system", "display"] - if any(x not in schema_str for x in required_fields): - return False + if expected is None: + expected = CODEABLE_CONCEPT + # TODO: this naievely checks a column for: + # - containing the target field + # - containing the expected elements + # but it does not check the elements are actually associated with that field. + # This should be revisited once we've got better database parsing logic in place + if nested_field: + expected = [nested_field, *expected] + if any(x not in schema_str.lower() for x in expected): + return False return True except Exception: diff --git a/pyproject.toml b/pyproject.toml index b54cb6da..8bffdeb3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,6 +56,12 @@ build-backend = "flit_core.buildapi" [tool.flit.sdist] include = [".sqlfluff"] +[tool.pytest.ini_options] +minversion = "6.0" +testpaths = [ + "tests", +] + [tool.ruff] target-version = "py310" diff --git a/tests/conftest.py b/tests/conftest.py index 0a25d4a9..b9a92a56 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -31,6 +31,15 @@ } +def get_sorted_table_data(cursor, table): + num_cols = cursor.execute( + f"SELECT count(*) FROM information_schema.columns WHERE table_name='{table}'" + ).fetchone()[0] + return cursor.execute( + f"SELECT * FROM '{table}' ORDER BY " f"{','.join(map(str, range(1,num_cols)))}" + ).fetchall() + + def modify_resource_column( cursor: DatabaseCursor, table: str, col: str, replacement_val ): diff --git a/tests/test_cli.py b/tests/test_cli.py index 69ecc7d8..17700507 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -531,14 +531,14 @@ def test_cli_upload_studies(mock_glob, args, status, login_error, raises): with raises: with requests_mock.Mocker() as r: if login_error: - r.post("https://aggregator.smartcumulus.org/upload/", status_code=401) + r.post("https://upload.url.test/upload/", status_code=401) else: r.post( - "https://aggregator.smartcumulus.org/upload/", - json={"url": "https://presigned.url.org", "fields": {"a": "b"}}, + "https://upload.url.test/upload/", + json={"url": "https://presigned.url.test", "fields": {"a": "b"}}, ) - r.post("https://presigned.url.org", status_code=status) - cli.main(cli_args=args) + r.post("https://presigned.url.test", status_code=status) + cli.main(cli_args=[*args, "--url", "https://upload.url.test/upload/"]) @pytest.mark.parametrize( diff --git a/tests/test_core.py b/tests/test_core.py index ca32c9b7..2d37830c 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -6,18 +6,9 @@ import pytest import toml -from cumulus_library.cli import StudyRunner +from cumulus_library import cli from cumulus_library.studies.core.core_templates import core_templates -from tests.conftest import modify_resource_column - - -def get_sorted_table_data(cursor, table): - num_cols = cursor.execute( - f"SELECT count(*) FROM information_schema.columns WHERE table_name='{table}'" - ).fetchone()[0] - return cursor.execute( - f"SELECT * FROM '{table}' ORDER BY " f"{','.join(map(str, range(1,num_cols)))}" - ).fetchall() +from tests import conftest @pytest.mark.parametrize( @@ -45,7 +36,7 @@ def test_core_tables(mock_db_core, table): # The schema check is to ensure we have a consistent order for the data in # these files, mostly for making git history simpler in case of minor changes - table_rows = get_sorted_table_data(cursor, table) + table_rows = conftest.get_sorted_table_data(cursor, table) # For regenerating data if needed # with open(f"./tests/test_data/core/{table}.txt", "wt", encoding="UTF-8") as f: @@ -73,14 +64,14 @@ def test_core_count_missing_data(tmp_path, mock_db): "version": None, } cursor = mock_db.cursor() - modify_resource_column(cursor, "encounter", "class", null_code_class) + conftest.modify_resource_column(cursor, "encounter", "class", null_code_class) - builder = StudyRunner(mock_db, f"{tmp_path}/data_path/") + builder = cli.StudyRunner(mock_db, f"{tmp_path}/data_path/") builder.clean_and_build_study( f"{Path(__file__).parent.parent}/cumulus_library/studies/core", stats_build=False, ) - table_rows = get_sorted_table_data(cursor, "core__count_encounter_month") + table_rows = conftest.get_sorted_table_data(cursor, "core__count_encounter_month") # For regenerating data if needed # with open( # f"./tests/test_data/core/core__count_encounter_month_missing_data.txt", diff --git a/tests/test_data/core/core__documentreference.txt b/tests/test_data/core/core__documentreference.txt index 36b460a9..1b65ef5e 100644 --- a/tests/test_data/core/core__documentreference.txt +++ b/tests/test_data/core/core__documentreference.txt @@ -1,102 +1,102 @@ -('351ea353-4dc6-b0a8-2a70-0e5478e8171e', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 15), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/cb8c0665-30ee-479c-8994-d29f1a6848b0', 'Encounter/1d679c3a-2765-5e13-e2a3-4bd76a898fc6', 'DocumentReference/351ea353-4dc6-b0a8-2a70-0e5478e8171e') -('351ea353-4dc6-b0a8-2a70-0e5478e8171e', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 15), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/cb8c0665-30ee-479c-8994-d29f1a6848b0', 'Encounter/1d679c3a-2765-5e13-e2a3-4bd76a898fc6', 'DocumentReference/351ea353-4dc6-b0a8-2a70-0e5478e8171e') -('36d0d49a-6346-2856-d614-3f0a1ae85685', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 21), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/f9399f0d-5401-09f3-d4ff-89b1aa51b9c8', 'Encounter/6a952afd-3be5-e27e-9e05-5a1e085e34d0', 'DocumentReference/36d0d49a-6346-2856-d614-3f0a1ae85685') -('36d0d49a-6346-2856-d614-3f0a1ae85685', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 21), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/f9399f0d-5401-09f3-d4ff-89b1aa51b9c8', 'Encounter/6a952afd-3be5-e27e-9e05-5a1e085e34d0', 'DocumentReference/36d0d49a-6346-2856-d614-3f0a1ae85685') -('37c2d2ba-1976-1167-9bf6-7eb17f3fa35f', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 13), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/8022fbbe-aaa4-056c-d0f5-ec074bf0656c', 'Encounter/e922a884-7039-a171-a65e-78051fe7afe6', 'DocumentReference/37c2d2ba-1976-1167-9bf6-7eb17f3fa35f') -('37c2d2ba-1976-1167-9bf6-7eb17f3fa35f', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 13), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/8022fbbe-aaa4-056c-d0f5-ec074bf0656c', 'Encounter/e922a884-7039-a171-a65e-78051fe7afe6', 'DocumentReference/37c2d2ba-1976-1167-9bf6-7eb17f3fa35f') -('3ebf29a1-a116-9d17-5e9a-bad0d6c2d756', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 28), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/0b052286-9534-99a8-8d5e-06c2c04a7df7', 'Encounter/e5dabcb6-1d7a-7467-dbba-b864d0d5f5b0', 'DocumentReference/3ebf29a1-a116-9d17-5e9a-bad0d6c2d756') -('3ebf29a1-a116-9d17-5e9a-bad0d6c2d756', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 28), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/0b052286-9534-99a8-8d5e-06c2c04a7df7', 'Encounter/e5dabcb6-1d7a-7467-dbba-b864d0d5f5b0', 'DocumentReference/3ebf29a1-a116-9d17-5e9a-bad0d6c2d756') -('3f0e9271-a486-797d-978a-fb2d32d37d47', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 21), datetime.date(2018, 6, 18), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/a46846ca-3f95-2cbb-3a9d-5eae150a0273', 'Encounter/5c3450fb-12f0-08f3-6e4d-8a5e433e19a4', 'DocumentReference/3f0e9271-a486-797d-978a-fb2d32d37d47') -('3f0e9271-a486-797d-978a-fb2d32d37d47', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 21), datetime.date(2018, 6, 18), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/a46846ca-3f95-2cbb-3a9d-5eae150a0273', 'Encounter/5c3450fb-12f0-08f3-6e4d-8a5e433e19a4', 'DocumentReference/3f0e9271-a486-797d-978a-fb2d32d37d47') -('3f578a1b-f50a-9333-3030-306982950658', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 13), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/3cf7af45-2bee-aa9c-d524-40b487149d60', 'Encounter/d2782687-6885-037c-957d-579fbd681d2a', 'DocumentReference/3f578a1b-f50a-9333-3030-306982950658') -('3f578a1b-f50a-9333-3030-306982950658', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 13), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/3cf7af45-2bee-aa9c-d524-40b487149d60', 'Encounter/d2782687-6885-037c-957d-579fbd681d2a', 'DocumentReference/3f578a1b-f50a-9333-3030-306982950658') -('406679b2-a02c-0003-3b17-56ba373fccff', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 21), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/0734762a-9db6-22fc-b595-c3e472bb2a9a', 'Encounter/2f55edb9-a906-0b40-e183-89b1d65d1aa1', 'DocumentReference/406679b2-a02c-0003-3b17-56ba373fccff') -('406679b2-a02c-0003-3b17-56ba373fccff', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 21), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/0734762a-9db6-22fc-b595-c3e472bb2a9a', 'Encounter/2f55edb9-a906-0b40-e183-89b1d65d1aa1', 'DocumentReference/406679b2-a02c-0003-3b17-56ba373fccff') -('41eb62dd-7032-e98d-84c6-d494ad8c877b', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, 'final', None, datetime.date(2018, 7, 31), datetime.date(2018, 7, 30), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/2a0e1946-acf6-5a7e-9399-a9cbc4730199', 'Encounter/aabb3ac3-c4a3-f613-9507-63280adb9209', 'DocumentReference/41eb62dd-7032-e98d-84c6-d494ad8c877b') -('41eb62dd-7032-e98d-84c6-d494ad8c877b', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, 'final', None, datetime.date(2018, 7, 31), datetime.date(2018, 7, 30), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/2a0e1946-acf6-5a7e-9399-a9cbc4730199', 'Encounter/aabb3ac3-c4a3-f613-9507-63280adb9209', 'DocumentReference/41eb62dd-7032-e98d-84c6-d494ad8c877b') -('4390dbd1-3bdf-e516-9fe0-a8180181507f', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, 'amended', None, datetime.date(2018, 6, 3), datetime.date(2018, 5, 28), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/e80dda2c-a260-dbf7-3167-bf0945f3a91d', 'Encounter/029d1814-d7bf-0624-524d-7ccda5f320f6', 'DocumentReference/4390dbd1-3bdf-e516-9fe0-a8180181507f') -('4390dbd1-3bdf-e516-9fe0-a8180181507f', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, 'amended', None, datetime.date(2018, 6, 3), datetime.date(2018, 5, 28), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/e80dda2c-a260-dbf7-3167-bf0945f3a91d', 'Encounter/029d1814-d7bf-0624-524d-7ccda5f320f6', 'DocumentReference/4390dbd1-3bdf-e516-9fe0-a8180181507f') -('4390dbd1-3bdf-e516-9fe0-a8180181507f-error', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, 'entered-in-error', None, datetime.date(2018, 6, 3), datetime.date(2018, 5, 28), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/e80dda2c-a260-dbf7-3167-bf0945f3a91d', 'Encounter/029d1814-d7bf-0624-524d-7ccda5f320f6', 'DocumentReference/4390dbd1-3bdf-e516-9fe0-a8180181507f-error') -('4390dbd1-3bdf-e516-9fe0-a8180181507f-error', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, 'entered-in-error', None, datetime.date(2018, 6, 3), datetime.date(2018, 5, 28), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/e80dda2c-a260-dbf7-3167-bf0945f3a91d', 'Encounter/029d1814-d7bf-0624-524d-7ccda5f320f6', 'DocumentReference/4390dbd1-3bdf-e516-9fe0-a8180181507f-error') -('4439aa6e-fbc2-21a1-208e-095907104a65', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 30), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/82b8a670-4700-30e8-24a0-b83efa3c5e0a', 'Encounter/75b68644-535d-bdc1-4c31-aa9fe7e1822f', 'DocumentReference/4439aa6e-fbc2-21a1-208e-095907104a65') -('4439aa6e-fbc2-21a1-208e-095907104a65', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 30), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/82b8a670-4700-30e8-24a0-b83efa3c5e0a', 'Encounter/75b68644-535d-bdc1-4c31-aa9fe7e1822f', 'DocumentReference/4439aa6e-fbc2-21a1-208e-095907104a65') -('45160ef5-42e8-7239-6633-904308273198', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 13), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/3627adb8-f741-acf3-2dd6-10f3bcbe1077', 'Encounter/bca7cabc-b2fc-8a08-c69b-5bc0afa20d80', 'DocumentReference/45160ef5-42e8-7239-6633-904308273198') -('45160ef5-42e8-7239-6633-904308273198', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 13), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/3627adb8-f741-acf3-2dd6-10f3bcbe1077', 'Encounter/bca7cabc-b2fc-8a08-c69b-5bc0afa20d80', 'DocumentReference/45160ef5-42e8-7239-6633-904308273198') -('4711ca43-989d-a8f9-5f32-0102640804cf', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 19), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/d3c0274f-f42b-8d2b-15f2-82331e723383', 'Encounter/6565ef5c-30b9-8697-6ca6-2b77894d5437', 'DocumentReference/4711ca43-989d-a8f9-5f32-0102640804cf') -('4711ca43-989d-a8f9-5f32-0102640804cf', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 19), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/d3c0274f-f42b-8d2b-15f2-82331e723383', 'Encounter/6565ef5c-30b9-8697-6ca6-2b77894d5437', 'DocumentReference/4711ca43-989d-a8f9-5f32-0102640804cf') -('48693636-4eec-ad3d-b71d-8f650bd0a6f1', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 7), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/c7ad408d-fcae-b54a-eb1d-26d48f7a5f84', 'Encounter/02eb4e14-1a6f-d968-2c26-c0cf5023afe0', 'DocumentReference/48693636-4eec-ad3d-b71d-8f650bd0a6f1') -('48693636-4eec-ad3d-b71d-8f650bd0a6f1', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 7), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/c7ad408d-fcae-b54a-eb1d-26d48f7a5f84', 'Encounter/02eb4e14-1a6f-d968-2c26-c0cf5023afe0', 'DocumentReference/48693636-4eec-ad3d-b71d-8f650bd0a6f1') -('48933dd8-3fcf-416e-89ca-27851e45391f', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 29), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/7cef0e6f-9aea-4079-dfc6-18a96454708e', 'Encounter/d735c414-9dd3-c9b1-285c-8da79a7fbbdf', 'DocumentReference/48933dd8-3fcf-416e-89ca-27851e45391f') -('48933dd8-3fcf-416e-89ca-27851e45391f', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 29), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/7cef0e6f-9aea-4079-dfc6-18a96454708e', 'Encounter/d735c414-9dd3-c9b1-285c-8da79a7fbbdf', 'DocumentReference/48933dd8-3fcf-416e-89ca-27851e45391f') -('4b2e99d5-d4c2-fd1f-a5fd-96fe9546b58a', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 10), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/6385ddd7-2639-6505-3789-0521b8f66c8b', 'Encounter/fd0754a4-e96d-cba7-b3c0-77697a09c86e', 'DocumentReference/4b2e99d5-d4c2-fd1f-a5fd-96fe9546b58a') -('4b2e99d5-d4c2-fd1f-a5fd-96fe9546b58a', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 10), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/6385ddd7-2639-6505-3789-0521b8f66c8b', 'Encounter/fd0754a4-e96d-cba7-b3c0-77697a09c86e', 'DocumentReference/4b2e99d5-d4c2-fd1f-a5fd-96fe9546b58a') -('99b390f4-1bcb-21ec-85d5-85cbb74e86ae', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 13), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/9eaa056b-1efc-0cc8-70ff-62c8f704cc13', 'Encounter/5c994000-aa78-2be5-e6cf-99f230d50c2f', 'DocumentReference/99b390f4-1bcb-21ec-85d5-85cbb74e86ae') -('99b390f4-1bcb-21ec-85d5-85cbb74e86ae', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 13), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/9eaa056b-1efc-0cc8-70ff-62c8f704cc13', 'Encounter/5c994000-aa78-2be5-e6cf-99f230d50c2f', 'DocumentReference/99b390f4-1bcb-21ec-85d5-85cbb74e86ae') -('99d49a34-c515-23a1-c3e4-ef73c3cef727', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 26), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/cc9fb8e2-fe52-b72a-aebb-9d10260f121b', 'Encounter/683b04eb-663a-849f-715f-4ccd70bf1524', 'DocumentReference/99d49a34-c515-23a1-c3e4-ef73c3cef727') -('99d49a34-c515-23a1-c3e4-ef73c3cef727', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 26), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/cc9fb8e2-fe52-b72a-aebb-9d10260f121b', 'Encounter/683b04eb-663a-849f-715f-4ccd70bf1524', 'DocumentReference/99d49a34-c515-23a1-c3e4-ef73c3cef727') -('99e26f8b-a5a2-ad5e-713a-16266b5991a1', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 29), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/1c498b42-61fd-6341-69c3-053f6e4fe404', 'Encounter/e613f29d-7505-6f2e-a1f5-bfbec300752d', 'DocumentReference/99e26f8b-a5a2-ad5e-713a-16266b5991a1') -('99e26f8b-a5a2-ad5e-713a-16266b5991a1', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 29), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/1c498b42-61fd-6341-69c3-053f6e4fe404', 'Encounter/e613f29d-7505-6f2e-a1f5-bfbec300752d', 'DocumentReference/99e26f8b-a5a2-ad5e-713a-16266b5991a1') -('9a50a40a-8099-5ab5-0903-1ba65d8c0905', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 14), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/24906e2c-e556-71dc-23d9-3e1d5fb08986', 'Encounter/1154d05c-8727-9373-4224-25b9fdba9ab3', 'DocumentReference/9a50a40a-8099-5ab5-0903-1ba65d8c0905') -('9a50a40a-8099-5ab5-0903-1ba65d8c0905', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 14), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/24906e2c-e556-71dc-23d9-3e1d5fb08986', 'Encounter/1154d05c-8727-9373-4224-25b9fdba9ab3', 'DocumentReference/9a50a40a-8099-5ab5-0903-1ba65d8c0905') -('9ca118c6-e354-5588-3cdc-77ee3b3c8711', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 28), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/2da1bee2-2bc2-4511-84e1-42860310e2fb', 'Encounter/d5f342b7-017c-f2e7-8697-5a038c91518e', 'DocumentReference/9ca118c6-e354-5588-3cdc-77ee3b3c8711') -('9ca118c6-e354-5588-3cdc-77ee3b3c8711', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 28), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/2da1bee2-2bc2-4511-84e1-42860310e2fb', 'Encounter/d5f342b7-017c-f2e7-8697-5a038c91518e', 'DocumentReference/9ca118c6-e354-5588-3cdc-77ee3b3c8711') -('a1b69e45-11f8-a49f-170e-32004c70e842', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 11), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/5ce2e599-fb6e-9b4d-3c2e-87310619b957', 'Encounter/4b03a408-6694-88e3-0e63-3ee464ecd6cd', 'DocumentReference/a1b69e45-11f8-a49f-170e-32004c70e842') -('a1b69e45-11f8-a49f-170e-32004c70e842', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 11), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/5ce2e599-fb6e-9b4d-3c2e-87310619b957', 'Encounter/4b03a408-6694-88e3-0e63-3ee464ecd6cd', 'DocumentReference/a1b69e45-11f8-a49f-170e-32004c70e842') -('a3964c82-0605-c2b2-97dc-0de17a1ec0ef', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 17), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/7f941bcc-e7b2-99e1-585f-129d0ef1c13d', 'Encounter/65f8fdca-a949-80a0-8072-094e9aaee474', 'DocumentReference/a3964c82-0605-c2b2-97dc-0de17a1ec0ef') -('a3964c82-0605-c2b2-97dc-0de17a1ec0ef', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 17), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/7f941bcc-e7b2-99e1-585f-129d0ef1c13d', 'Encounter/65f8fdca-a949-80a0-8072-094e9aaee474', 'DocumentReference/a3964c82-0605-c2b2-97dc-0de17a1ec0ef') -('a5231f35-ad14-580e-1888-55c1b383aa11', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 2), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/3ae095ec-8fe0-133b-36d4-8785a6ad8df3', 'Encounter/75312bd2-d5ac-c62e-c9df-0004783725c7', 'DocumentReference/a5231f35-ad14-580e-1888-55c1b383aa11') -('a5231f35-ad14-580e-1888-55c1b383aa11', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 2), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/3ae095ec-8fe0-133b-36d4-8785a6ad8df3', 'Encounter/75312bd2-d5ac-c62e-c9df-0004783725c7', 'DocumentReference/a5231f35-ad14-580e-1888-55c1b383aa11') -('a59ca653-b95d-09d2-9fa5-a1b492d85a5f', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 28), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/c20e5afd-30df-ac3d-6684-cc29438a9bc4', 'Encounter/b864bcd8-14e0-8bec-b7cc-f8629d91470e', 'DocumentReference/a59ca653-b95d-09d2-9fa5-a1b492d85a5f') -('a59ca653-b95d-09d2-9fa5-a1b492d85a5f', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 28), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/c20e5afd-30df-ac3d-6684-cc29438a9bc4', 'Encounter/b864bcd8-14e0-8bec-b7cc-f8629d91470e', 'DocumentReference/a59ca653-b95d-09d2-9fa5-a1b492d85a5f') -('a69150c5-2fbe-2284-1eb5-e11146858a22', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 1), datetime.date(2018, 5, 28), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/9c8d8539-0b1e-73e2-b64f-83f1ea601fa4', 'Encounter/f2752dd7-1bf1-739d-dd8c-40122d0b63bc', 'DocumentReference/a69150c5-2fbe-2284-1eb5-e11146858a22') -('a69150c5-2fbe-2284-1eb5-e11146858a22', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 1), datetime.date(2018, 5, 28), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/9c8d8539-0b1e-73e2-b64f-83f1ea601fa4', 'Encounter/f2752dd7-1bf1-739d-dd8c-40122d0b63bc', 'DocumentReference/a69150c5-2fbe-2284-1eb5-e11146858a22') -('a7115116-f8da-3960-e3ed-f1f0d89646c3', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 2), datetime.date(2018, 5, 28), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/8877ef1f-7cd7-3242-d7f0-73cf3f7165f4', 'Encounter/299b6495-3fe7-8db3-c494-6e1ce8b7986d', 'DocumentReference/a7115116-f8da-3960-e3ed-f1f0d89646c3') -('a7115116-f8da-3960-e3ed-f1f0d89646c3', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 2), datetime.date(2018, 5, 28), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/8877ef1f-7cd7-3242-d7f0-73cf3f7165f4', 'Encounter/299b6495-3fe7-8db3-c494-6e1ce8b7986d', 'DocumentReference/a7115116-f8da-3960-e3ed-f1f0d89646c3') -('a79da4dd-83bc-5b6a-db34-bd35b3acbd2c', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 6), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/19158de4-66a2-f70f-e3bf-4396b312c8f1', 'Encounter/ed151e04-3dd6-8cb7-a3e5-777c8a8667f1', 'DocumentReference/a79da4dd-83bc-5b6a-db34-bd35b3acbd2c') -('a79da4dd-83bc-5b6a-db34-bd35b3acbd2c', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 6), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/19158de4-66a2-f70f-e3bf-4396b312c8f1', 'Encounter/ed151e04-3dd6-8cb7-a3e5-777c8a8667f1', 'DocumentReference/a79da4dd-83bc-5b6a-db34-bd35b3acbd2c') -('a95df5ea-7005-9e98-e97a-1ade6967b585', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 16), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/16be855b-ece2-8b96-1ef9-a4d93adf3289', 'Encounter/83d0d564-3bbf-48eb-7445-bd2b81130671', 'DocumentReference/a95df5ea-7005-9e98-e97a-1ade6967b585') -('a95df5ea-7005-9e98-e97a-1ade6967b585', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 16), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/16be855b-ece2-8b96-1ef9-a4d93adf3289', 'Encounter/83d0d564-3bbf-48eb-7445-bd2b81130671', 'DocumentReference/a95df5ea-7005-9e98-e97a-1ade6967b585') -('a96ba3b7-a461-5849-1881-d372e0460ccc', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 14), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/26a3984f-b2a8-e67f-7abc-ff147a0e6e35', 'Encounter/79d8f213-7847-646b-8a66-5da208cc1c27', 'DocumentReference/a96ba3b7-a461-5849-1881-d372e0460ccc') -('a96ba3b7-a461-5849-1881-d372e0460ccc', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 14), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/26a3984f-b2a8-e67f-7abc-ff147a0e6e35', 'Encounter/79d8f213-7847-646b-8a66-5da208cc1c27', 'DocumentReference/a96ba3b7-a461-5849-1881-d372e0460ccc') -('ac0439bc-e450-d339-da6d-5ead96d8b346', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 30), datetime.date(2018, 7, 30), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/2858705f-5af1-9869-4d94-894e09a9f99a', 'Encounter/de9d67de-6ae3-32f7-20f2-e719ae23a9a3', 'DocumentReference/ac0439bc-e450-d339-da6d-5ead96d8b346') -('ac0439bc-e450-d339-da6d-5ead96d8b346', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 30), datetime.date(2018, 7, 30), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/2858705f-5af1-9869-4d94-894e09a9f99a', 'Encounter/de9d67de-6ae3-32f7-20f2-e719ae23a9a3', 'DocumentReference/ac0439bc-e450-d339-da6d-5ead96d8b346') -('ad2bee76-6e59-5d8b-21ed-b30cdb784198', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 9), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/e455ca3f-fc16-6ffc-297a-adc27e2db183', 'Encounter/98d4bd14-d78e-debb-e7dc-2df7786aedf3', 'DocumentReference/ad2bee76-6e59-5d8b-21ed-b30cdb784198') -('ad2bee76-6e59-5d8b-21ed-b30cdb784198', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 9), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/e455ca3f-fc16-6ffc-297a-adc27e2db183', 'Encounter/98d4bd14-d78e-debb-e7dc-2df7786aedf3', 'DocumentReference/ad2bee76-6e59-5d8b-21ed-b30cdb784198') -('b1f5c114-8e28-08c0-0193-0855aa10c97f', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 2), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/c7c5c028-f1fb-962b-8db2-dfd4c6d6b02a', 'Encounter/aa890974-162f-5906-dc71-2bb6d2185314', 'DocumentReference/b1f5c114-8e28-08c0-0193-0855aa10c97f') -('b1f5c114-8e28-08c0-0193-0855aa10c97f', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 2), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/c7c5c028-f1fb-962b-8db2-dfd4c6d6b02a', 'Encounter/aa890974-162f-5906-dc71-2bb6d2185314', 'DocumentReference/b1f5c114-8e28-08c0-0193-0855aa10c97f') -('b2896621-57ef-1ad3-91c5-389dce96973b', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 7), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/ac91b90d-97e4-4fc5-41cd-036bac49e6e8', 'Encounter/dc5ed645-3979-e765-3e03-6ba2173027c3', 'DocumentReference/b2896621-57ef-1ad3-91c5-389dce96973b') -('b2896621-57ef-1ad3-91c5-389dce96973b', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 7), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/ac91b90d-97e4-4fc5-41cd-036bac49e6e8', 'Encounter/dc5ed645-3979-e765-3e03-6ba2173027c3', 'DocumentReference/b2896621-57ef-1ad3-91c5-389dce96973b') -('b3357397-9f4c-7d00-06af-18f03c63d583', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 15), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/c1bfec36-dc2c-afc8-c767-3d35ed2bf6f0', 'Encounter/8ff1dc01-5a28-b2d8-3b42-4b7a7d539970', 'DocumentReference/b3357397-9f4c-7d00-06af-18f03c63d583') -('b3357397-9f4c-7d00-06af-18f03c63d583', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 15), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/c1bfec36-dc2c-afc8-c767-3d35ed2bf6f0', 'Encounter/8ff1dc01-5a28-b2d8-3b42-4b7a7d539970', 'DocumentReference/b3357397-9f4c-7d00-06af-18f03c63d583') -('b339c2e8-35eb-1838-7eea-5a04c81695df', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 14), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/267fc42d-cd9e-8527-1f9e-887fe7776147', 'Encounter/4c4d0730-201f-5b75-c657-8d0de09cc28f', 'DocumentReference/b339c2e8-35eb-1838-7eea-5a04c81695df') -('b339c2e8-35eb-1838-7eea-5a04c81695df', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 14), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/267fc42d-cd9e-8527-1f9e-887fe7776147', 'Encounter/4c4d0730-201f-5b75-c657-8d0de09cc28f', 'DocumentReference/b339c2e8-35eb-1838-7eea-5a04c81695df') -('b39532e8-ee15-a7c4-cac5-353a8be67d15', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 8), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/6a883108-7b87-120b-d163-d369336e04e5', 'Encounter/2b1ee164-6c87-420d-a9e2-6c235ebeef71', 'DocumentReference/b39532e8-ee15-a7c4-cac5-353a8be67d15') -('b39532e8-ee15-a7c4-cac5-353a8be67d15', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 8), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/6a883108-7b87-120b-d163-d369336e04e5', 'Encounter/2b1ee164-6c87-420d-a9e2-6c235ebeef71', 'DocumentReference/b39532e8-ee15-a7c4-cac5-353a8be67d15') -('b44d277c-7c09-a39b-97e9-1e96d71b6978', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 15), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/7bf52d54-0d2a-265a-15aa-eeed7aaf4af6', 'Encounter/ba84689e-2f9f-7cea-af1f-d69ffdd3a3eb', 'DocumentReference/b44d277c-7c09-a39b-97e9-1e96d71b6978') -('b44d277c-7c09-a39b-97e9-1e96d71b6978', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 15), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/7bf52d54-0d2a-265a-15aa-eeed7aaf4af6', 'Encounter/ba84689e-2f9f-7cea-af1f-d69ffdd3a3eb', 'DocumentReference/b44d277c-7c09-a39b-97e9-1e96d71b6978') -('b58f7768-64be-6c0f-1b82-3deffdef1076', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 29), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/a28be3e1-a6bd-7df4-fc81-1140848f8453', 'Encounter/91f94a9d-69a7-e30a-cd1a-68c52dc01e70', 'DocumentReference/b58f7768-64be-6c0f-1b82-3deffdef1076') -('b58f7768-64be-6c0f-1b82-3deffdef1076', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 29), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/a28be3e1-a6bd-7df4-fc81-1140848f8453', 'Encounter/91f94a9d-69a7-e30a-cd1a-68c52dc01e70', 'DocumentReference/b58f7768-64be-6c0f-1b82-3deffdef1076') -('b73493d0-e2f4-9aa6-cdad-920f7c126d6c', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 16), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/50f8b42e-17a6-e932-8546-da94004c597c', 'Encounter/37604257-be1a-120f-81ee-336f81603f92', 'DocumentReference/b73493d0-e2f4-9aa6-cdad-920f7c126d6c') -('b73493d0-e2f4-9aa6-cdad-920f7c126d6c', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 16), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/50f8b42e-17a6-e932-8546-da94004c597c', 'Encounter/37604257-be1a-120f-81ee-336f81603f92', 'DocumentReference/b73493d0-e2f4-9aa6-cdad-920f7c126d6c') -('b7b68006-53d5-b823-d193-56b262f45e8b', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 19), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/ad3ed58a-5645-af0a-eeca-ab543123a8aa', 'Encounter/03e34b19-2889-b828-792d-2a83400c55be', 'DocumentReference/b7b68006-53d5-b823-d193-56b262f45e8b') -('b7b68006-53d5-b823-d193-56b262f45e8b', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 19), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/ad3ed58a-5645-af0a-eeca-ab543123a8aa', 'Encounter/03e34b19-2889-b828-792d-2a83400c55be', 'DocumentReference/b7b68006-53d5-b823-d193-56b262f45e8b') -('b953a85f-f18b-d7a3-8974-ba44e0a3141c', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 5), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/a5bc08ea-9462-c4f5-1bd2-ff342598ac99', 'Encounter/f964be66-3fcd-95c8-0021-71c7d24c91b7', 'DocumentReference/b953a85f-f18b-d7a3-8974-ba44e0a3141c') -('b953a85f-f18b-d7a3-8974-ba44e0a3141c', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 5), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/a5bc08ea-9462-c4f5-1bd2-ff342598ac99', 'Encounter/f964be66-3fcd-95c8-0021-71c7d24c91b7', 'DocumentReference/b953a85f-f18b-d7a3-8974-ba44e0a3141c') -('b985a70c-9504-b7b3-0707-f8381ba77976', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 7), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/149de67a-2809-59a8-bfa2-36df509021dc', 'Encounter/beb26500-4ccd-ce0a-44f6-74f44be5fafe', 'DocumentReference/b985a70c-9504-b7b3-0707-f8381ba77976') -('b985a70c-9504-b7b3-0707-f8381ba77976', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 7), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/149de67a-2809-59a8-bfa2-36df509021dc', 'Encounter/beb26500-4ccd-ce0a-44f6-74f44be5fafe', 'DocumentReference/b985a70c-9504-b7b3-0707-f8381ba77976') -('ba0abbd6-49a9-95fa-2396-7118c56da8c6', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 12), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/9b17654f-a902-3d56-9000-4ade3dd3059f', 'Encounter/ca45bbef-ef2a-3b3c-ea5e-76bcd5865780', 'DocumentReference/ba0abbd6-49a9-95fa-2396-7118c56da8c6') -('ba0abbd6-49a9-95fa-2396-7118c56da8c6', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 12), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/9b17654f-a902-3d56-9000-4ade3dd3059f', 'Encounter/ca45bbef-ef2a-3b3c-ea5e-76bcd5865780', 'DocumentReference/ba0abbd6-49a9-95fa-2396-7118c56da8c6') -('bcbaa9d3-d7cf-3f5f-44d3-32c8a267f991', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 2), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/17fde357-dcc9-af8b-a8d3-4bd213afeb22', 'Encounter/32d0ae2d-1be8-9e90-a4da-4c222abd88a9', 'DocumentReference/bcbaa9d3-d7cf-3f5f-44d3-32c8a267f991') -('bcbaa9d3-d7cf-3f5f-44d3-32c8a267f991', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 2), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/17fde357-dcc9-af8b-a8d3-4bd213afeb22', 'Encounter/32d0ae2d-1be8-9e90-a4da-4c222abd88a9', 'DocumentReference/bcbaa9d3-d7cf-3f5f-44d3-32c8a267f991') -('bd60a52b-65b9-f26d-03e4-282850509f03', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 10), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/51032f44-d514-26e9-3e85-e956561c076e', 'Encounter/d73ed087-e0ae-78e0-7a05-1bac1060c476', 'DocumentReference/bd60a52b-65b9-f26d-03e4-282850509f03') -('bd60a52b-65b9-f26d-03e4-282850509f03', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 10), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/51032f44-d514-26e9-3e85-e956561c076e', 'Encounter/d73ed087-e0ae-78e0-7a05-1bac1060c476', 'DocumentReference/bd60a52b-65b9-f26d-03e4-282850509f03') -('bfddb0ff-1296-107e-76ca-14b4a14db9ce', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 2), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/26baae20-c8c5-003a-ab6b-ebcc49be20db', 'Encounter/c6ec2350-43d4-abab-2e84-4d2aadb337a7', 'DocumentReference/bfddb0ff-1296-107e-76ca-14b4a14db9ce') -('bfddb0ff-1296-107e-76ca-14b4a14db9ce', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 2), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/26baae20-c8c5-003a-ab6b-ebcc49be20db', 'Encounter/c6ec2350-43d4-abab-2e84-4d2aadb337a7', 'DocumentReference/bfddb0ff-1296-107e-76ca-14b4a14db9ce') -('c18dbe84-be31-cee5-1f2e-cf163cdd3e3f', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 27), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/a5b171a7-9b28-20e7-86a7-936ecbf55f36', 'Encounter/c4605953-3103-ede6-e0c0-e0588e6f019e', 'DocumentReference/c18dbe84-be31-cee5-1f2e-cf163cdd3e3f') -('c18dbe84-be31-cee5-1f2e-cf163cdd3e3f', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 27), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/a5b171a7-9b28-20e7-86a7-936ecbf55f36', 'Encounter/c4605953-3103-ede6-e0c0-e0588e6f019e', 'DocumentReference/c18dbe84-be31-cee5-1f2e-cf163cdd3e3f') -('c6598486-8276-b44a-286e-b376143f7efc', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 25), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/47c37c92-5932-9cfe-66be-208556780fe0', 'Encounter/b5974881-ae62-ddd6-b905-8c86c1ca9e33', 'DocumentReference/c6598486-8276-b44a-286e-b376143f7efc') -('c6598486-8276-b44a-286e-b376143f7efc', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 25), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/47c37c92-5932-9cfe-66be-208556780fe0', 'Encounter/b5974881-ae62-ddd6-b905-8c86c1ca9e33', 'DocumentReference/c6598486-8276-b44a-286e-b376143f7efc') -('c6c64129-9dfa-840d-3309-a5590cc74f2e', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 15), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/ad239efc-637c-e428-c829-b87e700d5446', 'Encounter/366df7d3-2ea9-db22-7cdd-60fa8a5c45ca', 'DocumentReference/c6c64129-9dfa-840d-3309-a5590cc74f2e') -('c6c64129-9dfa-840d-3309-a5590cc74f2e', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 15), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), None, 'Patient/ad239efc-637c-e428-c829-b87e700d5446', 'Encounter/366df7d3-2ea9-db22-7cdd-60fa8a5c45ca', 'DocumentReference/c6c64129-9dfa-840d-3309-a5590cc74f2e') -('c84e67e9-4ea8-700b-9f2b-c0179e803d4f', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 15), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/dffa62dc-8ec2-1cd6-ee75-f9156a5283fe', 'Encounter/11381dc6-0e06-da55-0735-d1e7bbf8bb35', 'DocumentReference/c84e67e9-4ea8-700b-9f2b-c0179e803d4f') -('c84e67e9-4ea8-700b-9f2b-c0179e803d4f', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 15), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), None, 'Patient/dffa62dc-8ec2-1cd6-ee75-f9156a5283fe', 'Encounter/11381dc6-0e06-da55-0735-d1e7bbf8bb35', 'DocumentReference/c84e67e9-4ea8-700b-9f2b-c0179e803d4f') +('351ea353-4dc6-b0a8-2a70-0e5478e8171e', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 15), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/cb8c0665-30ee-479c-8994-d29f1a6848b0', 'Encounter/1d679c3a-2765-5e13-e2a3-4bd76a898fc6', 'DocumentReference/351ea353-4dc6-b0a8-2a70-0e5478e8171e') +('351ea353-4dc6-b0a8-2a70-0e5478e8171e', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 15), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/cb8c0665-30ee-479c-8994-d29f1a6848b0', 'Encounter/1d679c3a-2765-5e13-e2a3-4bd76a898fc6', 'DocumentReference/351ea353-4dc6-b0a8-2a70-0e5478e8171e') +('36d0d49a-6346-2856-d614-3f0a1ae85685', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 21), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/f9399f0d-5401-09f3-d4ff-89b1aa51b9c8', 'Encounter/6a952afd-3be5-e27e-9e05-5a1e085e34d0', 'DocumentReference/36d0d49a-6346-2856-d614-3f0a1ae85685') +('36d0d49a-6346-2856-d614-3f0a1ae85685', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 21), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/f9399f0d-5401-09f3-d4ff-89b1aa51b9c8', 'Encounter/6a952afd-3be5-e27e-9e05-5a1e085e34d0', 'DocumentReference/36d0d49a-6346-2856-d614-3f0a1ae85685') +('37c2d2ba-1976-1167-9bf6-7eb17f3fa35f', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 13), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/8022fbbe-aaa4-056c-d0f5-ec074bf0656c', 'Encounter/e922a884-7039-a171-a65e-78051fe7afe6', 'DocumentReference/37c2d2ba-1976-1167-9bf6-7eb17f3fa35f') +('37c2d2ba-1976-1167-9bf6-7eb17f3fa35f', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 13), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/8022fbbe-aaa4-056c-d0f5-ec074bf0656c', 'Encounter/e922a884-7039-a171-a65e-78051fe7afe6', 'DocumentReference/37c2d2ba-1976-1167-9bf6-7eb17f3fa35f') +('3ebf29a1-a116-9d17-5e9a-bad0d6c2d756', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 28), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/0b052286-9534-99a8-8d5e-06c2c04a7df7', 'Encounter/e5dabcb6-1d7a-7467-dbba-b864d0d5f5b0', 'DocumentReference/3ebf29a1-a116-9d17-5e9a-bad0d6c2d756') +('3ebf29a1-a116-9d17-5e9a-bad0d6c2d756', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 28), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/0b052286-9534-99a8-8d5e-06c2c04a7df7', 'Encounter/e5dabcb6-1d7a-7467-dbba-b864d0d5f5b0', 'DocumentReference/3ebf29a1-a116-9d17-5e9a-bad0d6c2d756') +('3f0e9271-a486-797d-978a-fb2d32d37d47', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 21), datetime.date(2018, 6, 18), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/a46846ca-3f95-2cbb-3a9d-5eae150a0273', 'Encounter/5c3450fb-12f0-08f3-6e4d-8a5e433e19a4', 'DocumentReference/3f0e9271-a486-797d-978a-fb2d32d37d47') +('3f0e9271-a486-797d-978a-fb2d32d37d47', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 21), datetime.date(2018, 6, 18), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/a46846ca-3f95-2cbb-3a9d-5eae150a0273', 'Encounter/5c3450fb-12f0-08f3-6e4d-8a5e433e19a4', 'DocumentReference/3f0e9271-a486-797d-978a-fb2d32d37d47') +('3f578a1b-f50a-9333-3030-306982950658', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 13), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/3cf7af45-2bee-aa9c-d524-40b487149d60', 'Encounter/d2782687-6885-037c-957d-579fbd681d2a', 'DocumentReference/3f578a1b-f50a-9333-3030-306982950658') +('3f578a1b-f50a-9333-3030-306982950658', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 13), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/3cf7af45-2bee-aa9c-d524-40b487149d60', 'Encounter/d2782687-6885-037c-957d-579fbd681d2a', 'DocumentReference/3f578a1b-f50a-9333-3030-306982950658') +('406679b2-a02c-0003-3b17-56ba373fccff', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 21), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/0734762a-9db6-22fc-b595-c3e472bb2a9a', 'Encounter/2f55edb9-a906-0b40-e183-89b1d65d1aa1', 'DocumentReference/406679b2-a02c-0003-3b17-56ba373fccff') +('406679b2-a02c-0003-3b17-56ba373fccff', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 21), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/0734762a-9db6-22fc-b595-c3e472bb2a9a', 'Encounter/2f55edb9-a906-0b40-e183-89b1d65d1aa1', 'DocumentReference/406679b2-a02c-0003-3b17-56ba373fccff') +('41eb62dd-7032-e98d-84c6-d494ad8c877b', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, 'final', None, datetime.date(2018, 7, 31), datetime.date(2018, 7, 30), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/2a0e1946-acf6-5a7e-9399-a9cbc4730199', 'Encounter/aabb3ac3-c4a3-f613-9507-63280adb9209', 'DocumentReference/41eb62dd-7032-e98d-84c6-d494ad8c877b') +('41eb62dd-7032-e98d-84c6-d494ad8c877b', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, 'final', None, datetime.date(2018, 7, 31), datetime.date(2018, 7, 30), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/2a0e1946-acf6-5a7e-9399-a9cbc4730199', 'Encounter/aabb3ac3-c4a3-f613-9507-63280adb9209', 'DocumentReference/41eb62dd-7032-e98d-84c6-d494ad8c877b') +('4390dbd1-3bdf-e516-9fe0-a8180181507f', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, 'amended', None, datetime.date(2018, 6, 3), datetime.date(2018, 5, 28), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/e80dda2c-a260-dbf7-3167-bf0945f3a91d', 'Encounter/029d1814-d7bf-0624-524d-7ccda5f320f6', 'DocumentReference/4390dbd1-3bdf-e516-9fe0-a8180181507f') +('4390dbd1-3bdf-e516-9fe0-a8180181507f', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, 'amended', None, datetime.date(2018, 6, 3), datetime.date(2018, 5, 28), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/e80dda2c-a260-dbf7-3167-bf0945f3a91d', 'Encounter/029d1814-d7bf-0624-524d-7ccda5f320f6', 'DocumentReference/4390dbd1-3bdf-e516-9fe0-a8180181507f') +('4390dbd1-3bdf-e516-9fe0-a8180181507f-error', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, 'entered-in-error', None, datetime.date(2018, 6, 3), datetime.date(2018, 5, 28), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/e80dda2c-a260-dbf7-3167-bf0945f3a91d', 'Encounter/029d1814-d7bf-0624-524d-7ccda5f320f6', 'DocumentReference/4390dbd1-3bdf-e516-9fe0-a8180181507f-error') +('4390dbd1-3bdf-e516-9fe0-a8180181507f-error', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, 'entered-in-error', None, datetime.date(2018, 6, 3), datetime.date(2018, 5, 28), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/e80dda2c-a260-dbf7-3167-bf0945f3a91d', 'Encounter/029d1814-d7bf-0624-524d-7ccda5f320f6', 'DocumentReference/4390dbd1-3bdf-e516-9fe0-a8180181507f-error') +('4439aa6e-fbc2-21a1-208e-095907104a65', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 30), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/82b8a670-4700-30e8-24a0-b83efa3c5e0a', 'Encounter/75b68644-535d-bdc1-4c31-aa9fe7e1822f', 'DocumentReference/4439aa6e-fbc2-21a1-208e-095907104a65') +('4439aa6e-fbc2-21a1-208e-095907104a65', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 30), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/82b8a670-4700-30e8-24a0-b83efa3c5e0a', 'Encounter/75b68644-535d-bdc1-4c31-aa9fe7e1822f', 'DocumentReference/4439aa6e-fbc2-21a1-208e-095907104a65') +('45160ef5-42e8-7239-6633-904308273198', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 13), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/3627adb8-f741-acf3-2dd6-10f3bcbe1077', 'Encounter/bca7cabc-b2fc-8a08-c69b-5bc0afa20d80', 'DocumentReference/45160ef5-42e8-7239-6633-904308273198') +('45160ef5-42e8-7239-6633-904308273198', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 13), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/3627adb8-f741-acf3-2dd6-10f3bcbe1077', 'Encounter/bca7cabc-b2fc-8a08-c69b-5bc0afa20d80', 'DocumentReference/45160ef5-42e8-7239-6633-904308273198') +('4711ca43-989d-a8f9-5f32-0102640804cf', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 19), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/d3c0274f-f42b-8d2b-15f2-82331e723383', 'Encounter/6565ef5c-30b9-8697-6ca6-2b77894d5437', 'DocumentReference/4711ca43-989d-a8f9-5f32-0102640804cf') +('4711ca43-989d-a8f9-5f32-0102640804cf', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 19), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/d3c0274f-f42b-8d2b-15f2-82331e723383', 'Encounter/6565ef5c-30b9-8697-6ca6-2b77894d5437', 'DocumentReference/4711ca43-989d-a8f9-5f32-0102640804cf') +('48693636-4eec-ad3d-b71d-8f650bd0a6f1', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 7), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/c7ad408d-fcae-b54a-eb1d-26d48f7a5f84', 'Encounter/02eb4e14-1a6f-d968-2c26-c0cf5023afe0', 'DocumentReference/48693636-4eec-ad3d-b71d-8f650bd0a6f1') +('48693636-4eec-ad3d-b71d-8f650bd0a6f1', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 7), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/c7ad408d-fcae-b54a-eb1d-26d48f7a5f84', 'Encounter/02eb4e14-1a6f-d968-2c26-c0cf5023afe0', 'DocumentReference/48693636-4eec-ad3d-b71d-8f650bd0a6f1') +('48933dd8-3fcf-416e-89ca-27851e45391f', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 29), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/7cef0e6f-9aea-4079-dfc6-18a96454708e', 'Encounter/d735c414-9dd3-c9b1-285c-8da79a7fbbdf', 'DocumentReference/48933dd8-3fcf-416e-89ca-27851e45391f') +('48933dd8-3fcf-416e-89ca-27851e45391f', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 29), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/7cef0e6f-9aea-4079-dfc6-18a96454708e', 'Encounter/d735c414-9dd3-c9b1-285c-8da79a7fbbdf', 'DocumentReference/48933dd8-3fcf-416e-89ca-27851e45391f') +('4b2e99d5-d4c2-fd1f-a5fd-96fe9546b58a', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 10), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/6385ddd7-2639-6505-3789-0521b8f66c8b', 'Encounter/fd0754a4-e96d-cba7-b3c0-77697a09c86e', 'DocumentReference/4b2e99d5-d4c2-fd1f-a5fd-96fe9546b58a') +('4b2e99d5-d4c2-fd1f-a5fd-96fe9546b58a', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 10), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/6385ddd7-2639-6505-3789-0521b8f66c8b', 'Encounter/fd0754a4-e96d-cba7-b3c0-77697a09c86e', 'DocumentReference/4b2e99d5-d4c2-fd1f-a5fd-96fe9546b58a') +('99b390f4-1bcb-21ec-85d5-85cbb74e86ae', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 13), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/9eaa056b-1efc-0cc8-70ff-62c8f704cc13', 'Encounter/5c994000-aa78-2be5-e6cf-99f230d50c2f', 'DocumentReference/99b390f4-1bcb-21ec-85d5-85cbb74e86ae') +('99b390f4-1bcb-21ec-85d5-85cbb74e86ae', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 13), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/9eaa056b-1efc-0cc8-70ff-62c8f704cc13', 'Encounter/5c994000-aa78-2be5-e6cf-99f230d50c2f', 'DocumentReference/99b390f4-1bcb-21ec-85d5-85cbb74e86ae') +('99d49a34-c515-23a1-c3e4-ef73c3cef727', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 26), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/cc9fb8e2-fe52-b72a-aebb-9d10260f121b', 'Encounter/683b04eb-663a-849f-715f-4ccd70bf1524', 'DocumentReference/99d49a34-c515-23a1-c3e4-ef73c3cef727') +('99d49a34-c515-23a1-c3e4-ef73c3cef727', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 26), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/cc9fb8e2-fe52-b72a-aebb-9d10260f121b', 'Encounter/683b04eb-663a-849f-715f-4ccd70bf1524', 'DocumentReference/99d49a34-c515-23a1-c3e4-ef73c3cef727') +('99e26f8b-a5a2-ad5e-713a-16266b5991a1', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 29), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/1c498b42-61fd-6341-69c3-053f6e4fe404', 'Encounter/e613f29d-7505-6f2e-a1f5-bfbec300752d', 'DocumentReference/99e26f8b-a5a2-ad5e-713a-16266b5991a1') +('99e26f8b-a5a2-ad5e-713a-16266b5991a1', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 29), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/1c498b42-61fd-6341-69c3-053f6e4fe404', 'Encounter/e613f29d-7505-6f2e-a1f5-bfbec300752d', 'DocumentReference/99e26f8b-a5a2-ad5e-713a-16266b5991a1') +('9a50a40a-8099-5ab5-0903-1ba65d8c0905', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 14), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/24906e2c-e556-71dc-23d9-3e1d5fb08986', 'Encounter/1154d05c-8727-9373-4224-25b9fdba9ab3', 'DocumentReference/9a50a40a-8099-5ab5-0903-1ba65d8c0905') +('9a50a40a-8099-5ab5-0903-1ba65d8c0905', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 14), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/24906e2c-e556-71dc-23d9-3e1d5fb08986', 'Encounter/1154d05c-8727-9373-4224-25b9fdba9ab3', 'DocumentReference/9a50a40a-8099-5ab5-0903-1ba65d8c0905') +('9ca118c6-e354-5588-3cdc-77ee3b3c8711', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 28), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/2da1bee2-2bc2-4511-84e1-42860310e2fb', 'Encounter/d5f342b7-017c-f2e7-8697-5a038c91518e', 'DocumentReference/9ca118c6-e354-5588-3cdc-77ee3b3c8711') +('9ca118c6-e354-5588-3cdc-77ee3b3c8711', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 28), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/2da1bee2-2bc2-4511-84e1-42860310e2fb', 'Encounter/d5f342b7-017c-f2e7-8697-5a038c91518e', 'DocumentReference/9ca118c6-e354-5588-3cdc-77ee3b3c8711') +('a1b69e45-11f8-a49f-170e-32004c70e842', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 11), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/5ce2e599-fb6e-9b4d-3c2e-87310619b957', 'Encounter/4b03a408-6694-88e3-0e63-3ee464ecd6cd', 'DocumentReference/a1b69e45-11f8-a49f-170e-32004c70e842') +('a1b69e45-11f8-a49f-170e-32004c70e842', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 11), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/5ce2e599-fb6e-9b4d-3c2e-87310619b957', 'Encounter/4b03a408-6694-88e3-0e63-3ee464ecd6cd', 'DocumentReference/a1b69e45-11f8-a49f-170e-32004c70e842') +('a3964c82-0605-c2b2-97dc-0de17a1ec0ef', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 17), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/7f941bcc-e7b2-99e1-585f-129d0ef1c13d', 'Encounter/65f8fdca-a949-80a0-8072-094e9aaee474', 'DocumentReference/a3964c82-0605-c2b2-97dc-0de17a1ec0ef') +('a3964c82-0605-c2b2-97dc-0de17a1ec0ef', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 17), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/7f941bcc-e7b2-99e1-585f-129d0ef1c13d', 'Encounter/65f8fdca-a949-80a0-8072-094e9aaee474', 'DocumentReference/a3964c82-0605-c2b2-97dc-0de17a1ec0ef') +('a5231f35-ad14-580e-1888-55c1b383aa11', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 2), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/3ae095ec-8fe0-133b-36d4-8785a6ad8df3', 'Encounter/75312bd2-d5ac-c62e-c9df-0004783725c7', 'DocumentReference/a5231f35-ad14-580e-1888-55c1b383aa11') +('a5231f35-ad14-580e-1888-55c1b383aa11', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 2), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/3ae095ec-8fe0-133b-36d4-8785a6ad8df3', 'Encounter/75312bd2-d5ac-c62e-c9df-0004783725c7', 'DocumentReference/a5231f35-ad14-580e-1888-55c1b383aa11') +('a59ca653-b95d-09d2-9fa5-a1b492d85a5f', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 28), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/c20e5afd-30df-ac3d-6684-cc29438a9bc4', 'Encounter/b864bcd8-14e0-8bec-b7cc-f8629d91470e', 'DocumentReference/a59ca653-b95d-09d2-9fa5-a1b492d85a5f') +('a59ca653-b95d-09d2-9fa5-a1b492d85a5f', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 28), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/c20e5afd-30df-ac3d-6684-cc29438a9bc4', 'Encounter/b864bcd8-14e0-8bec-b7cc-f8629d91470e', 'DocumentReference/a59ca653-b95d-09d2-9fa5-a1b492d85a5f') +('a69150c5-2fbe-2284-1eb5-e11146858a22', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 1), datetime.date(2018, 5, 28), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/9c8d8539-0b1e-73e2-b64f-83f1ea601fa4', 'Encounter/f2752dd7-1bf1-739d-dd8c-40122d0b63bc', 'DocumentReference/a69150c5-2fbe-2284-1eb5-e11146858a22') +('a69150c5-2fbe-2284-1eb5-e11146858a22', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 1), datetime.date(2018, 5, 28), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/9c8d8539-0b1e-73e2-b64f-83f1ea601fa4', 'Encounter/f2752dd7-1bf1-739d-dd8c-40122d0b63bc', 'DocumentReference/a69150c5-2fbe-2284-1eb5-e11146858a22') +('a7115116-f8da-3960-e3ed-f1f0d89646c3', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 2), datetime.date(2018, 5, 28), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/8877ef1f-7cd7-3242-d7f0-73cf3f7165f4', 'Encounter/299b6495-3fe7-8db3-c494-6e1ce8b7986d', 'DocumentReference/a7115116-f8da-3960-e3ed-f1f0d89646c3') +('a7115116-f8da-3960-e3ed-f1f0d89646c3', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 2), datetime.date(2018, 5, 28), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/8877ef1f-7cd7-3242-d7f0-73cf3f7165f4', 'Encounter/299b6495-3fe7-8db3-c494-6e1ce8b7986d', 'DocumentReference/a7115116-f8da-3960-e3ed-f1f0d89646c3') +('a79da4dd-83bc-5b6a-db34-bd35b3acbd2c', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 6), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/19158de4-66a2-f70f-e3bf-4396b312c8f1', 'Encounter/ed151e04-3dd6-8cb7-a3e5-777c8a8667f1', 'DocumentReference/a79da4dd-83bc-5b6a-db34-bd35b3acbd2c') +('a79da4dd-83bc-5b6a-db34-bd35b3acbd2c', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 6), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/19158de4-66a2-f70f-e3bf-4396b312c8f1', 'Encounter/ed151e04-3dd6-8cb7-a3e5-777c8a8667f1', 'DocumentReference/a79da4dd-83bc-5b6a-db34-bd35b3acbd2c') +('a95df5ea-7005-9e98-e97a-1ade6967b585', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 16), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/16be855b-ece2-8b96-1ef9-a4d93adf3289', 'Encounter/83d0d564-3bbf-48eb-7445-bd2b81130671', 'DocumentReference/a95df5ea-7005-9e98-e97a-1ade6967b585') +('a95df5ea-7005-9e98-e97a-1ade6967b585', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 16), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/16be855b-ece2-8b96-1ef9-a4d93adf3289', 'Encounter/83d0d564-3bbf-48eb-7445-bd2b81130671', 'DocumentReference/a95df5ea-7005-9e98-e97a-1ade6967b585') +('a96ba3b7-a461-5849-1881-d372e0460ccc', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 14), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/26a3984f-b2a8-e67f-7abc-ff147a0e6e35', 'Encounter/79d8f213-7847-646b-8a66-5da208cc1c27', 'DocumentReference/a96ba3b7-a461-5849-1881-d372e0460ccc') +('a96ba3b7-a461-5849-1881-d372e0460ccc', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 14), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/26a3984f-b2a8-e67f-7abc-ff147a0e6e35', 'Encounter/79d8f213-7847-646b-8a66-5da208cc1c27', 'DocumentReference/a96ba3b7-a461-5849-1881-d372e0460ccc') +('ac0439bc-e450-d339-da6d-5ead96d8b346', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 30), datetime.date(2018, 7, 30), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/2858705f-5af1-9869-4d94-894e09a9f99a', 'Encounter/de9d67de-6ae3-32f7-20f2-e719ae23a9a3', 'DocumentReference/ac0439bc-e450-d339-da6d-5ead96d8b346') +('ac0439bc-e450-d339-da6d-5ead96d8b346', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 30), datetime.date(2018, 7, 30), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/2858705f-5af1-9869-4d94-894e09a9f99a', 'Encounter/de9d67de-6ae3-32f7-20f2-e719ae23a9a3', 'DocumentReference/ac0439bc-e450-d339-da6d-5ead96d8b346') +('ad2bee76-6e59-5d8b-21ed-b30cdb784198', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 9), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/e455ca3f-fc16-6ffc-297a-adc27e2db183', 'Encounter/98d4bd14-d78e-debb-e7dc-2df7786aedf3', 'DocumentReference/ad2bee76-6e59-5d8b-21ed-b30cdb784198') +('ad2bee76-6e59-5d8b-21ed-b30cdb784198', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 9), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/e455ca3f-fc16-6ffc-297a-adc27e2db183', 'Encounter/98d4bd14-d78e-debb-e7dc-2df7786aedf3', 'DocumentReference/ad2bee76-6e59-5d8b-21ed-b30cdb784198') +('b1f5c114-8e28-08c0-0193-0855aa10c97f', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 2), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/c7c5c028-f1fb-962b-8db2-dfd4c6d6b02a', 'Encounter/aa890974-162f-5906-dc71-2bb6d2185314', 'DocumentReference/b1f5c114-8e28-08c0-0193-0855aa10c97f') +('b1f5c114-8e28-08c0-0193-0855aa10c97f', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 2), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/c7c5c028-f1fb-962b-8db2-dfd4c6d6b02a', 'Encounter/aa890974-162f-5906-dc71-2bb6d2185314', 'DocumentReference/b1f5c114-8e28-08c0-0193-0855aa10c97f') +('b2896621-57ef-1ad3-91c5-389dce96973b', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 7), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/ac91b90d-97e4-4fc5-41cd-036bac49e6e8', 'Encounter/dc5ed645-3979-e765-3e03-6ba2173027c3', 'DocumentReference/b2896621-57ef-1ad3-91c5-389dce96973b') +('b2896621-57ef-1ad3-91c5-389dce96973b', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 7), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/ac91b90d-97e4-4fc5-41cd-036bac49e6e8', 'Encounter/dc5ed645-3979-e765-3e03-6ba2173027c3', 'DocumentReference/b2896621-57ef-1ad3-91c5-389dce96973b') +('b3357397-9f4c-7d00-06af-18f03c63d583', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 15), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/c1bfec36-dc2c-afc8-c767-3d35ed2bf6f0', 'Encounter/8ff1dc01-5a28-b2d8-3b42-4b7a7d539970', 'DocumentReference/b3357397-9f4c-7d00-06af-18f03c63d583') +('b3357397-9f4c-7d00-06af-18f03c63d583', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 15), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/c1bfec36-dc2c-afc8-c767-3d35ed2bf6f0', 'Encounter/8ff1dc01-5a28-b2d8-3b42-4b7a7d539970', 'DocumentReference/b3357397-9f4c-7d00-06af-18f03c63d583') +('b339c2e8-35eb-1838-7eea-5a04c81695df', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 14), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/267fc42d-cd9e-8527-1f9e-887fe7776147', 'Encounter/4c4d0730-201f-5b75-c657-8d0de09cc28f', 'DocumentReference/b339c2e8-35eb-1838-7eea-5a04c81695df') +('b339c2e8-35eb-1838-7eea-5a04c81695df', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 14), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/267fc42d-cd9e-8527-1f9e-887fe7776147', 'Encounter/4c4d0730-201f-5b75-c657-8d0de09cc28f', 'DocumentReference/b339c2e8-35eb-1838-7eea-5a04c81695df') +('b39532e8-ee15-a7c4-cac5-353a8be67d15', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 8), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/6a883108-7b87-120b-d163-d369336e04e5', 'Encounter/2b1ee164-6c87-420d-a9e2-6c235ebeef71', 'DocumentReference/b39532e8-ee15-a7c4-cac5-353a8be67d15') +('b39532e8-ee15-a7c4-cac5-353a8be67d15', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 8), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/6a883108-7b87-120b-d163-d369336e04e5', 'Encounter/2b1ee164-6c87-420d-a9e2-6c235ebeef71', 'DocumentReference/b39532e8-ee15-a7c4-cac5-353a8be67d15') +('b44d277c-7c09-a39b-97e9-1e96d71b6978', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 15), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/7bf52d54-0d2a-265a-15aa-eeed7aaf4af6', 'Encounter/ba84689e-2f9f-7cea-af1f-d69ffdd3a3eb', 'DocumentReference/b44d277c-7c09-a39b-97e9-1e96d71b6978') +('b44d277c-7c09-a39b-97e9-1e96d71b6978', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 15), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/7bf52d54-0d2a-265a-15aa-eeed7aaf4af6', 'Encounter/ba84689e-2f9f-7cea-af1f-d69ffdd3a3eb', 'DocumentReference/b44d277c-7c09-a39b-97e9-1e96d71b6978') +('b58f7768-64be-6c0f-1b82-3deffdef1076', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 29), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/a28be3e1-a6bd-7df4-fc81-1140848f8453', 'Encounter/91f94a9d-69a7-e30a-cd1a-68c52dc01e70', 'DocumentReference/b58f7768-64be-6c0f-1b82-3deffdef1076') +('b58f7768-64be-6c0f-1b82-3deffdef1076', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 29), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/a28be3e1-a6bd-7df4-fc81-1140848f8453', 'Encounter/91f94a9d-69a7-e30a-cd1a-68c52dc01e70', 'DocumentReference/b58f7768-64be-6c0f-1b82-3deffdef1076') +('b73493d0-e2f4-9aa6-cdad-920f7c126d6c', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 16), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/50f8b42e-17a6-e932-8546-da94004c597c', 'Encounter/37604257-be1a-120f-81ee-336f81603f92', 'DocumentReference/b73493d0-e2f4-9aa6-cdad-920f7c126d6c') +('b73493d0-e2f4-9aa6-cdad-920f7c126d6c', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 16), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/50f8b42e-17a6-e932-8546-da94004c597c', 'Encounter/37604257-be1a-120f-81ee-336f81603f92', 'DocumentReference/b73493d0-e2f4-9aa6-cdad-920f7c126d6c') +('b7b68006-53d5-b823-d193-56b262f45e8b', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 19), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/ad3ed58a-5645-af0a-eeca-ab543123a8aa', 'Encounter/03e34b19-2889-b828-792d-2a83400c55be', 'DocumentReference/b7b68006-53d5-b823-d193-56b262f45e8b') +('b7b68006-53d5-b823-d193-56b262f45e8b', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 19), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/ad3ed58a-5645-af0a-eeca-ab543123a8aa', 'Encounter/03e34b19-2889-b828-792d-2a83400c55be', 'DocumentReference/b7b68006-53d5-b823-d193-56b262f45e8b') +('b953a85f-f18b-d7a3-8974-ba44e0a3141c', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 5), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/a5bc08ea-9462-c4f5-1bd2-ff342598ac99', 'Encounter/f964be66-3fcd-95c8-0021-71c7d24c91b7', 'DocumentReference/b953a85f-f18b-d7a3-8974-ba44e0a3141c') +('b953a85f-f18b-d7a3-8974-ba44e0a3141c', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 5), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/a5bc08ea-9462-c4f5-1bd2-ff342598ac99', 'Encounter/f964be66-3fcd-95c8-0021-71c7d24c91b7', 'DocumentReference/b953a85f-f18b-d7a3-8974-ba44e0a3141c') +('b985a70c-9504-b7b3-0707-f8381ba77976', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 7), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/149de67a-2809-59a8-bfa2-36df509021dc', 'Encounter/beb26500-4ccd-ce0a-44f6-74f44be5fafe', 'DocumentReference/b985a70c-9504-b7b3-0707-f8381ba77976') +('b985a70c-9504-b7b3-0707-f8381ba77976', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 7), datetime.date(2018, 6, 4), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/149de67a-2809-59a8-bfa2-36df509021dc', 'Encounter/beb26500-4ccd-ce0a-44f6-74f44be5fafe', 'DocumentReference/b985a70c-9504-b7b3-0707-f8381ba77976') +('ba0abbd6-49a9-95fa-2396-7118c56da8c6', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 12), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/9b17654f-a902-3d56-9000-4ade3dd3059f', 'Encounter/ca45bbef-ef2a-3b3c-ea5e-76bcd5865780', 'DocumentReference/ba0abbd6-49a9-95fa-2396-7118c56da8c6') +('ba0abbd6-49a9-95fa-2396-7118c56da8c6', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 12), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/9b17654f-a902-3d56-9000-4ade3dd3059f', 'Encounter/ca45bbef-ef2a-3b3c-ea5e-76bcd5865780', 'DocumentReference/ba0abbd6-49a9-95fa-2396-7118c56da8c6') +('bcbaa9d3-d7cf-3f5f-44d3-32c8a267f991', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 2), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/17fde357-dcc9-af8b-a8d3-4bd213afeb22', 'Encounter/32d0ae2d-1be8-9e90-a4da-4c222abd88a9', 'DocumentReference/bcbaa9d3-d7cf-3f5f-44d3-32c8a267f991') +('bcbaa9d3-d7cf-3f5f-44d3-32c8a267f991', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 2), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/17fde357-dcc9-af8b-a8d3-4bd213afeb22', 'Encounter/32d0ae2d-1be8-9e90-a4da-4c222abd88a9', 'DocumentReference/bcbaa9d3-d7cf-3f5f-44d3-32c8a267f991') +('bd60a52b-65b9-f26d-03e4-282850509f03', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 10), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/51032f44-d514-26e9-3e85-e956561c076e', 'Encounter/d73ed087-e0ae-78e0-7a05-1bac1060c476', 'DocumentReference/bd60a52b-65b9-f26d-03e4-282850509f03') +('bd60a52b-65b9-f26d-03e4-282850509f03', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 10), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/51032f44-d514-26e9-3e85-e956561c076e', 'Encounter/d73ed087-e0ae-78e0-7a05-1bac1060c476', 'DocumentReference/bd60a52b-65b9-f26d-03e4-282850509f03') +('bfddb0ff-1296-107e-76ca-14b4a14db9ce', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 2), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/26baae20-c8c5-003a-ab6b-ebcc49be20db', 'Encounter/c6ec2350-43d4-abab-2e84-4d2aadb337a7', 'DocumentReference/bfddb0ff-1296-107e-76ca-14b4a14db9ce') +('bfddb0ff-1296-107e-76ca-14b4a14db9ce', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 2), datetime.date(2018, 7, 2), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/26baae20-c8c5-003a-ab6b-ebcc49be20db', 'Encounter/c6ec2350-43d4-abab-2e84-4d2aadb337a7', 'DocumentReference/bfddb0ff-1296-107e-76ca-14b4a14db9ce') +('c18dbe84-be31-cee5-1f2e-cf163cdd3e3f', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 27), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/a5b171a7-9b28-20e7-86a7-936ecbf55f36', 'Encounter/c4605953-3103-ede6-e0c0-e0588e6f019e', 'DocumentReference/c18dbe84-be31-cee5-1f2e-cf163cdd3e3f') +('c18dbe84-be31-cee5-1f2e-cf163cdd3e3f', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 27), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/a5b171a7-9b28-20e7-86a7-936ecbf55f36', 'Encounter/c4605953-3103-ede6-e0c0-e0588e6f019e', 'DocumentReference/c18dbe84-be31-cee5-1f2e-cf163cdd3e3f') +('c6598486-8276-b44a-286e-b376143f7efc', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 25), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/47c37c92-5932-9cfe-66be-208556780fe0', 'Encounter/b5974881-ae62-ddd6-b905-8c86c1ca9e33', 'DocumentReference/c6598486-8276-b44a-286e-b376143f7efc') +('c6598486-8276-b44a-286e-b376143f7efc', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 25), datetime.date(2018, 6, 25), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/47c37c92-5932-9cfe-66be-208556780fe0', 'Encounter/b5974881-ae62-ddd6-b905-8c86c1ca9e33', 'DocumentReference/c6598486-8276-b44a-286e-b376143f7efc') +('c6c64129-9dfa-840d-3309-a5590cc74f2e', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 6, 15), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/ad239efc-637c-e428-c829-b87e700d5446', 'Encounter/366df7d3-2ea9-db22-7cdd-60fa8a5c45ca', 'DocumentReference/c6c64129-9dfa-840d-3309-a5590cc74f2e') +('c6c64129-9dfa-840d-3309-a5590cc74f2e', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 6, 15), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/ad239efc-637c-e428-c829-b87e700d5446', 'Encounter/366df7d3-2ea9-db22-7cdd-60fa8a5c45ca', 'DocumentReference/c6c64129-9dfa-840d-3309-a5590cc74f2e') +('c84e67e9-4ea8-700b-9f2b-c0179e803d4f', 'current', '34111-5', 'http://loinc.org', 'Emergency department note', None, None, None, datetime.date(2018, 7, 15), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/dffa62dc-8ec2-1cd6-ee75-f9156a5283fe', 'Encounter/11381dc6-0e06-da55-0735-d1e7bbf8bb35', 'DocumentReference/c84e67e9-4ea8-700b-9f2b-c0179e803d4f') +('c84e67e9-4ea8-700b-9f2b-c0179e803d4f', 'current', '51847-2', 'http://loinc.org', 'Evaluation + Plan note', None, None, None, datetime.date(2018, 7, 15), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'urn:ihe:iti:xds:2017:mimeTypeSufficient', 'Patient/dffa62dc-8ec2-1cd6-ee75-f9156a5283fe', 'Encounter/11381dc6-0e06-da55-0735-d1e7bbf8bb35', 'DocumentReference/c84e67e9-4ea8-700b-9f2b-c0179e803d4f') diff --git a/tests/test_data/core/core__encounter.txt b/tests/test_data/core/core__encounter.txt index 3d1ecb30..9a65190e 100644 --- a/tests/test_data/core/core__encounter.txt +++ b/tests/test_data/core/core__encounter.txt @@ -13,7 +13,7 @@ ('4b03a408-6694-88e3-0e63-3ee464ecd6cd', 'finished', 'AMB', 'ambulatory', None, None, None, None, None, None, None, None, None, None, 73, datetime.date(2018, 7, 11), datetime.date(2018, 7, 11), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'Patient/5ce2e599-fb6e-9b4d-3c2e-87310619b957', 'Encounter/4b03a408-6694-88e3-0e63-3ee464ecd6cd', 'male', 'white', 'not hispanic or latino', '660') ('4c4d0730-201f-5b75-c657-8d0de09cc28f', 'finished', 'AMB', 'ambulatory', None, None, None, None, None, None, None, None, None, None, 60, datetime.date(2018, 6, 14), datetime.date(2018, 6, 14), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'Patient/267fc42d-cd9e-8527-1f9e-887fe7776147', 'Encounter/4c4d0730-201f-5b75-c657-8d0de09cc28f', 'female', 'white', 'not hispanic or latino', '676') ('5c3450fb-12f0-08f3-6e4d-8a5e433e19a4', 'finished', 'AMB', 'ambulatory', None, None, None, None, None, None, None, None, None, None, 46, datetime.date(2018, 6, 21), datetime.date(2018, 6, 21), datetime.date(2018, 6, 18), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'Patient/a46846ca-3f95-2cbb-3a9d-5eae150a0273', 'Encounter/5c3450fb-12f0-08f3-6e4d-8a5e433e19a4', 'female', 'white', 'not hispanic or latino', '660') -('5c994000-aa78-2be5-e6cf-99f230d50c2f', 'finished', 'AMB', 'ambulatory', None, None, None, None, None, None, None, None, None, None, 81, datetime.date(2018, 7, 13), datetime.date(2018, 7, 13), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'Patient/9eaa056b-1efc-0cc8-70ff-62c8f704cc13', 'Encounter/5c994000-aa78-2be5-e6cf-99f230d50c2f', 'male', 'white', 'not hispanic or latino', '672') +('5c994000-aa78-2be5-e6cf-99f230d50c2f', 'finished', 'AMB', 'ambulatory', None, None, None, None, None, None, None, None, '01', 'http://www.nubc.org/patient-discharge', 81, datetime.date(2018, 7, 13), datetime.date(2018, 7, 13), datetime.date(2018, 7, 9), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'Patient/9eaa056b-1efc-0cc8-70ff-62c8f704cc13', 'Encounter/5c994000-aa78-2be5-e6cf-99f230d50c2f', 'male', 'white', 'not hispanic or latino', '672') ('6565ef5c-30b9-8697-6ca6-2b77894d5437', 'finished', 'AMB', 'ambulatory', None, None, None, None, None, None, None, None, None, None, 19, datetime.date(2018, 7, 19), datetime.date(2018, 7, 19), datetime.date(2018, 7, 16), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'Patient/d3c0274f-f42b-8d2b-15f2-82331e723383', 'Encounter/6565ef5c-30b9-8697-6ca6-2b77894d5437', 'female', 'white', 'not hispanic or latino', '668') ('65f8fdca-a949-80a0-8072-094e9aaee474', 'finished', 'AMB', 'ambulatory', None, None, None, None, None, None, '10509002', 'http://snomed.info/sct', None, None, 9, datetime.date(2018, 6, 17), datetime.date(2018, 6, 17), datetime.date(2018, 6, 11), datetime.date(2018, 6, 1), datetime.date(2018, 1, 1), 'Patient/7f941bcc-e7b2-99e1-585f-129d0ef1c13d', 'Encounter/65f8fdca-a949-80a0-8072-094e9aaee474', 'female', 'white', 'not hispanic or latino', '674') ('683b04eb-663a-849f-715f-4ccd70bf1524', 'finished', 'AMB', 'ambulatory', None, None, None, None, None, None, None, None, None, None, 12, datetime.date(2018, 7, 26), datetime.date(2018, 7, 26), datetime.date(2018, 7, 23), datetime.date(2018, 7, 1), datetime.date(2018, 1, 1), 'Patient/cc9fb8e2-fe52-b72a-aebb-9d10260f121b', 'Encounter/683b04eb-663a-849f-715f-4ccd70bf1524', 'female', 'white', 'not hispanic or latino', '660') diff --git a/tests/test_data/discovery/discovery__code_sources.txt b/tests/test_data/discovery/discovery__code_sources.txt new file mode 100644 index 00000000..b96c1885 --- /dev/null +++ b/tests/test_data/discovery/discovery__code_sources.txt @@ -0,0 +1,57 @@ +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 +condition,code,33737001,Fracture of rib,http://snomed.info/sct +condition,code,368581000119106,Neuropathy due to type 2 diabetes mellitus (disorder),http://snomed.info/sct +condition,code,422650009,Social isolation (finding),http://snomed.info/sct +condition,code,424393004,Reports of violence in the environment (finding),http://snomed.info/sct +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,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,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,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,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,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 diff --git a/tests/test_data/duckdb_data/encounter/encounters.arbitrary.name.ndjson b/tests/test_data/duckdb_data/encounter/encounters.arbitrary.name.ndjson index 9102bc62..dbe364ca 100644 --- a/tests/test_data/duckdb_data/encounter/encounters.arbitrary.name.ndjson +++ b/tests/test_data/duckdb_data/encounter/encounters.arbitrary.name.ndjson @@ -1,4 +1,4 @@ -{"resourceType": "Encounter", "id": "5c994000-aa78-2be5-e6cf-99f230d50c2f", "meta": {"profile": ["http://hl7.org/fhir/us/core/StructureDefinition/us-core-encounter"]}, "identifier": [{"use": "official", "system": "https://github.com/synthetichealth/synthea", "value": "5c994000-aa78-2be5-e6cf-99f230d50c2f"}], "status": "finished", "class": {"system": "http://terminology.hl7.org/CodeSystem/v3-ActCode", "code": "AMB"}, "type": [{"coding": [{"system": "http://snomed.info/sct", "code": "185349003", "display": "Encounter for check up (procedure)"}], "text": "Encounter for check up (procedure)"}], "subject": {"reference": "Patient/9eaa056b-1efc-0cc8-70ff-62c8f704cc13", "display": "Mr. Waldo53 Amado512 Glover433"}, "participant": [{"type": [{"coding": [{"system": "http://terminology.hl7.org/CodeSystem/v3-ParticipationType", "code": "PPRF", "display": "primary performer"}], "text": "primary performer"}], "period": {"start": "2018-07-13T13:30:43-04:00", "end": "2018-07-13T13:45:43-04:00"}, "individual": {"reference": "Practitioner?identifier=http://hl7.org/fhir/sid/us-npi|9999970798", "display": "Dr. Tamra871 Kerluke267"}}], "period": {"start": "2018-07-13T13:30:43-04:00", "end": "2018-07-13T13:45:43-04:00"}, "location": [{"location": {"reference": "Location?identifier=https://github.com/synthetichealth/synthea|81846412-0624-32f7-86d8-ee6eccb07942", "display": "Wichita Vet Center"}}], "serviceProvider": {"reference": "Organization?identifier=https://github.com/synthetichealth/synthea|979603fb-1332-36b1-988f-21c2347aa1ad", "display": "Wichita Vet Center"}} +{"resourceType": "Encounter", "id": "5c994000-aa78-2be5-e6cf-99f230d50c2f", "meta": {"profile": ["http://hl7.org/fhir/us/core/StructureDefinition/us-core-encounter"]}, "identifier": [{"use": "official", "system": "https://github.com/synthetichealth/synthea", "value": "5c994000-aa78-2be5-e6cf-99f230d50c2f"}], "status": "finished", "class": {"system": "http://terminology.hl7.org/CodeSystem/v3-ActCode", "code": "AMB"}, "type": [{"coding": [{"system": "http://snomed.info/sct", "code": "185349003", "display": "Encounter for check up (procedure)"}], "text": "Encounter for check up (procedure)"}], "subject": {"reference": "Patient/9eaa056b-1efc-0cc8-70ff-62c8f704cc13", "display": "Mr. Waldo53 Amado512 Glover433"}, "participant": [{"type": [{"coding": [{"system": "http://terminology.hl7.org/CodeSystem/v3-ParticipationType", "code": "PPRF", "display": "primary performer"}], "text": "primary performer"}], "period": {"start": "2018-07-13T13:30:43-04:00", "end": "2018-07-13T13:45:43-04:00"}, "individual": {"reference": "Practitioner?identifier=http://hl7.org/fhir/sid/us-npi|9999970798", "display": "Dr. Tamra871 Kerluke267"}}], "period": {"start": "2018-07-13T13:30:43-04:00", "end": "2018-07-13T13:45:43-04:00"}, "location": [{"location": {"reference": "Location?identifier=https://github.com/synthetichealth/synthea|81846412-0624-32f7-86d8-ee6eccb07942", "display": "Wichita Vet Center"}}], "serviceProvider": {"reference": "Organization?identifier=https://github.com/synthetichealth/synthea|979603fb-1332-36b1-988f-21c2347aa1ad", "display": "Wichita Vet Center"},"hospitalization": {"dischargeDisposition": {"coding": [{"code": "01","display": "Discharged to home care or self care (routine discharge)", "system": "http://www.nubc.org/patient-discharge"}], "text": "Discharged to home care or self care (routine discharge)"},"id": "null"}} {"resourceType": "Encounter", "id": "683b04eb-663a-849f-715f-4ccd70bf1524", "meta": {"profile": ["http://hl7.org/fhir/us/core/StructureDefinition/us-core-encounter"]}, "identifier": [{"use": "official", "system": "https://github.com/synthetichealth/synthea", "value": "683b04eb-663a-849f-715f-4ccd70bf1524"}], "status": "finished", "class": {"system": "http://terminology.hl7.org/CodeSystem/v3-ActCode", "code": "AMB"}, "type": [{"coding": [{"system": "http://snomed.info/sct", "code": "410620009", "display": "Well child visit (procedure)"}], "text": "Well child visit (procedure)"}], "subject": {"reference": "Patient/cc9fb8e2-fe52-b72a-aebb-9d10260f121b", "display": "Babette571 Mignon230 Bashirian201"}, "participant": [{"type": [{"coding": [{"system": "http://terminology.hl7.org/CodeSystem/v3-ParticipationType", "code": "PPRF", "display": "primary performer"}], "text": "primary performer"}], "period": {"start": "2018-07-26T19:42:29-04:00", "end": "2018-07-26T19:57:29-04:00"}, "individual": {"reference": "Practitioner?identifier=http://hl7.org/fhir/sid/us-npi|9999932699", "display": "Dr. Julia241 Quintana711"}}], "period": {"start": "2018-07-26T19:42:29-04:00", "end": "2018-07-26T19:57:29-04:00"}, "location": [{"location": {"reference": "Location?identifier=https://github.com/synthetichealth/synthea|36b7a3c9-9190-3b4c-bb4e-b83f64b6cbdb", "display": "MAKING CONNECTIONS, LLC INDIVIDUAL AND FAMILY SERVICES"}}], "serviceProvider": {"reference": "Organization?identifier=https://github.com/synthetichealth/synthea|b59d77b5-7b57-3f7e-9a76-5e0e1ef4f62d", "display": "MAKING CONNECTIONS, LLC INDIVIDUAL AND FAMILY SERVICES"}} {"resourceType": "Encounter", "id": "e613f29d-7505-6f2e-a1f5-bfbec300752d", "meta": {"profile": ["http://hl7.org/fhir/us/core/StructureDefinition/us-core-encounter"]}, "identifier": [{"use": "official", "system": "https://github.com/synthetichealth/synthea", "value": "e613f29d-7505-6f2e-a1f5-bfbec300752d"}], "status": "finished", "class": {"system": "http://terminology.hl7.org/CodeSystem/v3-ActCode", "code": "AMB"}, "type": [{"coding": [{"system": "http://snomed.info/sct", "code": "448337001", "display": "Telemedicine consultation with patient"}], "text": "Telemedicine consultation with patient"}], "subject": {"reference": "Patient/1c498b42-61fd-6341-69c3-053f6e4fe404", "display": "Mrs. Kala987 Katlyn29 Daniel959"}, "participant": [{"type": [{"coding": [{"system": "http://terminology.hl7.org/CodeSystem/v3-ParticipationType", "code": "PPRF", "display": "primary performer"}], "text": "primary performer"}], "period": {"start": "2018-06-29T00:31:23-04:00", "end": "2018-06-29T00:46:23-04:00"}, "individual": {"reference": "Practitioner?identifier=http://hl7.org/fhir/sid/us-npi|9999896399", "display": "Dr. Tiffani287 Toy286"}}], "period": {"start": "2018-06-29T00:31:23-04:00", "end": "2018-06-29T00:46:23-04:00"}, "reasonCode": [{"coding": [{"system": "http://snomed.info/sct", "code": "88805009", "display": "Chronic congestive heart failure (disorder)"}]}], "location": [{"location": {"reference": "Location?identifier=https://github.com/synthetichealth/synthea|0b9875ba-9310-313d-93d4-bf552585d527", "display": "LIFE CARE CENTER OF BURLINGTON"}}], "serviceProvider": {"reference": "Organization?identifier=https://github.com/synthetichealth/synthea|658bfe6a-1b87-3ca3-9923-959fd4e14477", "display": "LIFE CARE CENTER OF BURLINGTON"}} {"resourceType": "Encounter", "id": "1154d05c-8727-9373-4224-25b9fdba9ab3", "meta": {"profile": ["http://hl7.org/fhir/us/core/StructureDefinition/us-core-encounter"]}, "identifier": [{"use": "official", "system": "https://github.com/synthetichealth/synthea", "value": "1154d05c-8727-9373-4224-25b9fdba9ab3"}], "status": "finished", "class": {"system": "http://terminology.hl7.org/CodeSystem/v3-ActCode", "code": "AMB"}, "type": [{"coding": [{"system": "http://snomed.info/sct", "code": "162673000", "display": "General examination of patient (procedure)"}], "text": "General examination of patient (procedure)"}], "subject": {"reference": "Patient/24906e2c-e556-71dc-23d9-3e1d5fb08986", "display": "Mrs. Sofia418 Natalia964 Armas910"}, "participant": [{"type": [{"coding": [{"system": "http://terminology.hl7.org/CodeSystem/v3-ParticipationType", "code": "PPRF", "display": "primary performer"}], "text": "primary performer"}], "period": {"start": "2018-06-14T19:21:26-04:00", "end": "2018-06-14T19:57:04-04:00"}, "individual": {"reference": "Practitioner?identifier=http://hl7.org/fhir/sid/us-npi|9999949198", "display": "Dr. Florance664 Leannon79"}}], "period": {"start": "2018-06-14T19:21:26-04:00", "end": "2018-06-14T19:57:04-04:00"}, "location": [{"location": {"reference": "Location?identifier=https://github.com/synthetichealth/synthea|b4f5949b-6d3a-342d-b7fb-53f277207a64", "display": "HOSPITAL DISTRICT NO 6 OF HARPER COUNTY KANSAS"}}], "serviceProvider": {"reference": "Organization?identifier=https://github.com/synthetichealth/synthea|e3963cc4-4b2d-3626-97d2-96cf2aaf50fe", "display": "HOSPITAL DISTRICT NO 6 OF HARPER COUNTY KANSAS"}} diff --git a/tests/test_discovery.py b/tests/test_discovery.py new file mode 100644 index 00000000..244fc8ed --- /dev/null +++ b/tests/test_discovery.py @@ -0,0 +1,64 @@ +import os +import pathlib +from unittest import mock + +from cumulus_library import cli, databases +from tests import conftest + + +@mock.patch.dict( + os.environ, + clear=True, +) +def test_discovery(tmp_path): + cli.main( + cli_args=conftest.duckdb_args( + [ + "build", + "-t", + "core", + "-s", + "./tests/test_data", + "--database", + "test", + ], + tmp_path, + ) + ) + cli.main( + cli_args=conftest.duckdb_args( + [ + "build", + "-t", + "discovery", + "-s", + "./tests/test_data", + "--database", + f"{tmp_path}/duck.db", + ], + tmp_path, + ) + ) + db = databases.DuckDatabaseBackend(f"{tmp_path}/duck.db") + cursor = db.cursor() + 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", + ) as ref: + for row in ref: + ref_row = row.rstrip().split(",") + for pos in range(0, len(ref_row)): + if ref_row[pos] == "None": + ref_row[pos] = None + assert tuple(ref_row) in table_rows diff --git a/tests/test_duckdb.py b/tests/test_duckdb.py index 2db351c7..ac67142e 100644 --- a/tests/test_duckdb.py +++ b/tests/test_duckdb.py @@ -18,40 +18,37 @@ os.environ, clear=True, ) -def test_duckdb_core_build_and_export(): +def test_duckdb_core_build_and_export(tmp_path): + print(tmp_path) data_dir = f"{Path(__file__).parent}/test_data/duckdb_data" + cli.main( + [ + "build", + "--target=core", + "--db-type=duckdb", + f"--database={tmp_path}/duck.db", + f"--load-ndjson-dir={data_dir}", + ] + ) + cli.main( + [ + "export", + "--target=core", + "--db-type=duckdb", + f"--database={tmp_path}/duck.db", + f"{tmp_path}/counts", + ] + ) - with tempfile.TemporaryDirectory() as tmpdir: - cli.main( - [ - "build", - "--target=core", - "--db-type=duckdb", - f"--database={tmpdir}/duck.db", - f"--load-ndjson-dir={data_dir}", - ] - ) - cli.main( - [ - "export", - "--target=core", - "--db-type=duckdb", - f"--database={tmpdir}/duck.db", - f"{tmpdir}/counts", - ] - ) - - # Now check each csv file - we'll assume the parquest are alright - csv_files = glob.glob(f"{tmpdir}/counts/core/*.csv") - for csv_file in csv_files: - basename = Path(csv_file).name - with open(csv_file, encoding="utf8") as f: - generated = f.read().strip() - with open( - f"{data_dir}/expected_export/core/{basename}", encoding="utf8" - ) as f: - expected = f.read().strip() - assert generated == expected, basename + # Now check each csv file - we'll assume the parquest are alright + csv_files = glob.glob(f"{tmp_path}/counts/core/*.csv") + for csv_file in csv_files: + basename = Path(csv_file).name + with open(csv_file, encoding="utf8") as f: + generated = f.read().strip() + with open(f"{data_dir}/expected_export/core/{basename}", encoding="utf8") as f: + expected = f.read().strip() + assert generated == expected, basename @pytest.mark.parametrize( diff --git a/tests/test_template_sql_utils.py b/tests/test_template_sql_utils.py index 2136cc9c..4f8be574 100644 --- a/tests/test_template_sql_utils.py +++ b/tests/test_template_sql_utils.py @@ -8,63 +8,39 @@ @pytest.mark.parametrize( - "table,base_col,expected,raises", + "table,hierarchy,expected,returns,raises", [ # coding - ("condition", "code", True, does_not_raise()), + ("condition", [("code", dict), ("coding", list)], None, True, does_not_raise()), # array coding - ("condition", "category", False, does_not_raise()), + ( + "condition", + [("category", list), ("coding", list)], + None, + True, + does_not_raise(), + ), # bare code - ("encounter", "class", False, does_not_raise()), + ( + "encounter", + [("class", dict)], + ["code", "system", "display"], + True, + does_not_raise(), + ), # non coding - ("condition", "resourcetype", False, does_not_raise()), + ("encounter", [("period", dict)], None, False, does_not_raise()), + # non coding with specific expected fields + ("encounter", [("period", dict)], ["start", "end"], True, does_not_raise()), ], ) -def test_is_codeable_concept_populated(mock_db, table, base_col, expected, raises): +def test_is_field_populated(mock_db, table, hierarchy, expected, returns, raises): with raises: - res = sql_utils.is_codeable_concept_populated( - "main", table, base_col, mock_db.cursor() + res = sql_utils.is_field_populated( + schema="main", + source_table=table, + hierarchy=hierarchy, + expected=expected, + cursor=mock_db.cursor(), ) - assert res == expected - - -@pytest.mark.parametrize( - "table,base_col,expected,raises", - [ - # coding - ("condition", "code", False, does_not_raise()), - # array coding - ("condition", "category", True, does_not_raise()), - # bare code - ("encounter", "status", False, does_not_raise()), - # non coding - ("condition", "resourcetype", False, does_not_raise()), - ], -) -def test_is_codeable_concept_array_populated( - mock_db, table, base_col, expected, raises -): - with raises: - res = sql_utils.is_codeable_concept_array_populated( - "main", table, base_col, mock_db.cursor() - ) - assert res == expected - - -@pytest.mark.parametrize( - "table,base_col,expected,raises", - [ - # coding - ("condition", "code", False, does_not_raise()), - # array coding - ("condition", "category", False, does_not_raise()), - # bare code - ("encounter", "class", True, does_not_raise()), - # non coding - ("condition", "resourcetype", False, does_not_raise()), - ], -) -def test_is_code_populated(mock_db, table, base_col, expected, raises): - with raises: - res = sql_utils.is_code_populated("main", table, base_col, mock_db.cursor()) - assert res == expected + assert res == returns diff --git a/tests/test_templates.py b/tests/test_templates.py index e4401f0a..e1f2e0fb 100644 --- a/tests/test_templates.py +++ b/tests/test_templates.py @@ -55,9 +55,8 @@ def test_codeable_concept_denormalize_all_creation(): config = sql_utils.CodeableConceptConfig( source_table="source", source_id="id", - column_name="code_col", + column_hierarchy=[("code_col", list)], target_table="target__concepts", - is_array=True, ) query = base_templates.get_codeable_concept_denormalize_query(config) assert query == expected @@ -144,9 +143,8 @@ def test_codeable_concept_denormalize_filter_creation(): config = sql_utils.CodeableConceptConfig( source_table="source", source_id="id", - column_name="code_col", + column_hierarchy=[("code_col", dict)], target_table="target__concepts", - is_array=False, filter_priority=True, code_systems=[ "http://snomed.info/sct", @@ -354,22 +352,22 @@ def test_extension_denormalize_creation(): WHERE available_priority = 1 );""" config = sql_utils.ExtensionConfig( - "source_table", - "source_id", - "target_table", - "prefix", - "fhir_extension", - ["omb", "text"], + source_table="source_table", + source_id="source_id", + target_table="target_table", + target_col_prefix="prefix", + fhir_extension="fhir_extension", + ext_systems=["omb", "text"], ) query = base_templates.get_extension_denormalize_query(config) assert query == expected config = sql_utils.ExtensionConfig( - "source_table", - "source_id", - "target_table", - "prefix", - "fhir_extension", - ["omb", "text"], + source_table="source_table", + source_id="source_id", + target_table="target_table", + target_col_prefix="prefix", + fhir_extension="fhir_extension", + ext_systems=["omb", "text"], is_array=True, ) query = base_templates.get_extension_denormalize_query(config) @@ -503,13 +501,11 @@ def test_get_code_system_pairs(): SELECT * FROM ( VALUES ( - ( - 'empty', - 'empty', - '', - '', - '' - ) + 'empty', + 'empty', + '', + '', + '' ) ) AS t (table_name, column_name, code, display, system)"""