Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added practitioner_id to procedure and updated condition logic #4

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions models/condition.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ with coding as (
,'http://hl7.org/fhir/sid/icd-10'
,'urn:oid:2.16.840.1.113883.3.623.1' -- this is weird, oid is for "us oncology", maintained by mckesson, but all codes are icd10cm
) then 'icd-10-cm'
when ccc.{{ protected_columns('SYSTEM') }} = 'http://hl7.org/fhir/sid/icd-9'
when ccc.{{ protected_columns('SYSTEM') }} in( 'http://hl7.org/fhir/sid/icd-9',
'http://hl7.org/fhir/sid/icd-9-cm')
then 'icd-9-cm'
when ccc.{{ protected_columns('SYSTEM') }} = 'http://snomed.info/sct'
then 'snomed-ct'
Expand All @@ -25,7 +26,8 @@ with coding as (
,condition_code as (
select
cc.condition_id
, cc.code
, case when cc.{{ protected_columns('SYSTEM') }} in ('icd-10-cm','icd-9-cm') then replace(cc.code,'.','')
else cc.code end as code
, cc.{{ protected_columns('SYSTEM') }}
, cc.display
from coding cc
Expand Down Expand Up @@ -79,7 +81,7 @@ left join {{ref('stage__patient')}} p
left join condition_code cc
on c.id = cc.condition_id
left join {{ref('terminology__icd_10_cm')}} icd10
on cc.{{ protected_columns('SYSTEM') }} = 'icd-10-cm' and replace(cc.code,'.','') = icd10.icd_10_cm
on cc.{{ protected_columns('SYSTEM') }} = 'icd-10-cm' and cc.code = icd10.icd_10_cm
left join {{ref('terminology__icd_9_cm')}} icd9
on cc.{{ protected_columns('SYSTEM') }} = 'icd-9-cm' and cc.code = icd9.icd_9_cm
left join {{ref('terminology__loinc')}} loinc
Expand Down
6 changes: 5 additions & 1 deletion models/procedure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ select
, cast(null as {{ dbt.type_string() }} ) as modifier_3
, cast(null as {{ dbt.type_string() }} ) as modifier_4
, cast(null as {{ dbt.type_string() }} ) as modifier_5
, cast(null as {{ dbt.type_string() }} ) as practitioner_id
, cast(pc.identifier_0_value as {{ dbt.type_string() }} ) as practitioner_id
, cast('healthgorilla' as {{ dbt.type_string() }} ) as data_source
from {{ ref('stage__procedure' ) }} pro
left join {{ ref('stage__patient' ) }} pat
on right(pro.subject_reference,24) = pat.id
left join {{ ref('stage__procedure_contained')}} pc
on pro.id = pc.procedure_id
and replace(pro.PERFORMER_0_ACTOR_REFERENCE,'#','') = pc.ID
and pc.RESOURCETYPE = 'Practitioner'
left join {{ref('terminology__hcpcs_level_2')}} hcpcs
on code_coding_0_system in ('urn:oid:2.16.840.1.113883.6.285','http://www.ama-assn.org/go/cpt')
and pro.code_coding_0_code = hcpcs.hcpcs
Expand Down
Loading