Skip to content

Commit

Permalink
charlson map table. Remove unnecessary DISTINCTS
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsemharb committed Jun 1, 2023
1 parent 58839c3 commit 22bc195
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions inst/sql/sql_server/quartiles/IQRComplementaryTables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -685,11 +685,11 @@ DROP TABLE IF EXISTS @cohort_database_schema.charlson_map;
CREATE TABLE @cohort_database_schema.charlson_map AS
SELECT DISTINCT *
FROM (
SELECT DISTINCT COALESCE(diag_category_id, 0) as diag_category_id,
COALESCE (weight, 0) as weight,
c.cohort_definition_id,
c.subject_id,
c.cohort_start_date
SELECT COALESCE(diag_category_id, 0) as diag_category_id,
COALESCE (weight, 0) as weight,
c.cohort_definition_id,
c.subject_id,
c.cohort_start_date
FROM (SELECT concepts.diag_category_id, score.weight, cohort.subject_id, cohort.cohort_definition_id
FROM
@cohort_database_schema.@cohort_table cohort
Expand All @@ -707,7 +707,7 @@ FROM (
UNION ALL

-- cancer modifiers
SELECT DISTINCT
SELECT
16 AS diag_category_id,
6 AS weight,
cohort.cohort_definition_id,
Expand All @@ -718,15 +718,15 @@ FROM (
ON cohort.subject_id = meas.person_id
WHERE meas.measurement_date <= cohort.cohort_start_date
AND measurement_concept_id IN (
SELECT DISTINCT ca.descendant_concept_id
SELECT ca.descendant_concept_id
FROM @cdm_database_schema.concept_ancestor ca
WHERE ca.ancestor_concept_id IN (36769180, 1635142)
)

UNION ALL

-- metastasis measurement
SELECT distinct
SELECT
16 AS diag_category_id,
6 AS weight,
cohort.cohort_definition_id,
Expand All @@ -737,7 +737,7 @@ FROM (
ON cohort.subject_id = meas.person_id
WHERE meas.measurement_date <= cohort.cohort_start_date
AND measurement_concept_id IN (
SELECT DISTINCT ca.descendant_concept_id
SELECT ca.descendant_concept_id
FROM @cdm_database_schema.concept_ancestor ca
WHERE ca.ancestor_concept_id IN (3006575)
)
Expand Down

0 comments on commit 22bc195

Please sign in to comment.