Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v2 cutover
Browse files Browse the repository at this point in the history
dogversioning committed Apr 3, 2024
1 parent 368507d commit 1ffb869
Showing 7 changed files with 949 additions and 297 deletions.
7 changes: 3 additions & 4 deletions cumulus_library_covid/covid_symptom/counts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from cumulus_library.schema.counts import CountsBuilder
from cumulus_library.statistics.counts import CountsBuilder


class CovidCountsBuilder(CountsBuilder):
@@ -98,7 +98,7 @@ def count_symptom(self, duration="week"):
]
return self.count_encounter(view_name, from_table, cols)

def prepare_queries(self, cursor=None, schema=None):
def prepare_queries(self, cursor=None, schema=None, **kwargs):
self.queries = [
self.count_dx("month"),
self.count_dx("week"),
@@ -112,7 +112,6 @@ def prepare_queries(self, cursor=None, schema=None):
self.count_prevalence_ed("week"),
]


if __name__ == "__main__":
builder = CovidCountsBuilder()
builder.write_counts(f"{Path(__file__).resolve().parent}/counts.sql")
builder.write_counts(f"{Path(__file__).resolve().parent}/counts.sql")
1,193 changes: 923 additions & 270 deletions cumulus_library_covid/covid_symptom/counts.sql

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions cumulus_library_covid/covid_symptom/table_dx.sql
Original file line number Diff line number Diff line change
@@ -21,9 +21,9 @@ SELECT DISTINCT
c.encounter_ref,
s.status,
c.code AS cond_code, -- noqa: LT01,RF02
c.recorded_week AS cond_week,
c.recorded_month AS cond_month,
c.recorded_year AS cond_year,
c.recordeddate_week AS cond_week,
c.recordeddate_month AS cond_month,
c.recordeddate_year AS cond_year,
s.enc_class_display,
s.age_at_visit,
s.ed_note,
14 changes: 7 additions & 7 deletions cumulus_library_covid/covid_symptom/table_pcr.sql
Original file line number Diff line number Diff line change
@@ -24,10 +24,10 @@ WITH obs_interpret AS (

SELECT DISTINCT
obs_interpret.display AS covid_pcr_result_display,
o.lab_code AS covid_pcr_code,
o.lab_date AS covid_pcr_date,
o.lab_week AS covid_pcr_week,
o.lab_month AS covid_pcr_month,
o.observation_code AS covid_pcr_code,
o.effectivedatetime_day AS covid_pcr_date,
o.effectivedatetime_week AS covid_pcr_week,
o.effectivedatetime_month AS covid_pcr_month,
s.status,
s.variant_era,
s.author_date,
@@ -51,9 +51,9 @@ FROM core__observation_lab AS o,
WHERE
(s.encounter_ref = o.encounter_ref)
AND (s.variant_era = p.variant_era)
AND (o.lab_week BETWEEN p.variant_start AND p.variant_end)
AND (o.lab_code.code = pcr.code)
AND (o.lab_result.code = obs_interpret.code);
AND (o.effectivedatetime_week BETWEEN p.variant_start AND p.variant_end)
AND (o.observation_code = pcr.code)
AND (o.valuecodeableconcept_code = obs_interpret.code);

-- TODO Cerner specific handling of lab RESULT
-- https://github.com/smart-on-fhir/cumulus-library-covid/issues/13
16 changes: 8 additions & 8 deletions cumulus_library_covid/covid_symptom/table_study_period.sql
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
CREATE TABLE covid_symptom__study_period AS
SELECT DISTINCT
v.variant_era,
s.start_date,
s.start_week,
s.start_month,
s.end_date,
s.period_start_day as start_date,
s.period_start_week as start_week,
s.period_start_month as start_month,
s.period_end_day as end_date,
s.age_at_visit,
s.author_date,
s.author_day as author_date,
s.author_week,
s.author_month,
s.author_year,
s.gender,
s.race_display,
s.subject_ref,
s.encounter_ref,
s.doc_ref,
s.documentreference_ref,
s.diff_enc_note_days,
s.enc_class_code,
s.enc_class_display,
@@ -29,8 +29,8 @@ FROM core__study_period AS s,
WHERE
s.age_at_visit = a.age
AND s.gender IN ('female', 'male')
AND s.author_date BETWEEN v.variant_start AND v.variant_end
AND s.start_date BETWEEN v.variant_start AND v.variant_end
AND s.author_day BETWEEN v.variant_start AND v.variant_end
AND s.period_start_day BETWEEN v.variant_start AND v.variant_end
AND s.diff_enc_note_days BETWEEN -30 AND 30;

CREATE TABLE covid_symptom__meta_date AS
4 changes: 2 additions & 2 deletions cumulus_library_covid/covid_symptom/table_symptom.sql
Original file line number Diff line number Diff line change
@@ -43,8 +43,8 @@ SELECT DISTINCT
s.encounter_ref,
m.docref_id,
def.pref AS symptom_display,
s.start_date AS start_date,
s.end_date AS end_date,
s.start_date,
s.end_date,
s.author_week,
s.author_month,
s.age_group,
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[project]
name = "cumulus-library-covid"
requires-python = ">= 3.9"
version = "0.2.2"
version = "1.0.0"
dependencies = [
"cumulus-library >= 1.4.0, <2",
"sqlfluff == 2.0.2"
"cumulus-library >= 2.0, <3",
"sqlfluff >= 3"
]
description = "SQL generation for cumulus covid symptom analysis"
readme = "README.md"

0 comments on commit 1ffb869

Please sign in to comment.