Skip to content

Commit

Permalink
Bug fixes - cost & Util
Browse files Browse the repository at this point in the history
#486
#480
(cherry picked from commit 1a2ef9e)
  • Loading branch information
tagwhom authored and pavgra committed Jul 18, 2018
1 parent e071c14 commit 764a407
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9461,6 +9461,7 @@ select cohort_definition_id
, count(distinct visit_start_date) as count_value
into #raw_4009_u6
from #raw_4009
where ancestor = 0
GROUP BY cohort_definition_id, subject_id;


Expand Down Expand Up @@ -11734,17 +11735,17 @@ rxnorm_rollup (cohort_definition_id, subject_id, drug_concept_id, drug_type_conc
select cohort_definition_id, subject_id, drug_concept_id, drug_type_concept_id, cost_concept_id, cost_type_concept_id, drug_exposure_start_date, drug_exposure_id, cost, ancestor
INTO #raw_cost_4022
FROM (
select cohort_definition_id, subject_id, drug_concept_id, drug_type_concept_id, cost_concept_id, cost_type_concept_id, drug_exposure_start_date, drug_exposure_id, cost FROM drug_records
select cohort_definition_id, subject_id, drug_concept_id, drug_type_concept_id, cost_concept_id, cost_type_concept_id, drug_exposure_start_date, drug_exposure_id, cost, 0 as ancestor FROM drug_records
UNION ALL
select cohort_definition_id, subject_id, drug_concept_id, drug_type_concept_id, cost_concept_id, cost_type_concept_id, drug_exposure_start_date, drug_exposure_id, cost FROM atc_rollup
select cohort_definition_id, subject_id, drug_concept_id, drug_type_concept_id, cost_concept_id, cost_type_concept_id, drug_exposure_start_date, drug_exposure_id, cost, 1 as ancestor FROM atc_rollup
UNION ALL
select cohort_definition_id, subject_id, drug_concept_id, drug_type_concept_id, cost_concept_id, cost_type_concept_id, drug_exposure_start_date, drug_exposure_id, cost FROM rxnorm_rollup
select cohort_definition_id, subject_id, drug_concept_id, drug_type_concept_id, cost_concept_id, cost_type_concept_id, drug_exposure_start_date, drug_exposure_id, cost, 1 as ancestor FROM rxnorm_rollup
) D
;

create index ix_rc_visit_date on #raw_cost_4022 (drug_exposure_start_date);

select cohort_definition_id, subject_id, hp.period_id, drug_exposure_id, drug_concept_id, drug_type_concept_id, cost_concept_id, cost_type_concept_id, cost
select cohort_definition_id, subject_id, hp.period_id, drug_exposure_id, drug_concept_id, drug_type_concept_id, cost_concept_id, cost_type_concept_id, cost, ancestor
into #raw_period_4022
from #raw_cost_4022
join #periods_baseline hp on drug_exposure_start_date >= hp.period_start_date and drug_exposure_start_date < hp.period_end_date
Expand Down Expand Up @@ -11784,6 +11785,7 @@ select cohort_definition_id
, sum(cost) as count_value
into #raw_4022_u3
from #raw_period_4022
where ancestor = 0
GROUP BY subject_id, period_id, cost_concept_id, cost_type_concept_id, cohort_definition_id;

select cohort_definition_id
Expand Down Expand Up @@ -11820,6 +11822,7 @@ select cohort_definition_id
, sum(cost) as count_value
into #raw_4022_u6
from #raw_cost_4022
where ancestor = 0
GROUP BY subject_id, cost_concept_id, cost_type_concept_id, cohort_definition_id;


Expand Down Expand Up @@ -11971,17 +11974,17 @@ rxnorm_rollup (cohort_definition_id, subject_id, drug_concept_id, drug_type_conc
select cohort_definition_id, subject_id, drug_concept_id, drug_type_concept_id, cost_concept_id, cost_type_concept_id, drug_exposure_start_date, drug_exposure_id, cost, ancestor
INTO #raw_cost_4023
FROM (
select cohort_definition_id, subject_id, drug_concept_id, drug_type_concept_id, cost_concept_id, cost_type_concept_id, drug_exposure_start_date, drug_exposure_id, cost FROM drug_records
select cohort_definition_id, subject_id, drug_concept_id, drug_type_concept_id, cost_concept_id, cost_type_concept_id, drug_exposure_start_date, drug_exposure_id, cost, 0 as ancestor FROM drug_records
UNION ALL
select cohort_definition_id, subject_id, drug_concept_id, drug_type_concept_id, cost_concept_id, cost_type_concept_id, drug_exposure_start_date, drug_exposure_id, cost FROM atc_rollup
select cohort_definition_id, subject_id, drug_concept_id, drug_type_concept_id, cost_concept_id, cost_type_concept_id, drug_exposure_start_date, drug_exposure_id, cost, 1 as ancestor FROM atc_rollup
UNION ALL
select cohort_definition_id, subject_id, drug_concept_id, drug_type_concept_id, cost_concept_id, cost_type_concept_id, drug_exposure_start_date, drug_exposure_id, cost FROM rxnorm_rollup
select cohort_definition_id, subject_id, drug_concept_id, drug_type_concept_id, cost_concept_id, cost_type_concept_id, drug_exposure_start_date, drug_exposure_id, cost, 1 as ancestor FROM rxnorm_rollup
) D
;

create index ix_rc_visit_date on #raw_cost_4023 (drug_exposure_start_date);

select cohort_definition_id, subject_id, hp.period_id, drug_exposure_id,drug_concept_id, drug_type_concept_id, cost_concept_id, cost_type_concept_id, cost
select cohort_definition_id, subject_id, hp.period_id, drug_exposure_id,drug_concept_id, drug_type_concept_id, cost_concept_id, cost_type_concept_id, cost, ancestor
into #raw_period_4023
from #raw_cost_4023
join #periods_atrisk hp on drug_exposure_start_date >= hp.period_start_date and drug_exposure_start_date < hp.period_end_date
Expand Down Expand Up @@ -12021,6 +12024,7 @@ select cohort_definition_id
, sum(cost) as count_value
into #raw_4023_u3
from #raw_period_4023
where ancestor = 0
GROUP BY subject_id, period_id, cost_concept_id, cost_type_concept_id, cohort_definition_id;

select cohort_definition_id
Expand Down Expand Up @@ -12057,6 +12061,7 @@ select cohort_definition_id
, sum(cost) as count_value
into #raw_4023_u6
from #raw_cost_4023
where ancestor = 0
GROUP BY subject_id, cost_concept_id, cost_type_concept_id, cohort_definition_id;

WITH cteRawData (cohort_definition_id, subject_id, stratum_1, stratum_2, stratum_3, stratum_4, stratum_5, count_value) as
Expand Down

0 comments on commit 764a407

Please sign in to comment.