Commit d5c87e45 authored by Sebastian Mate's avatar Sebastian Mate
Browse files

Update all coding systems

parent e6501735
......@@ -10,6 +10,7 @@
-- 2021-01-25: - Initial basic support for FHIR bundles
-- - Improved readout of Patient resource
-- 2021-01-26: - Recognize SNOMED-CT entries
-- - Update all coding systems
-- ============= Create Basic Tables =============
......@@ -88,7 +89,7 @@ declare
i record;
begin
--
perform i2b2miracum.fhir_elt_log('Incoming FHIR: ' || new.fhir::text);
perform i2b2miracum.fhir_elt_log('--- Incoming FHIR: ' || new.fhir::text);
--
if json_extract_path_text(new.fhir::json, 'resourceType') = 'Bundle' then
--for i in select * from jsonb_array_elements(new.fhir->'entry')
......@@ -298,7 +299,10 @@ begin
select i2b2_encounter_identifier, -- encounter_num
i2b2_patient_identifier, -- patient_num
case when fhir_data.system = 'http://fhir.de/CodeSystem/dimdi/icd-10-gm' then 'ICD10'
when fhir_data.system = 'http://snomed.info/sct' then 'SNOMED-CT'
when fhir_data.system = 'http://fhir.de/CodeSystem/dimdi/ops' then 'OPS'
when fhir_data.system = 'http://fhir.de/CodeSystem/dimdi/atc' then 'ATC'
when fhir_data.system = 'http://snomed.info/sct' then 'SNOMED-CT'
when fhir_data.system = 'http://loinc.org' then 'LOINC'
else 'UNKNOWN'
end || ':' || fhir_data.code, -- concept_cd
'FHIR', -- provider_id
......@@ -343,11 +347,16 @@ begin
insert into i2b2miracum.observation_fact (encounter_num, patient_num, concept_cd, provider_id, start_date, modifier_cd, instance_num, valtype_cd, tval_char, nval_num, valueflag_cd, quantity_num, units_cd, end_date, location_cd, observation_blob, confidence_num, update_date, download_date, import_date, sourcesystem_cd, upload_id, text_search_index)
select i2b2_encounter_identifier, -- encounter_num
i2b2_patient_identifier, -- patient_num
case when fhir_data.system = 'http://loinc.org' then 'LOINC'
case when fhir_data.system = 'http://fhir.de/CodeSystem/dimdi/icd-10-gm' then 'ICD10'
when fhir_data.system = 'http://fhir.de/CodeSystem/dimdi/ops' then 'OPS'
when fhir_data.system = 'http://fhir.de/CodeSystem/dimdi/atc' then 'ATC'
when fhir_data.system = 'http://snomed.info/sct' then 'SNOMED-CT'
when fhir_data.system = 'http://loinc.org' then 'LOINC'
else 'UNKNOWN'
end || ':' || fhir_data.code, -- concept_cd
'FHIR', -- provider_id
fhir_data.effectiveDateTime, -- start_date
case when fhir_data.effectiveDateTime is not null then fhir_data.effectiveDateTime
else now() end, -- start_date
'@', -- modifier_cd
nextval('instance_num_seq'), -- instance_num
'N', -- valtype_cd
......@@ -356,7 +365,8 @@ begin
'', -- valueflag_cd
1, -- quantity_num
fhir_data.valueQuantity_unit, -- units_cd
fhir_data.effectiveDateTime, -- end_date
case when fhir_data.effectiveDateTime is not null then fhir_data.effectiveDateTime
else now() end, -- end_date
'', -- location_cd
FHIR_id, -- observation_blob
0, -- confidence_num
......@@ -388,7 +398,11 @@ begin
insert into i2b2miracum.observation_fact (encounter_num, patient_num, concept_cd, provider_id, start_date, modifier_cd, instance_num, valtype_cd, tval_char, nval_num, valueflag_cd, quantity_num, units_cd, end_date, location_cd, observation_blob, confidence_num, update_date, download_date, import_date, sourcesystem_cd, upload_id, text_search_index)
select i2b2_encounter_identifier, -- encounter_num
i2b2_patient_identifier, -- patient_num
case when fhir_data.system = 'http://fhir.de/CodeSystem/dimdi/ops' then 'OPS'
case when fhir_data.system = 'http://fhir.de/CodeSystem/dimdi/icd-10-gm' then 'ICD10'
when fhir_data.system = 'http://fhir.de/CodeSystem/dimdi/ops' then 'OPS'
when fhir_data.system = 'http://fhir.de/CodeSystem/dimdi/atc' then 'ATC'
when fhir_data.system = 'http://snomed.info/sct' then 'SNOMED-CT'
when fhir_data.system = 'http://loinc.org' then 'LOINC'
else 'UNKNOWN'
end || ':' || fhir_data.code, -- concept_cd
'FHIR', -- provider_id
......@@ -443,9 +457,13 @@ begin
insert into i2b2miracum.observation_fact (
select oft.encounter_num,
oft.patient_num,
case when fm.system = 'http://fhir.de/CodeSystem/dimdi/atc' then 'ATC'
else 'UNKNOWN'
end || ':' || fm.code, -- concept_cd
case when fm.system = 'http://fhir.de/CodeSystem/dimdi/icd-10-gm' then 'ICD10'
when fm.system = 'http://fhir.de/CodeSystem/dimdi/ops' then 'OPS'
when fm.system = 'http://fhir.de/CodeSystem/dimdi/atc' then 'ATC'
when fm.system = 'http://snomed.info/sct' then 'SNOMED-CT'
when fm.system = 'http://loinc.org' then 'LOINC'
else 'UNKNOWN'
end || ':' || fhir_data.code, -- concept_cd
oft.provider_id,
oft.start_date,
oft.modifier_cd,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment