Skip to content

Commit

Permalink
Merge pull request #125 from OHDSI/premier-observation-upd
Browse files Browse the repository at this point in the history
Remove admission and discharge info from Observation
  • Loading branch information
bradanton authored Nov 4, 2024
2 parents def935d + 670e8c2 commit 4789786
Showing 1 changed file with 157 additions and 190 deletions.
Original file line number Diff line number Diff line change
@@ -1,129 +1,130 @@
<QueryDefinition>
<Query>
select
cast(pat.medrec_key as bigint) as medrec_key,
pat.pat_key,
adm_date,
disc_date,
case lower(pat.gender)
when 'u' then NULL
else pat.gender
end as gender,
case lower(pat.race)
when 'w' then 8527
when 'b' then 8516
when 'a' then 8515
else 0
end as race_concept_id,
case
when lower(hispanic_ind) = 'y' then 38003563
when lower(pat.race) = 'h' then 38003563
when lower(hispanic_ind) = 'n' then 38003564
else 0
end as ethnicity_concept_id,
pat.race as race_source_value,
hispanic_ind as ethnicity_source_value,
case
when pat.point_of_origin = '7' and lower(pat.i_o_ind) = 'o' then 9203
when pat.point_of_origin = '7' and lower(pat.i_o_ind) = 'i' then 262
when lower(pat.i_o_ind) = 'i' then 9201
when lower(pat.i_o_ind) = 'o' then 9202
end as place_of_service_concept_id,
CASE
WHEN lower(pat.i_o_ind)='i' then 1
ELSE 0
END as contains_weight,
pat.i_o_ind,
pat.disc_status,
CASE
WHEN pat.disc_status IN (20, 40, 41, 42) THEN 1
ELSE 0
END as died,
ds.disc_status_desc,
po.point_of_origin_desc,
pat.mart_status,
pat.adm_phy,
pat.prov_id,
pat.age,
32880 PeriodTypeConceptId,
pat.pat_charges,
pat_type_desc,
31 as observation_period_gap,
CASE
WHEN pat.POINT_OF_ORIGIN = '0' then 8976
WHEN pat.POINT_OF_ORIGIN = '1' then 8844
WHEN pat.POINT_OF_ORIGIN = '2' then 8716
WHEN pat.POINT_OF_ORIGIN = '3' then 8844
WHEN pat.POINT_OF_ORIGIN = '4' then 8717
WHEN pat.POINT_OF_ORIGIN = '5' then 8863
WHEN pat.POINT_OF_ORIGIN = '6' then 8844
WHEN pat.POINT_OF_ORIGIN = '7' then 8870
WHEN pat.POINT_OF_ORIGIN = '8' then 8844
WHEN pat.POINT_OF_ORIGIN = '9' then 8844
WHEN pat.POINT_OF_ORIGIN = '45' then 581384
WHEN pat.POINT_OF_ORIGIN = '46' then 8650
WHEN lower(pat.POINT_OF_ORIGIN) = 'a' then 8761
WHEN lower(pat.POINT_OF_ORIGIN) = 'b' then 8536
WHEN lower(pat.POINT_OF_ORIGIN) = 'c' then 8536
WHEN lower(pat.POINT_OF_ORIGIN) = 'd' then 8717
WHEN lower(pat.POINT_OF_ORIGIN) = 'e' then 8883
WHEN lower(pat.POINT_OF_ORIGIN) = 'f' then 8546
END as ADMITTING_SOURCE_CONCEPT_ID,
CASE pat.DISC_STATUS
when 1 then 8536
when 2 then 8844
when 3 then 8863
when 4 then 8863
when 5 then 8844
when 6 then 8536
when 7 then 8844
when 8 then 8536
when 9 then 8717
when 20 then NULL
when 21 then 8844
when 30 then 8844
when 40 then 8546
when 41 then 8546
when 42 then 8546
when 43 then 8966
when 50 then 8546
when 51 then 8546
when 61 then 8863
when 62 then 8920
when 63 then 8970
when 64 then 8676
when 65 then 8971
when 66 then 581379
when 69 then 8844
when 70 then 8844
when 71 then 8844
when 72 then 8717
when 81 then 8536
when 82 then 581379
when 83 then 8863
when 84 then 8827
when 85 then 8844
when 86 then 8536
when 87 then 8844
when 88 then 8966
when 89 then 8863
when 90 then 581379
when 91 then 581379
when 92 then 8676
when 93 then 8971
when 94 then 581379
when 95 then 8844
when 99 then 8844
else NULL
END as DISCHARGE_TO_CONCEPT_ID,
pat.POINT_OF_ORIGIN
from {sc}.pat
JOIN {ch_sc}._chunks ch ON ch.ChunkId = {0} AND pat.medrec_key = ch.PERSON_SOURCE_VALUE
left join {sc}.poorigin po on po.point_of_origin = pat.point_of_origin
left join {sc}.disstat ds on ds.disc_status = pat.disc_status
left join {sc}.pattype pt on pat.pat_type=pt.pat_type
order by cast(pat.medrec_key as bigint)
</Query>
select
cast(pat.medrec_key as bigint) as medrec_key,
pat.pat_key,
adm_date,
disc_date,
case lower(pat.gender)
when 'u' then NULL
else pat.gender
end as gender,
case lower(pat.race)
when 'w' then 8527
when 'b' then 8516
when 'a' then 8515
else 0
end as race_concept_id,
case
when lower(hispanic_ind) = 'y' then 38003563
when lower(pat.race) = 'h' then 38003563
when lower(hispanic_ind) = 'n' then 38003564
else 0
end as ethnicity_concept_id,
pat.race as race_source_value,
hispanic_ind as ethnicity_source_value,
case
when pat.point_of_origin = '7' and lower(pat.i_o_ind) = 'o' then 9203
when pat.point_of_origin = '7' and lower(pat.i_o_ind) = 'i' then 262
when lower(pat.i_o_ind) = 'i' then 9201
when lower(pat.i_o_ind) = 'o' then 9202
end as place_of_service_concept_id,
CASE
WHEN lower(pat.i_o_ind)='i' then 1
ELSE 0
END as contains_weight,
pat.i_o_ind,
pat.disc_status,
CASE
WHEN pat.disc_status IN (20, 40, 41, 42) THEN 1
ELSE 0
END as died,
ds.disc_status_desc,
po.point_of_origin_desc,
pat.mart_status,
pat.adm_phy,
pat.prov_id,
pat.age,
32880 PeriodTypeConceptId,
pat.pat_charges,
pat_type_desc,
31 as observation_period_gap,
CASE
WHEN pat.POINT_OF_ORIGIN = '0' then 8976
WHEN pat.POINT_OF_ORIGIN = '1' then 8844
WHEN pat.POINT_OF_ORIGIN = '2' then 8716
WHEN pat.POINT_OF_ORIGIN = '3' then 8844
WHEN pat.POINT_OF_ORIGIN = '4' then 8717
WHEN pat.POINT_OF_ORIGIN = '5' then 8863
WHEN pat.POINT_OF_ORIGIN = '6' then 8844
WHEN pat.POINT_OF_ORIGIN = '7' then 8870
WHEN pat.POINT_OF_ORIGIN = '8' then 8844
WHEN pat.POINT_OF_ORIGIN = '9' then 0
WHEN pat.POINT_OF_ORIGIN = '45' then 581384
WHEN pat.POINT_OF_ORIGIN = '46' then 8844
WHEN lower(pat.POINT_OF_ORIGIN) = 'a' then 8761
WHEN lower(pat.POINT_OF_ORIGIN) = 'b' then 8536
WHEN lower(pat.POINT_OF_ORIGIN) = 'c' then 8536
WHEN lower(pat.POINT_OF_ORIGIN) = 'd' then 8717
WHEN lower(pat.POINT_OF_ORIGIN) = 'e' then 8883
WHEN lower(pat.POINT_OF_ORIGIN) = 'f' then 8546
WHEN lower(pat.POINT_OF_ORIGIN) = 'g' then 8844
END as ADMITTING_SOURCE_CONCEPT_ID,
CASE pat.DISC_STATUS
when 1 then 8536
when 2 then 8844
when 3 then 8863
when 4 then 8863
when 5 then 8844
when 6 then 8536
when 7 then 8844
when 8 then 8536
when 9 then 8717
when 20 then NULL
when 21 then 8844
when 30 then 8844
when 40 then 0
when 41 then 0
when 42 then 0
when 43 then 8844
when 50 then 8546
when 51 then 8546
when 61 then 8863
when 62 then 8920
when 63 then 8970
when 64 then 8676
when 65 then 8971
when 66 then 581379
when 69 then 8844
when 70 then 8844
when 71 then 8844
when 72 then 8717
when 81 then 8536
when 82 then 581379
when 83 then 8863
when 84 then 8827
when 85 then 8844
when 86 then 8536
when 87 then 8844
when 88 then 8844
when 89 then 8863
when 90 then 581379
when 91 then 581379
when 92 then 8676
when 93 then 8971
when 94 then 581379
when 95 then 8844
when 99 then 0
else NULL
END as DISCHARGE_TO_CONCEPT_ID,
pat.POINT_OF_ORIGIN
from {sc}.pat
JOIN {ch_sc}._chunks ch ON ch.ChunkId = {0} AND pat.medrec_key = ch.PERSON_SOURCE_VALUE
left join {sc}.poorigin po on po.point_of_origin = pat.point_of_origin
left join {sc}.disstat ds on ds.disc_status = pat.disc_status
left join {sc}.pattype pt on pat.pat_type=pt.pat_type
order by cast(pat.medrec_key as bigint)
</Query>
<Persons>
<PersonDefinition>
<ObservationPeriodGap>observation_period_gap</ObservationPeriodGap>
Expand Down Expand Up @@ -176,70 +177,36 @@
</Concepts>
</DeathDefinition>
</Death>
<Observation>

<ObservationDefinition>
<PersonId>medrec_key</PersonId>
<VisitOccurrenceId>pat_key</VisitOccurrenceId>
<ProviderId>adm_phy</ProviderId>
<ValuesAsString>
<string>mart_status</string>
</ValuesAsString>
<Concepts>
<Concept>
<Fields>
<Field defaultConceptId="4053609" defaultSource=" " defaultTypeId="38000281"/>
</Fields>
</Concept>
</Concepts>
</ObservationDefinition>

<ObservationDefinition>
<PersonId>medrec_key</PersonId>
<VisitOccurrenceId>pat_key</VisitOccurrenceId>
<ProviderId>adm_phy</ProviderId>
<ValuesAsString>
<string>point_of_origin_desc</string>
</ValuesAsString>
<Concepts>
<Concept>
<Fields>
<Field defaultConceptId="40757183" defaultSource=" " defaultTypeId="38000281"/>
</Fields>
</Concept>
</Concepts>
</ObservationDefinition>

<ObservationDefinition>
<PersonId>medrec_key</PersonId>
<VisitOccurrenceId>pat_key</VisitOccurrenceId>
<ProviderId>adm_phy</ProviderId>
<ValuesAsString>
<string>disc_status_desc</string>
</ValuesAsString>
<Concepts>
<Concept>
<Fields>
<Field defaultConceptId="40757177" defaultSource=" " defaultTypeId="38000281"/>
</Fields>
</Concept>
</Concepts>
</ObservationDefinition>

<ObservationDefinition>
<PersonId>medrec_key</PersonId>
<VisitOccurrenceId>pat_key</VisitOccurrenceId>
<ProviderId>adm_phy</ProviderId>
<ValuesAsString>
<string>pat_type_desc</string>
</ValuesAsString>
<Concepts>
<Concept>
<Fields>
<Field defaultConceptId="40769091" defaultSource=" " defaultTypeId="38000281"/>
</Fields>
</Concept>
</Concepts>
</ObservationDefinition>
</Observation>
<Observation>
<ObservationDefinition>
<PersonId>medrec_key</PersonId>
<VisitOccurrenceId>pat_key</VisitOccurrenceId>
<ProviderId>adm_phy</ProviderId>
<ValuesAsString>
<string>mart_status</string>
</ValuesAsString>
<Concepts>
<Concept>
<Fields>
<Field defaultConceptId="4053609" defaultSource=" " defaultTypeId="38000281"/>
</Fields>
</Concept>
</Concepts>
</ObservationDefinition>
<ObservationDefinition>
<PersonId>medrec_key</PersonId>
<VisitOccurrenceId>pat_key</VisitOccurrenceId>
<ProviderId>adm_phy</ProviderId>
<ValuesAsString>
<string>pat_type_desc</string>
</ValuesAsString>
<Concepts>
<Concept>
<Fields>
<Field defaultConceptId="40769091" defaultSource=" " defaultTypeId="38000281"/>
</Fields>
</Concept>
</Concepts>
</ObservationDefinition>
</Observation>
</QueryDefinition>

0 comments on commit 4789786

Please sign in to comment.