Skip to content

Commit

Permalink
Impala casts (#268) (#291)
Browse files Browse the repository at this point in the history
* Indices creation skip if netezza

* fix

* ATLP-301 Impala: Achilles reports fails

* test fixes
  • Loading branch information
pavgra authored and t-abdul-basser committed Aug 7, 2018
1 parent e7c1ea1 commit c920e14
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
11 changes: 7 additions & 4 deletions inst/sql/sql_server/AchillesHeel_v5.sql
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,18 @@ create table @results_database_schema.ACHILLES_results_derived
--generate counts for meas type, drug type, proc type, obs type
--optional TODO: possibly rewrite this with CASE statement to better make 705 into drug, 605 into proc ...etc
-- in measure_id column (or make that separate sql calls for each category)
insert into @results_database_schema.ACHILLES_results_derived (analysis_id, stratum_1, statistic_value,measure_id)
select
with t1(label_id, measure_id) as (select analysis_id as label_id, CAST(CONCAT('ach_',CAST(analysis_id as VARCHAR(10)),':GlobalCnt') AS VARCHAR(100)) as measure_id
from @results_database_schema.achilles_results
where analysis_id in(1805,705,605,805,405))
insert into @results_database_schema.ACHILLES_results_derived (analysis_id, stratum_1, statistic_value,measure_id)
select
--100000+analysis_id,
NULL as analysis_id,
stratum_2 as stratum_1,
sum(count_value) as statistic_value,
CAST(CONCAT('ach_',CAST(analysis_id as VARCHAR(10)),':GlobalCnt') AS VARCHAR(100)) as measure_id
from @results_database_schema.achilles_results
where analysis_id in(1805,705,605,805,405) group by analysis_id,stratum_2,CAST(CONCAT('ach_',CAST(analysis_id as VARCHAR(10)),':GlobalCnt') AS VARCHAR(100));
from t1 inner join @results_database_schema.achilles_results on t1.label_id = analysis_id
group by analysis_id,stratum_2,measure_id;



Expand Down
2 changes: 1 addition & 1 deletion inst/sql/sql_server/Achilles_v5.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7511,7 +7511,7 @@ Reports
-- 1900 concept_0 report

INSERT INTO @results_database_schema.ACHILLES_results (analysis_id, stratum_1, stratum_2, count_value)
select 1900 as analysis_id, CAST(table_name AS VARCHAR(255)) as stratum_1, source_value as stratum_2, cnt as count_value
select 1900 as analysis_id, CAST(table_name AS VARCHAR(255)) as stratum_1, CAST(source_value AS VARCHAR(255)) as stratum_2, cnt as count_value
from (
select 'measurement' as table_name,measurement_source_value as source_value, COUNT_BIG(*) as cnt from @cdm_database_schema.measurement where measurement_concept_id = 0 group by measurement_source_value
union
Expand Down
32 changes: 16 additions & 16 deletions inst/sql/sql_server/ConceptHierarchy_v5.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ INSERT INTO @results_database_schema.concept_hierarchy
(concept_id, concept_name, treemap, level1_concept_name, level2_concept_name, level3_concept_name, level4_concept_name)
SELECT
snomed.concept_id,
snomed.concept_name AS snomed_concept_name,
CAST(snomed.concept_name AS VARCHAR(400)) AS snomed_concept_name,
CAST('Condition' AS VARCHAR(20)) AS treemap,
pt_to_hlt.pt_concept_name,
hlt_to_hlgt.hlt_concept_name,
hlgt_to_soc.hlgt_concept_name,
soc.concept_name AS soc_concept_name
CAST(pt_to_hlt.pt_concept_name AS VARCHAR(255)),
CAST(hlt_to_hlgt.hlt_concept_name AS VARCHAR(255)),
CAST(hlgt_to_soc.hlgt_concept_name AS VARCHAR(255)),
CAST(soc.concept_name AS VARCHAR(255)) AS soc_concept_name
FROM
(
SELECT
Expand Down Expand Up @@ -128,12 +128,12 @@ INSERT INTO @results_database_schema.concept_hierarchy
(concept_id, concept_name, treemap, level1_concept_name, level2_concept_name, level3_concept_name, level4_concept_name)
SELECT
rxnorm.concept_id,
rxnorm.concept_name AS rxnorm_concept_name,
CAST(rxnorm.concept_name AS VARCHAR(400)) AS rxnorm_concept_name,
CAST('Drug' AS VARCHAR(20)) AS treemap,
rxnorm.rxnorm_ingredient_concept_name,
atc5_to_atc3.atc5_concept_name,
atc3_to_atc1.atc3_concept_name,
atc1.concept_name AS atc1_concept_name
CAST(rxnorm.rxnorm_ingredient_concept_name AS VARCHAR(255)),
CAST(atc5_to_atc3.atc5_concept_name AS VARCHAR(255)),
CAST(atc3_to_atc1.atc3_concept_name AS VARCHAR(255)),
CAST(atc1.concept_name AS VARCHAR(255)) AS atc1_concept_name
FROM
(
SELECT
Expand Down Expand Up @@ -220,11 +220,11 @@ INSERT INTO @results_database_schema.concept_hierarchy
(concept_id, concept_name, treemap, level1_concept_name, level2_concept_name, level3_concept_name)
SELECT
rxnorm.rxnorm_ingredient_concept_id,
rxnorm.rxnorm_ingredient_concept_name,
CAST(rxnorm.rxnorm_ingredient_concept_name AS VARCHAR(400)),
CAST('Drug Era' AS VARCHAR(20)) AS treemap,
atc5_to_atc3.atc5_concept_name,
atc3_to_atc1.atc3_concept_name,
atc1.concept_name AS atc1_concept_name
CAST(atc5_to_atc3.atc5_concept_name AS VARCHAR(255)),
CAST(atc3_to_atc1.atc3_concept_name AS VARCHAR(255)),
CAST(atc1.concept_name AS VARCHAR(255)) AS atc1_concept_name
FROM
(
SELECT
Expand Down Expand Up @@ -306,7 +306,7 @@ INSERT INTO @results_database_schema.concept_hierarchy
(concept_id, concept_name, treemap, level1_concept_name, level2_concept_name, level3_concept_name)
SELECT
m.concept_id,
m.concept_name,
CAST(m.concept_name AS VARCHAR(400)),
CAST('Measurement' AS VARCHAR(20)) AS treemap,
CAST(max(c1.concept_name) AS VARCHAR(255)) AS level1_concept_name,
CAST(max(c2.concept_name) AS VARCHAR(255)) AS level2_concept_name,
Expand Down Expand Up @@ -335,7 +335,7 @@ INSERT INTO @results_database_schema.concept_hierarchy
(concept_id, concept_name, treemap, level1_concept_name, level2_concept_name, level3_concept_name)
SELECT
obs.concept_id,
obs.concept_name,
CAST(obs.concept_name AS VARCHAR(400)),
CAST('Observation' AS VARCHAR(20)) AS treemap,
CAST(max(c1.concept_name) AS VARCHAR(255)) AS level1_concept_name,
CAST(max(c2.concept_name) AS VARCHAR(255)) AS level2_concept_name,
Expand Down

0 comments on commit c920e14

Please sign in to comment.