Skip to content

Commit

Permalink
Merge pull request #111 from OHDSI/health-verity-upd
Browse files Browse the repository at this point in the history
Health verity upd
  • Loading branch information
bradanton authored Aug 29, 2024
2 parents 23111cc + 6d58bdb commit 7306191
Show file tree
Hide file tree
Showing 17 changed files with 151 additions and 68 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
SELECT DISTINCT {0} row_number() over (order by hvid) person_id, hvid
from
(
SELECT DISTINCT hvid FROM cdm_health_verity_cc_ehr_cce_v2776.enrollment
SELECT DISTINCT hvid FROM {sc}.enrollment
where lower(benefit_type) = 'medical'
union
SELECT DISTINCT hvid FROM cdm_health_verity_cc_ehr_cce_v2776.enrollment
SELECT DISTINCT hvid FROM {sc}.enrollment
where lower(benefit_type) = 'pharmacy' or benefit_type is null
) a
where hvid != '' and hvid is not null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<QueryDefinition>
<Query>
<Query database="none">
select distinct enc_prov_taxnmy_id as specialty_source_value,
enc_prov_id provider_source_value,
coalesce(enc_prov_id, '') || ';' || coalesce(enc_prov_taxnmy_id, '') ProviderIdKey
from cdm_health_verity_cc_ehr_cce_v2776.emr_enc
from {sc}.emr_enc
</Query>
<Providers>
<ProviderDefinition>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<QueryDefinition>
<Query>
<Query database="none">
SELECT
ch.person_id as PersonId,
hvid,
Expand All @@ -17,7 +17,7 @@
when enc_start_dt &lt; '10/1/2015' then '9'
when enc_start_dt &gt;= '10/1/2015' then '10'
end as icd_ver
FROM cdm_health_verity_cc_ehr_cce_v2776.cdm_diag
FROM {sc}.cdm_diag
JOIN {ch_sc}._chunks ch ON ch.ChunkId = {0} AND hvid = ch.PERSON_SOURCE_VALUE
where enc_start_dt is not null
order by ch.person_id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<QueryDefinition>
<Query>
<Query database="none">
SELECT distinct
ch.person_id as PersonId,
d.hvid,
Expand All @@ -15,9 +15,9 @@
when enc_grp_txt LIKE '%ENCOUNTER_VISIT_TYPE: Inpatient%' and los_day_cnt > 1 then 9201
else 9202
end defaultConceptId
FROM cdm_health_verity_cc_ehr_cce_v2776.cdm_enc_dtl d
FROM {sc}.cdm_enc_dtl d
JOIN {ch_sc}._chunks ch ON ch.ChunkId = {0} AND d.hvid = ch.PERSON_SOURCE_VALUE
JOIN cdm_health_verity_cc_ehr_cce_v2776.cdm_enc e ON d.hvid = e.hvid and d.hv_enc_id = e.hv_enc_id
JOIN {sc}.cdm_enc e ON d.hvid = e.hvid and d.hv_enc_id = e.hv_enc_id
where d.proc_dt is not null
order by ch.person_id
</Query>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<QueryDefinition>
<Query>
<Query database="none">
SELECT
ch.person_id as PersonId,
hvid,
Expand All @@ -11,7 +11,7 @@
clin_obsn_uom,
32827 type_concept_id,
coalesce(clin_obsn_prov_id, '') || ';' || coalesce(clin_obsn_prov_taxnmy_id, '') ProviderIdKey
from cdm_health_verity_cc_ehr_cce_v2776.emr_clin_obsn
from {sc}.emr_clin_obsn
JOIN {ch_sc}._chunks ch ON ch.ChunkId = {0} AND hvid = ch.PERSON_SOURCE_VALUE
order by ch.person_id
</Query>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<QueryDefinition>
<Query>
<Query database="none">
SELECT
ch.person_id as PersonId,
hvid,
Expand Down Expand Up @@ -28,7 +28,7 @@
END as condition_status_concept_id,
32827 type_concept_id,
coalesce(diag_prov_id, '') || ';' || coalesce(diag_prov_taxnmy_id, '') ProviderIdKey
from cdm_health_verity_cc_ehr_cce_v2776.emr_diag
from {sc}.emr_diag
JOIN {ch_sc}._chunks ch ON ch.ChunkId = {0} AND hvid = ch.PERSON_SOURCE_VALUE
where upper(coalesce(diag_stat_desc, '')) not in
(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<QueryDefinition>
<Query>
<Query database="none">
SELECT distinct
ch.person_id as PersonId,
hvid,
hv_enc_dt,
hv_enc_id,
coalesce(enc_prov_id, '') || ';' || coalesce(enc_prov_taxnmy_id, '') ProviderIdKey
from cdm_health_verity_cc_ehr_cce_v2776.emr_enc
from {sc}.emr_enc
JOIN {ch_sc}._chunks ch ON ch.ChunkId = {0} AND hvid = ch.PERSON_SOURCE_VALUE
where hv_enc_dt is not null
order by ch.person_id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<QueryDefinition>
<Query>
<Query database="none">
SELECT
ch.person_id as PersonId,
hvid,
Expand All @@ -11,7 +11,7 @@
lab_result_uom,
lab_result_msrmt,
coalesce(lab_test_prov_id, '') || ';' || coalesce(lab_test_prov_taxnmy_id, '') ProviderIdKey
from cdm_health_verity_cc_ehr_cce_v2776.emr_lab_test
from {sc}.emr_lab_test
JOIN {ch_sc}._chunks ch ON ch.ChunkId = {0} AND hvid = ch.PERSON_SOURCE_VALUE
where upper(prmy_src_tbl_nm) in
(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<QueryDefinition>
<Query>
<Query database="none">
SELECT
ch.person_id as PersonId,
hvid,
Expand All @@ -19,7 +19,7 @@
else '4'
end as type,
32833 type_concept_id
from cdm_health_verity_cc_ehr_cce_v2776.emr_medctn
from {sc}.emr_medctn
JOIN {ch_sc}._chunks ch ON ch.ChunkId = {0} AND hvid = ch.PERSON_SOURCE_VALUE
where coalesce(hv_medctn_dt, medctn_start_dt, medctn_admin_dt, medctn_ord_dt) is not null
order by 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<QueryDefinition>
<Query>
<Query database="none">
SELECT
ch.person_id as PersonId,
hvid,
Expand All @@ -17,7 +17,7 @@
end proc,
32827 type_concept_id,
coalesce(proc_prov_id, '') || ';' || coalesce(proc_prov_taxnmy_id, '') ProviderIdKey
from cdm_health_verity_cc_ehr_cce_v2776.emr_proc
from {sc}.emr_proc
JOIN {ch_sc}._chunks ch ON ch.ChunkId = {0} AND hvid = ch.PERSON_SOURCE_VALUE
where coalesce(upper(proc_stat_cd), '') not in
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
date_end,
1 as benefit_type,
data_vendor
FROM cdm_health_verity_cc_ehr_cce_v2776.enrollment
FROM {sc}.enrollment
JOIN {ch_sc}._chunks ch ON ch.ChunkId = {0} AND hvid = ch.PERSON_SOURCE_VALUE
where lower(benefit_type) = 'medical'

Expand All @@ -26,7 +26,7 @@
date_end,
2 as benefit_type,
data_vendor
FROM cdm_health_verity_cc_ehr_cce_v2776.enrollment
FROM {sc}.enrollment
JOIN {ch_sc}._chunks ch ON ch.ChunkId = {0} AND hvid = ch.PERSON_SOURCE_VALUE
where lower(benefit_type) = 'pharmacy' or benefit_type is null
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<QueryDefinition>
<Query>
<Query database="none">
SELECT
ch.person_id as PersonId,
coalesce(date_service, date_specimen) as date_service,
Expand All @@ -10,7 +10,7 @@
result_unit_of_measure,
replace(result, chr(9), ' ') as result,
data_vendor
from cdm_health_verity_cc_ehr_cce_v2776.lab_tests
from {sc}.lab_tests
JOIN {ch_sc}._chunks ch ON ch.ChunkId = {0} AND hvid = ch.PERSON_SOURCE_VALUE
where loinc_code is not null and test_ordered_name is not null and result_name is not null and coalesce(date_service, date_specimen) is not null
order by ch.person_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
ch.person_id as PersonId,
hvid,
date_service,
diagnosis_code,
trim(replace(replace(replace(diagnosis_code, chr(9), ' '), chr(10), ' '), chr(13), ' ')) diagnosis_code,
procedure_code,
ndc_code,
claim_type,
Expand Down Expand Up @@ -36,7 +36,7 @@
end as icd_ver,
hv_enc_id,
1 as fake
FROM cdm_health_verity_cc_ehr_cce_v2776.medical_claims
FROM {sc}.medical_claims
JOIN {ch_sc}._chunks ch ON ch.ChunkId = {0} AND hvid = ch.PERSON_SOURCE_VALUE
where date_service is not null and date_part('year', date_service) &gt;= 2009 and
(logical_delete_reason is null or logical_delete_reason = '' or logical_delete_reason = 'null' or lower(logical_delete_reason) not in ('denied claims', 'reversal to original claim'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
when date_service &gt;= '10/1/2015' then '10'
end as icd_ver

FROM cdm_health_verity_cc_ehr_cce_v2776.pharmacy_claims
FROM {sc}.pharmacy_claims
JOIN {ch_sc}._chunks ch ON ch.ChunkId = {0} AND hvid = ch.PERSON_SOURCE_VALUE
where date_service is not null and date_part('year', date_service) &gt;= 2009 and
(logical_delete_reason is null or logical_delete_reason = '' or logical_delete_reason = 'null')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<QueryDefinition>
<Query>
<Query database="none">
SELECT distinct
ch.person_id as PersonId,
hvid,
Expand All @@ -23,7 +23,7 @@
when date_service &gt;= '10/1/2015' then '10'
end as icd_ver

FROM cdm_health_verity_cc_ehr_cce_v2776.pharmacy_claims_vaccine
FROM {sc}.pharmacy_claims_vaccine
JOIN {ch_sc}._chunks ch ON ch.ChunkId = {0} AND hvid = ch.PERSON_SOURCE_VALUE
where date_service is not null and date_part('year', date_service) &gt;= 2009 and
(logical_delete_reason is null or logical_delete_reason = '' or logical_delete_reason = 'null')
Expand Down
Loading

0 comments on commit 7306191

Please sign in to comment.