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

Update "Consent"

Update docu
parent 1a79355d
......@@ -11,8 +11,8 @@ The SQL Trigger is aware of or processes the following FHIR resource types and a
* Encounter OK
* Condition OK
* Observation OK
* Immunization
* Consent
* Immunization OK
* Consent OK
* Procedure OK
* Medication
* MedicationStatement
......@@ -21,7 +21,10 @@ The SQL Trigger is aware of or processes the following FHIR resource types and a
## Implementation Details
In general, `code.coding.code` and `code.coding.system` are used to generate the i2b2 concept code.
General:
* `code.coding.code` and `code.coding.system` are used to generate the i2b2 concept code.
* If no timestamp can be found in the data, the PostgreSQL function call `'-infinity'::timestamptz` is used to generate a dummy date, which is "292269055-12-03 00:00:00".
### Patient
......@@ -110,7 +113,7 @@ Timestamps are derived from:
* `performedDateTime`
The following fields are used to generate i2b2 modifiers:
The following fields are used to generate i2b2 concept codes:
* `protocolApplied.targetDisease.coding.system` and `protocolApplied.targetDisease.coding.code`
......@@ -124,6 +127,20 @@ It does not yet process the fields:
* `category`
### Consent
Timestamps are derived from:
* `effectiveDateTime`
The following fields are used to generate i2b2 concept codes:
* `category.coding.system` and `category.coding.code`
The following fields are used to generate i2b2 modifiers:
* `provision.code.coding.system` and `provision.code.coding.code`
......@@ -24,6 +24,7 @@
-- 2021-02-01: - Add support for "bodySite" field in "Procedure" ressource
-- - Implementation of support for "DiagnosticReport" resource
-- - Implementation of support for "Immunization" resource
-- - Update implementation for "Consent" resource
-- ============= Create Basic Tables =============
......@@ -105,6 +106,7 @@ begin
when systemlink = 'http://fdasis.nlm.nih.gov' then return 'FDASIS';
when systemlink = 'http://dicom.nema.org/resources/ontology/DCM' then return 'DCM';
when systemlink = 'http://terminology.hl7.org/CodeSystem/condition-ver-status' then return 'CVS';
when systemlink = 'http://terminology.hl7.org/CodeSystem/consentcategorycodes' then return 'CCC';
else
perform i2b2miracum.fhir_elt_log('ERROR: Coding system unknown: ' || systemlink);
return 'UNKNOWN';
......@@ -557,11 +559,14 @@ 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
i2b2miracum.get_system_abbrv(fhir_data.system) || ':' || fhir_data.code, -- concept_cd
i2b2miracum.get_system_abbrv(fhir_data.category_coding_system) || ':' || fhir_data.category_coding_code, -- concept_cd
'FHIR', -- provider_id
case when fhir_data.effectiveDateTime is not null then fhir_data.effectiveDateTime
else '-infinity'::timestamptz end, -- start_date
'@', -- modifier_cd
case when fhir_data.provision_code_coding_system is not null
then i2b2miracum.get_system_abbrv(fhir_data.provision_code_coding_system) || ':' || fhir_data.provision_code_coding_code
else '@'
end, -- modifier_cd
nextval('instance_num_seq'), -- instance_num
'N', -- valtype_cd
'E', -- tval_char
......@@ -580,15 +585,26 @@ begin
FHIR_sourcesystem, -- sourcesystem_cd
1, -- upload_id
nextval('instance_num_seq') -- text_search_index
from (SELECT
jsonb_array_elements(fhir->'provision'->'code'->'coding')->>'code' as code,
jsonb_array_elements(fhir->'provision'->'code'->'coding')->>'system' as system,
(fhir->>'effectiveDateTime')::timestamp as effectiveDateTime,
(fhir->'valueQuantity'->>'value')::numeric(18,5) as valueQuantity_value--,
--fhir->'valueQuantity'->>'unit'::text as valueQuantity_unit,
--fhir->'valueQuantity'->>'system'::text as valueQuantity_system,
--fhir->'valueQuantity'->>'code'::text as valueQuantity_code
) fhir_data;
from (
with FhirTempTable(fhir2) AS (select fhir)
select
--jsonb_path_query(fhir2, '$.id')->>0 as ID,
(fhir2->>'id')::text as ID,
effectiveDateTime,
category_coding_code,
category_coding_system,
provision_code_coding_code,
provision_code_coding_system
from FhirTempTable
left join (select (fhir2->>'effectiveDateTime')::timestamp as effectiveDateTime
from FhirTempTable) as sq1 on true
left join (select jsonb_array_elements(jsonb_array_elements(fhir->'category')->'coding')->>'code' as category_coding_code,
jsonb_array_elements(jsonb_array_elements(fhir->'category')->'coding')->>'system' as category_coding_system
from FhirTempTable) as sq2 on true
left join (select jsonb_array_elements(jsonb_array_elements(fhir->'provision'->'code')->'coding')->>'code' as provision_code_coding_code,
jsonb_array_elements(jsonb_array_elements(fhir->'provision'->'code')->'coding')->>'system' as provision_code_coding_system
from FhirTempTable) as sq3 on true
) fhir_data;
end if;
--
-- *** Handle FHIR PROCEDURE resource ***
......
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