Skip to content

Commit

Permalink
Update transform for birth measurements
Browse files Browse the repository at this point in the history
  • Loading branch information
burrowse committed Sep 7, 2021
1 parent 1b79131 commit 31b7b27
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
2 changes: 2 additions & 0 deletions v4.3_to_v6.0/sql_etl/data/concept_map.csv
Original file line number Diff line number Diff line change
Expand Up @@ -6786,3 +6786,5 @@ result_qual_source,TRACE,Trace,,Trace,
result_qual_source,TRACE,Trace,,TRACE,
result_qual_source,URINE,Urine,,Urine,
result_qual_source,URINE,Urine,,URINE,
Birth Measures,'8339-4','Birth weight Measured',3013762,'Birth weight Measured',
Birth Measures,'89269-5','Birth height Measured',3023540,'Birth height Measured',
23 changes: 12 additions & 11 deletions v4.3_to_v6.0/sql_etl/scripts/etl_scripts/l_vitals.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ create table SITE_pcornet.ms_ht as
(
select distinct person_id, 'SITE' as site, measurement_id,visit_occurrence_id, measurement_date, measurement_datetime, value_as_number
, measurement_concept_id,measurement_source_value, provider_id,operator_concept_id, unit_concept_id, unit_source_value, value_as_concept_id,
value_source_value
value_source_value,measurement_type_concept_id
from SITE_pedsnet.measurement
where measurement_concept_id = '3023540'
);
Expand All @@ -33,7 +33,7 @@ create table SITE_pcornet.ms_wt as
(
select person_id, 'SITE' as site, measurement_id,visit_occurrence_id, measurement_date, measurement_datetime, value_as_number
, measurement_concept_id,measurement_source_value, provider_id,operator_concept_id, unit_concept_id, unit_source_value, value_as_concept_id,
value_source_value
value_source_value,measurement_type_concept_id
from SITE_pedsnet.measurement
where measurement_concept_id = '3013762'
);
Expand All @@ -55,7 +55,7 @@ create table SITE_pcornet.ms_bmi as
(
select distinct person_id, 'SITE' as site, measurement_id,visit_occurrence_id, provider_id, value_as_concept_id,
measurement_date, measurement_datetime, value_as_number, measurement_concept_id,measurement_source_value,operator_concept_id, unit_concept_id, unit_source_value,
value_source_value
value_source_value,measurement_type_concept_id
from SITE_pedsnet.measurement
where measurement_concept_id = '3038553'
);
Expand All @@ -76,7 +76,7 @@ create table SITE_pcornet.ms_sys as
(
select distinct person_id, 'SITE' as site, measurement_id, visit_occurrence_id, provider_id, value_as_concept_id,
measurement_date, measurement_datetime, value_as_number, measurement_concept_id,measurement_source_value,operator_concept_id, unit_concept_id, unit_source_value,
value_source_value
value_source_value,measurement_type_concept_id
from SITE_pedsnet.measurement
where measurement_concept_id in ('3018586','3035856','3009395','3004249')
);
Expand All @@ -98,7 +98,7 @@ create table SITE_pcornet.ms_dia as
select distinct person_id, 'SITE' as site, measurement_id, provider_id, value_as_concept_id,
visit_occurrence_id, measurement_date, measurement_datetime, value_as_number,
measurement_concept_id,measurement_source_value,operator_concept_id, unit_concept_id, unit_source_value,
value_source_value
value_source_value,measurement_type_concept_id
from SITE_pedsnet.measurement
where measurement_concept_id in ('3034703','3019962','3013940','3012888')
);
Expand All @@ -118,23 +118,23 @@ commit;
begin;
create table SITE_pcornet.ms as
select person_id, site, measurement_id, visit_occurrence_id, value_as_concept_id, measurement_date, measurement_datetime, value_as_number, measurement_concept_id, measurement_source_value, provider_id,operator_concept_id, unit_concept_id, unit_source_value,
value_source_value
value_source_value,measurement_type_concept_id
from SITE_pcornet.ms_ht
UNION
select person_id, site, measurement_id, visit_occurrence_id, value_as_concept_id, measurement_date, measurement_datetime, value_as_number, measurement_concept_id, measurement_source_value, provider_id,operator_concept_id, unit_concept_id, unit_source_value,
value_source_value
value_source_value,measurement_type_concept_id
from SITE_pcornet.ms_wt
UNION
select person_id, site, measurement_id, visit_occurrence_id, value_as_concept_id, measurement_date, measurement_datetime, value_as_number, measurement_concept_id, measurement_source_value, provider_id,operator_concept_id, unit_concept_id, unit_source_value,
value_source_value
value_source_value,measurement_type_concept_id
from SITE_pcornet.ms_bmi
UNION
select person_id, site, measurement_id, visit_occurrence_id, value_as_concept_id, measurement_date, measurement_datetime, value_as_number, measurement_concept_id, measurement_source_value, provider_id,operator_concept_id, unit_concept_id, unit_source_value,
value_source_value
value_source_value,measurement_type_concept_id
from SITE_pcornet.ms_sys
UNION
select person_id, site, measurement_id, visit_occurrence_id, value_as_concept_id, measurement_date, measurement_datetime, value_as_number, measurement_concept_id, measurement_source_value, provider_id,operator_concept_id, unit_concept_id, unit_source_value,
value_source_value
value_source_value,measurement_type_concept_id
from SITE_pcornet.ms_dia;
commit;

Expand Down Expand Up @@ -240,7 +240,8 @@ and ms.measurement_datetime = ms_ht.measurement_datetime
left join SITE_pcornet.ms_wt on ms.visit_occurrence_id = ms_wt.visit_occurrence_id
and ms.measurement_datetime = ms_wt.measurement_datetime
left join SITE_pcornet.ms_bmi on ms.visit_occurrence_id = ms_bmi.visit_occurrence_id
and ms.measurement_datetime = ms_bmi.measurement_datetime;
and ms.measurement_datetime = ms_bmi.measurement_datetime
;
commit;

begin;
Expand Down
13 changes: 11 additions & 2 deletions v4.3_to_v6.0/sql_etl/scripts/etl_scripts/n_obs_clin.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ INSERT INTO SITE_pcornet.obs_clin(encounterid, obsclin_code, obsclin_abn_ind, ob
obsclin_result_unit, obsclin_source, obsclin_start_time, obsclin_type, obsclinid, patid, raw_obsclin_code, raw_obsclin_modifier, raw_obsclin_name, raw_obsclin_result, raw_obsclin_type,
raw_obsclin_unit, obsclin_stop_date, obsclin_stop_time,site)
select distinct on (obsclinid) ms.visit_occurrence_id::int as encounterid,
coalesce(code.concept_code, null) as obsclin_code,
case
when measurement_type_concept_id = 44818704
then birth_meas.target_concept
else coalesce(code.concept_code, null)
end as obsclin_code,
coalesce(abn.target_concept, 'NI') as obsclin_abn_ind,
ms.measurement_date as obsclin_start_date,
ms.provider_id as obsclin_providerid,
Expand All @@ -36,7 +40,11 @@ LPAD(date_part('hour',ms.measurement_datetime)::text,2,'0')||':'||LPAD(date_part
person_id::text as patid,
coalesce(code.concept_code,'NI') as raw_obsclin_code,
null as raw_obsclin_modifier,
code.concept_name as raw_obsclin_name,
case
when measurement_type_concept_id = 44818704
then birth_meas.concept_description
else code.concept_name
end as raw_obsclin_name,
ms.value_as_number::text as raw_obsclin_result,
code.vocabulary_id as raw_obsclin_type,
ms.unit_source_value as raw_obsclin_unit,
Expand All @@ -45,6 +53,7 @@ null as obsclin_stop_time,
ms.site as site
from SITE_pcornet.ms
left join vocabulary.concept code on code.concept_id = ms.measurement_concept_id and code.vocabulary_id = 'LOINC'
left join pcornet_maps.pedsnet_pcornet_valueset_map birth_meas on birth_meas.source_concept_id=ms.measurement_concept_id and birth_meas.source_concept_class = 'Birth Measures'
left join pcornet_maps.pedsnet_pcornet_valueset_map modif on modif.source_concept_id = ms.operator_concept_id::text and modif.source_concept_class = 'Result modifier'
left join pcornet_maps.pedsnet_pcornet_valueset_map unit on unit.source_concept_id = ms.unit_concept_id::text and unit.source_concept_class in ('Dose unit','Result unit')
Left join pcornet_maps.pedsnet_pcornet_valueset_map abn on abn.source_concept_id::int = ms.value_as_concept_id and abn.source_concept_class = 'abnormal_indicator'
Expand Down

0 comments on commit 31b7b27

Please sign in to comment.