From e94a6dfc2029eb23f2e59bff0412919ebcef5781 Mon Sep 17 00:00:00 2001 From: Michael Prittie Date: Mon, 28 Mar 2016 14:38:12 -0500 Subject: [PATCH 01/15] Replace default SCHILS PCORI_LAB hierarchy with local lab result hierarchy. --- Oracle/pcornet_mapping.sql | 83 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/Oracle/pcornet_mapping.sql b/Oracle/pcornet_mapping.sql index b67d147..4a7e76c 100644 --- a/Oracle/pcornet_mapping.sql +++ b/Oracle/pcornet_mapping.sql @@ -424,3 +424,86 @@ join "&&i2b2_meta_schema".pcornet_med on med_mod_mapping.PCORI_PATH = pcornet_me ; commit; + +/* Replace PCORNet Labs (LOINC) hierarchy with the local hierarchy. +*/ + +-- Create temporary table for mapping LOINC codes to PCORI specimen source values +CREATE TABLE TEMP_LAB_LOINC_MAP (PCORI_BASECODE VARCHAR2(50 BYTE), PCORI_SPECIMEN_SOURCE VARCHAR2(50 BYTE)); +INSERT ALL + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','10839-9') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','12187-1') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','12189-7') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','13969-1') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','14682-9') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','14775-1') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','16255-2') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','17856-6') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','20509-6') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','20569-0') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','21232-4') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','2154-3') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','2157-6') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','2160-0') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','30313-1') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','30350-3') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','30351-1') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','30352-9') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','32673-6') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','33204-9') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','34714-6') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','35203-9') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','38483-4') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','42757-5') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','44784-7') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','4548-4') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','46418-0') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','47213-4') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','48425-3') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','48426-1') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','49136-5') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','49551-5') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','49563-0') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','50756-6') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','55782-7') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','59260-0') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','59826-8') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('PPP','6301-6') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','6597-9') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','6598-7') + INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','718-7') +SELECT * FROM DUAL; + +-- Delete SCHILS Lab hierarchy +delete +from "&&i2b2_meta_schema".PCORNET_LAB +where c_fullname like '\PCORI\LAB_RESULT\%' +; + +-- Replace with local Lab hierarchy + PCORI_BASECODE + PCORI_SPECIMEN_SOURCE +insert into "&&i2b2_meta_schema".PCORNET_LAB +with terms_loinc as ( + select + ht.*, replace(ht.c_basecode, 'LOINC:', '') lc + from + "&&i2b2_meta_schema"."&&terms_table" ht + where c_fullname like '\i2b2\Laboratory Tests\%' and c_basecode like 'LOINC:%' order by c_hlevel + ) +select + tl.c_hlevel, + replace(tl.c_fullname, '\i2b2\Laboratory Tests\', '\PCORI\LAB_RESULT\') c_fullname, + tl.c_name, tl.c_synonym_cd, tl.c_visualattributes, + tl.c_totalnum, tl.c_basecode, tl.c_metadataxml, tl.c_facttablecolumn, tl.c_tablename, + tl.c_columnname, tl.c_columndatatype, tl.c_operator, tl.c_dimcode, tl.c_comment, + tl.c_tooltip, tl.m_applied_path, tl.update_date, tl.download_date, tl.import_date, + tl.sourcesystem_cd, tl.valuetype_cd, tl.m_exclusion_cd, tl.c_path, tl.c_symbol, + tllm.pcori_basecode, tl.lc pcori_specimen_souce +from terms_loinc tl left join temp_lab_loinc_map tllm on tl.lc = tllm.pcori_specimen_source +order by c_hlevel +; + +-- Drop temporary table +DROP TABLE TEMP_LAB_LOINC_MAP; + +commit; + From 1976883beaf51296ae1a8a2dda61a7a4a2ada752 Mon Sep 17 00:00:00 2001 From: Michael Prittie Date: Mon, 28 Mar 2016 16:02:36 -0500 Subject: [PATCH 02/15] Attempting to correct PCORI_LAB path issue which causes tranform to fail. --- Oracle/pcornet_mapping.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Oracle/pcornet_mapping.sql b/Oracle/pcornet_mapping.sql index 4a7e76c..ea777a2 100644 --- a/Oracle/pcornet_mapping.sql +++ b/Oracle/pcornet_mapping.sql @@ -491,7 +491,7 @@ with terms_loinc as ( ) select tl.c_hlevel, - replace(tl.c_fullname, '\i2b2\Laboratory Tests\', '\PCORI\LAB_RESULT\') c_fullname, + replace(tl.c_fullname, '\i2b2\Laboratory Tests\', '\PCORI\LAB_RESULT_CM\') c_fullname, tl.c_name, tl.c_synonym_cd, tl.c_visualattributes, tl.c_totalnum, tl.c_basecode, tl.c_metadataxml, tl.c_facttablecolumn, tl.c_tablename, tl.c_columnname, tl.c_columndatatype, tl.c_operator, tl.c_dimcode, tl.c_comment, From 8051c443a8ae865f0e827ca493b9be2b0aa1b13d Mon Sep 17 00:00:00 2001 From: Michael Prittie Date: Mon, 28 Mar 2016 16:35:00 -0500 Subject: [PATCH 03/15] Forgot update the path while removing the SCHILS paths. --- Oracle/pcornet_mapping.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Oracle/pcornet_mapping.sql b/Oracle/pcornet_mapping.sql index ea777a2..9344cf3 100644 --- a/Oracle/pcornet_mapping.sql +++ b/Oracle/pcornet_mapping.sql @@ -477,7 +477,7 @@ SELECT * FROM DUAL; -- Delete SCHILS Lab hierarchy delete from "&&i2b2_meta_schema".PCORNET_LAB -where c_fullname like '\PCORI\LAB_RESULT\%' +where c_fullname like '\PCORI\LAB_RESULT_CM\%' ; -- Replace with local Lab hierarchy + PCORI_BASECODE + PCORI_SPECIMEN_SOURCE From 21924791e807fda952d299b03176f5052e75b09a Mon Sep 17 00:00:00 2001 From: Michael Prittie Date: Mon, 25 Apr 2016 09:43:43 -0500 Subject: [PATCH 04/15] Add relevent nodes from local i2b2 lab hierarchy to SCHILS Lab hierarchy. --- Oracle/pcornet_mapping.sql | 115 +++++++++++++------------------------ 1 file changed, 40 insertions(+), 75 deletions(-) diff --git a/Oracle/pcornet_mapping.sql b/Oracle/pcornet_mapping.sql index 9344cf3..7521b5a 100644 --- a/Oracle/pcornet_mapping.sql +++ b/Oracle/pcornet_mapping.sql @@ -425,85 +425,50 @@ join "&&i2b2_meta_schema".pcornet_med on med_mod_mapping.PCORI_PATH = pcornet_me commit; -/* Replace PCORNet Labs (LOINC) hierarchy with the local hierarchy. +/* Add relevent nodes from local i2b2 lab hierarchy to PCORNet Labs hierarchy. */ --- Create temporary table for mapping LOINC codes to PCORI specimen source values -CREATE TABLE TEMP_LAB_LOINC_MAP (PCORI_BASECODE VARCHAR2(50 BYTE), PCORI_SPECIMEN_SOURCE VARCHAR2(50 BYTE)); -INSERT ALL - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','10839-9') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','12187-1') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','12189-7') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','13969-1') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','14682-9') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','14775-1') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','16255-2') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','17856-6') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','20509-6') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','20569-0') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','21232-4') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','2154-3') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','2157-6') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','2160-0') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','30313-1') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','30350-3') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','30351-1') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','30352-9') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','32673-6') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','33204-9') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','34714-6') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','35203-9') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','38483-4') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','42757-5') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','44784-7') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','4548-4') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','46418-0') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','47213-4') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','48425-3') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','48426-1') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','49136-5') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','49551-5') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','49563-0') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','50756-6') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','55782-7') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','59260-0') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','59826-8') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('PPP','6301-6') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','6597-9') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('SERUM, PLASMA, or SR_PLS','6598-7') - INTO TEMP_LAB_LOINC_MAP (PCORI_BASECODE, PCORI_SPECIMEN_SOURCE) VALUES ('BLOOD','718-7') -SELECT * FROM DUAL; - --- Delete SCHILS Lab hierarchy -delete -from "&&i2b2_meta_schema".PCORNET_LAB -where c_fullname like '\PCORI\LAB_RESULT_CM\%' -; - --- Replace with local Lab hierarchy + PCORI_BASECODE + PCORI_SPECIMEN_SOURCE insert into "&&i2b2_meta_schema".PCORNET_LAB -with terms_loinc as ( - select - ht.*, replace(ht.c_basecode, 'LOINC:', '') lc - from - "&&i2b2_meta_schema"."&&terms_table" ht - where c_fullname like '\i2b2\Laboratory Tests\%' and c_basecode like 'LOINC:%' order by c_hlevel - ) -select - tl.c_hlevel, - replace(tl.c_fullname, '\i2b2\Laboratory Tests\', '\PCORI\LAB_RESULT_CM\') c_fullname, - tl.c_name, tl.c_synonym_cd, tl.c_visualattributes, - tl.c_totalnum, tl.c_basecode, tl.c_metadataxml, tl.c_facttablecolumn, tl.c_tablename, - tl.c_columnname, tl.c_columndatatype, tl.c_operator, tl.c_dimcode, tl.c_comment, - tl.c_tooltip, tl.m_applied_path, tl.update_date, tl.download_date, tl.import_date, - tl.sourcesystem_cd, tl.valuetype_cd, tl.m_exclusion_cd, tl.c_path, tl.c_symbol, - tllm.pcori_basecode, tl.lc pcori_specimen_souce -from terms_loinc tl left join temp_lab_loinc_map tllm on tl.lc = tllm.pcori_specimen_source -order by c_hlevel +with lab_map as ( + select distinct lab.c_hlevel, lab.c_path, lab.pcori_basecode, trim(CHR(13) from lab.pcori_specimen_source) as pcori_specimen_source + from "&&i2b2_meta_schema".pcornet_lab lab + inner JOIN "&&i2b2_meta_schema".pcornet_lab ont_parent on lab.c_path=ont_parent.c_fullname + inner join pmn_labnormal norm on ont_parent.c_basecode=norm.LAB_NAME + where lab.c_fullname like '\PCORI\LAB_RESULT_CM\%' +) +select +lm.C_HLEVEL, +concat(lm.c_path, substr(regexp_substr(lt.c_fullname, '\\[^\\]+\\$'), 2, length(regexp_substr(lt.c_fullname, '\\[^\\]+\\$')))) as c_fullname, +lt.C_NAME, +lt.C_SYNONYM_CD, +lt.C_VISUALATTRIBUTES, +lt.C_TOTALNUM, +lt.C_BASECODE, +lt.C_METADATAXML, +lt.C_FACTTABLECOLUMN, +lt.C_TABLENAME, +lt.C_COLUMNNAME, +lt.C_COLUMNDATATYPE, +lt.C_OPERATOR, +lt.C_DIMCODE, +lt.C_COMMENT, +lt.C_TOOLTIP, +lt.M_APPLIED_PATH, +lt.UPDATE_DATE, +lt.DOWNLOAD_DATE, +lt.IMPORT_DATE, +lt.SOURCESYSTEM_CD, +lt.VALUETYPE_CD, +lt.M_EXCLUSION_CD, +lm.C_PATH, +lt.C_SYMBOL, +lt.TERM_ID, +lm.PCORI_BASECODE, +lm.pcori_specimen_source +from "&&i2b2_meta_schema"."&&terms_table" lt, lab_map lm +where lm.pcori_specimen_source=replace(lt.c_basecode, 'LOINC:', '') +and lt.c_fullname like '\i2b2\Laboratory Tests\%' and lt.c_basecode like 'LOINC:%' ; --- Drop temporary table -DROP TABLE TEMP_LAB_LOINC_MAP; - commit; From ab172f101c870818741a47cf03285d483db97150 Mon Sep 17 00:00:00 2001 From: Michael Prittie Date: Tue, 26 Apr 2016 14:40:56 -0500 Subject: [PATCH 05/15] Removed local column reference. --- Oracle/pcornet_mapping.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/Oracle/pcornet_mapping.sql b/Oracle/pcornet_mapping.sql index 7521b5a..87d12f8 100644 --- a/Oracle/pcornet_mapping.sql +++ b/Oracle/pcornet_mapping.sql @@ -462,7 +462,6 @@ lt.VALUETYPE_CD, lt.M_EXCLUSION_CD, lm.C_PATH, lt.C_SYMBOL, -lt.TERM_ID, lm.PCORI_BASECODE, lm.pcori_specimen_source from "&&i2b2_meta_schema"."&&terms_table" lt, lab_map lm From aa9dd537808f71e185ddf87097f872684fde8fb8 Mon Sep 17 00:00:00 2001 From: Michael Prittie Date: Wed, 27 Apr 2016 08:59:09 -0500 Subject: [PATCH 06/15] Moved static PMN_LabNormal creation out of PCORNETLoader.sql for use in mapping. --- Oracle/PCORNetLoader_ora.sql | 60 ------------------------------------ Oracle/pmn_labnormal.csv | 13 ++++++++ Oracle/run-i2p-transform.sh | 1 + 3 files changed, 14 insertions(+), 60 deletions(-) create mode 100644 Oracle/pmn_labnormal.csv diff --git a/Oracle/PCORNetLoader_ora.sql b/Oracle/PCORNetLoader_ora.sql index 1750f37..ac66ea8 100644 --- a/Oracle/PCORNetLoader_ora.sql +++ b/Oracle/PCORNetLoader_ora.sql @@ -415,66 +415,6 @@ begin end; / -BEGIN -PMN_DROPSQL('DROP TABLE PMN_LabNormal'); -END; -/ -CREATE TABLE PMN_LabNormal ( - LAB_NAME varchar(150) NULL, - NORM_RANGE_LOW varchar(10) NULL, - NORM_MODIFIER_LOW varchar(2) NULL, - NORM_RANGE_HIGH varchar(10) NULL, - NORM_MODIFIER_HIGH varchar(2) NULL - ) -/ - -INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) - VALUES('LAB_NAME:LDL', '0', 'GE', '165', 'LE') -/ - -INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) - VALUES('LAB_NAME:A1C', '', 'NI', '', 'NI') -/ - -INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) - VALUES('LAB_NAME:CK', '50', 'GE', '236', 'LE') -/ - -INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) - VALUES('LAB_NAME:CK_MB', '', 'NI', '', 'NI') -/ - -INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) - VALUES('LAB_NAME:CK_MBI', '', 'NI', '', 'NI') -/ - -INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) - VALUES('LAB_NAME:CREATININE', '0', 'GE', '1.6', 'LE') -/ - -INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) - VALUES('LAB_NAME:CREATININE', '0', 'GE', '1.6', 'LE') -/ - -INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) - VALUES('LAB_NAME:HGB', '12', 'GE', '17.5', 'LE') -/ - -INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) - VALUES('LAB_NAME:INR', '0.8', 'GE', '1.3', 'LE') -/ - -INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) - VALUES('LAB_NAME:TROP_I', '0', 'GE', '0.49', 'LE') -/ - -INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) - VALUES('LAB_NAME:TROP_T_QL', '', 'NI', '', 'NI') -/ - -INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) - VALUES('LAB_NAME:TROP_T_QN', '0', 'GE', '0.09', 'LE') -/ BEGIN PMN_DROPSQL('DROP TABLE death'); diff --git a/Oracle/pmn_labnormal.csv b/Oracle/pmn_labnormal.csv new file mode 100644 index 0000000..6d6277a --- /dev/null +++ b/Oracle/pmn_labnormal.csv @@ -0,0 +1,13 @@ +LAB_NAME,NORM_RANGE_LOW,NORM_MODIFIER_LOW,NORM_RANGE_HIGH,NORM_MODIFIER_HIGH +LAB_NAME:LDL,0,GE,165,LE +LAB_NAME:A1C,,NI,,NI +LAB_NAME:CK,50,GE,236,LE +LAB_NAME:CK_MB,,NI,,NI +LAB_NAME:CK_MBI,,NI,,NI +LAB_NAME:CREATININE,0,GE,1.6,LE +LAB_NAME:CREATININE,0,GE,1.6,LE +LAB_NAME:HGB,12,GE,17.5,LE +LAB_NAME:INR,0.8,GE,1.3,LE +LAB_NAME:TROP_I,0,GE,0.49,LE +LAB_NAME:TROP_T_QL,,NI,,NI +LAB_NAME:TROP_T_QN,0,GE,0.09,LE diff --git a/Oracle/run-i2p-transform.sh b/Oracle/run-i2p-transform.sh index d55a49b..a740256 100644 --- a/Oracle/run-i2p-transform.sh +++ b/Oracle/run-i2p-transform.sh @@ -24,6 +24,7 @@ set -e #export terms_table= python load_csv.py harvest_local harvest_local.csv harvest_local.ctl pcornet_cdm_user pcornet_cdm +python load_csv.py PMN_LabNormal pmn_labnormal.csv pmn_labnormal.ctl pcornet_cdm_user pcornet_cdm . ./load_pcornet_mapping.sh # Run some tests From baa708ff232cd58675873f83c99d4da0f5a91d36 Mon Sep 17 00:00:00 2001 From: Michael Prittie Date: Mon, 2 May 2016 14:20:29 -0500 Subject: [PATCH 07/15] 2nd attempt at hanging the correct local nodes under SCHILS lab nodes. --- Oracle/pcornet_mapping.sql | 108 ++++++++++++++++++++++++------------- 1 file changed, 71 insertions(+), 37 deletions(-) diff --git a/Oracle/pcornet_mapping.sql b/Oracle/pcornet_mapping.sql index 87d12f8..295a1c2 100644 --- a/Oracle/pcornet_mapping.sql +++ b/Oracle/pcornet_mapping.sql @@ -430,44 +430,78 @@ commit; insert into "&&i2b2_meta_schema".PCORNET_LAB with lab_map as ( - select distinct lab.c_hlevel, lab.c_path, lab.pcori_basecode, trim(CHR(13) from lab.pcori_specimen_source) as pcori_specimen_source - from "&&i2b2_meta_schema".pcornet_lab lab - inner JOIN "&&i2b2_meta_schema".pcornet_lab ont_parent on lab.c_path=ont_parent.c_fullname - inner join pmn_labnormal norm on ont_parent.c_basecode=norm.LAB_NAME - where lab.c_fullname like '\PCORI\LAB_RESULT_CM\%' + select distinct lab.c_hlevel, lab.c_path, lab.pcori_basecode, trim(CHR(13) from lab.pcori_specimen_source) as pcori_specimen_source + from pcornet_lab lab + inner JOIN pcornet_lab ont_parent on lab.c_path=ont_parent.c_fullname + inner join pmn_labnormal norm on ont_parent.c_basecode=norm.LAB_NAME + where lab.c_fullname like '\PCORI\LAB_RESULT_CM\%' +), +local_loinc_terms as ( + select + lm.C_HLEVEL, + lt.C_FULLNAME, + lt.C_NAME, + lt.C_SYNONYM_CD, + lt.C_VISUALATTRIBUTES, + lt.C_TOTALNUM, + lt.C_BASECODE, + lt.C_METADATAXML, + lt.C_FACTTABLECOLUMN, + lt.C_TABLENAME, + lt.C_COLUMNNAME, + lt.C_COLUMNDATATYPE, + lt.C_OPERATOR, + lt.C_DIMCODE, + lt.C_COMMENT, + lt.C_TOOLTIP, + lt.M_APPLIED_PATH, + lt.UPDATE_DATE, + lt.DOWNLOAD_DATE, + lt.IMPORT_DATE, + lt.SOURCESYSTEM_CD, + lt.VALUETYPE_CD, + lt.M_EXCLUSION_CD, + lm.C_PATH, + lt.C_SYMBOL, + lt.TERM_ID, + lm.PCORI_BASECODE, + lm.pcori_specimen_source + from "&&i2b2_meta_schema"."&&terms_table" lt, lab_map lm + where lm.pcori_specimen_source=replace(lt.c_basecode, 'LOINC:', '') + and lt.c_fullname like '\i2b2\Laboratory Tests\%' and lt.c_basecode like 'LOINC:%' ) -select -lm.C_HLEVEL, -concat(lm.c_path, substr(regexp_substr(lt.c_fullname, '\\[^\\]+\\$'), 2, length(regexp_substr(lt.c_fullname, '\\[^\\]+\\$')))) as c_fullname, -lt.C_NAME, -lt.C_SYNONYM_CD, -lt.C_VISUALATTRIBUTES, -lt.C_TOTALNUM, -lt.C_BASECODE, -lt.C_METADATAXML, -lt.C_FACTTABLECOLUMN, -lt.C_TABLENAME, -lt.C_COLUMNNAME, -lt.C_COLUMNDATATYPE, -lt.C_OPERATOR, -lt.C_DIMCODE, -lt.C_COMMENT, -lt.C_TOOLTIP, -lt.M_APPLIED_PATH, -lt.UPDATE_DATE, -lt.DOWNLOAD_DATE, -lt.IMPORT_DATE, -lt.SOURCESYSTEM_CD, -lt.VALUETYPE_CD, -lt.M_EXCLUSION_CD, -lm.C_PATH, -lt.C_SYMBOL, -lm.PCORI_BASECODE, -lm.pcori_specimen_source -from "&&i2b2_meta_schema"."&&terms_table" lt, lab_map lm -where lm.pcori_specimen_source=replace(lt.c_basecode, 'LOINC:', '') -and lt.c_fullname like '\i2b2\Laboratory Tests\%' and lt.c_basecode like 'LOINC:%' -; +select + llt.C_HLEVEL, + concat(llt.c_path, substr(regexp_substr(lt.c_fullname, '\\[^\\]+\\$'), 2, length(regexp_substr(lt.c_fullname, '\\[^\\]+\\$')))) as c_fullname, + lt.C_NAME, + lt.C_SYNONYM_CD, + lt.C_VISUALATTRIBUTES, + lt.C_TOTALNUM, + lt.C_BASECODE, + lt.C_METADATAXML, + lt.C_FACTTABLECOLUMN, + lt.C_TABLENAME, + lt.C_COLUMNNAME, + lt.C_COLUMNDATATYPE, + lt.C_OPERATOR, + lt.C_DIMCODE, + lt.C_COMMENT, + lt.C_TOOLTIP, + lt.M_APPLIED_PATH, + lt.UPDATE_DATE, + lt.DOWNLOAD_DATE, + lt.IMPORT_DATE, + 'MAPPING', + lt.VALUETYPE_CD, + lt.M_EXCLUSION_CD, + llt.C_PATH, + lt.C_SYMBOL, + lt.TERM_ID, + llt.PCORI_BASECODE, + llt.pcori_specimen_source +from "&&i2b2_meta_schema"."&&terms_table" lt, local_loinc_terms llt +where lt.c_fullname like llt.c_fullname||'%\' +; commit; From 227e2d1f8e6e89bbd575f268ef2e7fbb8062e321 Mon Sep 17 00:00:00 2001 From: Michael Prittie Date: Wed, 4 May 2016 09:33:46 -0500 Subject: [PATCH 08/15] Cleaned up lab mapping SQL. --- Oracle/pcornet_mapping.sql | 103 +++++++++++++------------------------ 1 file changed, 37 insertions(+), 66 deletions(-) diff --git a/Oracle/pcornet_mapping.sql b/Oracle/pcornet_mapping.sql index 295a1c2..13dca3a 100644 --- a/Oracle/pcornet_mapping.sql +++ b/Oracle/pcornet_mapping.sql @@ -430,78 +430,49 @@ commit; insert into "&&i2b2_meta_schema".PCORNET_LAB with lab_map as ( - select distinct lab.c_hlevel, lab.c_path, lab.pcori_basecode, trim(CHR(13) from lab.pcori_specimen_source) as pcori_specimen_source - from pcornet_lab lab - inner JOIN pcornet_lab ont_parent on lab.c_path=ont_parent.c_fullname - inner join pmn_labnormal norm on ont_parent.c_basecode=norm.LAB_NAME - where lab.c_fullname like '\PCORI\LAB_RESULT_CM\%' + select distinct lab.c_hlevel, lab.c_path, lab.pcori_basecode, trim(CHR(13) from lab.pcori_specimen_source) as pcori_specimen_source + from pcornet_lab lab + inner JOIN pcornet_lab ont_parent on lab.c_path=ont_parent.c_fullname + inner join pmn_labnormal norm on ont_parent.c_basecode=norm.LAB_NAME + where lab.c_fullname like '\PCORI\LAB_RESULT_CM\%' ), local_loinc_terms as ( - select - lm.C_HLEVEL, - lt.C_FULLNAME, - lt.C_NAME, - lt.C_SYNONYM_CD, - lt.C_VISUALATTRIBUTES, - lt.C_TOTALNUM, - lt.C_BASECODE, - lt.C_METADATAXML, - lt.C_FACTTABLECOLUMN, - lt.C_TABLENAME, - lt.C_COLUMNNAME, - lt.C_COLUMNDATATYPE, - lt.C_OPERATOR, - lt.C_DIMCODE, - lt.C_COMMENT, - lt.C_TOOLTIP, - lt.M_APPLIED_PATH, - lt.UPDATE_DATE, - lt.DOWNLOAD_DATE, - lt.IMPORT_DATE, - lt.SOURCESYSTEM_CD, - lt.VALUETYPE_CD, - lt.M_EXCLUSION_CD, - lm.C_PATH, - lt.C_SYMBOL, - lt.TERM_ID, - lm.PCORI_BASECODE, - lm.pcori_specimen_source - from "&&i2b2_meta_schema"."&&terms_table" lt, lab_map lm - where lm.pcori_specimen_source=replace(lt.c_basecode, 'LOINC:', '') - and lt.c_fullname like '\i2b2\Laboratory Tests\%' and lt.c_basecode like 'LOINC:%' + select lm.C_HLEVEL, lt.C_FULLNAME, lm.C_PATH, lm.PCORI_BASECODE, lm.pcori_specimen_source + from "&&i2b2_meta_schema"."&&terms_table" lt, lab_map lm + where lm.pcori_specimen_source=replace(lt.c_basecode, 'LOINC:', '') + and lt.c_fullname like '\i2b2\Laboratory Tests\%' and lt.c_basecode like 'LOINC:%' ) select - llt.C_HLEVEL, - concat(llt.c_path, substr(regexp_substr(lt.c_fullname, '\\[^\\]+\\$'), 2, length(regexp_substr(lt.c_fullname, '\\[^\\]+\\$')))) as c_fullname, - lt.C_NAME, - lt.C_SYNONYM_CD, - lt.C_VISUALATTRIBUTES, - lt.C_TOTALNUM, - lt.C_BASECODE, - lt.C_METADATAXML, - lt.C_FACTTABLECOLUMN, - lt.C_TABLENAME, - lt.C_COLUMNNAME, - lt.C_COLUMNDATATYPE, - lt.C_OPERATOR, - lt.C_DIMCODE, - lt.C_COMMENT, - lt.C_TOOLTIP, - lt.M_APPLIED_PATH, - lt.UPDATE_DATE, - lt.DOWNLOAD_DATE, - lt.IMPORT_DATE, - 'MAPPING', - lt.VALUETYPE_CD, - lt.M_EXCLUSION_CD, - llt.C_PATH, - lt.C_SYMBOL, - lt.TERM_ID, - llt.PCORI_BASECODE, - llt.pcori_specimen_source + llt.C_HLEVEL, + concat(llt.c_path, substr(regexp_substr(lt.c_fullname, '\\[^\\]+\\$'), 2, length(regexp_substr(lt.c_fullname, '\\[^\\]+\\$')))) as c_fullname, + lt.C_NAME, + lt.C_SYNONYM_CD, + lt.C_VISUALATTRIBUTES, + lt.C_TOTALNUM, + lt.C_BASECODE, + lt.C_METADATAXML, + lt.C_FACTTABLECOLUMN, + lt.C_TABLENAME, + lt.C_COLUMNNAME, + lt.C_COLUMNDATATYPE, + lt.C_OPERATOR, + lt.C_DIMCODE, + lt.C_COMMENT, + lt.C_TOOLTIP, + lt.M_APPLIED_PATH, + lt.UPDATE_DATE, + lt.DOWNLOAD_DATE, + lt.IMPORT_DATE, + 'MAPPING', + lt.VALUETYPE_CD, + lt.M_EXCLUSION_CD, + llt.C_PATH, + lt.C_SYMBOL, + llt.PCORI_BASECODE, + llt.pcori_specimen_source from "&&i2b2_meta_schema"."&&terms_table" lt, local_loinc_terms llt where lt.c_fullname like llt.c_fullname||'%\' -; +; commit; From d4441ddeab3861652fdd846399c5f57c15c7b7db Mon Sep 17 00:00:00 2001 From: Michael Prittie Date: Wed, 4 May 2016 14:55:56 -0500 Subject: [PATCH 09/15] PMN_LABNORMAL was being dropped before it could be used. --- Oracle/run-i2p-transform.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/Oracle/run-i2p-transform.sh b/Oracle/run-i2p-transform.sh index a740256..77c08e7 100644 --- a/Oracle/run-i2p-transform.sh +++ b/Oracle/run-i2p-transform.sh @@ -66,7 +66,6 @@ set timing on; WHENEVER SQLERROR CONTINUE; -drop table PMN_LABNORMAL; drop table DEMOGRAPHIC; drop table ENROLLMENT; drop table ENCOUNTER; From 3828e24da97a94ee309bdd66008ba4981e663cdb Mon Sep 17 00:00:00 2001 From: Michael Prittie Date: Thu, 5 May 2016 13:58:29 -0500 Subject: [PATCH 10/15] Updated SQL to reflect the correction of PCORI_BASECODE/PCORI_SPECIMEN_SOURCE switch in CTL creation --- Oracle/pcornet_mapping.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Oracle/pcornet_mapping.sql b/Oracle/pcornet_mapping.sql index 13dca3a..986e9db 100644 --- a/Oracle/pcornet_mapping.sql +++ b/Oracle/pcornet_mapping.sql @@ -430,7 +430,7 @@ commit; insert into "&&i2b2_meta_schema".PCORNET_LAB with lab_map as ( - select distinct lab.c_hlevel, lab.c_path, lab.pcori_basecode, trim(CHR(13) from lab.pcori_specimen_source) as pcori_specimen_source + select distinct lab.c_hlevel, lab.c_path, lab.pcori_specimen_source, trim(CHR(13) from lab.pcori_basecode) as pcori_basecode from pcornet_lab lab inner JOIN pcornet_lab ont_parent on lab.c_path=ont_parent.c_fullname inner join pmn_labnormal norm on ont_parent.c_basecode=norm.LAB_NAME @@ -439,7 +439,7 @@ with lab_map as ( local_loinc_terms as ( select lm.C_HLEVEL, lt.C_FULLNAME, lm.C_PATH, lm.PCORI_BASECODE, lm.pcori_specimen_source from "&&i2b2_meta_schema"."&&terms_table" lt, lab_map lm - where lm.pcori_specimen_source=replace(lt.c_basecode, 'LOINC:', '') + where lm.pcori_basecode=replace(lt.c_basecode, 'LOINC:', '') and lt.c_fullname like '\i2b2\Laboratory Tests\%' and lt.c_basecode like 'LOINC:%' ) select From 6d91bbb0ef5211330aeb211fece7457f04cd61ac Mon Sep 17 00:00:00 2001 From: Michael Prittie Date: Mon, 9 May 2016 13:38:35 -0500 Subject: [PATCH 11/15] Forgot to switch the column order in this statement as well. --- Oracle/pcornet_mapping.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Oracle/pcornet_mapping.sql b/Oracle/pcornet_mapping.sql index 986e9db..4227079 100644 --- a/Oracle/pcornet_mapping.sql +++ b/Oracle/pcornet_mapping.sql @@ -428,7 +428,7 @@ commit; /* Add relevent nodes from local i2b2 lab hierarchy to PCORNet Labs hierarchy. */ -insert into "&&i2b2_meta_schema".PCORNET_LAB +insert into PCORNET_LAB with lab_map as ( select distinct lab.c_hlevel, lab.c_path, lab.pcori_specimen_source, trim(CHR(13) from lab.pcori_basecode) as pcori_basecode from pcornet_lab lab @@ -468,8 +468,8 @@ select lt.M_EXCLUSION_CD, llt.C_PATH, lt.C_SYMBOL, - llt.PCORI_BASECODE, - llt.pcori_specimen_source + llt.pcori_specimen_source, + llt.PCORI_BASECODE from "&&i2b2_meta_schema"."&&terms_table" lt, local_loinc_terms llt where lt.c_fullname like llt.c_fullname||'%\' ; From 93b9272e493ca332de74d81726cce820da0e6612 Mon Sep 17 00:00:00 2001 From: Michael Prittie Date: Thu, 12 May 2016 09:01:18 -0500 Subject: [PATCH 12/15] Temp fix for errors generated by inserting non-standard values into RESULT_QUAL. --- Oracle/PCORNetLoader_ora.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Oracle/PCORNetLoader_ora.sql b/Oracle/PCORNetLoader_ora.sql index ac66ea8..e1db772 100644 --- a/Oracle/PCORNetLoader_ora.sql +++ b/Oracle/PCORNetLoader_ora.sql @@ -1275,7 +1275,8 @@ m.start_date SPECIMEN_DATE, to_char(m.start_date,'HH:MI') SPECIMEN_TIME, m.end_date RESULT_DATE, to_char(m.end_date,'HH:MI') RESULT_TIME, -CASE WHEN m.ValType_Cd='T' THEN NVL(nullif(m.TVal_Char,''),'NI') ELSE 'NI' END RESULT_QUAL, -- TODO: Should be a standardized value +--CASE WHEN m.ValType_Cd='T' THEN NVL(nullif(m.TVal_Char,''),'NI') ELSE 'NI' END RESULT_QUAL, -- TODO: Should be a standardized value +'NI' RESULT_QUAL, -- Temporary fix for KUMC CASE WHEN m.ValType_Cd='N' THEN m.NVAL_NUM ELSE null END RESULT_NUM, CASE WHEN m.ValType_Cd='N' THEN (CASE NVL(nullif(m.TVal_Char,''),'NI') WHEN 'E' THEN 'EQ' WHEN 'NE' THEN 'OT' WHEN 'L' THEN 'LT' WHEN 'LE' THEN 'LE' WHEN 'G' THEN 'GT' WHEN 'GE' THEN 'GE' ELSE 'NI' END) ELSE 'TX' END RESULT_MODIFIER, NVL(m.Units_CD,'NI') RESULT_UNIT, -- TODO: Should be standardized units From 129bf9bcefba354c1648ffae539eec623e14bd9a Mon Sep 17 00:00:00 2001 From: Michael Prittie Date: Thu, 12 May 2016 12:27:55 -0500 Subject: [PATCH 13/15] Removed duplicate reference to Creatinine lab. --- Oracle/pmn_labnormal.csv | 1 - 1 file changed, 1 deletion(-) diff --git a/Oracle/pmn_labnormal.csv b/Oracle/pmn_labnormal.csv index 6d6277a..fd92568 100644 --- a/Oracle/pmn_labnormal.csv +++ b/Oracle/pmn_labnormal.csv @@ -5,7 +5,6 @@ LAB_NAME:CK,50,GE,236,LE LAB_NAME:CK_MB,,NI,,NI LAB_NAME:CK_MBI,,NI,,NI LAB_NAME:CREATININE,0,GE,1.6,LE -LAB_NAME:CREATININE,0,GE,1.6,LE LAB_NAME:HGB,12,GE,17.5,LE LAB_NAME:INR,0.8,GE,1.3,LE LAB_NAME:TROP_I,0,GE,0.49,LE From 146792a4b8f97a6e578c54d0bc653e1d47344166 Mon Sep 17 00:00:00 2001 From: Michael Prittie Date: Thu, 12 May 2016 12:46:15 -0500 Subject: [PATCH 14/15] Added simple LAB_RESULT_CM SQL test. --- Oracle/cdm_transform_tests.sql | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Oracle/cdm_transform_tests.sql b/Oracle/cdm_transform_tests.sql index 9707fbe..ff8374f 100644 --- a/Oracle/cdm_transform_tests.sql +++ b/Oracle/cdm_transform_tests.sql @@ -528,6 +528,38 @@ order by 2 ; */ + +/* Verify that LAB_RESULT_CM contains data associated with a least half of the +labs defined in PMN_LABLOCAL. +*/ +insert into test_cases (query_name, description, obs, by_value1, by_value2, record_pct, pass) +with partial_lab_counts as ( + select lab_name, count(lab_name) lab_count + from lab_result_cm + group by lab_name +), complete_lab_counts as( + select replace(pmn.lab_name, 'LAB_NAME:', '') lab_name, + case when lc.lab_count is null then 0 else lc.lab_count end lab_count + from pmn_labnormal pmn + left outer join partial_lab_counts lc on concat('LAB_NAME:', lc.lab_name) = pmn.lab_name +), total_lab_types as ( + select count(*) num_labs from complete_lab_counts +), present_lab_types as ( + select count(*) num_labs from complete_lab_counts + where lab_count > 0 +) +select +'LAB_RESULT_CM Test' query_name, +'LAB_RESULT_CM contains data associated with at least half of the defined labs' description, +rownum obs, +plt.num_labs by_value1, +tlt.num_labs by_values2, +round(plt.num_labs/tlt.num_labs, 4) record_pct, +case when (plt.num_labs/tlt.num_labs) > 0.5 then 1 else 0 end pass +from present_lab_types plt +cross join total_lab_types tlt +; + select case when count(*) > 0 then 1/0 else 1 end all_test_cases_pass from ( select * from test_cases where pass = 0 ); From 0d00d3e100a1d1ea5fe4bf206b070875ec5f4589 Mon Sep 17 00:00:00 2001 From: Nathan Graham Date: Tue, 17 May 2016 11:55:39 -0500 Subject: [PATCH 15/15] The pcornet_lab synonym isn't created before pcornet_mapping.sql is run. --- Oracle/pcornet_mapping.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Oracle/pcornet_mapping.sql b/Oracle/pcornet_mapping.sql index 4227079..c54c635 100644 --- a/Oracle/pcornet_mapping.sql +++ b/Oracle/pcornet_mapping.sql @@ -428,11 +428,11 @@ commit; /* Add relevent nodes from local i2b2 lab hierarchy to PCORNet Labs hierarchy. */ -insert into PCORNET_LAB +insert into "&&i2b2_meta_schema".pcornet_lab with lab_map as ( select distinct lab.c_hlevel, lab.c_path, lab.pcori_specimen_source, trim(CHR(13) from lab.pcori_basecode) as pcori_basecode - from pcornet_lab lab - inner JOIN pcornet_lab ont_parent on lab.c_path=ont_parent.c_fullname + from "&&i2b2_meta_schema".pcornet_lab lab + inner JOIN "&&i2b2_meta_schema".pcornet_lab ont_parent on lab.c_path=ont_parent.c_fullname inner join pmn_labnormal norm on ont_parent.c_basecode=norm.LAB_NAME where lab.c_fullname like '\PCORI\LAB_RESULT_CM\%' ),