Skip to content

Commit

Permalink
Switch _code_system to _system
Browse files Browse the repository at this point in the history
  • Loading branch information
dogversioning committed Jul 11, 2024
1 parent d9e2207 commit 3b0c769
Show file tree
Hide file tree
Showing 16 changed files with 98 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ WITH temp_condition AS (
SELECT
tc.id,
cdc.code AS category_code,
cdc.code_system AS category_code_system,
cdc.code_system AS category_system,
cdc.display AS category_display,
tc.code,
tc.code_system,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ WITH temp_documentreference AS (
)
}},
cdrt.code as type_code,
cdrt.code_system as type_code_system,
cdrt.code_system as type_system,
cdrt.display as type_display,
cdrc.code as category_code,
cdrf.code as format_code
Expand Down Expand Up @@ -75,7 +75,7 @@ SELECT DISTINCT
tdr.id,
tdr.status,
tdr.type_code,
tdr.type_code_system,
tdr.type_system,
tdr.type_display,
tdr.category_code,
tdr.docStatus,
Expand Down
24 changes: 12 additions & 12 deletions cumulus_library/studies/core/core_templates/encounter.sql.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ temp_encounter_nullable AS (
[
'status',
('class', 'code', 'class_code'),
('class', 'system', 'class_code_system'),
('class', 'system', 'class_system'),
('subject', 'reference', 'subject_ref'),
],
schema
Expand Down Expand Up @@ -69,7 +69,7 @@ temp_encounter AS (
e.id,
e.status,
e.class_code,
e.class_code_system,
e.class_system,
e.subject_ref,
e.period_start,
e.period_start_day,
Expand All @@ -78,19 +78,19 @@ temp_encounter AS (
e.period_start_month,
e.period_start_year,
edt.code AS type_code,
edt.code_system AS type_code_system,
edt.code_system AS type_system,
edt.display AS type_display,
eds.code AS serviceType_code,
eds.code_system AS serviceType_code_system,
eds.code_system AS serviceType_system,
eds.display AS serviceType_display,
edp.code AS priority_code,
edp.code_system AS priority_code_system,
edp.code_system AS priority_system,
edp.display AS priority_display,
edr.code AS reasonCode_code,
edr.code_system AS reasonCode_code_system,
edr.code_system AS reasonCode_system,
edr.display AS reasonCode_display,
edd.code AS dischargeDisposition_code,
edd.code_system AS dischargeDisposition_code_system,
edd.code_system AS dischargeDisposition_system,
edd.display AS dischargeDisposition_display

FROM temp_encounter_nullable AS e
Expand All @@ -107,19 +107,19 @@ SELECT DISTINCT
ac.code AS class_code,
ac.display AS class_display,
e.type_code,
e.type_code_system,
e.type_system,
e.type_display,
e.serviceType_code,
e.serviceType_code_system,
e.serviceType_system,
e.serviceType_display,
e.priority_code,
e.priority_code_system,
e.priority_system,
e.priority_display,
e.reasonCode_code,
e.reasonCode_code_system,
e.reasonCode_system,
e.reasonCode_display,
e.dischargeDisposition_code,
e.dischargeDisposition_code_system,
e.dischargeDisposition_system,
e.dischargeDisposition_display,
date_diff('year', date(p.birthdate), e.period_start_day) AS age_at_visit,
p.gender,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ temp_mr AS (
schema
) -}},
mrc.code AS category_code,
mrc.code_system AS category_code_system,
mrc.code_system AS category_system,
mrm.code AS medication_code,
mrm.code_system AS medication_code_system,
mrm.code_system AS medication_system,
mrm.display AS medication_display,
mrdt.dosageInstruction_text
FROM medicationrequest AS mr
Expand All @@ -76,9 +76,9 @@ SELECT
mr.status,
mr.intent,
mr.category_code,
mr.category_code_system,
mr.category_system,
mr.reportedBoolean,
mr.medication_code_system,
mr.medication_system,
mr.medication_code,
mr.medication_display,
mr.authoredOn,
Expand Down
24 changes: 12 additions & 12 deletions cumulus_library/studies/core/core_templates/observation.sql.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ WITH temp_observation AS (
('valueQuantity', 'value', 'valueQuantity_value'),
('valueQuantity', 'comparator', 'valueQuantity_comparator'),
('valueQuantity', 'unit', 'valueQuantity_unit'),
('valueQuantity', 'system', 'valueQuantity_code_system'),
('valueQuantity', 'system', 'valueQuantity_system'),
('valueQuantity', 'code', 'valueQuantity_code'),
],
schema
Expand All @@ -41,17 +41,17 @@ WITH temp_observation AS (
)
}},
odc.code AS observation_code,
odc.code_system AS observation_code_system,
odc.code_system AS observation_system,
odcat.code AS category_code,
odcat.code_system AS category_code_system,
odcat.code_system AS category_system,
odi.code AS interpretation_code,
odi.code_system AS interpretation_code_system,
odi.code_system AS interpretation_system,
odi.display AS interpretation_display,
odvcc.code AS valueCodeableConcept_code,
odvcc.code_system AS valueCodeableConcept_code_system,
odvcc.code_system AS valueCodeableConcept_system,
odvcc.display AS valueCodeableConcept_display,
odda.code AS dataAbsentReason_code,
odda.code_system AS dataAbsentReason_code_system,
odda.code_system AS dataAbsentReason_system,
odda.display AS dataAbsentReason_display
FROM observation AS o
LEFT JOIN core__observation_dn_category AS odcat ON o.id = odcat.id
Expand All @@ -64,28 +64,28 @@ WITH temp_observation AS (
SELECT
id,
category_code,
category_code_system,
category_system,
status,
observation_code,
observation_code_system,
observation_system,
interpretation_code,
interpretation_code_system,
interpretation_system,
interpretation_display,
effectiveDateTime_day,
effectiveDateTime_week,
effectiveDateTime_month,
effectiveDateTime_year,
valueCodeableConcept_code,
valueCodeableConcept_code_system,
valueCodeableConcept_system,
valueCodeableConcept_display,
valueQuantity_value,
valueQuantity_comparator,
valueQuantity_unit,
valueQuantity_code_system,
valueQuantity_system,
valueQuantity_code,
valueString,
dataAbsentReason_code,
dataAbsentReason_code_system,
dataAbsentReason_system,
dataAbsentReason_display,
subject_ref,
encounter_ref,
Expand Down
20 changes: 10 additions & 10 deletions cumulus_library/studies/core/observation_type.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ CREATE TABLE core__observation_lab AS
SELECT
co.id,
co.observation_code,
co.observation_code_system,
co.observation_system,
co.category_code,
co.category_code_system,
co.category_system,
co.valueCodeableConcept_code,
co.valueCodeableConcept_code_system,
co.valueCodeableConcept_system,
co.valueCodeableConcept_display,
co.effectiveDateTime_day,
co.effectiveDateTime_week,
Expand All @@ -24,27 +24,27 @@ FROM
core__observation AS co
WHERE
co.category_code = 'laboratory'
AND co.category_code_system
AND co.category_system
= 'http://terminology.hl7.org/CodeSystem/observation-category';

CREATE TABLE core__observation_vital_signs AS
SELECT
co.id,
co.observation_code,
co.observation_code_system,
co.observation_system,
co.category_code,
co.category_code_system,
co.category_system,
co.valueCodeableConcept_code,
co.valueCodeableConcept_code_system,
co.valueCodeableConcept_system,
co.valueCodeableConcept_display,
co.valueQuantity_value,
co.valueQuantity_comparator,
co.valueQuantity_unit,
co.valueQuantity_code_system,
co.valueQuantity_system,
co.valueQuantity_code,
co.status,
co.interpretation_code,
co.interpretation_code_system,
co.interpretation_system,
co.interpretation_display,
co.effectiveDateTime_day,
co.effectiveDateTime_week,
Expand All @@ -57,5 +57,5 @@ FROM
core__observation AS co
WHERE
co.category_code = 'vital-signs'
AND co.category_code_system
AND co.category_system
= 'http://terminology.hl7.org/CodeSystem/observation-category';
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ WITH temp_condition AS (
SELECT
tc.id,
cdc.code AS category_code,
cdc.code_system AS category_code_system,
cdc.code_system AS category_system,
cdc.display AS category_display,
tc.code,
tc.code_system,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ WITH temp_documentreference AS (
date_trunc('year', date(from_iso8601_timestamp(dr."context"."period"."start")))
AS author_year,
cdrt.code as type_code,
cdrt.code_system as type_code_system,
cdrt.code_system as type_system,
cdrt.display as type_display,
cdrc.code as category_code,
cdrf.code as format_code
Expand All @@ -201,7 +201,7 @@ SELECT DISTINCT
tdr.id,
tdr.status,
tdr.type_code,
tdr.type_code_system,
tdr.type_system,
tdr.type_display,
tdr.category_code,
tdr.docStatus,
Expand Down
24 changes: 12 additions & 12 deletions cumulus_library/studies/core/reference_sql/builder_encounter.sql
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ temp_encounter_nullable AS (
e.id,
e.status,
e.class.code AS class_code,
e.class.system AS class_code_system,
e.class.system AS class_system,
e.subject.reference AS subject_ref,
date(from_iso8601_timestamp(e.period.start)) AS period_start,
date_trunc('day', date(from_iso8601_timestamp(e."period"."end")))
Expand All @@ -638,7 +638,7 @@ temp_encounter AS (
e.id,
e.status,
e.class_code,
e.class_code_system,
e.class_system,
e.subject_ref,
e.period_start,
e.period_start_day,
Expand All @@ -647,19 +647,19 @@ temp_encounter AS (
e.period_start_month,
e.period_start_year,
edt.code AS type_code,
edt.code_system AS type_code_system,
edt.code_system AS type_system,
edt.display AS type_display,
eds.code AS serviceType_code,
eds.code_system AS serviceType_code_system,
eds.code_system AS serviceType_system,
eds.display AS serviceType_display,
edp.code AS priority_code,
edp.code_system AS priority_code_system,
edp.code_system AS priority_system,
edp.display AS priority_display,
edr.code AS reasonCode_code,
edr.code_system AS reasonCode_code_system,
edr.code_system AS reasonCode_system,
edr.display AS reasonCode_display,
edd.code AS dischargeDisposition_code,
edd.code_system AS dischargeDisposition_code_system,
edd.code_system AS dischargeDisposition_system,
edd.display AS dischargeDisposition_display

FROM temp_encounter_nullable AS e
Expand All @@ -676,19 +676,19 @@ SELECT DISTINCT
ac.code AS class_code,
ac.display AS class_display,
e.type_code,
e.type_code_system,
e.type_system,
e.type_display,
e.serviceType_code,
e.serviceType_code_system,
e.serviceType_system,
e.serviceType_display,
e.priority_code,
e.priority_code_system,
e.priority_system,
e.priority_display,
e.reasonCode_code,
e.reasonCode_code_system,
e.reasonCode_system,
e.reasonCode_display,
e.dischargeDisposition_code,
e.dischargeDisposition_code_system,
e.dischargeDisposition_system,
e.dischargeDisposition_display,
date_diff('year', date(p.birthdate), e.period_start_day) AS age_at_visit,
p.gender,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ temp_mr AS (
mr.subject.reference AS subject_ref,
mr.encounter.reference AS encounter_ref,
mrc.code AS category_code,
mrc.code_system AS category_code_system,
mrc.code_system AS category_system,
mrm.code AS medication_code,
mrm.code_system AS medication_code_system,
mrm.code_system AS medication_system,
mrm.display AS medication_display,
mrdt.dosageInstruction_text
FROM medicationrequest AS mr
Expand All @@ -99,9 +99,9 @@ SELECT
mr.status,
mr.intent,
mr.category_code,
mr.category_code_system,
mr.category_system,
mr.reportedBoolean,
mr.medication_code_system,
mr.medication_system,
mr.medication_code,
mr.medication_display,
mr.authoredOn,
Expand Down
Loading

0 comments on commit 3b0c769

Please sign in to comment.