Merge pull request #26 from anthonysena/master

Inclusion of Type Concept
This commit is contained in:
Patrick Ryan 2016-08-29 13:37:30 -04:00 committed by GitHub
commit 8bb3f64c97
7 changed files with 520 additions and 638 deletions

View File

@ -1,38 +0,0 @@
# Load Libraries
install.packages(devtools)
library(devtools)
install_github("OHDSI/SqlRender")
library(SqlRender)
# Variables
ohdsiSqlFile <- "C:/Git/CommonDataModel/Version4 To Version5 Conversion/OMOP CDMv4 to CDMv5 - OHDSI-SQL.sql"
targetSqlServerFile <- "C:/Git/CommonDataModel/Version4 To Version5 Conversion/Sql Server/OMOP CDMv4 to CDMv5 - SQL Server.sql"
targetPostgreSqlFile <- "C:/Git/CommonDataModel/Version4 To Version5 Conversion/PostgreSQL/OMOP CDMv4 to CDMv5 - PostgreSQL.sql"
targetOracleFile <- "C:/Git/CommonDataModel/Version4 To Version5 Conversion/Oracle/OMOP CDMv4 to CDMv5 - Oracle.sql"
targetSqlServerPDWFile <- "C:/Git/CommonDataModel/Version4 To Version5 Conversion/Sql Server PDW/OMOP CDMv4 to CDMv5 - Sql Server PDW.dsql"
targetRedshiftFile <- "C:/Git/CommonDataModel/Version4 To Version5 Conversion/Redshift/OMOP CDMv4 to CDMv5 - Redshift.sql"
##### LOCAL - SQL Server Testing
#renderSqlFile(ohdsiSqlFile, targetSqlServerFile, SOURCE_CDMV4 = "[CDMV4]", SOURCE_CDMV4_SCHEMA = "[CDMV4].[dbo]", TARGET_CDMV5 = "[CDMV5]", TARGET_CDMV5_SCHEMA = "[CDMV5].[dbo]")
##### SQL Server Testing
#renderSqlFile(ohdsiSqlFile, targetSqlServerFile, SOURCE_CDMV4 = "[CDM_TRUVEN_CCAE_6k]", SOURCE_CDMV4_SCHEMA = "[CDM_TRUVEN_CCAE_6k].[dbo]", TARGET_CDMV5 = "[CDMV5_Conversion_Target]", TARGET_CDMV5_SCHEMA = "[CDMV5_Conversion_Target].[dbo]")
##### PostgreSql Testing
#renderSqlFile(ohdsiSqlFile, targetSqlServerFile, SOURCE_CDMV4 = "sandbox", SOURCE_CDMV4_SCHEMA = "sandbox.cdmv4", TARGET_CDMV5 = "sandbox", TARGET_CDMV5_SCHEMA = "sandbox.cdmv5")
#translateSqlFile(sourceFile = targetSqlServerFile, targetFile = targetPostgreSqlFile, targetDialect = "postgresql")
##### Oracle Testing
#renderSqlFile(ohdsiSqlFile, targetSqlServerFile, SOURCE_CDMV4 = "CDMV4", SOURCE_CDMV4_SCHEMA = "CDMV4", TARGET_CDMV5 = "CDMV5", TARGET_CDMV5_SCHEMA = "CDMV5")
#translateSqlFile(sourceFile = targetSqlServerFile, targetFile = targetOracleFile, targetDialect = "oracle")
##### APS Testing
#renderSqlFile(ohdsiSqlFile, targetSqlServerFile, SOURCE_CDMV4 = "[CDM_THIN]", SOURCE_CDMV4_SCHEMA = "[CDM_THIN].[dbo]", TARGET_CDMV5 = "[CDM_THIN_V5_asena5]", TARGET_CDMV5_SCHEMA = "[CDM_THIN_V5_asena5].[dbo]")
#translateSqlFile(sourceFile = targetSqlServerFile, targetFile = targetSqlServerPDWFile, targetDialect = "pdw")
##### Push to GitHub
renderSqlFile(ohdsiSqlFile, targetSqlServerFile)
translateSqlFile(sourceFile = targetSqlServerFile, targetFile = targetPostgreSqlFile, targetDialect = "postgresql")
translateSqlFile(sourceFile = targetSqlServerFile, targetFile = targetOracleFile, targetDialect = "oracle")
translateSqlFile(sourceFile = targetSqlServerFile, targetFile = targetSqlServerPDWFile, targetDialect = "pdw")
translateSqlFile(sourceFile = targetSqlServerFile, targetFile = targetRedshiftFile, targetDialect = "redshift")

View File

@ -479,7 +479,7 @@ SELECT person_id
,CAST(NULL AS INT) AS cause_source_concept_id
FROM @SOURCE_CDMV4_SCHEMA.DEATH
LEFT JOIN #concept_map_distinct cm1 ON DEATH.DEATH_TYPE_CONCEPT_ID = CM1.SOURCE_CONCEPT_ID
AND LOWER(DOMAIN_ID) IN ('death type');
AND LOWER(DOMAIN_ID) IN ('death type', 'Type Concept');
INSERT INTO @TARGET_CDMV5_SCHEMA.ETL_WARNINGS (WARNING_MESSAGE)
SELECT 'DEATH: ' + CAST(NUM_INVALID_RECORDS AS VARCHAR) + ' records in the source CDMv4 database have invalid DEATH_TYPE_CONCEPT_ID'
@ -492,7 +492,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('death type')
AND LOWER(DOMAIN_ID) IN ('death type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -589,7 +589,7 @@ INNER JOIN #concept_map_distinct cmdis ON cm1.source_concept_id = cmdis.source_c
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount = 1
LEFT JOIN #concept_map cm2 ON PROCEDURE_OCCURRENCE.PROCEDURE_TYPE_CONCEPT_ID = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('procedure type')
AND LOWER(cm2.domain_id) IN ('procedure type', 'Type Concept')
LEFT JOIN #concept_map_distinct cmdis2 ON cm2.source_concept_id = cmdis2.source_concept_id
AND cm2.domain_id = cmdis2.domain_id
AND cmdis2.targetConceptCount = 1
@ -632,7 +632,7 @@ SELECT procedure_occurrence_id
FROM @SOURCE_CDMV4_SCHEMA.PROCEDURE_OCCURRENCE
LEFT JOIN #concept_map cm1 ON procedure_concept_id = cm1.source_concept_id
LEFT JOIN #concept_map cm2 ON procedure_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('procedure type')
AND LOWER(cm2.domain_id) IN ('procedure type', 'Type Concept')
WHERE procedure_concept_id <> 0
AND cm1.domain_id IS NULL
@ -680,7 +680,7 @@ FROM (
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount > 1
LEFT JOIN #concept_map cm2 ON PROCEDURE_OCCURRENCE.PROCEDURE_TYPE_CONCEPT_ID = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('procedure type')
AND LOWER(cm2.domain_id) IN ('procedure type', 'Type Concept')
UNION ALL
@ -801,7 +801,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('procedure type')
AND LOWER(DOMAIN_ID) IN ('procedure type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -877,7 +877,7 @@ INNER JOIN #concept_map_distinct cmdis ON cm1.source_concept_id = cmdis.source_c
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount = 1
LEFT JOIN #concept_map cm2 ON drug_exposure.drug_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('drug type')
AND LOWER(cm2.domain_id) IN ('drug type', 'Type Concept')
INNER JOIN #concept_map_distinct cmdis2 ON cm2.source_concept_id = cmdis2.source_concept_id
AND cm2.domain_id = cmdis2.domain_id
AND cmdis2.targetConceptCount = 1
@ -939,7 +939,7 @@ SELECT drug_exposure_id
FROM @SOURCE_CDMV4_SCHEMA.DRUG_EXPOSURE
LEFT JOIN #concept_map cm1 ON drug_concept_id = cm1.source_concept_id
LEFT JOIN #concept_map cm2 ON drug_exposure.drug_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('drug type')
AND LOWER(cm2.domain_id) IN ('drug type', 'Type Concept')
WHERE drug_concept_id <> 0
AND cm1.domain_id IS NULL
@ -1004,7 +1004,7 @@ FROM (
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount > 1
LEFT JOIN #concept_map cm2 ON drug_exposure.drug_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('drug type')
AND LOWER(cm2.domain_id) IN ('drug type', 'Type Concept')
UNION ALL
@ -1170,7 +1170,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('drug type')
AND LOWER(DOMAIN_ID) IN ('drug type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -1201,7 +1201,7 @@ INNER JOIN #concept_map_distinct cmdis ON cm1.source_concept_id = cmdis.source_c
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount = 1
LEFT JOIN #concept_map cm2 ON condition_occurrence.condition_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('condition type')
AND LOWER(cm2.domain_id) IN ('condition type', 'Type Concept')
WHERE condition_concept_id > 0 -- This condition will map those concepts that were mapped to valid concepts in V4
UNION ALL
@ -1238,7 +1238,7 @@ SELECT condition_occurrence_id
FROM @SOURCE_CDMV4_SCHEMA.CONDITION_OCCURRENCE
LEFT JOIN #concept_map cm1 ON condition_occurrence.condition_concept_id = cm1.source_concept_id
LEFT JOIN #concept_map cm2 ON condition_occurrence.condition_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('condition type')
AND LOWER(cm2.domain_id) IN ('condition type', 'Type Concept')
WHERE condition_concept_id <> 0
AND cm1.domain_id IS NULL
@ -1281,7 +1281,7 @@ FROM (
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount > 1
LEFT JOIN #concept_map cm2 ON condition_occurrence.condition_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('condition type')
AND LOWER(cm2.domain_id) IN ('condition type', 'Type Concept')
WHERE condition_concept_id > 0 -- This condition will map those concepts that were mapped to valid concepts in V4
UNION ALL
@ -1369,7 +1369,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('condition type')
AND LOWER(DOMAIN_ID) IN ('condition type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -1522,7 +1522,7 @@ FROM (
INNER JOIN #concept_map cm1 ON observation.observation_concept_id = cm1.source_concept_id
AND LOWER(cm1.domain_id) IN ('measurement')
LEFT JOIN #concept_map cm2 ON observation.unit_concept_id = cm2.source_concept_id
AND LOWER(cm1.domain_id) IN ('unit')
AND LOWER(cm2.domain_id) IN ('unit')
UNION ALL

View File

@ -486,7 +486,7 @@ SELECT person_id
,CAST(NULL AS INT) AS cause_source_concept_id
FROM [SOURCE_CDMV4].[SCHEMA].DEATH
LEFT JOIN concept_map_distinct cm1 ON DEATH.DEATH_TYPE_CONCEPT_ID = CM1.SOURCE_CONCEPT_ID
AND LOWER(DOMAIN_ID) IN ('death type');
AND LOWER(DOMAIN_ID) IN ('death type', 'Type Concept');
INSERT INTO [TARGET_CDMV5].[SCHEMA].ETL_WARNINGS (WARNING_MESSAGE)
SELECT 'DEATH: ' || CAST(NUM_INVALID_RECORDS AS VARCHAR) || ' records in the source CDMv4 database have invalid DEATH_TYPE_CONCEPT_ID'
@ -499,7 +499,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('death type')
AND LOWER(DOMAIN_ID) IN ('death type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -600,7 +600,7 @@ INNER JOIN concept_map_distinct cmdis ON cm1.source_concept_id = cmdis.source_co
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount = 1
LEFT JOIN concept_map cm2 ON PROCEDURE_OCCURRENCE.PROCEDURE_TYPE_CONCEPT_ID = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('procedure type')
AND LOWER(cm2.domain_id) IN ('procedure type', 'Type Concept')
LEFT JOIN concept_map_distinct cmdis2 ON cm2.source_concept_id = cmdis2.source_concept_id
AND cm2.domain_id = cmdis2.domain_id
AND cmdis2.targetConceptCount = 1
@ -643,7 +643,7 @@ SELECT procedure_occurrence_id
FROM [SOURCE_CDMV4].[SCHEMA].PROCEDURE_OCCURRENCE
LEFT JOIN concept_map cm1 ON procedure_concept_id = cm1.source_concept_id
LEFT JOIN concept_map cm2 ON procedure_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('procedure type')
AND LOWER(cm2.domain_id) IN ('procedure type', 'Type Concept')
WHERE procedure_concept_id <> 0
AND cm1.domain_id IS NULL
@ -691,7 +691,7 @@ FROM (
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount > 1
LEFT JOIN concept_map cm2 ON PROCEDURE_OCCURRENCE.PROCEDURE_TYPE_CONCEPT_ID = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('procedure type')
AND LOWER(cm2.domain_id) IN ('procedure type', 'Type Concept')
UNION ALL
@ -812,7 +812,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('procedure type')
AND LOWER(DOMAIN_ID) IN ('procedure type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -892,7 +892,7 @@ INNER JOIN concept_map_distinct cmdis ON cm1.source_concept_id = cmdis.source_co
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount = 1
LEFT JOIN concept_map cm2 ON drug_exposure.drug_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('drug type')
AND LOWER(cm2.domain_id) IN ('drug type', 'Type Concept')
INNER JOIN concept_map_distinct cmdis2 ON cm2.source_concept_id = cmdis2.source_concept_id
AND cm2.domain_id = cmdis2.domain_id
AND cmdis2.targetConceptCount = 1
@ -954,7 +954,7 @@ SELECT drug_exposure_id
FROM [SOURCE_CDMV4].[SCHEMA].DRUG_EXPOSURE
LEFT JOIN concept_map cm1 ON drug_concept_id = cm1.source_concept_id
LEFT JOIN concept_map cm2 ON drug_exposure.drug_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('drug type')
AND LOWER(cm2.domain_id) IN ('drug type', 'Type Concept')
WHERE drug_concept_id <> 0
AND cm1.domain_id IS NULL
@ -1019,7 +1019,7 @@ FROM (
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount > 1
LEFT JOIN concept_map cm2 ON drug_exposure.drug_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('drug type')
AND LOWER(cm2.domain_id) IN ('drug type', 'Type Concept')
UNION ALL
@ -1185,7 +1185,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('drug type')
AND LOWER(DOMAIN_ID) IN ('drug type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -1216,7 +1216,7 @@ INNER JOIN concept_map_distinct cmdis ON cm1.source_concept_id = cmdis.source_co
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount = 1
LEFT JOIN concept_map cm2 ON condition_occurrence.condition_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('condition type')
AND LOWER(cm2.domain_id) IN ('condition type', 'Type Concept')
WHERE condition_concept_id > 0 -- This condition will map those concepts that were mapped to valid concepts in V4
UNION ALL
@ -1253,7 +1253,7 @@ SELECT condition_occurrence_id
FROM [SOURCE_CDMV4].[SCHEMA].CONDITION_OCCURRENCE
LEFT JOIN concept_map cm1 ON condition_occurrence.condition_concept_id = cm1.source_concept_id
LEFT JOIN concept_map cm2 ON condition_occurrence.condition_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('condition type')
AND LOWER(cm2.domain_id) IN ('condition type', 'Type Concept')
WHERE condition_concept_id <> 0
AND cm1.domain_id IS NULL
@ -1296,7 +1296,7 @@ FROM (
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount > 1
LEFT JOIN concept_map cm2 ON condition_occurrence.condition_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('condition type')
AND LOWER(cm2.domain_id) IN ('condition type', 'Type Concept')
WHERE condition_concept_id > 0 -- This condition will map those concepts that were mapped to valid concepts in V4
UNION ALL
@ -1384,7 +1384,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('condition type')
AND LOWER(DOMAIN_ID) IN ('condition type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -1537,7 +1537,7 @@ FROM (
INNER JOIN concept_map cm1 ON observation.observation_concept_id = cm1.source_concept_id
AND LOWER(cm1.domain_id) IN ('measurement')
LEFT JOIN concept_map cm2 ON observation.unit_concept_id = cm2.source_concept_id
AND LOWER(cm1.domain_id) IN ('unit')
AND LOWER(cm2.domain_id) IN ('unit')
UNION ALL

View File

@ -486,7 +486,7 @@ SELECT person_id
,CAST(NULL AS INT) AS cause_source_concept_id
FROM [SOURCE_CDMV4].[SCHEMA].DEATH
LEFT JOIN concept_map_distinct cm1 ON DEATH.DEATH_TYPE_CONCEPT_ID = CM1.SOURCE_CONCEPT_ID
AND LOWER(DOMAIN_ID) IN ('death type');
AND LOWER(DOMAIN_ID) IN ('death type', 'Type Concept');
INSERT INTO [TARGET_CDMV5].[SCHEMA].ETL_WARNINGS (WARNING_MESSAGE)
SELECT 'DEATH: ' || CAST(NUM_INVALID_RECORDS AS VARCHAR) || ' records in the source CDMv4 database have invalid DEATH_TYPE_CONCEPT_ID'
@ -499,7 +499,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('death type')
AND LOWER(DOMAIN_ID) IN ('death type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -600,7 +600,7 @@ INNER JOIN concept_map_distinct cmdis ON cm1.source_concept_id = cmdis.source_co
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount = 1
LEFT JOIN concept_map cm2 ON PROCEDURE_OCCURRENCE.PROCEDURE_TYPE_CONCEPT_ID = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('procedure type')
AND LOWER(cm2.domain_id) IN ('procedure type', 'Type Concept')
LEFT JOIN concept_map_distinct cmdis2 ON cm2.source_concept_id = cmdis2.source_concept_id
AND cm2.domain_id = cmdis2.domain_id
AND cmdis2.targetConceptCount = 1
@ -643,7 +643,7 @@ SELECT procedure_occurrence_id
FROM [SOURCE_CDMV4].[SCHEMA].PROCEDURE_OCCURRENCE
LEFT JOIN concept_map cm1 ON procedure_concept_id = cm1.source_concept_id
LEFT JOIN concept_map cm2 ON procedure_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('procedure type')
AND LOWER(cm2.domain_id) IN ('procedure type', 'Type Concept')
WHERE procedure_concept_id <> 0
AND cm1.domain_id IS NULL
@ -691,7 +691,7 @@ FROM (
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount > 1
LEFT JOIN concept_map cm2 ON PROCEDURE_OCCURRENCE.PROCEDURE_TYPE_CONCEPT_ID = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('procedure type')
AND LOWER(cm2.domain_id) IN ('procedure type', 'Type Concept')
UNION ALL
@ -812,7 +812,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('procedure type')
AND LOWER(DOMAIN_ID) IN ('procedure type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -892,7 +892,7 @@ INNER JOIN concept_map_distinct cmdis ON cm1.source_concept_id = cmdis.source_co
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount = 1
LEFT JOIN concept_map cm2 ON drug_exposure.drug_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('drug type')
AND LOWER(cm2.domain_id) IN ('drug type', 'Type Concept')
INNER JOIN concept_map_distinct cmdis2 ON cm2.source_concept_id = cmdis2.source_concept_id
AND cm2.domain_id = cmdis2.domain_id
AND cmdis2.targetConceptCount = 1
@ -954,7 +954,7 @@ SELECT drug_exposure_id
FROM [SOURCE_CDMV4].[SCHEMA].DRUG_EXPOSURE
LEFT JOIN concept_map cm1 ON drug_concept_id = cm1.source_concept_id
LEFT JOIN concept_map cm2 ON drug_exposure.drug_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('drug type')
AND LOWER(cm2.domain_id) IN ('drug type', 'Type Concept')
WHERE drug_concept_id <> 0
AND cm1.domain_id IS NULL
@ -1019,7 +1019,7 @@ FROM (
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount > 1
LEFT JOIN concept_map cm2 ON drug_exposure.drug_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('drug type')
AND LOWER(cm2.domain_id) IN ('drug type', 'Type Concept')
UNION ALL
@ -1185,7 +1185,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('drug type')
AND LOWER(DOMAIN_ID) IN ('drug type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -1216,7 +1216,7 @@ INNER JOIN concept_map_distinct cmdis ON cm1.source_concept_id = cmdis.source_co
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount = 1
LEFT JOIN concept_map cm2 ON condition_occurrence.condition_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('condition type')
AND LOWER(cm2.domain_id) IN ('condition type', 'Type Concept')
WHERE condition_concept_id > 0 -- This condition will map those concepts that were mapped to valid concepts in V4
UNION ALL
@ -1253,7 +1253,7 @@ SELECT condition_occurrence_id
FROM [SOURCE_CDMV4].[SCHEMA].CONDITION_OCCURRENCE
LEFT JOIN concept_map cm1 ON condition_occurrence.condition_concept_id = cm1.source_concept_id
LEFT JOIN concept_map cm2 ON condition_occurrence.condition_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('condition type')
AND LOWER(cm2.domain_id) IN ('condition type', 'Type Concept')
WHERE condition_concept_id <> 0
AND cm1.domain_id IS NULL
@ -1296,7 +1296,7 @@ FROM (
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount > 1
LEFT JOIN concept_map cm2 ON condition_occurrence.condition_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('condition type')
AND LOWER(cm2.domain_id) IN ('condition type', 'Type Concept')
WHERE condition_concept_id > 0 -- This condition will map those concepts that were mapped to valid concepts in V4
UNION ALL
@ -1384,7 +1384,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('condition type')
AND LOWER(DOMAIN_ID) IN ('condition type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -1537,7 +1537,7 @@ FROM (
INNER JOIN concept_map cm1 ON observation.observation_concept_id = cm1.source_concept_id
AND LOWER(cm1.domain_id) IN ('measurement')
LEFT JOIN concept_map cm2 ON observation.unit_concept_id = cm2.source_concept_id
AND LOWER(cm1.domain_id) IN ('unit')
AND LOWER(cm2.domain_id) IN ('unit')
UNION ALL

View File

@ -485,7 +485,7 @@ SELECT person_id
,CAST(NULL AS INT) AS cause_source_concept_id
FROM [SOURCE_CDMV4].[SCHEMA].DEATH
LEFT JOIN #concept_map_distinct cm1 ON DEATH.DEATH_TYPE_CONCEPT_ID = CM1.SOURCE_CONCEPT_ID
AND LOWER(DOMAIN_ID) IN ('death type');
AND LOWER(DOMAIN_ID) IN ('death type', 'Type Concept');
INSERT INTO [TARGET_CDMV5].[SCHEMA].ETL_WARNINGS (WARNING_MESSAGE)
SELECT 'DEATH: ' + CAST(NUM_INVALID_RECORDS AS VARCHAR) + ' records in the source CDMv4 database have invalid DEATH_TYPE_CONCEPT_ID'
@ -498,7 +498,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('death type')
AND LOWER(DOMAIN_ID) IN ('death type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -597,7 +597,7 @@ INNER JOIN #concept_map_distinct cmdis ON cm1.source_concept_id = cmdis.source_c
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount = 1
LEFT JOIN #concept_map cm2 ON PROCEDURE_OCCURRENCE.PROCEDURE_TYPE_CONCEPT_ID = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('procedure type')
AND LOWER(cm2.domain_id) IN ('procedure type', 'Type Concept')
LEFT JOIN #concept_map_distinct cmdis2 ON cm2.source_concept_id = cmdis2.source_concept_id
AND cm2.domain_id = cmdis2.domain_id
AND cmdis2.targetConceptCount = 1
@ -640,7 +640,7 @@ SELECT procedure_occurrence_id
FROM [SOURCE_CDMV4].[SCHEMA].PROCEDURE_OCCURRENCE
LEFT JOIN #concept_map cm1 ON procedure_concept_id = cm1.source_concept_id
LEFT JOIN #concept_map cm2 ON procedure_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('procedure type')
AND LOWER(cm2.domain_id) IN ('procedure type', 'Type Concept')
WHERE procedure_concept_id <> 0
AND cm1.domain_id IS NULL
@ -688,7 +688,7 @@ FROM (
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount > 1
LEFT JOIN #concept_map cm2 ON PROCEDURE_OCCURRENCE.PROCEDURE_TYPE_CONCEPT_ID = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('procedure type')
AND LOWER(cm2.domain_id) IN ('procedure type', 'Type Concept')
UNION ALL
@ -809,7 +809,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('procedure type')
AND LOWER(DOMAIN_ID) IN ('procedure type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -887,7 +887,7 @@ INNER JOIN #concept_map_distinct cmdis ON cm1.source_concept_id = cmdis.source_c
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount = 1
LEFT JOIN #concept_map cm2 ON drug_exposure.drug_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('drug type')
AND LOWER(cm2.domain_id) IN ('drug type', 'Type Concept')
INNER JOIN #concept_map_distinct cmdis2 ON cm2.source_concept_id = cmdis2.source_concept_id
AND cm2.domain_id = cmdis2.domain_id
AND cmdis2.targetConceptCount = 1
@ -949,7 +949,7 @@ SELECT drug_exposure_id
FROM [SOURCE_CDMV4].[SCHEMA].DRUG_EXPOSURE
LEFT JOIN #concept_map cm1 ON drug_concept_id = cm1.source_concept_id
LEFT JOIN #concept_map cm2 ON drug_exposure.drug_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('drug type')
AND LOWER(cm2.domain_id) IN ('drug type', 'Type Concept')
WHERE drug_concept_id <> 0
AND cm1.domain_id IS NULL
@ -1014,7 +1014,7 @@ FROM (
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount > 1
LEFT JOIN #concept_map cm2 ON drug_exposure.drug_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('drug type')
AND LOWER(cm2.domain_id) IN ('drug type', 'Type Concept')
UNION ALL
@ -1180,7 +1180,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('drug type')
AND LOWER(DOMAIN_ID) IN ('drug type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -1211,7 +1211,7 @@ INNER JOIN #concept_map_distinct cmdis ON cm1.source_concept_id = cmdis.source_c
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount = 1
LEFT JOIN #concept_map cm2 ON condition_occurrence.condition_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('condition type')
AND LOWER(cm2.domain_id) IN ('condition type', 'Type Concept')
WHERE condition_concept_id > 0 -- This condition will map those concepts that were mapped to valid concepts in V4
UNION ALL
@ -1248,7 +1248,7 @@ SELECT condition_occurrence_id
FROM [SOURCE_CDMV4].[SCHEMA].CONDITION_OCCURRENCE
LEFT JOIN #concept_map cm1 ON condition_occurrence.condition_concept_id = cm1.source_concept_id
LEFT JOIN #concept_map cm2 ON condition_occurrence.condition_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('condition type')
AND LOWER(cm2.domain_id) IN ('condition type', 'Type Concept')
WHERE condition_concept_id <> 0
AND cm1.domain_id IS NULL
@ -1291,7 +1291,7 @@ FROM (
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount > 1
LEFT JOIN #concept_map cm2 ON condition_occurrence.condition_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('condition type')
AND LOWER(cm2.domain_id) IN ('condition type', 'Type Concept')
WHERE condition_concept_id > 0 -- This condition will map those concepts that were mapped to valid concepts in V4
UNION ALL
@ -1379,7 +1379,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('condition type')
AND LOWER(DOMAIN_ID) IN ('condition type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -1532,7 +1532,7 @@ FROM (
INNER JOIN #concept_map cm1 ON observation.observation_concept_id = cm1.source_concept_id
AND LOWER(cm1.domain_id) IN ('measurement')
LEFT JOIN #concept_map cm2 ON observation.unit_concept_id = cm2.source_concept_id
AND LOWER(cm1.domain_id) IN ('unit')
AND LOWER(cm2.domain_id) IN ('unit')
UNION ALL

View File

@ -479,7 +479,7 @@ SELECT person_id
,CAST(NULL AS INT) AS cause_source_concept_id
FROM [SOURCE_CDMV4].[SCHEMA].DEATH
LEFT JOIN #concept_map_distinct cm1 ON DEATH.DEATH_TYPE_CONCEPT_ID = CM1.SOURCE_CONCEPT_ID
AND LOWER(DOMAIN_ID) IN ('death type');
AND LOWER(DOMAIN_ID) IN ('death type', 'Type Concept');
INSERT INTO [TARGET_CDMV5].[SCHEMA].ETL_WARNINGS (WARNING_MESSAGE)
SELECT 'DEATH: ' + CAST(NUM_INVALID_RECORDS AS VARCHAR) + ' records in the source CDMv4 database have invalid DEATH_TYPE_CONCEPT_ID'
@ -492,7 +492,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('death type')
AND LOWER(DOMAIN_ID) IN ('death type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -589,7 +589,7 @@ INNER JOIN #concept_map_distinct cmdis ON cm1.source_concept_id = cmdis.source_c
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount = 1
LEFT JOIN #concept_map cm2 ON PROCEDURE_OCCURRENCE.PROCEDURE_TYPE_CONCEPT_ID = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('procedure type')
AND LOWER(cm2.domain_id) IN ('procedure type', 'Type Concept')
LEFT JOIN #concept_map_distinct cmdis2 ON cm2.source_concept_id = cmdis2.source_concept_id
AND cm2.domain_id = cmdis2.domain_id
AND cmdis2.targetConceptCount = 1
@ -632,7 +632,7 @@ SELECT procedure_occurrence_id
FROM [SOURCE_CDMV4].[SCHEMA].PROCEDURE_OCCURRENCE
LEFT JOIN #concept_map cm1 ON procedure_concept_id = cm1.source_concept_id
LEFT JOIN #concept_map cm2 ON procedure_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('procedure type')
AND LOWER(cm2.domain_id) IN ('procedure type', 'Type Concept')
WHERE procedure_concept_id <> 0
AND cm1.domain_id IS NULL
@ -680,7 +680,7 @@ FROM (
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount > 1
LEFT JOIN #concept_map cm2 ON PROCEDURE_OCCURRENCE.PROCEDURE_TYPE_CONCEPT_ID = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('procedure type')
AND LOWER(cm2.domain_id) IN ('procedure type', 'Type Concept')
UNION ALL
@ -801,7 +801,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('procedure type')
AND LOWER(DOMAIN_ID) IN ('procedure type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -877,7 +877,7 @@ INNER JOIN #concept_map_distinct cmdis ON cm1.source_concept_id = cmdis.source_c
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount = 1
LEFT JOIN #concept_map cm2 ON drug_exposure.drug_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('drug type')
AND LOWER(cm2.domain_id) IN ('drug type', 'Type Concept')
INNER JOIN #concept_map_distinct cmdis2 ON cm2.source_concept_id = cmdis2.source_concept_id
AND cm2.domain_id = cmdis2.domain_id
AND cmdis2.targetConceptCount = 1
@ -939,7 +939,7 @@ SELECT drug_exposure_id
FROM [SOURCE_CDMV4].[SCHEMA].DRUG_EXPOSURE
LEFT JOIN #concept_map cm1 ON drug_concept_id = cm1.source_concept_id
LEFT JOIN #concept_map cm2 ON drug_exposure.drug_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('drug type')
AND LOWER(cm2.domain_id) IN ('drug type', 'Type Concept')
WHERE drug_concept_id <> 0
AND cm1.domain_id IS NULL
@ -1004,7 +1004,7 @@ FROM (
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount > 1
LEFT JOIN #concept_map cm2 ON drug_exposure.drug_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('drug type')
AND LOWER(cm2.domain_id) IN ('drug type', 'Type Concept')
UNION ALL
@ -1170,7 +1170,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('drug type')
AND LOWER(DOMAIN_ID) IN ('drug type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -1201,7 +1201,7 @@ INNER JOIN #concept_map_distinct cmdis ON cm1.source_concept_id = cmdis.source_c
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount = 1
LEFT JOIN #concept_map cm2 ON condition_occurrence.condition_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('condition type')
AND LOWER(cm2.domain_id) IN ('condition type', 'Type Concept')
WHERE condition_concept_id > 0 -- This condition will map those concepts that were mapped to valid concepts in V4
UNION ALL
@ -1238,7 +1238,7 @@ SELECT condition_occurrence_id
FROM [SOURCE_CDMV4].[SCHEMA].CONDITION_OCCURRENCE
LEFT JOIN #concept_map cm1 ON condition_occurrence.condition_concept_id = cm1.source_concept_id
LEFT JOIN #concept_map cm2 ON condition_occurrence.condition_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('condition type')
AND LOWER(cm2.domain_id) IN ('condition type', 'Type Concept')
WHERE condition_concept_id <> 0
AND cm1.domain_id IS NULL
@ -1281,7 +1281,7 @@ FROM (
AND cm1.domain_id = cmdis.domain_id
AND cmdis.targetConceptCount > 1
LEFT JOIN #concept_map cm2 ON condition_occurrence.condition_type_concept_id = cm2.source_concept_id
AND LOWER(cm2.domain_id) IN ('condition type')
AND LOWER(cm2.domain_id) IN ('condition type', 'Type Concept')
WHERE condition_concept_id > 0 -- This condition will map those concepts that were mapped to valid concepts in V4
UNION ALL
@ -1369,7 +1369,7 @@ FROM (
WHERE CONCEPT_ID = 0
OR (
STANDARD_CONCEPT = 'S'
AND LOWER(DOMAIN_ID) IN ('condition type')
AND LOWER(DOMAIN_ID) IN ('condition type', 'Type Concept')
)
)
HAVING COUNT(PERSON_ID) > 0
@ -1522,7 +1522,7 @@ FROM (
INNER JOIN #concept_map cm1 ON observation.observation_concept_id = cm1.source_concept_id
AND LOWER(cm1.domain_id) IN ('measurement')
LEFT JOIN #concept_map cm2 ON observation.unit_concept_id = cm2.source_concept_id
AND LOWER(cm1.domain_id) IN ('unit')
AND LOWER(cm2.domain_id) IN ('unit')
UNION ALL