Skip to content

Commit

Permalink
towards better support of PCR tests and results in different coding s…
Browse files Browse the repository at this point in the history
…ystems and EHR support.

#8
#13
  • Loading branch information
comorbidity committed Jun 21, 2023
1 parent 0ad2470 commit 051fff3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
15 changes: 15 additions & 0 deletions cumulus_library_covid/covid_symptom/define_pcr_custom.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- http://hl7.org/fhir/R4/v3/ObservationInterpretation/cs.html#v3-ObservationInterpretation-ObservationInterpretationDetection
--
--code=POS
-- display=Positive
-- A presence finding of the specified component / analyte, organism or clinical sign based on the established threshold of the performed test or procedure.
--code=NEG
-- display=Negative
-- An absence finding of the specified component / analyte, organism or clinical sign based on the established threshold of the performed test or procedure.

create or replace view covid_symptom__define_pcr_custom as select * from (values
('http://cumulus.smarthealthit.org', 'Negative', 'Negative', 'http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation', 'NEG', 'Negative')
,('http://cumulus.smarthealthit.org', 'NEGATIVE', 'NEGATIVE', 'http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation', 'NEG', 'Negative')
,('http://cumulus.smarthealthit.org', 'Positive', 'Positive', 'http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation', 'POS', 'Positive')
,('http://cumulus.smarthealthit.org', 'POSITIVE', 'POSITIVE', 'http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation', 'POS', 'Positive')
) AS t (from_system, from_code, from_display, system, code, display);
30 changes: 15 additions & 15 deletions cumulus_library_covid/covid_symptom/table_pcr.sql
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
-- ############################################################################
-- Table COVID19 PCR tests for COVID performed at the local hospital
-- **Likely does not include PCR tests from other healthcare settings**
--
-- Study Period: @core_study_period_covid
-- PCR Test Codes: @covid_define_pcr, @map_lab_code

CREATE TABLE covid_symptom__pcr AS
WITH obs_interpret AS
(
select system,code, 'Negative' as display from covid_symptom__define_pcr_negative
UNION
select system,code, 'Positive' as display from covid_symptom__define_pcr_positive
UNION
select from_system, from_code as code, display from covid_symptom__define_pcr_custom
)
SELECT DISTINCT
upper(o.lab_result.display) AS covid_pcr_result_display,
o.lab_result AS covid_pcr_result,
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,
Expand All @@ -28,19 +31,16 @@ SELECT DISTINCT
o.encounter_ref,
o.observation_ref
FROM core__observation_lab AS o,
covid_symptom__define_pcr AS pcr,
covid_symptom__define_period AS p,
covid_symptom__site_pcr,
covid_symptom__study_period AS s
covid_symptom__study_period AS s,
covid_symptom__define_pcr AS pcr,
obs_interpret
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 IN (
'260385009', 'Negative', 'NEGATIVE',
'10828004', 'Positive', 'POSITIVE'
));
AND (o.lab_result.code = obs_interpret.code);

-- # TODO i2b2 specific lab result codes are hardcoded, should be covid_symptom__define_pcr
-- https://github.com/smart-on-fhir/cumulus-etl/issues/231
-- TODO Cerner specific handling of lab RESULT
-- https://github.com/smart-on-fhir/cumulus-library-covid/issues/13

0 comments on commit 051fff3

Please sign in to comment.