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

For start_date and end_date, instead of now(), use '-infinity'::timestamptz if...

For start_date and end_date, instead of now(), use '-infinity'::timestamptz if no timestamp could be determined
parent aa359371
......@@ -18,6 +18,7 @@
-- - 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)
-- - For start_date and end_date, instead of now(), use '-infinity'::timestamptz if no timestamp could be determined
-- ============= Create Basic Tables =============
......@@ -344,7 +345,7 @@ begin
i2b2miracum.get_system_abbrv(fhir_data.CodeCodingSystem) || ':' || fhir_data.CodeCodingCode, -- concept_cd
'FHIR', -- provider_id
case when fhir_data.OnsetDateTime is not null then fhir_data.OnsetDateTime
else now()
else '-infinity'::timestamptz
end, -- start_date
case when fhir_data.VerificationStatusCodingSystem is not null
then i2b2miracum.get_system_abbrv(fhir_data.VerificationStatusCodingSystem) || ':' || fhir_data.VerificationStatusCodingCode
......@@ -360,7 +361,7 @@ begin
null, -- quantity_num
null, -- units_cd
case when fhir_data.OnsetDateTime is not null then fhir_data.OnsetDateTime
else now()
else '-infinity'::timestamptz
end, -- end_date
'', -- location_cd
FHIR_id, -- observation_blob
......@@ -384,7 +385,7 @@ begin
ExtensionValueCodeableConceptCodingCode,
ExtensionValueCodeableConceptCodingSystem
from FhirTempTable
left join (select (fhir2->>'onsetDateTime')::timestamp as OnsetDateTime
left join (select (fhir2->>'recordedDate')::timestamp as OnsetDateTime
from FhirTempTable) as sq1 on true
left join (select jsonb_array_elements(fhir->'code'->'coding')->>'code' as CodeCodingCode,
jsonb_array_elements(fhir->'code'->'coding')->>'system' as CodeCodingSystem
......@@ -418,7 +419,7 @@ begin
i2b2miracum.get_system_abbrv(fhir_data.system) || ':' || fhir_data.code, -- concept_cd
'FHIR', -- provider_id
case when fhir_data.effectiveDateTime is not null then fhir_data.effectiveDateTime
else now() end, -- start_date
else '-infinity'::timestamptz end, -- start_date
'@', -- modifier_cd
nextval('instance_num_seq'), -- instance_num
'N', -- valtype_cd
......@@ -428,7 +429,7 @@ begin
1, -- quantity_num
fhir_data.valueQuantity_unit, -- units_cd
case when fhir_data.effectiveDateTime is not null then fhir_data.effectiveDateTime
else now() end, -- end_date
else '-infinity'::timestamptz end, -- end_date
'', -- location_cd
FHIR_id, -- observation_blob
0, -- confidence_num
......@@ -463,7 +464,7 @@ begin
i2b2miracum.get_system_abbrv(fhir_data.system) || ':' || fhir_data.code, -- concept_cd
'FHIR', -- provider_id
case when fhir_data.effectiveDateTime is not null then fhir_data.effectiveDateTime
else now() end, -- start_date
else '-infinity'::timestamptz end, -- start_date
'@', -- modifier_cd
nextval('instance_num_seq'), -- instance_num
'N', -- valtype_cd
......@@ -473,7 +474,7 @@ begin
1, -- quantity_num
null, -- units_cd
case when fhir_data.effectiveDateTime is not null then fhir_data.effectiveDateTime
else now() end, -- end_date
else '-infinity'::timestamptz end, -- end_date
'', -- location_cd
FHIR_id, -- observation_blob
0, -- confidence_num
......@@ -508,7 +509,7 @@ begin
i2b2miracum.get_system_abbrv(fhir_data.system) || ':' || fhir_data.code, -- concept_cd
'FHIR', -- provider_id
case when fhir_data.effectiveDateTime is not null then fhir_data.effectiveDateTime
else now() end, -- start_date
else '-infinity'::timestamptz end, -- start_date
'@', -- modifier_cd
nextval('instance_num_seq'), -- instance_num
'N', -- valtype_cd
......@@ -518,7 +519,7 @@ begin
1, -- quantity_num
null, -- units_cd
case when fhir_data.effectiveDateTime is not null then fhir_data.effectiveDateTime
else now() end, -- end_date
else '-infinity'::timestamptz end, -- end_date
'', -- location_cd
FHIR_id, -- observation_blob
0, -- confidence_num
......@@ -553,7 +554,7 @@ begin
i2b2miracum.get_system_abbrv(fhir_data.system) || ':' || fhir_data.code, -- concept_cd
'FHIR', -- provider_id
case when fhir_data.performedDateTime is not null then fhir_data.performedDateTime
else now() end, -- start_date
else '-infinity'::timestamptz end, -- start_date
'@', -- modifier_cd
nextval('instance_num_seq'), -- instance_num
'@', -- valtype_cd
......@@ -563,7 +564,7 @@ begin
null, -- quantity_num
null, -- units_cd
case when fhir_data.performedDateTime is not null then fhir_data.performedDateTime
else now() end, -- end_date
else '-infinity'::timestamptz end, -- end_date
'', -- location_cd
FHIR_id, -- observation_blob
0, -- confidence_num
......@@ -656,7 +657,7 @@ begin
end,
'FHIR', -- provider_id
case when fhir_data.effectiveDateTime is not null then fhir_data.effectiveDateTime
else now() end, -- start_date
else '-infinity'::timestamptz end, -- start_date
'@', -- modifier_cd
nextval('instance_num_seq'), -- instance_num
'@', -- valtype_cd
......@@ -666,7 +667,7 @@ begin
null, -- quantity_num
null, -- units_cd
case when fhir_data.effectiveDateTime is not null then fhir_data.effectiveDateTime
else now() end, -- end_date
else '-infinity'::timestamptz end, -- end_date
'', -- location_cd
FHIR_id, -- observation_blob
0, -- confidence_num
......
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