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

Achieve backward-compatibility with PostgreSQL 9.4 (old Miracum i2b2 Deployment)

parent c9436f3e
......@@ -17,6 +17,7 @@
-- - Initial support for resource type "Consent"
-- - Note: Implementation of "Immunization" and "Consent" useless, as-is. TODO
-- 2021-01-28: - Reimplementation of "Condition" resource processing to make it compatible with GECCO modeling
-- 2021-01-29: - Achieve backward-compatibility with PostgreSQL 9.4 (old Miracum i2b2 Deployment)
-- ============= Create Basic Tables =============
......@@ -373,7 +374,8 @@ begin
from (
with FhirTempTable(fhir2) AS (select fhir)
select
jsonb_path_query(fhir2, '$.id')->>0 as ID,
--jsonb_path_query(fhir2, '$.id')->>0 as ID,
(fhir2->>'id')::text as ID,
OnsetDateTime,
CodeCodingCode,
CodeCodingSystem,
......@@ -384,14 +386,20 @@ begin
from FhirTempTable
left join (select (fhir2->>'onsetDateTime')::timestamp as OnsetDateTime
from FhirTempTable) as sq1 on true
left join (select jsonb_path_query(fhir2, '$.code.coding.code')->>0 as CodeCodingCode,
jsonb_path_query(fhir2, '$.code.coding.system')->>0 as CodeCodingSystem
left join (select jsonb_array_elements(fhir->'code'->'coding')->>'code' as CodeCodingCode,
jsonb_array_elements(fhir->'code'->'coding')->>'system' as CodeCodingSystem
--jsonb_path_query(fhir2, '$.code.coding.code')->>0 as CodeCodingCode,
--jsonb_path_query(fhir2, '$.code.coding.system')->>0 as CodeCodingSystem
from FhirTempTable) as sq2 on true
left join (select jsonb_path_query(fhir2, '$.verificationStatus.coding.code')->>0 as VerificationStatusCodingCode,
jsonb_path_query(fhir2, '$.verificationStatus.coding.system')->>0 as VerificationStatusCodingSystem
left join (select jsonb_array_elements(fhir->'verificationStatus'->'coding')->>'code' as VerificationStatusCodingCode,
jsonb_array_elements(fhir->'verificationStatus'->'coding')->>'system' as VerificationStatusCodingSystem
--jsonb_path_query(fhir2, '$.verificationStatus.coding.code')->>0 as VerificationStatusCodingCode,
--jsonb_path_query(fhir2, '$.verificationStatus.coding.system')->>0 as VerificationStatusCodingSystem
from FhirTempTable) as sq3 on true
left join (select jsonb_path_query(fhir2, '$.extension.valueCodeableConcept.coding.code')->>0 as ExtensionValueCodeableConceptCodingCode,
jsonb_path_query(fhir2, '$.extension.valueCodeableConcept.coding.system')->>0 as ExtensionValueCodeableConceptCodingSystem
left join (select jsonb_array_elements(jsonb_array_elements(fhir->'extension')->'valueCodeableConcept'->'coding')->>'code' as ExtensionValueCodeableConceptCodingCode,
jsonb_array_elements(jsonb_array_elements(fhir->'extension')->'valueCodeableConcept'->'coding')->>'system' as ExtensionValueCodeableConceptCodingSystem
--jsonb_path_query(fhir2, '$.extension.valueCodeableConcept.coding.code')->>0 as ExtensionValueCodeableConceptCodingCode,
--jsonb_path_query(fhir2, '$.extension.valueCodeableConcept.coding.system')->>0 as ExtensionValueCodeableConceptCodingSystem
from FhirTempTable) as sq4 on true
) fhir_data;
end if;
......
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