Commit 1a79355d authored by Sebastian Mate's avatar Sebastian Mate
Browse files

Update subquery of Patient

parent 41ba994c
......@@ -284,15 +284,25 @@ begin
now(), -- import_date
FHIR_sourcesystem, -- sourcesystem_cd
1 -- upload_id
from (SELECT
jsonb_array_elements(fhir->'code'->'coding')->>'code' as age,
--jsonb_array_elements(fhir->'code'->'coding')->>'system' as system,
--(fhir->>'onsetDateTime')::timestamp as onsetDateTime
(fhir->>'deceasedDateTime')::timestamp as deceasedDateTime,
(fhir->>'birthDate')::timestamp as birthDate,
(fhir->>'gender')::text as gender,
jsonb_array_elements(fhir->'address')->>'postalCode' as address_postalCode -- zip_cd
) fhir_data;
from (
with FhirTempTable(fhir2) AS (select fhir)
--jsonb_path_query(fhir2, '$.id')->>0 as ID,
(fhir2->>'id')::text as ID,
from FhirTempTable
left join (select (fhir2->>'birthDate')::timestamp as birthDate
from FhirTempTable) as sq1 on true
left join (select (fhir2->>'deceasedDateTime')::timestamp as deceasedDateTime
from FhirTempTable) as sq2 on true
left join (select (fhir2->>'gender')::text as gender
from FhirTempTable) as sq3 on true
left join (select jsonb_array_elements(fhir2->'address')->>'postalCode' as address_postalCode
from FhirTempTable) as sq4 on true
) fhir_data;
end if;
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