From d35b17ac976fe6fd17cd13240fbc0dce73990074 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Thu, 3 Oct 2024 14:44:56 -0400 Subject: [PATCH] core: drop 2016 cutoff from core tables --- .../core/core_templates/allergyintolerance.sql.jinja | 3 +-- .../studies/core/core_templates/condition.sql.jinja | 3 +-- .../core/core_templates/documentreference.sql.jinja | 3 +-- .../studies/core/core_templates/encounter.sql.jinja | 4 +--- .../studies/core/core_templates/observation.sql.jinja | 6 +----- tests/core/test_core_allergy.py | 11 ----------- 6 files changed, 5 insertions(+), 25 deletions(-) diff --git a/cumulus_library/studies/core/core_templates/allergyintolerance.sql.jinja b/cumulus_library/studies/core/core_templates/allergyintolerance.sql.jinja index b657aab..a40d761 100644 --- a/cumulus_library/studies/core/core_templates/allergyintolerance.sql.jinja +++ b/cumulus_library/studies/core/core_templates/allergyintolerance.sql.jinja @@ -134,5 +134,4 @@ LEFT JOIN core__allergyintolerance_dn_code AS dn_code ON ta.id = dn_code.id LEFT JOIN core__allergyintolerance_dn_clinical_status AS dn_cstat ON ta.id = dn_cstat.id LEFT JOIN core__allergyintolerance_dn_verification_status AS dn_vstat ON ta.id = dn_vstat.id -LEFT JOIN temp_category AS tcat ON ta.id = tcat.id -WHERE ta.recordedDate BETWEEN date('2016-01-01') AND current_date; +LEFT JOIN temp_category AS tcat ON ta.id = tcat.id; diff --git a/cumulus_library/studies/core/core_templates/condition.sql.jinja b/cumulus_library/studies/core/core_templates/condition.sql.jinja index b28130b..54541d5 100644 --- a/cumulus_library/studies/core/core_templates/condition.sql.jinja +++ b/cumulus_library/studies/core/core_templates/condition.sql.jinja @@ -80,5 +80,4 @@ SELECT FROM temp_condition AS tc LEFT JOIN core__condition_dn_category AS cdc ON tc.id = cdc.id LEFT JOIN core__condition_dn_clinical_status AS cdcs ON tc.id = cdcs.id -LEFT JOIN core__condition_dn_verification_status AS cdvs ON tc.id = cdvs.id -WHERE tc.recordedDate BETWEEN date('2016-01-01') AND current_date; +LEFT JOIN core__condition_dn_verification_status AS cdvs ON tc.id = cdvs.id; diff --git a/cumulus_library/studies/core/core_templates/documentreference.sql.jinja b/cumulus_library/studies/core/core_templates/documentreference.sql.jinja index 51d9bcd..205bdca 100644 --- a/cumulus_library/studies/core/core_templates/documentreference.sql.jinja +++ b/cumulus_library/studies/core/core_templates/documentreference.sql.jinja @@ -89,5 +89,4 @@ SELECT DISTINCT te.encounter_ref, concat('DocumentReference/', tdr.id) AS documentreference_ref FROM temp_documentreference AS tdr -LEFT JOIN temp_encounters AS te ON tdr.id = te.id -WHERE date(tdr.author_day) BETWEEN date('2016-06-01') AND current_date; +LEFT JOIN temp_encounters AS te ON tdr.id = te.id; diff --git a/cumulus_library/studies/core/core_templates/encounter.sql.jinja b/cumulus_library/studies/core/core_templates/encounter.sql.jinja index 850a550..389b646 100644 --- a/cumulus_library/studies/core/core_templates/encounter.sql.jinja +++ b/cumulus_library/studies/core/core_templates/encounter.sql.jinja @@ -137,6 +137,4 @@ FROM temp_encounter AS e LEFT JOIN core__fhir_mapping_expected_act_encounter_code_v3 AS eac ON e.class_code = eac.found LEFT JOIN core__fhir_act_encounter_code_v3 AS ac ON eac.expected = ac.code -INNER JOIN core__patient AS p ON e.subject_ref = p.subject_ref -WHERE - e.period_start_day BETWEEN date('2016-06-01') AND current_date; +INNER JOIN core__patient AS p ON e.subject_ref = p.subject_ref; diff --git a/cumulus_library/studies/core/core_templates/observation.sql.jinja b/cumulus_library/studies/core/core_templates/observation.sql.jinja index 4887593..502c451 100644 --- a/cumulus_library/studies/core/core_templates/observation.sql.jinja +++ b/cumulus_library/studies/core/core_templates/observation.sql.jinja @@ -90,8 +90,4 @@ SELECT subject_ref, encounter_ref, concat('Observation/', id) AS observation_ref -FROM temp_observation -WHERE - effectiveDateTime_day BETWEEN date( - from_iso8601_timestamp('2016-06-01') - ) AND current_date; +FROM temp_observation; diff --git a/tests/core/test_core_allergy.py b/tests/core/test_core_allergy.py index 47e726a..e1102bf 100644 --- a/tests/core/test_core_allergy.py +++ b/tests/core/test_core_allergy.py @@ -229,17 +229,6 @@ def test_core_allergy_many_cases(tmp_path): assert expected_set == dict_set_from_list(rows) -def test_core_allergy_date_cutoff(tmp_path): - """Verify that we ignore rows before 2016""" - testbed = testbed_utils.LocalTestbed(tmp_path) - testbed.add_allergy_intolerance("Old", recorded="2015") - testbed.add_allergy_intolerance("New", recorded="2016") - - con = testbed.build() - df = con.sql("SELECT id FROM core__allergyintolerance").df() - assert ["New"] == list(df.id) - - @mock.patch("cumulus_library.builders.counts.DEFAULT_MIN_SUBJECT", new=1) def test_core_count_allergy_intolerance_by_patient(tmp_path): """Verify that our basic allergy count is per-patient"""