From d3665bc3f55017db2d8d354cc7383b9e4fa43483 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Thu, 12 Dec 2019 20:07:58 -0800 Subject: [PATCH 01/95] Remove owlexpression table with mysql syntax. --- src/main/resources/rf2/oracle_tables.sql | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/main/resources/rf2/oracle_tables.sql b/src/main/resources/rf2/oracle_tables.sql index c4c8394..2f3ad97 100644 --- a/src/main/resources/rf2/oracle_tables.sql +++ b/src/main/resources/rf2/oracle_tables.sql @@ -102,21 +102,6 @@ CREATE TABLE relationship ( ) PCTFREE 10 PCTUSED 80; -DROP TABLE IF EXISTS owlexpression; -CREATE TABLE owlexpression ( - id NUMERIC(18) UNSIGNED NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(18) UNSIGNED NOT NULL, - refsetId NUMERIC(18) UNSIGNED NOT NULL, - referencedComponentId NUMERIC(18) UNSIGNED NOT NULL, - owlExpression VARCHAR(10000) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (sourceId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (referencedComponentId) REFERENCES concept(id) -) CHARACTER SET utf8; - -- OWL Expression table. EXECUTE drop_table('owlexpression'); CREATE TABLE owlexpression ( From e41177b6b5488e17fc5781f10620df424d1ba41d Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Thu, 12 Dec 2019 20:09:58 -0800 Subject: [PATCH 02/95] Remove extra underscore in filename --- src/main/resources/rf2/owlexpression.ctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/rf2/owlexpression.ctl b/src/main/resources/rf2/owlexpression.ctl index ab3baa3..0ef9ae1 100644 --- a/src/main/resources/rf2/owlexpression.ctl +++ b/src/main/resources/rf2/owlexpression.ctl @@ -1,7 +1,7 @@ options (skip=1,direct=true) load data characterset UTF8 length semantics char -infile 'Snapshot/Terminology/sct2_sRefset_OWLExpression_Snapshot_${editionLabel}_${editionVersion}.txt' "str X'0d0a'" +infile 'Snapshot/Terminology/sct2_sRefset_OWLExpressionSnapshot_${editionLabel}_${editionVersion}.txt' "str X'0d0a'" badfile 'owlexpression.bad' discardfile 'owlexpression.dsc' insert From 73487d23959adea58a86b301a57d014676652903 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Thu, 12 Dec 2019 21:27:56 -0800 Subject: [PATCH 03/95] Fix SNOMED file name for import --- src/main/resources/rf2/mrcmattributedomain.ctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/rf2/mrcmattributedomain.ctl b/src/main/resources/rf2/mrcmattributedomain.ctl index b702dae..c05c577 100644 --- a/src/main/resources/rf2/mrcmattributedomain.ctl +++ b/src/main/resources/rf2/mrcmattributedomain.ctl @@ -1,7 +1,7 @@ options (skip=1,direct=true) load data characterset UTF8 length semantics char -infile 'Snapshot/Refset/Metadata/der2_ssRefset_MRCMAttributeDomainSnapshot_${editionLabel}_${editionVersion}.txt' "str X'0d0a'" +infile 'Snapshot/Refset/Metadata/der2_cissccRefset_MRCMAttributeDomainSnapshot_${editionLabel}_${editionVersion}.txt' "str X'0d0a'" badfile 'mrcmattributedomain.bad' discardfile 'mrcmattributedomain.dsc' insert From 70fadddaff1bc805c5d0cb79a4ae2a9b6517f5ab Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Thu, 12 Dec 2019 21:28:34 -0800 Subject: [PATCH 04/95] Fix SNOMED file name for import --- src/main/resources/rf2/mrcmattributerange.ctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/rf2/mrcmattributerange.ctl b/src/main/resources/rf2/mrcmattributerange.ctl index fd722b4..dee9cab 100644 --- a/src/main/resources/rf2/mrcmattributerange.ctl +++ b/src/main/resources/rf2/mrcmattributerange.ctl @@ -1,7 +1,7 @@ options (skip=1,direct=true) load data characterset UTF8 length semantics char -infile 'Snapshot/Refset/Metadata/der2_ssRefset_MRCMAttributeRangeSnapshot_${editionLabel}_${editionVersion}.txt' "str X'0d0a'" +infile 'Snapshot/Refset/Metadata/der2_ssccRefset_MRCMAttributeRangeSnapshot_${editionLabel}_${editionVersion}.txt' "str X'0d0a'" badfile 'mrcmattributerange.bad' discardfile 'mrcmattributerange.dsc' insert From 634f8e50eae5c44d035e416dd32668f20bd021c1 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Thu, 12 Dec 2019 21:29:49 -0800 Subject: [PATCH 05/95] Fix SNOMED file name and table columns to match MRCM Domain Snapshot --- src/main/resources/rf2/mrcmdomain.ctl | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/resources/rf2/mrcmdomain.ctl b/src/main/resources/rf2/mrcmdomain.ctl index 34fdf23..3da70a4 100644 --- a/src/main/resources/rf2/mrcmdomain.ctl +++ b/src/main/resources/rf2/mrcmdomain.ctl @@ -1,20 +1,26 @@ options (skip=1,direct=true) load data characterset UTF8 length semantics char -infile 'Snapshot/Refset/Metadata/der2_ssRefset_MRCMModuleScopeSnapshot_${editionLabel}_${editionVersion}.txt' "str X'0d0a'" -badfile 'mrcmmodulescope.bad' -discardfile 'mrcmmodulescope.dsc' +infile 'Snapshot/Refset/Metadata/der2_sssssssRefset_MRCMDomainSnapshot_${editionLabel}_${editionVersion}.txt' "str X'0d0a'" +badfile 'mrcmdomain.bad' +discardfile 'mrcmdomain.dsc' insert -into table mrcmmodulescope +into table mrcmdomain reenable disabled_constraints fields terminated by X'09' trailing nullcols ( - id CHAR(52), + id CHAR(52), effectiveTime DATE "YYYYMMDD", active INTEGER EXTERNAL, moduleId INTEGER EXTERNAL, refsetId INTEGER EXTERNAL, referencedComponentId INTEGER EXTERNAL, - mrcmRuleRefsetId INTEGER EXTERNAL + domainConstraint CHAR(4000), + parentDomain CHAR(4000), + proximalPrimitiveConstraint CHAR(4000), + proximalPrimitiveRefinement CHAR(4000), + domainTemplateForPrecoordination VARCHAR2(5000), + domainTemplateForPostcoordination CHAR(4000), + guideURL CHAR(4000) ) From 71ea8d0fdfc9362cc3fee0029c52d5b4826e2888 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Thu, 12 Dec 2019 21:30:53 -0800 Subject: [PATCH 06/95] Fix SNOMED file name and table columns to match MRCM Module Scope Snapshot --- src/main/resources/rf2/mrcmmodulescope.ctl | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/main/resources/rf2/mrcmmodulescope.ctl b/src/main/resources/rf2/mrcmmodulescope.ctl index cb3d1b3..353c9f6 100644 --- a/src/main/resources/rf2/mrcmmodulescope.ctl +++ b/src/main/resources/rf2/mrcmmodulescope.ctl @@ -1,11 +1,11 @@ options (skip=1,direct=true) load data characterset UTF8 length semantics char -infile 'Snapshot/Refset/Metadata/der2_ssRefset_MRCMDomainSnapshot_${editionLabel}_${editionVersion}.txt' "str X'0d0a'" -badfile 'mrcmdomain.bad' -discardfile 'mrcmdomain.dsc' +infile 'Snapshot/Refset/Metadata/der2_cRefset_MRCMModuleScopeSnapshot_${editionLabel}_${editionVersion}.txt' "str X'0d0a'" +badfile 'mrcmmodulescope.bad' +discardfile 'mrcmmodulescope.dsc' insert -into table mrcmdomain +into table mrcmmodulescope reenable disabled_constraints fields terminated by X'09' trailing nullcols @@ -16,11 +16,5 @@ trailing nullcols moduleId INTEGER EXTERNAL, refsetId INTEGER EXTERNAL, referencedComponentId INTEGER EXTERNAL, - domainConstraint CHAR(4000), - parentDomain CHAR(4000), - proximalPrimitiveConstraint CHAR(4000) - proximalPrimitiveRefinement CHAR(4000), - domainTemplateForPrecoordination CHAR(4000), - domainTemplateForPostcoordination CHAR(4000), - guideURL CHAR(4000) + mrcmRuleRefsetId INTEGER EXTERNAL ) From d2511abe65f6fdf21f0f2aa015c4eaae75cbbb83 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Mon, 17 Feb 2020 11:30:25 -0800 Subject: [PATCH 07/95] Update INT to 20200131 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d7e61aa..725d930 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ true - 20190731 + 20200131 Core INT From 4d65b7b8d32e171f684ad22eb78b37b1034170e5 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Tue, 3 Mar 2020 14:48:23 -0800 Subject: [PATCH 08/95] Update US to 20200301 and include instructions for postgres docker testing --- README.md | 4 +- pom.xml | 2 +- src/main/resources/rf2/populate_mysql_db.sh | 2 +- .../resources/rf2/populate_postgres_db.sh | 9 ++- src/test/resources/README-mysql-docker.txt | 19 +++++ src/test/resources/README-postgres-docker.txt | 77 +++++++++++++++++++ 6 files changed, 106 insertions(+), 7 deletions(-) create mode 100644 src/test/resources/README-postgres-docker.txt diff --git a/README.md b/README.md index 2d25ba0..fde5b38 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ http://www.westcoastinformatics.com/resources.html Minimum Specification --------------------- -- MYSQL v5.6.+ +- MYSQL v5.6.+, MySQL v8.+ - Oracle v11.+ -- Postgres 9.+ +- Postgres v9.+, v10.+, v11.+, v12.+ Installation ------------ diff --git a/pom.xml b/pom.xml index 725d930..babf555 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ US - 20190901 + 20200301 National US1000124 diff --git a/src/main/resources/rf2/populate_mysql_db.sh b/src/main/resources/rf2/populate_mysql_db.sh index 58617b0..ff22cd3 100644 --- a/src/main/resources/rf2/populate_mysql_db.sh +++ b/src/main/resources/rf2/populate_mysql_db.sh @@ -2,7 +2,7 @@ # # Database connection parameters # Please edit these variables to reflect your environment -# - Tested with docker mysql 5.6, 5.7 (using docker mysql server and client) +# - Tested with docker mysql 5.6, 5.7, 8.0 (using docker mysql server and client) # - host=host.docker.internal # host= diff --git a/src/main/resources/rf2/populate_postgres_db.sh b/src/main/resources/rf2/populate_postgres_db.sh index 5549270..292ea60 100644 --- a/src/main/resources/rf2/populate_postgres_db.sh +++ b/src/main/resources/rf2/populate_postgres_db.sh @@ -1,14 +1,17 @@ #!/bin/bash -f + # # Database connection parameters # Please edit these variables to reflect your environment +# - Tested with docker mysql 5.6, 5.7 (using docker mysql server and client) +# - host=host.docker.internal # - Tested on Windows with "Git Bash" as a shell -# - and psql in the path, use the alias if needed +# - and psql in the path # -#alias psql="C:/PostgreSQL/pg96/bin/psql.exe" +export PGHOST=localhost export PGUSER=postgres -export PGPASSWORD= +export PGPASSWORD=admin export PGDATABASE=snomed /bin/rm -f postgres.log diff --git a/src/test/resources/README-mysql-docker.txt b/src/test/resources/README-mysql-docker.txt index 2f8db98..682413d 100644 --- a/src/test/resources/README-mysql-docker.txt +++ b/src/test/resources/README-mysql-docker.txt @@ -15,6 +15,7 @@ docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQ # host = host.docker.internal (**make sure to edit this setting before proceeding) # dir=c:/data/SnomedCt_International +dir=c:/data/SnomedCt_US docker run -it -v $dir:/data mysql:5.6 /bin/bash root@842bfb3da1f1:/# cd /data root@842bfb3da1f1:/data# ./populate_mysql_db.sh & @@ -36,7 +37,25 @@ docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQ # host = host.docker.internal (**make sure to edit this setting before proceeding) # dir=c:/data/SnomedCt_International +dir=c:/data/SnomedCt_US docker run -it -v $dir:/data mysql:5.7 /bin/bash root@842bfb3da1f1:/# cd /data root@842bfb3da1f1:/data# ./populate_mysql_db.sh & +##### MySQL 8.0 + +# +# Launch the container +# +docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d mysql:8.0 + +# +# populate_mysql_db.sh +# host = host.docker.internal (**make sure to edit this setting before proceeding) +# +dir=c:/data/SnomedCt_International +dir=c:/data/SnomedCt_US +docker run -it -v $dir:/data mysql:8.0 /bin/bash +root@842bfb3da1f1:/# cd /data +root@842bfb3da1f1:/data# ./populate_mysql_db.sh & + diff --git a/src/test/resources/README-postgres-docker.txt b/src/test/resources/README-postgres-docker.txt new file mode 100644 index 0000000..f65c426 --- /dev/null +++ b/src/test/resources/README-postgres-docker.txt @@ -0,0 +1,77 @@ + +##### Postgres 9.6 + +# +# For testing postgres, run a docker postgres instance +# - https://hub.docker.com/_/postgres + +# +# Launch the container +# +docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d postgres:9.6 + +# +# populate_postgres_db.sh +# host = host.docker.internal (**make sure to edit this setting before proceeding) +# +dir=c:/data/SnomedCt_International +dir=c:/data/SnomedCt_US +docker run -it -v $dir:/data postgres:9.6 /bin/bash +root@842bfb3da1f1:/# cd /data +root@842bfb3da1f1:/data# ./populate_postgres_db.sh & + + +##### Postgres 10.12 + +# +# For testing postgres, run a docker postgres instance +# - https://hub.docker.com/_/postgres + +# +# Launch the container +# +docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d postgres:10.12 + +# +# populate_postgres_db.sh +# host = host.docker.internal (**make sure to edit this setting before proceeding) +# +dir=c:/data/SnomedCt_International +dir=c:/data/SnomedCt_US +docker run -it -v $dir:/data postgres:10.12 /bin/bash +root@842bfb3da1f1:/# cd /data +root@842bfb3da1f1:/data# ./populate_postgres_db.sh & + +##### Postgres 11.7 + +# +# Launch the container +# +docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d postgres:11.2 + +# +# populate_postgres_db.sh +# host = host.docker.internal (**make sure to edit this setting before proceeding) +# +dir=c:/data/SnomedCt_International +dir=c:/data/SnomedCt_US +docker run -it -v $dir:/data postgres:11.2 /bin/bash +root@842bfb3da1f1:/# cd /data +root@842bfb3da1f1:/data# ./populate_postgres_db.sh & + +##### Postgres 12.2 + +# +# Launch the container +# +docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d postgres:12.2 + +# +# populate_postgres_db.sh +# host = host.docker.internal (**make sure to edit this setting before proceeding) +# +dir=c:/data/SnomedCt_International +dir=c:/data/SnomedCt_US +docker run -it -v $dir:/data postgres:12.2 /bin/bash +root@842bfb3da1f1:/# cd /data +root@842bfb3da1f1:/data# ./populate_postgres_db.sh & From d6a64fe28443786e2bea0d8ae0e852798284cb80 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Tue, 3 Mar 2020 17:29:03 -0800 Subject: [PATCH 09/95] Minor changes to make it work with MySQL 8 --- README.md | 1 + src/main/resources/rf2/mysql_tables.sql | 6 +++--- src/test/resources/README-mysql-docker.txt | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fde5b38..1e50afe 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ http://www.westcoastinformatics.com/resources.html Minimum Specification --------------------- - MYSQL v5.6.+, MySQL v8.+ + - MySQL v8 requires the server to run with "--local_infile=ON" - Oracle v11.+ - Postgres v9.+, v10.+, v11.+, v12.+ diff --git a/src/main/resources/rf2/mysql_tables.sql b/src/main/resources/rf2/mysql_tables.sql index 52cc990..7e8e1fd 100644 --- a/src/main/resources/rf2/mysql_tables.sql +++ b/src/main/resources/rf2/mysql_tables.sql @@ -122,7 +122,7 @@ CREATE TABLE owlexpression ( moduleId NUMERIC(18) UNSIGNED NOT NULL, refsetId NUMERIC(18) UNSIGNED NOT NULL, referencedComponentId NUMERIC(18) UNSIGNED NOT NULL, - owlExpression VARCHAR(10000) NOT NULL, + owlExpression TEXT NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (referencedComponentId) REFERENCES concept(id) @@ -572,8 +572,8 @@ CREATE TABLE mrcmdomain ( parentDomain VARCHAR(4000), proximalPrimitiveConstraint VARCHAR(4000) NOT NULL, proximalPrimitiveRefinement VARCHAR(4000), - domainTemplateForPrecoordination VARCHAR(40000) NOT NULL, - domainTemplateForPostcoordination VARCHAR(40000) NOT NULL, + domainTemplateForPrecoordination TEXT NOT NULL, + domainTemplateForPostcoordination TEXT NOT NULL, guideURL VARCHAR(4000) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id) diff --git a/src/test/resources/README-mysql-docker.txt b/src/test/resources/README-mysql-docker.txt index 682413d..f38c4fe 100644 --- a/src/test/resources/README-mysql-docker.txt +++ b/src/test/resources/README-mysql-docker.txt @@ -47,7 +47,7 @@ root@842bfb3da1f1:/data# ./populate_mysql_db.sh & # # Launch the container # -docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d mysql:8.0 +docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d mysql:8.0 --local_infile=ON # # populate_mysql_db.sh From 2eec07907a03b7fecf17ef2635e6c6947c66d94f Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Wed, 4 Mar 2020 10:55:05 -0800 Subject: [PATCH 10/95] Add testing for MariaDB and add a file to make it easier to make announcements --- README.md | 4 +- src/test/resources/README-announcements.txt | 45 +++++++++++++++++++++ src/test/resources/README-mysql-docker.txt | 23 +++++------ 3 files changed, 56 insertions(+), 16 deletions(-) create mode 100644 src/test/resources/README-announcements.txt diff --git a/README.md b/README.md index 1e50afe..7fe3621 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ http://www.westcoastinformatics.com/resources.html Minimum Specification --------------------- -- MYSQL v5.6.+, MySQL v8.+ - - MySQL v8 requires the server to run with "--local_infile=ON" +- MYSQL v5.6.+, MySQL v8.+, MariaDB 10.+ + - MySQL v8 requires the server to run with "--local_infile=ON" - Oracle v11.+ - Postgres v9.+, v10.+, v11.+, v12.+ diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt new file mode 100644 index 0000000..5cb0105 --- /dev/null +++ b/src/test/resources/README-announcements.txt @@ -0,0 +1,45 @@ +## Sample texts for announcing new releases + +### Twitter, LinkedIn, Facebook + +Announcing #SNOMEDCT DB load and transitive closure scripts for +the 03/01/2020 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +See http://westcoastinformatics.com/resources.html #MakingTerminologyEasy #snomed + +This freely available solution enables one to load their #SQL database with the latest US Editions of SNOMED. + +---- + +Announcing #SNOMEDCT DB load and transitive closure scripts for +the 01/31/2020 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +See http://westcoastinformatics.com/resources.html #MakingTerminologyEasy #MakingSnomedEasy #snomed + +This freely available solution enables one to load their #SQL database with the latest US Editions of SNOMED. + +### UMLS Users Mailing List + +Hi all, + +NLM recently posted the March 1, 2020 update of the SNOMEDCT US Edition. + +For those interested in interacting with SNOMEDCT data through a relational database, +we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. +It works for both International Edition and the US Edition. + +This utility is freely available through our website: + +* Information and download: http://westcoastinformatics.com/resources.html + - See the "DB Load Scripts" section + - See the "Transitive Closure Scripts" section + +* Github projects: + - https://github.com/WestCoastInformatics/SNOMED-DB-Load-Scripts + - https://github.com/WestCoastInformatics/SNOMED-CT-Transitive-Closure + +* Training video: + - https://www.youtube.com/watch?v=th36V4B1O8E + + +Feel free to share this announcement with others or retweet the announcement - +https://twitter.com/wcinformatics/status/ ! + diff --git a/src/test/resources/README-mysql-docker.txt b/src/test/resources/README-mysql-docker.txt index f38c4fe..6c0edeb 100644 --- a/src/test/resources/README-mysql-docker.txt +++ b/src/test/resources/README-mysql-docker.txt @@ -1,5 +1,5 @@ -##### MySQL 5.6 +##### MySQL 5.7 # # For testing mysql, run a docker mysql instance @@ -8,7 +8,7 @@ # # Launch the container # -docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d mysql:5.6 +docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d mysql:5.7 # # populate_mysql_db.sh @@ -16,21 +16,16 @@ docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQ # dir=c:/data/SnomedCt_International dir=c:/data/SnomedCt_US -docker run -it -v $dir:/data mysql:5.6 /bin/bash +docker run -it -v $dir:/data mysql:5.7 /bin/bash root@842bfb3da1f1:/# cd /data root@842bfb3da1f1:/data# ./populate_mysql_db.sh & - -##### MySQL 5.7 - -# -# For testing mysql, run a docker mysql instance -# - https://hub.docker.com/_/mysql +##### MySQL 8.0 # # Launch the container # -docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d mysql:5.7 +docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d mysql:8.0 --local_infile=ON # # populate_mysql_db.sh @@ -38,16 +33,16 @@ docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQ # dir=c:/data/SnomedCt_International dir=c:/data/SnomedCt_US -docker run -it -v $dir:/data mysql:5.7 /bin/bash +docker run -it -v $dir:/data mysql:8.0 /bin/bash root@842bfb3da1f1:/# cd /data root@842bfb3da1f1:/data# ./populate_mysql_db.sh & -##### MySQL 8.0 +##### MariaDB - 10.4 # # Launch the container # -docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d mysql:8.0 --local_infile=ON +docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d mariadb:10.4 # # populate_mysql_db.sh @@ -55,7 +50,7 @@ docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQ # dir=c:/data/SnomedCt_International dir=c:/data/SnomedCt_US -docker run -it -v $dir:/data mysql:8.0 /bin/bash +docker run -it -v $dir:/data mariadb:10.4 /bin/bash root@842bfb3da1f1:/# cd /data root@842bfb3da1f1:/data# ./populate_mysql_db.sh & From 18ae50870123b2017fcd55f557034d0cf5a920f1 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Wed, 4 Mar 2020 11:04:07 -0800 Subject: [PATCH 11/95] Update documentation --- src/main/resources/HOWTO.txt | 15 ++++----------- src/main/resources/LICENSE.txt | 2 +- src/main/resources/README.txt | 2 +- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/main/resources/HOWTO.txt b/src/main/resources/HOWTO.txt index ca9a9ba..cdcd226 100644 --- a/src/main/resources/HOWTO.txt +++ b/src/main/resources/HOWTO.txt @@ -3,13 +3,6 @@ This HOWTO describes how to use the installer scripts to load SNOMED into a data Installation ------------ 1. Download the database loader zip file from the http://www.westcoastinformatics.com/resources.html website. Select the appropriate database-version pair (i.e. oracle-US Edition). Depending on your database and edition, identify the appropriate target's zip file. - For example: - * For MySQL SNOMED-CORE, use the "snomed-db-scripts-mysql.20190731.zip" file - * For MySQL US-Edition, use the "snomed-db-scripts-mysql.20190901.zip" file - * For Postgres SNOMED-CORE, use the "snomed-db-scripts-postgres.20190731.zip" file - * For Postgres US-Edition, use the "snomed-db-scripts-postgres.20190901.zip" file - * For Oracle SNOMED-CORE, use the "snomed-db-scripts-oracle.20190731.zip" file - * For Oracle US-Edition, use the "snomed-db-scripts-oracle.20190901.zip" file 2. Unzip the contents of the zip file into a 'data' folder @@ -32,18 +25,18 @@ Installation 5. In a text editor, open the temp-folder's appropriate "populate" script in a text editor as defined by your platform and database. * For example: - - For MySQL on Windows, use the "populate_mysql_db.bat" script + - For MySQL (or MariadB) on Windows, use the "populate_mysql_db.bat" script - For Postgres on Windows, use the "populate_postgres_db.bat" script - For Oracle on Windows, use the "populate_oracle_db.bat" script - - For MySQL on Linux/Unix/MacOS, use the "populate_mysql_db.sh" script + - For MySQL (or MariaDB) on Linux/Unix/MacOS, use the "populate_mysql_db.sh" script - For Postgres on Linux/Unix/MacOS, use the "populate_postgres_db.sh" script - For Oracle on Linux/Unix/MacOS, use the "populate_oracle_db.sh" script * Configure settings at the top of the "populate" script for your environment - - user is your database's username + - user is your database's username - password is your database's password - tns_name or db_name is the database's schema which is to be populated -6. Create the database schema as defined in step #5.b.iii +6. Create the database schema as defined in step #5 * NOTE: postgres supports only db-level character encoding, so make sure to create your database using: WITH ENCODING 'UTF-8' diff --git a/src/main/resources/LICENSE.txt b/src/main/resources/LICENSE.txt index 61a2fa8..2828032 100644 --- a/src/main/resources/LICENSE.txt +++ b/src/main/resources/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright 2019 West Coast Informatics, LLC +Copyright 2020 West Coast Informatics, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/main/resources/README.txt b/src/main/resources/README.txt index 2883fbd..f2ce773 100644 --- a/src/main/resources/README.txt +++ b/src/main/resources/README.txt @@ -11,7 +11,7 @@ Important Notes Key Features ------------ -* Support for Oracle, Postgres, and MySQL +* Support for Oracle, Postgres, and MySQL (and MariaDB) * Support for RF2 data format * Denormalization of concept/description ids for contextualized lookup From 2c9cbce3679c9d139f45ea822d01a347750c686c Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Mon, 10 Aug 2020 09:30:16 -0700 Subject: [PATCH 12/95] Upgrade for 20200731 --- pom.xml | 2 +- src/main/resources/rf2/populate_mysql_db.sh | 2 +- .../resources/rf2/populate_postgres_db.bat | 3 +- .../resources/rf2/populate_postgres_db.sh | 8 ++--- src/test/resources/README-mysql-docker.txt | 33 ++++++++++++------- src/test/resources/README-postgres-docker.txt | 32 +++++++++--------- 6 files changed, 43 insertions(+), 37 deletions(-) diff --git a/pom.xml b/pom.xml index babf555..befbccb 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ true - 20200131 + 20200731 Core INT diff --git a/src/main/resources/rf2/populate_mysql_db.sh b/src/main/resources/rf2/populate_mysql_db.sh index ff22cd3..9003ba9 100644 --- a/src/main/resources/rf2/populate_mysql_db.sh +++ b/src/main/resources/rf2/populate_mysql_db.sh @@ -1,10 +1,10 @@ #!/bin/bash -f # # Database connection parameters +# NOTE: or MySQL 8.0, you'll need to run the server with local_infile=ON # Please edit these variables to reflect your environment # - Tested with docker mysql 5.6, 5.7, 8.0 (using docker mysql server and client) # - host=host.docker.internal -# host= user=root password=admin diff --git a/src/main/resources/rf2/populate_postgres_db.bat b/src/main/resources/rf2/populate_postgres_db.bat index ee52500..06225b6 100644 --- a/src/main/resources/rf2/populate_postgres_db.bat +++ b/src/main/resources/rf2/populate_postgres_db.bat @@ -3,8 +3,9 @@ :: Please edit these variables to reflect your environment :: set psql=C:/PostgreSQL/pg96/bin/psql.exe +set PGHOST=localhost set PGUSER=postgres -set PGPASSWORD= +set PGPASSWORD=admin set PGDATABASE=snomed del postgres.log diff --git a/src/main/resources/rf2/populate_postgres_db.sh b/src/main/resources/rf2/populate_postgres_db.sh index 292ea60..3c4879f 100644 --- a/src/main/resources/rf2/populate_postgres_db.sh +++ b/src/main/resources/rf2/populate_postgres_db.sh @@ -4,8 +4,8 @@ # # Database connection parameters # Please edit these variables to reflect your environment -# - Tested with docker mysql 5.6, 5.7 (using docker mysql server and client) -# - host=host.docker.internal +# - Tested with docker postgres 9, 10, 11, 12 (using docker postgres server and client) +# - PGHOST=host.docker.internal # - Tested on Windows with "Git Bash" as a shell # - and psql in the path # @@ -26,10 +26,6 @@ echo "----------------------------------------" >> postgres.log 2>&1 echo "user = $PGUSER" >> postgres.log 2>&1 echo "db_name = $PGDATABASE" >> postgres.log 2>&1 -if [ "${password}" != "" ]; then - password="-p${password}" -fi - echo " Create and load tables ... `/bin/date`" >> postgres.log 2>&1 psql < psql_tables.sql >> postgres.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi diff --git a/src/test/resources/README-mysql-docker.txt b/src/test/resources/README-mysql-docker.txt index 6c0edeb..2d9d954 100644 --- a/src/test/resources/README-mysql-docker.txt +++ b/src/test/resources/README-mysql-docker.txt @@ -8,49 +8,58 @@ # # Launch the container # -docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d mysql:5.7 +docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mysql:5.7 # -# populate_mysql_db.sh +# populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_International dir=c:/data/SnomedCt_US +dir=c:/data/SnomedCt_International +cd $dir +./transitive_closure.sh docker run -it -v $dir:/data mysql:5.7 /bin/bash root@842bfb3da1f1:/# cd /data -root@842bfb3da1f1:/data# ./populate_mysql_db.sh & +root@842bfb3da1f1:/data# ./populate_mysql_db.sh +root@842bfb3da1f1:/data# ./populate_mysql_db_tc.sh ##### MySQL 8.0 # # Launch the container # -docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d mysql:8.0 --local_infile=ON +docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mysql:8.0 --local_infile=ON # -# populate_mysql_db.sh +# populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_International dir=c:/data/SnomedCt_US +dir=c:/data/SnomedCt_International +cd $dir +./transitive_closure.sh docker run -it -v $dir:/data mysql:8.0 /bin/bash root@842bfb3da1f1:/# cd /data -root@842bfb3da1f1:/data# ./populate_mysql_db.sh & +root@842bfb3da1f1:/data# ./populate_mysql_db.sh +root@842bfb3da1f1:/data# ./populate_mysql_db_tc.sh ##### MariaDB - 10.4 # # Launch the container # -docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d mariadb:10.4 +docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mariadb:10.4 # -# populate_mysql_db.sh +# populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_International dir=c:/data/SnomedCt_US +dir=c:/data/SnomedCt_International +cd $dir +./transitive_closure.sh docker run -it -v $dir:/data mariadb:10.4 /bin/bash root@842bfb3da1f1:/# cd /data -root@842bfb3da1f1:/data# ./populate_mysql_db.sh & +root@842bfb3da1f1:/data# ./populate_mysql_db.sh +root@842bfb3da1f1:/data# ./populate_mysql_db_tc.sh diff --git a/src/test/resources/README-postgres-docker.txt b/src/test/resources/README-postgres-docker.txt index f65c426..9e9772c 100644 --- a/src/test/resources/README-postgres-docker.txt +++ b/src/test/resources/README-postgres-docker.txt @@ -1,24 +1,21 @@ ##### Postgres 9.6 -# -# For testing postgres, run a docker postgres instance -# - https://hub.docker.com/_/postgres - # # Launch the container # -docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d postgres:9.6 +docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:9.6 # -# populate_postgres_db.sh +# populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # dir=c:/data/SnomedCt_International dir=c:/data/SnomedCt_US docker run -it -v $dir:/data postgres:9.6 /bin/bash root@842bfb3da1f1:/# cd /data -root@842bfb3da1f1:/data# ./populate_postgres_db.sh & +root@842bfb3da1f1:/data# ./populate_postgres_db.sh +root@842bfb3da1f1:/data# ./populate_postgres_db_tc.sh ##### Postgres 10.12 @@ -30,48 +27,51 @@ root@842bfb3da1f1:/data# ./populate_postgres_db.sh & # # Launch the container # -docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d postgres:10.12 +docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:10.12 # -# populate_postgres_db.sh +# populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # dir=c:/data/SnomedCt_International dir=c:/data/SnomedCt_US docker run -it -v $dir:/data postgres:10.12 /bin/bash root@842bfb3da1f1:/# cd /data -root@842bfb3da1f1:/data# ./populate_postgres_db.sh & +root@842bfb3da1f1:/data# ./populate_postgres_db.sh +root@842bfb3da1f1:/data# ./populate_postgres_db_tc.sh ##### Postgres 11.7 # # Launch the container # -docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d postgres:11.2 +docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:11.2 # -# populate_postgres_db.sh +# populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # dir=c:/data/SnomedCt_International dir=c:/data/SnomedCt_US docker run -it -v $dir:/data postgres:11.2 /bin/bash root@842bfb3da1f1:/# cd /data -root@842bfb3da1f1:/data# ./populate_postgres_db.sh & +root@842bfb3da1f1:/data# ./populate_postgres_db.sh +root@842bfb3da1f1:/data# ./populate_postgres_db_tc.sh ##### Postgres 12.2 # # Launch the container # -docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d postgres:12.2 +docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:12.2 # -# populate_postgres_db.sh +# populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # dir=c:/data/SnomedCt_International dir=c:/data/SnomedCt_US docker run -it -v $dir:/data postgres:12.2 /bin/bash root@842bfb3da1f1:/# cd /data -root@842bfb3da1f1:/data# ./populate_postgres_db.sh & +root@842bfb3da1f1:/data# ./populate_postgres_db.sh +root@842bfb3da1f1:/data# ./populate_postgres_db_tc.sh From 5666bc9cad0d6cf3c96833809dcf78f6a29ceefe Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Mon, 10 Aug 2020 10:02:53 -0700 Subject: [PATCH 13/95] Some cleanup of postgres scripts --- src/main/resources/rf2/populate_oracle_db.sh | 6 ++---- src/main/resources/rf2/populate_postgres_db.sh | 1 - src/test/resources/README-postgres-docker.txt | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/resources/rf2/populate_oracle_db.sh b/src/main/resources/rf2/populate_oracle_db.sh index bc5080f..e14a292 100644 --- a/src/main/resources/rf2/populate_oracle_db.sh +++ b/src/main/resources/rf2/populate_oracle_db.sh @@ -5,13 +5,11 @@ # Please edit these variables to reflect your environment # - Tested on Windows with "Git Bash" as a shell # -ORACLE_HOME=/app/oracle/product/12.1.0/dbhome_1 -export ORACLE_HOME +export ORACLE_HOME=/app/oracle/product/12.1.0/dbhome_1 user=snomed password=snomed tns_name=global -NLS_LANG=AMERICAN_AMERICA.UTF8 -export NLS_LANG +export NLS_LANG=AMERICAN_AMERICA.UTF8 /bin/rm -f oracle.log touch oracle.log diff --git a/src/main/resources/rf2/populate_postgres_db.sh b/src/main/resources/rf2/populate_postgres_db.sh index 3c4879f..e7534eb 100644 --- a/src/main/resources/rf2/populate_postgres_db.sh +++ b/src/main/resources/rf2/populate_postgres_db.sh @@ -1,6 +1,5 @@ #!/bin/bash -f - # # Database connection parameters # Please edit these variables to reflect your environment diff --git a/src/test/resources/README-postgres-docker.txt b/src/test/resources/README-postgres-docker.txt index 9e9772c..a869021 100644 --- a/src/test/resources/README-postgres-docker.txt +++ b/src/test/resources/README-postgres-docker.txt @@ -10,8 +10,10 @@ docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snom # populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_International dir=c:/data/SnomedCt_US +dir=c:/data/SnomedCt_International +cd $dir +./transitive_closure.sh docker run -it -v $dir:/data postgres:9.6 /bin/bash root@842bfb3da1f1:/# cd /data root@842bfb3da1f1:/data# ./populate_postgres_db.sh @@ -33,8 +35,10 @@ docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snom # populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_International dir=c:/data/SnomedCt_US +dir=c:/data/SnomedCt_International +cd $dir +./transitive_closure.sh docker run -it -v $dir:/data postgres:10.12 /bin/bash root@842bfb3da1f1:/# cd /data root@842bfb3da1f1:/data# ./populate_postgres_db.sh @@ -51,8 +55,10 @@ docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snom # populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_International dir=c:/data/SnomedCt_US +dir=c:/data/SnomedCt_International +cd $dir +./transitive_closure.sh docker run -it -v $dir:/data postgres:11.2 /bin/bash root@842bfb3da1f1:/# cd /data root@842bfb3da1f1:/data# ./populate_postgres_db.sh @@ -69,8 +75,10 @@ docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snom # populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_International dir=c:/data/SnomedCt_US +dir=c:/data/SnomedCt_International +cd $dir +./transitive_closure.sh docker run -it -v $dir:/data postgres:12.2 /bin/bash root@842bfb3da1f1:/# cd /data root@842bfb3da1f1:/data# ./populate_postgres_db.sh From e8cb9e0933b6c55088d6a576976220e7e795b493 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Mon, 10 Aug 2020 17:01:47 -0700 Subject: [PATCH 14/95] Support for docker testing of Oracle --- src/main/resources/rf2/populate_oracle_db.sh | 8 +++-- src/test/resources/README-oracle-docker.txt | 35 ++++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 src/test/resources/README-oracle-docker.txt diff --git a/src/main/resources/rf2/populate_oracle_db.sh b/src/main/resources/rf2/populate_oracle_db.sh index e14a292..a6c6274 100644 --- a/src/main/resources/rf2/populate_oracle_db.sh +++ b/src/main/resources/rf2/populate_oracle_db.sh @@ -5,10 +5,12 @@ # Please edit these variables to reflect your environment # - Tested on Windows with "Git Bash" as a shell # -export ORACLE_HOME=/app/oracle/product/12.1.0/dbhome_1 + +# Set if necessary +#export ORACLE_HOME=/app/oracle/product/12.1.0/dbhome_1 user=snomed password=snomed -tns_name=global +tns_name=ORCLCDB export NLS_LANG=AMERICAN_AMERICA.UTF8 /bin/rm -f oracle.log @@ -24,7 +26,7 @@ echo "user = $user" >> oracle.log 2>&1 echo "tns_name = $tns_name" >> oracle.log 2>&1 echo " Create tables ... `/bin/date`" >> oracle.log 2>&1 -echo "@oracle_tables.sql"|$ORACLE_HOME/bin/sqlplus $user/$password@$tns_name >> oracle.log 2>&1 +echo "@oracle_tables.sql" | $ORACLE_HOME/bin/sqlplus $user/$password@$tns_name >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi if [ $ef -ne 1 ]; then diff --git a/src/test/resources/README-oracle-docker.txt b/src/test/resources/README-oracle-docker.txt new file mode 100644 index 0000000..5c5b996 --- /dev/null +++ b/src/test/resources/README-oracle-docker.txt @@ -0,0 +1,35 @@ + +##### Oracle 12c + +# Prerequisites +# - https://hub.docker.com/_/oracle-database-enterprise-edition?tab=description (Click "Proceed to checkout") + +# +# For testing oracle, run a docker mysql instance +# - https://dzone.com/articles/oracle-12c-image-installation-in-docker + +# +# Launch the container +# +dir=c:/data/SnomedCt_US +dir=c:/data/SnomedCt_International +cd $dir +./transitive_closure.sh +docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 store/oracle/database-enterprise:12.2.0.1-slim + +# +# populate_oracle_db.sh, populate_oracle_db_tc.sh +# host = host.docker.internal (**make sure to edit this setting before proceeding) +# +docker exec -it snomed-oracle /bin/bash +root@842bfb3da1f1:/# cd /data +root@842bfb3da1f1:/# source /home/oracle/.bashrc +root@842bfb3da1f1:/# sqlplus /nolog +connect sys as sysdba; +-- Here enter the password as 'Oradoc_db1' +alter session set "_ORACLE_SCRIPT"=true; +create user snomed identified by snomed; +GRANT CONNECT, RESOURCE, DBA TO snomed; +exit +root@842bfb3da1f1:/data# ./populate_oracle_db.sh +root@842bfb3da1f1:/data# ./populate_oracle_db_tc.sh From c04cc82851f5e8f46aede8a44b60060590a87928 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Mon, 10 Aug 2020 17:06:53 -0700 Subject: [PATCH 15/95] Final changes for 20200731 --- src/main/resources/rf2/populate_oracle_db.bat | 2 +- src/main/resources/rf2/populate_postgres_db.bat | 2 +- src/main/resources/rf2/populate_postgres_db.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/rf2/populate_oracle_db.bat b/src/main/resources/rf2/populate_oracle_db.bat index b999065..bbaa6d6 100644 --- a/src/main/resources/rf2/populate_oracle_db.bat +++ b/src/main/resources/rf2/populate_oracle_db.bat @@ -5,7 +5,7 @@ set ORACLE_HOME=C:\app\oracle\product\12.1.0\dbhome_1 set user=snomed set password=snomed -set tns_name=global +set tns_name=ORCLCDB set NLS_LANG=AMERICAN_AMERICA.UTF8 del oracle.log diff --git a/src/main/resources/rf2/populate_postgres_db.bat b/src/main/resources/rf2/populate_postgres_db.bat index 06225b6..23a1811 100644 --- a/src/main/resources/rf2/populate_postgres_db.bat +++ b/src/main/resources/rf2/populate_postgres_db.bat @@ -5,7 +5,7 @@ set psql=C:/PostgreSQL/pg96/bin/psql.exe set PGHOST=localhost set PGUSER=postgres -set PGPASSWORD=admin +set PGPASSWORD= set PGDATABASE=snomed del postgres.log diff --git a/src/main/resources/rf2/populate_postgres_db.sh b/src/main/resources/rf2/populate_postgres_db.sh index e7534eb..1f798dc 100644 --- a/src/main/resources/rf2/populate_postgres_db.sh +++ b/src/main/resources/rf2/populate_postgres_db.sh @@ -10,7 +10,7 @@ # export PGHOST=localhost export PGUSER=postgres -export PGPASSWORD=admin +export PGPASSWORD= export PGDATABASE=snomed /bin/rm -f postgres.log From fc992566e7112b9b6113a7f8c2eed0d85050d25c Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Mon, 10 Aug 2020 17:39:21 -0700 Subject: [PATCH 16/95] Announcements update --- src/test/resources/README-announcements.txt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 5cb0105..2d06b3a 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -2,25 +2,26 @@ ### Twitter, LinkedIn, Facebook -Announcing #SNOMEDCT DB load and transitive closure scripts for -the 03/01/2020 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. -See http://westcoastinformatics.com/resources.html #MakingTerminologyEasy #snomed +It's that time again! Announcing #SNOMEDCT DB load and transitive closure scripts for +the 07/31/2020 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +See https://westcoastinformatics.com/resources.html #MakingTerminologyEasy #snomed -This freely available solution enables one to load their #SQL database with the latest US Editions of SNOMED. +This freely available solution enables loading of #SQL database with the latest editions of SNOMED. ---- Announcing #SNOMEDCT DB load and transitive closure scripts for the 01/31/2020 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. -See http://westcoastinformatics.com/resources.html #MakingTerminologyEasy #MakingSnomedEasy #snomed +See https://westcoastinformatics.com/resources.html #MakingTerminologyEasy #MakingSnomedEasy #snomed This freely available solution enables one to load their #SQL database with the latest US Editions of SNOMED. ### UMLS Users Mailing List +Subject: SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the March 1, 2020 update of the SNOMEDCT US Edition. +NLM recently posted the July 31, 2020 update of the SNOMEDCT International Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. @@ -28,7 +29,7 @@ It works for both International Edition and the US Edition. This utility is freely available through our website: -* Information and download: http://westcoastinformatics.com/resources.html +* Information and download: https://westcoastinformatics.com/resources.html - See the "DB Load Scripts" section - See the "Transitive Closure Scripts" section From 4825833bcd8bd65a8bc9fc4849595a47e0d0f359 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Tue, 1 Sep 2020 12:05:14 -0700 Subject: [PATCH 17/95] Update US to 20200901 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index befbccb..84ae8eb 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ US - 20200301 + 20200901 National US1000124 From 83d0c9802ead8c47053010d300bbcae4e2809bbb Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Wed, 2 Sep 2020 09:47:50 -0700 Subject: [PATCH 18/95] Extend numerics to 20 digits to avoid UNSIGNED issues --- src/main/resources/rf2/mysql_tables.sql | 184 ++++++++--------- src/main/resources/rf2/oracle_tables.sql | 184 ++++++++--------- src/main/resources/rf2/psql_tables.sql | 185 +++++++++--------- src/test/resources/README-mysql-docker.txt | 6 +- src/test/resources/README-postgres-docker.txt | 18 +- 5 files changed, 288 insertions(+), 289 deletions(-) diff --git a/src/main/resources/rf2/mysql_tables.sql b/src/main/resources/rf2/mysql_tables.sql index 7e8e1fd..616cfba 100644 --- a/src/main/resources/rf2/mysql_tables.sql +++ b/src/main/resources/rf2/mysql_tables.sql @@ -8,11 +8,11 @@ SET FOREIGN_KEY_CHECKS = 0; -- Concept file. DROP TABLE IF EXISTS concept; CREATE TABLE concept ( - id NUMERIC(18) UNSIGNED NOT NULL PRIMARY KEY, + id NUMERIC(20) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) UNSIGNED NOT NULL, - definitionStatusId NUMERIC(18) UNSIGNED NOT NULL, + moduleId NUMERIC(20) NOT NULL, + definitionStatusId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (definitionStatusId) REFERENCES concept(id) ) CHARACTER SET utf8; @@ -29,15 +29,15 @@ definitionStatusId = @definitionStatusId; -- Description file. DROP TABLE IF EXISTS description; CREATE TABLE description ( - id NUMERIC(18) UNSIGNED NOT NULL PRIMARY KEY, + id NUMERIC(20) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) UNSIGNED NOT NULL, - conceptId NUMERIC(18) UNSIGNED NOT NULL, + moduleId NUMERIC(20) NOT NULL, + conceptId NUMERIC(20) NOT NULL, languageCode CHAR(2) NOT NULL, - typeId NUMERIC(18) UNSIGNED NOT NULL, + typeId NUMERIC(20) NOT NULL, term VARCHAR(255) NOT NULL, - caseSignificanceId NUMERIC(18) UNSIGNED NOT NULL, + caseSignificanceId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (conceptId) REFERENCES concept(id), FOREIGN KEY (typeId) REFERENCES concept(id), @@ -60,12 +60,12 @@ caseSignificanceId=@caseSignificanceId; -- Identifier file. DROP TABLE IF EXISTS identifier; CREATE TABLE identifier ( - identifierSchemeId NUMERIC(18) UNSIGNED NOT NULL, + identifierSchemeId NUMERIC(20) NOT NULL, alternateIdentifier VARCHAR(255) NOT NULL, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) UNSIGNED NOT NULL, - referencedComponentId NUMERIC(18) UNSIGNED NOT NULL, + moduleId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id) ) CHARACTER SET utf8; @@ -82,16 +82,16 @@ referencedComponentId = @referencedComponentId; -- Relationship file. DROP TABLE IF EXISTS relationship; CREATE TABLE relationship ( - id NUMERIC(18) UNSIGNED NOT NULL PRIMARY KEY, + id NUMERIC(20) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) UNSIGNED NOT NULL, - sourceId NUMERIC(18) UNSIGNED NOT NULL, - destinationId NUMERIC(18) UNSIGNED NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + destinationId NUMERIC(20) NOT NULL, relationshipGroup INT UNSIGNED NOT NULL, - typeId NUMERIC(18) UNSIGNED NOT NULL, - characteristicTypeId NUMERIC(18) UNSIGNED NOT NULL, - modifierId NUMERIC(18) UNSIGNED NOT NULL, + typeId NUMERIC(20) NOT NULL, + characteristicTypeId NUMERIC(20) NOT NULL, + modifierId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (sourceId) REFERENCES concept(id), FOREIGN KEY (destinationId) REFERENCES concept(id), @@ -119,9 +119,9 @@ CREATE TABLE owlexpression ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) UNSIGNED NOT NULL, - refsetId NUMERIC(18) UNSIGNED NOT NULL, - referencedComponentId NUMERIC(18) UNSIGNED NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, owlExpression TEXT NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), @@ -142,16 +142,16 @@ owlExpression = @owlExpression; -- Stated Relationship file. DROP TABLE IF EXISTS statedrelationship; CREATE TABLE statedrelationship ( - id NUMERIC(18) UNSIGNED NOT NULL PRIMARY KEY, + id NUMERIC(20) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) UNSIGNED NOT NULL, - sourceId NUMERIC(18) UNSIGNED NOT NULL, - destinationId NUMERIC(18) UNSIGNED NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + destinationId NUMERIC(20) NOT NULL, relationshipGroup INT UNSIGNED NOT NULL, - typeId NUMERIC(18) UNSIGNED NOT NULL, - characteristicTypeId NUMERIC(18) UNSIGNED NOT NULL, - modifierId NUMERIC(18) UNSIGNED NOT NULL, + typeId NUMERIC(20) NOT NULL, + characteristicTypeId NUMERIC(20) NOT NULL, + modifierId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (sourceId) REFERENCES concept(id), FOREIGN KEY (destinationId) REFERENCES concept(id), @@ -176,15 +176,15 @@ modifierId = @modifierId; -- Text Definition file. DROP TABLE IF EXISTS textdefinition; CREATE TABLE textdefinition ( - id NUMERIC(18) UNSIGNED NOT NULL PRIMARY KEY, + id NUMERIC(20) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) UNSIGNED NOT NULL, - conceptId NUMERIC(18) UNSIGNED NOT NULL, + moduleId NUMERIC(20) NOT NULL, + conceptId NUMERIC(20) NOT NULL, languageCode CHAR(2) NOT NULL, - typeId NUMERIC(18) UNSIGNED NOT NULL, + typeId NUMERIC(20) NOT NULL, term VARCHAR(2048) NOT NULL, - caseSignificanceId NUMERIC(18) UNSIGNED NOT NULL, + caseSignificanceId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (conceptId) REFERENCES concept(id), FOREIGN KEY (typeId) REFERENCES concept(id), @@ -210,10 +210,10 @@ CREATE TABLE association ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) UNSIGNED NOT NULL, - refsetId NUMERIC(18) UNSIGNED NOT NULL, - referencedComponentId NUMERIC(18) UNSIGNED NOT NULL, - targetComponent NUMERIC(18) UNSIGNED NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + targetComponent NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (targetComponent) REFERENCES concept(id) @@ -236,10 +236,10 @@ CREATE TABLE attributevalue ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) UNSIGNED NOT NULL, - refsetId NUMERIC(18) UNSIGNED NOT NULL, - referencedComponentId NUMERIC(18) UNSIGNED NOT NULL, - valueId NUMERIC(18) UNSIGNED NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + valueId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (valueId) REFERENCES concept(id) @@ -262,9 +262,9 @@ CREATE TABLE simple ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) UNSIGNED NOT NULL, - refsetId NUMERIC(18) UNSIGNED NOT NULL, - referencedComponentId NUMERIC(18) UNSIGNED NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id) ) CHARACTER SET utf8; @@ -286,15 +286,15 @@ referencedComponentId = @referencedComponentId; -- id CHAR(52) NOT NULL PRIMARY KEY, -- effectiveTime DATE NOT NULL, -- active BOOLEAN NOT NULL, --- moduleId NUMERIC(18) UNSIGNED NOT NULL, --- refsetId NUMERIC(18) UNSIGNED NOT NULL, --- referencedComponentId NUMERIC(18) UNSIGNED NOT NULL, +-- moduleId NUMERIC(20) NOT NULL, +-- refsetId NUMERIC(20) NOT NULL, +-- referencedComponentId NUMERIC(20) NOT NULL, -- mapGroup INT UNSIGNED NOT NULL, -- mapPriority INT UNSIGNED NOT NULL, -- mapRule VARCHAR(4000) NOT NULL, -- mapAdvice VARCHAR(4000) NOT NULL, -- mapTarget VARCHAR(100) NOT NULL, --- correlationId NUMERIC(18) UNSIGNED NOT NULL, +-- correlationId NUMERIC(20) NOT NULL, -- FOREIGN KEY (moduleId) REFERENCES concept(id), -- FOREIGN KEY (refsetId) REFERENCES concept(id), -- FOREIGN KEY (correlationId) REFERENCES concept(id) @@ -322,16 +322,16 @@ CREATE TABLE extendedmap ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) UNSIGNED NOT NULL, - refsetId NUMERIC(18) UNSIGNED NOT NULL, - referencedComponentId NUMERIC(18) UNSIGNED NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, mapGroup INT UNSIGNED NOT NULL, mapPriority INT UNSIGNED NOT NULL, mapRule VARCHAR(4000) NOT NULL, mapAdvice VARCHAR(4000) NOT NULL, mapTarget VARCHAR(100) NOT NULL, - correlationId NUMERIC(18) UNSIGNED NOT NULL, - mapCategoryId NUMERIC(18) UNSIGNED NOT NULL, + correlationId NUMERIC(20) NOT NULL, + mapCategoryId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (correlationId) REFERENCES concept(id), @@ -361,9 +361,9 @@ CREATE TABLE simplemap ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) UNSIGNED NOT NULL, - refsetId NUMERIC(18) UNSIGNED NOT NULL, - referencedComponentId NUMERIC(18) UNSIGNED NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, mapTarget VARCHAR(100) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id) @@ -386,10 +386,10 @@ CREATE TABLE language ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) UNSIGNED NOT NULL, - refsetId NUMERIC(18) UNSIGNED NOT NULL, - referencedComponentId NUMERIC(18) UNSIGNED NOT NULL, - acceptabilityId NUMERIC(18) UNSIGNED NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + acceptabilityId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (acceptabilityId) REFERENCES concept(id) @@ -412,12 +412,12 @@ CREATE TABLE refsetdescriptor ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) UNSIGNED NOT NULL, - refsetId NUMERIC(18) UNSIGNED NOT NULL, - referencedComponentId NUMERIC(18) UNSIGNED NOT NULL, - attributeDescription NUMERIC(18) UNSIGNED NOT NULL, - attributeType NUMERIC(18) UNSIGNED NOT NULL, - attributeOrder NUMERIC(18) UNSIGNED NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + attributeDescription NUMERIC(20) NOT NULL, + attributeType NUMERIC(20) NOT NULL, + attributeOrder NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id) ) CHARACTER SET utf8; @@ -441,10 +441,10 @@ CREATE TABLE descriptiontype ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) UNSIGNED NOT NULL, - refsetId NUMERIC(18) UNSIGNED NOT NULL, - referencedComponentId NUMERIC(18) UNSIGNED NOT NULL, - descriptionFormat NUMERIC(18) UNSIGNED NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + descriptionFormat NUMERIC(20) NOT NULL, descriptionLength INT UNSIGNED NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id) @@ -468,15 +468,15 @@ CREATE TABLE mrcmattributedomain ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, - domainId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + domainId NUMERIC(20) NOT NULL, grouped INT NOT NULL, attributeCardinality VARCHAR(20) NOT NULL, attributeInGroupCardinality VARCHAR(20) NOT NULL, - ruleStrengthId NUMERIC(18) NOT NULL, - contentTypeId NUMERIC(18) NOT NULL, + ruleStrengthId NUMERIC(20) NOT NULL, + contentTypeId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (domainId) REFERENCES concept(id), @@ -506,10 +506,10 @@ CREATE TABLE mrcmmodulescope ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, - mrcmRuleRefsetId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + mrcmRuleRefsetId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (mrcmRuleRefsetId) REFERENCES concept(id) @@ -532,13 +532,13 @@ CREATE TABLE mrcmattributerange ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, rangeConstraint VARCHAR(4000) NOT NULL, attributeRule VARCHAR(4000) NOT NULL, - ruleStrengthId NUMERIC(18) NOT NULL, - contentTypeId NUMERIC(18) NOT NULL, + ruleStrengthId NUMERIC(20) NOT NULL, + contentTypeId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (ruleStrengthId) REFERENCES concept(id), @@ -565,16 +565,16 @@ CREATE TABLE mrcmdomain ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, domainConstraint VARCHAR(4000) NOT NULL, parentDomain VARCHAR(4000), proximalPrimitiveConstraint VARCHAR(4000) NOT NULL, proximalPrimitiveRefinement VARCHAR(4000), domainTemplateForPrecoordination TEXT NOT NULL, domainTemplateForPostcoordination TEXT NOT NULL, - guideURL VARCHAR(4000) NOT NULL, + guideURL VARCHAR(4000), FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id) ) CHARACTER SET utf8; @@ -601,9 +601,9 @@ CREATE TABLE moduledependency ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) UNSIGNED NOT NULL, - refsetId NUMERIC(18) UNSIGNED NOT NULL, - referencedComponentId NUMERIC(18) UNSIGNED NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, sourceEffectiveTime DATE NOT NULL, targetEffectiveTime DATE NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), diff --git a/src/main/resources/rf2/oracle_tables.sql b/src/main/resources/rf2/oracle_tables.sql index 2f3ad97..8ec061b 100644 --- a/src/main/resources/rf2/oracle_tables.sql +++ b/src/main/resources/rf2/oracle_tables.sql @@ -35,11 +35,11 @@ END; -- Concept table. EXECUTE drop_table('concept'); CREATE TABLE concept ( - id NUMERIC(18) NOT NULL PRIMARY KEY, + id NUMERIC(20) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - definitionStatusId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + definitionStatusId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (definitionStatusId) REFERENCES concept(id) ) @@ -49,15 +49,15 @@ PCTFREE 10 PCTUSED 80; -- Description table. EXECUTE drop_table('description'); CREATE TABLE description ( - id NUMERIC(18) NOT NULL PRIMARY KEY, + id NUMERIC(20) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - conceptId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + conceptId NUMERIC(20) NOT NULL, languageCode CHAR(2) NOT NULL, - typeId NUMERIC(18) NOT NULL, + typeId NUMERIC(20) NOT NULL, term VARCHAR2(255) NOT NULL, - caseSignificanceId NUMERIC(18) NOT NULL, + caseSignificanceId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (conceptId) REFERENCES concept(id), FOREIGN KEY (typeId) REFERENCES concept(id), @@ -69,12 +69,12 @@ PCTFREE 10 PCTUSED 80; -- Identifier table. EXECUTE drop_table('identifier'); CREATE TABLE identifier ( - identifierSchemeId NUMERIC(18) NOT NULL, + identifierSchemeId NUMERIC(20) NOT NULL, alternateIdentifier VARCHAR2(255) NOT NULL, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id) ) PCTFREE 10 PCTUSED 80; @@ -83,16 +83,16 @@ PCTFREE 10 PCTUSED 80; -- Relationship table. EXECUTE drop_table('relationship'); CREATE TABLE relationship ( - id NUMERIC(18) NOT NULL PRIMARY KEY, + id NUMERIC(20) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - sourceId NUMERIC(18) NOT NULL, - destinationId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + destinationId NUMERIC(20) NOT NULL, relationshipGroup INT NOT NULL, - typeId NUMERIC(18) NOT NULL, - characteristicTypeId NUMERIC(18) NOT NULL, - modifierId NUMERIC(18) NOT NULL, + typeId NUMERIC(20) NOT NULL, + characteristicTypeId NUMERIC(20) NOT NULL, + modifierId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (sourceId) REFERENCES concept(id), FOREIGN KEY (destinationId) REFERENCES concept(id), @@ -108,9 +108,9 @@ CREATE TABLE owlexpression ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, owlExpression VARCHAR2(4000) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), @@ -121,16 +121,16 @@ PCTFREE 10 PCTUSED 80; -- Stated Relationship table. EXECUTE drop_table('statedrelationship'); CREATE TABLE statedrelationship ( - id NUMERIC(18) NOT NULL PRIMARY KEY, + id NUMERIC(20) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - sourceId NUMERIC(18) NOT NULL, - destinationId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + destinationId NUMERIC(20) NOT NULL, relationshipGroup INT NOT NULL, - typeId NUMERIC(18) NOT NULL, - characteristicTypeId NUMERIC(18) NOT NULL, - modifierId NUMERIC(18) NOT NULL, + typeId NUMERIC(20) NOT NULL, + characteristicTypeId NUMERIC(20) NOT NULL, + modifierId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (sourceId) REFERENCES concept(id), FOREIGN KEY (destinationId) REFERENCES concept(id), @@ -144,15 +144,15 @@ PCTFREE 10 PCTUSED 80; -- Text Definition table. EXECUTE drop_table('textdefinition'); CREATE TABLE textdefinition ( - id NUMERIC(18) NOT NULL PRIMARY KEY, + id NUMERIC(20) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - conceptId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + conceptId NUMERIC(20) NOT NULL, languageCode CHAR(2) NOT NULL, - typeId NUMERIC(18) NOT NULL, + typeId NUMERIC(20) NOT NULL, term VARCHAR2(2048) NOT NULL, - caseSignificanceId NUMERIC(18) NOT NULL, + caseSignificanceId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (conceptId) REFERENCES concept(id), FOREIGN KEY (typeId) REFERENCES concept(id), @@ -167,10 +167,10 @@ CREATE TABLE association ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, - targetComponent NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + targetComponent NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id) -- TODO: FOREIGN KEY targetComponent? @@ -184,10 +184,10 @@ CREATE TABLE attributevalue ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, - valueId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + valueId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (valueId) REFERENCES concept(id) @@ -201,9 +201,9 @@ CREATE TABLE simple ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id) ) @@ -216,15 +216,15 @@ PCTFREE 10 PCTUSED 80; -- id CHAR(52) NOT NULL PRIMARY KEY, -- effectiveTime DATE NOT NULL, -- active NUMERIC(1) NOT NULL, --- moduleId NUMERIC(18) NOT NULL, --- refsetId NUMERIC(18) NOT NULL, --- referencedComponentId NUMERIC(18) NOT NULL, +-- moduleId NUMERIC(20) NOT NULL, +-- refsetId NUMERIC(20) NOT NULL, +-- referencedComponentId NUMERIC(20) NOT NULL, -- mapGroup INT NOT NULL, -- mapPriority INT NOT NULL, -- mapRule VARCHAR2(4000), -- mapAdvice VARCHAR2(4000), -- mapTarget VARCHAR2(100), --- correlationId NUMERIC(18) NOT NULL, +-- correlationId NUMERIC(20) NOT NULL, -- FOREIGN KEY (moduleId) REFERENCES concept(id), -- FOREIGN KEY (refsetId) REFERENCES concept(id), -- FOREIGN KEY (correlationId) REFERENCES concept(id) @@ -238,16 +238,16 @@ CREATE TABLE extendedmap ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, mapGroup INT NOT NULL, mapPriority INT NOT NULL, mapRule VARCHAR2(4000), mapAdvice VARCHAR2(4000), mapTarget VARCHAR2(100), - correlationId NUMERIC(18) NOT NULL, - mapCategoryId NUMERIC(18) NOT NULL, + correlationId NUMERIC(20) NOT NULL, + mapCategoryId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (correlationId) REFERENCES concept(id), @@ -262,9 +262,9 @@ CREATE TABLE simplemap ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, mapTarget VARCHAR2(100) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id) @@ -278,10 +278,10 @@ CREATE TABLE language ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, - acceptabilityId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + acceptabilityId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (acceptabilityId) REFERENCES concept(id) @@ -295,12 +295,12 @@ CREATE TABLE refsetdescriptor ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, - attributeDescription NUMERIC(18) NOT NULL, - attributeType NUMERIC(18) NOT NULL, - attributeOrder NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + attributeDescription NUMERIC(20) NOT NULL, + attributeType NUMERIC(20) NOT NULL, + attributeOrder NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id) ) @@ -313,10 +313,10 @@ CREATE TABLE descriptiontype ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, - descriptionFormat NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + descriptionFormat NUMERIC(20) NOT NULL, descriptionLength INT NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id) @@ -330,15 +330,15 @@ CREATE TABLE mrcmattributedomain ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, - domainId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + domainId NUMERIC(20) NOT NULL, grouped INT NOT NULL, attributeCardinality VARCHAR2(20) NOT NULL, attributeInGroupCardinality VARCHAR2(20) NOT NULL, - ruleStrengthId NUMERIC(18) NOT NULL, - contentTypeId NUMERIC(18) NOT NULL, + ruleStrengthId NUMERIC(20) NOT NULL, + contentTypeId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (domainId) REFERENCES concept(id), @@ -354,10 +354,10 @@ CREATE TABLE mrcmmodulescope ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, - mrcmRuleRefsetId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + mrcmRuleRefsetId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (mrcmRuleRefsetId) REFERENCES concept(id) @@ -371,13 +371,13 @@ CREATE TABLE mrcmattributerange ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, rangeConstraint VARCHAR2(4000) NOT NULL, attributeRule VARCHAR2(4000) NOT NULL, - ruleStrengthId NUMERIC(18) NOT NULL, - contentTypeId NUMERIC(18) NOT NULL, + ruleStrengthId NUMERIC(20) NOT NULL, + contentTypeId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (ruleStrengthId) REFERENCES concept(id), @@ -392,16 +392,16 @@ CREATE TABLE mrcmdomain ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, domainConstraint VARCHAR2(4000) NOT NULL, parentDomain VARCHAR2(4000), proximalPrimitiveConstraint VARCHAR2(4000) NOT NULL, proximalPrimitiveRefinement VARCHAR2(4000), domainTemplateForPrecoordination VARCHAR2(4000) NOT NULL, domainTemplateForPostcoordination VARCHAR2(4000) NOT NULL, - guideURL VARCHAR2(4000) NOT NULL, + guideURL VARCHAR2(4000), FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id) ) @@ -414,9 +414,9 @@ CREATE TABLE moduledependency ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, sourceEffectiveTime DATE NOT NULL, targetEffectiveTime DATE NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), diff --git a/src/main/resources/rf2/psql_tables.sql b/src/main/resources/rf2/psql_tables.sql index d4eff6f..7713882 100644 --- a/src/main/resources/rf2/psql_tables.sql +++ b/src/main/resources/rf2/psql_tables.sql @@ -1,13 +1,12 @@ -\ -- Concept file. DROP TABLE IF EXISTS concept CASCADE; CREATE TABLE concept ( - id NUMERIC(18) NOT NULL PRIMARY KEY, + id NUMERIC(20) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - definitionStatusId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + definitionStatusId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (definitionStatusId) REFERENCES concept(id) ); @@ -17,15 +16,15 @@ CREATE TABLE concept ( -- Description file. DROP TABLE IF EXISTS description CASCADE; CREATE TABLE description ( - id NUMERIC(18) NOT NULL PRIMARY KEY, + id NUMERIC(20) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - conceptId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + conceptId NUMERIC(20) NOT NULL, languageCode CHAR(2) NOT NULL, - typeId NUMERIC(18) NOT NULL, + typeId NUMERIC(20) NOT NULL, term VARCHAR(255) NOT NULL, - caseSignificanceId NUMERIC(18) NOT NULL, + caseSignificanceId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (conceptId) REFERENCES concept(id), FOREIGN KEY (typeId) REFERENCES concept(id), @@ -37,12 +36,12 @@ CREATE TABLE description ( -- Identifier file. DROP TABLE IF EXISTS identifier CASCADE; CREATE TABLE identifier ( - identifierSchemeId NUMERIC(18) NOT NULL, + identifierSchemeId NUMERIC(20) NOT NULL, alternateIdentifier VARCHAR(255) NOT NULL, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id) ); @@ -52,16 +51,16 @@ CREATE TABLE identifier ( -- Relationship file. DROP TABLE IF EXISTS relationship CASCADE; CREATE TABLE relationship ( - id NUMERIC(18) NOT NULL PRIMARY KEY, + id NUMERIC(20) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - sourceId NUMERIC(18) NOT NULL, - destinationId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + destinationId NUMERIC(20) NOT NULL, relationshipGroup INT NOT NULL, - typeId NUMERIC(18) NOT NULL, - characteristicTypeId NUMERIC(18) NOT NULL, - modifierId NUMERIC(18) NOT NULL, + typeId NUMERIC(20) NOT NULL, + characteristicTypeId NUMERIC(20) NOT NULL, + modifierId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (sourceId) REFERENCES concept(id), FOREIGN KEY (destinationId) REFERENCES concept(id), @@ -79,9 +78,9 @@ CREATE TABLE owlexpression ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, owlExpression VARCHAR(10000) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), @@ -94,16 +93,16 @@ CREATE TABLE owlexpression ( -- Stated Relationship file. DROP TABLE IF EXISTS statedrelationship CASCADE; CREATE TABLE statedrelationship ( - id NUMERIC(18) NOT NULL PRIMARY KEY, + id NUMERIC(20) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - sourceId NUMERIC(18) NOT NULL, - destinationId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + destinationId NUMERIC(20) NOT NULL, relationshipGroup INT NOT NULL, - typeId NUMERIC(18) NOT NULL, - characteristicTypeId NUMERIC(18) NOT NULL, - modifierId NUMERIC(18) NOT NULL, + typeId NUMERIC(20) NOT NULL, + characteristicTypeId NUMERIC(20) NOT NULL, + modifierId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (sourceId) REFERENCES concept(id), FOREIGN KEY (destinationId) REFERENCES concept(id), @@ -118,15 +117,15 @@ CREATE TABLE statedrelationship ( -- Text Definition file. DROP TABLE IF EXISTS textdefinition CASCADE; CREATE TABLE textdefinition ( - id NUMERIC(18) NOT NULL PRIMARY KEY, + id NUMERIC(20) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - conceptId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + conceptId NUMERIC(20) NOT NULL, languageCode CHAR(2) NOT NULL, - typeId NUMERIC(18) NOT NULL, + typeId NUMERIC(20) NOT NULL, term VARCHAR(2048) NOT NULL, - caseSignificanceId NUMERIC(18) NOT NULL, + caseSignificanceId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (conceptId) REFERENCES concept(id), FOREIGN KEY (typeId) REFERENCES concept(id), @@ -142,10 +141,10 @@ CREATE TABLE association ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, - targetComponent NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + targetComponent NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (targetComponent) REFERENCES concept(id) @@ -160,10 +159,10 @@ CREATE TABLE attributevalue ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, - valueId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + valueId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (valueId) REFERENCES concept(id) @@ -178,9 +177,9 @@ CREATE TABLE simple ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id) ); @@ -195,15 +194,15 @@ CREATE TABLE simple ( -- id CHAR(52) NOT NULL PRIMARY KEY, -- effectiveTime DATE NOT NULL, -- active BOOLEAN NOT NULL, --- moduleId NUMERIC(18) NOT NULL, --- refsetId NUMERIC(18) NOT NULL, --- referencedComponentId NUMERIC(18) NOT NULL, +-- moduleId NUMERIC(20) NOT NULL, +-- refsetId NUMERIC(20) NOT NULL, +-- referencedComponentId NUMERIC(20) NOT NULL, -- mapGroup INT NOT NULL, -- mapPriority INT NOT NULL, -- mapRule VARCHAR(4000) NOT NULL, -- mapAdvice VARCHAR(4000) NOT NULL, -- mapTarget VARCHAR(100) NOT NULL, --- correlationId NUMERIC(18) NOT NULL, +-- correlationId NUMERIC(20) NOT NULL, -- FOREIGN KEY (moduleId) REFERENCES concept(id), -- FOREIGN KEY (refsetId) REFERENCES concept(id), -- FOREIGN KEY (correlationId) REFERENCES concept(id) @@ -231,16 +230,16 @@ CREATE TABLE extendedmap ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, mapGroup INT NOT NULL, mapPriority INT NOT NULL, mapRule VARCHAR(4000) NOT NULL, mapAdvice VARCHAR(4000) NOT NULL, mapTarget VARCHAR(100), - correlationId NUMERIC(18) NOT NULL, - mapCategoryId NUMERIC(18) NOT NULL, + correlationId NUMERIC(20) NOT NULL, + mapCategoryId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (correlationId) REFERENCES concept(id), @@ -256,9 +255,9 @@ CREATE TABLE simplemap ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, mapTarget VARCHAR(100) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id) @@ -273,10 +272,10 @@ CREATE TABLE language ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, - acceptabilityId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + acceptabilityId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (acceptabilityId) REFERENCES concept(id) @@ -291,12 +290,12 @@ CREATE TABLE refsetdescriptor ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, - attributeDescription NUMERIC(18) NOT NULL, - attributeType NUMERIC(18) NOT NULL, - attributeOrder NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + attributeDescription NUMERIC(20) NOT NULL, + attributeType NUMERIC(20) NOT NULL, + attributeOrder NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id) ); @@ -310,10 +309,10 @@ CREATE TABLE descriptiontype ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, - descriptionFormat NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + descriptionFormat NUMERIC(20) NOT NULL, descriptionLength INT NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id) @@ -328,15 +327,15 @@ CREATE TABLE mrcmattributedomain ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, - domainId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + domainId NUMERIC(20) NOT NULL, grouped INT NOT NULL, attributeCardinality VARCHAR(20) NOT NULL, attributeInGroupCardinality VARCHAR(20) NOT NULL, - ruleStrengthId NUMERIC(18) NOT NULL, - contentTypeId NUMERIC(18) NOT NULL, + ruleStrengthId NUMERIC(20) NOT NULL, + contentTypeId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (domainId) REFERENCES concept(id), @@ -353,10 +352,10 @@ CREATE TABLE mrcmmodulescope ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, - mrcmRuleRefsetId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + mrcmRuleRefsetId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (mrcmRuleRefsetId) REFERENCES concept(id) @@ -371,13 +370,13 @@ CREATE TABLE mrcmattributerange ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, rangeConstraint VARCHAR(4000) NOT NULL, attributeRule VARCHAR(4000) NOT NULL, - ruleStrengthId NUMERIC(18) NOT NULL, - contentTypeId NUMERIC(18) NOT NULL, + ruleStrengthId NUMERIC(20) NOT NULL, + contentTypeId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id), FOREIGN KEY (ruleStrengthId) REFERENCES concept(id), @@ -393,16 +392,16 @@ CREATE TABLE mrcmdomain ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, domainConstraint VARCHAR(4000) NOT NULL, parentDomain VARCHAR(4000), proximalPrimitiveConstraint VARCHAR(4000) NOT NULL, proximalPrimitiveRefinement VARCHAR(4000), domainTemplateForPrecoordination VARCHAR(40000) NOT NULL, domainTemplateForPostcoordination VARCHAR(40000) NOT NULL, - guideURL VARCHAR(4000) NOT NULL, + guideURL VARCHAR(4000), FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (refsetId) REFERENCES concept(id) ); @@ -416,9 +415,9 @@ CREATE TABLE moduledependency ( id CHAR(52) NOT NULL PRIMARY KEY, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, - moduleId NUMERIC(18) NOT NULL, - refsetId NUMERIC(18) NOT NULL, - referencedComponentId NUMERIC(18) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, sourceEffectiveTime DATE NOT NULL, targetEffectiveTime DATE NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), diff --git a/src/test/resources/README-mysql-docker.txt b/src/test/resources/README-mysql-docker.txt index 2d9d954..088b7c9 100644 --- a/src/test/resources/README-mysql-docker.txt +++ b/src/test/resources/README-mysql-docker.txt @@ -14,8 +14,8 @@ docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQ # populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_US dir=c:/data/SnomedCt_International +dir=c:/data/SnomedCt_US cd $dir ./transitive_closure.sh docker run -it -v $dir:/data mysql:5.7 /bin/bash @@ -34,8 +34,8 @@ docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQ # populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_US dir=c:/data/SnomedCt_International +dir=c:/data/SnomedCt_US cd $dir ./transitive_closure.sh docker run -it -v $dir:/data mysql:8.0 /bin/bash @@ -54,8 +54,8 @@ docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQ # populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_US dir=c:/data/SnomedCt_International +dir=c:/data/SnomedCt_US cd $dir ./transitive_closure.sh docker run -it -v $dir:/data mariadb:10.4 /bin/bash diff --git a/src/test/resources/README-postgres-docker.txt b/src/test/resources/README-postgres-docker.txt index a869021..59bdde6 100644 --- a/src/test/resources/README-postgres-docker.txt +++ b/src/test/resources/README-postgres-docker.txt @@ -10,8 +10,8 @@ docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snom # populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_US dir=c:/data/SnomedCt_International +dir=c:/data/SnomedCt_US cd $dir ./transitive_closure.sh docker run -it -v $dir:/data postgres:9.6 /bin/bash @@ -29,17 +29,17 @@ root@842bfb3da1f1:/data# ./populate_postgres_db_tc.sh # # Launch the container # -docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:10.12 +docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:10.14 # # populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_US dir=c:/data/SnomedCt_International +dir=c:/data/SnomedCt_US cd $dir ./transitive_closure.sh -docker run -it -v $dir:/data postgres:10.12 /bin/bash +docker run -it -v $dir:/data postgres:10.14 /bin/bash root@842bfb3da1f1:/# cd /data root@842bfb3da1f1:/data# ./populate_postgres_db.sh root@842bfb3da1f1:/data# ./populate_postgres_db_tc.sh @@ -49,17 +49,17 @@ root@842bfb3da1f1:/data# ./populate_postgres_db_tc.sh # # Launch the container # -docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:11.2 +docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:11.9 # # populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_US dir=c:/data/SnomedCt_International +dir=c:/data/SnomedCt_US cd $dir ./transitive_closure.sh -docker run -it -v $dir:/data postgres:11.2 /bin/bash +docker run -it -v $dir:/data postgres:11.9 /bin/bash root@842bfb3da1f1:/# cd /data root@842bfb3da1f1:/data# ./populate_postgres_db.sh root@842bfb3da1f1:/data# ./populate_postgres_db_tc.sh @@ -69,7 +69,7 @@ root@842bfb3da1f1:/data# ./populate_postgres_db_tc.sh # # Launch the container # -docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:12.2 +docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:12.4 # # populate_mysql_db.sh, populate_mysql_db_tc.sh @@ -79,7 +79,7 @@ dir=c:/data/SnomedCt_US dir=c:/data/SnomedCt_International cd $dir ./transitive_closure.sh -docker run -it -v $dir:/data postgres:12.2 /bin/bash +docker run -it -v $dir:/data postgres:12.4 /bin/bash root@842bfb3da1f1:/# cd /data root@842bfb3da1f1:/data# ./populate_postgres_db.sh root@842bfb3da1f1:/data# ./populate_postgres_db_tc.sh From fb1a1f4a18cc697b33109784122c81d6025d558e Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Wed, 2 Sep 2020 10:57:41 -0700 Subject: [PATCH 19/95] Small fixes to oracle docker testin g --- src/test/resources/README-oracle-docker.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/test/resources/README-oracle-docker.txt b/src/test/resources/README-oracle-docker.txt index 5c5b996..657620f 100644 --- a/src/test/resources/README-oracle-docker.txt +++ b/src/test/resources/README-oracle-docker.txt @@ -11,8 +11,8 @@ # # Launch the container # -dir=c:/data/SnomedCt_US dir=c:/data/SnomedCt_International +dir=c:/data/SnomedCt_US cd $dir ./transitive_closure.sh docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 store/oracle/database-enterprise:12.2.0.1-slim @@ -23,10 +23,8 @@ docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 # docker exec -it snomed-oracle /bin/bash root@842bfb3da1f1:/# cd /data -root@842bfb3da1f1:/# source /home/oracle/.bashrc -root@842bfb3da1f1:/# sqlplus /nolog -connect sys as sysdba; --- Here enter the password as 'Oradoc_db1' +root@842bfb3da1f1:/# . /home/oracle/.bashrc +root@842bfb3da1f1:/# sqlplus sys/Oradoc_db1 as sysdba alter session set "_ORACLE_SCRIPT"=true; create user snomed identified by snomed; GRANT CONNECT, RESOURCE, DBA TO snomed; From e81619fa7acc7deb274f96dc7beca7b2676c5c55 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Wed, 10 Feb 2021 13:01:45 -0800 Subject: [PATCH 20/95] Update to file paths to use the same structure as in HOWTO.txt. Add port for postgres db. --- src/test/resources/README-mysql-docker.txt | 30 +++++-------- src/test/resources/README-oracle-docker.txt | 10 ++--- src/test/resources/README-postgres-docker.txt | 44 ++++++++----------- 3 files changed, 34 insertions(+), 50 deletions(-) diff --git a/src/test/resources/README-mysql-docker.txt b/src/test/resources/README-mysql-docker.txt index 088b7c9..49f4273 100644 --- a/src/test/resources/README-mysql-docker.txt +++ b/src/test/resources/README-mysql-docker.txt @@ -14,14 +14,12 @@ docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQ # populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_International -dir=c:/data/SnomedCt_US +dir=c:/data/ cd $dir -./transitive_closure.sh docker run -it -v $dir:/data mysql:5.7 /bin/bash -root@842bfb3da1f1:/# cd /data -root@842bfb3da1f1:/data# ./populate_mysql_db.sh -root@842bfb3da1f1:/data# ./populate_mysql_db_tc.sh +root@842bfb3da1f1:/# cd /data/rf2 +root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh +root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh ##### MySQL 8.0 @@ -34,14 +32,12 @@ docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQ # populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_International -dir=c:/data/SnomedCt_US +dir=c:/data/ cd $dir -./transitive_closure.sh docker run -it -v $dir:/data mysql:8.0 /bin/bash -root@842bfb3da1f1:/# cd /data -root@842bfb3da1f1:/data# ./populate_mysql_db.sh -root@842bfb3da1f1:/data# ./populate_mysql_db_tc.sh +root@842bfb3da1f1:/# cd /data/rf2 +root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh +root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh ##### MariaDB - 10.4 @@ -54,12 +50,10 @@ docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQ # populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_International -dir=c:/data/SnomedCt_US +dir=c:/data cd $dir -./transitive_closure.sh docker run -it -v $dir:/data mariadb:10.4 /bin/bash -root@842bfb3da1f1:/# cd /data -root@842bfb3da1f1:/data# ./populate_mysql_db.sh -root@842bfb3da1f1:/data# ./populate_mysql_db_tc.sh +root@842bfb3da1f1:/# cd /data/rf2 +root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh +root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh diff --git a/src/test/resources/README-oracle-docker.txt b/src/test/resources/README-oracle-docker.txt index 657620f..699529e 100644 --- a/src/test/resources/README-oracle-docker.txt +++ b/src/test/resources/README-oracle-docker.txt @@ -11,10 +11,8 @@ # # Launch the container # -dir=c:/data/SnomedCt_International -dir=c:/data/SnomedCt_US +dir=c:/data/ cd $dir -./transitive_closure.sh docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 store/oracle/database-enterprise:12.2.0.1-slim # @@ -22,12 +20,12 @@ docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 # host = host.docker.internal (**make sure to edit this setting before proceeding) # docker exec -it snomed-oracle /bin/bash -root@842bfb3da1f1:/# cd /data +root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/# . /home/oracle/.bashrc root@842bfb3da1f1:/# sqlplus sys/Oradoc_db1 as sysdba alter session set "_ORACLE_SCRIPT"=true; create user snomed identified by snomed; GRANT CONNECT, RESOURCE, DBA TO snomed; exit -root@842bfb3da1f1:/data# ./populate_oracle_db.sh -root@842bfb3da1f1:/data# ./populate_oracle_db_tc.sh +root@842bfb3da1f1:/data/rf2# ./populate_oracle_db.sh +root@842bfb3da1f1:/data/rf2# ./populate_oracle_db_tc.sh diff --git a/src/test/resources/README-postgres-docker.txt b/src/test/resources/README-postgres-docker.txt index 59bdde6..1b2661b 100644 --- a/src/test/resources/README-postgres-docker.txt +++ b/src/test/resources/README-postgres-docker.txt @@ -4,18 +4,16 @@ # # Launch the container # -docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:9.6 +docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:9.6 # # populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_International -dir=c:/data/SnomedCt_US +dir=c:/data/ cd $dir -./transitive_closure.sh docker run -it -v $dir:/data postgres:9.6 /bin/bash -root@842bfb3da1f1:/# cd /data +root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data# ./populate_postgres_db.sh root@842bfb3da1f1:/data# ./populate_postgres_db_tc.sh @@ -29,57 +27,51 @@ root@842bfb3da1f1:/data# ./populate_postgres_db_tc.sh # # Launch the container # -docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:10.14 +docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:10.14 # # populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_International -dir=c:/data/SnomedCt_US +dir=c:/data/ cd $dir -./transitive_closure.sh docker run -it -v $dir:/data postgres:10.14 /bin/bash -root@842bfb3da1f1:/# cd /data -root@842bfb3da1f1:/data# ./populate_postgres_db.sh -root@842bfb3da1f1:/data# ./populate_postgres_db_tc.sh +root@842bfb3da1f1:/# cd /data/rf2 +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh ##### Postgres 11.7 # # Launch the container # -docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:11.9 +docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:11.9 # # populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_International -dir=c:/data/SnomedCt_US +dir=c:/data/ cd $dir -./transitive_closure.sh docker run -it -v $dir:/data postgres:11.9 /bin/bash -root@842bfb3da1f1:/# cd /data -root@842bfb3da1f1:/data# ./populate_postgres_db.sh -root@842bfb3da1f1:/data# ./populate_postgres_db_tc.sh +root@842bfb3da1f1:/# cd /data/rf2 +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh ##### Postgres 12.2 # # Launch the container # -docker run --name snomed-postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:12.4 +docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:12.4 # # populate_mysql_db.sh, populate_mysql_db_tc.sh # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/SnomedCt_US -dir=c:/data/SnomedCt_International +dir=c:/data/ cd $dir -./transitive_closure.sh docker run -it -v $dir:/data postgres:12.4 /bin/bash -root@842bfb3da1f1:/# cd /data -root@842bfb3da1f1:/data# ./populate_postgres_db.sh -root@842bfb3da1f1:/data# ./populate_postgres_db_tc.sh +root@842bfb3da1f1:/# cd /data/rf2 +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh From 38398c799372b4ff15eb5697b89ae1070c138270 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Wed, 10 Feb 2021 13:02:06 -0800 Subject: [PATCH 21/95] Update INT to 20210131 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 84ae8eb..64b35bd 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ true - 20200731 + 20210131 Core INT From f9bc33e8df7f6257d0aedcf985a6ec91700c2514 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Tue, 16 Feb 2021 19:35:25 -0800 Subject: [PATCH 22/95] Update paths for wci-build server and file permissions for MacOS and Linux. Use Docker IP on Linux Server --- src/test/resources/README-mysql-docker.txt | 46 ++++++++++++++- src/test/resources/README-oracle-docker.txt | 36 +++++++++-- src/test/resources/README-postgres-docker.txt | 59 +++++++++++++++++-- 3 files changed, 128 insertions(+), 13 deletions(-) diff --git a/src/test/resources/README-mysql-docker.txt b/src/test/resources/README-mysql-docker.txt index 49f4273..2e31387 100644 --- a/src/test/resources/README-mysql-docker.txt +++ b/src/test/resources/README-mysql-docker.txt @@ -1,4 +1,11 @@ +##### File Setup LINUX (BUILD SERVER) + +cd /wci/data +unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-mysql.*.zip +sudo chmod +x rf2/populate_mysql_db.sh +sudo chmod +x rf2/populate_mysql_db_tc.sh + ##### MySQL 5.7 # @@ -12,11 +19,22 @@ docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQ # # populate_mysql_db.sh, populate_mysql_db_tc.sh +# WINDOWS # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/ +# LINUX (BUILD SERVER) +# host = 172.17.0.1 (**make sure to edit this setting before proceeding) + +# WINDOWS +dir=C:/data +cd %dir% +docker run -it -v %dir%:/data mysql:5.7 /bin/bash + +# LINUX (BUILD SERVER) +export dir=/wci/data/ cd $dir docker run -it -v $dir:/data mysql:5.7 /bin/bash + root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh @@ -30,11 +48,22 @@ docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQ # # populate_mysql_db.sh, populate_mysql_db_tc.sh +# WINDOWS # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/ +# LINUX (BUILD SERVER) +# host = 172.17.0.1 (**make sure to edit this setting before proceeding) + +# WINDOWS +dir=C:/data +cd %dir% +docker run -it -v %dir%:/data mysql:8.0 /bin/bash + +# LINUX (BUILD SERVER) +export dir=/wci/data/ cd $dir docker run -it -v $dir:/data mysql:8.0 /bin/bash + root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh @@ -48,11 +77,22 @@ docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQ # # populate_mysql_db.sh, populate_mysql_db_tc.sh +# WINDOWS # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data +# LINUX (BUILD SERVER) +# host = 172.17.0.1 (**make sure to edit this setting before proceeding) + +# WINDOWS +dir=C:/data +cd %dir% +docker run -it -v %dir%:/data mariadb:10.4 /bin/bash + +# LINUX (BUILD SERVER) +export dir=/wci/data/ cd $dir docker run -it -v $dir:/data mariadb:10.4 /bin/bash + root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh diff --git a/src/test/resources/README-oracle-docker.txt b/src/test/resources/README-oracle-docker.txt index 699529e..439fdf8 100644 --- a/src/test/resources/README-oracle-docker.txt +++ b/src/test/resources/README-oracle-docker.txt @@ -1,31 +1,55 @@ +##### File Setup LINUX (BUILD SERVER) + +cd /wci/data +unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-postgres.*.zip +sudo chmod +x rf2/populate_mysql_db.sh +sudo chmod +x rf2/populate_mysql_db_tc.sh + ##### Oracle 12c # Prerequisites -# - https://hub.docker.com/_/oracle-database-enterprise-edition?tab=description (Click "Proceed to checkout") +# - Log into DockerHub and agree to Oracle's Terms of Service +# - https://hub.docker.com/_/oracle-database-enterprise-edition?tab=description (Click "Proceed to checkout") # -# For testing oracle, run a docker mysql instance +# For testing oracle, run a docker oracle instance # - https://dzone.com/articles/oracle-12c-image-installation-in-docker + # -# Launch the container +# Launch the container WINDOWS +dir=C:/data +cd %dir% +docker run --name snomed-oracle -v %dir%:/data -d --rm -p 8080:8080 -p 1521:1521 store/oracle/database-enterprise:12.2.0.1-slim + # -dir=c:/data/ +# Launch the container LINUX (BUILD SERVER) +export dir=/wci/data/ cd $dir docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 store/oracle/database-enterprise:12.2.0.1-slim # -# populate_oracle_db.sh, populate_oracle_db_tc.sh +# populate_mysql_db.sh, populate_mysql_db_tc.sh +# WINDOWS # host = host.docker.internal (**make sure to edit this setting before proceeding) # +# LINUX (BUILD SERVER) +# host = 172.17.0.1 (**make sure to edit this setting before proceeding) + +# +# Launch the container +# +docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 store/oracle/database-enterprise:12.2.0.1-slim + docker exec -it snomed-oracle /bin/bash -root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/# . /home/oracle/.bashrc root@842bfb3da1f1:/# sqlplus sys/Oradoc_db1 as sysdba alter session set "_ORACLE_SCRIPT"=true; create user snomed identified by snomed; GRANT CONNECT, RESOURCE, DBA TO snomed; exit + +root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_oracle_db.sh root@842bfb3da1f1:/data/rf2# ./populate_oracle_db_tc.sh diff --git a/src/test/resources/README-postgres-docker.txt b/src/test/resources/README-postgres-docker.txt index 1b2661b..5838085 100644 --- a/src/test/resources/README-postgres-docker.txt +++ b/src/test/resources/README-postgres-docker.txt @@ -1,4 +1,11 @@ +##### File Setup LINUX (BUILD SERVER) + +cd /wci/data +unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-postgres.*.zip +sudo chmod +x rf2/populate_mysql_db.sh +sudo chmod +x rf2/populate_mysql_db_tc.sh + ##### Postgres 9.6 # @@ -8,11 +15,22 @@ docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POS # # populate_mysql_db.sh, populate_mysql_db_tc.sh +# WINDOWS # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/ +# LINUX (BUILD SERVER) +# host = 172.17.0.1 (**make sure to edit this setting before proceeding) + +# WINDOWS +dir=C:/data +cd %dir% +docker run -it -v %dir%:/data postgres:9.6 /bin/bash + +# LINUX (BUILD SERVER) +export dir=/wci/data/ cd $dir docker run -it -v $dir:/data postgres:9.6 /bin/bash + root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data# ./populate_postgres_db.sh root@842bfb3da1f1:/data# ./populate_postgres_db_tc.sh @@ -31,11 +49,22 @@ docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POS # # populate_mysql_db.sh, populate_mysql_db_tc.sh +# WINDOWS # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/ +# LINUX (BUILD SERVER) +# host = 172.17.0.1 (**make sure to edit this setting before proceeding) + +# WINDOWS +dir=C:/data +cd %dir% +docker run -it -v %dir%:/data postgres:10.14 /bin/bash + +# LINUX (BUILD SERVER) +export dir=/wci/data/ cd $dir docker run -it -v $dir:/data postgres:10.14 /bin/bash + root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh @@ -49,11 +78,22 @@ docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POS # # populate_mysql_db.sh, populate_mysql_db_tc.sh +# WINDOWS # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/ +# LINUX (BUILD SERVER) +# host = 172.17.0.1 (**make sure to edit this setting before proceeding) + +# WINDOWS +dir=C:/data +cd %dir% +docker run -it -v %dir%:/data postgres:11.9 /bin/bash + +# LINUX (BUILD SERVER) +export dir=/wci/data/ cd $dir docker run -it -v $dir:/data postgres:11.9 /bin/bash + root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh @@ -67,11 +107,22 @@ docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POS # # populate_mysql_db.sh, populate_mysql_db_tc.sh +# WINDOWS # host = host.docker.internal (**make sure to edit this setting before proceeding) # -dir=c:/data/ +# LINUX (BUILD SERVER) +# host = 172.17.0.1 (**make sure to edit this setting before proceeding) + +# WINDOWS +dir=C:/data +cd %dir% +docker run -it -v %dir%:/data postgres:12.4 /bin/bash + +# LINUX (BUILD SERVER) +export dir=/wci/data/ cd $dir docker run -it -v $dir:/data postgres:12.4 /bin/bash + root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh From 4a1f00e2661f052102be57d199f247f33e9600cd Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Wed, 24 Feb 2021 16:52:25 -0800 Subject: [PATCH 23/95] Update for 20210131 --- src/test/resources/README-announcements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 2d06b3a..d42414e 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -3,7 +3,7 @@ ### Twitter, LinkedIn, Facebook It's that time again! Announcing #SNOMEDCT DB load and transitive closure scripts for -the 07/31/2020 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +the 01/31/2021 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/resources.html #MakingTerminologyEasy #snomed This freely available solution enables loading of #SQL database with the latest editions of SNOMED. @@ -21,7 +21,7 @@ Subject: SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the July 31, 2020 update of the SNOMEDCT International Edition. +NLM recently posted the January 31, 2021 update of the SNOMEDCT International Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. From dcac64f7bb40b84ad87c272eb684d89b9e96090a Mon Sep 17 00:00:00 2001 From: Joshua Liu - WCI Date: Mon, 1 Mar 2021 14:48:33 -0800 Subject: [PATCH 24/95] update SNOMED US 20210301 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 64b35bd..aa46f44 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ US - 20200901 + 20210301 National US1000124 From 8991ad49feefda9d3001e1eaddaaa14387f5c671 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Wed, 3 Mar 2021 16:14:06 -0800 Subject: [PATCH 25/95] Add comment to use docker login to enable Oracle Docker image to download on Linux systems --- src/test/resources/README-oracle-docker.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/resources/README-oracle-docker.txt b/src/test/resources/README-oracle-docker.txt index 439fdf8..0fdb377 100644 --- a/src/test/resources/README-oracle-docker.txt +++ b/src/test/resources/README-oracle-docker.txt @@ -2,7 +2,7 @@ ##### File Setup LINUX (BUILD SERVER) cd /wci/data -unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-postgres.*.zip +unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-oracle.*.zip sudo chmod +x rf2/populate_mysql_db.sh sudo chmod +x rf2/populate_mysql_db_tc.sh @@ -16,6 +16,11 @@ sudo chmod +x rf2/populate_mysql_db_tc.sh # For testing oracle, run a docker oracle instance # - https://dzone.com/articles/oracle-12c-image-installation-in-docker +# +# If running an Oracle Database Docker Container on Linux use docker login and enter your hub.docker.com +# credentials for image to download. +# + # # Launch the container WINDOWS From 7492d424bcd40807fec95a0d923e524ab26a0313 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Thu, 4 Mar 2021 16:38:16 -0800 Subject: [PATCH 26/95] Update for running load scripts with Oracle Docker on Linux --- src/main/resources/rf2/populate_oracle_db.sh | 8 +++-- src/test/resources/README-oracle-docker.txt | 37 ++++++++++++-------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/main/resources/rf2/populate_oracle_db.sh b/src/main/resources/rf2/populate_oracle_db.sh index a6c6274..89e3154 100644 --- a/src/main/resources/rf2/populate_oracle_db.sh +++ b/src/main/resources/rf2/populate_oracle_db.sh @@ -13,8 +13,10 @@ password=snomed tns_name=ORCLCDB export NLS_LANG=AMERICAN_AMERICA.UTF8 -/bin/rm -f oracle.log -touch oracle.log +# Oracle Docker on Ubuntu does not allow removing the log file +# Do this step prior to starting Docker to execute populate scripts +# /bin/rm -f oracle.log +# touch oracle.log ef=0 echo "See oracle.log for output" @@ -28,7 +30,7 @@ echo "tns_name = $tns_name" >> oracle.log 2>&1 echo " Create tables ... `/bin/date`" >> oracle.log 2>&1 echo "@oracle_tables.sql" | $ORACLE_HOME/bin/sqlplus $user/$password@$tns_name >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi - + if [ $ef -ne 1 ]; then echo " Load concept table data ... `/bin/date`" >> oracle.log 2>&1 $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="concept.ctl" >> oracle.log 2>&1 diff --git a/src/test/resources/README-oracle-docker.txt b/src/test/resources/README-oracle-docker.txt index 0fdb377..909cfd6 100644 --- a/src/test/resources/README-oracle-docker.txt +++ b/src/test/resources/README-oracle-docker.txt @@ -3,51 +3,51 @@ cd /wci/data unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-oracle.*.zip -sudo chmod +x rf2/populate_mysql_db.sh -sudo chmod +x rf2/populate_mysql_db_tc.sh +sudo chmod +x rf2/populate_oracle_db.sh +sudo chmod +x rf2/populate_oracle_db_tc.sh ##### Oracle 12c # Prerequisites # - Log into DockerHub and agree to Oracle's Terms of Service # - https://hub.docker.com/_/oracle-database-enterprise-edition?tab=description (Click "Proceed to checkout") - # # For testing oracle, run a docker oracle instance # - https://dzone.com/articles/oracle-12c-image-installation-in-docker - # # If running an Oracle Database Docker Container on Linux use docker login and enter your hub.docker.com # credentials for image to download. # - # # Launch the container WINDOWS +# dir=C:/data cd %dir% docker run --name snomed-oracle -v %dir%:/data -d --rm -p 8080:8080 -p 1521:1521 store/oracle/database-enterprise:12.2.0.1-slim + # +# If not running Docker as root LINUX (BUILD SERVER) +# +touch oracle.log concept.log description.log identifier.log relationship.log owlexpression.log statedrelationship.log textdefinition.log association.log attributevalue.log simple.log complexmap.log extendedmap.log simplemap.log language.log refsetdescriptor.log descriptiontype.log moduledependency.log +chmod a=rw oracle.log concept.log description.log identifier.log relationship.log owlexpression.log statedrelationship.log textdefinition.log association.log attributevalue.log simple.log complexmap.log extendedmap.log simplemap.log language.log refsetdescriptor.log descriptiontype.log moduledependency.log + +# +# Create log files and allow read/write to all users. # Launch the container LINUX (BUILD SERVER) +# export dir=/wci/data/ cd $dir docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 store/oracle/database-enterprise:12.2.0.1-slim # -# populate_mysql_db.sh, populate_mysql_db_tc.sh -# WINDOWS -# host = host.docker.internal (**make sure to edit this setting before proceeding) -# -# LINUX (BUILD SERVER) -# host = 172.17.0.1 (**make sure to edit this setting before proceeding) - +# populate_oracle_db.sh, populate_oracle_db_tc.sh # # Launch the container # -docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 store/oracle/database-enterprise:12.2.0.1-slim - docker exec -it snomed-oracle /bin/bash + root@842bfb3da1f1:/# . /home/oracle/.bashrc root@842bfb3da1f1:/# sqlplus sys/Oradoc_db1 as sysdba alter session set "_ORACLE_SCRIPT"=true; @@ -58,3 +58,12 @@ exit root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_oracle_db.sh root@842bfb3da1f1:/data/rf2# ./populate_oracle_db_tc.sh + +# +# Connect to Oracle database to query tables +# Skip docker exec command if still connected from prior step +# + +docker exec -it snomed-oracle /bin/bash +root@842bfb3da1f1:/# . /home/oracle/.bashrc +root@842bfb3da1f1:/# sqlplus snomed/snomed@ORCLCDB From 7b8ea880a733f9dbc86dbd6677685a56b6bb0a5c Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Fri, 5 Mar 2021 10:14:07 -0800 Subject: [PATCH 27/95] Update copyright to 2021 --- src/main/resources/LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/LICENSE.txt b/src/main/resources/LICENSE.txt index 2828032..9758ec1 100644 --- a/src/main/resources/LICENSE.txt +++ b/src/main/resources/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright 2020 West Coast Informatics, LLC +Copyright 2021 West Coast Informatics, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From aff4708763bfcd4f4be3e7bd47802cf736617043 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Fri, 5 Mar 2021 10:23:29 -0800 Subject: [PATCH 28/95] Update version release information in announcements --- src/test/resources/README-announcements.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index d42414e..2a1d786 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -2,16 +2,16 @@ ### Twitter, LinkedIn, Facebook -It's that time again! Announcing #SNOMEDCT DB load and transitive closure scripts for -the 01/31/2021 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +It's that time again! Announcing #SNOMEDCT DB load and transitive closure scripts for +the 013/01/2021 United States Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/resources.html #MakingTerminologyEasy #snomed This freely available solution enables loading of #SQL database with the latest editions of SNOMED. ---- -Announcing #SNOMEDCT DB load and transitive closure scripts for -the 01/31/2020 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +Announcing #SNOMEDCT DB load and transitive closure scripts for +the 03/01/2021 United States Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/resources.html #MakingTerminologyEasy #MakingSnomedEasy #snomed This freely available solution enables one to load their #SQL database with the latest US Editions of SNOMED. @@ -21,9 +21,9 @@ Subject: SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the January 31, 2021 update of the SNOMEDCT International Edition. +NLM recently posted the March 1, 2021 update of the SNOMEDCT International Edition. -For those interested in interacting with SNOMEDCT data through a relational database, +For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. It works for both International Edition and the US Edition. @@ -41,6 +41,6 @@ This utility is freely available through our website: - https://www.youtube.com/watch?v=th36V4B1O8E -Feel free to share this announcement with others or retweet the announcement - +Feel free to share this announcement with others or retweet the announcement - https://twitter.com/wcinformatics/status/ ! From aef2a2dc54361656a532252e3dc0e023b2f3c47a Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Thu, 29 Jul 2021 16:34:31 -0700 Subject: [PATCH 29/95] Enhancements for the RelationshipConcreteValues file --- src/main/resources/rf2/mysql_tables.sql | 34 +++++++++++++++++++ src/main/resources/rf2/mysql_views.sql | 21 ++++++++++++ src/main/resources/rf2/oracle_tables.sql | 22 ++++++++++++ src/main/resources/rf2/oracle_views.sql | 21 ++++++++++++ src/main/resources/rf2/populate_oracle_db.bat | 5 +++ src/main/resources/rf2/populate_oracle_db.sh | 7 ++++ src/main/resources/rf2/psql_tables.sql | 23 +++++++++++++ src/main/resources/rf2/psql_views.sql | 22 ++++++++++++ .../rf2/relationshipconcretevalues.ctl | 23 +++++++++++++ 9 files changed, 178 insertions(+) create mode 100644 src/main/resources/rf2/relationshipconcretevalues.ctl diff --git a/src/main/resources/rf2/mysql_tables.sql b/src/main/resources/rf2/mysql_tables.sql index 616cfba..0680d96 100644 --- a/src/main/resources/rf2/mysql_tables.sql +++ b/src/main/resources/rf2/mysql_tables.sql @@ -113,6 +113,40 @@ typeId = @typeId, characteristicTypeId = @characteristicTypeId, modifierId = @modifierId; +-- Relationship concrete values file. +DROP TABLE IF EXISTS relationshipconcretevalues; +CREATE TABLE relationshipconcretevalues ( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + value VARCHAR(256) NOT NULL, + relationshipGroup INT UNSIGNED NOT NULL, + typeId NUMERIC(20) NOT NULL, + characteristicTypeId NUMERIC(20) NOT NULL, + modifierId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept(id), + FOREIGN KEY (sourceId) REFERENCES concept(id), + FOREIGN KEY (destinationId) REFERENCES concept(id), + FOREIGN KEY (typeId) REFERENCES concept(id), + FOREIGN KEY (characteristicTypeId) REFERENCES concept(id), + FOREIGN KEY (modifierId) REFERENCES concept(id) +) CHARACTER SET utf8; + +LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_RelationshipConcreteValues_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE relationship LINES TERMINATED BY '\r\n' IGNORE 1 LINES +(@id,@effectiveTime,@active,@moduleId,@sourceId,@value,@relationshipGroup,@typeId,@characteristicTypeId,@modifierId) +SET id = @id, +effectiveTime = @effectiveTime, +active = @active, +moduleId = @moduleId, +sourceId = @sourceId, +value = @value, +relationshipGroup = @relationshipGroup, +typeId = @typeId, +characteristicTypeId = @characteristicTypeId, +modifierId = @modifierId; + -- OWL Expression file. DROP TABLE IF EXISTS owlexpression; CREATE TABLE owlexpression ( diff --git a/src/main/resources/rf2/mysql_views.sql b/src/main/resources/rf2/mysql_views.sql index 24236b7..f2cfcc1 100644 --- a/src/main/resources/rf2/mysql_views.sql +++ b/src/main/resources/rf2/mysql_views.sql @@ -92,6 +92,27 @@ AND typeId = cpn4.conceptId AND characteristicTypeId = cpn5.conceptId AND modifierId = cpn6.conceptId; +-- Relationship concrete values table. +DROP VIEW IF EXISTS relationshipconcretevalueswithnames; +CREATE VIEW relationshipconcretevalueswithnames AS +SELECT id, effectiveTime, active, + moduleId, cpn1.preferredName moduleIdName, + sourceId, cpn2.preferredName sourceIdName, + value, relationshipGroup, + typeId, cpn4.preferredName typeIdName, + characteristicTypeId, cpn5.preferredName characteristicTypeIdName, + modifierId, cpn6.preferredName modifierIdName +from relationshipconcretevalues, + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn4, + conceptpreferredname cpn5, + conceptpreferredname cpn6 +WHERE moduleId = cpn1.conceptId +AND sourceId = cpn2.conceptId +AND typeId = cpn4.conceptId +AND characteristicTypeId = cpn5.conceptId +AND modifierId = cpn6.conceptId; -- OWL Expression table DROP VIEW IF EXISTS owlexpressionwithnames; diff --git a/src/main/resources/rf2/oracle_tables.sql b/src/main/resources/rf2/oracle_tables.sql index 8ec061b..c10ede9 100644 --- a/src/main/resources/rf2/oracle_tables.sql +++ b/src/main/resources/rf2/oracle_tables.sql @@ -102,6 +102,28 @@ CREATE TABLE relationship ( ) PCTFREE 10 PCTUSED 80; +-- Relationship concrete values table. +EXECUTE drop_table('relationshipconcretevalues'); +CREATE TABLE relationshipconcretevalues ( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + value VARCHAR2(256) NOT NULL, + relationshipGroup INT NOT NULL, + typeId NUMERIC(20) NOT NULL, + characteristicTypeId NUMERIC(20) NOT NULL, + modifierId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept(id), + FOREIGN KEY (sourceId) REFERENCES concept(id), + FOREIGN KEY (destinationId) REFERENCES concept(id), + FOREIGN KEY (typeId) REFERENCES concept(id), + FOREIGN KEY (characteristicTypeId) REFERENCES concept(id), + FOREIGN KEY (modifierId) REFERENCES concept(id) +) +PCTFREE 10 PCTUSED 80; + -- OWL Expression table. EXECUTE drop_table('owlexpression'); CREATE TABLE owlexpression ( diff --git a/src/main/resources/rf2/oracle_views.sql b/src/main/resources/rf2/oracle_views.sql index cab450e..3433b5b 100644 --- a/src/main/resources/rf2/oracle_views.sql +++ b/src/main/resources/rf2/oracle_views.sql @@ -123,6 +123,27 @@ AND typeId = cpn4.conceptId AND characteristicTypeId = cpn5.conceptId AND modifierId = cpn6.conceptId; +xxx-- Relationship concrete values table. +EXECUTE drop_view('relationshipconcretevalueswithnames'); +CREATE VIEW relationshipconcretevalueswithnames AS +SELECT id, effectiveTime, active, + moduleId, cpn1.preferredName moduleIdName, + sourceId, cpn2.preferredName sourceIdName, + value, relationshipGroup, + typeId, cpn4.preferredName typeIdName, + characteristicTypeId, cpn5.preferredName characteristicTypeIdName, + modifierId, cpn6.preferredName modifierIdName +from relationshipconcretevalues, + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn4, + conceptpreferredname cpn5, + conceptpreferredname cpn6 +WHERE moduleId = cpn1.conceptId +AND sourceId = cpn2.conceptId +AND typeId = cpn4.conceptId +AND characteristicTypeId = cpn5.conceptId +AND modifierId = cpn6.conceptId; -- Stated Relationship table. EXECUTE drop_view('statedrelationshipwithnames'); diff --git a/src/main/resources/rf2/populate_oracle_db.bat b/src/main/resources/rf2/populate_oracle_db.bat index bbaa6d6..9948229 100644 --- a/src/main/resources/rf2/populate_oracle_db.bat +++ b/src/main/resources/rf2/populate_oracle_db.bat @@ -45,6 +45,11 @@ echo Load relationship table data >> oracle.log 2>&1 IF %ERRORLEVEL% NEQ 0 (set error=1) type relationship.log >> oracle.log +echo Load relationship concrete values table data >> oracle.log 2>&1 +%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="relationshipconcretevalues.ctl" >> oracle.log 2>&1 +IF %ERRORLEVEL% NEQ 0 (set error=1) +type relationshipconcretevalues.log >> oracle.log + echo Load owl expression table data >> oracle.log 2>&1 %ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="owlexpression.ctl" >> oracle.log 2>&1 IF %ERRORLEVEL% NEQ 0 (set error=1) diff --git a/src/main/resources/rf2/populate_oracle_db.sh b/src/main/resources/rf2/populate_oracle_db.sh index a6c6274..2207b47 100644 --- a/src/main/resources/rf2/populate_oracle_db.sh +++ b/src/main/resources/rf2/populate_oracle_db.sh @@ -57,6 +57,13 @@ if [ $? -ne 0 ]; then ef=1; fi cat relationship.log >> oracle.log fi +if [ $ef -ne 1 ]; then +echo " Load relationship concrete values table data ... `/bin/date`" >> oracle.log 2>&1 +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="relationshipconcretevalues.ctl" >> oracle.log 2>&1 +if [ $? -ne 0 ]; then ef=1; fi +cat relationshipconcretevalues.log >> oracle.log +fi + if [ $ef -ne 1 ]; then echo " Load owl expression table data ... `/bin/date`" >> oracle.log 2>&1 $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="owlexpression.ctl" >> oracle.log 2>&1 diff --git a/src/main/resources/rf2/psql_tables.sql b/src/main/resources/rf2/psql_tables.sql index 7713882..6b2a861 100644 --- a/src/main/resources/rf2/psql_tables.sql +++ b/src/main/resources/rf2/psql_tables.sql @@ -71,6 +71,29 @@ CREATE TABLE relationship ( \copy relationship FROM 'Snapshot/Terminology/sct2_Relationship_Snapshot_${editionLabel}_${editionVersion}.txt' WITH DELIMITER E'\t' QUOTE E'\\' ENCODING 'UTF8' CSV HEADER; +-- Relationship concrete values file. +DROP TABLE IF EXISTS relationshipconcretevalues CASCADE; +CREATE TABLE relationshipconcretevalues ( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + value VARCHAR(256) NOT NULL, + relationshipGroup INT NOT NULL, + typeId NUMERIC(20) NOT NULL, + characteristicTypeId NUMERIC(20) NOT NULL, + modifierId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept(id), + FOREIGN KEY (sourceId) REFERENCES concept(id), + FOREIGN KEY (destinationId) REFERENCES concept(id), + FOREIGN KEY (typeId) REFERENCES concept(id), + FOREIGN KEY (characteristicTypeId) REFERENCES concept(id), + FOREIGN KEY (modifierId) REFERENCES concept(id) +); + +\copy relationship FROM 'Snapshot/Terminology/sct2_RelationshipConcreteValues_Snapshot_${editionLabel}_${editionVersion}.txt' WITH DELIMITER E'\t' QUOTE E'\\' ENCODING 'UTF8' CSV HEADER; + -- OWL Expression file. DROP TABLE IF EXISTS owlexpression CASCADE; diff --git a/src/main/resources/rf2/psql_views.sql b/src/main/resources/rf2/psql_views.sql index 69559da..3234ded 100644 --- a/src/main/resources/rf2/psql_views.sql +++ b/src/main/resources/rf2/psql_views.sql @@ -90,6 +90,28 @@ AND typeId = cpn4.conceptId AND characteristicTypeId = cpn5.conceptId AND modifierId = cpn6.conceptId; +-- Relationship concrete values table. +DROP VIEW IF EXISTS relationshipconcretevalueswithnames; +CREATE VIEW relationshipconcretevalueswithnames AS +SELECT id, effectiveTime, active, + moduleId, cpn1.preferredName moduleIdName, + sourceId, cpn2.preferredName sourceIdName, + value, relationshipGroup, + typeId, cpn4.preferredName typeIdName, + characteristicTypeId, cpn5.preferredName characteristicTypeIdName, + modifierId, cpn6.preferredName modifierIdName +from relationshipconcretevalues, + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn4, + conceptpreferredname cpn5, + conceptpreferredname cpn6 +WHERE moduleId = cpn1.conceptId +AND sourceId = cpn2.conceptId +AND typeId = cpn4.conceptId +AND characteristicTypeId = cpn5.conceptId +AND modifierId = cpn6.conceptId; + -- OWL Expression table DROP VIEW IF EXISTS owlexpressionwithnames; diff --git a/src/main/resources/rf2/relationshipconcretevalues.ctl b/src/main/resources/rf2/relationshipconcretevalues.ctl new file mode 100644 index 0000000..d215f45 --- /dev/null +++ b/src/main/resources/rf2/relationshipconcretevalues.ctl @@ -0,0 +1,23 @@ +options (skip=1,direct=true) +load data +characterset UTF8 length semantics char +infile 'Snapshot/Terminology/sct2_Relationship_Snapshot_${editionLabel}_${editionVersion}.txt' "str X'0d0a'" +badfile 'relationship.bad' +discardfile 'relationship.dsc' +insert +into table relationship +reenable disabled_constraints +fields terminated by X'09' +trailing nullcols +( + id INTEGER EXTERNAL, + effectiveTime DATE "YYYYMMDD", + active INTEGER EXTERNAL, + moduleId INTEGER EXTERNAL, + sourceId INTEGER EXTERNAL, + destinationId INTEGER EXTERNAL, + relationshipGroup INTEGER EXTERNAL, + typeId INTEGER EXTERNAL, + characteristicTypeId INTEGER EXTERNAL, + modifierId INTEGER EXTERNAL +) \ No newline at end of file From a450f8af92d449b8fc658949e57c37f39c18d3a3 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Mon, 2 Aug 2021 16:54:19 -0700 Subject: [PATCH 30/95] More fixes for 20210731 --- pom.xml | 2 +- src/main/resources/rf2/mysql_tables.sql | 3 +- src/main/resources/rf2/oracle_tables.sql | 1 - .../resources/rf2/populate_postgres_db.sh | 2 +- src/main/resources/rf2/psql_tables.sql | 3 +- src/test/resources/README-check-files.txt | 9 +- src/test/resources/README-mysql-docker.txt | 56 ++++---- src/test/resources/README-oracle-docker.txt | 12 ++ src/test/resources/README-postgres-docker.txt | 126 +++++++++--------- 9 files changed, 107 insertions(+), 107 deletions(-) diff --git a/pom.xml b/pom.xml index aa46f44..e781226 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ true - 20210131 + 20210731 Core INT diff --git a/src/main/resources/rf2/mysql_tables.sql b/src/main/resources/rf2/mysql_tables.sql index 0680d96..8bfdee4 100644 --- a/src/main/resources/rf2/mysql_tables.sql +++ b/src/main/resources/rf2/mysql_tables.sql @@ -128,13 +128,12 @@ CREATE TABLE relationshipconcretevalues ( modifierId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (sourceId) REFERENCES concept(id), - FOREIGN KEY (destinationId) REFERENCES concept(id), FOREIGN KEY (typeId) REFERENCES concept(id), FOREIGN KEY (characteristicTypeId) REFERENCES concept(id), FOREIGN KEY (modifierId) REFERENCES concept(id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_RelationshipConcreteValues_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE relationship LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_RelationshipConcreteValues_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE relationshipconcretevalues LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@sourceId,@value,@relationshipGroup,@typeId,@characteristicTypeId,@modifierId) SET id = @id, effectiveTime = @effectiveTime, diff --git a/src/main/resources/rf2/oracle_tables.sql b/src/main/resources/rf2/oracle_tables.sql index c10ede9..f1c90c2 100644 --- a/src/main/resources/rf2/oracle_tables.sql +++ b/src/main/resources/rf2/oracle_tables.sql @@ -117,7 +117,6 @@ CREATE TABLE relationshipconcretevalues ( modifierId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (sourceId) REFERENCES concept(id), - FOREIGN KEY (destinationId) REFERENCES concept(id), FOREIGN KEY (typeId) REFERENCES concept(id), FOREIGN KEY (characteristicTypeId) REFERENCES concept(id), FOREIGN KEY (modifierId) REFERENCES concept(id) diff --git a/src/main/resources/rf2/populate_postgres_db.sh b/src/main/resources/rf2/populate_postgres_db.sh index 1f798dc..db25a83 100644 --- a/src/main/resources/rf2/populate_postgres_db.sh +++ b/src/main/resources/rf2/populate_postgres_db.sh @@ -3,7 +3,7 @@ # # Database connection parameters # Please edit these variables to reflect your environment -# - Tested with docker postgres 9, 10, 11, 12 (using docker postgres server and client) +# - Tested with docker postgres 10, 11, 12, 13 (using docker postgres server and client) # - PGHOST=host.docker.internal # - Tested on Windows with "Git Bash" as a shell # - and psql in the path diff --git a/src/main/resources/rf2/psql_tables.sql b/src/main/resources/rf2/psql_tables.sql index 6b2a861..07d1757 100644 --- a/src/main/resources/rf2/psql_tables.sql +++ b/src/main/resources/rf2/psql_tables.sql @@ -86,13 +86,12 @@ CREATE TABLE relationshipconcretevalues ( modifierId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (sourceId) REFERENCES concept(id), - FOREIGN KEY (destinationId) REFERENCES concept(id), FOREIGN KEY (typeId) REFERENCES concept(id), FOREIGN KEY (characteristicTypeId) REFERENCES concept(id), FOREIGN KEY (modifierId) REFERENCES concept(id) ); -\copy relationship FROM 'Snapshot/Terminology/sct2_RelationshipConcreteValues_Snapshot_${editionLabel}_${editionVersion}.txt' WITH DELIMITER E'\t' QUOTE E'\\' ENCODING 'UTF8' CSV HEADER; +\copy relationshipconcretevalues FROM 'Snapshot/Terminology/sct2_RelationshipConcreteValues_Snapshot_${editionLabel}_${editionVersion}.txt' WITH DELIMITER E'\t' QUOTE E'\\' ENCODING 'UTF8' CSV HEADER; -- OWL Expression file. diff --git a/src/test/resources/README-check-files.txt b/src/test/resources/README-check-files.txt index 870acf2..0182bb8 100644 --- a/src/test/resources/README-check-files.txt +++ b/src/test/resources/README-check-files.txt @@ -8,10 +8,11 @@ find . -name "*txt" | grep -v Refset_Association | grep -v Refset_AttributeValue grep -v Refset_MRCMAttributeDomain | grep -v Refset_MRCMModuleScope |\ grep -v Refset_MRCMAttributeRange | grep -v Refset_ModuleDependency |\ grep -v Refset_MRCMDomain | grep -v sct2_Concept | grep -v sct2_Description |\ - grep -v sct2_Identifier | grep -v sct2_Relationship | grep -v Refset_OWLExpression |\ - grep -v sct2_StatedRelationship | grep -v sct2_TextDefinition | wc -l + grep -v sct2_Identifier | grep -v sct2_Relationship_ | grep -v Refset_OWLExpression |\ + grep -v sct2_StatedRelationship | grep -v sct2_TextDefinition |\ + grep -v sct2_RelationshipConcreteValues | wc -l -# Look that all files are there (this should equal 20) +# Look that all files are there (this should equal 21) find . -name "*txt" |\ perl -ne 'print if /Refset_Association|AttributeValue|Refset_SimpleSn/; \ print if /Refset_Language|Refset_ExtendedMap|Refset_SimpleMap/; \ @@ -19,6 +20,6 @@ find . -name "*txt" |\ print if /Refset_MRCMAttributeDomain|Refset_MRCMModuleScope/; \ print if /Refset_MRCMAttributeRange|Refset_ModuleDependency/; \ print if /Refset_MRCMDomain|sct2_Concept|sct2_Description/; \ - print if /sct2_Identifier|sct2_Relationship|Refset_OWLExpression/; \ + print if /sct2_Identifier|sct2_Relationship(ConcreteValues)?_|Refset_OWLExpression/; \ print if /sct2_StatedRelationship|sct2_TextDefinition/; \ print if /sct2_TransitiveClosure/' | wc -l diff --git a/src/test/resources/README-mysql-docker.txt b/src/test/resources/README-mysql-docker.txt index 2e31387..86463da 100644 --- a/src/test/resources/README-mysql-docker.txt +++ b/src/test/resources/README-mysql-docker.txt @@ -1,8 +1,20 @@ +##### File Setup WINDOWS + +* Download the SNOMED distribution from NLM +* Unpack to c:/data/SnomedCT_International (for international edition) +* Unpack to c:/data/SnomedCT_US (for US edition) +* Clone and build these projects + * git@github.com:WestCoastInformatics/SNOMED-DB-Load-Scripts.git + * git@github.com:WestCoastInformatics/SNOMED-CT-Transitive-Closure.git +* Open the target/snomed*-mysql*zip file +* Copy the contents of the "rf2" directory to folder where SNOMED data is unpacked (see above) + ##### File Setup LINUX (BUILD SERVER) cd /wci/data unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-mysql.*.zip +unzip -o /wci/projects/SNOMED-CT-Transitive-Closure/target/snomed-transitive-closure-mysql.*.zip sudo chmod +x rf2/populate_mysql_db.sh sudo chmod +x rf2/populate_mysql_db_tc.sh @@ -17,20 +29,17 @@ sudo chmod +x rf2/populate_mysql_db_tc.sh # docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mysql:5.7 -# -# populate_mysql_db.sh, populate_mysql_db_tc.sh -# WINDOWS -# host = host.docker.internal (**make sure to edit this setting before proceeding) -# -# LINUX (BUILD SERVER) -# host = 172.17.0.1 (**make sure to edit this setting before proceeding) - -# WINDOWS +# WINDOWS git bash (to simulate running in Linux) +# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) dir=C:/data -cd %dir% -docker run -it -v %dir%:/data mysql:5.7 /bin/bash +docker run -it -v "$dir":/data mysql:5.7 /bin/bash +root@842bfb3da1f1:/# cd /data/SnomedCT_International +root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh +root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh + # LINUX (BUILD SERVER) +# host = 172.17.0.1 (**make sure to edit this setting before proceeding) export dir=/wci/data/ cd $dir docker run -it -v $dir:/data mysql:5.7 /bin/bash @@ -46,13 +55,6 @@ root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh # docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mysql:8.0 --local_infile=ON -# -# populate_mysql_db.sh, populate_mysql_db_tc.sh -# WINDOWS -# host = host.docker.internal (**make sure to edit this setting before proceeding) -# -# LINUX (BUILD SERVER) -# host = 172.17.0.1 (**make sure to edit this setting before proceeding) # WINDOWS dir=C:/data @@ -60,6 +62,7 @@ cd %dir% docker run -it -v %dir%:/data mysql:8.0 /bin/bash # LINUX (BUILD SERVER) +# host = 172.17.0.1 (**make sure to edit this setting before proceeding) export dir=/wci/data/ cd $dir docker run -it -v $dir:/data mysql:8.0 /bin/bash @@ -68,30 +71,23 @@ root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh -##### MariaDB - 10.4 +##### MariaDB - 10.6 # # Launch the container # -docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mariadb:10.4 - -# -# populate_mysql_db.sh, populate_mysql_db_tc.sh -# WINDOWS -# host = host.docker.internal (**make sure to edit this setting before proceeding) -# -# LINUX (BUILD SERVER) -# host = 172.17.0.1 (**make sure to edit this setting before proceeding) +docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mariadb:10.6 # WINDOWS dir=C:/data cd %dir% -docker run -it -v %dir%:/data mariadb:10.4 /bin/bash +docker run -it -v %dir%:/data mariadb:10.6 /bin/bash # LINUX (BUILD SERVER) +# host = 172.17.0.1 (**make sure to edit this setting before proceeding) export dir=/wci/data/ cd $dir -docker run -it -v $dir:/data mariadb:10.4 /bin/bash +docker run -it -v $dir:/data mariadb:10.6 /bin/bash root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh diff --git a/src/test/resources/README-oracle-docker.txt b/src/test/resources/README-oracle-docker.txt index 0fdb377..23923fb 100644 --- a/src/test/resources/README-oracle-docker.txt +++ b/src/test/resources/README-oracle-docker.txt @@ -1,8 +1,20 @@ +##### File Setup WINDOWS + +* Download the SNOMED distribution from NLM +* Unpack to c:/data/SnomedCT_International (for international edition) +* Unpack to c:/data/SnomedCT_US (for US edition) +* Clone and build these projects + * git@github.com:WestCoastInformatics/SNOMED-DB-Load-Scripts.git + * git@github.com:WestCoastInformatics/SNOMED-CT-Transitive-Closure.git +* Open the target/snomed*-oracle*zip file +* Copy the contents of the "rf2" directory to folder where SNOMED data is unpacked (see above) + ##### File Setup LINUX (BUILD SERVER) cd /wci/data unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-oracle.*.zip +unzip -o /wci/projects/SNOMED-CT-Transitive-Closure/target/snomed-transitive-closure-oracle.*.zip sudo chmod +x rf2/populate_mysql_db.sh sudo chmod +x rf2/populate_mysql_db_tc.sh diff --git a/src/test/resources/README-postgres-docker.txt b/src/test/resources/README-postgres-docker.txt index 5838085..2756e1e 100644 --- a/src/test/resources/README-postgres-docker.txt +++ b/src/test/resources/README-postgres-docker.txt @@ -1,127 +1,121 @@ +##### File Setup WINDOWS + +* Download the SNOMED distribution from NLM +* Unpack to c:/data/SnomedCT_International (for international edition) +* Unpack to c:/data/SnomedCT_US (for US edition) +* Clone and build these projects + * git@github.com:WestCoastInformatics/SNOMED-DB-Load-Scripts.git + * git@github.com:WestCoastInformatics/SNOMED-CT-Transitive-Closure.git +* Open the target/snomed*-postgres*zip file +* Copy the contents of the "rf2" directory to folder where SNOMED data is unpacked (see above) +* Go to that directory and run transitive_closure.sh/bat to generate the transitive closure file + ##### File Setup LINUX (BUILD SERVER) cd /wci/data +unzip -o /wci/projects/SNOMED-CT-Transitive-Closure/target/snomed-transitive-closure-postgres.*.zip unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-postgres.*.zip -sudo chmod +x rf2/populate_mysql_db.sh -sudo chmod +x rf2/populate_mysql_db_tc.sh - -##### Postgres 9.6 +sudo chmod +x rf2/populate_postgres_db.sh +sudo chmod +x rf2/populate_postgres_db_tc.sh # -# Launch the container +# For testing postgres, run a docker postgres instance +# - https://hub.docker.com/_/postgres # -docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:9.6 +##### Postgres 10.17 # -# populate_mysql_db.sh, populate_mysql_db_tc.sh -# WINDOWS -# host = host.docker.internal (**make sure to edit this setting before proceeding) +# Launch the container # -# LINUX (BUILD SERVER) -# host = 172.17.0.1 (**make sure to edit this setting before proceeding) +docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:10.17 -# WINDOWS +# WINDOWS git bash (to simulate running in Linux) +# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) dir=C:/data -cd %dir% -docker run -it -v %dir%:/data postgres:9.6 /bin/bash +docker run -it -v "$dir":/data postgres:10.17 /bin/bash +root@842bfb3da1f1:/# cd /data/SnomedCT_International +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh # LINUX (BUILD SERVER) +# export PGHOST=172.17.0.1 (**make sure to edit this setting before proceeding) export dir=/wci/data/ cd $dir -docker run -it -v $dir:/data postgres:9.6 /bin/bash +docker run -it -v "$dir":/data postgres:10.17 /bin/bash root@842bfb3da1f1:/# cd /data/rf2 -root@842bfb3da1f1:/data# ./populate_postgres_db.sh -root@842bfb3da1f1:/data# ./populate_postgres_db_tc.sh - - -##### Postgres 10.12 - -# -# For testing postgres, run a docker postgres instance -# - https://hub.docker.com/_/postgres +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh +##### Postgres 11.12 # # Launch the container # -docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:10.14 - -# -# populate_mysql_db.sh, populate_mysql_db_tc.sh -# WINDOWS -# host = host.docker.internal (**make sure to edit this setting before proceeding) -# -# LINUX (BUILD SERVER) -# host = 172.17.0.1 (**make sure to edit this setting before proceeding) +docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:11.12 -# WINDOWS +# WINDOWS git bash (to simulate running in Linux) +# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) dir=C:/data -cd %dir% -docker run -it -v %dir%:/data postgres:10.14 /bin/bash +docker run -it -v "$dir":/data postgres:11.12 /bin/bash +root@842bfb3da1f1:/# cd /data/SnomedCT_International +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh # LINUX (BUILD SERVER) +# export PGHOST=172.17.0.1 (**make sure to edit this setting before proceeding) export dir=/wci/data/ cd $dir -docker run -it -v $dir:/data postgres:10.14 /bin/bash +docker run -it -v "$dir":/data postgres:11.12 /bin/bash root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh -##### Postgres 11.7 - +##### Postgres 12.7 # # Launch the container # -docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:11.9 - -# -# populate_mysql_db.sh, populate_mysql_db_tc.sh -# WINDOWS -# host = host.docker.internal (**make sure to edit this setting before proceeding) -# -# LINUX (BUILD SERVER) -# host = 172.17.0.1 (**make sure to edit this setting before proceeding) +docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:12.7 -# WINDOWS +# WINDOWS git bash (to simulate running in Linux) +# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) dir=C:/data -cd %dir% -docker run -it -v %dir%:/data postgres:11.9 /bin/bash +docker run -it -v "$dir":/data postgres:12.7 /bin/bash +root@842bfb3da1f1:/# cd /data/SnomedCT_International +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh # LINUX (BUILD SERVER) +# export PGHOST=172.17.0.1 (**make sure to edit this setting before proceeding) export dir=/wci/data/ cd $dir -docker run -it -v $dir:/data postgres:11.9 /bin/bash +docker run -it -v "$dir":/data postgres:12.7 /bin/bash root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh -##### Postgres 12.2 +##### Postgres 13.3 # # Launch the container # -docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:12.4 +docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:13.3 -# -# populate_mysql_db.sh, populate_mysql_db_tc.sh -# WINDOWS -# host = host.docker.internal (**make sure to edit this setting before proceeding) -# -# LINUX (BUILD SERVER) -# host = 172.17.0.1 (**make sure to edit this setting before proceeding) - -# WINDOWS +# WINDOWS git bash (to simulate running in Linux) +# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) dir=C:/data -cd %dir% -docker run -it -v %dir%:/data postgres:12.4 /bin/bash +docker run -it -v "$dir":/data postgres:13.3 /bin/bash +root@842bfb3da1f1:/# cd /data/SnomedCT_International +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh # LINUX (BUILD SERVER) +# export PGHOST=172.17.0.1 (**make sure to edit this setting before proceeding) export dir=/wci/data/ cd $dir -docker run -it -v $dir:/data postgres:12.4 /bin/bash +docker run -it -v "$dir":/data postgres:13.3 /bin/bash root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh From 45d4ea6dcd49b80b8daf631e3e9ec157cee64e21 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Mon, 2 Aug 2021 17:02:27 -0700 Subject: [PATCH 31/95] Fix oracle ctl file --- src/main/resources/rf2/relationshipconcretevalues.ctl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/resources/rf2/relationshipconcretevalues.ctl b/src/main/resources/rf2/relationshipconcretevalues.ctl index d215f45..421e687 100644 --- a/src/main/resources/rf2/relationshipconcretevalues.ctl +++ b/src/main/resources/rf2/relationshipconcretevalues.ctl @@ -1,11 +1,11 @@ options (skip=1,direct=true) load data characterset UTF8 length semantics char -infile 'Snapshot/Terminology/sct2_Relationship_Snapshot_${editionLabel}_${editionVersion}.txt' "str X'0d0a'" -badfile 'relationship.bad' -discardfile 'relationship.dsc' +infile 'Snapshot/Terminology/sct2_RelationshipConcreteValues_Snapshot_${editionLabel}_${editionVersion}.txt' "str X'0d0a'" +badfile 'relationshipconcretevalues.bad' +discardfile 'relationshipconcretevalues.dsc' insert -into table relationship +into table relationshipconcretevalues reenable disabled_constraints fields terminated by X'09' trailing nullcols @@ -15,7 +15,7 @@ trailing nullcols active INTEGER EXTERNAL, moduleId INTEGER EXTERNAL, sourceId INTEGER EXTERNAL, - destinationId INTEGER EXTERNAL, + value CHAR(256), relationshipGroup INTEGER EXTERNAL, typeId INTEGER EXTERNAL, characteristicTypeId INTEGER EXTERNAL, From 1d5d19f397550f6e118a409d48695277109c0dc7 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Mon, 2 Aug 2021 17:06:09 -0700 Subject: [PATCH 32/95] Some cleanup of mysql readme --- src/test/resources/README-mysql-docker.txt | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/test/resources/README-mysql-docker.txt b/src/test/resources/README-mysql-docker.txt index 86463da..42245b3 100644 --- a/src/test/resources/README-mysql-docker.txt +++ b/src/test/resources/README-mysql-docker.txt @@ -55,11 +55,13 @@ root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh # docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mysql:8.0 --local_infile=ON - -# WINDOWS +# WINDOWS git bash (to simulate running in Linux) +# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) dir=C:/data -cd %dir% -docker run -it -v %dir%:/data mysql:8.0 /bin/bash +docker run -it -v "$dir":/data mysql:8.0 /bin/bash +root@842bfb3da1f1:/# cd /data/SnomedCT_International +root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh +root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh # LINUX (BUILD SERVER) # host = 172.17.0.1 (**make sure to edit this setting before proceeding) @@ -78,10 +80,14 @@ root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh # docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mariadb:10.6 -# WINDOWS +# WINDOWS git bash (to simulate running in Linux) +# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) dir=C:/data -cd %dir% -docker run -it -v %dir%:/data mariadb:10.6 /bin/bash +docker run -it -v "$dir":/data mariadb:10.6 /bin/bash +root@842bfb3da1f1:/# cd /data/SnomedCT_International +root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh +root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh + # LINUX (BUILD SERVER) # host = 172.17.0.1 (**make sure to edit this setting before proceeding) From 8b8cea5796d8e5d9d5d2f82f5c253abf07e79965 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Mon, 9 Aug 2021 15:08:37 -0700 Subject: [PATCH 33/95] Add relationship concrete values --- src/test/resources/README-oracle-docker.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/test/resources/README-oracle-docker.txt b/src/test/resources/README-oracle-docker.txt index 04e5084..ee1bf21 100644 --- a/src/test/resources/README-oracle-docker.txt +++ b/src/test/resources/README-oracle-docker.txt @@ -41,8 +41,9 @@ docker run --name snomed-oracle -v %dir%:/data -d --rm -p 8080:8080 -p 1521:1521 # # If not running Docker as root LINUX (BUILD SERVER) # -touch oracle.log concept.log description.log identifier.log relationship.log owlexpression.log statedrelationship.log textdefinition.log association.log attributevalue.log simple.log complexmap.log extendedmap.log simplemap.log language.log refsetdescriptor.log descriptiontype.log moduledependency.log -chmod a=rw oracle.log concept.log description.log identifier.log relationship.log owlexpression.log statedrelationship.log textdefinition.log association.log attributevalue.log simple.log complexmap.log extendedmap.log simplemap.log language.log refsetdescriptor.log descriptiontype.log moduledependency.log +cd $dir/rf2 +touch oracle.log concept.log description.log identifier.log relationship.log owlexpression.log statedrelationship.log textdefinition.log association.log attributevalue.log simple.log complexmap.log extendedmap.log simplemap.log language.log refsetdescriptor.log descriptiontype.log moduledependency.log relationshipconcretevalues.log +chmod a=rw oracle.log concept.log description.log identifier.log relationship.log owlexpression.log statedrelationship.log textdefinition.log association.log attributevalue.log simple.log complexmap.log extendedmap.log simplemap.log language.log refsetdescriptor.log descriptiontype.log moduledependency.log relationshipconcretevalues.log # # Create log files and allow read/write to all users. @@ -78,3 +79,5 @@ root@842bfb3da1f1:/data/rf2# ./populate_oracle_db_tc.sh docker exec -it snomed-oracle /bin/bash root@842bfb3da1f1:/# . /home/oracle/.bashrc root@842bfb3da1f1:/# sqlplus snomed/snomed@ORCLCDB + + From 96fffa733a560ca835fdced02cb83f44730d9eae Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Tue, 10 Aug 2021 14:41:53 -0700 Subject: [PATCH 34/95] Use sudo for oracle db. Populate scripts have trouble executing without sudo. --- src/test/resources/README-oracle-docker.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/resources/README-oracle-docker.txt b/src/test/resources/README-oracle-docker.txt index ee1bf21..3bf7946 100644 --- a/src/test/resources/README-oracle-docker.txt +++ b/src/test/resources/README-oracle-docker.txt @@ -51,14 +51,14 @@ chmod a=rw oracle.log concept.log description.log identifier.log relationship.lo # export dir=/wci/data/ cd $dir -docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 store/oracle/database-enterprise:12.2.0.1-slim +sudo docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 store/oracle/database-enterprise:12.2.0.1-slim # # populate_oracle_db.sh, populate_oracle_db_tc.sh # # Launch the container # -docker exec -it snomed-oracle /bin/bash +sudo docker exec -it snomed-oracle /bin/bash root@842bfb3da1f1:/# . /home/oracle/.bashrc root@842bfb3da1f1:/# sqlplus sys/Oradoc_db1 as sysdba @@ -76,7 +76,7 @@ root@842bfb3da1f1:/data/rf2# ./populate_oracle_db_tc.sh # Skip docker exec command if still connected from prior step # -docker exec -it snomed-oracle /bin/bash +sudo docker exec -it snomed-oracle /bin/bash root@842bfb3da1f1:/# . /home/oracle/.bashrc root@842bfb3da1f1:/# sqlplus snomed/snomed@ORCLCDB From bb1900decf1fd896cb8f82c548393ebf08f0f60b Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Thu, 19 Aug 2021 14:40:41 -0700 Subject: [PATCH 35/95] Add links to README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7fe3621..db9f89e 100644 --- a/README.md +++ b/README.md @@ -15,15 +15,15 @@ Minimum Specification Installation ------------ -* See HOWTO.txt file to understand how to load the rf2 files into the database +* See [HOWTO.txt](src/main/resources/HOWTO.txt) file to understand how to load the rf2 files into the database See Also -------- -* src/main/resources/LICENSE.txt -* src/main/resources/README.txt -* src/main/resources/HOWTO.txt - +* [src/main/resources/LICENSE.txt](src/main/resources/LICENSE.txt) +* [src/main/resources/README.txt](src/main/resources/README.txt) +* [src/main/resources/HOWTO.txt](src/main/resources/HOWTO.txt) + TODO ---- Next Steps: From 5356046d7853a4e810529054b52dd5bc1f149046 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Thu, 19 Aug 2021 14:41:46 -0700 Subject: [PATCH 36/95] Update versions of dbs supported --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index db9f89e..10bf5c4 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,10 @@ http://www.westcoastinformatics.com/resources.html Minimum Specification --------------------- -- MYSQL v5.6.+, MySQL v8.+, MariaDB 10.+ +- MYSQL v5.7.+, MySQL v8.+, MariaDB 10.+ - MySQL v8 requires the server to run with "--local_infile=ON" - Oracle v11.+ -- Postgres v9.+, v10.+, v11.+, v12.+ +- Postgres v10.+, v11.+, v12.+, v13.+ Installation ------------ From e1e3b825c01238e34ac5d3d96d22add389bb37cb Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Thu, 19 Aug 2021 14:42:27 -0700 Subject: [PATCH 37/95] Remove completed TODO --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 10bf5c4..dcc780b 100644 --- a/README.md +++ b/README.md @@ -29,4 +29,4 @@ TODO Next Steps: * Better automated QA to validate file sizes against table sizes * Better automated QA to validate views have same row count as driving tables -* Support additional SNOMED files + From 3d8a3ae1ea729e377aaafa94cf2d0324c5a158c4 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 8 Sep 2021 21:19:36 +0000 Subject: [PATCH 38/95] Update US version to 20210901 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e781226..19260f4 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ US - 20210301 + 20210901 National US1000124 From 5b02b242976e62549571b2402ca6727f7e1af360 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 8 Sep 2021 21:21:18 +0000 Subject: [PATCH 39/95] Update announcement for Snomed US 20210901 --- src/test/resources/README-announcements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 2a1d786..70ae2f4 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -3,7 +3,7 @@ ### Twitter, LinkedIn, Facebook It's that time again! Announcing #SNOMEDCT DB load and transitive closure scripts for -the 013/01/2021 United States Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +the 09/01/2021 United States Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/resources.html #MakingTerminologyEasy #snomed This freely available solution enables loading of #SQL database with the latest editions of SNOMED. @@ -11,7 +11,7 @@ This freely available solution enables loading of #SQL database with the latest ---- Announcing #SNOMEDCT DB load and transitive closure scripts for -the 03/01/2021 United States Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +the 09/01/2021 United States Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/resources.html #MakingTerminologyEasy #MakingSnomedEasy #snomed This freely available solution enables one to load their #SQL database with the latest US Editions of SNOMED. @@ -21,7 +21,7 @@ Subject: SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the March 1, 2021 update of the SNOMEDCT International Edition. +NLM recently posted the Sept 01, 2021 update of the SNOMEDCT United States Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. From ce7a1c9caae6d6fdc2b22091ab6e84d220bc65ff Mon Sep 17 00:00:00 2001 From: njmarques Date: Fri, 4 Feb 2022 13:18:01 -0800 Subject: [PATCH 40/95] Update Internation edition to 20220131 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 19260f4..5b6aaf8 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ true - 20210731 + 20220131 Core INT From 848bfdaed97aecb7790da7d3452a1f758bf5c27f Mon Sep 17 00:00:00 2001 From: njmarques Date: Fri, 4 Feb 2022 13:18:25 -0800 Subject: [PATCH 41/95] Update Internation edition to 20220131 --- src/main/resources/LICENSE.txt | 2 +- src/test/resources/README-announcements.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/resources/LICENSE.txt b/src/main/resources/LICENSE.txt index 9758ec1..57b8ff2 100644 --- a/src/main/resources/LICENSE.txt +++ b/src/main/resources/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright 2021 West Coast Informatics, LLC +Copyright 2022 West Coast Informatics, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 70ae2f4..5ded1bb 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -3,7 +3,7 @@ ### Twitter, LinkedIn, Facebook It's that time again! Announcing #SNOMEDCT DB load and transitive closure scripts for -the 09/01/2021 United States Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +the 01/31/2022 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/resources.html #MakingTerminologyEasy #snomed This freely available solution enables loading of #SQL database with the latest editions of SNOMED. @@ -11,7 +11,7 @@ This freely available solution enables loading of #SQL database with the latest ---- Announcing #SNOMEDCT DB load and transitive closure scripts for -the 09/01/2021 United States Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +the 01/31/2022 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/resources.html #MakingTerminologyEasy #MakingSnomedEasy #snomed This freely available solution enables one to load their #SQL database with the latest US Editions of SNOMED. @@ -21,7 +21,7 @@ Subject: SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the Sept 01, 2021 update of the SNOMEDCT United States Edition. +NLM recently posted the January 31, 2022 update of the SNOMEDCT International Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. From ad619226ed10321f158af4f38bb996f1062fa74c Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Mon, 7 Feb 2022 09:00:56 -0800 Subject: [PATCH 42/95] Update anouncements --- src/test/resources/README-announcements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 70ae2f4..3d1b706 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -3,7 +3,7 @@ ### Twitter, LinkedIn, Facebook It's that time again! Announcing #SNOMEDCT DB load and transitive closure scripts for -the 09/01/2021 United States Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +the 20210901 United States Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/resources.html #MakingTerminologyEasy #snomed This freely available solution enables loading of #SQL database with the latest editions of SNOMED. From 9e1a5aad7edc4dbefd6098de2dffea7af3ff93ab Mon Sep 17 00:00:00 2001 From: njmarques Date: Wed, 2 Mar 2022 10:22:11 -0800 Subject: [PATCH 43/95] Update US release to 20220301 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5b6aaf8..bec132a 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ US - 20210901 + 20220301 National US1000124 From a9f4a3b51154d1e4424944d517bc005f141a90f1 Mon Sep 17 00:00:00 2001 From: Joshua Liu <78755794+enjoylifejyl@users.noreply.github.com> Date: Thu, 3 Mar 2022 15:47:02 -0800 Subject: [PATCH 44/95] Update README-oracle-docker.txt --- src/test/resources/README-oracle-docker.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/README-oracle-docker.txt b/src/test/resources/README-oracle-docker.txt index 3bf7946..5ad5351 100644 --- a/src/test/resources/README-oracle-docker.txt +++ b/src/test/resources/README-oracle-docker.txt @@ -51,7 +51,7 @@ chmod a=rw oracle.log concept.log description.log identifier.log relationship.lo # export dir=/wci/data/ cd $dir -sudo docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 store/oracle/database-enterprise:12.2.0.1-slim +sudo docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 container-registry.oracle.com/database/enterprise:12.1.0.2 # # populate_oracle_db.sh, populate_oracle_db_tc.sh From 09ad1c82bdd91ad598b36ef990a8ad10fc300f09 Mon Sep 17 00:00:00 2001 From: Joshua Liu <78755794+enjoylifejyl@users.noreply.github.com> Date: Thu, 3 Mar 2022 16:25:58 -0800 Subject: [PATCH 45/95] Update README-oracle-docker.txt --- src/test/resources/README-oracle-docker.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/resources/README-oracle-docker.txt b/src/test/resources/README-oracle-docker.txt index 5ad5351..094ea45 100644 --- a/src/test/resources/README-oracle-docker.txt +++ b/src/test/resources/README-oracle-docker.txt @@ -51,6 +51,11 @@ chmod a=rw oracle.log concept.log description.log identifier.log relationship.lo # export dir=/wci/data/ cd $dir + +#For store/oracle/database-enterprise:12.2.0.1-slim +sudo docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 store/oracle/database-enterprise:12.2.0.1-slim + +#For container-registry.oracle.com/database/enterprise:12.1.0.2 sudo docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 container-registry.oracle.com/database/enterprise:12.1.0.2 # From 6b462bc9e1928d0cccbee5af90a7cc89011afb2e Mon Sep 17 00:00:00 2001 From: njmarques Date: Thu, 3 Mar 2022 17:06:16 -0800 Subject: [PATCH 46/95] Update announcement for US 3/1/2022 release --- src/test/resources/README-announcements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 5ded1bb..f643481 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -3,7 +3,7 @@ ### Twitter, LinkedIn, Facebook It's that time again! Announcing #SNOMEDCT DB load and transitive closure scripts for -the 01/31/2022 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +the 03/01/2022 United States Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/resources.html #MakingTerminologyEasy #snomed This freely available solution enables loading of #SQL database with the latest editions of SNOMED. @@ -11,7 +11,7 @@ This freely available solution enables loading of #SQL database with the latest ---- Announcing #SNOMEDCT DB load and transitive closure scripts for -the 01/31/2022 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +the 03/01/2022 United States Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/resources.html #MakingTerminologyEasy #MakingSnomedEasy #snomed This freely available solution enables one to load their #SQL database with the latest US Editions of SNOMED. @@ -21,7 +21,7 @@ Subject: SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the January 31, 2022 update of the SNOMEDCT International Edition. +NLM recently posted the March 1, 2022 update of the SNOMEDCT US Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. From 149bbb4adb967ab438c6fec51f17924c117645e7 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Mon, 7 Mar 2022 15:25:57 -0800 Subject: [PATCH 47/95] Update announcement --- src/test/resources/README-announcements.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 5ded1bb..0026b86 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -3,33 +3,33 @@ ### Twitter, LinkedIn, Facebook It's that time again! Announcing #SNOMEDCT DB load and transitive closure scripts for -the 01/31/2022 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. -See https://westcoastinformatics.com/resources.html #MakingTerminologyEasy #snomed +the 20220301 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +See https://westcoastinformatics.com/resources #MakingTerminologyEasy #snomed This freely available solution enables loading of #SQL database with the latest editions of SNOMED. ---- Announcing #SNOMEDCT DB load and transitive closure scripts for -the 01/31/2022 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. -See https://westcoastinformatics.com/resources.html #MakingTerminologyEasy #MakingSnomedEasy #snomed +the 20220131 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +See https://westcoastinformatics.com/resources #MakingTerminologyEasy #MakingSnomedEasy #snomed This freely available solution enables one to load their #SQL database with the latest US Editions of SNOMED. ### UMLS Users Mailing List -Subject: SNOMEDCT DB load and transitive closure scripts +Subject: 20220301 SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the January 31, 2022 update of the SNOMEDCT International Edition. +NLM recently posted the March 1, 2022 update of the SNOMEDCT US Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. -It works for both International Edition and the US Edition. +We offer support for both International Edition and the US Edition. This utility is freely available through our website: -* Information and download: https://westcoastinformatics.com/resources.html +* Information and download: https://westcoastinformatics.com/resources - See the "DB Load Scripts" section - See the "Transitive Closure Scripts" section From aa39cb06b4f07afe3b5d4812c52c7ab34fe58d9f Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Fri, 29 Jul 2022 17:31:47 -0700 Subject: [PATCH 48/95] Update for July 2022 International Edition --- pom.xml | 2 +- src/test/resources/README-announcements.txt | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index bec132a..4315f61 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ true - 20220131 + 20220731 Core INT diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 0026b86..7a05360 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -3,7 +3,7 @@ ### Twitter, LinkedIn, Facebook It's that time again! Announcing #SNOMEDCT DB load and transitive closure scripts for -the 20220301 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +the 20220731 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/resources #MakingTerminologyEasy #snomed This freely available solution enables loading of #SQL database with the latest editions of SNOMED. @@ -11,17 +11,17 @@ This freely available solution enables loading of #SQL database with the latest ---- Announcing #SNOMEDCT DB load and transitive closure scripts for -the 20220131 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +the 20220731 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/resources #MakingTerminologyEasy #MakingSnomedEasy #snomed This freely available solution enables one to load their #SQL database with the latest US Editions of SNOMED. ### UMLS Users Mailing List -Subject: 20220301 SNOMEDCT DB load and transitive closure scripts +Subject: 20220731 SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the March 1, 2022 update of the SNOMEDCT US Edition. +NLM recently posted the July 31, 2022 update of the SNOMEDCT International Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. From b528c955b26444faa8e459319cdb64c485c22e49 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Thu, 4 Aug 2022 16:59:05 -0700 Subject: [PATCH 49/95] Update announcement for latest version --- src/test/resources/README-announcements.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 0026b86..24713ad 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -2,19 +2,17 @@ ### Twitter, LinkedIn, Facebook -It's that time again! Announcing #SNOMEDCT DB load and transitive closure scripts for -the 20220301 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +It's that time again! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20220301 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/resources #MakingTerminologyEasy #snomed This freely available solution enables loading of #SQL database with the latest editions of SNOMED. ---- -Announcing #SNOMEDCT DB load and transitive closure scripts for -the 20220131 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +Is it July already?! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20220731 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/resources #MakingTerminologyEasy #MakingSnomedEasy #snomed -This freely available solution enables one to load their #SQL database with the latest US Editions of SNOMED. +This freely available solution enables one to load their #SQL database with the latest editions of #SNOMED. ### UMLS Users Mailing List Subject: 20220301 SNOMEDCT DB load and transitive closure scripts From 19659505be7374ade5192f3af57435795e132a77 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Thu, 1 Sep 2022 15:51:22 -0700 Subject: [PATCH 50/95] update to Snomed US edition 20220901 --- pom.xml | 2 +- src/test/resources/README-announcements.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 4315f61..87975b7 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ US - 20220301 + 20220901 National US1000124 diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 24713ad..079d0d1 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -2,7 +2,7 @@ ### Twitter, LinkedIn, Facebook -It's that time again! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20220301 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +It's that time again! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20220901 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/resources #MakingTerminologyEasy #snomed This freely available solution enables loading of #SQL database with the latest editions of SNOMED. @@ -15,11 +15,11 @@ See https://westcoastinformatics.com/resources #MakingTerminologyEasy #MakingSn This freely available solution enables one to load their #SQL database with the latest editions of #SNOMED. ### UMLS Users Mailing List -Subject: 20220301 SNOMEDCT DB load and transitive closure scripts +Subject: 20220901 SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the March 1, 2022 update of the SNOMEDCT US Edition. +NLM recently posted the September 1, 2022 update of the SNOMEDCT US Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. From 58d5b174a8435a69ba455446386ab65289b8c64c Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Thu, 15 Sep 2022 01:02:46 +0100 Subject: [PATCH 51/95] Update announcement --- src/test/resources/README-announcements.txt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 079d0d1..d2ce497 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -2,10 +2,21 @@ ### Twitter, LinkedIn, Facebook -It's that time again! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20220901 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. -See https://westcoastinformatics.com/resources #MakingTerminologyEasy #snomed +-- SNOMED International July 31: -This freely available solution enables loading of #SQL database with the latest editions of SNOMED. +Is it August already?! Announcing #SNOMEDCT DB load and transitive +closure scripts for the 20220731 International Edition! Out-of-the-box +support for #Postgres, #Oracle, #MySQL, and #MariaDB. +#MakingTerminologyEasy #MakingSnomedEasy #snomed +https://westcoastinformatics.com/resources + +-- US Edition September 1: + +Fall is upon us! Announcing #SNOMEDCT DB load and transitive +closure scripts for the 20220901 US Edition! Out-of-the-box +support for #Postgres, #Oracle, #MySQL, and #MariaDB. +#MakingTerminologyEasy #MakingSnomedEasy #snomed +https://westcoastinformatics.com/resources ---- From a28ec16b747250e2bf8270b31861ead07afcee43 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Wed, 1 Feb 2023 11:37:12 -0800 Subject: [PATCH 52/95] update for Snomed Int'l 20220131 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 87975b7..2e4c7c2 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ true - 20220731 + 20230131 Core INT From edd4730ed1b4fdf49a28fd4861eb6e19956748a5 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Thu, 9 Feb 2023 00:31:54 +0000 Subject: [PATCH 53/95] Update announcements --- src/test/resources/README-announcements.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index d2ce497..049babd 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -2,13 +2,13 @@ ### Twitter, LinkedIn, Facebook --- SNOMED International July 31: +-- SNOMED International Jan 31: Is it August already?! Announcing #SNOMEDCT DB load and transitive -closure scripts for the 20220731 International Edition! Out-of-the-box +closure scripts for the 20230131 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #MakingSnomedEasy #snomed -https://westcoastinformatics.com/resources +https://www.westcoastinformatics.com/products/db-load-scripts -- US Edition September 1: @@ -16,7 +16,7 @@ Fall is upon us! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20220901 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #MakingSnomedEasy #snomed -https://westcoastinformatics.com/resources +https://www.westcoastinformatics.com/products/db-load-scripts ---- @@ -26,11 +26,11 @@ See https://westcoastinformatics.com/resources #MakingTerminologyEasy #MakingSn This freely available solution enables one to load their #SQL database with the latest editions of #SNOMED. ### UMLS Users Mailing List -Subject: 20220901 SNOMEDCT DB load and transitive closure scripts +Subject: 20230301 SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the September 1, 2022 update of the SNOMEDCT US Edition. +NLM recently posted the March 1, 2023 update of the SNOMEDCT US Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. @@ -38,7 +38,7 @@ We offer support for both International Edition and the US Edition. This utility is freely available through our website: -* Information and download: https://westcoastinformatics.com/resources +* Information and download: https://www.westcoastinformatics.com/products/db-load-scripts - See the "DB Load Scripts" section - See the "Transitive Closure Scripts" section @@ -46,8 +46,8 @@ This utility is freely available through our website: - https://github.com/WestCoastInformatics/SNOMED-DB-Load-Scripts - https://github.com/WestCoastInformatics/SNOMED-CT-Transitive-Closure -* Training video: - - https://www.youtube.com/watch?v=th36V4B1O8E +* Updated Training video: + - https://youtu.be/f6akQZObZrs Feel free to share this announcement with others or retweet the announcement - From 0fe96988e31308586d7538e9ebf898c6da3dd94d Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Wed, 1 Mar 2023 13:45:59 -0800 Subject: [PATCH 54/95] Prepare US Edition 20230301 --- pom.xml | 2 +- src/test/resources/README-announcements.txt | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 2e4c7c2..88d2641 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ US - 20220901 + 20230301 National US1000124 diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 049babd..491787c 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -4,23 +4,23 @@ -- SNOMED International Jan 31: -Is it August already?! Announcing #SNOMEDCT DB load and transitive -closure scripts for the 20230131 International Edition! Out-of-the-box +Is it August already?! Announcing #SNOMEDCT DB load and transitive +closure scripts for the 20230131 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #MakingSnomedEasy #snomed https://www.westcoastinformatics.com/products/db-load-scripts --- US Edition September 1: +-- US Edition March 1: -Fall is upon us! Announcing #SNOMEDCT DB load and transitive -closure scripts for the 20220901 US Edition! Out-of-the-box +Fall is upon us! Announcing #SNOMEDCT DB load and transitive +closure scripts for the 20230301 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #MakingSnomedEasy #snomed https://www.westcoastinformatics.com/products/db-load-scripts ---- -Is it July already?! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20220731 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +Is it March already?! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20230301 United States Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/resources #MakingTerminologyEasy #MakingSnomedEasy #snomed This freely available solution enables one to load their #SQL database with the latest editions of #SNOMED. From 7dc50043da3e70a679a9d4e525af43f3be1facda Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Mon, 27 Mar 2023 21:57:12 +0100 Subject: [PATCH 55/95] Update announcement --- src/test/resources/README-announcements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 491787c..063d3f9 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -21,7 +21,7 @@ https://www.westcoastinformatics.com/products/db-load-scripts ---- Is it March already?! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20230301 United States Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. -See https://westcoastinformatics.com/resources #MakingTerminologyEasy #MakingSnomedEasy #snomed +See https://westcoastinformatics.com/products/db-load-scripts #MakingTerminologyEasy #MakingSnomedEasy #snomed This freely available solution enables one to load their #SQL database with the latest editions of #SNOMED. From 434b5b0e56cffaf43f17cb421ff458f7aedd03d9 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Fri, 28 Jul 2023 17:40:39 +0100 Subject: [PATCH 56/95] Update link to website --- src/main/resources/README.txt | 2 +- src/test/resources/README-announcements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/README.txt b/src/main/resources/README.txt index f2ce773..f57052c 100644 --- a/src/main/resources/README.txt +++ b/src/main/resources/README.txt @@ -1,5 +1,5 @@ Welcome to SNOMED CT MySQL, Postgres, and Oracle Database Load Scripts -http://www.wcinformatics.com/resources.html +https://www.westcoastinformatics.com/products/db-load-scripts Go to the above link for documentation, and additional downloads. diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 063d3f9..e4dcf4f 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -21,7 +21,7 @@ https://www.westcoastinformatics.com/products/db-load-scripts ---- Is it March already?! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20230301 United States Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. -See https://westcoastinformatics.com/products/db-load-scripts #MakingTerminologyEasy #MakingSnomedEasy #snomed +See https://westcoastinformatics.com/products/db-load-scripts #MakingTerminologyEasy #MakingSnomedEasy #snomedct This freely available solution enables one to load their #SQL database with the latest editions of #SNOMED. From 8521f97a8465b882bc75b6c999ddef4d4b031b43 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Fri, 28 Jul 2023 17:43:36 +0100 Subject: [PATCH 57/95] Update link to website --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dcc780b..d2bb8ba 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Scripts to create and populate a MySQL, Postgres, or Oracle database with a SNOMED CT terminology release in RF2. To download a package built for the latest US or International edition, visit -http://www.westcoastinformatics.com/resources.html +https://www.westcoastinformatics.com/products/db-load-scripts Minimum Specification --------------------- From a1b55209127cb6b4f39140ccd15843d639d4026c Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Tue, 1 Aug 2023 13:30:09 -0700 Subject: [PATCH 58/95] Update for 20230731 International release --- pom.xml | 2 +- src/main/resources/LICENSE.txt | 2 +- src/test/resources/README-announcements.txt | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 88d2641..fcf2232 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ true - 20230131 + 20230731 Core INT diff --git a/src/main/resources/LICENSE.txt b/src/main/resources/LICENSE.txt index 57b8ff2..6af66e4 100644 --- a/src/main/resources/LICENSE.txt +++ b/src/main/resources/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright 2022 West Coast Informatics, LLC +Copyright 2023 West Coast Informatics, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index e4dcf4f..bf8bb3d 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -2,10 +2,10 @@ ### Twitter, LinkedIn, Facebook --- SNOMED International Jan 31: +-- SNOMED International Jul 31: Is it August already?! Announcing #SNOMEDCT DB load and transitive -closure scripts for the 20230131 International Edition! Out-of-the-box +closure scripts for the 20230731 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #MakingSnomedEasy #snomed https://www.westcoastinformatics.com/products/db-load-scripts @@ -20,7 +20,7 @@ https://www.westcoastinformatics.com/products/db-load-scripts ---- -Is it March already?! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20230301 United States Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +Is it July already?! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20230701 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/products/db-load-scripts #MakingTerminologyEasy #MakingSnomedEasy #snomedct This freely available solution enables one to load their #SQL database with the latest editions of #SNOMED. @@ -30,7 +30,7 @@ Subject: 20230301 SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the March 1, 2023 update of the SNOMEDCT US Edition. +NLM recently posted the July 31, 2023 update of the SNOMEDCT INT Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. From f4b2290b274fef7eba2cdc58d863bb64c63e594f Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Tue, 1 Aug 2023 14:42:52 -0700 Subject: [PATCH 59/95] update database versions --- README.md | 8 +-- src/test/resources/README-mysql-docker.txt | 8 +-- src/test/resources/README-postgres-docker.txt | 59 ++++++++++++++----- 3 files changed, 51 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index d2bb8ba..706534a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ SNOMED CT DATABASE LOAD SCRIPTS =============================== -Scripts to create and populate a MySQL, Postgres, or Oracle database with a +Scripts to create and populate a MySQL, Postgres, or Oracle database with a SNOMED CT terminology release in RF2. To download a package built for the latest US or International edition, visit @@ -9,9 +9,9 @@ https://www.westcoastinformatics.com/products/db-load-scripts Minimum Specification --------------------- - MYSQL v5.7.+, MySQL v8.+, MariaDB 10.+ - - MySQL v8 requires the server to run with "--local_infile=ON" -- Oracle v11.+ -- Postgres v10.+, v11.+, v12.+, v13.+ + - MySQL v8 requires the server to run with "--local_infile=ON" +- Oracle v12.+ +- Postgres v11.+, v12.+, v13.+, v14.+, v15.+ Installation ------------ diff --git a/src/test/resources/README-mysql-docker.txt b/src/test/resources/README-mysql-docker.txt index 42245b3..57ec330 100644 --- a/src/test/resources/README-mysql-docker.txt +++ b/src/test/resources/README-mysql-docker.txt @@ -73,17 +73,17 @@ root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh -##### MariaDB - 10.6 +##### MariaDB - 10.11 # # Launch the container # -docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mariadb:10.6 +docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mariadb:10.11 # WINDOWS git bash (to simulate running in Linux) # export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) dir=C:/data -docker run -it -v "$dir":/data mariadb:10.6 /bin/bash +docker run -it -v "$dir":/data mariadb:10.11 /bin/bash root@842bfb3da1f1:/# cd /data/SnomedCT_International root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh @@ -93,7 +93,7 @@ root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh # host = 172.17.0.1 (**make sure to edit this setting before proceeding) export dir=/wci/data/ cd $dir -docker run -it -v $dir:/data mariadb:10.6 /bin/bash +docker run -it -v $dir:/data mariadb:10.11 /bin/bash root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh diff --git a/src/test/resources/README-postgres-docker.txt b/src/test/resources/README-postgres-docker.txt index 2756e1e..5eacfbe 100644 --- a/src/test/resources/README-postgres-docker.txt +++ b/src/test/resources/README-postgres-docker.txt @@ -24,16 +24,16 @@ sudo chmod +x rf2/populate_postgres_db_tc.sh # - https://hub.docker.com/_/postgres # -##### Postgres 10.17 +##### Postgres 11.20 # # Launch the container # -docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:10.17 +docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:11.20 # WINDOWS git bash (to simulate running in Linux) # export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) dir=C:/data -docker run -it -v "$dir":/data postgres:10.17 /bin/bash +docker run -it -v "$dir":/data postgres:11.20 /bin/bash root@842bfb3da1f1:/# cd /data/SnomedCT_International root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh @@ -42,22 +42,22 @@ root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh # export PGHOST=172.17.0.1 (**make sure to edit this setting before proceeding) export dir=/wci/data/ cd $dir -docker run -it -v "$dir":/data postgres:10.17 /bin/bash +docker run -it -v "$dir":/data postgres:11.20 /bin/bash root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh -##### Postgres 11.12 +##### Postgres 12.15 # # Launch the container # -docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:11.12 +docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:12.15 # WINDOWS git bash (to simulate running in Linux) # export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) dir=C:/data -docker run -it -v "$dir":/data postgres:11.12 /bin/bash +docker run -it -v "$dir":/data postgres:12.15 /bin/bash root@842bfb3da1f1:/# cd /data/SnomedCT_International root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh @@ -66,22 +66,23 @@ root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh # export PGHOST=172.17.0.1 (**make sure to edit this setting before proceeding) export dir=/wci/data/ cd $dir -docker run -it -v "$dir":/data postgres:11.12 /bin/bash +docker run -it -v "$dir":/data postgres:12.15 /bin/bash root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh -##### Postgres 12.7 + +##### Postgres 13.11 # # Launch the container # -docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:12.7 +docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:13.11 # WINDOWS git bash (to simulate running in Linux) # export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) dir=C:/data -docker run -it -v "$dir":/data postgres:12.7 /bin/bash +docker run -it -v "$dir":/data postgres:13.11 /bin/bash root@842bfb3da1f1:/# cd /data/SnomedCT_International root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh @@ -90,23 +91,49 @@ root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh # export PGHOST=172.17.0.1 (**make sure to edit this setting before proceeding) export dir=/wci/data/ cd $dir -docker run -it -v "$dir":/data postgres:12.7 /bin/bash +docker run -it -v "$dir":/data postgres:13.11 /bin/bash root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh -##### Postgres 13.3 +##### Postgres 14.8 +# +# Launch the container +# +docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:14.8 + +# WINDOWS git bash (to simulate running in Linux) +# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) +dir=C:/data +docker run -it -v "$dir":/data postgres:14.8 /bin/bash +root@842bfb3da1f1:/# cd /data/SnomedCT_International +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh + +# LINUX (BUILD SERVER) +# export PGHOST=172.17.0.1 (**make sure to edit this setting before proceeding) +export dir=/wci/data/ +cd $dir +docker run -it -v "$dir":/data postgres:14.8 /bin/bash + +root@842bfb3da1f1:/# cd /data/rf2 +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh +root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh + + + +##### Postgres 15.3 # # Launch the container # -docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:13.3 +docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:15.3 # WINDOWS git bash (to simulate running in Linux) # export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) dir=C:/data -docker run -it -v "$dir":/data postgres:13.3 /bin/bash +docker run -it -v "$dir":/data postgres:15.3 /bin/bash root@842bfb3da1f1:/# cd /data/SnomedCT_International root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh @@ -115,7 +142,7 @@ root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh # export PGHOST=172.17.0.1 (**make sure to edit this setting before proceeding) export dir=/wci/data/ cd $dir -docker run -it -v "$dir":/data postgres:13.3 /bin/bash +docker run -it -v "$dir":/data postgres:15.3 /bin/bash root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh From 1bf51625da77dc04f4bec924e64ecf1ecb55d673 Mon Sep 17 00:00:00 2001 From: Joshua Liu <78755794+enjoylifejyl@users.noreply.github.com> Date: Fri, 4 Aug 2023 16:58:40 -0700 Subject: [PATCH 60/95] Update README-postgres-docker.txt replaced --rm postgress:11.20 with --rm postgres:11.20-alpine. --- src/test/resources/README-postgres-docker.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/README-postgres-docker.txt b/src/test/resources/README-postgres-docker.txt index 5eacfbe..d7a0d91 100644 --- a/src/test/resources/README-postgres-docker.txt +++ b/src/test/resources/README-postgres-docker.txt @@ -28,7 +28,7 @@ sudo chmod +x rf2/populate_postgres_db_tc.sh # # Launch the container # -docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:11.20 +docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:11.20-alpine # WINDOWS git bash (to simulate running in Linux) # export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) From 28b284936a096d7b3dccc7997aa216dabd8c9eee Mon Sep 17 00:00:00 2001 From: Joshua Liu <78755794+enjoylifejyl@users.noreply.github.com> Date: Fri, 4 Aug 2023 17:00:48 -0700 Subject: [PATCH 61/95] Update README-postgres-docker.txt --- src/test/resources/README-postgres-docker.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/README-postgres-docker.txt b/src/test/resources/README-postgres-docker.txt index d7a0d91..e8863e8 100644 --- a/src/test/resources/README-postgres-docker.txt +++ b/src/test/resources/README-postgres-docker.txt @@ -42,7 +42,7 @@ root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh # export PGHOST=172.17.0.1 (**make sure to edit this setting before proceeding) export dir=/wci/data/ cd $dir -docker run -it -v "$dir":/data postgres:11.20 /bin/bash +docker run -it -v "$dir":/data postgres:11.20-alpine /bin/bash root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh From 6584abad12d0b8c105cd9bf78f2066c1e9eee5a8 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Sat, 2 Sep 2023 15:24:46 -0700 Subject: [PATCH 62/95] Update for SNOMEDCT US 20230901 --- pom.xml | 2 +- src/test/resources/README-announcements.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index fcf2232..6411def 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ US - 20230301 + 20230901 National US1000124 diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index bf8bb3d..9ab958a 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -10,10 +10,10 @@ support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #MakingSnomedEasy #snomed https://www.westcoastinformatics.com/products/db-load-scripts --- US Edition March 1: +-- US Edition September 1: Fall is upon us! Announcing #SNOMEDCT DB load and transitive -closure scripts for the 20230301 US Edition! Out-of-the-box +closure scripts for the 20230901 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #MakingSnomedEasy #snomed https://www.westcoastinformatics.com/products/db-load-scripts @@ -26,7 +26,7 @@ See https://westcoastinformatics.com/products/db-load-scripts #MakingTerminolog This freely available solution enables one to load their #SQL database with the latest editions of #SNOMED. ### UMLS Users Mailing List -Subject: 20230301 SNOMEDCT DB load and transitive closure scripts +Subject: 20230901 SNOMEDCT DB load and transitive closure scripts Hi all, From 5bb24acc427be07b946bc0094c54c03280291934 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Wed, 27 Sep 2023 18:33:10 +0100 Subject: [PATCH 63/95] Remove postgres 11 testing, update announcement --- src/test/resources/README-announcements.txt | 2 +- src/test/resources/README-postgres-docker.txt | 24 ------------------- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 9ab958a..4eb96fe 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -52,4 +52,4 @@ This utility is freely available through our website: Feel free to share this announcement with others or retweet the announcement - https://twitter.com/wcinformatics/status/ ! - +https://twitter.com/wcinformatics/status/1707085396663013545 diff --git a/src/test/resources/README-postgres-docker.txt b/src/test/resources/README-postgres-docker.txt index e8863e8..f331e7f 100644 --- a/src/test/resources/README-postgres-docker.txt +++ b/src/test/resources/README-postgres-docker.txt @@ -24,30 +24,6 @@ sudo chmod +x rf2/populate_postgres_db_tc.sh # - https://hub.docker.com/_/postgres # -##### Postgres 11.20 -# -# Launch the container -# -docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:11.20-alpine - -# WINDOWS git bash (to simulate running in Linux) -# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) -dir=C:/data -docker run -it -v "$dir":/data postgres:11.20 /bin/bash -root@842bfb3da1f1:/# cd /data/SnomedCT_International -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh - -# LINUX (BUILD SERVER) -# export PGHOST=172.17.0.1 (**make sure to edit this setting before proceeding) -export dir=/wci/data/ -cd $dir -docker run -it -v "$dir":/data postgres:11.20-alpine /bin/bash - -root@842bfb3da1f1:/# cd /data/rf2 -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh - ##### Postgres 12.15 # # Launch the container From 3d632629d64b8eda799d9e075404cdf66e304139 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Thu, 4 Jan 2024 11:37:58 -0800 Subject: [PATCH 64/95] January 1, 2024 Snomed International Release --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6411def..9fe58d3 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ true - 20230731 + 20240101 Core INT From e9f475f1f6362a1ee9a911f0ff1e045e344b6313 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Thu, 4 Jan 2024 11:38:02 -0800 Subject: [PATCH 65/95] January 1, 2024 Snomed International Release --- README.md | 4 ++-- src/main/resources/LICENSE.txt | 2 +- src/test/resources/README-announcements.txt | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 706534a..dd32930 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,10 @@ https://www.westcoastinformatics.com/products/db-load-scripts Minimum Specification --------------------- -- MYSQL v5.7.+, MySQL v8.+, MariaDB 10.+ +- MYSQL v5.7.+, MySQL v8.+, MariaDB 10.+, MariaDB 11.+ - MySQL v8 requires the server to run with "--local_infile=ON" - Oracle v12.+ -- Postgres v11.+, v12.+, v13.+, v14.+, v15.+ +- Postgres v12.+, v13.+, v14.+, v15.+, v16.+ Installation ------------ diff --git a/src/main/resources/LICENSE.txt b/src/main/resources/LICENSE.txt index 6af66e4..8a3b6d2 100644 --- a/src/main/resources/LICENSE.txt +++ b/src/main/resources/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright 2023 West Coast Informatics, LLC +Copyright 2024 West Coast Informatics, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 4eb96fe..5f4021d 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -2,10 +2,10 @@ ### Twitter, LinkedIn, Facebook --- SNOMED International Jul 31: +-- SNOMED International Jan 1: Is it August already?! Announcing #SNOMEDCT DB load and transitive -closure scripts for the 20230731 International Edition! Out-of-the-box +closure scripts for the 20240101 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #MakingSnomedEasy #snomed https://www.westcoastinformatics.com/products/db-load-scripts @@ -20,17 +20,17 @@ https://www.westcoastinformatics.com/products/db-load-scripts ---- -Is it July already?! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20230701 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +Is it January already?! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20240101 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/products/db-load-scripts #MakingTerminologyEasy #MakingSnomedEasy #snomedct This freely available solution enables one to load their #SQL database with the latest editions of #SNOMED. ### UMLS Users Mailing List -Subject: 20230901 SNOMEDCT DB load and transitive closure scripts +Subject: 20240101 SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the July 31, 2023 update of the SNOMEDCT INT Edition. +NLM recently posted the Jan 01, 2024 update of the SNOMEDCT INT Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. From 9c5daeabcf2c6c1230fb49e9845b78c44e18b548 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Mon, 8 Jan 2024 16:13:12 -0800 Subject: [PATCH 66/95] fix mrcmdomain table load for mysql --- src/main/resources/rf2/mysql_tables.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/rf2/mysql_tables.sql b/src/main/resources/rf2/mysql_tables.sql index 8bfdee4..79af434 100644 --- a/src/main/resources/rf2/mysql_tables.sql +++ b/src/main/resources/rf2/mysql_tables.sql @@ -221,7 +221,7 @@ CREATE TABLE textdefinition ( FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (conceptId) REFERENCES concept(id), FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (caseSignificanceId) REFERENCES concept(id) + FOREIGN KEY (caseSignificanceId) REFERENCES concept(id) ) CHARACTER SET utf8; LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_TextDefinition_Snapshot-en_${editionLabel}_${editionVersion}.txt' INTO TABLE textdefinition LINES TERMINATED BY '\r\n' IGNORE 1 LINES @@ -612,7 +612,7 @@ CREATE TABLE mrcmdomain ( FOREIGN KEY (refsetId) REFERENCES concept(id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_cissccRefset_MRCMAttributeDomainSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE mrcmdomain LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_sssssssRefset_MRCMDomainSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE mrcmdomain LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@domainConstraint,@parentDomain,@proximalPrimitiveConstraint,@proximalPrimitiveRefinement,@domainTemplateForPrecoordination,@domainTemplateForPostcoordination,@guideURL) SET id = @id, effectiveTime = @effectiveTime, From 6939f58987d63bea08d8112560515a050785877b Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Mon, 8 Jan 2024 16:13:33 -0800 Subject: [PATCH 67/95] make mysql consistent --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dd32930..f5cdf4a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ https://www.westcoastinformatics.com/products/db-load-scripts Minimum Specification --------------------- -- MYSQL v5.7.+, MySQL v8.+, MariaDB 10.+, MariaDB 11.+ +- MySQL v5.7.+, MySQL v8.+, MariaDB 10.+, MariaDB 11.+ - MySQL v8 requires the server to run with "--local_infile=ON" - Oracle v12.+ - Postgres v12.+, v13.+, v14.+, v15.+, v16.+ From 3df9d4866eb14b07d4d24f7d1a46303dd0a8e1e6 Mon Sep 17 00:00:00 2001 From: Alicia G <32443614+gaaliciA1990@users.noreply.github.com> Date: Wed, 6 Mar 2024 14:13:42 -0800 Subject: [PATCH 68/95] Update the Load Scripts (#1) --- .gitignore | 5 + README.md | 27 +- pom.xml | 2 +- src/main/assembly/tc.xml | 39 + src/main/resources/HOWTO.md | 42 ++ src/main/resources/HOWTO.txt | 45 -- src/main/resources/{README.txt => README.md} | 14 +- .../rf2/compute_transitive_closure.pl | 313 ++++++++ .../rf2/compute_transitive_closure.py | 268 +++++++ src/main/resources/rf2/mysql_tables.sql | 618 ++++++++------- src/main/resources/rf2/mysql_views.sql | 12 + src/main/resources/rf2/oracle_tables.sql | 600 +++++++-------- src/main/resources/rf2/oracle_views.sql | 551 ++++++++------ src/main/resources/rf2/populate_mysql_db.bat | 51 -- src/main/resources/rf2/populate_mysql_db.sh | 60 +- src/main/resources/rf2/populate_oracle_db.bat | 163 ---- src/main/resources/rf2/populate_oracle_db.sh | 94 ++- .../resources/rf2/populate_postgres_db.bat | 54 -- .../resources/rf2/populate_postgres_db.sh | 44 +- src/main/resources/rf2/psql_tables.sql | 15 +- src/main/resources/rf2/psql_views.sql | 707 +++++++++++------- src/main/resources/rf2/transitiveclosure.ctl | 16 + src/test/resources/README-announcements.txt | 10 +- ...-check-files.txt => README-check-files.md} | 19 +- src/test/resources/README-mysql-docker.md | 63 ++ src/test/resources/README-mysql-docker.txt | 101 --- src/test/resources/README-oracle-docker.md | 68 ++ src/test/resources/README-oracle-docker.txt | 88 --- src/test/resources/README-postgres-docker.md | 72 ++ src/test/resources/README-postgres-docker.txt | 125 ---- 30 files changed, 2485 insertions(+), 1801 deletions(-) create mode 100644 src/main/assembly/tc.xml create mode 100644 src/main/resources/HOWTO.md delete mode 100644 src/main/resources/HOWTO.txt rename src/main/resources/{README.txt => README.md} (63%) create mode 100644 src/main/resources/rf2/compute_transitive_closure.pl create mode 100644 src/main/resources/rf2/compute_transitive_closure.py delete mode 100644 src/main/resources/rf2/populate_mysql_db.bat delete mode 100644 src/main/resources/rf2/populate_oracle_db.bat delete mode 100644 src/main/resources/rf2/populate_postgres_db.bat create mode 100644 src/main/resources/rf2/transitiveclosure.ctl rename src/test/resources/{README-check-files.txt => README-check-files.md} (73%) create mode 100644 src/test/resources/README-mysql-docker.md delete mode 100644 src/test/resources/README-mysql-docker.txt create mode 100644 src/test/resources/README-oracle-docker.md delete mode 100644 src/test/resources/README-oracle-docker.txt create mode 100644 src/test/resources/README-postgres-docker.md delete mode 100644 src/test/resources/README-postgres-docker.txt diff --git a/.gitignore b/.gitignore index e39c14a..818c15f 100644 --- a/.gitignore +++ b/.gitignore @@ -214,3 +214,8 @@ pip-log.txt #Mr Developer .mr.developer.cfg /target + +################# +## IntelliJ +################# +.idea \ No newline at end of file diff --git a/README.md b/README.md index f5cdf4a..8069108 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,39 @@ SNOMED CT DATABASE LOAD SCRIPTS =============================== -Scripts to create and populate a MySQL, Postgres, or Oracle database with a -SNOMED CT terminology release in RF2. +Scripts to build a transitive closure table from an RF2, snapshot, +inferred SNOMED CT relationships file, create and populate a MySQL, +Postgres, or Oracle database with a SNOMED CT terminology release in RF2. To download a package built for the latest US or International edition, visit https://www.westcoastinformatics.com/products/db-load-scripts +*New feature: a "depth" flag is now computed as well where 0 means "self", +1 means "child", and >1 means "non-child descendant". This enables asking +queries about "child of", "descendant of", and "descendant or self of". + Minimum Specification --------------------- -- MySQL v5.7.+, MySQL v8.+, MariaDB 10.+, MariaDB 11.+ +- MySQL v8.+, MariaDB 10.+, MariaDB 11.+ - MySQL v8 requires the server to run with "--local_infile=ON" - Oracle v12.+ -- Postgres v12.+, v13.+, v14.+, v15.+, v16.+ +- Postgres v13.+, v14.+, v15.+, v16.+ + +Prerequisites +------------- +If loading transitive closure table into a database, first load SNOMED in RF2 +using the database load scripts you can also find at the URL above. This is +important because it creates a view that allows for denormalization of preferred +concept names, thus making the transitive closure table more useful. Installation ------------ -* See [HOWTO.txt](src/main/resources/HOWTO.txt) file to understand how to load the rf2 files into the database - +* See [HOWTO.md](src/main/resources/HOWTO.md) file to understand how to load the rf2 files into the database See Also -------- * [src/main/resources/LICENSE.txt](src/main/resources/LICENSE.txt) -* [src/main/resources/README.txt](src/main/resources/README.txt) -* [src/main/resources/HOWTO.txt](src/main/resources/HOWTO.txt) +* [src/main/resources/README.md](src/main/resources/README.md) +* [src/main/resources/HOWTO.md](src/main/resources/HOWTO.md) TODO ---- diff --git a/pom.xml b/pom.xml index 9fe58d3..3ae5e66 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ US - 20230901 + 20240301 National US1000124 diff --git a/src/main/assembly/tc.xml b/src/main/assembly/tc.xml new file mode 100644 index 0000000..683dc1f --- /dev/null +++ b/src/main/assembly/tc.xml @@ -0,0 +1,39 @@ + + tc + / + + zip + + + + src/main/resources + / + + rf1/** + **/*mysql* + **/*oracle* + **/*.ctl + + true + keep + + + + + + target/classes + /rf2 + + **/*class + + false + + + src/main/java + /rf2 + + + diff --git a/src/main/resources/HOWTO.md b/src/main/resources/HOWTO.md new file mode 100644 index 0000000..efec336 --- /dev/null +++ b/src/main/resources/HOWTO.md @@ -0,0 +1,42 @@ +# How To Use the SNOMED CT Database Loader +This HOWTO describes how to use the installer scripts to load SNOMEDCT into a database. + +## Installation +1. Download the database loader zip file from the https://www.westcoastinformatics.com/products/db-load-scripts website. Select the appropriate database-version pair (i.e. oracle-US Edition). Depending on your database and edition, identify the appropriate target's zip file. + +2. Unzip the contents of the zip file into a 'data' folder + +3. Download the SNOMED CT Release files in ZIP format. US Users can find the files here: + * [SNOMED CT® US Edition Release Files](https://www.nlm.nih.gov/healthit/snomedct/us_edition.html) + * [SNOMED CT® International Edition Release Files](https://www.nlm.nih.gov/healthit/snomedct/international.html) + +4. Open the desired zip file and extract the 'Snapshot' folder into the 'data/rf2' folder. Once completed: + * The 'data' folder's content will include: + - 'rf2' folder + - HOWTO.md + - LICENSE.txt + - README.md + * The 'data/rf2' folder's contents will include: + - 'Snapshot' folder + - *.sql files + - *.ctl files (for oracle only) + - one *.sh file + +5. In a text editor, open the temp-folder's appropriate "populate" script as defined by your database. + * For example: + - For MySQL (or MariaDB), use the "populate_mysql_db.sh" script + - For Postgres, use the "populate_postgres_db.sh" script + - For Oracle, use the "populate_oracle_db.sh" script + * Configure settings at the top of the "populate" script for your environment + - use your host's IP address or hostname + - user is your database's username + - password is your database's password + - tns_name or db_name is the database's schema which is to be populated + +6. Create the database schema as defined in step #5 + + * NOTE: postgres supports only db-level character encoding, so make sure to create your database using: `WITH ENCODING 'UTF-8'` + + +7. Execute the "populate" script + * Note: a complete log file will appear as `mysql.log`, `postgres.log`, or `oracle.log` diff --git a/src/main/resources/HOWTO.txt b/src/main/resources/HOWTO.txt deleted file mode 100644 index cdcd226..0000000 --- a/src/main/resources/HOWTO.txt +++ /dev/null @@ -1,45 +0,0 @@ -This HOWTO describes how to use the installer scripts to load SNOMED into a database. - -Installation ------------- -1. Download the database loader zip file from the http://www.westcoastinformatics.com/resources.html website. Select the appropriate database-version pair (i.e. oracle-US Edition). Depending on your database and edition, identify the appropriate target's zip file. - -2. Unzip the contents of the zip file into a 'data' folder - -3. Download the SNOMED CT Release files in ZIP format. US Users can find the files here: - * SNOMED CT® US Edition Release Files: https://www.nlm.nih.gov/healthit/snomedct/us_edition.html - * SNOMED CT® International Edition Release Files: https://www.nlm.nih.gov/healthit/snomedct/international.html - -4. Open the desired zip file and extract the 'Snapshot' folder into the 'data/rf2' folder. Once completed: - * The 'data' folder's content will include: - - 'rf2' folder - - HOWTO.txt - - LICENSE.txt - - README.txt - * The 'data/rf2' folder's contents will include: - - 'Snapshot' folder - - *.sql files - - *.ctl files (for oracle only) - - one *.bat file - - one *.sh file - -5. In a text editor, open the temp-folder's appropriate "populate" script in a text editor as defined by your platform and database. - * For example: - - For MySQL (or MariadB) on Windows, use the "populate_mysql_db.bat" script - - For Postgres on Windows, use the "populate_postgres_db.bat" script - - For Oracle on Windows, use the "populate_oracle_db.bat" script - - For MySQL (or MariaDB) on Linux/Unix/MacOS, use the "populate_mysql_db.sh" script - - For Postgres on Linux/Unix/MacOS, use the "populate_postgres_db.sh" script - - For Oracle on Linux/Unix/MacOS, use the "populate_oracle_db.sh" script - * Configure settings at the top of the "populate" script for your environment - - user is your database's username - - password is your database's password - - tns_name or db_name is the database's schema which is to be populated - -6. Create the database schema as defined in step #5 - - * NOTE: postgres supports only db-level character encoding, so make sure to create your database using: WITH ENCODING 'UTF-8' - - -7. Execute the "populate" script - * Note: a complete log file will appear as "mysql.log", "postgres.log", or "oracle.log" diff --git a/src/main/resources/README.txt b/src/main/resources/README.md similarity index 63% rename from src/main/resources/README.txt rename to src/main/resources/README.md index f57052c..cad555c 100644 --- a/src/main/resources/README.txt +++ b/src/main/resources/README.md @@ -1,20 +1,20 @@ +# Welcome to DB Load Scripts Welcome to SNOMED CT MySQL, Postgres, and Oracle Database Load Scripts https://www.westcoastinformatics.com/products/db-load-scripts Go to the above link for documentation, and additional downloads. -Important Notes ---------------- +## Important Notes * These database load scripts are configured to work with the ${editionVersion} SNOMEDCT ${editionLabel} Edition. -Key Features ------------- +## Key Features * Support for Oracle, Postgres, and MySQL (and MariaDB) * Support for RF2 data format * Denormalization of concept/description ids for contextualized lookup +* Builds transitive closure table from RF2 snapshot, inferred, SNOMEDCT file. +* Views with denormalized concept preferred names -Developer Notes ---------------- -https://github.com/bcarlsenca/SNOMED-DB-Load-Scripts.git +### Developer Notes +https://github.com/WestCoastInformatics/SNOMED-DB-Load-Scripts diff --git a/src/main/resources/rf2/compute_transitive_closure.pl b/src/main/resources/rf2/compute_transitive_closure.pl new file mode 100644 index 0000000..195db15 --- /dev/null +++ b/src/main/resources/rf2/compute_transitive_closure.pl @@ -0,0 +1,313 @@ +#!/usr/bin/perl +# Copyright 2024 West Coast Informatics, Inc +# +# Computes transitive closure from a snapshot inferred RF2 relationships file. +# +use strict vars; + +# +# Set Defaults & Environment +# +our $badargs; +our $badvalue; +our $isaRel = "116680003"; +our $root = "138875005"; +our $history = ""; +our $force = 0; +our $self = 1; + +# +# Check options +# +our @ARGS=(); +while (@ARGV) { + my $arg = shift(@ARGV); + if ($arg !~ /^-/) { + push @ARGS, $arg; + next; + } + if ($arg eq "--history-min") { + $history = "min"; + next; + } elsif ($arg eq "--history-mod") { + $history = "mod"; + next; + } elsif ($arg eq "--history-max") { + $history = "max"; + next; + } elsif ($arg eq "--noself") { + $self = 0; + next; + } elsif ($arg eq "--force") { + $force = 1; + next; + } elsif ($arg eq "--help") { + &PrintHelp; + exit(0); + } else { + $badargs = 1; + $badvalue = $arg; + } +} + +# +# Handle parameters +# +if (scalar(@ARGS) != 1) { + $badargs = 3; + $badvalue = scalar(@ARGS); +} +our ($relsFile) = @ARGS; +our $outputFile = "$relsFile"; +$outputFile =~ s/_Relationship_/_TransitiveClosure_/; + +# Check output file +if (-e "$outputFile") { + if ($force) { + unlink $outputFile; + } else { + die "Output file already exists: $outputFile. Check this is not an old file\n"; + } +} + +# Check history file +our $historyFile = ""; +if ($history) { + # Attempt to find the Association refset + $historyFile = "$relsFile"; + $historyFile =~ s/sct2_Relationship_/der2_cRefset_Association/; + if ($historyFile =~ /^der2/) { + $historyFile =~ s/^/..\/Refset\/Content\//; + } elsif ($historyFile =~ /Terminology/) { + $historyFile =~ s/Terminology/Refset\/Content/; + } else { + die "Unable to determine path to Association refset file from relationships file = $relsFile\n"; + } + if (! -e $historyFile) { + die "Computed path to Association refset file does not exist = $historyFile\n"; + } +} + + +# +# Write any arg errors +# +our %errors = (1 => "Illegal switch: $badvalue", + 2 => "Illegal service: $badvalue", + 3 => "Bad number of arguments: $badvalue", + 4 => "$badvalue must be set"); +if ($badargs) { + &PrintUsage; + print "\n$errors{$badargs}\n"; + exit(1); +} + +# +# Begin +# +print "------------------------------------------------------------\n"; +print "Starting ...", scalar(localtime),"\n"; +print "------------------------------------------------------------\n"; +print "Isa rel : $isaRel\n"; +print "Rels file : $relsFile\n"; +print "Self : $self\n"; +print "Output file : $outputFile\n"; +if ($history) { + print "History : $history\n"; + print "History file : $historyFile\n"; +} +print "\n"; + +# +# Load PAR/CHD relationships map. +# +print " Load PAR/CHD rels ...".(scalar(localtime))."\n"; +our %codes = (); +our %parChd = (); +our %seen = (); +our $eol = "\n"; +initRelationships($relsFile, $historyFile); + +# +# Write transitive closure file +# +print " Write transitive closure table ...".(scalar(localtime))."\n"; +our $OUT; +open ($OUT, ">$outputFile") || die "Could not open $outputFile: $! $?\n"; +print $OUT "superTypeId\tsubTypeId\tdepth$eol"; +our $code; +our $ct = 0; +foreach $code (keys %codes) { + # skip root + next if $code eq $root; + $ct++; + + # short circuit for leaf nodes + if (!$parChd{$code} && $self) { + print $OUT "$code\t$code\t0$eol"; + } + + # otherwise, gather descendants + else { + %seen = (); + my %descs = getDescendants($code, 1); + my $desc; + foreach $desc (keys %descs) { + if (!$self && !($descs{$desc}-1)) { + next; + } + print $OUT "$code\t$desc\t".($descs{$desc}-1)."$eol"; + } + } + + if ($ct % 10000 == 0) { + print " $ct codes processed ...", scalar(localtime),"\n"; + } +} +close($OUT); + +# +# Finish +# +print "------------------------------------------------------------\n"; +print "finished ...", scalar(localtime),"\n"; +print "------------------------------------------------------------\n"; + +exit 0; + + +######################### LOCAL PROCEDURES ####################### + +# +# Print the usage +# +sub PrintUsage { + + print qq{ +Usage: compute-transitive-closure.pl [--help] [--force] [--history-{min,mod,max}] + e.g. compute-transitive-closure.pl --history-min --noself +}; +} + +# +# Print help info +# +sub PrintHelp { + &PrintUsage; + print qq{ + Parameters + relsFile: A snapshot inferred RF2 relationships file + Options: + --force : If output file already exists, remove it and proceed + --history-min: Add historical relationships to support ECL HISTORY-MIN profile + --history-mod: Add historical relationships to support ECL HISTORY-MOD profile + --history-max: Add historical relationships to support ECL HISTORY-MAX profile + --help: On-line help + +}; +} + +# +# Initialize relationships hashes +# +sub initRelationships { + my($relsFile, $historyFile) = @_; + my $IN; + open ($IN, "<$relsFile") || die "Failed to open $relsFile: $! $?\n"; + my $ct = 1; + # iterate through rels file + while (<$IN>) { + chop; + if (/\r$/) { + s/\r//; + $eol = "\r\n"; + } + my ($id, $effectiveTime, $active, $moduleId, $sourceId, $destinationId, + $relationshipGroup, $typeId, $characteristicTypeId, $modifierId) = split /\t/; + + # skip inactive or non-isa rels + next unless $typeId eq $isaRel; + next unless $active; + $ct++; + + # push new child for parent + push @{$parChd{$destinationId}}, $sourceId; + $codes{$sourceId} = 1; + $codes{$destinationId} = 1; + } + print " $ct relationships loaded\n"; + close($IN); + + # Load appropriate history relationships + if ($history) { + + $ct = 0; + our %qual = (); + if ($history eq "min") { + $qual{"900000000000527005"} = 1; + } elsif ($history eq "mod") { + $qual{"900000000000527005"} = 1; + $qual{"900000000000526001"} = 1; + $qual{"900000000000528000"} = 1; + $qual{"1186924009"} = 1; + } + open ($IN, "<$historyFile") || die "Failed to open $historyFile: $! $?\n"; + my $ct = 0; + # iterate through history file + while (<$IN>) { + chop; s/\r//; + + my ($id, $effectiveTime, $active, $moduleId, $refsetId, + $referencedComponentId, $targetComponentId) = split /\t/; + + # skip unless the refsetId represents a qualifying historical association + next unless $history eq "max" || $qual{$refsetId}; + # skip inactive + next unless $active; + # skip if the targetComponentId isn't one of the codes (to avoid moved_to/from stuff) + next unless $codes{$targetComponentId}; + + $ct++; + + # push new child (inactive concept) for parent (active concept) + push @{$parChd{$targetComponentId}}, $referencedComponentId; + $codes{$referencedComponentId} = 1; + } + print " $ct historical relationships loaded\n"; + close($IN); + } +} + +# +# Get descendants of a root +# Input: root id +# Output: array of descendant ids +# +sub getDescendants { + my($par, $depth) = @_; + + # if we've seen this node already, children are accounted for - bail + if ($seen{$par}) { return (); } + $seen{$par} = 1; + + # Add an entry for this concept + my %descendants = (); + $descendants{$par} = $depth; + + # Get Children of this node + my @chd = @{$parChd{$par}}; + + # If this is a leaf node, bail + return %descendants if scalar(@chd) == 0; + + # Iterate through children, mark as descendant and recursively call + foreach my $chd (@chd) { + my %chddesc = getDescendants($chd, $depth+1); + # merge child descendants with the current descendants list. + foreach my $desc ( keys %chddesc) { + $descendants{"$desc"} = $chddesc{$desc}; + } + } + + return %descendants; +} \ No newline at end of file diff --git a/src/main/resources/rf2/compute_transitive_closure.py b/src/main/resources/rf2/compute_transitive_closure.py new file mode 100644 index 0000000..e511bc1 --- /dev/null +++ b/src/main/resources/rf2/compute_transitive_closure.py @@ -0,0 +1,268 @@ +#!/usr/bin/python +# Copyright 2024 West Coast Informatics, Inc +# +# Computes transitive closure from a snapshot inferred RF2 relationships file. +# + +import sys +import os +import csv +import glob +import argparse +import time +import logging + +# +# Set Defaults & Environment +# +isaRel = "116680003" +root = "138875005" +history = "" +force = False +self = True +codes = {} +parChd = {} +seen = {} + +# Set up logging +logging.basicConfig(level=logging.DEBUG) + +# Define the errors dictionary globally +errors = { + 1: "Illegal switch: ", + 2: "Illegal service: ", + 3: "Bad number of arguments: ", + 4: "{} must be set" +} + +## Custom help action for handling --help argparse option +class HelpAction(argparse.Action): + def __init__(self, option_strings, dest, nargs=0, **kwargs): + super(HelpAction, self).__init__(option_strings, dest, nargs=nargs, **kwargs) + + def __call__(self, parser, namespace, values, option_string=None): + print_help() + parser.exit() + +## Function to parse arguments +def parse_args(): + parser = argparse.ArgumentParser(add_help=False) + parser.add_argument('--history', choices=['min', 'mod', 'max']) + parser.add_argument('--force', action='store_true') + parser.add_argument('--noself', action='store_true') + parser.add_argument('relsFile') + parser.add_argument('--help', action=HelpAction) # Add the custom --help option + + try: + args = parser.parse_args() + except SystemExit: + badargs = errors[3] + print(badargs + args) + exit(1) + + # Check if the arguments are valid + if not args.relsFile: # Check if relsFile is provided + badargs = errors[4].format("relsFile") + elif args.history and args.history not in ['min', 'mod', 'max']: # Check if history is one of the allowed values + badargs = errors[1] + args.history + else: + badargs = None + + # Check for argument errors + if badargs: + print_usage() + print("\n{}".format(badargs)) + exit(1) + + return parser.parse_args() + +## Function to initialize relationships +def initRelationships(relsFile, historyFile): + global codes, parChd + try: + # Read relationships + with open(relsFile, 'r') as f: + reader = csv.reader(f, delimiter='\t') + ct = 1 + # iterate through rels file + for row in reader: + id, effectiveTime, active, moduleId, sourceId, destinationId, relationshipGroup, typeId, characteristicTypeId, modifierId = row + # skip inactive or non-isa relationships + if typeId != isaRel or not active: + continue + ct += 1 + + # push new child for parent + if destinationId not in parChd: + parChd[destinationId] = [] + parChd[destinationId].append(sourceId) + codes[sourceId] = 1 + codes[destinationId] = 1 + pass + except IOError as e: + logging.error("Failed to open {}: {}".format(relsFile, e)) + exit(1) + + # Load appropriate history relationships + if history: + ct = 0 + qual = {} + if history == "min": + qual = {"900000000000527005": 1} + elif history == "mod": + qual = {"900000000000527005": 1, "900000000000526001": 1, "900000000000528000": 1, "1186924009": 1} + + with open(historyFile, 'r') as IN: + for line in IN: + line = line.rstrip('\r\n') + + id, effectiveTime, active, moduleId, refsetId, referencedComponentId, targetComponentId = line.split('\t') + + # skip unless the refsetId represents a qualifying historical association + if not (history == "max" or refsetId in qual): + continue + # skip inactive + if not active: + continue + # skip if the targetComponentId isn't one of the codes (to avoid moved_to/from stuff) + if targetComponentId not in codes: + continue + + ct += 1 + + # push new child (inactive concept) for parent (active concept) + if targetComponentId not in parChd: + parChd[targetComponentId] = [] + parChd[targetComponentId].append(referencedComponentId) + codes[referencedComponentId] = 1 + + logging.info(" {} historical relationships loaded".format(ct)) + + + +## Function to get descendants +def getDescendants(par, depth): + global seen + # If parent has been seen, return empty dictionary + if par in seen: + return {} + + seen[par] = 1 + descendants = {par: depth} + + # If parent has children, get their descendants + if par in parChd: + for chd in parChd[par]: + descendants.update(getDescendants(chd, depth+1)) + return descendants + +## Function to print help +def print_help(parser=None, namespace=None, values=None, option_strings=None, dest=None): + print_usage() + + help_text = """ + Parameters: + relsFile: A snapshot inferred RF2 relationships file + Options: + --force: If output file already exists, remove it and proceed + --history-{min,mod,max}: Add historical relationships to support ECL HISTORY-{MIN,MOD,MAX} profile + --help: On-line help + """ + print(help_text) + sys.exit(0) # Exit the program + +## Function to print usage +def print_usage(): + print(""" +Usage: compute_transitive_closure.py [--help] [--force] [--history-{min,mod,max}] + e.g. compute_transitive_closure.py --history-min --noself +""") + +## Main function +def main(): + global badargs, ct + args = parse_args() + force = args.force + self = not args.noself + relsFile = args.relsFile + history = args.history + outputFile = relsFile.replace("_Relationship_", "_TransitiveClosure_") + # initialize ct + ct = 0 + + # Check history file + historyFile = "" + if history: + # Attempt to find the Association refset + historyFile = relsFile.replace("sct2_Relationship_", "der2_cRefset_Association") + if historyFile.startswith("der2"): + historyFile = "../Refset/Content/" + historyFile + elif "Terminology" in historyFile: + historyFile = historyFile.replace("Terminology", "Refset/Content") + else: + raise Exception("Unable to determine path to Association refset file from relationships file = {}".format(relsFile)) + if not os.path.exists(historyFile): + raise Exception("Computed path to Association refset file does not exist = {}".format(historyFile)) + + # Check if output file already exists + if os.path.exists(outputFile): + if force: + os.remove(outputFile) + else: + logging.warning("Output file already exists: {}".format(outputFile)) + exit(1) + + # Start processing + print("------------------------------------------------------------") + print("Starting ...", time.asctime()) + print("------------------------------------------------------------") + print("Isa rel : ", isaRel) + print("Rels file : ", relsFile) + print("Self : ", self) + print("Output file : ", outputFile) + if history: + print("History : ", history) + print("History file : ", historyFile) + print("\n") + + # Load PAR/CHD relationships map + print(" Load PAR/CHD rels ...", time.asctime()) + global codes, parChd, seen + codes = {} + parChd = {} + seen = {} + # Initialize relationships + initRelationships(relsFile, "") + + # Write transitive closure to output file + print(" Write transitive closure table ...", time.asctime()) + with open(outputFile, 'w') as f: + writer = csv.writer(f, delimiter='\t') + writer.writerow(["superTypeId", "subTypeId", "depth"]) + for code in codes.keys(): + # skip root + if code == root: + ct += 1 + continue + # short circuit for leaf nodes + if code not in parChd and self: + writer.writerow([code, code, 0]) + # gather descendants + else: + descendants = getDescendants(code, 1) + for desc, depth in descendants.items(): + if not self and not (depth-1): + continue + writer.writerow([code, desc, depth-1]) + + if ct % 10000 == 0: + logging.info(" {} codes processed ...".format(ct), time.asctime()) + + print("------------------------------------------------------------") + print("finished ...", time.asctime()) + print("------------------------------------------------------------\n") + + +## Run main function +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/src/main/resources/rf2/mysql_tables.sql b/src/main/resources/rf2/mysql_tables.sql index 79af434..525577c 100644 --- a/src/main/resources/rf2/mysql_tables.sql +++ b/src/main/resources/rf2/mysql_tables.sql @@ -7,17 +7,19 @@ SET FOREIGN_KEY_CHECKS = 0; -- Concept file. DROP TABLE IF EXISTS concept; -CREATE TABLE concept ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, +CREATE TABLE concept +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, definitionStatusId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (definitionStatusId) REFERENCES concept(id) + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (definitionStatusId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_Concept_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE concept LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Terminology/sct2_Concept_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE concept LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@definitionStatusId) SET id = @id, effectiveTime = @effectiveTime, @@ -28,23 +30,25 @@ definitionStatusId = @definitionStatusId; -- Description file. DROP TABLE IF EXISTS description; -CREATE TABLE description ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - conceptId NUMERIC(20) NOT NULL, - languageCode CHAR(2) NOT NULL, - typeId NUMERIC(20) NOT NULL, - term VARCHAR(255) NOT NULL, - caseSignificanceId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (conceptId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (caseSignificanceId) REFERENCES concept(id) +CREATE TABLE description +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + conceptId NUMERIC(20) NOT NULL, + languageCode CHAR(2) NOT NULL, + typeId NUMERIC(20) NOT NULL, + term VARCHAR(255) NOT NULL, + caseSignificanceId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (conceptId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (caseSignificanceId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_Description_Snapshot-en_${editionLabel}_${editionVersion}.txt' INTO TABLE description LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Terminology/sct2_Description_Snapshot-en_${editionLabel}_${editionVersion}.txt' INTO TABLE description LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@conceptId,@languageCode,@typeId,@term,@caseSignificanceId) SET id = @id, effectiveTime = @effectiveTime, @@ -59,17 +63,19 @@ caseSignificanceId=@caseSignificanceId; -- Identifier file. DROP TABLE IF EXISTS identifier; -CREATE TABLE identifier ( - identifierSchemeId NUMERIC(20) NOT NULL, - alternateIdentifier VARCHAR(255) NOT NULL, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - referencedComponentId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id) +CREATE TABLE identifier +( + identifierSchemeId NUMERIC(20) NOT NULL, + alternateIdentifier VARCHAR(255) NOT NULL, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_Identifier_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE identifier LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Terminology/sct2_Identifier_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE identifier LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@identifierSchemeId,@alternateIdentifier,@effectiveTime,@active,@moduleId,@referencedComponentId) SET identifierSchemeId = @identifierSchemeId, alternateIdentifier = @alternateIdentifier, @@ -81,26 +87,28 @@ referencedComponentId = @referencedComponentId; -- Relationship file. DROP TABLE IF EXISTS relationship; -CREATE TABLE relationship ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - sourceId NUMERIC(20) NOT NULL, - destinationId NUMERIC(20) NOT NULL, - relationshipGroup INT UNSIGNED NOT NULL, - typeId NUMERIC(20) NOT NULL, +CREATE TABLE relationship +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + destinationId NUMERIC(20) NOT NULL, + relationshipGroup INT UNSIGNED NOT NULL, + typeId NUMERIC(20) NOT NULL, characteristicTypeId NUMERIC(20) NOT NULL, - modifierId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (sourceId) REFERENCES concept(id), - FOREIGN KEY (destinationId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (characteristicTypeId) REFERENCES concept(id), - FOREIGN KEY (modifierId) REFERENCES concept(id) + modifierId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (sourceId) REFERENCES concept (id), + FOREIGN KEY (destinationId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (characteristicTypeId) REFERENCES concept (id), + FOREIGN KEY (modifierId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_Relationship_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE relationship LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Terminology/sct2_Relationship_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE relationship LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@sourceId,@destinationId,@relationshipGroup,@typeId,@characteristicTypeId,@modifierId) SET id = @id, effectiveTime = @effectiveTime, @@ -115,25 +123,27 @@ modifierId = @modifierId; -- Relationship concrete values file. DROP TABLE IF EXISTS relationshipconcretevalues; -CREATE TABLE relationshipconcretevalues ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - sourceId NUMERIC(20) NOT NULL, - value VARCHAR(256) NOT NULL, - relationshipGroup INT UNSIGNED NOT NULL, - typeId NUMERIC(20) NOT NULL, - characteristicTypeId NUMERIC(20) NOT NULL, - modifierId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (sourceId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (characteristicTypeId) REFERENCES concept(id), - FOREIGN KEY (modifierId) REFERENCES concept(id) +CREATE TABLE relationshipconcretevalues +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + value VARCHAR(256) NOT NULL, + relationshipGroup INT UNSIGNED NOT NULL, + typeId NUMERIC(20) NOT NULL, + characteristicTypeId NUMERIC(20) NOT NULL, + modifierId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (sourceId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (characteristicTypeId) REFERENCES concept (id), + FOREIGN KEY (modifierId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_RelationshipConcreteValues_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE relationshipconcretevalues LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Terminology/sct2_RelationshipConcreteValues_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE relationshipconcretevalues LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@sourceId,@value,@relationshipGroup,@typeId,@characteristicTypeId,@modifierId) SET id = @id, effectiveTime = @effectiveTime, @@ -148,20 +158,22 @@ modifierId = @modifierId; -- OWL Expression file. DROP TABLE IF EXISTS owlexpression; -CREATE TABLE owlexpression ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE owlexpression +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - owlExpression TEXT NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (referencedComponentId) REFERENCES concept(id) + owlExpression TEXT NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (referencedComponentId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_sRefset_OWLExpressionSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE owlexpression LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Terminology/sct2_sRefset_OWLExpressionSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE owlexpression LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@owlExpression) SET id = @id, effectiveTime = @effectiveTime, @@ -174,26 +186,28 @@ owlExpression = @owlExpression; -- Stated Relationship file. DROP TABLE IF EXISTS statedrelationship; -CREATE TABLE statedrelationship ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - sourceId NUMERIC(20) NOT NULL, - destinationId NUMERIC(20) NOT NULL, - relationshipGroup INT UNSIGNED NOT NULL, - typeId NUMERIC(20) NOT NULL, +CREATE TABLE statedrelationship +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + destinationId NUMERIC(20) NOT NULL, + relationshipGroup INT UNSIGNED NOT NULL, + typeId NUMERIC(20) NOT NULL, characteristicTypeId NUMERIC(20) NOT NULL, - modifierId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (sourceId) REFERENCES concept(id), - FOREIGN KEY (destinationId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (characteristicTypeId) REFERENCES concept(id), - FOREIGN KEY (modifierId) REFERENCES concept(id) + modifierId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (sourceId) REFERENCES concept (id), + FOREIGN KEY (destinationId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (characteristicTypeId) REFERENCES concept (id), + FOREIGN KEY (modifierId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_StatedRelationship_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE statedrelationship LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Terminology/sct2_StatedRelationship_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE statedrelationship LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@sourceId,@destinationId,@relationshipGroup,@typeId,@characteristicTypeId,@modifierId) SET id = @id, effectiveTime = @effectiveTime, @@ -208,23 +222,25 @@ modifierId = @modifierId; -- Text Definition file. DROP TABLE IF EXISTS textdefinition; -CREATE TABLE textdefinition ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - conceptId NUMERIC(20) NOT NULL, - languageCode CHAR(2) NOT NULL, - typeId NUMERIC(20) NOT NULL, - term VARCHAR(2048) NOT NULL, - caseSignificanceId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (conceptId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (caseSignificanceId) REFERENCES concept(id) +CREATE TABLE textdefinition +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + conceptId NUMERIC(20) NOT NULL, + languageCode CHAR(2) NOT NULL, + typeId NUMERIC(20) NOT NULL, + term VARCHAR(2048) NOT NULL, + caseSignificanceId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (conceptId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (caseSignificanceId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_TextDefinition_Snapshot-en_${editionLabel}_${editionVersion}.txt' INTO TABLE textdefinition LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Terminology/sct2_TextDefinition_Snapshot-en_${editionLabel}_${editionVersion}.txt' INTO TABLE textdefinition LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@conceptId,@languageCode,@typeId,@term,@caseSignificanceId) SET id = @id, effectiveTime = @effectiveTime, @@ -239,20 +255,22 @@ caseSignificanceId = @caseSignificanceId; -- Association Reference refset file. DROP TABLE IF EXISTS association; -CREATE TABLE association ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE association +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - targetComponent NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (targetComponent) REFERENCES concept(id) + targetComponent NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (targetComponent) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Content/der2_cRefset_AssociationSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE association LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Content/der2_cRefset_AssociationSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE association LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@targetComponent) SET id = @id, effectiveTime = @effectiveTime, @@ -265,20 +283,22 @@ targetComponent = @targetComponent; -- Attribute Value refset file. DROP TABLE IF EXISTS attributevalue; -CREATE TABLE attributevalue ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE attributevalue +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - valueId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (valueId) REFERENCES concept(id) + valueId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (valueId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Content/der2_cRefset_AttributeValueSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE attributevalue LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Content/der2_cRefset_AttributeValueSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE attributevalue LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@valueId) SET id = @id, effectiveTime = @effectiveTime, @@ -291,18 +311,20 @@ valueId = @valueId; -- Simple refset file. DROP TABLE IF EXISTS simple; -CREATE TABLE simple ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE simple +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Content/der2_Refset_SimpleSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE simple LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Content/der2_Refset_SimpleSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE simple LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId) SET id = @id, effectiveTime = @effectiveTime, @@ -351,27 +373,29 @@ referencedComponentId = @referencedComponentId; -- Extended Map refset file. DROP TABLE IF EXISTS extendedmap; -CREATE TABLE extendedmap ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, - referencedComponentId NUMERIC(20) NOT NULL, - mapGroup INT UNSIGNED NOT NULL, - mapPriority INT UNSIGNED NOT NULL, - mapRule VARCHAR(4000) NOT NULL, - mapAdvice VARCHAR(4000) NOT NULL, - mapTarget VARCHAR(100) NOT NULL, - correlationId NUMERIC(20) NOT NULL, - mapCategoryId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (correlationId) REFERENCES concept(id), - FOREIGN KEY (mapCategoryId) REFERENCES concept(id) +CREATE TABLE extendedmap +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + mapGroup INT UNSIGNED NOT NULL, + mapPriority INT UNSIGNED NOT NULL, + mapRule VARCHAR(4000) NOT NULL, + mapAdvice VARCHAR(4000) NOT NULL, + mapTarget VARCHAR(100) NOT NULL, + correlationId NUMERIC(20) NOT NULL, + mapCategoryId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (correlationId) REFERENCES concept (id), + FOREIGN KEY (mapCategoryId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Map/der2_iisssccRefset_ExtendedMapSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE extendedmap LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Map/der2_iisssccRefset_ExtendedMapSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE extendedmap LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@mapGroup,@mapPriority,@mapRule,@mapAdvice,@mapTarget,@correlationId,@mapCategoryId) SET id = @id, effectiveTime = @effectiveTime, @@ -390,19 +414,21 @@ mapCategoryId = @mapCategoryId; -- Simple Map refset file. DROP TABLE IF EXISTS simplemap; -CREATE TABLE simplemap ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, - referencedComponentId NUMERIC(20) NOT NULL, - mapTarget VARCHAR(100) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) +CREATE TABLE simplemap +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + mapTarget VARCHAR(100) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Map/der2_sRefset_SimpleMapSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE simplemap LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Map/der2_sRefset_SimpleMapSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE simplemap LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@mapTarget) SET id = @id, effectiveTime = @effectiveTime, @@ -415,20 +441,22 @@ mapTarget = @mapTarget; -- Language refset file. DROP TABLE IF EXISTS language; -CREATE TABLE language ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE language +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - acceptabilityId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (acceptabilityId) REFERENCES concept(id) + acceptabilityId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (acceptabilityId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Language/der2_cRefset_LanguageSnapshot-en_${editionLabel}_${editionVersion}.txt' INTO TABLE language LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Language/der2_cRefset_LanguageSnapshot-en_${editionLabel}_${editionVersion}.txt' INTO TABLE language LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@acceptabilityId) SET id = @id, effectiveTime = @effectiveTime, @@ -441,21 +469,23 @@ acceptabilityId = @acceptabilityId; -- Refset Descriptor refset file. DROP TABLE IF EXISTS refsetdescriptor; -CREATE TABLE refsetdescriptor ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE refsetdescriptor +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - attributeDescription NUMERIC(20) NOT NULL, - attributeType NUMERIC(20) NOT NULL, - attributeOrder NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) + attributeDescription NUMERIC(20) NOT NULL, + attributeType NUMERIC(20) NOT NULL, + attributeOrder NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_cciRefset_RefsetDescriptorSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE refsetdescriptor LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_cciRefset_RefsetDescriptorSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE refsetdescriptor LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@attributeDescription,@attributeType,@attributeOrder) SET id = @id, effectiveTime = @effectiveTime, @@ -470,20 +500,22 @@ attributeOrder = @attributeOrder; -- Description Type refset file. DROP TABLE IF EXISTS descriptiontype; -CREATE TABLE descriptiontype ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE descriptiontype +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - descriptionFormat NUMERIC(20) NOT NULL, - descriptionLength INT UNSIGNED NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) + descriptionFormat NUMERIC(20) NOT NULL, + descriptionLength INT UNSIGNED NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_ciRefset_DescriptionTypeSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE descriptiontype LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_ciRefset_DescriptionTypeSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE descriptiontype LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@descriptionFormat,@descriptionLength) SET id = @id, effectiveTime = @effectiveTime, @@ -497,27 +529,29 @@ descriptionLength = @descriptionLength; -- MRCM Attribute Domain refset file. DROP TABLE IF EXISTS mrcmattributedomain; -CREATE TABLE mrcmattributedomain ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, - referencedComponentId NUMERIC(20) NOT NULL, - domainId NUMERIC(20) NOT NULL, - grouped INT NOT NULL, - attributeCardinality VARCHAR(20) NOT NULL, +CREATE TABLE mrcmattributedomain +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + domainId NUMERIC(20) NOT NULL, + grouped INT NOT NULL, + attributeCardinality VARCHAR(20) NOT NULL, attributeInGroupCardinality VARCHAR(20) NOT NULL, - ruleStrengthId NUMERIC(20) NOT NULL, - contentTypeId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (domainId) REFERENCES concept(id), - FOREIGN KEY (ruleStrengthId) REFERENCES concept(id), - FOREIGN KEY (contentTypeId) REFERENCES concept(id) + ruleStrengthId NUMERIC(20) NOT NULL, + contentTypeId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (domainId) REFERENCES concept (id), + FOREIGN KEY (ruleStrengthId) REFERENCES concept (id), + FOREIGN KEY (contentTypeId) REFERENCES concept (id) ); -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_cissccRefset_MRCMAttributeDomainSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE mrcmattributedomain LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_cissccRefset_MRCMAttributeDomainSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE mrcmattributedomain LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@domainId,@grouped,@attributeCardinality,@attributeInGroupCardinality,@ruleStrengthId,@contentTypeId) SET id = @id, effectiveTime = @effectiveTime, @@ -535,20 +569,22 @@ contentTypeId = @contentTypeId; -- MRCM Module Scope refset file. DROP TABLE IF EXISTS mrcmmodulescope; -CREATE TABLE mrcmmodulescope ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE mrcmmodulescope +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - mrcmRuleRefsetId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (mrcmRuleRefsetId) REFERENCES concept(id) + mrcmRuleRefsetId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (mrcmRuleRefsetId) REFERENCES concept (id) ); -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_cRefset_MRCMModuleScopeSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE mrcmmodulescope LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_cRefset_MRCMModuleScopeSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE mrcmmodulescope LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@mrcmRuleRefsetId) SET id = @id, effectiveTime = @effectiveTime, @@ -561,24 +597,26 @@ mrcmRuleRefsetId = @mrcmRuleRefsetId; -- MRCM Attribute Range refset file. DROP TABLE IF EXISTS mrcmattributerange; -CREATE TABLE mrcmattributerange ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, - referencedComponentId NUMERIC(20) NOT NULL, - rangeConstraint VARCHAR(4000) NOT NULL, - attributeRule VARCHAR(4000) NOT NULL, - ruleStrengthId NUMERIC(20) NOT NULL, - contentTypeId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (ruleStrengthId) REFERENCES concept(id), - FOREIGN KEY (contentTypeId) REFERENCES concept(id) +CREATE TABLE mrcmattributerange +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + rangeConstraint VARCHAR(4000) NOT NULL, + attributeRule VARCHAR(4000) NOT NULL, + ruleStrengthId NUMERIC(20) NOT NULL, + contentTypeId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (ruleStrengthId) REFERENCES concept (id), + FOREIGN KEY (contentTypeId) REFERENCES concept (id) ); -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_ssccRefset_MRCMAttributeRangeSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE mrcmattributerange LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_ssccRefset_MRCMAttributeRangeSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE mrcmattributerange LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@rangeConstraint,@attributeRule,@ruleStrengthId,@contentTypeId) SET id = @id, effectiveTime = @effectiveTime, @@ -594,25 +632,27 @@ contentTypeId = @contentTypeId; -- MRCM Domain refset file. DROP TABLE IF EXISTS mrcmdomain; -CREATE TABLE mrcmdomain ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, - referencedComponentId NUMERIC(20) NOT NULL, - domainConstraint VARCHAR(4000) NOT NULL, - parentDomain VARCHAR(4000), - proximalPrimitiveConstraint VARCHAR(4000) NOT NULL, - proximalPrimitiveRefinement VARCHAR(4000), - domainTemplateForPrecoordination TEXT NOT NULL, - domainTemplateForPostcoordination TEXT NOT NULL, - guideURL VARCHAR(4000), - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) +CREATE TABLE mrcmdomain +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + domainConstraint VARCHAR(4000) NOT NULL, + parentDomain VARCHAR(4000), + proximalPrimitiveConstraint VARCHAR(4000) NOT NULL, + proximalPrimitiveRefinement VARCHAR(4000), + domainTemplateForPrecoordination TEXT NOT NULL, + domainTemplateForPostcoordination TEXT NOT NULL, + guideURL VARCHAR(4000), + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_sssssssRefset_MRCMDomainSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE mrcmdomain LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_sssssssRefset_MRCMDomainSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE mrcmdomain LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@domainConstraint,@parentDomain,@proximalPrimitiveConstraint,@proximalPrimitiveRefinement,@domainTemplateForPrecoordination,@domainTemplateForPostcoordination,@guideURL) SET id = @id, effectiveTime = @effectiveTime, @@ -630,20 +670,22 @@ guideURL = @guideURL; -- Module Dependency refset file. DROP TABLE IF EXISTS moduledependency; -CREATE TABLE moduledependency ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE moduledependency +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - sourceEffectiveTime DATE NOT NULL, - targetEffectiveTime DATE NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) + sourceEffectiveTime DATE NOT NULL, + targetEffectiveTime DATE NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_ssRefset_ModuleDependencySnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE moduledependency LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_ssRefset_ModuleDependencySnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE moduledependency LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@sourceEffectiveTime,@targetEffectiveTime) SET id = @id, effectiveTime = @effectiveTime, @@ -655,5 +697,25 @@ sourceEffectiveTime = @sourceEffectiveTime, targetEffectiveTime = @targetEffectiveTime; +-- Transitive Closure table. +DROP TABLE IF EXISTS transitiveclosure; +CREATE TABLE transitiveclosure +( + superTypeId NUMERIC(20) NOT NULL, + subTypeId NUMERIC(20) NOT NULL, + depth INT NOT NULL, + PRIMARY KEY (superTypeId, subTypeId), + FOREIGN KEY (superTypeId) REFERENCES concept (id), + FOREIGN KEY (subTypeId) REFERENCES concept (id) +) CHARACTER SET utf8; + +LOAD +DATA LOCAL INFILE 'Snapshot/Terminology/sct2_TransitiveClosure_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE transitiveclosure LINES TERMINATED BY '\r\n' IGNORE 1 LINES +(@superTypeId,@subTypeId,@depth) +SET superTypeId = @superTypeId, +subTypeId = @subTypeId, +depth = @depth; + -- Restore foreign key checks to enforce referential integrity. -SET FOREIGN_KEY_CHECKS = 1; +SET +FOREIGN_KEY_CHECKS = 1; \ No newline at end of file diff --git a/src/main/resources/rf2/mysql_views.sql b/src/main/resources/rf2/mysql_views.sql index f2cfcc1..dda19c4 100644 --- a/src/main/resources/rf2/mysql_views.sql +++ b/src/main/resources/rf2/mysql_views.sql @@ -453,3 +453,15 @@ WHERE moduleId = cpn1.conceptId AND refsetId = cpn2.conceptId AND referencedComponentId = cpn3.conceptId; +-- transitive closure table +-- NOTE: this assumes conceptpreferredname has already been created +-- via the standard RF2 load scripts +DROP VIEW IF EXISTS transitiveclosurewithnames; +CREATE VIEW transitiveclosurewithnames AS +SELECT superTypeId, cpn1.preferredName superTypeName, + subTypeId, cpn2.preferredName subTypeName, a.depth +FROM transitiveclosure a, + conceptpreferredname cpn1, + conceptpreferredname cpn2 +WHERE a.superTypeId = cpn1.conceptId + AND a.subTypeId = cpn2.conceptId; \ No newline at end of file diff --git a/src/main/resources/rf2/oracle_tables.sql b/src/main/resources/rf2/oracle_tables.sql index f1c90c2..778db2a 100644 --- a/src/main/resources/rf2/oracle_tables.sql +++ b/src/main/resources/rf2/oracle_tables.sql @@ -3,232 +3,233 @@ SET ECHO ON -- Session settings. -ALTER SESSION SET NLS_LENGTH_SEMANTICS='CHAR'; +ALTER +SESSION SET NLS_LENGTH_SEMANTICS='CHAR'; -- Define helper procedure to drop tables. BEGIN - EXECUTE IMMEDIATE 'DROP PROCEDURE drop_table'; +EXECUTE IMMEDIATE 'DROP PROCEDURE drop_table'; EXCEPTION WHEN OTHERS THEN -- If procedure doesn't exist, it can't be dropped, -- so an exception will be thrown. Ignore it. IF SQLCODE != -4043 THEN RAISE; - END IF; +END IF; END; / -CREATE PROCEDURE drop_table (table_name IN VARCHAR2) IS +CREATE PROCEDURE drop_table(table_name IN VARCHAR2) IS BEGIN - EXECUTE IMMEDIATE 'DROP TABLE ' || table_name || ' CASCADE CONSTRAINTS'; +EXECUTE IMMEDIATE 'DROP TABLE ' || table_name || ' CASCADE CONSTRAINTS'; EXCEPTION -- If table doesn't exist, it can't be dropped, -- so an exception will be thrown. Ignore it. WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; - END IF; +END IF; END; / -- Concept table. EXECUTE drop_table('concept'); -CREATE TABLE concept ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, +CREATE TABLE concept +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, definitionStatusId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (definitionStatusId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (definitionStatusId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Description table. EXECUTE drop_table('description'); -CREATE TABLE description ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - conceptId NUMERIC(20) NOT NULL, - languageCode CHAR(2) NOT NULL, - typeId NUMERIC(20) NOT NULL, - term VARCHAR2(255) NOT NULL, +CREATE TABLE description +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + conceptId NUMERIC(20) NOT NULL, + languageCode CHAR(2) NOT NULL, + typeId NUMERIC(20) NOT NULL, + term VARCHAR2(255) NOT NULL, caseSignificanceId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (conceptId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (caseSignificanceId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (conceptId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (caseSignificanceId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Identifier table. EXECUTE drop_table('identifier'); -CREATE TABLE identifier ( - identifierSchemeId NUMERIC(20) NOT NULL, - alternateIdentifier VARCHAR2(255) NOT NULL, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, +CREATE TABLE identifier +( + identifierSchemeId NUMERIC(20) NOT NULL, + alternateIdentifier VARCHAR2(255) NOT NULL, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + FOREIGN KEY (moduleId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Relationship table. EXECUTE drop_table('relationship'); -CREATE TABLE relationship ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - sourceId NUMERIC(20) NOT NULL, - destinationId NUMERIC(20) NOT NULL, - relationshipGroup INT NOT NULL, - typeId NUMERIC(20) NOT NULL, +CREATE TABLE relationship +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + destinationId NUMERIC(20) NOT NULL, + relationshipGroup INT NOT NULL, + typeId NUMERIC(20) NOT NULL, characteristicTypeId NUMERIC(20) NOT NULL, - modifierId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (sourceId) REFERENCES concept(id), - FOREIGN KEY (destinationId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (characteristicTypeId) REFERENCES concept(id), - FOREIGN KEY (modifierId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + modifierId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (sourceId) REFERENCES concept (id), + FOREIGN KEY (destinationId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (characteristicTypeId) REFERENCES concept (id), + FOREIGN KEY (modifierId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Relationship concrete values table. EXECUTE drop_table('relationshipconcretevalues'); -CREATE TABLE relationshipconcretevalues ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - sourceId NUMERIC(20) NOT NULL, - value VARCHAR2(256) NOT NULL, - relationshipGroup INT NOT NULL, - typeId NUMERIC(20) NOT NULL, +CREATE TABLE relationshipconcretevalues +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + value VARCHAR2(256) NOT NULL, + relationshipGroup INT NOT NULL, + typeId NUMERIC(20) NOT NULL, characteristicTypeId NUMERIC(20) NOT NULL, - modifierId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (sourceId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (characteristicTypeId) REFERENCES concept(id), - FOREIGN KEY (modifierId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + modifierId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (sourceId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (characteristicTypeId) REFERENCES concept (id), + FOREIGN KEY (modifierId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- OWL Expression table. EXECUTE drop_table('owlexpression'); -CREATE TABLE owlexpression ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE owlexpression +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - owlExpression VARCHAR2(4000) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (referencedComponentId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + owlExpression VARCHAR2(4000) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (referencedComponentId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Stated Relationship table. EXECUTE drop_table('statedrelationship'); -CREATE TABLE statedrelationship ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - sourceId NUMERIC(20) NOT NULL, - destinationId NUMERIC(20) NOT NULL, - relationshipGroup INT NOT NULL, - typeId NUMERIC(20) NOT NULL, +CREATE TABLE statedrelationship +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + destinationId NUMERIC(20) NOT NULL, + relationshipGroup INT NOT NULL, + typeId NUMERIC(20) NOT NULL, characteristicTypeId NUMERIC(20) NOT NULL, - modifierId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (sourceId) REFERENCES concept(id), - FOREIGN KEY (destinationId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (characteristicTypeId) REFERENCES concept(id), - FOREIGN KEY (modifierId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + modifierId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (sourceId) REFERENCES concept (id), + FOREIGN KEY (destinationId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (characteristicTypeId) REFERENCES concept (id), + FOREIGN KEY (modifierId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Text Definition table. EXECUTE drop_table('textdefinition'); -CREATE TABLE textdefinition ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - conceptId NUMERIC(20) NOT NULL, - languageCode CHAR(2) NOT NULL, - typeId NUMERIC(20) NOT NULL, - term VARCHAR2(2048) NOT NULL, +CREATE TABLE textdefinition +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + conceptId NUMERIC(20) NOT NULL, + languageCode CHAR(2) NOT NULL, + typeId NUMERIC(20) NOT NULL, + term VARCHAR2(2048) NOT NULL, caseSignificanceId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (conceptId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (caseSignificanceId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (conceptId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (caseSignificanceId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Association refset table. EXECUTE drop_table('association'); -CREATE TABLE association ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE association +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - targetComponent NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) + targetComponent NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) -- TODO: FOREIGN KEY targetComponent? -) -PCTFREE 10 PCTUSED 80; +) PCTFREE 10 PCTUSED 80; -- Attribute Value refset table. EXECUTE drop_table('attributevalue'); -CREATE TABLE attributevalue ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE attributevalue +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - valueId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (valueId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + valueId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (valueId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Simple refset table. EXECUTE drop_table('simple'); -CREATE TABLE simple ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE simple +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- No more complex map, ICD9CM maps deprecated -- Complex Map refset table. @@ -255,196 +256,207 @@ PCTFREE 10 PCTUSED 80; -- Extended Map refset table. EXECUTE drop_table('extendedmap'); -CREATE TABLE extendedmap ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE extendedmap +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - mapGroup INT NOT NULL, - mapPriority INT NOT NULL, - mapRule VARCHAR2(4000), - mapAdvice VARCHAR2(4000), - mapTarget VARCHAR2(100), - correlationId NUMERIC(20) NOT NULL, - mapCategoryId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (correlationId) REFERENCES concept(id), - FOREIGN KEY (mapCategoryId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + mapGroup INT NOT NULL, + mapPriority INT NOT NULL, + mapRule VARCHAR2(4000), + mapAdvice VARCHAR2(4000), + mapTarget VARCHAR2(100), + correlationId NUMERIC(20) NOT NULL, + mapCategoryId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (correlationId) REFERENCES concept (id), + FOREIGN KEY (mapCategoryId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Simple Map refset table. EXECUTE drop_table('simplemap'); -CREATE TABLE simplemap ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE simplemap +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - mapTarget VARCHAR2(100) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + mapTarget VARCHAR2(100) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Lanuage refset table. EXECUTE drop_table('language'); -CREATE TABLE language ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE language +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - acceptabilityId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (acceptabilityId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + acceptabilityId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (acceptabilityId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Refset Descriptor refset table. EXECUTE drop_table('refsetdescriptor'); -CREATE TABLE refsetdescriptor ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE refsetdescriptor +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - attributeDescription NUMERIC(20) NOT NULL, - attributeType NUMERIC(20) NOT NULL, - attributeOrder NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + attributeDescription NUMERIC(20) NOT NULL, + attributeType NUMERIC(20) NOT NULL, + attributeOrder NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Description Type refset table. EXECUTE drop_table('descriptiontype'); -CREATE TABLE descriptiontype ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE descriptiontype +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - descriptionFormat NUMERIC(20) NOT NULL, - descriptionLength INT NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + descriptionFormat NUMERIC(20) NOT NULL, + descriptionLength INT NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- MRCM Attribute Domain refset file. EXECUTE drop_table('mrcmattributedomain'); -CREATE TABLE mrcmattributedomain ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, - referencedComponentId NUMERIC(20) NOT NULL, - domainId NUMERIC(20) NOT NULL, - grouped INT NOT NULL, - attributeCardinality VARCHAR2(20) NOT NULL, +CREATE TABLE mrcmattributedomain +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + domainId NUMERIC(20) NOT NULL, + grouped INT NOT NULL, + attributeCardinality VARCHAR2(20) NOT NULL, attributeInGroupCardinality VARCHAR2(20) NOT NULL, - ruleStrengthId NUMERIC(20) NOT NULL, - contentTypeId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (domainId) REFERENCES concept(id), - FOREIGN KEY (ruleStrengthId) REFERENCES concept(id), - FOREIGN KEY (contentTypeId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + ruleStrengthId NUMERIC(20) NOT NULL, + contentTypeId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (domainId) REFERENCES concept (id), + FOREIGN KEY (ruleStrengthId) REFERENCES concept (id), + FOREIGN KEY (contentTypeId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- MRCM Module Scope refset file. EXECUTE drop_table('mrcmmodulescope'); -CREATE TABLE mrcmmodulescope ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE mrcmmodulescope +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - mrcmRuleRefsetId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (mrcmRuleRefsetId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + mrcmRuleRefsetId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (mrcmRuleRefsetId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- MRCM Attribute Range refset file. EXECUTE drop_table('mrcmattributerange'); -CREATE TABLE mrcmattributerange ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE mrcmattributerange +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - rangeConstraint VARCHAR2(4000) NOT NULL, - attributeRule VARCHAR2(4000) NOT NULL, - ruleStrengthId NUMERIC(20) NOT NULL, - contentTypeId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (ruleStrengthId) REFERENCES concept(id), - FOREIGN KEY (contentTypeId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + rangeConstraint VARCHAR2(4000) NOT NULL, + attributeRule VARCHAR2(4000) NOT NULL, + ruleStrengthId NUMERIC(20) NOT NULL, + contentTypeId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (ruleStrengthId) REFERENCES concept (id), + FOREIGN KEY (contentTypeId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- MRCM Domain refset file. EXECUTE drop_table('mrcmdomain'); -CREATE TABLE mrcmdomain ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, - referencedComponentId NUMERIC(20) NOT NULL, - domainConstraint VARCHAR2(4000) NOT NULL, - parentDomain VARCHAR2(4000), - proximalPrimitiveConstraint VARCHAR2(4000) NOT NULL, - proximalPrimitiveRefinement VARCHAR2(4000), - domainTemplateForPrecoordination VARCHAR2(4000) NOT NULL, +CREATE TABLE mrcmdomain +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + domainConstraint VARCHAR2(4000) NOT NULL, + parentDomain VARCHAR2(4000), + proximalPrimitiveConstraint VARCHAR2(4000) NOT NULL, + proximalPrimitiveRefinement VARCHAR2(4000), + domainTemplateForPrecoordination VARCHAR2(4000) NOT NULL, domainTemplateForPostcoordination VARCHAR2(4000) NOT NULL, - guideURL VARCHAR2(4000), - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + guideURL VARCHAR2(4000), + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Module Dependency refset table. EXECUTE drop_table('moduledependency'); -CREATE TABLE moduledependency ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE moduledependency +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - sourceEffectiveTime DATE NOT NULL, - targetEffectiveTime DATE NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) + sourceEffectiveTime DATE NOT NULL, + targetEffectiveTime DATE NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; + +-- Transitive closure table +EXECUTE drop_table('transitiveclosure'); +CREATE TABLE transitiveclosure ( + superTypeId NUMERIC(20) NOT NULL, + subTypeId NUMERIC(20) NOT NULL, + depth INTEGER NOT NULL, + PRIMARY KEY (superTypeId, subTypeId), + FOREIGN KEY (superTypeId) REFERENCES concept(id), + FOREIGN KEY (subTypeId) REFERENCES concept(id) ) PCTFREE 10 PCTUSED 80; - -- Clean up helper procedures. DROP PROCEDURE drop_table; diff --git a/src/main/resources/rf2/oracle_views.sql b/src/main/resources/rf2/oracle_views.sql index 3433b5b..69626dc 100644 --- a/src/main/resources/rf2/oracle_views.sql +++ b/src/main/resources/rf2/oracle_views.sql @@ -3,31 +3,32 @@ SET ECHO ON -- Session settings. -ALTER SESSION SET NLS_LENGTH_SEMANTICS='CHAR'; +ALTER +SESSION SET NLS_LENGTH_SEMANTICS='CHAR'; -- Define helper procedure to drop views. BEGIN - EXECUTE IMMEDIATE 'DROP PROCEDURE drop_view'; +EXECUTE IMMEDIATE 'DROP PROCEDURE drop_view'; EXCEPTION WHEN OTHERS THEN -- If procedure doesn't exist, it can't be dropped, -- so an exception will be thrown. Ignore it. IF SQLCODE != -4043 THEN RAISE; - END IF; +END IF; END; / -CREATE PROCEDURE drop_view (view_name IN VARCHAR2) IS +CREATE PROCEDURE drop_view(view_name IN VARCHAR2) IS BEGIN - EXECUTE IMMEDIATE 'DROP VIEW ' || view_name || ' CASCADE CONSTRAINTS'; +EXECUTE IMMEDIATE 'DROP VIEW ' || view_name || ' CASCADE CONSTRAINTS'; EXCEPTION -- If view doesn't exist, it can't be dropped, -- so an exception will be thrown. Ignore it. WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; - END IF; +END IF; END; / @@ -40,211 +41,280 @@ EXECUTE drop_view('conceptpreferredname'); CREATE VIEW conceptpreferredname AS SELECT c.id conceptId, NVL(d.term, 'no active preferred synonym') preferredName, d.id descriptionId FROM concept c -LEFT OUTER JOIN description d -ON c.id = d.conceptId -AND d.active = 1 -AND d.typeId = 900000000000013009 -LEFT OUTER JOIN language l -ON d.id = l.referencedComponentId -AND l.active = 1 -AND l.acceptabilityId = 900000000000548007 -AND l.refSetId = 900000000000509007 + LEFT OUTER JOIN description d + ON c.id = d.conceptId + AND d.active = 1 + AND d.typeId = 900000000000013009 + LEFT OUTER JOIN language l + ON d.id = l.referencedComponentId + AND l.active = 1 + AND l.acceptabilityId = 900000000000548007 + AND l.refSetId = 900000000000509007 WHERE (l.acceptabilityId IS NOT null OR d.TERM IS null); -- Concept table with names. EXECUTE drop_view('conceptwithnames'); CREATE VIEW conceptwithnames AS -SELECT id, cpn1.preferredName idName, effectiveTime, active, - moduleId, cpn2.preferredName moduleIdName, - definitionStatusId, cpn3.preferredName definitionStatusIdName +SELECT id, + cpn1.preferredName idName, + effectiveTime, + active, + moduleId, + cpn2.preferredName moduleIdName, + definitionStatusId, + cpn3.preferredName definitionStatusIdName FROM concept, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE id = cpn1.conceptId -AND moduleId = cpn2.conceptId -AND definitionStatusId = cpn3.conceptId; + AND moduleId = cpn2.conceptId + AND definitionStatusId = cpn3.conceptId; -- Description table. EXECUTE drop_view('descriptionwithnames'); CREATE VIEW descriptionwithnames AS -SELECT id, term, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - d.conceptId, cpn2.preferredName conceptIdName, - languageCode, - typeId, cpn3.preferredName typeIdName, - caseSignificanceId, cpn4.preferredName caseSignificanceIdName +SELECT id, + term, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + d.conceptId, + cpn2.preferredName conceptIdName, + languageCode, + typeId, + cpn3.preferredName typeIdName, + caseSignificanceId, + cpn4.preferredName caseSignificanceIdName FROM description d, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4 -WHERE moduleId = cpn1.conceptId AND d.conceptId = cpn2.conceptId AND typeId = cpn3.conceptId AND caseSignificanceId = cpn4.conceptId; + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4 +WHERE moduleId = cpn1.conceptId + AND d.conceptId = cpn2.conceptId + AND typeId = cpn3.conceptId + AND caseSignificanceId = cpn4.conceptId; -- Identifier table. EXECUTE drop_view('identifierwithnames'); CREATE VIEW identifierwithnames AS -SELECT identifierSchemeId, cpn1.preferredName identifierSchemeIdName, - alternateIdentifier, effectiveTime, active, - moduleId, cpn2.preferredName moduleIdName, - referencedComponentId +SELECT identifierSchemeId, + cpn1.preferredName identifierSchemeIdName, + alternateIdentifier, + effectiveTime, + active, + moduleId, + cpn2.preferredName moduleIdName, + referencedComponentId FROM identifier, - conceptpreferredname cpn1, - conceptpreferredname cpn2 + conceptpreferredname cpn1, + conceptpreferredname cpn2 WHERE identifierSchemeId = cpn1.conceptId -AND moduleId = cpn2.conceptId; + AND moduleId = cpn2.conceptId; -- Relationship table. EXECUTE drop_view('relationshipwithnames'); CREATE VIEW relationshipwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - sourceId, cpn2.preferredName sourceIdName, - destinationId, cpn3.preferredName destinationIdName, - relationshipGroup, - typeId, cpn4.preferredName typeIdName, - characteristicTypeId, cpn5.preferredName characteristicTypeIdName, - modifierId, cpn6.preferredName modifierIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + sourceId, + cpn2.preferredName sourceIdName, + destinationId, + cpn3.preferredName destinationIdName, + relationshipGroup, + typeId, + cpn4.preferredName typeIdName, + characteristicTypeId, + cpn5.preferredName characteristicTypeIdName, + modifierId, + cpn6.preferredName modifierIdName from relationship, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4, - conceptpreferredname cpn5, - conceptpreferredname cpn6 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4, + conceptpreferredname cpn5, + conceptpreferredname cpn6 WHERE moduleId = cpn1.conceptId -AND sourceId = cpn2.conceptId -AND destinationId = cpn3.conceptId -AND typeId = cpn4.conceptId -AND characteristicTypeId = cpn5.conceptId -AND modifierId = cpn6.conceptId; + AND sourceId = cpn2.conceptId + AND destinationId = cpn3.conceptId + AND typeId = cpn4.conceptId + AND characteristicTypeId = cpn5.conceptId + AND modifierId = cpn6.conceptId; xxx-- Relationship concrete values table. EXECUTE drop_view('relationshipconcretevalueswithnames'); CREATE VIEW relationshipconcretevalueswithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - sourceId, cpn2.preferredName sourceIdName, - value, relationshipGroup, - typeId, cpn4.preferredName typeIdName, - characteristicTypeId, cpn5.preferredName characteristicTypeIdName, - modifierId, cpn6.preferredName modifierIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + sourceId, + cpn2.preferredName sourceIdName, + value, + relationshipGroup, + typeId, + cpn4.preferredName typeIdName, + characteristicTypeId, + cpn5.preferredName characteristicTypeIdName, + modifierId, + cpn6.preferredName modifierIdName from relationshipconcretevalues, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn4, - conceptpreferredname cpn5, - conceptpreferredname cpn6 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn4, + conceptpreferredname cpn5, + conceptpreferredname cpn6 WHERE moduleId = cpn1.conceptId -AND sourceId = cpn2.conceptId -AND typeId = cpn4.conceptId -AND characteristicTypeId = cpn5.conceptId -AND modifierId = cpn6.conceptId; + AND sourceId = cpn2.conceptId + AND typeId = cpn4.conceptId + AND characteristicTypeId = cpn5.conceptId + AND modifierId = cpn6.conceptId; -- Stated Relationship table. EXECUTE drop_view('statedrelationshipwithnames'); CREATE VIEW statedrelationshipwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - sourceId, cpn2.preferredName sourceIdName, - destinationId, cpn3.preferredName destinationIdName, - relationshipGroup, - typeId, cpn4.preferredName typeIdName, - characteristicTypeId, cpn5.preferredName characteristicTypeIdName, - modifierId, cpn6.preferredName modifierIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + sourceId, + cpn2.preferredName sourceIdName, + destinationId, + cpn3.preferredName destinationIdName, + relationshipGroup, + typeId, + cpn4.preferredName typeIdName, + characteristicTypeId, + cpn5.preferredName characteristicTypeIdName, + modifierId, + cpn6.preferredName modifierIdName from statedrelationship, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4, - conceptpreferredname cpn5, - conceptpreferredname cpn6 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4, + conceptpreferredname cpn5, + conceptpreferredname cpn6 WHERE moduleId = cpn1.conceptId -AND sourceId = cpn2.conceptId -AND destinationId = cpn3.conceptId -AND typeId = cpn4.conceptId -AND characteristicTypeId = cpn5.conceptId -AND modifierId = cpn6.conceptId; + AND sourceId = cpn2.conceptId + AND destinationId = cpn3.conceptId + AND typeId = cpn4.conceptId + AND characteristicTypeId = cpn5.conceptId + AND modifierId = cpn6.conceptId; -- Text Definition table. EXECUTE drop_view('textdefinitionwithnames'); CREATE VIEW textdefinitionwithnames AS -SELECT id, term, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - td.conceptId, cpn2.preferredName conceptIdName, - languageCode, - typeId, cpn3.preferredName typeIdName, - caseSignificanceId, cpn4.preferredName caseSignificanceIdName +SELECT id, + term, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + td.conceptId, + cpn2.preferredName conceptIdName, + languageCode, + typeId, + cpn3.preferredName typeIdName, + caseSignificanceId, + cpn4.preferredName caseSignificanceIdName from textdefinition td, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4 WHERE moduleId = cpn1.conceptId -AND td.conceptId = cpn2.conceptId -AND typeId = cpn3.conceptId -AND caseSignificanceId = cpn4.conceptId; + AND td.conceptId = cpn2.conceptId + AND typeId = cpn3.conceptId + AND caseSignificanceId = cpn4.conceptId; -- Association refset table. EXECUTE drop_view('associationwithnames'); CREATE VIEW associationwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - targetComponent, cpn4.preferredName targetComponentName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + targetComponent, + cpn4.preferredName targetComponentName from association, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId -AND targetComponent = cpn4.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId + AND targetComponent = cpn4.conceptId; -- Attribute Value refset table. EXECUTE drop_view('attributevaluewithnames'); CREATE VIEW attributevaluewithnames AS -SELECT attributevalue.id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - valueId, cpn4.preferredName valueIdName +SELECT attributevalue.id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + valueId, + cpn4.preferredName valueIdName FROM attributevalue, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - (SELECT conceptId id, preferredName FROM conceptpreferredname - UNION ALL - SELECT d.id, term from description d) cpn3, - conceptpreferredname cpn4 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + (SELECT conceptId id, preferredName + FROM conceptpreferredname + UNION ALL + SELECT d.id, term + from description d) cpn3, + conceptpreferredname cpn4 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.id -AND valueId = cpn4.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.id + AND valueId = cpn4.conceptId; -- Simple refset table. EXECUTE drop_view('simplewithnames'); CREATE VIEW simplewithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName FROM simple, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- No more complex map, ICD9CM maps deprecated @@ -275,116 +345,165 @@ AND referencedComponentId = cpn3.conceptId; -- Extended Map refset table. EXECUTE drop_view('extendedmapwithnames'); CREATE VIEW extendedmapwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - mapGroup, - mapPriority, - mapRule, - mapAdvice, - mapTarget, - correlationId, cpn4.preferredName correlationIdName, - mapCategoryId, cpn5.preferredName mapCategoryIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + mapGroup, + mapPriority, + mapRule, + mapAdvice, + mapTarget, + correlationId, + cpn4.preferredName correlationIdName, + mapCategoryId, + cpn5.preferredName mapCategoryIdName FROM extendedmap, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4, - conceptpreferredname cpn5 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4, + conceptpreferredname cpn5 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId -AND correlationId = cpn4.conceptId -AND mapCategoryId = cpn5.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId + AND correlationId = cpn4.conceptId + AND mapCategoryId = cpn5.conceptId; -- Simple Map refset table. EXECUTE drop_view('simplemapwithnames'); CREATE VIEW simplemapwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - mapTarget +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + mapTarget FROM simplemap, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- Language refset table. EXECUTE drop_view('languagewithnames'); CREATE VIEW languagewithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - acceptabilityId, cpn4.preferredName acceptabilityIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + acceptabilityId, + cpn4.preferredName acceptabilityIdName FROM language, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.descriptionId -AND acceptabilityId = cpn4.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.descriptionId + AND acceptabilityId = cpn4.conceptId; -- Refset Descriptor refset table. EXECUTE drop_view('refsetdescriptorwithnames'); CREATE VIEW refsetdescriptorwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - attributeDescription, attributeType, attributeOrder +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + attributeDescription, + attributeType, + attributeOrder FROM refsetdescriptor, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- Description Type refset table. EXECUTE drop_view('descriptiontypewithnames'); CREATE VIEW descriptiontypewithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - descriptionFormat, descriptionLength +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + descriptionFormat, + descriptionLength FROM descriptiontype, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- Module Dependency refset table. EXECUTE drop_view('moduledependencywithnames'); CREATE VIEW moduledependencywithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - sourceEffectiveTime, targetEffectiveTime +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + sourceEffectiveTime, + targetEffectiveTime FROM moduledependency, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; - + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; + +-- transitive closure table +-- NOTE: this assumes conceptpreferredname has already been created +-- via the standard RF2 load scripts +EXECUTE drop_view('transitiveclosurewithnames'); +CREATE VIEW transitiveclosurewithnames AS +SELECT superTypeId, cpn1.preferredName superTypeName, + subTypeId, cpn2.preferredName subTypeName, a.depth +FROM transitiveclosure a, + conceptpreferredname cpn1, + conceptpreferredname cpn2 +WHERE a.superTypeId = cpn1.conceptId + AND a.subTypeId = cpn2.conceptId; -- Clean up helper procedures. DROP PROCEDURE drop_view; diff --git a/src/main/resources/rf2/populate_mysql_db.bat b/src/main/resources/rf2/populate_mysql_db.bat deleted file mode 100644 index 5c256a8..0000000 --- a/src/main/resources/rf2/populate_mysql_db.bat +++ /dev/null @@ -1,51 +0,0 @@ -:: -:: Database connection parameters -:: Please edit these variables to reflect your environment -:: -set mysql=C:/mysql/mysql-5.6.46-winx64/bin/mysql.exe -set user=root -set password=admin -set db_name=snomed - -del mysql.log -echo. > mysql.log -echo ---------------------------------------- >> mysql.log 2>&1 -echo Starting ... >> mysql.log 2>&1 -date /T >> mysql.log 2>&1 -time /T >> mysql.log 2>&1 -echo ---------------------------------------- >> mysql.log 2>&1 -echo MYSQL_HOME = %MYSQL_HOME% >> mysql.log 2>&1 -echo user = %user% >> mysql.log 2>&1 -echo db_name = %db_name% >> mysql.log 2>&1 -set error=0 - -echo Create and load tables >> mysql.log 2>&1 -"%mysql%" -vvv -u %user% -p%password% --local-infile=1 %db_name% < mysql_tables.sql >> mysql.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1 -goto trailer) - -echo Create indexes >> mysql.log 2>&1 -"%mysql%" -vvv -u %user% -p%password% --local-infile=1 %db_name% < mysql_indexes.sql >> mysql.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1 -goto trailer) - -echo Create views >> mysql.log 2>&1 -"%mysql%" -vvv -u %user% -p%password% --local-infile=1 %db_name% < mysql_views.sql >> mysql.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1 -goto trailer) - -:trailer -echo ---------------------------------------- >> mysql.log 2>&1 -IF %error% NEQ 0 ( -echo There were one or more errors. Please reference the mysql.log file for details. >> mysql.log 2>&1 -set retval=-1 -) else ( -echo Completed without errors. >> mysql.log 2>&1 -set retval=0 -) -echo Finished ... >> mysql.log 2>&1 -date /T >> mysql.log 2>&1 -time /T >> mysql.log 2>&1 -echo ---------------------------------------- >> mysql.log 2>&1 -pause -exit %retval% diff --git a/src/main/resources/rf2/populate_mysql_db.sh b/src/main/resources/rf2/populate_mysql_db.sh index 9003ba9..e98a63c 100644 --- a/src/main/resources/rf2/populate_mysql_db.sh +++ b/src/main/resources/rf2/populate_mysql_db.sh @@ -1,11 +1,8 @@ #!/bin/bash -f # # Database connection parameters -# NOTE: or MySQL 8.0, you'll need to run the server with local_infile=ON -# Please edit these variables to reflect your environment -# - Tested with docker mysql 5.6, 5.7, 8.0 (using docker mysql server and client) -# - host=host.docker.internal -host= +# PLEASE EDIT THESE VARIABLES TO REFLECT YOUR ENVIRONMENT +host=[UPDATE] user=root password=admin db_name=snomed @@ -14,14 +11,14 @@ db_name=snomed touch mysql.log ef=0 -echo "See mysql.log for output" +echo "See mysql.log for detailed output" -echo "----------------------------------------" >> mysql.log 2>&1 -echo "Starting ... `/bin/date`" >> mysql.log 2>&1 -echo "----------------------------------------" >> mysql.log 2>&1 -echo "user = $user" >> mysql.log 2>&1 -echo "db_name = $db_name" >> mysql.log 2>&1 -echo "host = $host" >> mysql.log 2>&1 +echo "----------------------------------------" | tee -a mysql.log +echo "Starting ... `/bin/date`" | tee -a mysql.log +echo "----------------------------------------" | tee -a mysql.log +echo "user = $user" | tee -a mysql.log +echo "db_name = $db_name" | tee -a mysql.log +echo "host = $host" | tee -a mysql.log if [ "${password}" != "" ]; then password="-p${password}" @@ -30,31 +27,54 @@ if [ "${host}" != "" ]; then host="-h ${host}" fi -echo " Create and load tables ... `/bin/date`" >> mysql.log 2>&1 +DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +echo " Compute transitive closure relationship file ... `/bin/date`" | tee -a mysql.log +relFile=$(find $DIR/Snapshot/Terminology/ -name "*_Relationship_Snapshot_*.txt" -print -quit) +#check if system has python or perl, run the corresponding script +if command -v python &> /dev/null +then + echo "python found, running python script" >> mysql.log 2>&1 + python $DIR/compute_transitive_closure.py --force --noself $relFile >> mysql.log 2>&1 + if [ $? -ne 0 ]; then ef=1; fi +elif command -v perl &> /dev/null +then + echo "perl found, running perl script" >> mysql.log 2>&1 + perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> mysql.log 2>&1 + if [ $? -ne 0 ]; then ef=1; fi +# if none are present, print error message +else + echo "No python or perl found. Please install one of them." | tee -a mysql.log + ef=1 +fi + +if [ $ef -ne 1 ]; then +echo " Create and load tables ... `/bin/date`" | tee -a mysql.log mysql -vvv $host -u $user $password --local-infile $db_name < mysql_tables.sql >> mysql.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi +fi if [ $ef -ne 1 ]; then -echo " Create indexes ... `/bin/date`" >> mysql.log 2>&1 +echo " Create indexes ... `/bin/date`" | tee -a mysql.log mysql -vvv $host -u $user $password --local-infile $db_name < mysql_indexes.sql >> mysql.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi if [ $ef -ne 1 ]; then -echo " Create views ... `/bin/date`" >> mysql.log 2>&1 +echo " Create views ... `/bin/date`" | tee -a mysql.log mysql -vvv $host -u $user $password --local-infile $db_name < mysql_views.sql >> mysql.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi -echo "----------------------------------------" >> mysql.log 2>&1 +echo "----------------------------------------" | tee -a mysql.log if [ $ef -eq 1 ] then - echo "There were one or more errors." >> mysql.log 2>&1 + echo "There were one or more errors." | tee -a mysql.log retval=-1 else - echo "Completed without errors." >> mysql.log 2>&1 + echo "Completed without errors." | tee - a mysql.log retval=0 fi -echo "Finished ... `/bin/date`" >> mysql.log 2>&1 -echo "----------------------------------------" >> mysql.log 2>&1 +echo "Finished ... `/bin/date`" | tee -a mysql.log +echo "----------------------------------------" | tee -a mysql.log exit $retval diff --git a/src/main/resources/rf2/populate_oracle_db.bat b/src/main/resources/rf2/populate_oracle_db.bat deleted file mode 100644 index 9948229..0000000 --- a/src/main/resources/rf2/populate_oracle_db.bat +++ /dev/null @@ -1,163 +0,0 @@ -:: -:: Database connection parameters -:: Please edit these variables to reflect your environment -:: -set ORACLE_HOME=C:\app\oracle\product\12.1.0\dbhome_1 -set user=snomed -set password=snomed -set tns_name=ORCLCDB -set NLS_LANG=AMERICAN_AMERICA.UTF8 - -del oracle.log -echo. > oracle.log -echo ---------------------------------------- >> oracle.log 2>&1 -echo Starting ... >> oracle.log 2>&1 -date /T >> oracle.log 2>&1 -time /T >> oracle.log 2>&1 -echo ---------------------------------------- >> oracle.log 2>&1 -echo ORACLE_HOME = %ORACLE_HOME% >> oracle.log 2>&1 -echo user = %user% >> oracle.log 2>&1 -echo tns_name = %tns_name% >> oracle.log 2>&1 -set error=0 - -echo Create tables >> oracle.log 2>&1 -echo @oracle_tables.sql|%ORACLE_HOME%\bin\sqlplus %user%/%password%@%tns_name% >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1 -goto trailer) - -echo Load concept table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="concept.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type concept.log >> oracle.log - -echo Load description table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="description.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type description.log >> oracle.log - -echo Load identifier table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="identifier.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type identifier.log >> oracle.log - -echo Load relationship table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="relationship.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type relationship.log >> oracle.log - -echo Load relationship concrete values table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="relationshipconcretevalues.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type relationshipconcretevalues.log >> oracle.log - -echo Load owl expression table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="owlexpression.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type owlexpression.log >> oracle.log - -echo Load stated relationship table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="statedrelationship.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type statedrelationship.log >> oracle.log - -echo Load text definition table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="textdefinition.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type textdefinition.log >> oracle.log - -echo Load association table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="association.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type association.log >> oracle.log - -echo Load attribute value table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="attributevalue.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type attributevalue.log >> oracle.log - -echo Load simple refset table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="simple.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type simple.log >> oracle.log - -:: No more complex map, ICD9CM maps deprecated -:: echo Load complex map refset table data >> oracle.log 2>&1 -:: %ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="complexmap.ctl" >> oracle.log 2>&1 -:: IF %ERRORLEVEL% NEQ 0 (set error=1) -:: type complexmap.log >> oracle.log - -echo Load extended map table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="extendedmap.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type extendedmap.log >> oracle.log - -echo Load simple map table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="simplemap.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type simplemap.log >> oracle.log - -echo Load language table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="language.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type language.log >> oracle.log - -echo Load refset descriptor table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="refsetdescriptor.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type refsetdescriptor.log >> oracle.log - -echo Load description type table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="descriptiontype.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type descriptiontype.log >> oracle.log - -echo Load mrcm attribute domain table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="mrcmattributedomain.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type mrcmattributedomain.log >> oracle.log - -echo Load mrcm module scope table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="mrcmmodulescope.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type mrcmmodulescope.log >> oracle.log - -echo Load mrcm attribute range table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="mrcmattributerange.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type mrcmattributerange.log >> oracle.log - -echo Load mrcm domain table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="mrcmdomain.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type mrcmdomain.log >> oracle.log - -echo Load module dependency table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="moduledependency.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type moduledependency.log >> oracle.log - -echo Create indexes >> oracle.log 2>&1 -echo @oracle_indexes.sql|%ORACLE_HOME%\bin\sqlplus %user%/%password%@%tns_name% >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1 -goto trailer) - -echo Create views >> oracle.log 2>&1 -echo @oracle_views.sql|%ORACLE_HOME%\bin\sqlplus %user%/%password%@%tns_name% >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1 -goto trailer) - -:trailer -echo ---------------------------------------- >> oracle.log 2>&1 -IF %error% NEQ 0 ( -echo There were one or more errors. >> oracle.log 2>&1 -set retval=-1 -) else ( -echo Completed without errors. >> oracle.log 2>&1 -set retval=0 -) -echo Finished ... >> oracle.log 2>&1 -date /T >> oracle.log 2>&1 -time /T >> oracle.log 2>&1 -echo ---------------------------------------- >> oracle.log 2>&1 -pause -exit %retval% diff --git a/src/main/resources/rf2/populate_oracle_db.sh b/src/main/resources/rf2/populate_oracle_db.sh index 1a0e9d7..9d9409a 100644 --- a/src/main/resources/rf2/populate_oracle_db.sh +++ b/src/main/resources/rf2/populate_oracle_db.sh @@ -2,112 +2,126 @@ # # Database connection parameters -# Please edit these variables to reflect your environment -# - Tested on Windows with "Git Bash" as a shell -# - # Set if necessary #export ORACLE_HOME=/app/oracle/product/12.1.0/dbhome_1 +# PLEASE EDIT THESE VARIABLES TO REFLECT YOUR ENVIRONMENT user=snomed password=snomed tns_name=ORCLCDB export NLS_LANG=AMERICAN_AMERICA.UTF8 -# Oracle Docker on Ubuntu does not allow removing the log file -# Do this step prior to starting Docker to execute populate scripts -# /bin/rm -f oracle.log -# touch oracle.log +# Clear the log file. If it doesn't exist, create it. +> oracle.log ef=0 -echo "See oracle.log for output" -echo "----------------------------------------" >> oracle.log 2>&1 -echo "Starting ... `/bin/date`" >> oracle.log 2>&1 -echo "----------------------------------------" >> oracle.log 2>&1 -echo "ORACLE_HOME = $ORACLE_HOME" >> oracle.log 2>&1 -echo "user = $user" >> oracle.log 2>&1 -echo "tns_name = $tns_name" >> oracle.log 2>&1 +echo "See oracle.log for detailed output" +echo "----------------------------------------" | tee -a oracle.log +echo "Starting ... `/bin/date`" | tee -a oracle.log +echo "----------------------------------------" | tee -a oracle.log +echo "ORACLE_HOME = $ORACLE_HOME" | tee -a oracle.log +echo "user = $user" | tee -a oracle.log +echo "tns_name = $tns_name" | tee -a oracle.log + + +DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -echo " Create tables ... `/bin/date`" >> oracle.log 2>&1 +echo " Compute transitive closure relationship file ... `/bin/date`" | tee -a oracle.log +relFile=$(find $DIR/Snapshot/Terminology/ -name "*_Relationship_Snapshot_*.txt" -print -quit) +$DIR/compute_transitive_closure.py --force --noself $relFile >> oracle.log 2>&1 +if [ $? -ne 0 ]; then ef=1; fi + +if [ $ef -ne 1 ]; then +echo " Create tables ... `/bin/date`" | tee -a oracle.log echo "@oracle_tables.sql" | $ORACLE_HOME/bin/sqlplus $user/$password@$tns_name >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi +fi +## Load RF2 tables if [ $ef -ne 1 ]; then -echo " Load concept table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load concept table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="concept.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat concept.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load description table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load description table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="description.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat description.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load identifier table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load identifier table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="identifier.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat identifier.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load relationship table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load relationship table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="relationship.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat relationship.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load relationship concrete values table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load relationship concrete values table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="relationshipconcretevalues.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat relationshipconcretevalues.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load owl expression table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load owl expression table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="owlexpression.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat owlexpression.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load stated relationship table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load stated relationship table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="statedrelationship.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat statedrelationship.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load text definition table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load text definition table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="textdefinition.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat textdefinition.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load association table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load association table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="association.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat association.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load attribute value table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load attribute value table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="attributevalue.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat attributevalue.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load simple refset table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load simple refset table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="simple.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat simple.log >> oracle.log fi +## Load TC table +if [ $ef -ne 1 ]; then +echo " Load transitive closure table ... `/bin/date`" | tee -a oracle.log +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="transitiveclosure.ctl" >> oracle.log 2>&1 +if [ $? -ne 0 ]; then ef=1; fi +cat concept.log >> oracle.log +fi + # No more complex maps # if [ $ef -ne 1 ]; then # echo " Load complex map table data ... `/bin/date`" >> oracle.log 2>&1 @@ -117,68 +131,68 @@ fi # fi if [ $ef -ne 1 ]; then -echo " Load extended map table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load extended map table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="extendedmap.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat extendedmap.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load simple map table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load simple map table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="simplemap.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat simplemap.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load language table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load language table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="language.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat language.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load refset descriptor table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load refset descriptor table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="refsetdescriptor.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat refsetdescriptor.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load description type table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load description type table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="descriptiontype.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat descriptiontype.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load module dependency table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load module dependency table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="moduledependency.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat moduledependency.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Create indexes ... `/bin/date`" >> oracle.log 2>&1 +echo " Create indexes ... `/bin/date`" | tee -a oracle.log echo "@oracle_indexes.sql"|$ORACLE_HOME/bin/sqlplus $user/$password@$tns_name >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi if [ $ef -ne 1 ]; then -echo " Create views ... `/bin/date`" >> oracle.log 2>&1 +echo " Create views ... `/bin/date`" | tee -a oracle.log echo "@oracle_views.sql"|$ORACLE_HOME/bin/sqlplus $user/$password@$tns_name >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi -echo "----------------------------------------" >> oracle.log 2>&1 +echo "----------------------------------------" | tee -a oracle.log if [ $ef -eq 1 ] then - echo "There were one or more errors." >> oracle.log 2>&1 + echo "There were one or more errors." | tee -a oracle.log retval=-1 else - echo "Completed without errors." >> oracle.log 2>&1 + echo "Completed without errors." | tee -a oracle.log retval=0 fi -echo "Finished ... `/bin/date`" >> oracle.log 2>&1 -echo "----------------------------------------" >> oracle.log 2>&1 +echo "Finished ... `/bin/date`" | tee -a oracle.log +echo "----------------------------------------" | tee -a oracle.log exit $retval diff --git a/src/main/resources/rf2/populate_postgres_db.bat b/src/main/resources/rf2/populate_postgres_db.bat deleted file mode 100644 index 23a1811..0000000 --- a/src/main/resources/rf2/populate_postgres_db.bat +++ /dev/null @@ -1,54 +0,0 @@ -:: -:: Database connection parameters -:: Please edit these variables to reflect your environment -:: -set psql=C:/PostgreSQL/pg96/bin/psql.exe -set PGHOST=localhost -set PGUSER=postgres -set PGPASSWORD= -set PGDATABASE=snomed - -del postgres.log -echo. > postgres.log -echo ---------------------------------------- >> postgres.log 2>&1 -echo Starting ... >> postgres.log 2>&1 -date /T >> postgres.log 2>&1 -time /T >> postgres.log 2>&1 -echo ---------------------------------------- >> postgres.log 2>&1 -echo psql = %psql% >> postgres.log 2>&1 -echo user = %PGUSER% >> postgres.log 2>&1 -echo db_name = %PGDATABASE% >> postgres.log 2>&1 -set error=0 - -echo Create and load tables >> postgres.log 2>&1 -"%psql%" < psql_tables.sql >> postgres.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1 -goto trailer) - -echo Create indexes >> postgres.log 2>&1 -"%psql%" < psql_indexes.sql >> postgres.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1 -goto trailer) - -echo Create views >> postgres.log 2>&1 -"%psql%" < psql_views.sql >> postgres.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1 -goto trailer) - -:trailer -echo ---------------------------------------- >> postgres.log 2>&1 -IF %error% NEQ 0 ( -echo There were one or more errors. Please reference the postgres.log file for details. >> postgres.log 2>&1 -set retval=-1 -) else ( -echo Completed without errors. >> postgres.log 2>&1 -set retval=0 -) -echo Finished ... >> postgres.log 2>&1 -date /T >> postgres.log 2>&1 -time /T >> postgres.log 2>&1 -echo ---------------------------------------- >> postgres.log 2>&1 - -pause -exit %retval% - diff --git a/src/main/resources/rf2/populate_postgres_db.sh b/src/main/resources/rf2/populate_postgres_db.sh index db25a83..e20198e 100644 --- a/src/main/resources/rf2/populate_postgres_db.sh +++ b/src/main/resources/rf2/populate_postgres_db.sh @@ -2,13 +2,8 @@ # # Database connection parameters -# Please edit these variables to reflect your environment -# - Tested with docker postgres 10, 11, 12, 13 (using docker postgres server and client) -# - PGHOST=host.docker.internal -# - Tested on Windows with "Git Bash" as a shell -# - and psql in the path -# -export PGHOST=localhost +# PLEASE EDIT THESE VARIABLES TO REFLECT YOUR ENVIRONMENT +export PGHOST=[UPDATE] export PGUSER=postgres export PGPASSWORD= export PGDATABASE=snomed @@ -19,37 +14,46 @@ ef=0 echo "See postgres.log for output" -echo "----------------------------------------" >> postgres.log 2>&1 -echo "Starting ... `/bin/date`" >> postgres.log 2>&1 -echo "----------------------------------------" >> postgres.log 2>&1 -echo "user = $PGUSER" >> postgres.log 2>&1 -echo "db_name = $PGDATABASE" >> postgres.log 2>&1 +echo "----------------------------------------" | tee -a postgres.log +echo "Starting ... `/bin/date`" | tee -a postgres.log +echo "----------------------------------------" | tee -a postgres.log +echo "user = $PGUSER" | tee -a postgres.log +echo "db_name = $PGDATABASE" | tee -a postgres.log + +DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +echo " Compute transitive closure relationship file ... `/bin/date`" | tee -a postgres.log +relFile=$(find $DIR/Snapshot/Terminology/ -name "*_Relationship_Snapshot_*.txt" -print -quit) +$DIR/compute_transitive_closure.pl --force --noself $relFile >> postgres.log 2>&1 +if [ $? -ne 0 ]; then ef=1; fi -echo " Create and load tables ... `/bin/date`" >> postgres.log 2>&1 +if [ $ef -ne 1 ]; then +echo " Create and load tables ... `/bin/date`" | tee -a postgres.log psql < psql_tables.sql >> postgres.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi +fi if [ $ef -ne 1 ]; then -echo " Create indexes ... `/bin/date`" >> postgres.log 2>&1 +echo " Create indexes ... `/bin/date`" | tee -a postgres.log psql < psql_indexes.sql >> postgres.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi if [ $ef -ne 1 ]; then -echo " Create views ... `/bin/date`" >> postgres.log 2>&1 +echo " Create views ... `/bin/date`" | tee -a postgres.log psql < psql_views.sql >> postgres.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi -echo "----------------------------------------" >> postgres.log 2>&1 +echo "----------------------------------------" | tee -a postgres.log if [ $ef -eq 1 ] then - echo "There were one or more errors." >> postgres.log 2>&1 + echo "There were one or more errors." | tee -a postgres.log retval=-1 else - echo "Completed without errors." >> postgres.log 2>&1 + echo "Completed without errors." | tee -a postgres.log retval=0 fi -echo "Finished ... `/bin/date`" >> postgres.log 2>&1 -echo "----------------------------------------" >> postgres.log 2>&1 +echo "Finished ... `/bin/date`" | tee -a postgres.log +echo "----------------------------------------" | tee -a postgres.log exit $retval diff --git a/src/main/resources/rf2/psql_tables.sql b/src/main/resources/rf2/psql_tables.sql index 07d1757..79726ff 100644 --- a/src/main/resources/rf2/psql_tables.sql +++ b/src/main/resources/rf2/psql_tables.sql @@ -151,7 +151,7 @@ CREATE TABLE textdefinition ( FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (conceptId) REFERENCES concept(id), FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (caseSignificanceId) REFERENCES concept(id) + FOREIGN KEY (caseSignificanceId) REFERENCES concept(id) ); \copy textdefinition FROM 'Snapshot/Terminology/sct2_TextDefinition_Snapshot-en_${editionLabel}_${editionVersion}.txt' WITH DELIMITER E'\t' QUOTE E'\\' ENCODING 'UTF8' CSV HEADER; @@ -447,3 +447,16 @@ CREATE TABLE moduledependency ( ); \copy moduledependency FROM 'Snapshot/Refset/Metadata/der2_ssRefset_ModuleDependencySnapshot_${editionLabel}_${editionVersion}.txt' WITH DELIMITER E'\t' QUOTE E'\\' ENCODING 'UTF8' CSV HEADER; + +-- Transitive closure table. +DROP TABLE IF EXISTS transitiveclosure CASCADE; +CREATE TABLE transitiveclosure ( + superTypeId NUMERIC(20) NOT NULL, + subTypeId NUMERIC(20) NOT NULL, + depth INT NOT NULL, + PRIMARY KEY (superTypeId, subTypeId), + FOREIGN KEY (superTypeId) REFERENCES concept(id), + FOREIGN KEY (subTypeId) REFERENCES concept(id) +); + +\copy transitiveclosure FROM 'Snapshot/Terminology/sct2_TransitiveClosure_Snapshot_${editionLabel}_${editionVersion}.txt' WITH DELIMITER E'\t' QUOTE E'\\' ENCODING 'UTF8' CSV HEADER; diff --git a/src/main/resources/rf2/psql_views.sql b/src/main/resources/rf2/psql_views.sql index 3234ded..066ade4 100644 --- a/src/main/resources/rf2/psql_views.sql +++ b/src/main/resources/rf2/psql_views.sql @@ -1,4 +1,3 @@ - -- Concept Preferred Name view, used by other views. -- 900000000000013009 = Synonym description type -- 900000000000548007 = Preferred @@ -7,222 +6,294 @@ DROP VIEW IF EXISTS conceptpreferredname; CREATE VIEW conceptpreferredname AS SELECT c.id conceptId, NULLIF(d.term, 'no active preferred synonym') preferredName, d.id descriptionId FROM concept c -LEFT OUTER JOIN description d -ON c.id = d.conceptId -AND d.active = TRUE -AND d.typeId = 900000000000013009 -LEFT OUTER JOIN language l -ON d.id = l.referencedComponentId -AND l.active = TRUE -AND l.acceptabilityId = 900000000000548007 -AND l.refSetId = 900000000000509007 + LEFT OUTER JOIN description d + ON c.id = d.conceptId + AND d.active = TRUE + AND d.typeId = 900000000000013009 + LEFT OUTER JOIN language l + ON d.id = l.referencedComponentId + AND l.active = TRUE + AND l.acceptabilityId = 900000000000548007 + AND l.refSetId = 900000000000509007 WHERE (l.acceptabilityId IS NOT null OR d.TERM IS null); -- Concept table with names. DROP VIEW IF EXISTS conceptwithnames; CREATE VIEW conceptwithnames AS -SELECT id, cpn1.preferredName idName, effectiveTime, active, - moduleId, cpn2.preferredName moduleIdName, - definitionStatusId, cpn3.preferredName definitionStatusIdName +SELECT id, + cpn1.preferredName idName, + effectiveTime, + active, + moduleId, + cpn2.preferredName moduleIdName, + definitionStatusId, + cpn3.preferredName definitionStatusIdName FROM concept, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE id = cpn1.conceptId -AND moduleId = cpn2.conceptId -AND definitionStatusId = cpn3.conceptId; + AND moduleId = cpn2.conceptId + AND definitionStatusId = cpn3.conceptId; -- Description table. DROP VIEW IF EXISTS descriptionwithnames; CREATE VIEW descriptionwithnames AS -SELECT id, term, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - d.conceptId, cpn2.preferredName conceptIdName, - languageCode, - typeId, cpn3.preferredName typeIdName, - caseSignificanceId, cpn4.preferredName caseSignificanceIdName +SELECT id, + term, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + d.conceptId, + cpn2.preferredName conceptIdName, + languageCode, + typeId, + cpn3.preferredName typeIdName, + caseSignificanceId, + cpn4.preferredName caseSignificanceIdName FROM description d, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4 -WHERE moduleId = cpn1.conceptId AND d.conceptId = cpn2.conceptId AND typeId = cpn3.conceptId AND caseSignificanceId = cpn4.conceptId; + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4 +WHERE moduleId = cpn1.conceptId + AND d.conceptId = cpn2.conceptId + AND typeId = cpn3.conceptId + AND caseSignificanceId = cpn4.conceptId; -- Identifier table. DROP VIEW IF EXISTS identifierwithnames; CREATE VIEW identifierwithnames AS -SELECT identifierSchemeId, cpn1.preferredName identifierSchemeIdName, - alternateIdentifier, effectiveTime, active, - moduleId, cpn2.preferredName moduleIdName, - referencedComponentId +SELECT identifierSchemeId, + cpn1.preferredName identifierSchemeIdName, + alternateIdentifier, + effectiveTime, + active, + moduleId, + cpn2.preferredName moduleIdName, + referencedComponentId FROM identifier, - conceptpreferredname cpn1, - conceptpreferredname cpn2 + conceptpreferredname cpn1, + conceptpreferredname cpn2 WHERE identifierSchemeId = cpn1.conceptId -AND moduleId = cpn2.conceptId; + AND moduleId = cpn2.conceptId; -- Relationship table. DROP VIEW IF EXISTS relationshipwithnames; CREATE VIEW relationshipwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - sourceId, cpn2.preferredName sourceIdName, - destinationId, cpn3.preferredName destinationIdName, - relationshipGroup, - typeId, cpn4.preferredName typeIdName, - characteristicTypeId, cpn5.preferredName characteristicTypeIdName, - modifierId, cpn6.preferredName modifierIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + sourceId, + cpn2.preferredName sourceIdName, + destinationId, + cpn3.preferredName destinationIdName, + relationshipGroup, + typeId, + cpn4.preferredName typeIdName, + characteristicTypeId, + cpn5.preferredName characteristicTypeIdName, + modifierId, + cpn6.preferredName modifierIdName from relationship, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4, - conceptpreferredname cpn5, - conceptpreferredname cpn6 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4, + conceptpreferredname cpn5, + conceptpreferredname cpn6 WHERE moduleId = cpn1.conceptId -AND sourceId = cpn2.conceptId -AND destinationId = cpn3.conceptId -AND typeId = cpn4.conceptId -AND characteristicTypeId = cpn5.conceptId -AND modifierId = cpn6.conceptId; + AND sourceId = cpn2.conceptId + AND destinationId = cpn3.conceptId + AND typeId = cpn4.conceptId + AND characteristicTypeId = cpn5.conceptId + AND modifierId = cpn6.conceptId; -- Relationship concrete values table. DROP VIEW IF EXISTS relationshipconcretevalueswithnames; CREATE VIEW relationshipconcretevalueswithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - sourceId, cpn2.preferredName sourceIdName, - value, relationshipGroup, - typeId, cpn4.preferredName typeIdName, - characteristicTypeId, cpn5.preferredName characteristicTypeIdName, - modifierId, cpn6.preferredName modifierIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + sourceId, + cpn2.preferredName sourceIdName, + value, + relationshipGroup, + typeId, + cpn4.preferredName typeIdName, + characteristicTypeId, + cpn5.preferredName characteristicTypeIdName, + modifierId, + cpn6.preferredName modifierIdName from relationshipconcretevalues, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn4, - conceptpreferredname cpn5, - conceptpreferredname cpn6 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn4, + conceptpreferredname cpn5, + conceptpreferredname cpn6 WHERE moduleId = cpn1.conceptId -AND sourceId = cpn2.conceptId -AND typeId = cpn4.conceptId -AND characteristicTypeId = cpn5.conceptId -AND modifierId = cpn6.conceptId; + AND sourceId = cpn2.conceptId + AND typeId = cpn4.conceptId + AND characteristicTypeId = cpn5.conceptId + AND modifierId = cpn6.conceptId; -- OWL Expression table DROP VIEW IF EXISTS owlexpressionwithnames; CREATE VIEW owlexpressionwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - owlExpression +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + owlExpression from owlexpression, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- Stated Relationship table. DROP VIEW IF EXISTS statedrelationshipwithnames; CREATE VIEW statedrelationshipwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - sourceId, cpn2.preferredName sourceIdName, - destinationId, cpn3.preferredName destinationIdName, - relationshipGroup, - typeId, cpn4.preferredName typeIdName, - characteristicTypeId, cpn5.preferredName characteristicTypeIdName, - modifierId, cpn6.preferredName modifierIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + sourceId, + cpn2.preferredName sourceIdName, + destinationId, + cpn3.preferredName destinationIdName, + relationshipGroup, + typeId, + cpn4.preferredName typeIdName, + characteristicTypeId, + cpn5.preferredName characteristicTypeIdName, + modifierId, + cpn6.preferredName modifierIdName from statedrelationship, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4, - conceptpreferredname cpn5, - conceptpreferredname cpn6 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4, + conceptpreferredname cpn5, + conceptpreferredname cpn6 WHERE moduleId = cpn1.conceptId -AND sourceId = cpn2.conceptId -AND destinationId = cpn3.conceptId -AND typeId = cpn4.conceptId -AND characteristicTypeId = cpn5.conceptId -AND modifierId = cpn6.conceptId; + AND sourceId = cpn2.conceptId + AND destinationId = cpn3.conceptId + AND typeId = cpn4.conceptId + AND characteristicTypeId = cpn5.conceptId + AND modifierId = cpn6.conceptId; -- Text Definition table. DROP VIEW IF EXISTS textdefinitionwithnames; CREATE VIEW textdefinitionwithnames AS -SELECT id, term, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - td.conceptId, cpn2.preferredName conceptIdName, - languageCode, - typeId, cpn3.preferredName typeIdName, - caseSignificanceId, cpn4.preferredName caseSignificanceIdName +SELECT id, + term, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + td.conceptId, + cpn2.preferredName conceptIdName, + languageCode, + typeId, + cpn3.preferredName typeIdName, + caseSignificanceId, + cpn4.preferredName caseSignificanceIdName from textdefinition td, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4 WHERE moduleId = cpn1.conceptId -AND td.conceptId = cpn2.conceptId -AND typeId = cpn3.conceptId -AND caseSignificanceId = cpn4.conceptId; + AND td.conceptId = cpn2.conceptId + AND typeId = cpn3.conceptId + AND caseSignificanceId = cpn4.conceptId; -- Association refset table. DROP VIEW IF EXISTS associationwithnames; CREATE VIEW associationwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - targetComponent, cpn4.preferredName targetComponentName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + targetComponent, + cpn4.preferredName targetComponentName from association, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId -AND targetComponent = cpn4.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId + AND targetComponent = cpn4.conceptId; -- Attribute Value refset table. DROP VIEW IF EXISTS attributevaluewithnames; CREATE VIEW attributevaluewithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, REPLACE(cpn3.preferredName, 'no active preferred synonym', 'no such concept') referencedComponentIdName, - valueId, cpn4.preferredName valueIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + REPLACE(cpn3.preferredName, 'no active preferred synonym', 'no such concept') referencedComponentIdName, + valueId, + cpn4.preferredName valueIdName FROM attributevalue -LEFT OUTER JOIN conceptpreferredname cpn3 ON referencedComponentId = cpn3.conceptId -INNER JOIN conceptpreferredname cpn1 ON moduleId = cpn1.conceptId -INNER JOIN conceptpreferredname cpn2 ON refsetId = cpn2.conceptId -INNER JOIN conceptpreferredname cpn4 ON valueId = cpn4.conceptId; + LEFT OUTER JOIN conceptpreferredname cpn3 ON referencedComponentId = cpn3.conceptId + INNER JOIN conceptpreferredname cpn1 ON moduleId = cpn1.conceptId + INNER JOIN conceptpreferredname cpn2 ON refsetId = cpn2.conceptId + INNER JOIN conceptpreferredname cpn4 ON valueId = cpn4.conceptId; -- Simple refset table. DROP VIEW IF EXISTS simplewithnames; CREATE VIEW simplewithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName FROM simple, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- No more complex map, ICD9CM maps deprecated @@ -253,202 +324,282 @@ AND referencedComponentId = cpn3.conceptId; -- Extended Map refset table. DROP VIEW IF EXISTS extendedmapwithnames; CREATE VIEW extendedmapwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - mapGroup, - mapPriority, - mapRule, - mapAdvice, - mapTarget, - correlationId, cpn4.preferredName correlationIdName, - mapCategoryId, cpn5.preferredName mapCategoryIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + mapGroup, + mapPriority, + mapRule, + mapAdvice, + mapTarget, + correlationId, + cpn4.preferredName correlationIdName, + mapCategoryId, + cpn5.preferredName mapCategoryIdName FROM extendedmap, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4, - conceptpreferredname cpn5 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4, + conceptpreferredname cpn5 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId -AND correlationId = cpn4.conceptId -AND mapCategoryId = cpn5.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId + AND correlationId = cpn4.conceptId + AND mapCategoryId = cpn5.conceptId; -- Simple Map refset table. DROP VIEW IF EXISTS simplemapwithnames; CREATE VIEW simplemapwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - mapTarget +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + mapTarget FROM simplemap, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- Language refset table. DROP VIEW IF EXISTS languagewithnames; CREATE VIEW languagewithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - acceptabilityId, cpn4.preferredName acceptabilityIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + acceptabilityId, + cpn4.preferredName acceptabilityIdName FROM language, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.descriptionId -AND acceptabilityId = cpn4.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.descriptionId + AND acceptabilityId = cpn4.conceptId; -- Refset Descriptor refset table. DROP VIEW IF EXISTS refsetdescriptorwithnames; CREATE VIEW refsetdescriptorwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - attributeDescription, attributeType, attributeOrder +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + attributeDescription, + attributeType, + attributeOrder FROM refsetdescriptor, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- Description Type refset table. DROP VIEW IF EXISTS descriptiontypewithnames; CREATE VIEW descriptiontypewithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - descriptionFormat, descriptionLength +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + descriptionFormat, + descriptionLength FROM descriptiontype, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- MRCM Attribute Domain refset table. DROP VIEW IF EXISTS mrcmattributedomainwithnames; CREATE VIEW mrcmattributedomainwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - domainId, cpn4.preferredName domainIdName, - grouped, attributeCardinality, attributeInGroupCardinality, - ruleStrengthId, cpn4.preferredName ruleStrengthIdName, - contentTypeId, cpn4.preferredName contentTypeIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + domainId, + cpn4.preferredName domainIdName, + grouped, + attributeCardinality, + attributeInGroupCardinality, + ruleStrengthId, + cpn4.preferredName ruleStrengthIdName, + contentTypeId, + cpn4.preferredName contentTypeIdName FROM mrcmattributedomain, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4, - conceptpreferredname cpn5, - conceptpreferredname cpn6 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4, + conceptpreferredname cpn5, + conceptpreferredname cpn6 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId -AND domainId = cpn4.conceptId -AND ruleStrengthId = cpn5.conceptId -AND contentTypeId = cpn6.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId + AND domainId = cpn4.conceptId + AND ruleStrengthId = cpn5.conceptId + AND contentTypeId = cpn6.conceptId; -- MRCM Module Scope refset table. DROP VIEW IF EXISTS mrcmmodulescopewithnames; CREATE VIEW mrcmmodulescopewithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - mrcmRuleRefsetId, cpn4.preferredName mrcmRuleRefsetIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + mrcmRuleRefsetId, + cpn4.preferredName mrcmRuleRefsetIdName FROM mrcmmodulescope, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId -AND mrcmRuleRefsetId = cpn4.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId + AND mrcmRuleRefsetId = cpn4.conceptId; -- MRCM Attribute Range refset table. DROP VIEW IF EXISTS mrcmattributerangewithnames; CREATE VIEW mrcmattributerangewithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - rangeConstraint, attributeRule, - ruleStrengthId, cpn4.preferredName ruleStrengthIdName, - contentTypeId, cpn4.preferredName contentTypeIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + rangeConstraint, + attributeRule, + ruleStrengthId, + cpn4.preferredName ruleStrengthIdName, + contentTypeId, + cpn4.preferredName contentTypeIdName FROM mrcmattributerange, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4, - conceptpreferredname cpn5 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4, + conceptpreferredname cpn5 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId -AND ruleStrengthId = cpn4.conceptId -AND contentTypeId = cpn5.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId + AND ruleStrengthId = cpn4.conceptId + AND contentTypeId = cpn5.conceptId; + - -- MRCM Domain refset table. DROP VIEW IF EXISTS mrcmdomainwithnames; CREATE VIEW mrcmdomainwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - domainConstraint, parentDomain, - proximalPrimitiveConstraint, proximalPrimitiveRefinement, - domainTemplateForPrecoordination, - domainTemplateForPostcoordination, - guideURL +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + domainConstraint, + parentDomain, + proximalPrimitiveConstraint, + proximalPrimitiveRefinement, + domainTemplateForPrecoordination, + domainTemplateForPostcoordination, + guideURL FROM mrcmdomain, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- Module Dependency refset table. DROP VIEW IF EXISTS moduledependencywithnames; CREATE VIEW moduledependencywithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - sourceEffectiveTime, targetEffectiveTime +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + sourceEffectiveTime, + targetEffectiveTime FROM moduledependency, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; - + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; + +-- transitive closure table with names +-- NOTE: this assumes conceptpreferredname has already been created +-- via the standard RF2 load scripts +DROP VIEW IF EXISTS transitiveclosurewithnames; +CREATE VIEW transitiveclosurewithnames AS +SELECT superTypeId, cpn1.preferredName superTypeName, + subTypeId, cpn2.preferredName subTypeName, a.depth +FROM transitiveclosure a, + conceptpreferredname cpn1, + conceptpreferredname cpn2 +WHERE a.superTypeId = cpn1.conceptId + AND a.subTypeId = cpn2.conceptId; diff --git a/src/main/resources/rf2/transitiveclosure.ctl b/src/main/resources/rf2/transitiveclosure.ctl new file mode 100644 index 0000000..9f587d5 --- /dev/null +++ b/src/main/resources/rf2/transitiveclosure.ctl @@ -0,0 +1,16 @@ +options (skip=1,direct=true) +load data +characterset UTF8 length semantics char +infile 'Snapshot/Terminology/sct2_TransitiveClosure_Snapshot_${editionLabel}_${editionVersion}.txt' "str X'0d0a'" +badfile 'transitiveclosure.bad' +discardfile 'transitiveclosure.dsc' +insert +into table transitiveclosure +reenable disabled_constraints +fields terminated by X'09' +trailing nullcols +( + superTypeId INTEGER EXTERNAL, + subTypeId INTEGER EXTERNAL, + depth INTEGER EXTERNAL +) \ No newline at end of file diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 5f4021d..44fc0f7 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -12,25 +12,25 @@ https://www.westcoastinformatics.com/products/db-load-scripts -- US Edition September 1: -Fall is upon us! Announcing #SNOMEDCT DB load and transitive -closure scripts for the 20230901 US Edition! Out-of-the-box +Spring is upon us! Announcing #SNOMEDCT DB load and transitive +closure scripts for the 20240301 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #MakingSnomedEasy #snomed https://www.westcoastinformatics.com/products/db-load-scripts ---- -Is it January already?! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20240101 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +Spring is upon us! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20240301 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/products/db-load-scripts #MakingTerminologyEasy #MakingSnomedEasy #snomedct This freely available solution enables one to load their #SQL database with the latest editions of #SNOMED. ### UMLS Users Mailing List -Subject: 20240101 SNOMEDCT DB load and transitive closure scripts +Subject: 20240301 SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the Jan 01, 2024 update of the SNOMEDCT INT Edition. +NLM recently posted the March 01, 2024 update of the SNOMEDCT US Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. diff --git a/src/test/resources/README-check-files.txt b/src/test/resources/README-check-files.md similarity index 73% rename from src/test/resources/README-check-files.txt rename to src/test/resources/README-check-files.md index 0182bb8..5f1ef76 100644 --- a/src/test/resources/README-check-files.txt +++ b/src/test/resources/README-check-files.md @@ -1,7 +1,11 @@ -# With a new download of SNOMED international edition or US edition, check that the file list -# still matches what we are loading. +# Check Files +With a new download of SNOMED international edition or US edition, check that the file list still matches what we are loading. -# Look for extra files (this should return zero rows) +## Look for extra files +- International Edition will return a 2, but these two files only contain 1 header file +- US Edition should return 0 + +``` find . -name "*txt" | grep -v Refset_Association | grep -v Refset_AttributeValue | grep -v Refset_SimpleSn |\ grep -v Refset_Language | grep -v Refset_ExtendedMap | grep -v Refset_SimpleMap |\ grep -v Refset_RefsetDescriptor | grep -v Refset_DescriptionType |\ @@ -11,8 +15,11 @@ find . -name "*txt" | grep -v Refset_Association | grep -v Refset_AttributeValue grep -v sct2_Identifier | grep -v sct2_Relationship_ | grep -v Refset_OWLExpression |\ grep -v sct2_StatedRelationship | grep -v sct2_TextDefinition |\ grep -v sct2_RelationshipConcreteValues | wc -l +``` -# Look that all files are there (this should equal 21) +## Look that all files are there +- Both editions should return 21 +``` find . -name "*txt" |\ perl -ne 'print if /Refset_Association|AttributeValue|Refset_SimpleSn/; \ print if /Refset_Language|Refset_ExtendedMap|Refset_SimpleMap/; \ @@ -21,5 +28,5 @@ find . -name "*txt" |\ print if /Refset_MRCMAttributeRange|Refset_ModuleDependency/; \ print if /Refset_MRCMDomain|sct2_Concept|sct2_Description/; \ print if /sct2_Identifier|sct2_Relationship(ConcreteValues)?_|Refset_OWLExpression/; \ - print if /sct2_StatedRelationship|sct2_TextDefinition/; \ - print if /sct2_TransitiveClosure/' | wc -l + print if /sct2_StatedRelationship|sct2_TextDefinition/' | wc -l +``` \ No newline at end of file diff --git a/src/test/resources/README-mysql-docker.md b/src/test/resources/README-mysql-docker.md new file mode 100644 index 0000000..982589d --- /dev/null +++ b/src/test/resources/README-mysql-docker.md @@ -0,0 +1,63 @@ +# BUILD INSTRUCTIONS +## Pre-requisites +Before proceeding, make sure you updated the hostname in the load script. + +## File Setup +``` + cd /wci/data + unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-mysql.*.zip + + sudo chmod +x rf2/populate_mysql_db.sh + sudo chmod +x rf2/compute_transitive_closure.pl + sudo chmod +x rf2/compute_transitive_closure.py + +``` +Follow the instructions for the version you are using below. + +### MySQL 8.0 + +1. Launch the container
+`docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mysql:8.0 --local_infile=ON` + + +2. Build Server +``` + export dir=/wci/data/ + cd $dir + docker run -it -v $dir:/data mysql:8.0 /bin/bash + + root@842bfb3da1f1:/# cd /data/rf2 + root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh +``` + +### MySQL 8.3 + +1. Launch the container
+ `docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mysql:8.3 --local_infile=ON` + + +2. Build Server +``` + export dir=/wci/data/ + cd $dir + docker run -it -v $dir:/data mysql:8.3 /bin/bash + + root@842bfb3da1f1:/# cd /data/rf2 + root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh +``` + +TODO: CHECK THE VERSION FOR MARIADB +### MariaDB - 10.11 +1. Launch the container
+`docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mariadb:10.11` + + +2. Build Server +``` + export dir=/wci/data/ + cd $dir + docker run -it -v $dir:/data mariadb:10.11 /bin/bash + + root@842bfb3da1f1:/# cd /data/rf2 + root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh +``` \ No newline at end of file diff --git a/src/test/resources/README-mysql-docker.txt b/src/test/resources/README-mysql-docker.txt deleted file mode 100644 index 57ec330..0000000 --- a/src/test/resources/README-mysql-docker.txt +++ /dev/null @@ -1,101 +0,0 @@ - -##### File Setup WINDOWS - -* Download the SNOMED distribution from NLM -* Unpack to c:/data/SnomedCT_International (for international edition) -* Unpack to c:/data/SnomedCT_US (for US edition) -* Clone and build these projects - * git@github.com:WestCoastInformatics/SNOMED-DB-Load-Scripts.git - * git@github.com:WestCoastInformatics/SNOMED-CT-Transitive-Closure.git -* Open the target/snomed*-mysql*zip file -* Copy the contents of the "rf2" directory to folder where SNOMED data is unpacked (see above) - -##### File Setup LINUX (BUILD SERVER) - -cd /wci/data -unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-mysql.*.zip -unzip -o /wci/projects/SNOMED-CT-Transitive-Closure/target/snomed-transitive-closure-mysql.*.zip -sudo chmod +x rf2/populate_mysql_db.sh -sudo chmod +x rf2/populate_mysql_db_tc.sh - -##### MySQL 5.7 - -# -# For testing mysql, run a docker mysql instance -# - https://hub.docker.com/_/mysql - -# -# Launch the container -# -docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mysql:5.7 - -# WINDOWS git bash (to simulate running in Linux) -# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) -dir=C:/data -docker run -it -v "$dir":/data mysql:5.7 /bin/bash -root@842bfb3da1f1:/# cd /data/SnomedCT_International -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh - - -# LINUX (BUILD SERVER) -# host = 172.17.0.1 (**make sure to edit this setting before proceeding) -export dir=/wci/data/ -cd $dir -docker run -it -v $dir:/data mysql:5.7 /bin/bash - -root@842bfb3da1f1:/# cd /data/rf2 -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh - -##### MySQL 8.0 - -# -# Launch the container -# -docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mysql:8.0 --local_infile=ON - -# WINDOWS git bash (to simulate running in Linux) -# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) -dir=C:/data -docker run -it -v "$dir":/data mysql:8.0 /bin/bash -root@842bfb3da1f1:/# cd /data/SnomedCT_International -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh - -# LINUX (BUILD SERVER) -# host = 172.17.0.1 (**make sure to edit this setting before proceeding) -export dir=/wci/data/ -cd $dir -docker run -it -v $dir:/data mysql:8.0 /bin/bash - -root@842bfb3da1f1:/# cd /data/rf2 -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh - -##### MariaDB - 10.11 - -# -# Launch the container -# -docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mariadb:10.11 - -# WINDOWS git bash (to simulate running in Linux) -# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) -dir=C:/data -docker run -it -v "$dir":/data mariadb:10.11 /bin/bash -root@842bfb3da1f1:/# cd /data/SnomedCT_International -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh - - -# LINUX (BUILD SERVER) -# host = 172.17.0.1 (**make sure to edit this setting before proceeding) -export dir=/wci/data/ -cd $dir -docker run -it -v $dir:/data mariadb:10.11 /bin/bash - -root@842bfb3da1f1:/# cd /data/rf2 -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh - diff --git a/src/test/resources/README-oracle-docker.md b/src/test/resources/README-oracle-docker.md new file mode 100644 index 0000000..74b22bd --- /dev/null +++ b/src/test/resources/README-oracle-docker.md @@ -0,0 +1,68 @@ +# Oracle 12c BUILD INSTRUCTIONS +## Prerequisites +1. Log into DockerHub and agree to Oracle's Terms of Service + - [Oracle DB Enterprise Repository](https://container-registry.oracle.com/ords/f?p=113:1:103153009327673::::FSP_LANGUAGE_PREFERENCE:&cs=3vvrLolDIFGAxz-ReKVoNrPBwhCCJtGRffMagNzTnvafG3AeKT2KLWKQSclqKpS-c6TF2uprvjENxXOETZOmgfQ) + - Log in with your account and then click on "Continue" on the line enterprise. This will allow you to pull the Oracle Database Enterprise Edition image from the Oracle Container Registry. + - Pull the image from the Oracle Container Registry + - `docker login container-registry.oracle.com` and enter your hub.docker.com credentials + - `docker pull container-registry.oracle.com/database/enterprise:12.2.0.1-slim` + - `docker pull container-registry.oracle.com/database/enterprise:12.1.0.2` +2. For testing oracle, run a docker oracle instance + - https://dzone.com/articles/oracle-12c-image-installation-in-docker + +3. If you're running this locally, you will use `localhost` as the host. If you're running this on a remote server, + you will use the server's IP address as the host. + +4. If running an Oracle Database Docker Container on Linux use docker login and enter your hub.docker.com + credentials for image to download. + +# Instructions + +## File Setup +``` + cd /wci/data + unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-oracle.*.zip + sudo chmod +x rf2/populate_oracle_db.sh + sudo chmod +x rf2/compute_transitive_closure.py + + # To avoid permission issues, make sure to grant write perms to the all folders + chmod -R 777 rf2 +``` + +## If not running Docker as root +``` + cd $dir/rf2 + touch oracle.log concept.log description.log identifier.log relationship.log owlexpression.log statedrelationship.log textdefinition.log association.log attributevalue.log simple.log complexmap.log extendedmap.log simplemap.log language.log refsetdescriptor.log descriptiontype.log moduledependency.log relationshipconcretevalues.log + chmod a=rw oracle.log concept.log description.log identifier.log relationship.log owlexpression.log statedrelationship.log textdefinition.log association.log attributevalue.log simple.log complexmap.log extendedmap.log simplemap.log language.log refsetdescriptor.log descriptiontype.log moduledependency.log relationshipconcretevalues.log +``` + +## Launch the container +Create log files and allow read/write to all users. +``` + export dir=/wci/data/ + cd $dir + + #For store/oracle/database-enterprise:12.2.0.1-slim + sudo docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 container-registry.oracle.com/database/enterprise:12.2.0.1-slim + + #For container-registry.oracle.com/database/enterprise:12.1.0.2 + sudo docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 container-registry.oracle.com/database/enterprise:12.1.0.2 +``` +## Populate DB + +1. Launch the container + +`sudo docker exec -it snomed-oracle /bin/bash` + +2. Populate the database +``` + root@842bfb3da1f1:/# . /home/oracle/.bashrc + root@842bfb3da1f1:/# sqlplus sys/Oradoc_db1 as sysdba + alter session set "_ORACLE_SCRIPT"=true; + create user snomed identified by snomed; + GRANT CONNECT, RESOURCE, DBA TO snomed; + exit + + root@842bfb3da1f1:/# cd /data/rf2 + root@842bfb3da1f1:/data/rf2# ./populate_oracle_db.sh +``` diff --git a/src/test/resources/README-oracle-docker.txt b/src/test/resources/README-oracle-docker.txt deleted file mode 100644 index 094ea45..0000000 --- a/src/test/resources/README-oracle-docker.txt +++ /dev/null @@ -1,88 +0,0 @@ - -##### File Setup WINDOWS - -* Download the SNOMED distribution from NLM -* Unpack to c:/data/SnomedCT_International (for international edition) -* Unpack to c:/data/SnomedCT_US (for US edition) -* Clone and build these projects - * git@github.com:WestCoastInformatics/SNOMED-DB-Load-Scripts.git - * git@github.com:WestCoastInformatics/SNOMED-CT-Transitive-Closure.git -* Open the target/snomed*-oracle*zip file -* Copy the contents of the "rf2" directory to folder where SNOMED data is unpacked (see above) - -##### File Setup LINUX (BUILD SERVER) - -cd /wci/data -unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-oracle.*.zip -sudo chmod +x rf2/populate_oracle_db.sh -sudo chmod +x rf2/populate_oracle_db_tc.sh - -##### Oracle 12c - -# Prerequisites -# - Log into DockerHub and agree to Oracle's Terms of Service -# - https://hub.docker.com/_/oracle-database-enterprise-edition?tab=description (Click "Proceed to checkout") -# -# For testing oracle, run a docker oracle instance -# - https://dzone.com/articles/oracle-12c-image-installation-in-docker -# -# If running an Oracle Database Docker Container on Linux use docker login and enter your hub.docker.com -# credentials for image to download. -# - -# -# Launch the container WINDOWS -# -dir=C:/data -cd %dir% -docker run --name snomed-oracle -v %dir%:/data -d --rm -p 8080:8080 -p 1521:1521 store/oracle/database-enterprise:12.2.0.1-slim - - -# -# If not running Docker as root LINUX (BUILD SERVER) -# -cd $dir/rf2 -touch oracle.log concept.log description.log identifier.log relationship.log owlexpression.log statedrelationship.log textdefinition.log association.log attributevalue.log simple.log complexmap.log extendedmap.log simplemap.log language.log refsetdescriptor.log descriptiontype.log moduledependency.log relationshipconcretevalues.log -chmod a=rw oracle.log concept.log description.log identifier.log relationship.log owlexpression.log statedrelationship.log textdefinition.log association.log attributevalue.log simple.log complexmap.log extendedmap.log simplemap.log language.log refsetdescriptor.log descriptiontype.log moduledependency.log relationshipconcretevalues.log - -# -# Create log files and allow read/write to all users. -# Launch the container LINUX (BUILD SERVER) -# -export dir=/wci/data/ -cd $dir - -#For store/oracle/database-enterprise:12.2.0.1-slim -sudo docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 store/oracle/database-enterprise:12.2.0.1-slim - -#For container-registry.oracle.com/database/enterprise:12.1.0.2 -sudo docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 container-registry.oracle.com/database/enterprise:12.1.0.2 - -# -# populate_oracle_db.sh, populate_oracle_db_tc.sh -# -# Launch the container -# -sudo docker exec -it snomed-oracle /bin/bash - -root@842bfb3da1f1:/# . /home/oracle/.bashrc -root@842bfb3da1f1:/# sqlplus sys/Oradoc_db1 as sysdba -alter session set "_ORACLE_SCRIPT"=true; -create user snomed identified by snomed; -GRANT CONNECT, RESOURCE, DBA TO snomed; -exit - -root@842bfb3da1f1:/# cd /data/rf2 -root@842bfb3da1f1:/data/rf2# ./populate_oracle_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_oracle_db_tc.sh - -# -# Connect to Oracle database to query tables -# Skip docker exec command if still connected from prior step -# - -sudo docker exec -it snomed-oracle /bin/bash -root@842bfb3da1f1:/# . /home/oracle/.bashrc -root@842bfb3da1f1:/# sqlplus snomed/snomed@ORCLCDB - - diff --git a/src/test/resources/README-postgres-docker.md b/src/test/resources/README-postgres-docker.md new file mode 100644 index 0000000..b73b346 --- /dev/null +++ b/src/test/resources/README-postgres-docker.md @@ -0,0 +1,72 @@ +# BUILD INSTRUCTIONS +## Pre-requisites +Before proceeding, make sure you updated the PGHOST in the load script. + +## File Setup +``` + cd /wci/data + unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-postgres.*.zip + sudo chmod +x rf2/populate_postgres_db.sh + sudo chmod +x rf2/compute_transitive_closure.pl +``` + +* For testing postgres, run a docker postgres instance - https://hub.docker.com/_/postgres + +### Postgres 12.15 +1. Launch the container
+`docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:12.15` + + +2. Build Server +``` + export dir=/wci/data/ + cd $dir + docker run -it -v "$dir":/data postgres:12.15 /bin/bash + + root@842bfb3da1f1:/# cd /data/rf2 + root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh +``` + +### Postgres 13.11 +1. Launch the container
+`docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:13.11` + +2. Build Server +``` + export dir=/wci/data/ + cd $dir + docker run -it -v "$dir":/data postgres:13.11 /bin/bash + + root@842bfb3da1f1:/# cd /data/rf2 + root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh +``` + +### Postgres 14.8 +1. Launch the container
+`docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:14.8` + + +2. Build Server +``` + export dir=/wci/data/ + cd $dir + docker run -it -v "$dir":/data postgres:14.8 /bin/bash + + root@842bfb3da1f1:/# cd /data/rf2 + root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh +``` + +### Postgres 15.3 +1. Launch the container
+`docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:15.3` + + +2. Build Server +``` + export dir=/wci/data/ + cd $dir + docker run -it -v "$dir":/data postgres:15.3 /bin/bash + + root@842bfb3da1f1:/# cd /data/rf2 + root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh +``` \ No newline at end of file diff --git a/src/test/resources/README-postgres-docker.txt b/src/test/resources/README-postgres-docker.txt deleted file mode 100644 index f331e7f..0000000 --- a/src/test/resources/README-postgres-docker.txt +++ /dev/null @@ -1,125 +0,0 @@ - -##### File Setup WINDOWS - -* Download the SNOMED distribution from NLM -* Unpack to c:/data/SnomedCT_International (for international edition) -* Unpack to c:/data/SnomedCT_US (for US edition) -* Clone and build these projects - * git@github.com:WestCoastInformatics/SNOMED-DB-Load-Scripts.git - * git@github.com:WestCoastInformatics/SNOMED-CT-Transitive-Closure.git -* Open the target/snomed*-postgres*zip file -* Copy the contents of the "rf2" directory to folder where SNOMED data is unpacked (see above) -* Go to that directory and run transitive_closure.sh/bat to generate the transitive closure file - -##### File Setup LINUX (BUILD SERVER) - -cd /wci/data -unzip -o /wci/projects/SNOMED-CT-Transitive-Closure/target/snomed-transitive-closure-postgres.*.zip -unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-postgres.*.zip -sudo chmod +x rf2/populate_postgres_db.sh -sudo chmod +x rf2/populate_postgres_db_tc.sh - -# -# For testing postgres, run a docker postgres instance -# - https://hub.docker.com/_/postgres -# - -##### Postgres 12.15 -# -# Launch the container -# -docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:12.15 - -# WINDOWS git bash (to simulate running in Linux) -# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) -dir=C:/data -docker run -it -v "$dir":/data postgres:12.15 /bin/bash -root@842bfb3da1f1:/# cd /data/SnomedCT_International -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh - -# LINUX (BUILD SERVER) -# export PGHOST=172.17.0.1 (**make sure to edit this setting before proceeding) -export dir=/wci/data/ -cd $dir -docker run -it -v "$dir":/data postgres:12.15 /bin/bash - -root@842bfb3da1f1:/# cd /data/rf2 -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh - - -##### Postgres 13.11 -# -# Launch the container -# -docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:13.11 - -# WINDOWS git bash (to simulate running in Linux) -# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) -dir=C:/data -docker run -it -v "$dir":/data postgres:13.11 /bin/bash -root@842bfb3da1f1:/# cd /data/SnomedCT_International -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh - -# LINUX (BUILD SERVER) -# export PGHOST=172.17.0.1 (**make sure to edit this setting before proceeding) -export dir=/wci/data/ -cd $dir -docker run -it -v "$dir":/data postgres:13.11 /bin/bash - -root@842bfb3da1f1:/# cd /data/rf2 -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh - - -##### Postgres 14.8 -# -# Launch the container -# -docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:14.8 - -# WINDOWS git bash (to simulate running in Linux) -# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) -dir=C:/data -docker run -it -v "$dir":/data postgres:14.8 /bin/bash -root@842bfb3da1f1:/# cd /data/SnomedCT_International -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh - -# LINUX (BUILD SERVER) -# export PGHOST=172.17.0.1 (**make sure to edit this setting before proceeding) -export dir=/wci/data/ -cd $dir -docker run -it -v "$dir":/data postgres:14.8 /bin/bash - -root@842bfb3da1f1:/# cd /data/rf2 -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh - - - -##### Postgres 15.3 -# -# Launch the container -# -docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:15.3 - -# WINDOWS git bash (to simulate running in Linux) -# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) -dir=C:/data -docker run -it -v "$dir":/data postgres:15.3 /bin/bash -root@842bfb3da1f1:/# cd /data/SnomedCT_International -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh - -# LINUX (BUILD SERVER) -# export PGHOST=172.17.0.1 (**make sure to edit this setting before proceeding) -export dir=/wci/data/ -cd $dir -docker run -it -v "$dir":/data postgres:15.3 /bin/bash - -root@842bfb3da1f1:/# cd /data/rf2 -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh From e70c2ff0959c875e16cf1f9eb1390ea5d572cff5 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Wed, 6 Mar 2024 14:16:31 -0800 Subject: [PATCH 69/95] Update the Load Scripts (#1) (#2) Co-authored-by: Alicia G <32443614+gaaliciA1990@users.noreply.github.com> --- .gitignore | 5 + README.md | 27 +- pom.xml | 2 +- src/main/assembly/tc.xml | 39 + src/main/resources/HOWTO.md | 42 ++ src/main/resources/HOWTO.txt | 45 -- src/main/resources/{README.txt => README.md} | 14 +- .../rf2/compute_transitive_closure.pl | 313 ++++++++ .../rf2/compute_transitive_closure.py | 268 +++++++ src/main/resources/rf2/mysql_tables.sql | 618 ++++++++------- src/main/resources/rf2/mysql_views.sql | 12 + src/main/resources/rf2/oracle_tables.sql | 600 +++++++-------- src/main/resources/rf2/oracle_views.sql | 551 ++++++++------ src/main/resources/rf2/populate_mysql_db.bat | 51 -- src/main/resources/rf2/populate_mysql_db.sh | 60 +- src/main/resources/rf2/populate_oracle_db.bat | 163 ---- src/main/resources/rf2/populate_oracle_db.sh | 94 ++- .../resources/rf2/populate_postgres_db.bat | 54 -- .../resources/rf2/populate_postgres_db.sh | 44 +- src/main/resources/rf2/psql_tables.sql | 15 +- src/main/resources/rf2/psql_views.sql | 707 +++++++++++------- src/main/resources/rf2/transitiveclosure.ctl | 16 + src/test/resources/README-announcements.txt | 10 +- ...-check-files.txt => README-check-files.md} | 19 +- src/test/resources/README-mysql-docker.md | 63 ++ src/test/resources/README-mysql-docker.txt | 101 --- src/test/resources/README-oracle-docker.md | 68 ++ src/test/resources/README-oracle-docker.txt | 88 --- src/test/resources/README-postgres-docker.md | 72 ++ src/test/resources/README-postgres-docker.txt | 125 ---- 30 files changed, 2485 insertions(+), 1801 deletions(-) create mode 100644 src/main/assembly/tc.xml create mode 100644 src/main/resources/HOWTO.md delete mode 100644 src/main/resources/HOWTO.txt rename src/main/resources/{README.txt => README.md} (63%) create mode 100644 src/main/resources/rf2/compute_transitive_closure.pl create mode 100644 src/main/resources/rf2/compute_transitive_closure.py delete mode 100644 src/main/resources/rf2/populate_mysql_db.bat delete mode 100644 src/main/resources/rf2/populate_oracle_db.bat delete mode 100644 src/main/resources/rf2/populate_postgres_db.bat create mode 100644 src/main/resources/rf2/transitiveclosure.ctl rename src/test/resources/{README-check-files.txt => README-check-files.md} (73%) create mode 100644 src/test/resources/README-mysql-docker.md delete mode 100644 src/test/resources/README-mysql-docker.txt create mode 100644 src/test/resources/README-oracle-docker.md delete mode 100644 src/test/resources/README-oracle-docker.txt create mode 100644 src/test/resources/README-postgres-docker.md delete mode 100644 src/test/resources/README-postgres-docker.txt diff --git a/.gitignore b/.gitignore index e39c14a..818c15f 100644 --- a/.gitignore +++ b/.gitignore @@ -214,3 +214,8 @@ pip-log.txt #Mr Developer .mr.developer.cfg /target + +################# +## IntelliJ +################# +.idea \ No newline at end of file diff --git a/README.md b/README.md index f5cdf4a..8069108 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,39 @@ SNOMED CT DATABASE LOAD SCRIPTS =============================== -Scripts to create and populate a MySQL, Postgres, or Oracle database with a -SNOMED CT terminology release in RF2. +Scripts to build a transitive closure table from an RF2, snapshot, +inferred SNOMED CT relationships file, create and populate a MySQL, +Postgres, or Oracle database with a SNOMED CT terminology release in RF2. To download a package built for the latest US or International edition, visit https://www.westcoastinformatics.com/products/db-load-scripts +*New feature: a "depth" flag is now computed as well where 0 means "self", +1 means "child", and >1 means "non-child descendant". This enables asking +queries about "child of", "descendant of", and "descendant or self of". + Minimum Specification --------------------- -- MySQL v5.7.+, MySQL v8.+, MariaDB 10.+, MariaDB 11.+ +- MySQL v8.+, MariaDB 10.+, MariaDB 11.+ - MySQL v8 requires the server to run with "--local_infile=ON" - Oracle v12.+ -- Postgres v12.+, v13.+, v14.+, v15.+, v16.+ +- Postgres v13.+, v14.+, v15.+, v16.+ + +Prerequisites +------------- +If loading transitive closure table into a database, first load SNOMED in RF2 +using the database load scripts you can also find at the URL above. This is +important because it creates a view that allows for denormalization of preferred +concept names, thus making the transitive closure table more useful. Installation ------------ -* See [HOWTO.txt](src/main/resources/HOWTO.txt) file to understand how to load the rf2 files into the database - +* See [HOWTO.md](src/main/resources/HOWTO.md) file to understand how to load the rf2 files into the database See Also -------- * [src/main/resources/LICENSE.txt](src/main/resources/LICENSE.txt) -* [src/main/resources/README.txt](src/main/resources/README.txt) -* [src/main/resources/HOWTO.txt](src/main/resources/HOWTO.txt) +* [src/main/resources/README.md](src/main/resources/README.md) +* [src/main/resources/HOWTO.md](src/main/resources/HOWTO.md) TODO ---- diff --git a/pom.xml b/pom.xml index 9fe58d3..3ae5e66 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ US - 20230901 + 20240301 National US1000124 diff --git a/src/main/assembly/tc.xml b/src/main/assembly/tc.xml new file mode 100644 index 0000000..683dc1f --- /dev/null +++ b/src/main/assembly/tc.xml @@ -0,0 +1,39 @@ + + tc + / + + zip + + + + src/main/resources + / + + rf1/** + **/*mysql* + **/*oracle* + **/*.ctl + + true + keep + + + + + + target/classes + /rf2 + + **/*class + + false + + + src/main/java + /rf2 + + + diff --git a/src/main/resources/HOWTO.md b/src/main/resources/HOWTO.md new file mode 100644 index 0000000..efec336 --- /dev/null +++ b/src/main/resources/HOWTO.md @@ -0,0 +1,42 @@ +# How To Use the SNOMED CT Database Loader +This HOWTO describes how to use the installer scripts to load SNOMEDCT into a database. + +## Installation +1. Download the database loader zip file from the https://www.westcoastinformatics.com/products/db-load-scripts website. Select the appropriate database-version pair (i.e. oracle-US Edition). Depending on your database and edition, identify the appropriate target's zip file. + +2. Unzip the contents of the zip file into a 'data' folder + +3. Download the SNOMED CT Release files in ZIP format. US Users can find the files here: + * [SNOMED CT® US Edition Release Files](https://www.nlm.nih.gov/healthit/snomedct/us_edition.html) + * [SNOMED CT® International Edition Release Files](https://www.nlm.nih.gov/healthit/snomedct/international.html) + +4. Open the desired zip file and extract the 'Snapshot' folder into the 'data/rf2' folder. Once completed: + * The 'data' folder's content will include: + - 'rf2' folder + - HOWTO.md + - LICENSE.txt + - README.md + * The 'data/rf2' folder's contents will include: + - 'Snapshot' folder + - *.sql files + - *.ctl files (for oracle only) + - one *.sh file + +5. In a text editor, open the temp-folder's appropriate "populate" script as defined by your database. + * For example: + - For MySQL (or MariaDB), use the "populate_mysql_db.sh" script + - For Postgres, use the "populate_postgres_db.sh" script + - For Oracle, use the "populate_oracle_db.sh" script + * Configure settings at the top of the "populate" script for your environment + - use your host's IP address or hostname + - user is your database's username + - password is your database's password + - tns_name or db_name is the database's schema which is to be populated + +6. Create the database schema as defined in step #5 + + * NOTE: postgres supports only db-level character encoding, so make sure to create your database using: `WITH ENCODING 'UTF-8'` + + +7. Execute the "populate" script + * Note: a complete log file will appear as `mysql.log`, `postgres.log`, or `oracle.log` diff --git a/src/main/resources/HOWTO.txt b/src/main/resources/HOWTO.txt deleted file mode 100644 index cdcd226..0000000 --- a/src/main/resources/HOWTO.txt +++ /dev/null @@ -1,45 +0,0 @@ -This HOWTO describes how to use the installer scripts to load SNOMED into a database. - -Installation ------------- -1. Download the database loader zip file from the http://www.westcoastinformatics.com/resources.html website. Select the appropriate database-version pair (i.e. oracle-US Edition). Depending on your database and edition, identify the appropriate target's zip file. - -2. Unzip the contents of the zip file into a 'data' folder - -3. Download the SNOMED CT Release files in ZIP format. US Users can find the files here: - * SNOMED CT® US Edition Release Files: https://www.nlm.nih.gov/healthit/snomedct/us_edition.html - * SNOMED CT® International Edition Release Files: https://www.nlm.nih.gov/healthit/snomedct/international.html - -4. Open the desired zip file and extract the 'Snapshot' folder into the 'data/rf2' folder. Once completed: - * The 'data' folder's content will include: - - 'rf2' folder - - HOWTO.txt - - LICENSE.txt - - README.txt - * The 'data/rf2' folder's contents will include: - - 'Snapshot' folder - - *.sql files - - *.ctl files (for oracle only) - - one *.bat file - - one *.sh file - -5. In a text editor, open the temp-folder's appropriate "populate" script in a text editor as defined by your platform and database. - * For example: - - For MySQL (or MariadB) on Windows, use the "populate_mysql_db.bat" script - - For Postgres on Windows, use the "populate_postgres_db.bat" script - - For Oracle on Windows, use the "populate_oracle_db.bat" script - - For MySQL (or MariaDB) on Linux/Unix/MacOS, use the "populate_mysql_db.sh" script - - For Postgres on Linux/Unix/MacOS, use the "populate_postgres_db.sh" script - - For Oracle on Linux/Unix/MacOS, use the "populate_oracle_db.sh" script - * Configure settings at the top of the "populate" script for your environment - - user is your database's username - - password is your database's password - - tns_name or db_name is the database's schema which is to be populated - -6. Create the database schema as defined in step #5 - - * NOTE: postgres supports only db-level character encoding, so make sure to create your database using: WITH ENCODING 'UTF-8' - - -7. Execute the "populate" script - * Note: a complete log file will appear as "mysql.log", "postgres.log", or "oracle.log" diff --git a/src/main/resources/README.txt b/src/main/resources/README.md similarity index 63% rename from src/main/resources/README.txt rename to src/main/resources/README.md index f57052c..cad555c 100644 --- a/src/main/resources/README.txt +++ b/src/main/resources/README.md @@ -1,20 +1,20 @@ +# Welcome to DB Load Scripts Welcome to SNOMED CT MySQL, Postgres, and Oracle Database Load Scripts https://www.westcoastinformatics.com/products/db-load-scripts Go to the above link for documentation, and additional downloads. -Important Notes ---------------- +## Important Notes * These database load scripts are configured to work with the ${editionVersion} SNOMEDCT ${editionLabel} Edition. -Key Features ------------- +## Key Features * Support for Oracle, Postgres, and MySQL (and MariaDB) * Support for RF2 data format * Denormalization of concept/description ids for contextualized lookup +* Builds transitive closure table from RF2 snapshot, inferred, SNOMEDCT file. +* Views with denormalized concept preferred names -Developer Notes ---------------- -https://github.com/bcarlsenca/SNOMED-DB-Load-Scripts.git +### Developer Notes +https://github.com/WestCoastInformatics/SNOMED-DB-Load-Scripts diff --git a/src/main/resources/rf2/compute_transitive_closure.pl b/src/main/resources/rf2/compute_transitive_closure.pl new file mode 100644 index 0000000..195db15 --- /dev/null +++ b/src/main/resources/rf2/compute_transitive_closure.pl @@ -0,0 +1,313 @@ +#!/usr/bin/perl +# Copyright 2024 West Coast Informatics, Inc +# +# Computes transitive closure from a snapshot inferred RF2 relationships file. +# +use strict vars; + +# +# Set Defaults & Environment +# +our $badargs; +our $badvalue; +our $isaRel = "116680003"; +our $root = "138875005"; +our $history = ""; +our $force = 0; +our $self = 1; + +# +# Check options +# +our @ARGS=(); +while (@ARGV) { + my $arg = shift(@ARGV); + if ($arg !~ /^-/) { + push @ARGS, $arg; + next; + } + if ($arg eq "--history-min") { + $history = "min"; + next; + } elsif ($arg eq "--history-mod") { + $history = "mod"; + next; + } elsif ($arg eq "--history-max") { + $history = "max"; + next; + } elsif ($arg eq "--noself") { + $self = 0; + next; + } elsif ($arg eq "--force") { + $force = 1; + next; + } elsif ($arg eq "--help") { + &PrintHelp; + exit(0); + } else { + $badargs = 1; + $badvalue = $arg; + } +} + +# +# Handle parameters +# +if (scalar(@ARGS) != 1) { + $badargs = 3; + $badvalue = scalar(@ARGS); +} +our ($relsFile) = @ARGS; +our $outputFile = "$relsFile"; +$outputFile =~ s/_Relationship_/_TransitiveClosure_/; + +# Check output file +if (-e "$outputFile") { + if ($force) { + unlink $outputFile; + } else { + die "Output file already exists: $outputFile. Check this is not an old file\n"; + } +} + +# Check history file +our $historyFile = ""; +if ($history) { + # Attempt to find the Association refset + $historyFile = "$relsFile"; + $historyFile =~ s/sct2_Relationship_/der2_cRefset_Association/; + if ($historyFile =~ /^der2/) { + $historyFile =~ s/^/..\/Refset\/Content\//; + } elsif ($historyFile =~ /Terminology/) { + $historyFile =~ s/Terminology/Refset\/Content/; + } else { + die "Unable to determine path to Association refset file from relationships file = $relsFile\n"; + } + if (! -e $historyFile) { + die "Computed path to Association refset file does not exist = $historyFile\n"; + } +} + + +# +# Write any arg errors +# +our %errors = (1 => "Illegal switch: $badvalue", + 2 => "Illegal service: $badvalue", + 3 => "Bad number of arguments: $badvalue", + 4 => "$badvalue must be set"); +if ($badargs) { + &PrintUsage; + print "\n$errors{$badargs}\n"; + exit(1); +} + +# +# Begin +# +print "------------------------------------------------------------\n"; +print "Starting ...", scalar(localtime),"\n"; +print "------------------------------------------------------------\n"; +print "Isa rel : $isaRel\n"; +print "Rels file : $relsFile\n"; +print "Self : $self\n"; +print "Output file : $outputFile\n"; +if ($history) { + print "History : $history\n"; + print "History file : $historyFile\n"; +} +print "\n"; + +# +# Load PAR/CHD relationships map. +# +print " Load PAR/CHD rels ...".(scalar(localtime))."\n"; +our %codes = (); +our %parChd = (); +our %seen = (); +our $eol = "\n"; +initRelationships($relsFile, $historyFile); + +# +# Write transitive closure file +# +print " Write transitive closure table ...".(scalar(localtime))."\n"; +our $OUT; +open ($OUT, ">$outputFile") || die "Could not open $outputFile: $! $?\n"; +print $OUT "superTypeId\tsubTypeId\tdepth$eol"; +our $code; +our $ct = 0; +foreach $code (keys %codes) { + # skip root + next if $code eq $root; + $ct++; + + # short circuit for leaf nodes + if (!$parChd{$code} && $self) { + print $OUT "$code\t$code\t0$eol"; + } + + # otherwise, gather descendants + else { + %seen = (); + my %descs = getDescendants($code, 1); + my $desc; + foreach $desc (keys %descs) { + if (!$self && !($descs{$desc}-1)) { + next; + } + print $OUT "$code\t$desc\t".($descs{$desc}-1)."$eol"; + } + } + + if ($ct % 10000 == 0) { + print " $ct codes processed ...", scalar(localtime),"\n"; + } +} +close($OUT); + +# +# Finish +# +print "------------------------------------------------------------\n"; +print "finished ...", scalar(localtime),"\n"; +print "------------------------------------------------------------\n"; + +exit 0; + + +######################### LOCAL PROCEDURES ####################### + +# +# Print the usage +# +sub PrintUsage { + + print qq{ +Usage: compute-transitive-closure.pl [--help] [--force] [--history-{min,mod,max}] + e.g. compute-transitive-closure.pl --history-min --noself +}; +} + +# +# Print help info +# +sub PrintHelp { + &PrintUsage; + print qq{ + Parameters + relsFile: A snapshot inferred RF2 relationships file + Options: + --force : If output file already exists, remove it and proceed + --history-min: Add historical relationships to support ECL HISTORY-MIN profile + --history-mod: Add historical relationships to support ECL HISTORY-MOD profile + --history-max: Add historical relationships to support ECL HISTORY-MAX profile + --help: On-line help + +}; +} + +# +# Initialize relationships hashes +# +sub initRelationships { + my($relsFile, $historyFile) = @_; + my $IN; + open ($IN, "<$relsFile") || die "Failed to open $relsFile: $! $?\n"; + my $ct = 1; + # iterate through rels file + while (<$IN>) { + chop; + if (/\r$/) { + s/\r//; + $eol = "\r\n"; + } + my ($id, $effectiveTime, $active, $moduleId, $sourceId, $destinationId, + $relationshipGroup, $typeId, $characteristicTypeId, $modifierId) = split /\t/; + + # skip inactive or non-isa rels + next unless $typeId eq $isaRel; + next unless $active; + $ct++; + + # push new child for parent + push @{$parChd{$destinationId}}, $sourceId; + $codes{$sourceId} = 1; + $codes{$destinationId} = 1; + } + print " $ct relationships loaded\n"; + close($IN); + + # Load appropriate history relationships + if ($history) { + + $ct = 0; + our %qual = (); + if ($history eq "min") { + $qual{"900000000000527005"} = 1; + } elsif ($history eq "mod") { + $qual{"900000000000527005"} = 1; + $qual{"900000000000526001"} = 1; + $qual{"900000000000528000"} = 1; + $qual{"1186924009"} = 1; + } + open ($IN, "<$historyFile") || die "Failed to open $historyFile: $! $?\n"; + my $ct = 0; + # iterate through history file + while (<$IN>) { + chop; s/\r//; + + my ($id, $effectiveTime, $active, $moduleId, $refsetId, + $referencedComponentId, $targetComponentId) = split /\t/; + + # skip unless the refsetId represents a qualifying historical association + next unless $history eq "max" || $qual{$refsetId}; + # skip inactive + next unless $active; + # skip if the targetComponentId isn't one of the codes (to avoid moved_to/from stuff) + next unless $codes{$targetComponentId}; + + $ct++; + + # push new child (inactive concept) for parent (active concept) + push @{$parChd{$targetComponentId}}, $referencedComponentId; + $codes{$referencedComponentId} = 1; + } + print " $ct historical relationships loaded\n"; + close($IN); + } +} + +# +# Get descendants of a root +# Input: root id +# Output: array of descendant ids +# +sub getDescendants { + my($par, $depth) = @_; + + # if we've seen this node already, children are accounted for - bail + if ($seen{$par}) { return (); } + $seen{$par} = 1; + + # Add an entry for this concept + my %descendants = (); + $descendants{$par} = $depth; + + # Get Children of this node + my @chd = @{$parChd{$par}}; + + # If this is a leaf node, bail + return %descendants if scalar(@chd) == 0; + + # Iterate through children, mark as descendant and recursively call + foreach my $chd (@chd) { + my %chddesc = getDescendants($chd, $depth+1); + # merge child descendants with the current descendants list. + foreach my $desc ( keys %chddesc) { + $descendants{"$desc"} = $chddesc{$desc}; + } + } + + return %descendants; +} \ No newline at end of file diff --git a/src/main/resources/rf2/compute_transitive_closure.py b/src/main/resources/rf2/compute_transitive_closure.py new file mode 100644 index 0000000..e511bc1 --- /dev/null +++ b/src/main/resources/rf2/compute_transitive_closure.py @@ -0,0 +1,268 @@ +#!/usr/bin/python +# Copyright 2024 West Coast Informatics, Inc +# +# Computes transitive closure from a snapshot inferred RF2 relationships file. +# + +import sys +import os +import csv +import glob +import argparse +import time +import logging + +# +# Set Defaults & Environment +# +isaRel = "116680003" +root = "138875005" +history = "" +force = False +self = True +codes = {} +parChd = {} +seen = {} + +# Set up logging +logging.basicConfig(level=logging.DEBUG) + +# Define the errors dictionary globally +errors = { + 1: "Illegal switch: ", + 2: "Illegal service: ", + 3: "Bad number of arguments: ", + 4: "{} must be set" +} + +## Custom help action for handling --help argparse option +class HelpAction(argparse.Action): + def __init__(self, option_strings, dest, nargs=0, **kwargs): + super(HelpAction, self).__init__(option_strings, dest, nargs=nargs, **kwargs) + + def __call__(self, parser, namespace, values, option_string=None): + print_help() + parser.exit() + +## Function to parse arguments +def parse_args(): + parser = argparse.ArgumentParser(add_help=False) + parser.add_argument('--history', choices=['min', 'mod', 'max']) + parser.add_argument('--force', action='store_true') + parser.add_argument('--noself', action='store_true') + parser.add_argument('relsFile') + parser.add_argument('--help', action=HelpAction) # Add the custom --help option + + try: + args = parser.parse_args() + except SystemExit: + badargs = errors[3] + print(badargs + args) + exit(1) + + # Check if the arguments are valid + if not args.relsFile: # Check if relsFile is provided + badargs = errors[4].format("relsFile") + elif args.history and args.history not in ['min', 'mod', 'max']: # Check if history is one of the allowed values + badargs = errors[1] + args.history + else: + badargs = None + + # Check for argument errors + if badargs: + print_usage() + print("\n{}".format(badargs)) + exit(1) + + return parser.parse_args() + +## Function to initialize relationships +def initRelationships(relsFile, historyFile): + global codes, parChd + try: + # Read relationships + with open(relsFile, 'r') as f: + reader = csv.reader(f, delimiter='\t') + ct = 1 + # iterate through rels file + for row in reader: + id, effectiveTime, active, moduleId, sourceId, destinationId, relationshipGroup, typeId, characteristicTypeId, modifierId = row + # skip inactive or non-isa relationships + if typeId != isaRel or not active: + continue + ct += 1 + + # push new child for parent + if destinationId not in parChd: + parChd[destinationId] = [] + parChd[destinationId].append(sourceId) + codes[sourceId] = 1 + codes[destinationId] = 1 + pass + except IOError as e: + logging.error("Failed to open {}: {}".format(relsFile, e)) + exit(1) + + # Load appropriate history relationships + if history: + ct = 0 + qual = {} + if history == "min": + qual = {"900000000000527005": 1} + elif history == "mod": + qual = {"900000000000527005": 1, "900000000000526001": 1, "900000000000528000": 1, "1186924009": 1} + + with open(historyFile, 'r') as IN: + for line in IN: + line = line.rstrip('\r\n') + + id, effectiveTime, active, moduleId, refsetId, referencedComponentId, targetComponentId = line.split('\t') + + # skip unless the refsetId represents a qualifying historical association + if not (history == "max" or refsetId in qual): + continue + # skip inactive + if not active: + continue + # skip if the targetComponentId isn't one of the codes (to avoid moved_to/from stuff) + if targetComponentId not in codes: + continue + + ct += 1 + + # push new child (inactive concept) for parent (active concept) + if targetComponentId not in parChd: + parChd[targetComponentId] = [] + parChd[targetComponentId].append(referencedComponentId) + codes[referencedComponentId] = 1 + + logging.info(" {} historical relationships loaded".format(ct)) + + + +## Function to get descendants +def getDescendants(par, depth): + global seen + # If parent has been seen, return empty dictionary + if par in seen: + return {} + + seen[par] = 1 + descendants = {par: depth} + + # If parent has children, get their descendants + if par in parChd: + for chd in parChd[par]: + descendants.update(getDescendants(chd, depth+1)) + return descendants + +## Function to print help +def print_help(parser=None, namespace=None, values=None, option_strings=None, dest=None): + print_usage() + + help_text = """ + Parameters: + relsFile: A snapshot inferred RF2 relationships file + Options: + --force: If output file already exists, remove it and proceed + --history-{min,mod,max}: Add historical relationships to support ECL HISTORY-{MIN,MOD,MAX} profile + --help: On-line help + """ + print(help_text) + sys.exit(0) # Exit the program + +## Function to print usage +def print_usage(): + print(""" +Usage: compute_transitive_closure.py [--help] [--force] [--history-{min,mod,max}] + e.g. compute_transitive_closure.py --history-min --noself +""") + +## Main function +def main(): + global badargs, ct + args = parse_args() + force = args.force + self = not args.noself + relsFile = args.relsFile + history = args.history + outputFile = relsFile.replace("_Relationship_", "_TransitiveClosure_") + # initialize ct + ct = 0 + + # Check history file + historyFile = "" + if history: + # Attempt to find the Association refset + historyFile = relsFile.replace("sct2_Relationship_", "der2_cRefset_Association") + if historyFile.startswith("der2"): + historyFile = "../Refset/Content/" + historyFile + elif "Terminology" in historyFile: + historyFile = historyFile.replace("Terminology", "Refset/Content") + else: + raise Exception("Unable to determine path to Association refset file from relationships file = {}".format(relsFile)) + if not os.path.exists(historyFile): + raise Exception("Computed path to Association refset file does not exist = {}".format(historyFile)) + + # Check if output file already exists + if os.path.exists(outputFile): + if force: + os.remove(outputFile) + else: + logging.warning("Output file already exists: {}".format(outputFile)) + exit(1) + + # Start processing + print("------------------------------------------------------------") + print("Starting ...", time.asctime()) + print("------------------------------------------------------------") + print("Isa rel : ", isaRel) + print("Rels file : ", relsFile) + print("Self : ", self) + print("Output file : ", outputFile) + if history: + print("History : ", history) + print("History file : ", historyFile) + print("\n") + + # Load PAR/CHD relationships map + print(" Load PAR/CHD rels ...", time.asctime()) + global codes, parChd, seen + codes = {} + parChd = {} + seen = {} + # Initialize relationships + initRelationships(relsFile, "") + + # Write transitive closure to output file + print(" Write transitive closure table ...", time.asctime()) + with open(outputFile, 'w') as f: + writer = csv.writer(f, delimiter='\t') + writer.writerow(["superTypeId", "subTypeId", "depth"]) + for code in codes.keys(): + # skip root + if code == root: + ct += 1 + continue + # short circuit for leaf nodes + if code not in parChd and self: + writer.writerow([code, code, 0]) + # gather descendants + else: + descendants = getDescendants(code, 1) + for desc, depth in descendants.items(): + if not self and not (depth-1): + continue + writer.writerow([code, desc, depth-1]) + + if ct % 10000 == 0: + logging.info(" {} codes processed ...".format(ct), time.asctime()) + + print("------------------------------------------------------------") + print("finished ...", time.asctime()) + print("------------------------------------------------------------\n") + + +## Run main function +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/src/main/resources/rf2/mysql_tables.sql b/src/main/resources/rf2/mysql_tables.sql index 79af434..525577c 100644 --- a/src/main/resources/rf2/mysql_tables.sql +++ b/src/main/resources/rf2/mysql_tables.sql @@ -7,17 +7,19 @@ SET FOREIGN_KEY_CHECKS = 0; -- Concept file. DROP TABLE IF EXISTS concept; -CREATE TABLE concept ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, +CREATE TABLE concept +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, definitionStatusId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (definitionStatusId) REFERENCES concept(id) + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (definitionStatusId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_Concept_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE concept LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Terminology/sct2_Concept_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE concept LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@definitionStatusId) SET id = @id, effectiveTime = @effectiveTime, @@ -28,23 +30,25 @@ definitionStatusId = @definitionStatusId; -- Description file. DROP TABLE IF EXISTS description; -CREATE TABLE description ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - conceptId NUMERIC(20) NOT NULL, - languageCode CHAR(2) NOT NULL, - typeId NUMERIC(20) NOT NULL, - term VARCHAR(255) NOT NULL, - caseSignificanceId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (conceptId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (caseSignificanceId) REFERENCES concept(id) +CREATE TABLE description +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + conceptId NUMERIC(20) NOT NULL, + languageCode CHAR(2) NOT NULL, + typeId NUMERIC(20) NOT NULL, + term VARCHAR(255) NOT NULL, + caseSignificanceId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (conceptId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (caseSignificanceId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_Description_Snapshot-en_${editionLabel}_${editionVersion}.txt' INTO TABLE description LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Terminology/sct2_Description_Snapshot-en_${editionLabel}_${editionVersion}.txt' INTO TABLE description LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@conceptId,@languageCode,@typeId,@term,@caseSignificanceId) SET id = @id, effectiveTime = @effectiveTime, @@ -59,17 +63,19 @@ caseSignificanceId=@caseSignificanceId; -- Identifier file. DROP TABLE IF EXISTS identifier; -CREATE TABLE identifier ( - identifierSchemeId NUMERIC(20) NOT NULL, - alternateIdentifier VARCHAR(255) NOT NULL, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - referencedComponentId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id) +CREATE TABLE identifier +( + identifierSchemeId NUMERIC(20) NOT NULL, + alternateIdentifier VARCHAR(255) NOT NULL, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_Identifier_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE identifier LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Terminology/sct2_Identifier_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE identifier LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@identifierSchemeId,@alternateIdentifier,@effectiveTime,@active,@moduleId,@referencedComponentId) SET identifierSchemeId = @identifierSchemeId, alternateIdentifier = @alternateIdentifier, @@ -81,26 +87,28 @@ referencedComponentId = @referencedComponentId; -- Relationship file. DROP TABLE IF EXISTS relationship; -CREATE TABLE relationship ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - sourceId NUMERIC(20) NOT NULL, - destinationId NUMERIC(20) NOT NULL, - relationshipGroup INT UNSIGNED NOT NULL, - typeId NUMERIC(20) NOT NULL, +CREATE TABLE relationship +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + destinationId NUMERIC(20) NOT NULL, + relationshipGroup INT UNSIGNED NOT NULL, + typeId NUMERIC(20) NOT NULL, characteristicTypeId NUMERIC(20) NOT NULL, - modifierId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (sourceId) REFERENCES concept(id), - FOREIGN KEY (destinationId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (characteristicTypeId) REFERENCES concept(id), - FOREIGN KEY (modifierId) REFERENCES concept(id) + modifierId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (sourceId) REFERENCES concept (id), + FOREIGN KEY (destinationId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (characteristicTypeId) REFERENCES concept (id), + FOREIGN KEY (modifierId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_Relationship_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE relationship LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Terminology/sct2_Relationship_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE relationship LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@sourceId,@destinationId,@relationshipGroup,@typeId,@characteristicTypeId,@modifierId) SET id = @id, effectiveTime = @effectiveTime, @@ -115,25 +123,27 @@ modifierId = @modifierId; -- Relationship concrete values file. DROP TABLE IF EXISTS relationshipconcretevalues; -CREATE TABLE relationshipconcretevalues ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - sourceId NUMERIC(20) NOT NULL, - value VARCHAR(256) NOT NULL, - relationshipGroup INT UNSIGNED NOT NULL, - typeId NUMERIC(20) NOT NULL, - characteristicTypeId NUMERIC(20) NOT NULL, - modifierId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (sourceId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (characteristicTypeId) REFERENCES concept(id), - FOREIGN KEY (modifierId) REFERENCES concept(id) +CREATE TABLE relationshipconcretevalues +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + value VARCHAR(256) NOT NULL, + relationshipGroup INT UNSIGNED NOT NULL, + typeId NUMERIC(20) NOT NULL, + characteristicTypeId NUMERIC(20) NOT NULL, + modifierId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (sourceId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (characteristicTypeId) REFERENCES concept (id), + FOREIGN KEY (modifierId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_RelationshipConcreteValues_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE relationshipconcretevalues LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Terminology/sct2_RelationshipConcreteValues_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE relationshipconcretevalues LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@sourceId,@value,@relationshipGroup,@typeId,@characteristicTypeId,@modifierId) SET id = @id, effectiveTime = @effectiveTime, @@ -148,20 +158,22 @@ modifierId = @modifierId; -- OWL Expression file. DROP TABLE IF EXISTS owlexpression; -CREATE TABLE owlexpression ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE owlexpression +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - owlExpression TEXT NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (referencedComponentId) REFERENCES concept(id) + owlExpression TEXT NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (referencedComponentId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_sRefset_OWLExpressionSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE owlexpression LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Terminology/sct2_sRefset_OWLExpressionSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE owlexpression LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@owlExpression) SET id = @id, effectiveTime = @effectiveTime, @@ -174,26 +186,28 @@ owlExpression = @owlExpression; -- Stated Relationship file. DROP TABLE IF EXISTS statedrelationship; -CREATE TABLE statedrelationship ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - sourceId NUMERIC(20) NOT NULL, - destinationId NUMERIC(20) NOT NULL, - relationshipGroup INT UNSIGNED NOT NULL, - typeId NUMERIC(20) NOT NULL, +CREATE TABLE statedrelationship +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + destinationId NUMERIC(20) NOT NULL, + relationshipGroup INT UNSIGNED NOT NULL, + typeId NUMERIC(20) NOT NULL, characteristicTypeId NUMERIC(20) NOT NULL, - modifierId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (sourceId) REFERENCES concept(id), - FOREIGN KEY (destinationId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (characteristicTypeId) REFERENCES concept(id), - FOREIGN KEY (modifierId) REFERENCES concept(id) + modifierId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (sourceId) REFERENCES concept (id), + FOREIGN KEY (destinationId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (characteristicTypeId) REFERENCES concept (id), + FOREIGN KEY (modifierId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_StatedRelationship_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE statedrelationship LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Terminology/sct2_StatedRelationship_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE statedrelationship LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@sourceId,@destinationId,@relationshipGroup,@typeId,@characteristicTypeId,@modifierId) SET id = @id, effectiveTime = @effectiveTime, @@ -208,23 +222,25 @@ modifierId = @modifierId; -- Text Definition file. DROP TABLE IF EXISTS textdefinition; -CREATE TABLE textdefinition ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - conceptId NUMERIC(20) NOT NULL, - languageCode CHAR(2) NOT NULL, - typeId NUMERIC(20) NOT NULL, - term VARCHAR(2048) NOT NULL, - caseSignificanceId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (conceptId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (caseSignificanceId) REFERENCES concept(id) +CREATE TABLE textdefinition +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + conceptId NUMERIC(20) NOT NULL, + languageCode CHAR(2) NOT NULL, + typeId NUMERIC(20) NOT NULL, + term VARCHAR(2048) NOT NULL, + caseSignificanceId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (conceptId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (caseSignificanceId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Terminology/sct2_TextDefinition_Snapshot-en_${editionLabel}_${editionVersion}.txt' INTO TABLE textdefinition LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Terminology/sct2_TextDefinition_Snapshot-en_${editionLabel}_${editionVersion}.txt' INTO TABLE textdefinition LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@conceptId,@languageCode,@typeId,@term,@caseSignificanceId) SET id = @id, effectiveTime = @effectiveTime, @@ -239,20 +255,22 @@ caseSignificanceId = @caseSignificanceId; -- Association Reference refset file. DROP TABLE IF EXISTS association; -CREATE TABLE association ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE association +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - targetComponent NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (targetComponent) REFERENCES concept(id) + targetComponent NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (targetComponent) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Content/der2_cRefset_AssociationSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE association LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Content/der2_cRefset_AssociationSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE association LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@targetComponent) SET id = @id, effectiveTime = @effectiveTime, @@ -265,20 +283,22 @@ targetComponent = @targetComponent; -- Attribute Value refset file. DROP TABLE IF EXISTS attributevalue; -CREATE TABLE attributevalue ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE attributevalue +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - valueId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (valueId) REFERENCES concept(id) + valueId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (valueId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Content/der2_cRefset_AttributeValueSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE attributevalue LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Content/der2_cRefset_AttributeValueSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE attributevalue LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@valueId) SET id = @id, effectiveTime = @effectiveTime, @@ -291,18 +311,20 @@ valueId = @valueId; -- Simple refset file. DROP TABLE IF EXISTS simple; -CREATE TABLE simple ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE simple +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Content/der2_Refset_SimpleSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE simple LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Content/der2_Refset_SimpleSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE simple LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId) SET id = @id, effectiveTime = @effectiveTime, @@ -351,27 +373,29 @@ referencedComponentId = @referencedComponentId; -- Extended Map refset file. DROP TABLE IF EXISTS extendedmap; -CREATE TABLE extendedmap ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, - referencedComponentId NUMERIC(20) NOT NULL, - mapGroup INT UNSIGNED NOT NULL, - mapPriority INT UNSIGNED NOT NULL, - mapRule VARCHAR(4000) NOT NULL, - mapAdvice VARCHAR(4000) NOT NULL, - mapTarget VARCHAR(100) NOT NULL, - correlationId NUMERIC(20) NOT NULL, - mapCategoryId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (correlationId) REFERENCES concept(id), - FOREIGN KEY (mapCategoryId) REFERENCES concept(id) +CREATE TABLE extendedmap +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + mapGroup INT UNSIGNED NOT NULL, + mapPriority INT UNSIGNED NOT NULL, + mapRule VARCHAR(4000) NOT NULL, + mapAdvice VARCHAR(4000) NOT NULL, + mapTarget VARCHAR(100) NOT NULL, + correlationId NUMERIC(20) NOT NULL, + mapCategoryId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (correlationId) REFERENCES concept (id), + FOREIGN KEY (mapCategoryId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Map/der2_iisssccRefset_ExtendedMapSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE extendedmap LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Map/der2_iisssccRefset_ExtendedMapSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE extendedmap LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@mapGroup,@mapPriority,@mapRule,@mapAdvice,@mapTarget,@correlationId,@mapCategoryId) SET id = @id, effectiveTime = @effectiveTime, @@ -390,19 +414,21 @@ mapCategoryId = @mapCategoryId; -- Simple Map refset file. DROP TABLE IF EXISTS simplemap; -CREATE TABLE simplemap ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, - referencedComponentId NUMERIC(20) NOT NULL, - mapTarget VARCHAR(100) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) +CREATE TABLE simplemap +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + mapTarget VARCHAR(100) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Map/der2_sRefset_SimpleMapSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE simplemap LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Map/der2_sRefset_SimpleMapSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE simplemap LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@mapTarget) SET id = @id, effectiveTime = @effectiveTime, @@ -415,20 +441,22 @@ mapTarget = @mapTarget; -- Language refset file. DROP TABLE IF EXISTS language; -CREATE TABLE language ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE language +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - acceptabilityId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (acceptabilityId) REFERENCES concept(id) + acceptabilityId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (acceptabilityId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Language/der2_cRefset_LanguageSnapshot-en_${editionLabel}_${editionVersion}.txt' INTO TABLE language LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Language/der2_cRefset_LanguageSnapshot-en_${editionLabel}_${editionVersion}.txt' INTO TABLE language LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@acceptabilityId) SET id = @id, effectiveTime = @effectiveTime, @@ -441,21 +469,23 @@ acceptabilityId = @acceptabilityId; -- Refset Descriptor refset file. DROP TABLE IF EXISTS refsetdescriptor; -CREATE TABLE refsetdescriptor ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE refsetdescriptor +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - attributeDescription NUMERIC(20) NOT NULL, - attributeType NUMERIC(20) NOT NULL, - attributeOrder NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) + attributeDescription NUMERIC(20) NOT NULL, + attributeType NUMERIC(20) NOT NULL, + attributeOrder NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_cciRefset_RefsetDescriptorSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE refsetdescriptor LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_cciRefset_RefsetDescriptorSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE refsetdescriptor LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@attributeDescription,@attributeType,@attributeOrder) SET id = @id, effectiveTime = @effectiveTime, @@ -470,20 +500,22 @@ attributeOrder = @attributeOrder; -- Description Type refset file. DROP TABLE IF EXISTS descriptiontype; -CREATE TABLE descriptiontype ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE descriptiontype +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - descriptionFormat NUMERIC(20) NOT NULL, - descriptionLength INT UNSIGNED NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) + descriptionFormat NUMERIC(20) NOT NULL, + descriptionLength INT UNSIGNED NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_ciRefset_DescriptionTypeSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE descriptiontype LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_ciRefset_DescriptionTypeSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE descriptiontype LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@descriptionFormat,@descriptionLength) SET id = @id, effectiveTime = @effectiveTime, @@ -497,27 +529,29 @@ descriptionLength = @descriptionLength; -- MRCM Attribute Domain refset file. DROP TABLE IF EXISTS mrcmattributedomain; -CREATE TABLE mrcmattributedomain ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, - referencedComponentId NUMERIC(20) NOT NULL, - domainId NUMERIC(20) NOT NULL, - grouped INT NOT NULL, - attributeCardinality VARCHAR(20) NOT NULL, +CREATE TABLE mrcmattributedomain +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + domainId NUMERIC(20) NOT NULL, + grouped INT NOT NULL, + attributeCardinality VARCHAR(20) NOT NULL, attributeInGroupCardinality VARCHAR(20) NOT NULL, - ruleStrengthId NUMERIC(20) NOT NULL, - contentTypeId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (domainId) REFERENCES concept(id), - FOREIGN KEY (ruleStrengthId) REFERENCES concept(id), - FOREIGN KEY (contentTypeId) REFERENCES concept(id) + ruleStrengthId NUMERIC(20) NOT NULL, + contentTypeId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (domainId) REFERENCES concept (id), + FOREIGN KEY (ruleStrengthId) REFERENCES concept (id), + FOREIGN KEY (contentTypeId) REFERENCES concept (id) ); -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_cissccRefset_MRCMAttributeDomainSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE mrcmattributedomain LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_cissccRefset_MRCMAttributeDomainSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE mrcmattributedomain LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@domainId,@grouped,@attributeCardinality,@attributeInGroupCardinality,@ruleStrengthId,@contentTypeId) SET id = @id, effectiveTime = @effectiveTime, @@ -535,20 +569,22 @@ contentTypeId = @contentTypeId; -- MRCM Module Scope refset file. DROP TABLE IF EXISTS mrcmmodulescope; -CREATE TABLE mrcmmodulescope ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE mrcmmodulescope +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - mrcmRuleRefsetId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (mrcmRuleRefsetId) REFERENCES concept(id) + mrcmRuleRefsetId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (mrcmRuleRefsetId) REFERENCES concept (id) ); -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_cRefset_MRCMModuleScopeSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE mrcmmodulescope LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_cRefset_MRCMModuleScopeSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE mrcmmodulescope LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@mrcmRuleRefsetId) SET id = @id, effectiveTime = @effectiveTime, @@ -561,24 +597,26 @@ mrcmRuleRefsetId = @mrcmRuleRefsetId; -- MRCM Attribute Range refset file. DROP TABLE IF EXISTS mrcmattributerange; -CREATE TABLE mrcmattributerange ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, - referencedComponentId NUMERIC(20) NOT NULL, - rangeConstraint VARCHAR(4000) NOT NULL, - attributeRule VARCHAR(4000) NOT NULL, - ruleStrengthId NUMERIC(20) NOT NULL, - contentTypeId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (ruleStrengthId) REFERENCES concept(id), - FOREIGN KEY (contentTypeId) REFERENCES concept(id) +CREATE TABLE mrcmattributerange +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + rangeConstraint VARCHAR(4000) NOT NULL, + attributeRule VARCHAR(4000) NOT NULL, + ruleStrengthId NUMERIC(20) NOT NULL, + contentTypeId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (ruleStrengthId) REFERENCES concept (id), + FOREIGN KEY (contentTypeId) REFERENCES concept (id) ); -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_ssccRefset_MRCMAttributeRangeSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE mrcmattributerange LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_ssccRefset_MRCMAttributeRangeSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE mrcmattributerange LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@rangeConstraint,@attributeRule,@ruleStrengthId,@contentTypeId) SET id = @id, effectiveTime = @effectiveTime, @@ -594,25 +632,27 @@ contentTypeId = @contentTypeId; -- MRCM Domain refset file. DROP TABLE IF EXISTS mrcmdomain; -CREATE TABLE mrcmdomain ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, - referencedComponentId NUMERIC(20) NOT NULL, - domainConstraint VARCHAR(4000) NOT NULL, - parentDomain VARCHAR(4000), - proximalPrimitiveConstraint VARCHAR(4000) NOT NULL, - proximalPrimitiveRefinement VARCHAR(4000), - domainTemplateForPrecoordination TEXT NOT NULL, - domainTemplateForPostcoordination TEXT NOT NULL, - guideURL VARCHAR(4000), - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) +CREATE TABLE mrcmdomain +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + domainConstraint VARCHAR(4000) NOT NULL, + parentDomain VARCHAR(4000), + proximalPrimitiveConstraint VARCHAR(4000) NOT NULL, + proximalPrimitiveRefinement VARCHAR(4000), + domainTemplateForPrecoordination TEXT NOT NULL, + domainTemplateForPostcoordination TEXT NOT NULL, + guideURL VARCHAR(4000), + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_sssssssRefset_MRCMDomainSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE mrcmdomain LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_sssssssRefset_MRCMDomainSnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE mrcmdomain LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@domainConstraint,@parentDomain,@proximalPrimitiveConstraint,@proximalPrimitiveRefinement,@domainTemplateForPrecoordination,@domainTemplateForPostcoordination,@guideURL) SET id = @id, effectiveTime = @effectiveTime, @@ -630,20 +670,22 @@ guideURL = @guideURL; -- Module Dependency refset file. DROP TABLE IF EXISTS moduledependency; -CREATE TABLE moduledependency ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active BOOLEAN NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE moduledependency +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active BOOLEAN NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - sourceEffectiveTime DATE NOT NULL, - targetEffectiveTime DATE NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) + sourceEffectiveTime DATE NOT NULL, + targetEffectiveTime DATE NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) ) CHARACTER SET utf8; -LOAD DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_ssRefset_ModuleDependencySnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE moduledependency LINES TERMINATED BY '\r\n' IGNORE 1 LINES +LOAD +DATA LOCAL INFILE 'Snapshot/Refset/Metadata/der2_ssRefset_ModuleDependencySnapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE moduledependency LINES TERMINATED BY '\r\n' IGNORE 1 LINES (@id,@effectiveTime,@active,@moduleId,@refsetId,@referencedComponentId,@sourceEffectiveTime,@targetEffectiveTime) SET id = @id, effectiveTime = @effectiveTime, @@ -655,5 +697,25 @@ sourceEffectiveTime = @sourceEffectiveTime, targetEffectiveTime = @targetEffectiveTime; +-- Transitive Closure table. +DROP TABLE IF EXISTS transitiveclosure; +CREATE TABLE transitiveclosure +( + superTypeId NUMERIC(20) NOT NULL, + subTypeId NUMERIC(20) NOT NULL, + depth INT NOT NULL, + PRIMARY KEY (superTypeId, subTypeId), + FOREIGN KEY (superTypeId) REFERENCES concept (id), + FOREIGN KEY (subTypeId) REFERENCES concept (id) +) CHARACTER SET utf8; + +LOAD +DATA LOCAL INFILE 'Snapshot/Terminology/sct2_TransitiveClosure_Snapshot_${editionLabel}_${editionVersion}.txt' INTO TABLE transitiveclosure LINES TERMINATED BY '\r\n' IGNORE 1 LINES +(@superTypeId,@subTypeId,@depth) +SET superTypeId = @superTypeId, +subTypeId = @subTypeId, +depth = @depth; + -- Restore foreign key checks to enforce referential integrity. -SET FOREIGN_KEY_CHECKS = 1; +SET +FOREIGN_KEY_CHECKS = 1; \ No newline at end of file diff --git a/src/main/resources/rf2/mysql_views.sql b/src/main/resources/rf2/mysql_views.sql index f2cfcc1..dda19c4 100644 --- a/src/main/resources/rf2/mysql_views.sql +++ b/src/main/resources/rf2/mysql_views.sql @@ -453,3 +453,15 @@ WHERE moduleId = cpn1.conceptId AND refsetId = cpn2.conceptId AND referencedComponentId = cpn3.conceptId; +-- transitive closure table +-- NOTE: this assumes conceptpreferredname has already been created +-- via the standard RF2 load scripts +DROP VIEW IF EXISTS transitiveclosurewithnames; +CREATE VIEW transitiveclosurewithnames AS +SELECT superTypeId, cpn1.preferredName superTypeName, + subTypeId, cpn2.preferredName subTypeName, a.depth +FROM transitiveclosure a, + conceptpreferredname cpn1, + conceptpreferredname cpn2 +WHERE a.superTypeId = cpn1.conceptId + AND a.subTypeId = cpn2.conceptId; \ No newline at end of file diff --git a/src/main/resources/rf2/oracle_tables.sql b/src/main/resources/rf2/oracle_tables.sql index f1c90c2..778db2a 100644 --- a/src/main/resources/rf2/oracle_tables.sql +++ b/src/main/resources/rf2/oracle_tables.sql @@ -3,232 +3,233 @@ SET ECHO ON -- Session settings. -ALTER SESSION SET NLS_LENGTH_SEMANTICS='CHAR'; +ALTER +SESSION SET NLS_LENGTH_SEMANTICS='CHAR'; -- Define helper procedure to drop tables. BEGIN - EXECUTE IMMEDIATE 'DROP PROCEDURE drop_table'; +EXECUTE IMMEDIATE 'DROP PROCEDURE drop_table'; EXCEPTION WHEN OTHERS THEN -- If procedure doesn't exist, it can't be dropped, -- so an exception will be thrown. Ignore it. IF SQLCODE != -4043 THEN RAISE; - END IF; +END IF; END; / -CREATE PROCEDURE drop_table (table_name IN VARCHAR2) IS +CREATE PROCEDURE drop_table(table_name IN VARCHAR2) IS BEGIN - EXECUTE IMMEDIATE 'DROP TABLE ' || table_name || ' CASCADE CONSTRAINTS'; +EXECUTE IMMEDIATE 'DROP TABLE ' || table_name || ' CASCADE CONSTRAINTS'; EXCEPTION -- If table doesn't exist, it can't be dropped, -- so an exception will be thrown. Ignore it. WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; - END IF; +END IF; END; / -- Concept table. EXECUTE drop_table('concept'); -CREATE TABLE concept ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, +CREATE TABLE concept +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, definitionStatusId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (definitionStatusId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (definitionStatusId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Description table. EXECUTE drop_table('description'); -CREATE TABLE description ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - conceptId NUMERIC(20) NOT NULL, - languageCode CHAR(2) NOT NULL, - typeId NUMERIC(20) NOT NULL, - term VARCHAR2(255) NOT NULL, +CREATE TABLE description +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + conceptId NUMERIC(20) NOT NULL, + languageCode CHAR(2) NOT NULL, + typeId NUMERIC(20) NOT NULL, + term VARCHAR2(255) NOT NULL, caseSignificanceId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (conceptId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (caseSignificanceId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (conceptId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (caseSignificanceId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Identifier table. EXECUTE drop_table('identifier'); -CREATE TABLE identifier ( - identifierSchemeId NUMERIC(20) NOT NULL, - alternateIdentifier VARCHAR2(255) NOT NULL, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, +CREATE TABLE identifier +( + identifierSchemeId NUMERIC(20) NOT NULL, + alternateIdentifier VARCHAR2(255) NOT NULL, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + FOREIGN KEY (moduleId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Relationship table. EXECUTE drop_table('relationship'); -CREATE TABLE relationship ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - sourceId NUMERIC(20) NOT NULL, - destinationId NUMERIC(20) NOT NULL, - relationshipGroup INT NOT NULL, - typeId NUMERIC(20) NOT NULL, +CREATE TABLE relationship +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + destinationId NUMERIC(20) NOT NULL, + relationshipGroup INT NOT NULL, + typeId NUMERIC(20) NOT NULL, characteristicTypeId NUMERIC(20) NOT NULL, - modifierId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (sourceId) REFERENCES concept(id), - FOREIGN KEY (destinationId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (characteristicTypeId) REFERENCES concept(id), - FOREIGN KEY (modifierId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + modifierId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (sourceId) REFERENCES concept (id), + FOREIGN KEY (destinationId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (characteristicTypeId) REFERENCES concept (id), + FOREIGN KEY (modifierId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Relationship concrete values table. EXECUTE drop_table('relationshipconcretevalues'); -CREATE TABLE relationshipconcretevalues ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - sourceId NUMERIC(20) NOT NULL, - value VARCHAR2(256) NOT NULL, - relationshipGroup INT NOT NULL, - typeId NUMERIC(20) NOT NULL, +CREATE TABLE relationshipconcretevalues +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + value VARCHAR2(256) NOT NULL, + relationshipGroup INT NOT NULL, + typeId NUMERIC(20) NOT NULL, characteristicTypeId NUMERIC(20) NOT NULL, - modifierId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (sourceId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (characteristicTypeId) REFERENCES concept(id), - FOREIGN KEY (modifierId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + modifierId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (sourceId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (characteristicTypeId) REFERENCES concept (id), + FOREIGN KEY (modifierId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- OWL Expression table. EXECUTE drop_table('owlexpression'); -CREATE TABLE owlexpression ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE owlexpression +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - owlExpression VARCHAR2(4000) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (referencedComponentId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + owlExpression VARCHAR2(4000) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (referencedComponentId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Stated Relationship table. EXECUTE drop_table('statedrelationship'); -CREATE TABLE statedrelationship ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - sourceId NUMERIC(20) NOT NULL, - destinationId NUMERIC(20) NOT NULL, - relationshipGroup INT NOT NULL, - typeId NUMERIC(20) NOT NULL, +CREATE TABLE statedrelationship +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + sourceId NUMERIC(20) NOT NULL, + destinationId NUMERIC(20) NOT NULL, + relationshipGroup INT NOT NULL, + typeId NUMERIC(20) NOT NULL, characteristicTypeId NUMERIC(20) NOT NULL, - modifierId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (sourceId) REFERENCES concept(id), - FOREIGN KEY (destinationId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (characteristicTypeId) REFERENCES concept(id), - FOREIGN KEY (modifierId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + modifierId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (sourceId) REFERENCES concept (id), + FOREIGN KEY (destinationId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (characteristicTypeId) REFERENCES concept (id), + FOREIGN KEY (modifierId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Text Definition table. EXECUTE drop_table('textdefinition'); -CREATE TABLE textdefinition ( - id NUMERIC(20) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - conceptId NUMERIC(20) NOT NULL, - languageCode CHAR(2) NOT NULL, - typeId NUMERIC(20) NOT NULL, - term VARCHAR2(2048) NOT NULL, +CREATE TABLE textdefinition +( + id NUMERIC(20) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + conceptId NUMERIC(20) NOT NULL, + languageCode CHAR(2) NOT NULL, + typeId NUMERIC(20) NOT NULL, + term VARCHAR2(2048) NOT NULL, caseSignificanceId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (conceptId) REFERENCES concept(id), - FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (caseSignificanceId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (conceptId) REFERENCES concept (id), + FOREIGN KEY (typeId) REFERENCES concept (id), + FOREIGN KEY (caseSignificanceId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Association refset table. EXECUTE drop_table('association'); -CREATE TABLE association ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE association +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - targetComponent NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) + targetComponent NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) -- TODO: FOREIGN KEY targetComponent? -) -PCTFREE 10 PCTUSED 80; +) PCTFREE 10 PCTUSED 80; -- Attribute Value refset table. EXECUTE drop_table('attributevalue'); -CREATE TABLE attributevalue ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE attributevalue +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - valueId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (valueId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + valueId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (valueId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Simple refset table. EXECUTE drop_table('simple'); -CREATE TABLE simple ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE simple +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- No more complex map, ICD9CM maps deprecated -- Complex Map refset table. @@ -255,196 +256,207 @@ PCTFREE 10 PCTUSED 80; -- Extended Map refset table. EXECUTE drop_table('extendedmap'); -CREATE TABLE extendedmap ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE extendedmap +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - mapGroup INT NOT NULL, - mapPriority INT NOT NULL, - mapRule VARCHAR2(4000), - mapAdvice VARCHAR2(4000), - mapTarget VARCHAR2(100), - correlationId NUMERIC(20) NOT NULL, - mapCategoryId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (correlationId) REFERENCES concept(id), - FOREIGN KEY (mapCategoryId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + mapGroup INT NOT NULL, + mapPriority INT NOT NULL, + mapRule VARCHAR2(4000), + mapAdvice VARCHAR2(4000), + mapTarget VARCHAR2(100), + correlationId NUMERIC(20) NOT NULL, + mapCategoryId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (correlationId) REFERENCES concept (id), + FOREIGN KEY (mapCategoryId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Simple Map refset table. EXECUTE drop_table('simplemap'); -CREATE TABLE simplemap ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE simplemap +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - mapTarget VARCHAR2(100) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + mapTarget VARCHAR2(100) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Lanuage refset table. EXECUTE drop_table('language'); -CREATE TABLE language ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE language +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - acceptabilityId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (acceptabilityId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + acceptabilityId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (acceptabilityId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Refset Descriptor refset table. EXECUTE drop_table('refsetdescriptor'); -CREATE TABLE refsetdescriptor ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE refsetdescriptor +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - attributeDescription NUMERIC(20) NOT NULL, - attributeType NUMERIC(20) NOT NULL, - attributeOrder NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + attributeDescription NUMERIC(20) NOT NULL, + attributeType NUMERIC(20) NOT NULL, + attributeOrder NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Description Type refset table. EXECUTE drop_table('descriptiontype'); -CREATE TABLE descriptiontype ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE descriptiontype +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - descriptionFormat NUMERIC(20) NOT NULL, - descriptionLength INT NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + descriptionFormat NUMERIC(20) NOT NULL, + descriptionLength INT NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- MRCM Attribute Domain refset file. EXECUTE drop_table('mrcmattributedomain'); -CREATE TABLE mrcmattributedomain ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, - referencedComponentId NUMERIC(20) NOT NULL, - domainId NUMERIC(20) NOT NULL, - grouped INT NOT NULL, - attributeCardinality VARCHAR2(20) NOT NULL, +CREATE TABLE mrcmattributedomain +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + domainId NUMERIC(20) NOT NULL, + grouped INT NOT NULL, + attributeCardinality VARCHAR2(20) NOT NULL, attributeInGroupCardinality VARCHAR2(20) NOT NULL, - ruleStrengthId NUMERIC(20) NOT NULL, - contentTypeId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (domainId) REFERENCES concept(id), - FOREIGN KEY (ruleStrengthId) REFERENCES concept(id), - FOREIGN KEY (contentTypeId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + ruleStrengthId NUMERIC(20) NOT NULL, + contentTypeId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (domainId) REFERENCES concept (id), + FOREIGN KEY (ruleStrengthId) REFERENCES concept (id), + FOREIGN KEY (contentTypeId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- MRCM Module Scope refset file. EXECUTE drop_table('mrcmmodulescope'); -CREATE TABLE mrcmmodulescope ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE mrcmmodulescope +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - mrcmRuleRefsetId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (mrcmRuleRefsetId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + mrcmRuleRefsetId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (mrcmRuleRefsetId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- MRCM Attribute Range refset file. EXECUTE drop_table('mrcmattributerange'); -CREATE TABLE mrcmattributerange ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE mrcmattributerange +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - rangeConstraint VARCHAR2(4000) NOT NULL, - attributeRule VARCHAR2(4000) NOT NULL, - ruleStrengthId NUMERIC(20) NOT NULL, - contentTypeId NUMERIC(20) NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id), - FOREIGN KEY (ruleStrengthId) REFERENCES concept(id), - FOREIGN KEY (contentTypeId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + rangeConstraint VARCHAR2(4000) NOT NULL, + attributeRule VARCHAR2(4000) NOT NULL, + ruleStrengthId NUMERIC(20) NOT NULL, + contentTypeId NUMERIC(20) NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id), + FOREIGN KEY (ruleStrengthId) REFERENCES concept (id), + FOREIGN KEY (contentTypeId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- MRCM Domain refset file. EXECUTE drop_table('mrcmdomain'); -CREATE TABLE mrcmdomain ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, - referencedComponentId NUMERIC(20) NOT NULL, - domainConstraint VARCHAR2(4000) NOT NULL, - parentDomain VARCHAR2(4000), - proximalPrimitiveConstraint VARCHAR2(4000) NOT NULL, - proximalPrimitiveRefinement VARCHAR2(4000), - domainTemplateForPrecoordination VARCHAR2(4000) NOT NULL, +CREATE TABLE mrcmdomain +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, + referencedComponentId NUMERIC(20) NOT NULL, + domainConstraint VARCHAR2(4000) NOT NULL, + parentDomain VARCHAR2(4000), + proximalPrimitiveConstraint VARCHAR2(4000) NOT NULL, + proximalPrimitiveRefinement VARCHAR2(4000), + domainTemplateForPrecoordination VARCHAR2(4000) NOT NULL, domainTemplateForPostcoordination VARCHAR2(4000) NOT NULL, - guideURL VARCHAR2(4000), - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) -) -PCTFREE 10 PCTUSED 80; + guideURL VARCHAR2(4000), + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; -- Module Dependency refset table. EXECUTE drop_table('moduledependency'); -CREATE TABLE moduledependency ( - id CHAR(52) NOT NULL PRIMARY KEY, - effectiveTime DATE NOT NULL, - active NUMERIC(1) NOT NULL, - moduleId NUMERIC(20) NOT NULL, - refsetId NUMERIC(20) NOT NULL, +CREATE TABLE moduledependency +( + id CHAR(52) NOT NULL PRIMARY KEY, + effectiveTime DATE NOT NULL, + active NUMERIC(1) NOT NULL, + moduleId NUMERIC(20) NOT NULL, + refsetId NUMERIC(20) NOT NULL, referencedComponentId NUMERIC(20) NOT NULL, - sourceEffectiveTime DATE NOT NULL, - targetEffectiveTime DATE NOT NULL, - FOREIGN KEY (moduleId) REFERENCES concept(id), - FOREIGN KEY (refsetId) REFERENCES concept(id) + sourceEffectiveTime DATE NOT NULL, + targetEffectiveTime DATE NOT NULL, + FOREIGN KEY (moduleId) REFERENCES concept (id), + FOREIGN KEY (refsetId) REFERENCES concept (id) +) PCTFREE 10 PCTUSED 80; + +-- Transitive closure table +EXECUTE drop_table('transitiveclosure'); +CREATE TABLE transitiveclosure ( + superTypeId NUMERIC(20) NOT NULL, + subTypeId NUMERIC(20) NOT NULL, + depth INTEGER NOT NULL, + PRIMARY KEY (superTypeId, subTypeId), + FOREIGN KEY (superTypeId) REFERENCES concept(id), + FOREIGN KEY (subTypeId) REFERENCES concept(id) ) PCTFREE 10 PCTUSED 80; - -- Clean up helper procedures. DROP PROCEDURE drop_table; diff --git a/src/main/resources/rf2/oracle_views.sql b/src/main/resources/rf2/oracle_views.sql index 3433b5b..69626dc 100644 --- a/src/main/resources/rf2/oracle_views.sql +++ b/src/main/resources/rf2/oracle_views.sql @@ -3,31 +3,32 @@ SET ECHO ON -- Session settings. -ALTER SESSION SET NLS_LENGTH_SEMANTICS='CHAR'; +ALTER +SESSION SET NLS_LENGTH_SEMANTICS='CHAR'; -- Define helper procedure to drop views. BEGIN - EXECUTE IMMEDIATE 'DROP PROCEDURE drop_view'; +EXECUTE IMMEDIATE 'DROP PROCEDURE drop_view'; EXCEPTION WHEN OTHERS THEN -- If procedure doesn't exist, it can't be dropped, -- so an exception will be thrown. Ignore it. IF SQLCODE != -4043 THEN RAISE; - END IF; +END IF; END; / -CREATE PROCEDURE drop_view (view_name IN VARCHAR2) IS +CREATE PROCEDURE drop_view(view_name IN VARCHAR2) IS BEGIN - EXECUTE IMMEDIATE 'DROP VIEW ' || view_name || ' CASCADE CONSTRAINTS'; +EXECUTE IMMEDIATE 'DROP VIEW ' || view_name || ' CASCADE CONSTRAINTS'; EXCEPTION -- If view doesn't exist, it can't be dropped, -- so an exception will be thrown. Ignore it. WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; - END IF; +END IF; END; / @@ -40,211 +41,280 @@ EXECUTE drop_view('conceptpreferredname'); CREATE VIEW conceptpreferredname AS SELECT c.id conceptId, NVL(d.term, 'no active preferred synonym') preferredName, d.id descriptionId FROM concept c -LEFT OUTER JOIN description d -ON c.id = d.conceptId -AND d.active = 1 -AND d.typeId = 900000000000013009 -LEFT OUTER JOIN language l -ON d.id = l.referencedComponentId -AND l.active = 1 -AND l.acceptabilityId = 900000000000548007 -AND l.refSetId = 900000000000509007 + LEFT OUTER JOIN description d + ON c.id = d.conceptId + AND d.active = 1 + AND d.typeId = 900000000000013009 + LEFT OUTER JOIN language l + ON d.id = l.referencedComponentId + AND l.active = 1 + AND l.acceptabilityId = 900000000000548007 + AND l.refSetId = 900000000000509007 WHERE (l.acceptabilityId IS NOT null OR d.TERM IS null); -- Concept table with names. EXECUTE drop_view('conceptwithnames'); CREATE VIEW conceptwithnames AS -SELECT id, cpn1.preferredName idName, effectiveTime, active, - moduleId, cpn2.preferredName moduleIdName, - definitionStatusId, cpn3.preferredName definitionStatusIdName +SELECT id, + cpn1.preferredName idName, + effectiveTime, + active, + moduleId, + cpn2.preferredName moduleIdName, + definitionStatusId, + cpn3.preferredName definitionStatusIdName FROM concept, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE id = cpn1.conceptId -AND moduleId = cpn2.conceptId -AND definitionStatusId = cpn3.conceptId; + AND moduleId = cpn2.conceptId + AND definitionStatusId = cpn3.conceptId; -- Description table. EXECUTE drop_view('descriptionwithnames'); CREATE VIEW descriptionwithnames AS -SELECT id, term, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - d.conceptId, cpn2.preferredName conceptIdName, - languageCode, - typeId, cpn3.preferredName typeIdName, - caseSignificanceId, cpn4.preferredName caseSignificanceIdName +SELECT id, + term, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + d.conceptId, + cpn2.preferredName conceptIdName, + languageCode, + typeId, + cpn3.preferredName typeIdName, + caseSignificanceId, + cpn4.preferredName caseSignificanceIdName FROM description d, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4 -WHERE moduleId = cpn1.conceptId AND d.conceptId = cpn2.conceptId AND typeId = cpn3.conceptId AND caseSignificanceId = cpn4.conceptId; + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4 +WHERE moduleId = cpn1.conceptId + AND d.conceptId = cpn2.conceptId + AND typeId = cpn3.conceptId + AND caseSignificanceId = cpn4.conceptId; -- Identifier table. EXECUTE drop_view('identifierwithnames'); CREATE VIEW identifierwithnames AS -SELECT identifierSchemeId, cpn1.preferredName identifierSchemeIdName, - alternateIdentifier, effectiveTime, active, - moduleId, cpn2.preferredName moduleIdName, - referencedComponentId +SELECT identifierSchemeId, + cpn1.preferredName identifierSchemeIdName, + alternateIdentifier, + effectiveTime, + active, + moduleId, + cpn2.preferredName moduleIdName, + referencedComponentId FROM identifier, - conceptpreferredname cpn1, - conceptpreferredname cpn2 + conceptpreferredname cpn1, + conceptpreferredname cpn2 WHERE identifierSchemeId = cpn1.conceptId -AND moduleId = cpn2.conceptId; + AND moduleId = cpn2.conceptId; -- Relationship table. EXECUTE drop_view('relationshipwithnames'); CREATE VIEW relationshipwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - sourceId, cpn2.preferredName sourceIdName, - destinationId, cpn3.preferredName destinationIdName, - relationshipGroup, - typeId, cpn4.preferredName typeIdName, - characteristicTypeId, cpn5.preferredName characteristicTypeIdName, - modifierId, cpn6.preferredName modifierIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + sourceId, + cpn2.preferredName sourceIdName, + destinationId, + cpn3.preferredName destinationIdName, + relationshipGroup, + typeId, + cpn4.preferredName typeIdName, + characteristicTypeId, + cpn5.preferredName characteristicTypeIdName, + modifierId, + cpn6.preferredName modifierIdName from relationship, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4, - conceptpreferredname cpn5, - conceptpreferredname cpn6 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4, + conceptpreferredname cpn5, + conceptpreferredname cpn6 WHERE moduleId = cpn1.conceptId -AND sourceId = cpn2.conceptId -AND destinationId = cpn3.conceptId -AND typeId = cpn4.conceptId -AND characteristicTypeId = cpn5.conceptId -AND modifierId = cpn6.conceptId; + AND sourceId = cpn2.conceptId + AND destinationId = cpn3.conceptId + AND typeId = cpn4.conceptId + AND characteristicTypeId = cpn5.conceptId + AND modifierId = cpn6.conceptId; xxx-- Relationship concrete values table. EXECUTE drop_view('relationshipconcretevalueswithnames'); CREATE VIEW relationshipconcretevalueswithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - sourceId, cpn2.preferredName sourceIdName, - value, relationshipGroup, - typeId, cpn4.preferredName typeIdName, - characteristicTypeId, cpn5.preferredName characteristicTypeIdName, - modifierId, cpn6.preferredName modifierIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + sourceId, + cpn2.preferredName sourceIdName, + value, + relationshipGroup, + typeId, + cpn4.preferredName typeIdName, + characteristicTypeId, + cpn5.preferredName characteristicTypeIdName, + modifierId, + cpn6.preferredName modifierIdName from relationshipconcretevalues, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn4, - conceptpreferredname cpn5, - conceptpreferredname cpn6 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn4, + conceptpreferredname cpn5, + conceptpreferredname cpn6 WHERE moduleId = cpn1.conceptId -AND sourceId = cpn2.conceptId -AND typeId = cpn4.conceptId -AND characteristicTypeId = cpn5.conceptId -AND modifierId = cpn6.conceptId; + AND sourceId = cpn2.conceptId + AND typeId = cpn4.conceptId + AND characteristicTypeId = cpn5.conceptId + AND modifierId = cpn6.conceptId; -- Stated Relationship table. EXECUTE drop_view('statedrelationshipwithnames'); CREATE VIEW statedrelationshipwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - sourceId, cpn2.preferredName sourceIdName, - destinationId, cpn3.preferredName destinationIdName, - relationshipGroup, - typeId, cpn4.preferredName typeIdName, - characteristicTypeId, cpn5.preferredName characteristicTypeIdName, - modifierId, cpn6.preferredName modifierIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + sourceId, + cpn2.preferredName sourceIdName, + destinationId, + cpn3.preferredName destinationIdName, + relationshipGroup, + typeId, + cpn4.preferredName typeIdName, + characteristicTypeId, + cpn5.preferredName characteristicTypeIdName, + modifierId, + cpn6.preferredName modifierIdName from statedrelationship, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4, - conceptpreferredname cpn5, - conceptpreferredname cpn6 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4, + conceptpreferredname cpn5, + conceptpreferredname cpn6 WHERE moduleId = cpn1.conceptId -AND sourceId = cpn2.conceptId -AND destinationId = cpn3.conceptId -AND typeId = cpn4.conceptId -AND characteristicTypeId = cpn5.conceptId -AND modifierId = cpn6.conceptId; + AND sourceId = cpn2.conceptId + AND destinationId = cpn3.conceptId + AND typeId = cpn4.conceptId + AND characteristicTypeId = cpn5.conceptId + AND modifierId = cpn6.conceptId; -- Text Definition table. EXECUTE drop_view('textdefinitionwithnames'); CREATE VIEW textdefinitionwithnames AS -SELECT id, term, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - td.conceptId, cpn2.preferredName conceptIdName, - languageCode, - typeId, cpn3.preferredName typeIdName, - caseSignificanceId, cpn4.preferredName caseSignificanceIdName +SELECT id, + term, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + td.conceptId, + cpn2.preferredName conceptIdName, + languageCode, + typeId, + cpn3.preferredName typeIdName, + caseSignificanceId, + cpn4.preferredName caseSignificanceIdName from textdefinition td, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4 WHERE moduleId = cpn1.conceptId -AND td.conceptId = cpn2.conceptId -AND typeId = cpn3.conceptId -AND caseSignificanceId = cpn4.conceptId; + AND td.conceptId = cpn2.conceptId + AND typeId = cpn3.conceptId + AND caseSignificanceId = cpn4.conceptId; -- Association refset table. EXECUTE drop_view('associationwithnames'); CREATE VIEW associationwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - targetComponent, cpn4.preferredName targetComponentName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + targetComponent, + cpn4.preferredName targetComponentName from association, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId -AND targetComponent = cpn4.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId + AND targetComponent = cpn4.conceptId; -- Attribute Value refset table. EXECUTE drop_view('attributevaluewithnames'); CREATE VIEW attributevaluewithnames AS -SELECT attributevalue.id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - valueId, cpn4.preferredName valueIdName +SELECT attributevalue.id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + valueId, + cpn4.preferredName valueIdName FROM attributevalue, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - (SELECT conceptId id, preferredName FROM conceptpreferredname - UNION ALL - SELECT d.id, term from description d) cpn3, - conceptpreferredname cpn4 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + (SELECT conceptId id, preferredName + FROM conceptpreferredname + UNION ALL + SELECT d.id, term + from description d) cpn3, + conceptpreferredname cpn4 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.id -AND valueId = cpn4.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.id + AND valueId = cpn4.conceptId; -- Simple refset table. EXECUTE drop_view('simplewithnames'); CREATE VIEW simplewithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName FROM simple, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- No more complex map, ICD9CM maps deprecated @@ -275,116 +345,165 @@ AND referencedComponentId = cpn3.conceptId; -- Extended Map refset table. EXECUTE drop_view('extendedmapwithnames'); CREATE VIEW extendedmapwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - mapGroup, - mapPriority, - mapRule, - mapAdvice, - mapTarget, - correlationId, cpn4.preferredName correlationIdName, - mapCategoryId, cpn5.preferredName mapCategoryIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + mapGroup, + mapPriority, + mapRule, + mapAdvice, + mapTarget, + correlationId, + cpn4.preferredName correlationIdName, + mapCategoryId, + cpn5.preferredName mapCategoryIdName FROM extendedmap, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4, - conceptpreferredname cpn5 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4, + conceptpreferredname cpn5 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId -AND correlationId = cpn4.conceptId -AND mapCategoryId = cpn5.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId + AND correlationId = cpn4.conceptId + AND mapCategoryId = cpn5.conceptId; -- Simple Map refset table. EXECUTE drop_view('simplemapwithnames'); CREATE VIEW simplemapwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - mapTarget +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + mapTarget FROM simplemap, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- Language refset table. EXECUTE drop_view('languagewithnames'); CREATE VIEW languagewithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - acceptabilityId, cpn4.preferredName acceptabilityIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + acceptabilityId, + cpn4.preferredName acceptabilityIdName FROM language, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.descriptionId -AND acceptabilityId = cpn4.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.descriptionId + AND acceptabilityId = cpn4.conceptId; -- Refset Descriptor refset table. EXECUTE drop_view('refsetdescriptorwithnames'); CREATE VIEW refsetdescriptorwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - attributeDescription, attributeType, attributeOrder +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + attributeDescription, + attributeType, + attributeOrder FROM refsetdescriptor, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- Description Type refset table. EXECUTE drop_view('descriptiontypewithnames'); CREATE VIEW descriptiontypewithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - descriptionFormat, descriptionLength +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + descriptionFormat, + descriptionLength FROM descriptiontype, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- Module Dependency refset table. EXECUTE drop_view('moduledependencywithnames'); CREATE VIEW moduledependencywithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - sourceEffectiveTime, targetEffectiveTime +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + sourceEffectiveTime, + targetEffectiveTime FROM moduledependency, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; - + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; + +-- transitive closure table +-- NOTE: this assumes conceptpreferredname has already been created +-- via the standard RF2 load scripts +EXECUTE drop_view('transitiveclosurewithnames'); +CREATE VIEW transitiveclosurewithnames AS +SELECT superTypeId, cpn1.preferredName superTypeName, + subTypeId, cpn2.preferredName subTypeName, a.depth +FROM transitiveclosure a, + conceptpreferredname cpn1, + conceptpreferredname cpn2 +WHERE a.superTypeId = cpn1.conceptId + AND a.subTypeId = cpn2.conceptId; -- Clean up helper procedures. DROP PROCEDURE drop_view; diff --git a/src/main/resources/rf2/populate_mysql_db.bat b/src/main/resources/rf2/populate_mysql_db.bat deleted file mode 100644 index 5c256a8..0000000 --- a/src/main/resources/rf2/populate_mysql_db.bat +++ /dev/null @@ -1,51 +0,0 @@ -:: -:: Database connection parameters -:: Please edit these variables to reflect your environment -:: -set mysql=C:/mysql/mysql-5.6.46-winx64/bin/mysql.exe -set user=root -set password=admin -set db_name=snomed - -del mysql.log -echo. > mysql.log -echo ---------------------------------------- >> mysql.log 2>&1 -echo Starting ... >> mysql.log 2>&1 -date /T >> mysql.log 2>&1 -time /T >> mysql.log 2>&1 -echo ---------------------------------------- >> mysql.log 2>&1 -echo MYSQL_HOME = %MYSQL_HOME% >> mysql.log 2>&1 -echo user = %user% >> mysql.log 2>&1 -echo db_name = %db_name% >> mysql.log 2>&1 -set error=0 - -echo Create and load tables >> mysql.log 2>&1 -"%mysql%" -vvv -u %user% -p%password% --local-infile=1 %db_name% < mysql_tables.sql >> mysql.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1 -goto trailer) - -echo Create indexes >> mysql.log 2>&1 -"%mysql%" -vvv -u %user% -p%password% --local-infile=1 %db_name% < mysql_indexes.sql >> mysql.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1 -goto trailer) - -echo Create views >> mysql.log 2>&1 -"%mysql%" -vvv -u %user% -p%password% --local-infile=1 %db_name% < mysql_views.sql >> mysql.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1 -goto trailer) - -:trailer -echo ---------------------------------------- >> mysql.log 2>&1 -IF %error% NEQ 0 ( -echo There were one or more errors. Please reference the mysql.log file for details. >> mysql.log 2>&1 -set retval=-1 -) else ( -echo Completed without errors. >> mysql.log 2>&1 -set retval=0 -) -echo Finished ... >> mysql.log 2>&1 -date /T >> mysql.log 2>&1 -time /T >> mysql.log 2>&1 -echo ---------------------------------------- >> mysql.log 2>&1 -pause -exit %retval% diff --git a/src/main/resources/rf2/populate_mysql_db.sh b/src/main/resources/rf2/populate_mysql_db.sh index 9003ba9..e98a63c 100644 --- a/src/main/resources/rf2/populate_mysql_db.sh +++ b/src/main/resources/rf2/populate_mysql_db.sh @@ -1,11 +1,8 @@ #!/bin/bash -f # # Database connection parameters -# NOTE: or MySQL 8.0, you'll need to run the server with local_infile=ON -# Please edit these variables to reflect your environment -# - Tested with docker mysql 5.6, 5.7, 8.0 (using docker mysql server and client) -# - host=host.docker.internal -host= +# PLEASE EDIT THESE VARIABLES TO REFLECT YOUR ENVIRONMENT +host=[UPDATE] user=root password=admin db_name=snomed @@ -14,14 +11,14 @@ db_name=snomed touch mysql.log ef=0 -echo "See mysql.log for output" +echo "See mysql.log for detailed output" -echo "----------------------------------------" >> mysql.log 2>&1 -echo "Starting ... `/bin/date`" >> mysql.log 2>&1 -echo "----------------------------------------" >> mysql.log 2>&1 -echo "user = $user" >> mysql.log 2>&1 -echo "db_name = $db_name" >> mysql.log 2>&1 -echo "host = $host" >> mysql.log 2>&1 +echo "----------------------------------------" | tee -a mysql.log +echo "Starting ... `/bin/date`" | tee -a mysql.log +echo "----------------------------------------" | tee -a mysql.log +echo "user = $user" | tee -a mysql.log +echo "db_name = $db_name" | tee -a mysql.log +echo "host = $host" | tee -a mysql.log if [ "${password}" != "" ]; then password="-p${password}" @@ -30,31 +27,54 @@ if [ "${host}" != "" ]; then host="-h ${host}" fi -echo " Create and load tables ... `/bin/date`" >> mysql.log 2>&1 +DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +echo " Compute transitive closure relationship file ... `/bin/date`" | tee -a mysql.log +relFile=$(find $DIR/Snapshot/Terminology/ -name "*_Relationship_Snapshot_*.txt" -print -quit) +#check if system has python or perl, run the corresponding script +if command -v python &> /dev/null +then + echo "python found, running python script" >> mysql.log 2>&1 + python $DIR/compute_transitive_closure.py --force --noself $relFile >> mysql.log 2>&1 + if [ $? -ne 0 ]; then ef=1; fi +elif command -v perl &> /dev/null +then + echo "perl found, running perl script" >> mysql.log 2>&1 + perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> mysql.log 2>&1 + if [ $? -ne 0 ]; then ef=1; fi +# if none are present, print error message +else + echo "No python or perl found. Please install one of them." | tee -a mysql.log + ef=1 +fi + +if [ $ef -ne 1 ]; then +echo " Create and load tables ... `/bin/date`" | tee -a mysql.log mysql -vvv $host -u $user $password --local-infile $db_name < mysql_tables.sql >> mysql.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi +fi if [ $ef -ne 1 ]; then -echo " Create indexes ... `/bin/date`" >> mysql.log 2>&1 +echo " Create indexes ... `/bin/date`" | tee -a mysql.log mysql -vvv $host -u $user $password --local-infile $db_name < mysql_indexes.sql >> mysql.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi if [ $ef -ne 1 ]; then -echo " Create views ... `/bin/date`" >> mysql.log 2>&1 +echo " Create views ... `/bin/date`" | tee -a mysql.log mysql -vvv $host -u $user $password --local-infile $db_name < mysql_views.sql >> mysql.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi -echo "----------------------------------------" >> mysql.log 2>&1 +echo "----------------------------------------" | tee -a mysql.log if [ $ef -eq 1 ] then - echo "There were one or more errors." >> mysql.log 2>&1 + echo "There were one or more errors." | tee -a mysql.log retval=-1 else - echo "Completed without errors." >> mysql.log 2>&1 + echo "Completed without errors." | tee - a mysql.log retval=0 fi -echo "Finished ... `/bin/date`" >> mysql.log 2>&1 -echo "----------------------------------------" >> mysql.log 2>&1 +echo "Finished ... `/bin/date`" | tee -a mysql.log +echo "----------------------------------------" | tee -a mysql.log exit $retval diff --git a/src/main/resources/rf2/populate_oracle_db.bat b/src/main/resources/rf2/populate_oracle_db.bat deleted file mode 100644 index 9948229..0000000 --- a/src/main/resources/rf2/populate_oracle_db.bat +++ /dev/null @@ -1,163 +0,0 @@ -:: -:: Database connection parameters -:: Please edit these variables to reflect your environment -:: -set ORACLE_HOME=C:\app\oracle\product\12.1.0\dbhome_1 -set user=snomed -set password=snomed -set tns_name=ORCLCDB -set NLS_LANG=AMERICAN_AMERICA.UTF8 - -del oracle.log -echo. > oracle.log -echo ---------------------------------------- >> oracle.log 2>&1 -echo Starting ... >> oracle.log 2>&1 -date /T >> oracle.log 2>&1 -time /T >> oracle.log 2>&1 -echo ---------------------------------------- >> oracle.log 2>&1 -echo ORACLE_HOME = %ORACLE_HOME% >> oracle.log 2>&1 -echo user = %user% >> oracle.log 2>&1 -echo tns_name = %tns_name% >> oracle.log 2>&1 -set error=0 - -echo Create tables >> oracle.log 2>&1 -echo @oracle_tables.sql|%ORACLE_HOME%\bin\sqlplus %user%/%password%@%tns_name% >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1 -goto trailer) - -echo Load concept table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="concept.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type concept.log >> oracle.log - -echo Load description table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="description.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type description.log >> oracle.log - -echo Load identifier table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="identifier.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type identifier.log >> oracle.log - -echo Load relationship table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="relationship.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type relationship.log >> oracle.log - -echo Load relationship concrete values table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="relationshipconcretevalues.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type relationshipconcretevalues.log >> oracle.log - -echo Load owl expression table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="owlexpression.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type owlexpression.log >> oracle.log - -echo Load stated relationship table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="statedrelationship.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type statedrelationship.log >> oracle.log - -echo Load text definition table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="textdefinition.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type textdefinition.log >> oracle.log - -echo Load association table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="association.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type association.log >> oracle.log - -echo Load attribute value table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="attributevalue.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type attributevalue.log >> oracle.log - -echo Load simple refset table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="simple.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type simple.log >> oracle.log - -:: No more complex map, ICD9CM maps deprecated -:: echo Load complex map refset table data >> oracle.log 2>&1 -:: %ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="complexmap.ctl" >> oracle.log 2>&1 -:: IF %ERRORLEVEL% NEQ 0 (set error=1) -:: type complexmap.log >> oracle.log - -echo Load extended map table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="extendedmap.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type extendedmap.log >> oracle.log - -echo Load simple map table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="simplemap.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type simplemap.log >> oracle.log - -echo Load language table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="language.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type language.log >> oracle.log - -echo Load refset descriptor table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="refsetdescriptor.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type refsetdescriptor.log >> oracle.log - -echo Load description type table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="descriptiontype.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type descriptiontype.log >> oracle.log - -echo Load mrcm attribute domain table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="mrcmattributedomain.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type mrcmattributedomain.log >> oracle.log - -echo Load mrcm module scope table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="mrcmmodulescope.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type mrcmmodulescope.log >> oracle.log - -echo Load mrcm attribute range table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="mrcmattributerange.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type mrcmattributerange.log >> oracle.log - -echo Load mrcm domain table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="mrcmdomain.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type mrcmdomain.log >> oracle.log - -echo Load module dependency table data >> oracle.log 2>&1 -%ORACLE_HOME%\bin\sqlldr %user%/%password%@%tns_name% control="moduledependency.ctl" >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1) -type moduledependency.log >> oracle.log - -echo Create indexes >> oracle.log 2>&1 -echo @oracle_indexes.sql|%ORACLE_HOME%\bin\sqlplus %user%/%password%@%tns_name% >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1 -goto trailer) - -echo Create views >> oracle.log 2>&1 -echo @oracle_views.sql|%ORACLE_HOME%\bin\sqlplus %user%/%password%@%tns_name% >> oracle.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1 -goto trailer) - -:trailer -echo ---------------------------------------- >> oracle.log 2>&1 -IF %error% NEQ 0 ( -echo There were one or more errors. >> oracle.log 2>&1 -set retval=-1 -) else ( -echo Completed without errors. >> oracle.log 2>&1 -set retval=0 -) -echo Finished ... >> oracle.log 2>&1 -date /T >> oracle.log 2>&1 -time /T >> oracle.log 2>&1 -echo ---------------------------------------- >> oracle.log 2>&1 -pause -exit %retval% diff --git a/src/main/resources/rf2/populate_oracle_db.sh b/src/main/resources/rf2/populate_oracle_db.sh index 1a0e9d7..9d9409a 100644 --- a/src/main/resources/rf2/populate_oracle_db.sh +++ b/src/main/resources/rf2/populate_oracle_db.sh @@ -2,112 +2,126 @@ # # Database connection parameters -# Please edit these variables to reflect your environment -# - Tested on Windows with "Git Bash" as a shell -# - # Set if necessary #export ORACLE_HOME=/app/oracle/product/12.1.0/dbhome_1 +# PLEASE EDIT THESE VARIABLES TO REFLECT YOUR ENVIRONMENT user=snomed password=snomed tns_name=ORCLCDB export NLS_LANG=AMERICAN_AMERICA.UTF8 -# Oracle Docker on Ubuntu does not allow removing the log file -# Do this step prior to starting Docker to execute populate scripts -# /bin/rm -f oracle.log -# touch oracle.log +# Clear the log file. If it doesn't exist, create it. +> oracle.log ef=0 -echo "See oracle.log for output" -echo "----------------------------------------" >> oracle.log 2>&1 -echo "Starting ... `/bin/date`" >> oracle.log 2>&1 -echo "----------------------------------------" >> oracle.log 2>&1 -echo "ORACLE_HOME = $ORACLE_HOME" >> oracle.log 2>&1 -echo "user = $user" >> oracle.log 2>&1 -echo "tns_name = $tns_name" >> oracle.log 2>&1 +echo "See oracle.log for detailed output" +echo "----------------------------------------" | tee -a oracle.log +echo "Starting ... `/bin/date`" | tee -a oracle.log +echo "----------------------------------------" | tee -a oracle.log +echo "ORACLE_HOME = $ORACLE_HOME" | tee -a oracle.log +echo "user = $user" | tee -a oracle.log +echo "tns_name = $tns_name" | tee -a oracle.log + + +DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -echo " Create tables ... `/bin/date`" >> oracle.log 2>&1 +echo " Compute transitive closure relationship file ... `/bin/date`" | tee -a oracle.log +relFile=$(find $DIR/Snapshot/Terminology/ -name "*_Relationship_Snapshot_*.txt" -print -quit) +$DIR/compute_transitive_closure.py --force --noself $relFile >> oracle.log 2>&1 +if [ $? -ne 0 ]; then ef=1; fi + +if [ $ef -ne 1 ]; then +echo " Create tables ... `/bin/date`" | tee -a oracle.log echo "@oracle_tables.sql" | $ORACLE_HOME/bin/sqlplus $user/$password@$tns_name >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi +fi +## Load RF2 tables if [ $ef -ne 1 ]; then -echo " Load concept table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load concept table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="concept.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat concept.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load description table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load description table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="description.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat description.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load identifier table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load identifier table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="identifier.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat identifier.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load relationship table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load relationship table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="relationship.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat relationship.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load relationship concrete values table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load relationship concrete values table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="relationshipconcretevalues.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat relationshipconcretevalues.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load owl expression table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load owl expression table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="owlexpression.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat owlexpression.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load stated relationship table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load stated relationship table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="statedrelationship.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat statedrelationship.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load text definition table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load text definition table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="textdefinition.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat textdefinition.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load association table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load association table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="association.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat association.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load attribute value table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load attribute value table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="attributevalue.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat attributevalue.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load simple refset table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load simple refset table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="simple.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat simple.log >> oracle.log fi +## Load TC table +if [ $ef -ne 1 ]; then +echo " Load transitive closure table ... `/bin/date`" | tee -a oracle.log +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="transitiveclosure.ctl" >> oracle.log 2>&1 +if [ $? -ne 0 ]; then ef=1; fi +cat concept.log >> oracle.log +fi + # No more complex maps # if [ $ef -ne 1 ]; then # echo " Load complex map table data ... `/bin/date`" >> oracle.log 2>&1 @@ -117,68 +131,68 @@ fi # fi if [ $ef -ne 1 ]; then -echo " Load extended map table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load extended map table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="extendedmap.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat extendedmap.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load simple map table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load simple map table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="simplemap.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat simplemap.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load language table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load language table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="language.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat language.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load refset descriptor table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load refset descriptor table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="refsetdescriptor.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat refsetdescriptor.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load description type table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load description type table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="descriptiontype.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat descriptiontype.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Load module dependency table data ... `/bin/date`" >> oracle.log 2>&1 +echo " Load module dependency table data ... `/bin/date`" | tee -a oracle.log $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="moduledependency.ctl" >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi cat moduledependency.log >> oracle.log fi if [ $ef -ne 1 ]; then -echo " Create indexes ... `/bin/date`" >> oracle.log 2>&1 +echo " Create indexes ... `/bin/date`" | tee -a oracle.log echo "@oracle_indexes.sql"|$ORACLE_HOME/bin/sqlplus $user/$password@$tns_name >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi if [ $ef -ne 1 ]; then -echo " Create views ... `/bin/date`" >> oracle.log 2>&1 +echo " Create views ... `/bin/date`" | tee -a oracle.log echo "@oracle_views.sql"|$ORACLE_HOME/bin/sqlplus $user/$password@$tns_name >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi -echo "----------------------------------------" >> oracle.log 2>&1 +echo "----------------------------------------" | tee -a oracle.log if [ $ef -eq 1 ] then - echo "There were one or more errors." >> oracle.log 2>&1 + echo "There were one or more errors." | tee -a oracle.log retval=-1 else - echo "Completed without errors." >> oracle.log 2>&1 + echo "Completed without errors." | tee -a oracle.log retval=0 fi -echo "Finished ... `/bin/date`" >> oracle.log 2>&1 -echo "----------------------------------------" >> oracle.log 2>&1 +echo "Finished ... `/bin/date`" | tee -a oracle.log +echo "----------------------------------------" | tee -a oracle.log exit $retval diff --git a/src/main/resources/rf2/populate_postgres_db.bat b/src/main/resources/rf2/populate_postgres_db.bat deleted file mode 100644 index 23a1811..0000000 --- a/src/main/resources/rf2/populate_postgres_db.bat +++ /dev/null @@ -1,54 +0,0 @@ -:: -:: Database connection parameters -:: Please edit these variables to reflect your environment -:: -set psql=C:/PostgreSQL/pg96/bin/psql.exe -set PGHOST=localhost -set PGUSER=postgres -set PGPASSWORD= -set PGDATABASE=snomed - -del postgres.log -echo. > postgres.log -echo ---------------------------------------- >> postgres.log 2>&1 -echo Starting ... >> postgres.log 2>&1 -date /T >> postgres.log 2>&1 -time /T >> postgres.log 2>&1 -echo ---------------------------------------- >> postgres.log 2>&1 -echo psql = %psql% >> postgres.log 2>&1 -echo user = %PGUSER% >> postgres.log 2>&1 -echo db_name = %PGDATABASE% >> postgres.log 2>&1 -set error=0 - -echo Create and load tables >> postgres.log 2>&1 -"%psql%" < psql_tables.sql >> postgres.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1 -goto trailer) - -echo Create indexes >> postgres.log 2>&1 -"%psql%" < psql_indexes.sql >> postgres.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1 -goto trailer) - -echo Create views >> postgres.log 2>&1 -"%psql%" < psql_views.sql >> postgres.log 2>&1 -IF %ERRORLEVEL% NEQ 0 (set error=1 -goto trailer) - -:trailer -echo ---------------------------------------- >> postgres.log 2>&1 -IF %error% NEQ 0 ( -echo There were one or more errors. Please reference the postgres.log file for details. >> postgres.log 2>&1 -set retval=-1 -) else ( -echo Completed without errors. >> postgres.log 2>&1 -set retval=0 -) -echo Finished ... >> postgres.log 2>&1 -date /T >> postgres.log 2>&1 -time /T >> postgres.log 2>&1 -echo ---------------------------------------- >> postgres.log 2>&1 - -pause -exit %retval% - diff --git a/src/main/resources/rf2/populate_postgres_db.sh b/src/main/resources/rf2/populate_postgres_db.sh index db25a83..e20198e 100644 --- a/src/main/resources/rf2/populate_postgres_db.sh +++ b/src/main/resources/rf2/populate_postgres_db.sh @@ -2,13 +2,8 @@ # # Database connection parameters -# Please edit these variables to reflect your environment -# - Tested with docker postgres 10, 11, 12, 13 (using docker postgres server and client) -# - PGHOST=host.docker.internal -# - Tested on Windows with "Git Bash" as a shell -# - and psql in the path -# -export PGHOST=localhost +# PLEASE EDIT THESE VARIABLES TO REFLECT YOUR ENVIRONMENT +export PGHOST=[UPDATE] export PGUSER=postgres export PGPASSWORD= export PGDATABASE=snomed @@ -19,37 +14,46 @@ ef=0 echo "See postgres.log for output" -echo "----------------------------------------" >> postgres.log 2>&1 -echo "Starting ... `/bin/date`" >> postgres.log 2>&1 -echo "----------------------------------------" >> postgres.log 2>&1 -echo "user = $PGUSER" >> postgres.log 2>&1 -echo "db_name = $PGDATABASE" >> postgres.log 2>&1 +echo "----------------------------------------" | tee -a postgres.log +echo "Starting ... `/bin/date`" | tee -a postgres.log +echo "----------------------------------------" | tee -a postgres.log +echo "user = $PGUSER" | tee -a postgres.log +echo "db_name = $PGDATABASE" | tee -a postgres.log + +DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +echo " Compute transitive closure relationship file ... `/bin/date`" | tee -a postgres.log +relFile=$(find $DIR/Snapshot/Terminology/ -name "*_Relationship_Snapshot_*.txt" -print -quit) +$DIR/compute_transitive_closure.pl --force --noself $relFile >> postgres.log 2>&1 +if [ $? -ne 0 ]; then ef=1; fi -echo " Create and load tables ... `/bin/date`" >> postgres.log 2>&1 +if [ $ef -ne 1 ]; then +echo " Create and load tables ... `/bin/date`" | tee -a postgres.log psql < psql_tables.sql >> postgres.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi +fi if [ $ef -ne 1 ]; then -echo " Create indexes ... `/bin/date`" >> postgres.log 2>&1 +echo " Create indexes ... `/bin/date`" | tee -a postgres.log psql < psql_indexes.sql >> postgres.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi if [ $ef -ne 1 ]; then -echo " Create views ... `/bin/date`" >> postgres.log 2>&1 +echo " Create views ... `/bin/date`" | tee -a postgres.log psql < psql_views.sql >> postgres.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi -echo "----------------------------------------" >> postgres.log 2>&1 +echo "----------------------------------------" | tee -a postgres.log if [ $ef -eq 1 ] then - echo "There were one or more errors." >> postgres.log 2>&1 + echo "There were one or more errors." | tee -a postgres.log retval=-1 else - echo "Completed without errors." >> postgres.log 2>&1 + echo "Completed without errors." | tee -a postgres.log retval=0 fi -echo "Finished ... `/bin/date`" >> postgres.log 2>&1 -echo "----------------------------------------" >> postgres.log 2>&1 +echo "Finished ... `/bin/date`" | tee -a postgres.log +echo "----------------------------------------" | tee -a postgres.log exit $retval diff --git a/src/main/resources/rf2/psql_tables.sql b/src/main/resources/rf2/psql_tables.sql index 07d1757..79726ff 100644 --- a/src/main/resources/rf2/psql_tables.sql +++ b/src/main/resources/rf2/psql_tables.sql @@ -151,7 +151,7 @@ CREATE TABLE textdefinition ( FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (conceptId) REFERENCES concept(id), FOREIGN KEY (typeId) REFERENCES concept(id), - FOREIGN KEY (caseSignificanceId) REFERENCES concept(id) + FOREIGN KEY (caseSignificanceId) REFERENCES concept(id) ); \copy textdefinition FROM 'Snapshot/Terminology/sct2_TextDefinition_Snapshot-en_${editionLabel}_${editionVersion}.txt' WITH DELIMITER E'\t' QUOTE E'\\' ENCODING 'UTF8' CSV HEADER; @@ -447,3 +447,16 @@ CREATE TABLE moduledependency ( ); \copy moduledependency FROM 'Snapshot/Refset/Metadata/der2_ssRefset_ModuleDependencySnapshot_${editionLabel}_${editionVersion}.txt' WITH DELIMITER E'\t' QUOTE E'\\' ENCODING 'UTF8' CSV HEADER; + +-- Transitive closure table. +DROP TABLE IF EXISTS transitiveclosure CASCADE; +CREATE TABLE transitiveclosure ( + superTypeId NUMERIC(20) NOT NULL, + subTypeId NUMERIC(20) NOT NULL, + depth INT NOT NULL, + PRIMARY KEY (superTypeId, subTypeId), + FOREIGN KEY (superTypeId) REFERENCES concept(id), + FOREIGN KEY (subTypeId) REFERENCES concept(id) +); + +\copy transitiveclosure FROM 'Snapshot/Terminology/sct2_TransitiveClosure_Snapshot_${editionLabel}_${editionVersion}.txt' WITH DELIMITER E'\t' QUOTE E'\\' ENCODING 'UTF8' CSV HEADER; diff --git a/src/main/resources/rf2/psql_views.sql b/src/main/resources/rf2/psql_views.sql index 3234ded..066ade4 100644 --- a/src/main/resources/rf2/psql_views.sql +++ b/src/main/resources/rf2/psql_views.sql @@ -1,4 +1,3 @@ - -- Concept Preferred Name view, used by other views. -- 900000000000013009 = Synonym description type -- 900000000000548007 = Preferred @@ -7,222 +6,294 @@ DROP VIEW IF EXISTS conceptpreferredname; CREATE VIEW conceptpreferredname AS SELECT c.id conceptId, NULLIF(d.term, 'no active preferred synonym') preferredName, d.id descriptionId FROM concept c -LEFT OUTER JOIN description d -ON c.id = d.conceptId -AND d.active = TRUE -AND d.typeId = 900000000000013009 -LEFT OUTER JOIN language l -ON d.id = l.referencedComponentId -AND l.active = TRUE -AND l.acceptabilityId = 900000000000548007 -AND l.refSetId = 900000000000509007 + LEFT OUTER JOIN description d + ON c.id = d.conceptId + AND d.active = TRUE + AND d.typeId = 900000000000013009 + LEFT OUTER JOIN language l + ON d.id = l.referencedComponentId + AND l.active = TRUE + AND l.acceptabilityId = 900000000000548007 + AND l.refSetId = 900000000000509007 WHERE (l.acceptabilityId IS NOT null OR d.TERM IS null); -- Concept table with names. DROP VIEW IF EXISTS conceptwithnames; CREATE VIEW conceptwithnames AS -SELECT id, cpn1.preferredName idName, effectiveTime, active, - moduleId, cpn2.preferredName moduleIdName, - definitionStatusId, cpn3.preferredName definitionStatusIdName +SELECT id, + cpn1.preferredName idName, + effectiveTime, + active, + moduleId, + cpn2.preferredName moduleIdName, + definitionStatusId, + cpn3.preferredName definitionStatusIdName FROM concept, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE id = cpn1.conceptId -AND moduleId = cpn2.conceptId -AND definitionStatusId = cpn3.conceptId; + AND moduleId = cpn2.conceptId + AND definitionStatusId = cpn3.conceptId; -- Description table. DROP VIEW IF EXISTS descriptionwithnames; CREATE VIEW descriptionwithnames AS -SELECT id, term, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - d.conceptId, cpn2.preferredName conceptIdName, - languageCode, - typeId, cpn3.preferredName typeIdName, - caseSignificanceId, cpn4.preferredName caseSignificanceIdName +SELECT id, + term, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + d.conceptId, + cpn2.preferredName conceptIdName, + languageCode, + typeId, + cpn3.preferredName typeIdName, + caseSignificanceId, + cpn4.preferredName caseSignificanceIdName FROM description d, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4 -WHERE moduleId = cpn1.conceptId AND d.conceptId = cpn2.conceptId AND typeId = cpn3.conceptId AND caseSignificanceId = cpn4.conceptId; + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4 +WHERE moduleId = cpn1.conceptId + AND d.conceptId = cpn2.conceptId + AND typeId = cpn3.conceptId + AND caseSignificanceId = cpn4.conceptId; -- Identifier table. DROP VIEW IF EXISTS identifierwithnames; CREATE VIEW identifierwithnames AS -SELECT identifierSchemeId, cpn1.preferredName identifierSchemeIdName, - alternateIdentifier, effectiveTime, active, - moduleId, cpn2.preferredName moduleIdName, - referencedComponentId +SELECT identifierSchemeId, + cpn1.preferredName identifierSchemeIdName, + alternateIdentifier, + effectiveTime, + active, + moduleId, + cpn2.preferredName moduleIdName, + referencedComponentId FROM identifier, - conceptpreferredname cpn1, - conceptpreferredname cpn2 + conceptpreferredname cpn1, + conceptpreferredname cpn2 WHERE identifierSchemeId = cpn1.conceptId -AND moduleId = cpn2.conceptId; + AND moduleId = cpn2.conceptId; -- Relationship table. DROP VIEW IF EXISTS relationshipwithnames; CREATE VIEW relationshipwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - sourceId, cpn2.preferredName sourceIdName, - destinationId, cpn3.preferredName destinationIdName, - relationshipGroup, - typeId, cpn4.preferredName typeIdName, - characteristicTypeId, cpn5.preferredName characteristicTypeIdName, - modifierId, cpn6.preferredName modifierIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + sourceId, + cpn2.preferredName sourceIdName, + destinationId, + cpn3.preferredName destinationIdName, + relationshipGroup, + typeId, + cpn4.preferredName typeIdName, + characteristicTypeId, + cpn5.preferredName characteristicTypeIdName, + modifierId, + cpn6.preferredName modifierIdName from relationship, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4, - conceptpreferredname cpn5, - conceptpreferredname cpn6 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4, + conceptpreferredname cpn5, + conceptpreferredname cpn6 WHERE moduleId = cpn1.conceptId -AND sourceId = cpn2.conceptId -AND destinationId = cpn3.conceptId -AND typeId = cpn4.conceptId -AND characteristicTypeId = cpn5.conceptId -AND modifierId = cpn6.conceptId; + AND sourceId = cpn2.conceptId + AND destinationId = cpn3.conceptId + AND typeId = cpn4.conceptId + AND characteristicTypeId = cpn5.conceptId + AND modifierId = cpn6.conceptId; -- Relationship concrete values table. DROP VIEW IF EXISTS relationshipconcretevalueswithnames; CREATE VIEW relationshipconcretevalueswithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - sourceId, cpn2.preferredName sourceIdName, - value, relationshipGroup, - typeId, cpn4.preferredName typeIdName, - characteristicTypeId, cpn5.preferredName characteristicTypeIdName, - modifierId, cpn6.preferredName modifierIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + sourceId, + cpn2.preferredName sourceIdName, + value, + relationshipGroup, + typeId, + cpn4.preferredName typeIdName, + characteristicTypeId, + cpn5.preferredName characteristicTypeIdName, + modifierId, + cpn6.preferredName modifierIdName from relationshipconcretevalues, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn4, - conceptpreferredname cpn5, - conceptpreferredname cpn6 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn4, + conceptpreferredname cpn5, + conceptpreferredname cpn6 WHERE moduleId = cpn1.conceptId -AND sourceId = cpn2.conceptId -AND typeId = cpn4.conceptId -AND characteristicTypeId = cpn5.conceptId -AND modifierId = cpn6.conceptId; + AND sourceId = cpn2.conceptId + AND typeId = cpn4.conceptId + AND characteristicTypeId = cpn5.conceptId + AND modifierId = cpn6.conceptId; -- OWL Expression table DROP VIEW IF EXISTS owlexpressionwithnames; CREATE VIEW owlexpressionwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - owlExpression +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + owlExpression from owlexpression, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- Stated Relationship table. DROP VIEW IF EXISTS statedrelationshipwithnames; CREATE VIEW statedrelationshipwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - sourceId, cpn2.preferredName sourceIdName, - destinationId, cpn3.preferredName destinationIdName, - relationshipGroup, - typeId, cpn4.preferredName typeIdName, - characteristicTypeId, cpn5.preferredName characteristicTypeIdName, - modifierId, cpn6.preferredName modifierIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + sourceId, + cpn2.preferredName sourceIdName, + destinationId, + cpn3.preferredName destinationIdName, + relationshipGroup, + typeId, + cpn4.preferredName typeIdName, + characteristicTypeId, + cpn5.preferredName characteristicTypeIdName, + modifierId, + cpn6.preferredName modifierIdName from statedrelationship, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4, - conceptpreferredname cpn5, - conceptpreferredname cpn6 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4, + conceptpreferredname cpn5, + conceptpreferredname cpn6 WHERE moduleId = cpn1.conceptId -AND sourceId = cpn2.conceptId -AND destinationId = cpn3.conceptId -AND typeId = cpn4.conceptId -AND characteristicTypeId = cpn5.conceptId -AND modifierId = cpn6.conceptId; + AND sourceId = cpn2.conceptId + AND destinationId = cpn3.conceptId + AND typeId = cpn4.conceptId + AND characteristicTypeId = cpn5.conceptId + AND modifierId = cpn6.conceptId; -- Text Definition table. DROP VIEW IF EXISTS textdefinitionwithnames; CREATE VIEW textdefinitionwithnames AS -SELECT id, term, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - td.conceptId, cpn2.preferredName conceptIdName, - languageCode, - typeId, cpn3.preferredName typeIdName, - caseSignificanceId, cpn4.preferredName caseSignificanceIdName +SELECT id, + term, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + td.conceptId, + cpn2.preferredName conceptIdName, + languageCode, + typeId, + cpn3.preferredName typeIdName, + caseSignificanceId, + cpn4.preferredName caseSignificanceIdName from textdefinition td, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4 WHERE moduleId = cpn1.conceptId -AND td.conceptId = cpn2.conceptId -AND typeId = cpn3.conceptId -AND caseSignificanceId = cpn4.conceptId; + AND td.conceptId = cpn2.conceptId + AND typeId = cpn3.conceptId + AND caseSignificanceId = cpn4.conceptId; -- Association refset table. DROP VIEW IF EXISTS associationwithnames; CREATE VIEW associationwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - targetComponent, cpn4.preferredName targetComponentName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + targetComponent, + cpn4.preferredName targetComponentName from association, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId -AND targetComponent = cpn4.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId + AND targetComponent = cpn4.conceptId; -- Attribute Value refset table. DROP VIEW IF EXISTS attributevaluewithnames; CREATE VIEW attributevaluewithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, REPLACE(cpn3.preferredName, 'no active preferred synonym', 'no such concept') referencedComponentIdName, - valueId, cpn4.preferredName valueIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + REPLACE(cpn3.preferredName, 'no active preferred synonym', 'no such concept') referencedComponentIdName, + valueId, + cpn4.preferredName valueIdName FROM attributevalue -LEFT OUTER JOIN conceptpreferredname cpn3 ON referencedComponentId = cpn3.conceptId -INNER JOIN conceptpreferredname cpn1 ON moduleId = cpn1.conceptId -INNER JOIN conceptpreferredname cpn2 ON refsetId = cpn2.conceptId -INNER JOIN conceptpreferredname cpn4 ON valueId = cpn4.conceptId; + LEFT OUTER JOIN conceptpreferredname cpn3 ON referencedComponentId = cpn3.conceptId + INNER JOIN conceptpreferredname cpn1 ON moduleId = cpn1.conceptId + INNER JOIN conceptpreferredname cpn2 ON refsetId = cpn2.conceptId + INNER JOIN conceptpreferredname cpn4 ON valueId = cpn4.conceptId; -- Simple refset table. DROP VIEW IF EXISTS simplewithnames; CREATE VIEW simplewithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName FROM simple, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- No more complex map, ICD9CM maps deprecated @@ -253,202 +324,282 @@ AND referencedComponentId = cpn3.conceptId; -- Extended Map refset table. DROP VIEW IF EXISTS extendedmapwithnames; CREATE VIEW extendedmapwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - mapGroup, - mapPriority, - mapRule, - mapAdvice, - mapTarget, - correlationId, cpn4.preferredName correlationIdName, - mapCategoryId, cpn5.preferredName mapCategoryIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + mapGroup, + mapPriority, + mapRule, + mapAdvice, + mapTarget, + correlationId, + cpn4.preferredName correlationIdName, + mapCategoryId, + cpn5.preferredName mapCategoryIdName FROM extendedmap, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4, - conceptpreferredname cpn5 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4, + conceptpreferredname cpn5 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId -AND correlationId = cpn4.conceptId -AND mapCategoryId = cpn5.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId + AND correlationId = cpn4.conceptId + AND mapCategoryId = cpn5.conceptId; -- Simple Map refset table. DROP VIEW IF EXISTS simplemapwithnames; CREATE VIEW simplemapwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - mapTarget +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + mapTarget FROM simplemap, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- Language refset table. DROP VIEW IF EXISTS languagewithnames; CREATE VIEW languagewithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - acceptabilityId, cpn4.preferredName acceptabilityIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + acceptabilityId, + cpn4.preferredName acceptabilityIdName FROM language, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.descriptionId -AND acceptabilityId = cpn4.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.descriptionId + AND acceptabilityId = cpn4.conceptId; -- Refset Descriptor refset table. DROP VIEW IF EXISTS refsetdescriptorwithnames; CREATE VIEW refsetdescriptorwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - attributeDescription, attributeType, attributeOrder +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + attributeDescription, + attributeType, + attributeOrder FROM refsetdescriptor, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- Description Type refset table. DROP VIEW IF EXISTS descriptiontypewithnames; CREATE VIEW descriptiontypewithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - descriptionFormat, descriptionLength +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + descriptionFormat, + descriptionLength FROM descriptiontype, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- MRCM Attribute Domain refset table. DROP VIEW IF EXISTS mrcmattributedomainwithnames; CREATE VIEW mrcmattributedomainwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - domainId, cpn4.preferredName domainIdName, - grouped, attributeCardinality, attributeInGroupCardinality, - ruleStrengthId, cpn4.preferredName ruleStrengthIdName, - contentTypeId, cpn4.preferredName contentTypeIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + domainId, + cpn4.preferredName domainIdName, + grouped, + attributeCardinality, + attributeInGroupCardinality, + ruleStrengthId, + cpn4.preferredName ruleStrengthIdName, + contentTypeId, + cpn4.preferredName contentTypeIdName FROM mrcmattributedomain, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4, - conceptpreferredname cpn5, - conceptpreferredname cpn6 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4, + conceptpreferredname cpn5, + conceptpreferredname cpn6 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId -AND domainId = cpn4.conceptId -AND ruleStrengthId = cpn5.conceptId -AND contentTypeId = cpn6.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId + AND domainId = cpn4.conceptId + AND ruleStrengthId = cpn5.conceptId + AND contentTypeId = cpn6.conceptId; -- MRCM Module Scope refset table. DROP VIEW IF EXISTS mrcmmodulescopewithnames; CREATE VIEW mrcmmodulescopewithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - mrcmRuleRefsetId, cpn4.preferredName mrcmRuleRefsetIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + mrcmRuleRefsetId, + cpn4.preferredName mrcmRuleRefsetIdName FROM mrcmmodulescope, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId -AND mrcmRuleRefsetId = cpn4.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId + AND mrcmRuleRefsetId = cpn4.conceptId; -- MRCM Attribute Range refset table. DROP VIEW IF EXISTS mrcmattributerangewithnames; CREATE VIEW mrcmattributerangewithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - rangeConstraint, attributeRule, - ruleStrengthId, cpn4.preferredName ruleStrengthIdName, - contentTypeId, cpn4.preferredName contentTypeIdName +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + rangeConstraint, + attributeRule, + ruleStrengthId, + cpn4.preferredName ruleStrengthIdName, + contentTypeId, + cpn4.preferredName contentTypeIdName FROM mrcmattributerange, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3, - conceptpreferredname cpn4, - conceptpreferredname cpn5 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3, + conceptpreferredname cpn4, + conceptpreferredname cpn5 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId -AND ruleStrengthId = cpn4.conceptId -AND contentTypeId = cpn5.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId + AND ruleStrengthId = cpn4.conceptId + AND contentTypeId = cpn5.conceptId; + - -- MRCM Domain refset table. DROP VIEW IF EXISTS mrcmdomainwithnames; CREATE VIEW mrcmdomainwithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - domainConstraint, parentDomain, - proximalPrimitiveConstraint, proximalPrimitiveRefinement, - domainTemplateForPrecoordination, - domainTemplateForPostcoordination, - guideURL +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + domainConstraint, + parentDomain, + proximalPrimitiveConstraint, + proximalPrimitiveRefinement, + domainTemplateForPrecoordination, + domainTemplateForPostcoordination, + guideURL FROM mrcmdomain, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; -- Module Dependency refset table. DROP VIEW IF EXISTS moduledependencywithnames; CREATE VIEW moduledependencywithnames AS -SELECT id, effectiveTime, active, - moduleId, cpn1.preferredName moduleIdName, - refsetId, cpn2.preferredName refsetIdName, - referencedComponentId, cpn3.preferredName referencedComponentIdName, - sourceEffectiveTime, targetEffectiveTime +SELECT id, + effectiveTime, + active, + moduleId, + cpn1.preferredName moduleIdName, + refsetId, + cpn2.preferredName refsetIdName, + referencedComponentId, + cpn3.preferredName referencedComponentIdName, + sourceEffectiveTime, + targetEffectiveTime FROM moduledependency, - conceptpreferredname cpn1, - conceptpreferredname cpn2, - conceptpreferredname cpn3 + conceptpreferredname cpn1, + conceptpreferredname cpn2, + conceptpreferredname cpn3 WHERE moduleId = cpn1.conceptId -AND refsetId = cpn2.conceptId -AND referencedComponentId = cpn3.conceptId; - + AND refsetId = cpn2.conceptId + AND referencedComponentId = cpn3.conceptId; + +-- transitive closure table with names +-- NOTE: this assumes conceptpreferredname has already been created +-- via the standard RF2 load scripts +DROP VIEW IF EXISTS transitiveclosurewithnames; +CREATE VIEW transitiveclosurewithnames AS +SELECT superTypeId, cpn1.preferredName superTypeName, + subTypeId, cpn2.preferredName subTypeName, a.depth +FROM transitiveclosure a, + conceptpreferredname cpn1, + conceptpreferredname cpn2 +WHERE a.superTypeId = cpn1.conceptId + AND a.subTypeId = cpn2.conceptId; diff --git a/src/main/resources/rf2/transitiveclosure.ctl b/src/main/resources/rf2/transitiveclosure.ctl new file mode 100644 index 0000000..9f587d5 --- /dev/null +++ b/src/main/resources/rf2/transitiveclosure.ctl @@ -0,0 +1,16 @@ +options (skip=1,direct=true) +load data +characterset UTF8 length semantics char +infile 'Snapshot/Terminology/sct2_TransitiveClosure_Snapshot_${editionLabel}_${editionVersion}.txt' "str X'0d0a'" +badfile 'transitiveclosure.bad' +discardfile 'transitiveclosure.dsc' +insert +into table transitiveclosure +reenable disabled_constraints +fields terminated by X'09' +trailing nullcols +( + superTypeId INTEGER EXTERNAL, + subTypeId INTEGER EXTERNAL, + depth INTEGER EXTERNAL +) \ No newline at end of file diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 5f4021d..44fc0f7 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -12,25 +12,25 @@ https://www.westcoastinformatics.com/products/db-load-scripts -- US Edition September 1: -Fall is upon us! Announcing #SNOMEDCT DB load and transitive -closure scripts for the 20230901 US Edition! Out-of-the-box +Spring is upon us! Announcing #SNOMEDCT DB load and transitive +closure scripts for the 20240301 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #MakingSnomedEasy #snomed https://www.westcoastinformatics.com/products/db-load-scripts ---- -Is it January already?! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20240101 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +Spring is upon us! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20240301 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/products/db-load-scripts #MakingTerminologyEasy #MakingSnomedEasy #snomedct This freely available solution enables one to load their #SQL database with the latest editions of #SNOMED. ### UMLS Users Mailing List -Subject: 20240101 SNOMEDCT DB load and transitive closure scripts +Subject: 20240301 SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the Jan 01, 2024 update of the SNOMEDCT INT Edition. +NLM recently posted the March 01, 2024 update of the SNOMEDCT US Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. diff --git a/src/test/resources/README-check-files.txt b/src/test/resources/README-check-files.md similarity index 73% rename from src/test/resources/README-check-files.txt rename to src/test/resources/README-check-files.md index 0182bb8..5f1ef76 100644 --- a/src/test/resources/README-check-files.txt +++ b/src/test/resources/README-check-files.md @@ -1,7 +1,11 @@ -# With a new download of SNOMED international edition or US edition, check that the file list -# still matches what we are loading. +# Check Files +With a new download of SNOMED international edition or US edition, check that the file list still matches what we are loading. -# Look for extra files (this should return zero rows) +## Look for extra files +- International Edition will return a 2, but these two files only contain 1 header file +- US Edition should return 0 + +``` find . -name "*txt" | grep -v Refset_Association | grep -v Refset_AttributeValue | grep -v Refset_SimpleSn |\ grep -v Refset_Language | grep -v Refset_ExtendedMap | grep -v Refset_SimpleMap |\ grep -v Refset_RefsetDescriptor | grep -v Refset_DescriptionType |\ @@ -11,8 +15,11 @@ find . -name "*txt" | grep -v Refset_Association | grep -v Refset_AttributeValue grep -v sct2_Identifier | grep -v sct2_Relationship_ | grep -v Refset_OWLExpression |\ grep -v sct2_StatedRelationship | grep -v sct2_TextDefinition |\ grep -v sct2_RelationshipConcreteValues | wc -l +``` -# Look that all files are there (this should equal 21) +## Look that all files are there +- Both editions should return 21 +``` find . -name "*txt" |\ perl -ne 'print if /Refset_Association|AttributeValue|Refset_SimpleSn/; \ print if /Refset_Language|Refset_ExtendedMap|Refset_SimpleMap/; \ @@ -21,5 +28,5 @@ find . -name "*txt" |\ print if /Refset_MRCMAttributeRange|Refset_ModuleDependency/; \ print if /Refset_MRCMDomain|sct2_Concept|sct2_Description/; \ print if /sct2_Identifier|sct2_Relationship(ConcreteValues)?_|Refset_OWLExpression/; \ - print if /sct2_StatedRelationship|sct2_TextDefinition/; \ - print if /sct2_TransitiveClosure/' | wc -l + print if /sct2_StatedRelationship|sct2_TextDefinition/' | wc -l +``` \ No newline at end of file diff --git a/src/test/resources/README-mysql-docker.md b/src/test/resources/README-mysql-docker.md new file mode 100644 index 0000000..982589d --- /dev/null +++ b/src/test/resources/README-mysql-docker.md @@ -0,0 +1,63 @@ +# BUILD INSTRUCTIONS +## Pre-requisites +Before proceeding, make sure you updated the hostname in the load script. + +## File Setup +``` + cd /wci/data + unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-mysql.*.zip + + sudo chmod +x rf2/populate_mysql_db.sh + sudo chmod +x rf2/compute_transitive_closure.pl + sudo chmod +x rf2/compute_transitive_closure.py + +``` +Follow the instructions for the version you are using below. + +### MySQL 8.0 + +1. Launch the container
+`docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mysql:8.0 --local_infile=ON` + + +2. Build Server +``` + export dir=/wci/data/ + cd $dir + docker run -it -v $dir:/data mysql:8.0 /bin/bash + + root@842bfb3da1f1:/# cd /data/rf2 + root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh +``` + +### MySQL 8.3 + +1. Launch the container
+ `docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mysql:8.3 --local_infile=ON` + + +2. Build Server +``` + export dir=/wci/data/ + cd $dir + docker run -it -v $dir:/data mysql:8.3 /bin/bash + + root@842bfb3da1f1:/# cd /data/rf2 + root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh +``` + +TODO: CHECK THE VERSION FOR MARIADB +### MariaDB - 10.11 +1. Launch the container
+`docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mariadb:10.11` + + +2. Build Server +``` + export dir=/wci/data/ + cd $dir + docker run -it -v $dir:/data mariadb:10.11 /bin/bash + + root@842bfb3da1f1:/# cd /data/rf2 + root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh +``` \ No newline at end of file diff --git a/src/test/resources/README-mysql-docker.txt b/src/test/resources/README-mysql-docker.txt deleted file mode 100644 index 57ec330..0000000 --- a/src/test/resources/README-mysql-docker.txt +++ /dev/null @@ -1,101 +0,0 @@ - -##### File Setup WINDOWS - -* Download the SNOMED distribution from NLM -* Unpack to c:/data/SnomedCT_International (for international edition) -* Unpack to c:/data/SnomedCT_US (for US edition) -* Clone and build these projects - * git@github.com:WestCoastInformatics/SNOMED-DB-Load-Scripts.git - * git@github.com:WestCoastInformatics/SNOMED-CT-Transitive-Closure.git -* Open the target/snomed*-mysql*zip file -* Copy the contents of the "rf2" directory to folder where SNOMED data is unpacked (see above) - -##### File Setup LINUX (BUILD SERVER) - -cd /wci/data -unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-mysql.*.zip -unzip -o /wci/projects/SNOMED-CT-Transitive-Closure/target/snomed-transitive-closure-mysql.*.zip -sudo chmod +x rf2/populate_mysql_db.sh -sudo chmod +x rf2/populate_mysql_db_tc.sh - -##### MySQL 5.7 - -# -# For testing mysql, run a docker mysql instance -# - https://hub.docker.com/_/mysql - -# -# Launch the container -# -docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mysql:5.7 - -# WINDOWS git bash (to simulate running in Linux) -# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) -dir=C:/data -docker run -it -v "$dir":/data mysql:5.7 /bin/bash -root@842bfb3da1f1:/# cd /data/SnomedCT_International -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh - - -# LINUX (BUILD SERVER) -# host = 172.17.0.1 (**make sure to edit this setting before proceeding) -export dir=/wci/data/ -cd $dir -docker run -it -v $dir:/data mysql:5.7 /bin/bash - -root@842bfb3da1f1:/# cd /data/rf2 -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh - -##### MySQL 8.0 - -# -# Launch the container -# -docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mysql:8.0 --local_infile=ON - -# WINDOWS git bash (to simulate running in Linux) -# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) -dir=C:/data -docker run -it -v "$dir":/data mysql:8.0 /bin/bash -root@842bfb3da1f1:/# cd /data/SnomedCT_International -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh - -# LINUX (BUILD SERVER) -# host = 172.17.0.1 (**make sure to edit this setting before proceeding) -export dir=/wci/data/ -cd $dir -docker run -it -v $dir:/data mysql:8.0 /bin/bash - -root@842bfb3da1f1:/# cd /data/rf2 -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh - -##### MariaDB - 10.11 - -# -# Launch the container -# -docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mariadb:10.11 - -# WINDOWS git bash (to simulate running in Linux) -# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) -dir=C:/data -docker run -it -v "$dir":/data mariadb:10.11 /bin/bash -root@842bfb3da1f1:/# cd /data/SnomedCT_International -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh - - -# LINUX (BUILD SERVER) -# host = 172.17.0.1 (**make sure to edit this setting before proceeding) -export dir=/wci/data/ -cd $dir -docker run -it -v $dir:/data mariadb:10.11 /bin/bash - -root@842bfb3da1f1:/# cd /data/rf2 -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_mysql_db_tc.sh - diff --git a/src/test/resources/README-oracle-docker.md b/src/test/resources/README-oracle-docker.md new file mode 100644 index 0000000..74b22bd --- /dev/null +++ b/src/test/resources/README-oracle-docker.md @@ -0,0 +1,68 @@ +# Oracle 12c BUILD INSTRUCTIONS +## Prerequisites +1. Log into DockerHub and agree to Oracle's Terms of Service + - [Oracle DB Enterprise Repository](https://container-registry.oracle.com/ords/f?p=113:1:103153009327673::::FSP_LANGUAGE_PREFERENCE:&cs=3vvrLolDIFGAxz-ReKVoNrPBwhCCJtGRffMagNzTnvafG3AeKT2KLWKQSclqKpS-c6TF2uprvjENxXOETZOmgfQ) + - Log in with your account and then click on "Continue" on the line enterprise. This will allow you to pull the Oracle Database Enterprise Edition image from the Oracle Container Registry. + - Pull the image from the Oracle Container Registry + - `docker login container-registry.oracle.com` and enter your hub.docker.com credentials + - `docker pull container-registry.oracle.com/database/enterprise:12.2.0.1-slim` + - `docker pull container-registry.oracle.com/database/enterprise:12.1.0.2` +2. For testing oracle, run a docker oracle instance + - https://dzone.com/articles/oracle-12c-image-installation-in-docker + +3. If you're running this locally, you will use `localhost` as the host. If you're running this on a remote server, + you will use the server's IP address as the host. + +4. If running an Oracle Database Docker Container on Linux use docker login and enter your hub.docker.com + credentials for image to download. + +# Instructions + +## File Setup +``` + cd /wci/data + unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-oracle.*.zip + sudo chmod +x rf2/populate_oracle_db.sh + sudo chmod +x rf2/compute_transitive_closure.py + + # To avoid permission issues, make sure to grant write perms to the all folders + chmod -R 777 rf2 +``` + +## If not running Docker as root +``` + cd $dir/rf2 + touch oracle.log concept.log description.log identifier.log relationship.log owlexpression.log statedrelationship.log textdefinition.log association.log attributevalue.log simple.log complexmap.log extendedmap.log simplemap.log language.log refsetdescriptor.log descriptiontype.log moduledependency.log relationshipconcretevalues.log + chmod a=rw oracle.log concept.log description.log identifier.log relationship.log owlexpression.log statedrelationship.log textdefinition.log association.log attributevalue.log simple.log complexmap.log extendedmap.log simplemap.log language.log refsetdescriptor.log descriptiontype.log moduledependency.log relationshipconcretevalues.log +``` + +## Launch the container +Create log files and allow read/write to all users. +``` + export dir=/wci/data/ + cd $dir + + #For store/oracle/database-enterprise:12.2.0.1-slim + sudo docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 container-registry.oracle.com/database/enterprise:12.2.0.1-slim + + #For container-registry.oracle.com/database/enterprise:12.1.0.2 + sudo docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 container-registry.oracle.com/database/enterprise:12.1.0.2 +``` +## Populate DB + +1. Launch the container + +`sudo docker exec -it snomed-oracle /bin/bash` + +2. Populate the database +``` + root@842bfb3da1f1:/# . /home/oracle/.bashrc + root@842bfb3da1f1:/# sqlplus sys/Oradoc_db1 as sysdba + alter session set "_ORACLE_SCRIPT"=true; + create user snomed identified by snomed; + GRANT CONNECT, RESOURCE, DBA TO snomed; + exit + + root@842bfb3da1f1:/# cd /data/rf2 + root@842bfb3da1f1:/data/rf2# ./populate_oracle_db.sh +``` diff --git a/src/test/resources/README-oracle-docker.txt b/src/test/resources/README-oracle-docker.txt deleted file mode 100644 index 094ea45..0000000 --- a/src/test/resources/README-oracle-docker.txt +++ /dev/null @@ -1,88 +0,0 @@ - -##### File Setup WINDOWS - -* Download the SNOMED distribution from NLM -* Unpack to c:/data/SnomedCT_International (for international edition) -* Unpack to c:/data/SnomedCT_US (for US edition) -* Clone and build these projects - * git@github.com:WestCoastInformatics/SNOMED-DB-Load-Scripts.git - * git@github.com:WestCoastInformatics/SNOMED-CT-Transitive-Closure.git -* Open the target/snomed*-oracle*zip file -* Copy the contents of the "rf2" directory to folder where SNOMED data is unpacked (see above) - -##### File Setup LINUX (BUILD SERVER) - -cd /wci/data -unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-oracle.*.zip -sudo chmod +x rf2/populate_oracle_db.sh -sudo chmod +x rf2/populate_oracle_db_tc.sh - -##### Oracle 12c - -# Prerequisites -# - Log into DockerHub and agree to Oracle's Terms of Service -# - https://hub.docker.com/_/oracle-database-enterprise-edition?tab=description (Click "Proceed to checkout") -# -# For testing oracle, run a docker oracle instance -# - https://dzone.com/articles/oracle-12c-image-installation-in-docker -# -# If running an Oracle Database Docker Container on Linux use docker login and enter your hub.docker.com -# credentials for image to download. -# - -# -# Launch the container WINDOWS -# -dir=C:/data -cd %dir% -docker run --name snomed-oracle -v %dir%:/data -d --rm -p 8080:8080 -p 1521:1521 store/oracle/database-enterprise:12.2.0.1-slim - - -# -# If not running Docker as root LINUX (BUILD SERVER) -# -cd $dir/rf2 -touch oracle.log concept.log description.log identifier.log relationship.log owlexpression.log statedrelationship.log textdefinition.log association.log attributevalue.log simple.log complexmap.log extendedmap.log simplemap.log language.log refsetdescriptor.log descriptiontype.log moduledependency.log relationshipconcretevalues.log -chmod a=rw oracle.log concept.log description.log identifier.log relationship.log owlexpression.log statedrelationship.log textdefinition.log association.log attributevalue.log simple.log complexmap.log extendedmap.log simplemap.log language.log refsetdescriptor.log descriptiontype.log moduledependency.log relationshipconcretevalues.log - -# -# Create log files and allow read/write to all users. -# Launch the container LINUX (BUILD SERVER) -# -export dir=/wci/data/ -cd $dir - -#For store/oracle/database-enterprise:12.2.0.1-slim -sudo docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 store/oracle/database-enterprise:12.2.0.1-slim - -#For container-registry.oracle.com/database/enterprise:12.1.0.2 -sudo docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 container-registry.oracle.com/database/enterprise:12.1.0.2 - -# -# populate_oracle_db.sh, populate_oracle_db_tc.sh -# -# Launch the container -# -sudo docker exec -it snomed-oracle /bin/bash - -root@842bfb3da1f1:/# . /home/oracle/.bashrc -root@842bfb3da1f1:/# sqlplus sys/Oradoc_db1 as sysdba -alter session set "_ORACLE_SCRIPT"=true; -create user snomed identified by snomed; -GRANT CONNECT, RESOURCE, DBA TO snomed; -exit - -root@842bfb3da1f1:/# cd /data/rf2 -root@842bfb3da1f1:/data/rf2# ./populate_oracle_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_oracle_db_tc.sh - -# -# Connect to Oracle database to query tables -# Skip docker exec command if still connected from prior step -# - -sudo docker exec -it snomed-oracle /bin/bash -root@842bfb3da1f1:/# . /home/oracle/.bashrc -root@842bfb3da1f1:/# sqlplus snomed/snomed@ORCLCDB - - diff --git a/src/test/resources/README-postgres-docker.md b/src/test/resources/README-postgres-docker.md new file mode 100644 index 0000000..b73b346 --- /dev/null +++ b/src/test/resources/README-postgres-docker.md @@ -0,0 +1,72 @@ +# BUILD INSTRUCTIONS +## Pre-requisites +Before proceeding, make sure you updated the PGHOST in the load script. + +## File Setup +``` + cd /wci/data + unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-postgres.*.zip + sudo chmod +x rf2/populate_postgres_db.sh + sudo chmod +x rf2/compute_transitive_closure.pl +``` + +* For testing postgres, run a docker postgres instance - https://hub.docker.com/_/postgres + +### Postgres 12.15 +1. Launch the container
+`docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:12.15` + + +2. Build Server +``` + export dir=/wci/data/ + cd $dir + docker run -it -v "$dir":/data postgres:12.15 /bin/bash + + root@842bfb3da1f1:/# cd /data/rf2 + root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh +``` + +### Postgres 13.11 +1. Launch the container
+`docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:13.11` + +2. Build Server +``` + export dir=/wci/data/ + cd $dir + docker run -it -v "$dir":/data postgres:13.11 /bin/bash + + root@842bfb3da1f1:/# cd /data/rf2 + root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh +``` + +### Postgres 14.8 +1. Launch the container
+`docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:14.8` + + +2. Build Server +``` + export dir=/wci/data/ + cd $dir + docker run -it -v "$dir":/data postgres:14.8 /bin/bash + + root@842bfb3da1f1:/# cd /data/rf2 + root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh +``` + +### Postgres 15.3 +1. Launch the container
+`docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:15.3` + + +2. Build Server +``` + export dir=/wci/data/ + cd $dir + docker run -it -v "$dir":/data postgres:15.3 /bin/bash + + root@842bfb3da1f1:/# cd /data/rf2 + root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh +``` \ No newline at end of file diff --git a/src/test/resources/README-postgres-docker.txt b/src/test/resources/README-postgres-docker.txt deleted file mode 100644 index f331e7f..0000000 --- a/src/test/resources/README-postgres-docker.txt +++ /dev/null @@ -1,125 +0,0 @@ - -##### File Setup WINDOWS - -* Download the SNOMED distribution from NLM -* Unpack to c:/data/SnomedCT_International (for international edition) -* Unpack to c:/data/SnomedCT_US (for US edition) -* Clone and build these projects - * git@github.com:WestCoastInformatics/SNOMED-DB-Load-Scripts.git - * git@github.com:WestCoastInformatics/SNOMED-CT-Transitive-Closure.git -* Open the target/snomed*-postgres*zip file -* Copy the contents of the "rf2" directory to folder where SNOMED data is unpacked (see above) -* Go to that directory and run transitive_closure.sh/bat to generate the transitive closure file - -##### File Setup LINUX (BUILD SERVER) - -cd /wci/data -unzip -o /wci/projects/SNOMED-CT-Transitive-Closure/target/snomed-transitive-closure-postgres.*.zip -unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-postgres.*.zip -sudo chmod +x rf2/populate_postgres_db.sh -sudo chmod +x rf2/populate_postgres_db_tc.sh - -# -# For testing postgres, run a docker postgres instance -# - https://hub.docker.com/_/postgres -# - -##### Postgres 12.15 -# -# Launch the container -# -docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:12.15 - -# WINDOWS git bash (to simulate running in Linux) -# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) -dir=C:/data -docker run -it -v "$dir":/data postgres:12.15 /bin/bash -root@842bfb3da1f1:/# cd /data/SnomedCT_International -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh - -# LINUX (BUILD SERVER) -# export PGHOST=172.17.0.1 (**make sure to edit this setting before proceeding) -export dir=/wci/data/ -cd $dir -docker run -it -v "$dir":/data postgres:12.15 /bin/bash - -root@842bfb3da1f1:/# cd /data/rf2 -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh - - -##### Postgres 13.11 -# -# Launch the container -# -docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:13.11 - -# WINDOWS git bash (to simulate running in Linux) -# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) -dir=C:/data -docker run -it -v "$dir":/data postgres:13.11 /bin/bash -root@842bfb3da1f1:/# cd /data/SnomedCT_International -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh - -# LINUX (BUILD SERVER) -# export PGHOST=172.17.0.1 (**make sure to edit this setting before proceeding) -export dir=/wci/data/ -cd $dir -docker run -it -v "$dir":/data postgres:13.11 /bin/bash - -root@842bfb3da1f1:/# cd /data/rf2 -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh - - -##### Postgres 14.8 -# -# Launch the container -# -docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:14.8 - -# WINDOWS git bash (to simulate running in Linux) -# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) -dir=C:/data -docker run -it -v "$dir":/data postgres:14.8 /bin/bash -root@842bfb3da1f1:/# cd /data/SnomedCT_International -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh - -# LINUX (BUILD SERVER) -# export PGHOST=172.17.0.1 (**make sure to edit this setting before proceeding) -export dir=/wci/data/ -cd $dir -docker run -it -v "$dir":/data postgres:14.8 /bin/bash - -root@842bfb3da1f1:/# cd /data/rf2 -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh - - - -##### Postgres 15.3 -# -# Launch the container -# -docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:15.3 - -# WINDOWS git bash (to simulate running in Linux) -# export PGHOST=host.docker.internal (**make sure to edit this setting before proceeding) -dir=C:/data -docker run -it -v "$dir":/data postgres:15.3 /bin/bash -root@842bfb3da1f1:/# cd /data/SnomedCT_International -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh - -# LINUX (BUILD SERVER) -# export PGHOST=172.17.0.1 (**make sure to edit this setting before proceeding) -export dir=/wci/data/ -cd $dir -docker run -it -v "$dir":/data postgres:15.3 /bin/bash - -root@842bfb3da1f1:/# cd /data/rf2 -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh -root@842bfb3da1f1:/data/rf2# ./populate_postgres_db_tc.sh From 9abdc8024a2666e54dfcac3bde8879f26182190f Mon Sep 17 00:00:00 2001 From: "Alicia G." Date: Thu, 7 Mar 2024 08:47:34 -0800 Subject: [PATCH 70/95] Added check for python and perl to oracle and postgres --- src/main/resources/rf2/populate_oracle_db.sh | 18 ++++++++++++++++-- src/main/resources/rf2/populate_postgres_db.sh | 18 ++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/main/resources/rf2/populate_oracle_db.sh b/src/main/resources/rf2/populate_oracle_db.sh index 9d9409a..5081f6d 100644 --- a/src/main/resources/rf2/populate_oracle_db.sh +++ b/src/main/resources/rf2/populate_oracle_db.sh @@ -27,8 +27,22 @@ DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) echo " Compute transitive closure relationship file ... `/bin/date`" | tee -a oracle.log relFile=$(find $DIR/Snapshot/Terminology/ -name "*_Relationship_Snapshot_*.txt" -print -quit) -$DIR/compute_transitive_closure.py --force --noself $relFile >> oracle.log 2>&1 -if [ $? -ne 0 ]; then ef=1; fi +#check if system has python or perl, run the corresponding script +if command -v python &> /dev/null +then + echo "python found, running python script" >> mysql.log 2>&1 + python $DIR/compute_transitive_closure.py --force --noself $relFile >> mysql.log 2>&1 + if [ $? -ne 0 ]; then ef=1; fi +elif command -v perl &> /dev/null +then + echo "perl found, running perl script" >> mysql.log 2>&1 + perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> mysql.log 2>&1 + if [ $? -ne 0 ]; then ef=1; fi +# if none are present, print error message +else + echo "No python or perl found. Please install one of them." | tee -a mysql.log + ef=1 +fi if [ $ef -ne 1 ]; then echo " Create tables ... `/bin/date`" | tee -a oracle.log diff --git a/src/main/resources/rf2/populate_postgres_db.sh b/src/main/resources/rf2/populate_postgres_db.sh index e20198e..8e55cf5 100644 --- a/src/main/resources/rf2/populate_postgres_db.sh +++ b/src/main/resources/rf2/populate_postgres_db.sh @@ -24,8 +24,22 @@ DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) echo " Compute transitive closure relationship file ... `/bin/date`" | tee -a postgres.log relFile=$(find $DIR/Snapshot/Terminology/ -name "*_Relationship_Snapshot_*.txt" -print -quit) -$DIR/compute_transitive_closure.pl --force --noself $relFile >> postgres.log 2>&1 -if [ $? -ne 0 ]; then ef=1; fi +#check if system has python or perl, run the corresponding script +if command -v python &> /dev/null +then + echo "python found, running python script" >> mysql.log 2>&1 + python $DIR/compute_transitive_closure.py --force --noself $relFile >> mysql.log 2>&1 + if [ $? -ne 0 ]; then ef=1; fi +elif command -v perl &> /dev/null +then + echo "perl found, running perl script" >> mysql.log 2>&1 + perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> mysql.log 2>&1 + if [ $? -ne 0 ]; then ef=1; fi +# if none are present, print error message +else + echo "No python or perl found. Please install one of them." | tee -a mysql.log + ef=1 +fi if [ $ef -ne 1 ]; then echo " Create and load tables ... `/bin/date`" | tee -a postgres.log From a63a7c8e2122ffc9044eeef059349bc5dfe8639d Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Fri, 8 Mar 2024 23:01:29 +0000 Subject: [PATCH 71/95] Update READMEs for announcement --- README.md | 7 ------- src/main/resources/HOWTO.md | 4 ++++ src/main/resources/README.md | 4 ++++ src/test/resources/README-announcements.txt | 8 ++++---- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 8069108..c926b32 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,6 @@ Minimum Specification - Oracle v12.+ - Postgres v13.+, v14.+, v15.+, v16.+ -Prerequisites -------------- -If loading transitive closure table into a database, first load SNOMED in RF2 -using the database load scripts you can also find at the URL above. This is -important because it creates a view that allows for denormalization of preferred -concept names, thus making the transitive closure table more useful. - Installation ------------ * See [HOWTO.md](src/main/resources/HOWTO.md) file to understand how to load the rf2 files into the database diff --git a/src/main/resources/HOWTO.md b/src/main/resources/HOWTO.md index efec336..0beb5b0 100644 --- a/src/main/resources/HOWTO.md +++ b/src/main/resources/HOWTO.md @@ -1,6 +1,10 @@ # How To Use the SNOMED CT Database Loader This HOWTO describes how to use the installer scripts to load SNOMEDCT into a database. +## Watch the Demo Video + +See [https://youtu.be/917T6D3b5ro](https://youtu.be/917T6D3b5ro) + ## Installation 1. Download the database loader zip file from the https://www.westcoastinformatics.com/products/db-load-scripts website. Select the appropriate database-version pair (i.e. oracle-US Edition). Depending on your database and edition, identify the appropriate target's zip file. diff --git a/src/main/resources/README.md b/src/main/resources/README.md index cad555c..f564e4b 100644 --- a/src/main/resources/README.md +++ b/src/main/resources/README.md @@ -16,5 +16,9 @@ Go to the above link for documentation, and additional downloads. * Builds transitive closure table from RF2 snapshot, inferred, SNOMEDCT file. * Views with denormalized concept preferred names +## Watch the Demo Video + +See [https://youtu.be/917T6D3b5ro](https://youtu.be/917T6D3b5ro) + ### Developer Notes https://github.com/WestCoastInformatics/SNOMED-DB-Load-Scripts diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 44fc0f7..f876698 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -10,12 +10,12 @@ support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #MakingSnomedEasy #snomed https://www.westcoastinformatics.com/products/db-load-scripts --- US Edition September 1: +-- US Edition March 1: Spring is upon us! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20240301 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. -#MakingTerminologyEasy #MakingSnomedEasy #snomed +#MakingTerminologyEasy #snomedct #termhub https://www.westcoastinformatics.com/products/db-load-scripts ---- @@ -47,9 +47,9 @@ This utility is freely available through our website: - https://github.com/WestCoastInformatics/SNOMED-CT-Transitive-Closure * Updated Training video: - - https://youtu.be/f6akQZObZrs + - https://youtu.be/917T6D3b5ro Feel free to share this announcement with others or retweet the announcement - https://twitter.com/wcinformatics/status/ ! -https://twitter.com/wcinformatics/status/1707085396663013545 +https://twitter.com/wcinformatics/status/1766236868088386039 From de18d8f357e669e179fa8efcbd9db7914c45569e Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Fri, 8 Mar 2024 23:11:27 +0000 Subject: [PATCH 72/95] Update READMEs for announcement --- src/test/resources/README-announcements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index f876698..463d560 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -40,7 +40,7 @@ This utility is freely available through our website: * Information and download: https://www.westcoastinformatics.com/products/db-load-scripts - See the "DB Load Scripts" section - - See the "Transitive Closure Scripts" section + - These scripts have been updated to automatically compute a transitive closure table and load it also * Github projects: - https://github.com/WestCoastInformatics/SNOMED-DB-Load-Scripts From 40b168e9679ea671446e53fb8b573828973592bd Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Wed, 27 Mar 2024 18:17:45 +0100 Subject: [PATCH 73/95] Update announcement --- src/test/resources/README-announcements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 463d560..adc9019 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -42,9 +42,8 @@ This utility is freely available through our website: - See the "DB Load Scripts" section - These scripts have been updated to automatically compute a transitive closure table and load it also -* Github projects: +* Github project: - https://github.com/WestCoastInformatics/SNOMED-DB-Load-Scripts - - https://github.com/WestCoastInformatics/SNOMED-CT-Transitive-Closure * Updated Training video: - https://youtu.be/917T6D3b5ro From 3f5b9621b1c28e7b029cc197deb443d7f80f49cb Mon Sep 17 00:00:00 2001 From: gaalici1990 Date: Tue, 16 Jul 2024 11:50:35 -0700 Subject: [PATCH 74/95] updating version for July INT download --- pom.xml | 2 +- src/test/resources/README-announcements.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 3ae5e66..7e0ebcb 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ true - 20240101 + 20240701 Core INT diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index adc9019..98da868 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -20,17 +20,17 @@ https://www.westcoastinformatics.com/products/db-load-scripts ---- -Spring is upon us! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20240301 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +Summer is in full swing! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20240701 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/products/db-load-scripts #MakingTerminologyEasy #MakingSnomedEasy #snomedct This freely available solution enables one to load their #SQL database with the latest editions of #SNOMED. ### UMLS Users Mailing List -Subject: 20240301 SNOMEDCT DB load and transitive closure scripts +Subject: 202400701 SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the March 01, 2024 update of the SNOMEDCT US Edition. +NLM recently posted the July 01, 2024 update of the SNOMEDCT International Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. From e56f08a30f4ae3b6476aa94a2c49c033b5702657 Mon Sep 17 00:00:00 2001 From: gaalici1990 Date: Thu, 18 Jul 2024 12:44:21 -0700 Subject: [PATCH 75/95] OP-783 - fixing typos for log outputs --- src/main/resources/rf2/populate_oracle_db.sh | 6 +++--- src/main/resources/rf2/populate_postgres_db.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/resources/rf2/populate_oracle_db.sh b/src/main/resources/rf2/populate_oracle_db.sh index 5081f6d..f5b210f 100644 --- a/src/main/resources/rf2/populate_oracle_db.sh +++ b/src/main/resources/rf2/populate_oracle_db.sh @@ -31,16 +31,16 @@ relFile=$(find $DIR/Snapshot/Terminology/ -name "*_Relationship_Snapshot_*.txt" if command -v python &> /dev/null then echo "python found, running python script" >> mysql.log 2>&1 - python $DIR/compute_transitive_closure.py --force --noself $relFile >> mysql.log 2>&1 + python $DIR/compute_transitive_closure.py --force --noself $relFile >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi elif command -v perl &> /dev/null then echo "perl found, running perl script" >> mysql.log 2>&1 - perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> mysql.log 2>&1 + perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi # if none are present, print error message else - echo "No python or perl found. Please install one of them." | tee -a mysql.log + echo "No python or perl found. Please install one of them." | tee -a oracle.log ef=1 fi diff --git a/src/main/resources/rf2/populate_postgres_db.sh b/src/main/resources/rf2/populate_postgres_db.sh index 8e55cf5..1c0c96c 100644 --- a/src/main/resources/rf2/populate_postgres_db.sh +++ b/src/main/resources/rf2/populate_postgres_db.sh @@ -28,16 +28,16 @@ relFile=$(find $DIR/Snapshot/Terminology/ -name "*_Relationship_Snapshot_*.txt" if command -v python &> /dev/null then echo "python found, running python script" >> mysql.log 2>&1 - python $DIR/compute_transitive_closure.py --force --noself $relFile >> mysql.log 2>&1 + python $DIR/compute_transitive_closure.py --force --noself $relFile >> postgres.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi elif command -v perl &> /dev/null then echo "perl found, running perl script" >> mysql.log 2>&1 - perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> mysql.log 2>&1 + perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> postgres.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi # if none are present, print error message else - echo "No python or perl found. Please install one of them." | tee -a mysql.log + echo "No python or perl found. Please install one of them." | tee -a postgres.log ef=1 fi From 59110d73c46bb47caabc2b68a9e1acfc248ac471 Mon Sep 17 00:00:00 2001 From: gaalici1990 Date: Thu, 18 Jul 2024 14:14:26 -0700 Subject: [PATCH 76/95] fixing remaining to log typos --- src/main/resources/rf2/populate_oracle_db.sh | 4 ++-- src/main/resources/rf2/populate_postgres_db.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/resources/rf2/populate_oracle_db.sh b/src/main/resources/rf2/populate_oracle_db.sh index f5b210f..e343b8e 100644 --- a/src/main/resources/rf2/populate_oracle_db.sh +++ b/src/main/resources/rf2/populate_oracle_db.sh @@ -30,12 +30,12 @@ relFile=$(find $DIR/Snapshot/Terminology/ -name "*_Relationship_Snapshot_*.txt" #check if system has python or perl, run the corresponding script if command -v python &> /dev/null then - echo "python found, running python script" >> mysql.log 2>&1 + echo "python found, running python script" >> oracle.log 2>&1 python $DIR/compute_transitive_closure.py --force --noself $relFile >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi elif command -v perl &> /dev/null then - echo "perl found, running perl script" >> mysql.log 2>&1 + echo "perl found, running perl script" >> oracle.log 2>&1 perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> oracle.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi # if none are present, print error message diff --git a/src/main/resources/rf2/populate_postgres_db.sh b/src/main/resources/rf2/populate_postgres_db.sh index 1c0c96c..7058aef 100644 --- a/src/main/resources/rf2/populate_postgres_db.sh +++ b/src/main/resources/rf2/populate_postgres_db.sh @@ -27,12 +27,12 @@ relFile=$(find $DIR/Snapshot/Terminology/ -name "*_Relationship_Snapshot_*.txt" #check if system has python or perl, run the corresponding script if command -v python &> /dev/null then - echo "python found, running python script" >> mysql.log 2>&1 + echo "python found, running python script" >> postgres.log 2>&1 python $DIR/compute_transitive_closure.py --force --noself $relFile >> postgres.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi elif command -v perl &> /dev/null then - echo "perl found, running perl script" >> mysql.log 2>&1 + echo "perl found, running perl script" >> postgres.log 2>&1 perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> postgres.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi # if none are present, print error message From aaf5ef9b959eb976fc3c0192726bd04654010ad0 Mon Sep 17 00:00:00 2001 From: "Alicia G." <32443614+gaaliciA1990@users.noreply.github.com> Date: Mon, 22 Jul 2024 09:51:59 -0700 Subject: [PATCH 77/95] OP-721 Increased the max length for areas with 255 to 4096 (#4) --- src/main/resources/rf2/description.ctl | 2 +- src/main/resources/rf2/identifier.ctl | 2 +- src/main/resources/rf2/mysql_tables.sql | 4 ++-- src/main/resources/rf2/oracle_tables.sql | 4 ++-- src/main/resources/rf2/psql_tables.sql | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/resources/rf2/description.ctl b/src/main/resources/rf2/description.ctl index b0b2b74..156b8fe 100644 --- a/src/main/resources/rf2/description.ctl +++ b/src/main/resources/rf2/description.ctl @@ -17,6 +17,6 @@ trailing nullcols conceptId INTEGER EXTERNAL, languageCode CHAR(2), typeId INTEGER EXTERNAL, - term CHAR(255), + term CHAR(4096), caseSignificanceId INTEGER EXTERNAL ) \ No newline at end of file diff --git a/src/main/resources/rf2/identifier.ctl b/src/main/resources/rf2/identifier.ctl index 132673a..6231ec1 100644 --- a/src/main/resources/rf2/identifier.ctl +++ b/src/main/resources/rf2/identifier.ctl @@ -11,7 +11,7 @@ fields terminated by X'09' trailing nullcols ( identifierSchemeId INTEGER EXTERNAL, - alternateIdentifier CHAR(255), + alternateIdentifier CHAR(4096), effectiveTime DATE "YYYYMMDD", active INTEGER EXTERNAL, moduleId INTEGER EXTERNAL, diff --git a/src/main/resources/rf2/mysql_tables.sql b/src/main/resources/rf2/mysql_tables.sql index 525577c..f70f3b1 100644 --- a/src/main/resources/rf2/mysql_tables.sql +++ b/src/main/resources/rf2/mysql_tables.sql @@ -39,7 +39,7 @@ CREATE TABLE description conceptId NUMERIC(20) NOT NULL, languageCode CHAR(2) NOT NULL, typeId NUMERIC(20) NOT NULL, - term VARCHAR(255) NOT NULL, + term VARCHAR(4096) NOT NULL, caseSignificanceId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept (id), FOREIGN KEY (conceptId) REFERENCES concept (id), @@ -66,7 +66,7 @@ DROP TABLE IF EXISTS identifier; CREATE TABLE identifier ( identifierSchemeId NUMERIC(20) NOT NULL, - alternateIdentifier VARCHAR(255) NOT NULL, + alternateIdentifier VARCHAR(4096) NOT NULL, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, moduleId NUMERIC(20) NOT NULL, diff --git a/src/main/resources/rf2/oracle_tables.sql b/src/main/resources/rf2/oracle_tables.sql index 778db2a..b4ba707 100644 --- a/src/main/resources/rf2/oracle_tables.sql +++ b/src/main/resources/rf2/oracle_tables.sql @@ -58,7 +58,7 @@ CREATE TABLE description conceptId NUMERIC(20) NOT NULL, languageCode CHAR(2) NOT NULL, typeId NUMERIC(20) NOT NULL, - term VARCHAR2(255) NOT NULL, + term VARCHAR2(4096) NOT NULL, caseSignificanceId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept (id), FOREIGN KEY (conceptId) REFERENCES concept (id), @@ -72,7 +72,7 @@ EXECUTE drop_table('identifier'); CREATE TABLE identifier ( identifierSchemeId NUMERIC(20) NOT NULL, - alternateIdentifier VARCHAR2(255) NOT NULL, + alternateIdentifier VARCHAR2(4096) NOT NULL, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, moduleId NUMERIC(20) NOT NULL, diff --git a/src/main/resources/rf2/psql_tables.sql b/src/main/resources/rf2/psql_tables.sql index 79726ff..643671f 100644 --- a/src/main/resources/rf2/psql_tables.sql +++ b/src/main/resources/rf2/psql_tables.sql @@ -23,7 +23,7 @@ CREATE TABLE description ( conceptId NUMERIC(20) NOT NULL, languageCode CHAR(2) NOT NULL, typeId NUMERIC(20) NOT NULL, - term VARCHAR(255) NOT NULL, + term VARCHAR(4096) NOT NULL, caseSignificanceId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept(id), FOREIGN KEY (conceptId) REFERENCES concept(id), @@ -37,7 +37,7 @@ CREATE TABLE description ( DROP TABLE IF EXISTS identifier CASCADE; CREATE TABLE identifier ( identifierSchemeId NUMERIC(20) NOT NULL, - alternateIdentifier VARCHAR(255) NOT NULL, + alternateIdentifier VARCHAR(4096) NOT NULL, effectiveTime DATE NOT NULL, active BOOLEAN NOT NULL, moduleId NUMERIC(20) NOT NULL, From 74e29502d18d239982c18be3c10a068baba6892e Mon Sep 17 00:00:00 2001 From: gaalici1990 Date: Thu, 12 Sep 2024 15:18:18 -0700 Subject: [PATCH 78/95] OP-839 Updated populate script to check for perl first --- src/main/resources/rf2/populate_mysql_db.sh | 14 +++++++------- src/main/resources/rf2/populate_oracle_db.sh | 14 +++++++------- src/main/resources/rf2/populate_postgres_db.sh | 16 ++++++++-------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/main/resources/rf2/populate_mysql_db.sh b/src/main/resources/rf2/populate_mysql_db.sh index e98a63c..5268cfd 100644 --- a/src/main/resources/rf2/populate_mysql_db.sh +++ b/src/main/resources/rf2/populate_mysql_db.sh @@ -32,19 +32,19 @@ DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) echo " Compute transitive closure relationship file ... `/bin/date`" | tee -a mysql.log relFile=$(find $DIR/Snapshot/Terminology/ -name "*_Relationship_Snapshot_*.txt" -print -quit) #check if system has python or perl, run the corresponding script -if command -v python &> /dev/null +if command -v perl &> /dev/null then - echo "python found, running python script" >> mysql.log 2>&1 - python $DIR/compute_transitive_closure.py --force --noself $relFile >> mysql.log 2>&1 + echo "perl found, running perl script" >> postgres.log 2>&1 + perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> postgres.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi -elif command -v perl &> /dev/null +elif command -v python &> /dev/null then - echo "perl found, running perl script" >> mysql.log 2>&1 - perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> mysql.log 2>&1 + echo "python found, running python script" >> postgres.log 2>&1 + python $DIR/compute_transitive_closure.py --force --noself $relFile >> postgres.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi # if none are present, print error message else - echo "No python or perl found. Please install one of them." | tee -a mysql.log + echo "No perl or python found on your machine. Please install one of them to proceed." | tee -a postgres.log ef=1 fi diff --git a/src/main/resources/rf2/populate_oracle_db.sh b/src/main/resources/rf2/populate_oracle_db.sh index e343b8e..c6b5e8f 100644 --- a/src/main/resources/rf2/populate_oracle_db.sh +++ b/src/main/resources/rf2/populate_oracle_db.sh @@ -28,19 +28,19 @@ DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) echo " Compute transitive closure relationship file ... `/bin/date`" | tee -a oracle.log relFile=$(find $DIR/Snapshot/Terminology/ -name "*_Relationship_Snapshot_*.txt" -print -quit) #check if system has python or perl, run the corresponding script -if command -v python &> /dev/null +if command -v perl &> /dev/null then - echo "python found, running python script" >> oracle.log 2>&1 - python $DIR/compute_transitive_closure.py --force --noself $relFile >> oracle.log 2>&1 + echo "perl found, running perl script" >> postgres.log 2>&1 + perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> postgres.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi -elif command -v perl &> /dev/null +elif command -v python &> /dev/null then - echo "perl found, running perl script" >> oracle.log 2>&1 - perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> oracle.log 2>&1 + echo "python found, running python script" >> postgres.log 2>&1 + python $DIR/compute_transitive_closure.py --force --noself $relFile >> postgres.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi # if none are present, print error message else - echo "No python or perl found. Please install one of them." | tee -a oracle.log + echo "No perl or python found on your machine. Please install one of them to proceed." | tee -a postgres.log ef=1 fi diff --git a/src/main/resources/rf2/populate_postgres_db.sh b/src/main/resources/rf2/populate_postgres_db.sh index 7058aef..b24efd8 100644 --- a/src/main/resources/rf2/populate_postgres_db.sh +++ b/src/main/resources/rf2/populate_postgres_db.sh @@ -24,20 +24,20 @@ DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) echo " Compute transitive closure relationship file ... `/bin/date`" | tee -a postgres.log relFile=$(find $DIR/Snapshot/Terminology/ -name "*_Relationship_Snapshot_*.txt" -print -quit) -#check if system has python or perl, run the corresponding script -if command -v python &> /dev/null -then - echo "python found, running python script" >> postgres.log 2>&1 - python $DIR/compute_transitive_closure.py --force --noself $relFile >> postgres.log 2>&1 - if [ $? -ne 0 ]; then ef=1; fi -elif command -v perl &> /dev/null +#check if system has perl first, then python, run the corresponding script +if command -v perl &> /dev/null then echo "perl found, running perl script" >> postgres.log 2>&1 perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> postgres.log 2>&1 if [ $? -ne 0 ]; then ef=1; fi +elif command -v python &> /dev/null +then + echo "python found, running python script" >> postgres.log 2>&1 + python $DIR/compute_transitive_closure.py --force --noself $relFile >> postgres.log 2>&1 + if [ $? -ne 0 ]; then ef=1; fi # if none are present, print error message else - echo "No python or perl found. Please install one of them." | tee -a postgres.log + echo "No perl or python found on your machine. Please install one of them to proceed." | tee -a postgres.log ef=1 fi From 4e23887e615ef1e48031bf83d9323851a8761645 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Thu, 10 Oct 2024 01:00:00 +0100 Subject: [PATCH 79/95] Updates for announcement --- src/test/resources/README-announcements.txt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 98da868..ec2b2df 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -1,6 +1,6 @@ ## Sample texts for announcing new releases -### Twitter, LinkedIn, Facebook +### Twitter -- SNOMED International Jan 1: @@ -20,17 +20,22 @@ https://www.westcoastinformatics.com/products/db-load-scripts ---- -Summer is in full swing! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20240701 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. -See https://westcoastinformatics.com/products/db-load-scripts #MakingTerminologyEasy #MakingSnomedEasy #snomedct +### LinkedIn -This freely available solution enables one to load their #SQL database with the latest editions of #SNOMED. +At West Coast Informatics, we are experts in loading healthcare terminology data +into standard databases. Announcing updates to our Database Load Scripts for the +20240901 US Edition of SNOMEDCT. +Download now at https://www.westcoastinformatics.com/products/db-load-scripts + +These tools are designed to provide an easy mechanism to load SNOMEDCT into Postgres, MySQL (or MariaDB), or Oracle databases. These resources are free to use and will assist you with loading core SNOMED CT data and transitive closure tables into supported environments. These projects are hosted on Github and we welcome any feedback or community contributions. +#MakingTerminologyEasy #MakingSnomedEasy #snomedct ### UMLS Users Mailing List -Subject: 202400701 SNOMEDCT DB load and transitive closure scripts +Subject: 20240901 SNOMEDCT US Edition DB load and transitive closure scripts Hi all, -NLM recently posted the July 01, 2024 update of the SNOMEDCT International Edition. +NLM recently posted the September 01, 2024 update of the SNOMEDCT US Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. From 646ed8e9a378e285a88fedf7b18b1bdf3bfddfaa Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Thu, 9 Jan 2025 12:21:47 -0800 Subject: [PATCH 80/95] OP-854: update python script to calculate transitive closures --- .../rf2/compute_transitive_closure.py | 175 ++++++++---------- 1 file changed, 79 insertions(+), 96 deletions(-) diff --git a/src/main/resources/rf2/compute_transitive_closure.py b/src/main/resources/rf2/compute_transitive_closure.py index e511bc1..90a2f5c 100644 --- a/src/main/resources/rf2/compute_transitive_closure.py +++ b/src/main/resources/rf2/compute_transitive_closure.py @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 2024 West Coast Informatics, Inc +# Copyright 2025 West Coast Informatics, Inc # # Computes transitive closure from a snapshot inferred RF2 relationships file. # @@ -11,6 +11,7 @@ import argparse import time import logging +from typing import Dict, List, Any # # Set Defaults & Environment @@ -47,48 +48,33 @@ def __call__(self, parser, namespace, values, option_string=None): ## Function to parse arguments def parse_args(): parser = argparse.ArgumentParser(add_help=False) - parser.add_argument('--history', choices=['min', 'mod', 'max']) + parser.add_argument('--history-min', action='store_const', const='min', dest='history') + parser.add_argument('--history-mod', action='store_const', const='mod', dest='history') + parser.add_argument('--history-max', action='store_const', const='max', dest='history') parser.add_argument('--force', action='store_true') parser.add_argument('--noself', action='store_true') - parser.add_argument('relsFile') - parser.add_argument('--help', action=HelpAction) # Add the custom --help option + parser.add_argument('relsFile', help='RF2 relationships file') + parser.add_argument('--help', action=HelpAction) - try: - args = parser.parse_args() - except SystemExit: - badargs = errors[3] - print(badargs + args) - exit(1) - - # Check if the arguments are valid - if not args.relsFile: # Check if relsFile is provided - badargs = errors[4].format("relsFile") - elif args.history and args.history not in ['min', 'mod', 'max']: # Check if history is one of the allowed values - badargs = errors[1] + args.history - else: - badargs = None - - # Check for argument errors - if badargs: - print_usage() - print("\n{}".format(badargs)) - exit(1) - - return parser.parse_args() + args = parser.parse_args() + return args ## Function to initialize relationships def initRelationships(relsFile, historyFile): global codes, parChd try: # Read relationships - with open(relsFile, 'r') as f: + with open(relsFile, 'r', newline='') as f: reader = csv.reader(f, delimiter='\t') + next(reader) # Skip header row ct = 1 # iterate through rels file for row in reader: + if len(row) < 10: # Add validation + continue id, effectiveTime, active, moduleId, sourceId, destinationId, relationshipGroup, typeId, characteristicTypeId, modifierId = row # skip inactive or non-isa relationships - if typeId != isaRel or not active: + if typeId != isaRel or active != '1': # Check for '1' instead of boolean continue ct += 1 @@ -98,47 +84,51 @@ def initRelationships(relsFile, historyFile): parChd[destinationId].append(sourceId) codes[sourceId] = 1 codes[destinationId] = 1 - pass + + logging.info(f" {ct} relationships loaded") except IOError as e: logging.error("Failed to open {}: {}".format(relsFile, e)) exit(1) # Load appropriate history relationships if history: - ct = 0 - qual = {} - if history == "min": - qual = {"900000000000527005": 1} - elif history == "mod": - qual = {"900000000000527005": 1, "900000000000526001": 1, "900000000000528000": 1, "1186924009": 1} - - with open(historyFile, 'r') as IN: - for line in IN: - line = line.rstrip('\r\n') - - id, effectiveTime, active, moduleId, refsetId, referencedComponentId, targetComponentId = line.split('\t') - - # skip unless the refsetId represents a qualifying historical association - if not (history == "max" or refsetId in qual): - continue - # skip inactive - if not active: - continue - # skip if the targetComponentId isn't one of the codes (to avoid moved_to/from stuff) - if targetComponentId not in codes: - continue - - ct += 1 - - # push new child (inactive concept) for parent (active concept) - if targetComponentId not in parChd: - parChd[targetComponentId] = [] - parChd[targetComponentId].append(referencedComponentId) - codes[referencedComponentId] = 1 + try: + ct = 0 + qual = {} + if history == "min": + qual = {"900000000000527005": 1} + elif history == "mod": + qual = {"900000000000527005": 1, "900000000000526001": 1, + "900000000000528000": 1, "1186924009": 1} + + with open(historyFile, 'r') as IN: + reader = csv.reader(IN, delimiter='\t') + next(reader) # Skip header + for row in reader: + id, effectiveTime, active, moduleId, refsetId, referencedComponentId, targetComponentId = row + + # skip unless qualifying historical association + if not (history == "max" or refsetId in qual): + continue + # skip inactive + if active != '1': # Check for string '1' instead of boolean + continue + # skip if targetComponentId not in codes + if targetComponentId not in codes: + continue - logging.info(" {} historical relationships loaded".format(ct)) + ct += 1 + # push new child for parent + if targetComponentId not in parChd: + parChd[targetComponentId] = [] + parChd[targetComponentId].append(referencedComponentId) + codes[referencedComponentId] = 1 + logging.info(f" {ct} historical relationships loaded") + except Exception as e: + logging.error(f"Error processing history file: {e}") + raise ## Function to get descendants def getDescendants(par, depth): @@ -180,83 +170,76 @@ def print_usage(): ## Main function def main(): - global badargs, ct args = parse_args() + global force, self, history force = args.force self = not args.noself - relsFile = args.relsFile history = args.history + relsFile = args.relsFile outputFile = relsFile.replace("_Relationship_", "_TransitiveClosure_") - # initialize ct - ct = 0 - # Check history file + # Check output file + if os.path.exists(outputFile): + if force: + os.remove(outputFile) + else: + raise Exception(f"Output file already exists: {outputFile}. Check this is not an old file") + + # Determine history file path historyFile = "" if history: - # Attempt to find the Association refset historyFile = relsFile.replace("sct2_Relationship_", "der2_cRefset_Association") if historyFile.startswith("der2"): - historyFile = "../Refset/Content/" + historyFile + historyFile = os.path.join("..", "Refset", "Content", historyFile) elif "Terminology" in historyFile: historyFile = historyFile.replace("Terminology", "Refset/Content") else: - raise Exception("Unable to determine path to Association refset file from relationships file = {}".format(relsFile)) + raise Exception(f"Unable to determine path to Association refset file from relationships file = {relsFile}") if not os.path.exists(historyFile): - raise Exception("Computed path to Association refset file does not exist = {}".format(historyFile)) - - # Check if output file already exists - if os.path.exists(outputFile): - if force: - os.remove(outputFile) - else: - logging.warning("Output file already exists: {}".format(outputFile)) - exit(1) + raise Exception(f"Computed path to Association refset file does not exist = {historyFile}") - # Start processing + # Print configuration print("------------------------------------------------------------") - print("Starting ...", time.asctime()) + print(f"Starting ... {time.asctime()}") print("------------------------------------------------------------") - print("Isa rel : ", isaRel) - print("Rels file : ", relsFile) - print("Self : ", self) - print("Output file : ", outputFile) + print(f"Isa rel : {isaRel}") + print(f"Rels file : {relsFile}") + print(f"Self : {self}") + print(f"Output file : {outputFile}") if history: - print("History : ", history) - print("History file : ", historyFile) + print(f"History : {history}") + print(f"History file : {historyFile}") print("\n") - # Load PAR/CHD relationships map - print(" Load PAR/CHD rels ...", time.asctime()) - global codes, parChd, seen - codes = {} - parChd = {} - seen = {} # Initialize relationships - initRelationships(relsFile, "") + print(f" Load PAR/CHD rels ... {time.asctime()}") + initRelationships(relsFile, historyFile) # Write transitive closure to output file print(" Write transitive closure table ...", time.asctime()) - with open(outputFile, 'w') as f: + ct = 0 # Initialize counter here + with open(outputFile, 'w', newline='') as f: writer = csv.writer(f, delimiter='\t') writer.writerow(["superTypeId", "subTypeId", "depth"]) for code in codes.keys(): + ct += 1 # Increment counter for each code # skip root if code == root: - ct += 1 continue # short circuit for leaf nodes if code not in parChd and self: writer.writerow([code, code, 0]) # gather descendants else: + seen.clear() # Clear seen dict for each new code descendants = getDescendants(code, 1) for desc, depth in descendants.items(): if not self and not (depth-1): continue writer.writerow([code, desc, depth-1]) - if ct % 10000 == 0: - logging.info(" {} codes processed ...".format(ct), time.asctime()) + if ct % 10000 == 0: + logging.info(f" {ct} codes processed ... {time.asctime()}") print("------------------------------------------------------------") print("finished ...", time.asctime()) From aa615255bda6ef4b7187bcc6023baac967ed81ba Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Thu, 9 Jan 2025 12:22:34 -0800 Subject: [PATCH 81/95] OP-934: update files for Snomed Intl 01, 2025 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7e0ebcb..a128361 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ true - 20240701 + 20250101 Core INT From 0f2060cc4254217ddfc626ebbde6d205e84ba116 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Thu, 9 Jan 2025 12:22:58 -0800 Subject: [PATCH 82/95] OP-934: update files for Snomed Intl 01, 2025 --- src/main/resources/LICENSE.txt | 2 +- src/main/resources/rf2/compute_transitive_closure.pl | 2 +- src/test/resources/README-announcements.txt | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/resources/LICENSE.txt b/src/main/resources/LICENSE.txt index 8a3b6d2..9b836df 100644 --- a/src/main/resources/LICENSE.txt +++ b/src/main/resources/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright 2024 West Coast Informatics, LLC +Copyright 2025 West Coast Informatics, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/main/resources/rf2/compute_transitive_closure.pl b/src/main/resources/rf2/compute_transitive_closure.pl index 195db15..9640794 100644 --- a/src/main/resources/rf2/compute_transitive_closure.pl +++ b/src/main/resources/rf2/compute_transitive_closure.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# Copyright 2024 West Coast Informatics, Inc +# Copyright 2025 West Coast Informatics, Inc # # Computes transitive closure from a snapshot inferred RF2 relationships file. # diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index ec2b2df..792a323 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -4,8 +4,8 @@ -- SNOMED International Jan 1: -Is it August already?! Announcing #SNOMEDCT DB load and transitive -closure scripts for the 20240101 International Edition! Out-of-the-box +Is it January already?! Announcing #SNOMEDCT DB load and transitive +closure scripts for the 20250101 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #MakingSnomedEasy #snomed https://www.westcoastinformatics.com/products/db-load-scripts @@ -20,7 +20,8 @@ https://www.westcoastinformatics.com/products/db-load-scripts ---- -### LinkedIn +The new year is here! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20250101 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +See https://westcoastinformatics.com/products/db-load-scripts #MakingTerminologyEasy #MakingSnomedEasy #snomedct At West Coast Informatics, we are experts in loading healthcare terminology data into standard databases. Announcing updates to our Database Load Scripts for the @@ -31,11 +32,11 @@ These tools are designed to provide an easy mechanism to load SNOMEDCT into Post #MakingTerminologyEasy #MakingSnomedEasy #snomedct ### UMLS Users Mailing List -Subject: 20240901 SNOMEDCT US Edition DB load and transitive closure scripts +Subject: 20250101 SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the September 01, 2024 update of the SNOMEDCT US Edition. +NLM recently posted the January 01, 2025 update of the SNOMEDCT International Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. From 9e03f06a1ee75fef757845ba9856c28f21efea07 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Mon, 3 Mar 2025 14:53:34 -0800 Subject: [PATCH 83/95] OP-988: Update for SNOMEDCT US 20250301 --- pom.xml | 2 +- src/test/resources/README-announcements.txt | 10 +-- src/test/resources/README-mysql-docker.md | 41 +++++++----- src/test/resources/README-postgres-docker.md | 69 ++++++++++++++------ 4 files changed, 78 insertions(+), 44 deletions(-) diff --git a/pom.xml b/pom.xml index a128361..3b445ee 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ US - 20240301 + 20250301 National US1000124 diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 792a323..452da93 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -13,7 +13,7 @@ https://www.westcoastinformatics.com/products/db-load-scripts -- US Edition March 1: Spring is upon us! Announcing #SNOMEDCT DB load and transitive -closure scripts for the 20240301 US Edition! Out-of-the-box +closure scripts for the 20250301 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #snomedct #termhub https://www.westcoastinformatics.com/products/db-load-scripts @@ -23,9 +23,9 @@ https://www.westcoastinformatics.com/products/db-load-scripts The new year is here! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20250101 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/products/db-load-scripts #MakingTerminologyEasy #MakingSnomedEasy #snomedct -At West Coast Informatics, we are experts in loading healthcare terminology data -into standard databases. Announcing updates to our Database Load Scripts for the -20240901 US Edition of SNOMEDCT. +At West Coast Informatics, we are experts in loading healthcare terminology data +into standard databases. Announcing updates to our Database Load Scripts for the +20240901 US Edition of SNOMEDCT. Download now at https://www.westcoastinformatics.com/products/db-load-scripts These tools are designed to provide an easy mechanism to load SNOMEDCT into Postgres, MySQL (or MariaDB), or Oracle databases. These resources are free to use and will assist you with loading core SNOMED CT data and transitive closure tables into supported environments. These projects are hosted on Github and we welcome any feedback or community contributions. @@ -36,7 +36,7 @@ Subject: 20250101 SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the January 01, 2025 update of the SNOMEDCT International Edition. +NLM recently posted the March 01, 2025 update of the SNOMEDCT US Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. diff --git a/src/test/resources/README-mysql-docker.md b/src/test/resources/README-mysql-docker.md index 982589d..cd379a3 100644 --- a/src/test/resources/README-mysql-docker.md +++ b/src/test/resources/README-mysql-docker.md @@ -1,8 +1,14 @@ # BUILD INSTRUCTIONS + ## Pre-requisites + Before proceeding, make sure you updated the hostname in the load script. +Check current versions: https://endoflife.software/applications/databases/mysql +Add new versions, remove versions whose final release is the past and, bump the minor version numbers. + ## File Setup + ``` cd /wci/data unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-mysql.*.zip @@ -12,52 +18,53 @@ Before proceeding, make sure you updated the hostname in the load script. sudo chmod +x rf2/compute_transitive_closure.py ``` + Follow the instructions for the version you are using below. -### MySQL 8.0 +### MySQL 8.4 1. Launch the container
-`docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mysql:8.0 --local_infile=ON` - + `docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mysql:8.04 --local_infile=ON` 2. Build Server + ``` export dir=/wci/data/ cd $dir - docker run -it -v $dir:/data mysql:8.0 /bin/bash - + docker run -it -v $dir:/data mysql:8.4 /bin/bash + root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh ``` -### MySQL 8.3 +### MariaDB - 10.11 1. Launch the container
- `docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mysql:8.3 --local_infile=ON` - + `docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mariadb:10.11` 2. Build Server + ``` export dir=/wci/data/ cd $dir - docker run -it -v $dir:/data mysql:8.3 /bin/bash - + docker run -it -v $dir:/data mariadb:10.11 /bin/bash + root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh ``` -TODO: CHECK THE VERSION FOR MARIADB -### MariaDB - 10.11 -1. Launch the container
-`docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mariadb:10.11` +### MariaDB - 11.04 +1. Launch the container
+ `docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mariadb:11.04` 2. Build Server + ``` export dir=/wci/data/ cd $dir - docker run -it -v $dir:/data mariadb:10.11 /bin/bash - + docker run -it -v $dir:/data mariadb:11.04 /bin/bash + root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh -``` \ No newline at end of file +``` diff --git a/src/test/resources/README-postgres-docker.md b/src/test/resources/README-postgres-docker.md index b73b346..4a2d2c6 100644 --- a/src/test/resources/README-postgres-docker.md +++ b/src/test/resources/README-postgres-docker.md @@ -1,8 +1,14 @@ -# BUILD INSTRUCTIONS +# BUILD INSTRUCTIONS + ## Pre-requisites + Before proceeding, make sure you updated the PGHOST in the load script. +Check current versions: https://www.postgresql.org/support/versioning/ +Add new versions, remove versions whose final release is the past and, bump the minor version numbers. + ## File Setup + ``` cd /wci/data unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-postgres.*.zip @@ -10,63 +16,84 @@ Before proceeding, make sure you updated the PGHOST in the load script. sudo chmod +x rf2/compute_transitive_closure.pl ``` -* For testing postgres, run a docker postgres instance - https://hub.docker.com/_/postgres +- For testing postgres, run a docker postgres instance - https://hub.docker.com/_/postgres -### Postgres 12.15 -1. Launch the container
-`docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:12.15` +### Postgres 13.20 +1. Launch the container
+ `docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:13.20` 2. Build Server + ``` export dir=/wci/data/ cd $dir - docker run -it -v "$dir":/data postgres:12.15 /bin/bash - + docker run -it -v "$dir":/data postgres:13.20 /bin/bash + root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh ``` -### Postgres 13.11 +### Postgres 14.17 + 1. Launch the container
-`docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:13.11` + `docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:14.17` 2. Build Server + ``` export dir=/wci/data/ cd $dir - docker run -it -v "$dir":/data postgres:13.11 /bin/bash - + docker run -it -v "$dir":/data postgres:14.17 /bin/bash + root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh ``` -### Postgres 14.8 -1. Launch the container
-`docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:14.8` +### Postgres 15.12 +1. Launch the container
+ `docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:15.12` 2. Build Server + ``` export dir=/wci/data/ cd $dir - docker run -it -v "$dir":/data postgres:14.8 /bin/bash - + docker run -it -v "$dir":/data postgres:15.12 /bin/bash + root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh ``` -### Postgres 15.3 +### Postgres 16.8 + 1. Launch the container
-`docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:15.3` + `docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:16.8` +2. Build Server + +``` + export dir=/wci/data/ + cd $dir + docker run -it -v "$dir":/data postgres:16.8 /bin/bash + + root@842bfb3da1f1:/# cd /data/rf2 + root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh +``` + +### Postgres 17.4 + +1. Launch the container
+ `docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:17.4` 2. Build Server + ``` export dir=/wci/data/ cd $dir - docker run -it -v "$dir":/data postgres:15.3 /bin/bash - + docker run -it -v "$dir":/data postgres:17.4 /bin/bash + root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh -``` \ No newline at end of file +``` From 45404e0eaa5dbb89aa231bcf3865d6e98ea695ae Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Mon, 3 Mar 2025 16:17:04 -0800 Subject: [PATCH 84/95] Update README-mysql-docker.md Fix MySQL database version for docker. --- src/test/resources/README-mysql-docker.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/README-mysql-docker.md b/src/test/resources/README-mysql-docker.md index cd379a3..e5308cc 100644 --- a/src/test/resources/README-mysql-docker.md +++ b/src/test/resources/README-mysql-docker.md @@ -24,7 +24,7 @@ Follow the instructions for the version you are using below. ### MySQL 8.4 1. Launch the container
- `docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mysql:8.04 --local_infile=ON` + `docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mysql:8.4 --local_infile=ON` 2. Build Server From a8c9640fb04861d81f5f3c6fdace8ab896dacee9 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Wed, 5 Mar 2025 13:51:19 -0800 Subject: [PATCH 85/95] OP-988: Update versions. Add script for MariaDb due to update in SQL client --- README.md | 2 +- src/main/resources/HOWTO.md | 5 +- src/main/resources/rf2/populate_maria_db.sh | 79 +++++++++ src/main/resources/rf2/populate_mysql_db.sh | 54 +++--- src/main/resources/rf2/populate_oracle_db.sh | 166 +++++++++--------- .../resources/rf2/populate_postgres_db.sh | 52 +++--- src/test/resources/README-mysql-docker.md | 8 +- 7 files changed, 226 insertions(+), 140 deletions(-) create mode 100644 src/main/resources/rf2/populate_maria_db.sh diff --git a/README.md b/README.md index c926b32..6d20aa7 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Minimum Specification - MySQL v8.+, MariaDB 10.+, MariaDB 11.+ - MySQL v8 requires the server to run with "--local_infile=ON" - Oracle v12.+ -- Postgres v13.+, v14.+, v15.+, v16.+ +- Postgres v13.+, v14.+, v15.+, v16.+, v17.+ Installation ------------ diff --git a/src/main/resources/HOWTO.md b/src/main/resources/HOWTO.md index 0beb5b0..9b71d19 100644 --- a/src/main/resources/HOWTO.md +++ b/src/main/resources/HOWTO.md @@ -28,7 +28,8 @@ See [https://youtu.be/917T6D3b5ro](https://youtu.be/917T6D3b5ro) 5. In a text editor, open the temp-folder's appropriate "populate" script as defined by your database. * For example: - - For MySQL (or MariaDB), use the "populate_mysql_db.sh" script + - For MySQL (or MariaDB < 11), use the "populate_mysql_db.sh" script + - For MariaDB 11+, use the "populate_maria_db.sh" script - For Postgres, use the "populate_postgres_db.sh" script - For Oracle, use the "populate_oracle_db.sh" script * Configure settings at the top of the "populate" script for your environment @@ -43,4 +44,4 @@ See [https://youtu.be/917T6D3b5ro](https://youtu.be/917T6D3b5ro) 7. Execute the "populate" script - * Note: a complete log file will appear as `mysql.log`, `postgres.log`, or `oracle.log` + * Note: a complete log file will appear as `mysql.log`, `mariadb.log`, `postgres.log`, or `oracle.log` diff --git a/src/main/resources/rf2/populate_maria_db.sh b/src/main/resources/rf2/populate_maria_db.sh new file mode 100644 index 0000000..d3e7763 --- /dev/null +++ b/src/main/resources/rf2/populate_maria_db.sh @@ -0,0 +1,79 @@ +#!/bin/bash -f +# +# Database connection parameters +# PLEASE EDIT THESE VARIABLES TO REFLECT YOUR ENVIRONMENT +host=[UPDATE] +user=root +password=admin +db_name=snomed + +LOG_FILE=maria_db.log + +/bin/rm -f $LOG_FILE +touch $LOG_FILE +ef=0 + +echo "See $LOG_FILE for detailed output" + +echo "----------------------------------------" | tee -a $LOG_FILE +echo "Starting ... $(/bin/date)" | tee -a $LOG_FILE +echo "----------------------------------------" | tee -a $LOG_FILE +echo "user = $user" | tee -a $LOG_FILE +echo "db_name = $db_name" | tee -a $LOG_FILE +echo "host = $host" | tee -a $LOG_FILE + +if [ "${password}" != "" ]; then + password="-p${password}" +fi +if [ "${host}" != "" ]; then + host="-h ${host}" +fi + +DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) + +echo " Compute transitive closure relationship file ... $(/bin/date)" | tee -a $LOG_FILE +relFile=$(find $DIR/Snapshot/Terminology/ -name "*_Relationship_Snapshot_*.txt" -print -quit) +#check if system has python or perl, run the corresponding script +if command -v perl &>/dev/null; then + echo "perl found, running perl script" >>$LOG_FILE 2>&1 + perl $DIR/compute_transitive_closure.pl --force --noself $relFile >>$LOG_FILE 2>&1 + if [ $? -ne 0 ]; then ef=1; fi +elif command -v python &>/dev/null; then + echo "python found, running python script" >>$LOG_FILE 2>&1 + python $DIR/compute_transitive_closure.py --force --noself $relFile >>$LOG_FILE 2>&1 + if [ $? -ne 0 ]; then ef=1; fi +# if none are present, print error message +else + echo "No perl or python found on your machine. Please install one of them to proceed." | tee -a $LOG_FILE + ef=1 +fi + +if [ $ef -ne 1 ]; then + echo " Create and load tables ... $(/bin/date)" | tee -a $LOG_FILE + mariadb -vvv $host -u $user $password --local-infile $db_name >$LOG_FILE 2>&1 + if [ $? -ne 0 ]; then ef=1; fi +fi + +if [ $ef -ne 1 ]; then + echo " Create indexes ... $(/bin/date)" | tee -a $LOG_FILE + mariadb -vvv $host -u $user $password --local-infile $db_name >$LOG_FILE 2>&1 + if [ $? -ne 0 ]; then ef=1; fi +fi + +if [ $ef -ne 1 ]; then + echo " Create views ... $(/bin/date)" | tee -a $LOG_FILE + mariadb -vvv $host -u $user $password --local-infile $db_name >$LOG_FILE 2>&1 + if [ $? -ne 0 ]; then ef=1; fi +fi + +echo "----------------------------------------" | tee -a $LOG_FILE +if [ $ef -eq 1 ]; then + echo "There were one or more errors." | tee -a $LOG_FILE + retval=-1 +else + echo "Completed without errors." | tee - a $LOG_FILE + retval=0 +fi +echo "Finished ... $(/bin/date)" | tee -a $LOG_FILE +echo "----------------------------------------" | tee -a $LOG_FILE +exit $retval diff --git a/src/main/resources/rf2/populate_mysql_db.sh b/src/main/resources/rf2/populate_mysql_db.sh index 5268cfd..e228008 100644 --- a/src/main/resources/rf2/populate_mysql_db.sh +++ b/src/main/resources/rf2/populate_mysql_db.sh @@ -7,18 +7,20 @@ user=root password=admin db_name=snomed -/bin/rm -f mysql.log -touch mysql.log +LOG_FILE=mysql.log + +/bin/rm -f $LOG_FILE +touch $LOG_FILE ef=0 -echo "See mysql.log for detailed output" +echo "See $LOG_FILE for detailed output" -echo "----------------------------------------" | tee -a mysql.log -echo "Starting ... `/bin/date`" | tee -a mysql.log -echo "----------------------------------------" | tee -a mysql.log -echo "user = $user" | tee -a mysql.log -echo "db_name = $db_name" | tee -a mysql.log -echo "host = $host" | tee -a mysql.log +echo "----------------------------------------" | tee -a $LOG_FILE +echo "Starting ... `/bin/date`" | tee -a $LOG_FILE +echo "----------------------------------------" | tee -a $LOG_FILE +echo "user = $user" | tee -a $LOG_FILE +echo "db_name = $db_name" | tee -a $LOG_FILE +echo "host = $host" | tee -a $LOG_FILE if [ "${password}" != "" ]; then password="-p${password}" @@ -29,52 +31,52 @@ fi DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -echo " Compute transitive closure relationship file ... `/bin/date`" | tee -a mysql.log +echo " Compute transitive closure relationship file ... `/bin/date`" | tee -a $LOG_FILE relFile=$(find $DIR/Snapshot/Terminology/ -name "*_Relationship_Snapshot_*.txt" -print -quit) #check if system has python or perl, run the corresponding script if command -v perl &> /dev/null then - echo "perl found, running perl script" >> postgres.log 2>&1 - perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> postgres.log 2>&1 + echo "perl found, running perl script" >> $LOG_FILE 2>&1 + perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi elif command -v python &> /dev/null then - echo "python found, running python script" >> postgres.log 2>&1 - python $DIR/compute_transitive_closure.py --force --noself $relFile >> postgres.log 2>&1 + echo "python found, running python script" >> $LOG_FILE 2>&1 + python $DIR/compute_transitive_closure.py --force --noself $relFile >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi # if none are present, print error message else - echo "No perl or python found on your machine. Please install one of them to proceed." | tee -a postgres.log + echo "No perl or python found on your machine. Please install one of them to proceed." | tee -a $LOG_FILE ef=1 fi if [ $ef -ne 1 ]; then -echo " Create and load tables ... `/bin/date`" | tee -a mysql.log -mysql -vvv $host -u $user $password --local-infile $db_name < mysql_tables.sql >> mysql.log 2>&1 +echo " Create and load tables ... `/bin/date`" | tee -a $LOG_FILE +mysql -vvv $host -u $user $password --local-infile $db_name < mysql_tables.sql >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi if [ $ef -ne 1 ]; then -echo " Create indexes ... `/bin/date`" | tee -a mysql.log -mysql -vvv $host -u $user $password --local-infile $db_name < mysql_indexes.sql >> mysql.log 2>&1 +echo " Create indexes ... `/bin/date`" | tee -a $LOG_FILE +mysql -vvv $host -u $user $password --local-infile $db_name < mysql_indexes.sql >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi if [ $ef -ne 1 ]; then -echo " Create views ... `/bin/date`" | tee -a mysql.log -mysql -vvv $host -u $user $password --local-infile $db_name < mysql_views.sql >> mysql.log 2>&1 +echo " Create views ... `/bin/date`" | tee -a $LOG_FILE +mysql -vvv $host -u $user $password --local-infile $db_name < mysql_views.sql >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi -echo "----------------------------------------" | tee -a mysql.log +echo "----------------------------------------" | tee -a $LOG_FILE if [ $ef -eq 1 ] then - echo "There were one or more errors." | tee -a mysql.log + echo "There were one or more errors." | tee -a $LOG_FILE retval=-1 else - echo "Completed without errors." | tee - a mysql.log + echo "Completed without errors." | tee - a $LOG_FILE retval=0 fi -echo "Finished ... `/bin/date`" | tee -a mysql.log -echo "----------------------------------------" | tee -a mysql.log +echo "Finished ... `/bin/date`" | tee -a $LOG_FILE +echo "----------------------------------------" | tee -a $LOG_FILE exit $retval diff --git a/src/main/resources/rf2/populate_oracle_db.sh b/src/main/resources/rf2/populate_oracle_db.sh index c6b5e8f..aa0400a 100644 --- a/src/main/resources/rf2/populate_oracle_db.sh +++ b/src/main/resources/rf2/populate_oracle_db.sh @@ -10,203 +10,205 @@ password=snomed tns_name=ORCLCDB export NLS_LANG=AMERICAN_AMERICA.UTF8 +LOG_FILE=oracle.log + # Clear the log file. If it doesn't exist, create it. -> oracle.log +> $LOG_FILE ef=0 -echo "See oracle.log for detailed output" -echo "----------------------------------------" | tee -a oracle.log -echo "Starting ... `/bin/date`" | tee -a oracle.log -echo "----------------------------------------" | tee -a oracle.log -echo "ORACLE_HOME = $ORACLE_HOME" | tee -a oracle.log -echo "user = $user" | tee -a oracle.log -echo "tns_name = $tns_name" | tee -a oracle.log +echo "See $LOG_FILE for detailed output" +echo "----------------------------------------" | tee -a $LOG_FILE +echo "Starting ... `/bin/date`" | tee -a $LOG_FILE +echo "----------------------------------------" | tee -a $LOG_FILE +echo "ORACLE_HOME = $ORACLE_HOME" | tee -a $LOG_FILE +echo "user = $user" | tee -a $LOG_FILE +echo "tns_name = $tns_name" | tee -a $LOG_FILE DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -echo " Compute transitive closure relationship file ... `/bin/date`" | tee -a oracle.log +echo " Compute transitive closure relationship file ... `/bin/date`" | tee -a $LOG_FILE relFile=$(find $DIR/Snapshot/Terminology/ -name "*_Relationship_Snapshot_*.txt" -print -quit) #check if system has python or perl, run the corresponding script if command -v perl &> /dev/null then - echo "perl found, running perl script" >> postgres.log 2>&1 - perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> postgres.log 2>&1 + echo "perl found, running perl script" >> $LOG_FILE 2>&1 + perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi elif command -v python &> /dev/null then - echo "python found, running python script" >> postgres.log 2>&1 - python $DIR/compute_transitive_closure.py --force --noself $relFile >> postgres.log 2>&1 + echo "python found, running python script" >> $LOG_FILE 2>&1 + python $DIR/compute_transitive_closure.py --force --noself $relFile >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi # if none are present, print error message else - echo "No perl or python found on your machine. Please install one of them to proceed." | tee -a postgres.log + echo "No perl or python found on your machine. Please install one of them to proceed." | tee -a $LOG_FILE ef=1 fi if [ $ef -ne 1 ]; then -echo " Create tables ... `/bin/date`" | tee -a oracle.log -echo "@oracle_tables.sql" | $ORACLE_HOME/bin/sqlplus $user/$password@$tns_name >> oracle.log 2>&1 +echo " Create tables ... `/bin/date`" | tee -a $LOG_FILE +echo "@oracle_tables.sql" | $ORACLE_HOME/bin/sqlplus $user/$password@$tns_name >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi ## Load RF2 tables if [ $ef -ne 1 ]; then -echo " Load concept table data ... `/bin/date`" | tee -a oracle.log -$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="concept.ctl" >> oracle.log 2>&1 +echo " Load concept table data ... `/bin/date`" | tee -a $LOG_FILE +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="concept.ctl" >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi -cat concept.log >> oracle.log +cat concept.log >> $LOG_FILE fi if [ $ef -ne 1 ]; then -echo " Load description table data ... `/bin/date`" | tee -a oracle.log -$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="description.ctl" >> oracle.log 2>&1 +echo " Load description table data ... `/bin/date`" | tee -a $LOG_FILE +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="description.ctl" >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi -cat description.log >> oracle.log +cat description.log >> $LOG_FILE fi if [ $ef -ne 1 ]; then -echo " Load identifier table data ... `/bin/date`" | tee -a oracle.log -$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="identifier.ctl" >> oracle.log 2>&1 +echo " Load identifier table data ... `/bin/date`" | tee -a $LOG_FILE +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="identifier.ctl" >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi -cat identifier.log >> oracle.log +cat identifier.log >> $LOG_FILE fi if [ $ef -ne 1 ]; then -echo " Load relationship table data ... `/bin/date`" | tee -a oracle.log -$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="relationship.ctl" >> oracle.log 2>&1 +echo " Load relationship table data ... `/bin/date`" | tee -a $LOG_FILE +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="relationship.ctl" >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi -cat relationship.log >> oracle.log +cat relationship.log >> $LOG_FILE fi if [ $ef -ne 1 ]; then -echo " Load relationship concrete values table data ... `/bin/date`" | tee -a oracle.log -$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="relationshipconcretevalues.ctl" >> oracle.log 2>&1 +echo " Load relationship concrete values table data ... `/bin/date`" | tee -a $LOG_FILE +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="relationshipconcretevalues.ctl" >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi -cat relationshipconcretevalues.log >> oracle.log +cat relationshipconcretevalues.log >> $LOG_FILE fi if [ $ef -ne 1 ]; then -echo " Load owl expression table data ... `/bin/date`" | tee -a oracle.log -$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="owlexpression.ctl" >> oracle.log 2>&1 +echo " Load owl expression table data ... `/bin/date`" | tee -a $LOG_FILE +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="owlexpression.ctl" >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi -cat owlexpression.log >> oracle.log +cat owlexpression.log >> $LOG_FILE fi if [ $ef -ne 1 ]; then -echo " Load stated relationship table data ... `/bin/date`" | tee -a oracle.log -$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="statedrelationship.ctl" >> oracle.log 2>&1 +echo " Load stated relationship table data ... `/bin/date`" | tee -a $LOG_FILE +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="statedrelationship.ctl" >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi -cat statedrelationship.log >> oracle.log +cat statedrelationship.log >> $LOG_FILE fi if [ $ef -ne 1 ]; then -echo " Load text definition table data ... `/bin/date`" | tee -a oracle.log -$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="textdefinition.ctl" >> oracle.log 2>&1 +echo " Load text definition table data ... `/bin/date`" | tee -a $LOG_FILE +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="textdefinition.ctl" >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi -cat textdefinition.log >> oracle.log +cat textdefinition.log >> $LOG_FILE fi if [ $ef -ne 1 ]; then -echo " Load association table data ... `/bin/date`" | tee -a oracle.log -$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="association.ctl" >> oracle.log 2>&1 +echo " Load association table data ... `/bin/date`" | tee -a $LOG_FILE +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="association.ctl" >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi -cat association.log >> oracle.log +cat association.log >> $LOG_FILE fi if [ $ef -ne 1 ]; then -echo " Load attribute value table data ... `/bin/date`" | tee -a oracle.log -$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="attributevalue.ctl" >> oracle.log 2>&1 +echo " Load attribute value table data ... `/bin/date`" | tee -a $LOG_FILE +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="attributevalue.ctl" >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi -cat attributevalue.log >> oracle.log +cat attributevalue.log >> $LOG_FILE fi if [ $ef -ne 1 ]; then -echo " Load simple refset table data ... `/bin/date`" | tee -a oracle.log -$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="simple.ctl" >> oracle.log 2>&1 +echo " Load simple refset table data ... `/bin/date`" | tee -a $LOG_FILE +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="simple.ctl" >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi -cat simple.log >> oracle.log +cat simple.log >> $LOG_FILE fi ## Load TC table if [ $ef -ne 1 ]; then -echo " Load transitive closure table ... `/bin/date`" | tee -a oracle.log -$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="transitiveclosure.ctl" >> oracle.log 2>&1 +echo " Load transitive closure table ... `/bin/date`" | tee -a $LOG_FILE +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="transitiveclosure.ctl" >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi -cat concept.log >> oracle.log +cat concept.log >> $LOG_FILE fi # No more complex maps # if [ $ef -ne 1 ]; then -# echo " Load complex map table data ... `/bin/date`" >> oracle.log 2>&1 -# $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="complexmap.ctl" >> oracle.log 2>&1 +# echo " Load complex map table data ... `/bin/date`" >> $LOG_FILE 2>&1 +# $ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="complexmap.ctl" >> $LOG_FILE 2>&1 # if [ $? -ne 0 ]; then ef=1; fi -# cat complexmap.log >> oracle.log +# cat complexmap.log >> $LOG_FILE # fi if [ $ef -ne 1 ]; then -echo " Load extended map table data ... `/bin/date`" | tee -a oracle.log -$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="extendedmap.ctl" >> oracle.log 2>&1 +echo " Load extended map table data ... `/bin/date`" | tee -a $LOG_FILE +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="extendedmap.ctl" >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi -cat extendedmap.log >> oracle.log +cat extendedmap.log >> $LOG_FILE fi if [ $ef -ne 1 ]; then -echo " Load simple map table data ... `/bin/date`" | tee -a oracle.log -$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="simplemap.ctl" >> oracle.log 2>&1 +echo " Load simple map table data ... `/bin/date`" | tee -a $LOG_FILE +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="simplemap.ctl" >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi -cat simplemap.log >> oracle.log +cat simplemap.log >> $LOG_FILE fi if [ $ef -ne 1 ]; then -echo " Load language table data ... `/bin/date`" | tee -a oracle.log -$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="language.ctl" >> oracle.log 2>&1 +echo " Load language table data ... `/bin/date`" | tee -a $LOG_FILE +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="language.ctl" >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi -cat language.log >> oracle.log +cat language.log >> $LOG_FILE fi if [ $ef -ne 1 ]; then -echo " Load refset descriptor table data ... `/bin/date`" | tee -a oracle.log -$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="refsetdescriptor.ctl" >> oracle.log 2>&1 +echo " Load refset descriptor table data ... `/bin/date`" | tee -a $LOG_FILE +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="refsetdescriptor.ctl" >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi -cat refsetdescriptor.log >> oracle.log +cat refsetdescriptor.log >> $LOG_FILE fi if [ $ef -ne 1 ]; then -echo " Load description type table data ... `/bin/date`" | tee -a oracle.log -$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="descriptiontype.ctl" >> oracle.log 2>&1 +echo " Load description type table data ... `/bin/date`" | tee -a $LOG_FILE +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="descriptiontype.ctl" >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi -cat descriptiontype.log >> oracle.log +cat descriptiontype.log >> $LOG_FILE fi if [ $ef -ne 1 ]; then -echo " Load module dependency table data ... `/bin/date`" | tee -a oracle.log -$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="moduledependency.ctl" >> oracle.log 2>&1 +echo " Load module dependency table data ... `/bin/date`" | tee -a $LOG_FILE +$ORACLE_HOME/bin/sqlldr $user/$password@$tns_name control="moduledependency.ctl" >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi -cat moduledependency.log >> oracle.log +cat moduledependency.log >> $LOG_FILE fi if [ $ef -ne 1 ]; then -echo " Create indexes ... `/bin/date`" | tee -a oracle.log -echo "@oracle_indexes.sql"|$ORACLE_HOME/bin/sqlplus $user/$password@$tns_name >> oracle.log 2>&1 +echo " Create indexes ... `/bin/date`" | tee -a $LOG_FILE +echo "@oracle_indexes.sql"|$ORACLE_HOME/bin/sqlplus $user/$password@$tns_name >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi if [ $ef -ne 1 ]; then -echo " Create views ... `/bin/date`" | tee -a oracle.log -echo "@oracle_views.sql"|$ORACLE_HOME/bin/sqlplus $user/$password@$tns_name >> oracle.log 2>&1 +echo " Create views ... `/bin/date`" | tee -a $LOG_FILE +echo "@oracle_views.sql"|$ORACLE_HOME/bin/sqlplus $user/$password@$tns_name >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi -echo "----------------------------------------" | tee -a oracle.log +echo "----------------------------------------" | tee -a $LOG_FILE if [ $ef -eq 1 ] then - echo "There were one or more errors." | tee -a oracle.log + echo "There were one or more errors." | tee -a $LOG_FILE retval=-1 else - echo "Completed without errors." | tee -a oracle.log + echo "Completed without errors." | tee -a $LOG_FILE retval=0 fi -echo "Finished ... `/bin/date`" | tee -a oracle.log -echo "----------------------------------------" | tee -a oracle.log +echo "Finished ... `/bin/date`" | tee -a $LOG_FILE +echo "----------------------------------------" | tee -a $LOG_FILE exit $retval diff --git a/src/main/resources/rf2/populate_postgres_db.sh b/src/main/resources/rf2/populate_postgres_db.sh index b24efd8..0066689 100644 --- a/src/main/resources/rf2/populate_postgres_db.sh +++ b/src/main/resources/rf2/populate_postgres_db.sh @@ -8,66 +8,68 @@ export PGUSER=postgres export PGPASSWORD= export PGDATABASE=snomed -/bin/rm -f postgres.log -touch postgres.log +LOG_FILE=postgres.log + +/bin/rm -f $LOG_FILE +touch $LOG_FILE ef=0 -echo "See postgres.log for output" +echo "See $LOG_FILE for output" -echo "----------------------------------------" | tee -a postgres.log -echo "Starting ... `/bin/date`" | tee -a postgres.log -echo "----------------------------------------" | tee -a postgres.log -echo "user = $PGUSER" | tee -a postgres.log -echo "db_name = $PGDATABASE" | tee -a postgres.log +echo "----------------------------------------" | tee -a $LOG_FILE +echo "Starting ... `/bin/date`" | tee -a $LOG_FILE +echo "----------------------------------------" | tee -a $LOG_FILE +echo "user = $PGUSER" | tee -a $LOG_FILE +echo "db_name = $PGDATABASE" | tee -a $LOG_FILE DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -echo " Compute transitive closure relationship file ... `/bin/date`" | tee -a postgres.log +echo " Compute transitive closure relationship file ... `/bin/date`" | tee -a $LOG_FILE relFile=$(find $DIR/Snapshot/Terminology/ -name "*_Relationship_Snapshot_*.txt" -print -quit) #check if system has perl first, then python, run the corresponding script if command -v perl &> /dev/null then - echo "perl found, running perl script" >> postgres.log 2>&1 - perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> postgres.log 2>&1 + echo "perl found, running perl script" >> $LOG_FILE 2>&1 + perl $DIR/compute_transitive_closure.pl --force --noself $relFile >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi elif command -v python &> /dev/null then - echo "python found, running python script" >> postgres.log 2>&1 - python $DIR/compute_transitive_closure.py --force --noself $relFile >> postgres.log 2>&1 + echo "python found, running python script" >> $LOG_FILE 2>&1 + python $DIR/compute_transitive_closure.py --force --noself $relFile >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi # if none are present, print error message else - echo "No perl or python found on your machine. Please install one of them to proceed." | tee -a postgres.log + echo "No perl or python found on your machine. Please install one of them to proceed." | tee -a $LOG_FILE ef=1 fi if [ $ef -ne 1 ]; then -echo " Create and load tables ... `/bin/date`" | tee -a postgres.log -psql < psql_tables.sql >> postgres.log 2>&1 +echo " Create and load tables ... `/bin/date`" | tee -a $LOG_FILE +psql < psql_tables.sql >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi if [ $ef -ne 1 ]; then -echo " Create indexes ... `/bin/date`" | tee -a postgres.log -psql < psql_indexes.sql >> postgres.log 2>&1 +echo " Create indexes ... `/bin/date`" | tee -a $LOG_FILE +psql < psql_indexes.sql >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi if [ $ef -ne 1 ]; then -echo " Create views ... `/bin/date`" | tee -a postgres.log -psql < psql_views.sql >> postgres.log 2>&1 +echo " Create views ... `/bin/date`" | tee -a $LOG_FILE +psql < psql_views.sql >> $LOG_FILE 2>&1 if [ $? -ne 0 ]; then ef=1; fi fi -echo "----------------------------------------" | tee -a postgres.log +echo "----------------------------------------" | tee -a $LOG_FILE if [ $ef -eq 1 ] then - echo "There were one or more errors." | tee -a postgres.log + echo "There were one or more errors." | tee -a $LOG_FILE retval=-1 else - echo "Completed without errors." | tee -a postgres.log + echo "Completed without errors." | tee -a $LOG_FILE retval=0 fi -echo "Finished ... `/bin/date`" | tee -a postgres.log -echo "----------------------------------------" | tee -a postgres.log +echo "Finished ... `/bin/date`" | tee -a $LOG_FILE +echo "----------------------------------------" | tee -a $LOG_FILE exit $retval diff --git a/src/test/resources/README-mysql-docker.md b/src/test/resources/README-mysql-docker.md index e5308cc..99d768f 100644 --- a/src/test/resources/README-mysql-docker.md +++ b/src/test/resources/README-mysql-docker.md @@ -53,18 +53,18 @@ Follow the instructions for the version you are using below. root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh ``` -### MariaDB - 11.04 +### MariaDB - 11.4 1. Launch the container
- `docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mariadb:11.04` + `docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mariadb:11.4` 2. Build Server ``` export dir=/wci/data/ cd $dir - docker run -it -v $dir:/data mariadb:11.04 /bin/bash + docker run -it -v $dir:/data mariadb:11.4 /bin/bash root@842bfb3da1f1:/# cd /data/rf2 - root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh + root@842bfb3da1f1:/data/rf2# ./populate_maria_db.sh ``` From 725b0e6058753536bfeb9939a89eb5783bd27666 Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 3 Jul 2025 10:21:44 -0700 Subject: [PATCH 86/95] OP-1079: Snomed CT INT July 1 2025 release --- pom.xml | 2 +- src/test/resources/README-announcements.txt | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 3b445ee..bf4412c 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ true - 20250101 + 20250701 Core INT diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 452da93..a1b82ec 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -2,10 +2,10 @@ ### Twitter --- SNOMED International Jan 1: +-- SNOMED International July 1: -Is it January already?! Announcing #SNOMEDCT DB load and transitive -closure scripts for the 20250101 International Edition! Out-of-the-box +Is it July already?! Announcing #SNOMEDCT DB load and transitive +closure scripts for the 20250701 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #MakingSnomedEasy #snomed https://www.westcoastinformatics.com/products/db-load-scripts @@ -20,19 +20,19 @@ https://www.westcoastinformatics.com/products/db-load-scripts ---- -The new year is here! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20250101 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +The new year is here! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20250701 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/products/db-load-scripts #MakingTerminologyEasy #MakingSnomedEasy #snomedct At West Coast Informatics, we are experts in loading healthcare terminology data into standard databases. Announcing updates to our Database Load Scripts for the -20240901 US Edition of SNOMEDCT. +20250301 US Edition of SNOMEDCT. Download now at https://www.westcoastinformatics.com/products/db-load-scripts These tools are designed to provide an easy mechanism to load SNOMEDCT into Postgres, MySQL (or MariaDB), or Oracle databases. These resources are free to use and will assist you with loading core SNOMED CT data and transitive closure tables into supported environments. These projects are hosted on Github and we welcome any feedback or community contributions. #MakingTerminologyEasy #MakingSnomedEasy #snomedct ### UMLS Users Mailing List -Subject: 20250101 SNOMEDCT DB load and transitive closure scripts +Subject: 20250701 SNOMEDCT DB load and transitive closure scripts Hi all, From fe80a5219f6feca0522a5cf6d14675168c383ebf Mon Sep 17 00:00:00 2001 From: = <=> Date: Tue, 8 Jul 2025 12:43:10 -0700 Subject: [PATCH 87/95] OP-1079: Update script to make it compatible with Python 2 and 3. --- .../rf2/compute_transitive_closure.py | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/resources/rf2/compute_transitive_closure.py b/src/main/resources/rf2/compute_transitive_closure.py index 90a2f5c..1c8b0ff 100644 --- a/src/main/resources/rf2/compute_transitive_closure.py +++ b/src/main/resources/rf2/compute_transitive_closure.py @@ -11,7 +11,7 @@ import argparse import time import logging -from typing import Dict, List, Any +# Remove type hints for Python 2.7 compatibility # # Set Defaults & Environment @@ -64,7 +64,7 @@ def initRelationships(relsFile, historyFile): global codes, parChd try: # Read relationships - with open(relsFile, 'r', newline='') as f: + with open(relsFile, 'r') as f: reader = csv.reader(f, delimiter='\t') next(reader) # Skip header row ct = 1 @@ -85,7 +85,7 @@ def initRelationships(relsFile, historyFile): codes[sourceId] = 1 codes[destinationId] = 1 - logging.info(f" {ct} relationships loaded") + logging.info(" {} relationships loaded".format(ct)) except IOError as e: logging.error("Failed to open {}: {}".format(relsFile, e)) exit(1) @@ -125,9 +125,9 @@ def initRelationships(relsFile, historyFile): parChd[targetComponentId].append(referencedComponentId) codes[referencedComponentId] = 1 - logging.info(f" {ct} historical relationships loaded") + logging.info(" {} historical relationships loaded".format(ct)) except Exception as e: - logging.error(f"Error processing history file: {e}") + logging.error("Error processing history file: {}".format(e)) raise ## Function to get descendants @@ -183,7 +183,7 @@ def main(): if force: os.remove(outputFile) else: - raise Exception(f"Output file already exists: {outputFile}. Check this is not an old file") + raise Exception("Output file already exists: {}. Check this is not an old file".format(outputFile)) # Determine history file path historyFile = "" @@ -194,31 +194,31 @@ def main(): elif "Terminology" in historyFile: historyFile = historyFile.replace("Terminology", "Refset/Content") else: - raise Exception(f"Unable to determine path to Association refset file from relationships file = {relsFile}") + raise Exception("Unable to determine path to Association refset file from relationships file = {}".format(relsFile)) if not os.path.exists(historyFile): - raise Exception(f"Computed path to Association refset file does not exist = {historyFile}") + raise Exception("Computed path to Association refset file does not exist = {}".format(historyFile)) # Print configuration print("------------------------------------------------------------") - print(f"Starting ... {time.asctime()}") + print("Starting ... {}".format(time.asctime())) print("------------------------------------------------------------") - print(f"Isa rel : {isaRel}") - print(f"Rels file : {relsFile}") - print(f"Self : {self}") - print(f"Output file : {outputFile}") + print("Isa rel : {}".format(isaRel)) + print("Rels file : {}".format(relsFile)) + print("Self : {}".format(self)) + print("Output file : {}".format(outputFile)) if history: - print(f"History : {history}") - print(f"History file : {historyFile}") + print("History : {}".format(history)) + print("History file : {}".format(historyFile)) print("\n") # Initialize relationships - print(f" Load PAR/CHD rels ... {time.asctime()}") + print(" Load PAR/CHD rels ... {}".format(time.asctime())) initRelationships(relsFile, historyFile) # Write transitive closure to output file - print(" Write transitive closure table ...", time.asctime()) + print(" Write transitive closure table ... {}".format(time.asctime())) ct = 0 # Initialize counter here - with open(outputFile, 'w', newline='') as f: + with open(outputFile, 'w') as f: writer = csv.writer(f, delimiter='\t') writer.writerow(["superTypeId", "subTypeId", "depth"]) for code in codes.keys(): @@ -239,10 +239,10 @@ def main(): writer.writerow([code, desc, depth-1]) if ct % 10000 == 0: - logging.info(f" {ct} codes processed ... {time.asctime()}") + logging.info(" {} codes processed ... {}".format(ct, time.asctime())) print("------------------------------------------------------------") - print("finished ...", time.asctime()) + print("finished ... {}".format(time.asctime())) print("------------------------------------------------------------\n") From eaecaf4b3f8601557a207e3bd4b15b0d95ae74ba Mon Sep 17 00:00:00 2001 From: = <=> Date: Tue, 8 Jul 2025 12:43:47 -0700 Subject: [PATCH 88/95] OP-1079: Update field size to make load work with Oracle 19c. --- src/main/resources/rf2/oracle_tables.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/rf2/oracle_tables.sql b/src/main/resources/rf2/oracle_tables.sql index b4ba707..e8f69c2 100644 --- a/src/main/resources/rf2/oracle_tables.sql +++ b/src/main/resources/rf2/oracle_tables.sql @@ -58,7 +58,7 @@ CREATE TABLE description conceptId NUMERIC(20) NOT NULL, languageCode CHAR(2) NOT NULL, typeId NUMERIC(20) NOT NULL, - term VARCHAR2(4096) NOT NULL, + term CLOB NOT NULL, caseSignificanceId NUMERIC(20) NOT NULL, FOREIGN KEY (moduleId) REFERENCES concept (id), FOREIGN KEY (conceptId) REFERENCES concept (id), @@ -72,7 +72,7 @@ EXECUTE drop_table('identifier'); CREATE TABLE identifier ( identifierSchemeId NUMERIC(20) NOT NULL, - alternateIdentifier VARCHAR2(4096) NOT NULL, + alternateIdentifier CLOB NOT NULL, effectiveTime DATE NOT NULL, active NUMERIC(1) NOT NULL, moduleId NUMERIC(20) NOT NULL, From 334140580a8fc9e1146d093501bb1ea13ec80aa6 Mon Sep 17 00:00:00 2001 From: = <=> Date: Tue, 8 Jul 2025 12:51:35 -0700 Subject: [PATCH 89/95] OP-1079: Update for Oracle 19c. --- README.md | 2 +- src/main/resources/rf2/populate_oracle_db.sh | 2 +- src/test/resources/README-oracle-docker.md | 20 ++++++++------------ 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 6d20aa7..3e3a405 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Minimum Specification --------------------- - MySQL v8.+, MariaDB 10.+, MariaDB 11.+ - MySQL v8 requires the server to run with "--local_infile=ON" -- Oracle v12.+ +- Oracle v19.+ - Postgres v13.+, v14.+, v15.+, v16.+, v17.+ Installation diff --git a/src/main/resources/rf2/populate_oracle_db.sh b/src/main/resources/rf2/populate_oracle_db.sh index aa0400a..c705577 100644 --- a/src/main/resources/rf2/populate_oracle_db.sh +++ b/src/main/resources/rf2/populate_oracle_db.sh @@ -3,7 +3,7 @@ # # Database connection parameters # Set if necessary -#export ORACLE_HOME=/app/oracle/product/12.1.0/dbhome_1 +#export ORACLE_HOME=/opt/oracle/product/19c/dbhome_1 # PLEASE EDIT THESE VARIABLES TO REFLECT YOUR ENVIRONMENT user=snomed password=snomed diff --git a/src/test/resources/README-oracle-docker.md b/src/test/resources/README-oracle-docker.md index 74b22bd..d0f152d 100644 --- a/src/test/resources/README-oracle-docker.md +++ b/src/test/resources/README-oracle-docker.md @@ -1,14 +1,13 @@ -# Oracle 12c BUILD INSTRUCTIONS +# Oracle 19c BUILD INSTRUCTIONS ## Prerequisites 1. Log into DockerHub and agree to Oracle's Terms of Service - [Oracle DB Enterprise Repository](https://container-registry.oracle.com/ords/f?p=113:1:103153009327673::::FSP_LANGUAGE_PREFERENCE:&cs=3vvrLolDIFGAxz-ReKVoNrPBwhCCJtGRffMagNzTnvafG3AeKT2KLWKQSclqKpS-c6TF2uprvjENxXOETZOmgfQ) - Log in with your account and then click on "Continue" on the line enterprise. This will allow you to pull the Oracle Database Enterprise Edition image from the Oracle Container Registry. - Pull the image from the Oracle Container Registry - `docker login container-registry.oracle.com` and enter your hub.docker.com credentials - - `docker pull container-registry.oracle.com/database/enterprise:12.2.0.1-slim` - - `docker pull container-registry.oracle.com/database/enterprise:12.1.0.2` + - `docker pull container-registry.oracle.com/database/enterprise:19.3.0.0` 2. For testing oracle, run a docker oracle instance - - https://dzone.com/articles/oracle-12c-image-installation-in-docker + - https://dzone.com/articles/oracle-19c-image-installation-in-docker 3. If you're running this locally, you will use `localhost` as the host. If you're running this on a remote server, you will use the server's IP address as the host. @@ -24,7 +23,7 @@ unzip -o /wci/projects/SNOMED-DB-Load-Scripts/target/snomed-db-scripts-oracle.*.zip sudo chmod +x rf2/populate_oracle_db.sh sudo chmod +x rf2/compute_transitive_closure.py - + # To avoid permission issues, make sure to grant write perms to the all folders chmod -R 777 rf2 ``` @@ -41,12 +40,9 @@ Create log files and allow read/write to all users. ``` export dir=/wci/data/ cd $dir - - #For store/oracle/database-enterprise:12.2.0.1-slim - sudo docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 container-registry.oracle.com/database/enterprise:12.2.0.1-slim - - #For container-registry.oracle.com/database/enterprise:12.1.0.2 - sudo docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 container-registry.oracle.com/database/enterprise:12.1.0.2 + + #For container-registry.oracle.com/database/enterprise:19.3.0.0 + sudo docker run --name snomed-oracle -v $dir:/data -d --rm -p 8080:8080 -p 1521:1521 container-registry.oracle.com/database/enterprise:19.3.0.0 ``` ## Populate DB @@ -62,7 +58,7 @@ Create log files and allow read/write to all users. create user snomed identified by snomed; GRANT CONNECT, RESOURCE, DBA TO snomed; exit - + root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_oracle_db.sh ``` From ecdba2cc531ac12b9c7f8d205f0e0a9aaa1052e5 Mon Sep 17 00:00:00 2001 From: = <=> Date: Sun, 31 Aug 2025 16:27:15 -0700 Subject: [PATCH 90/95] SNOMEDCT US 20250901 release --- pom.xml | 2 +- src/test/resources/README-announcements.txt | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index bf4412c..7ac50f4 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ US - 20250301 + 20250901 National US1000124 diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index a1b82ec..e65c8db 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -10,10 +10,10 @@ support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #MakingSnomedEasy #snomed https://www.westcoastinformatics.com/products/db-load-scripts --- US Edition March 1: +-- US Edition September 1: Spring is upon us! Announcing #SNOMEDCT DB load and transitive -closure scripts for the 20250301 US Edition! Out-of-the-box +closure scripts for the 20250901 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #snomedct #termhub https://www.westcoastinformatics.com/products/db-load-scripts @@ -25,7 +25,7 @@ See https://westcoastinformatics.com/products/db-load-scripts #MakingTerminolog At West Coast Informatics, we are experts in loading healthcare terminology data into standard databases. Announcing updates to our Database Load Scripts for the -20250301 US Edition of SNOMEDCT. +20250901 US Edition of SNOMEDCT. Download now at https://www.westcoastinformatics.com/products/db-load-scripts These tools are designed to provide an easy mechanism to load SNOMEDCT into Postgres, MySQL (or MariaDB), or Oracle databases. These resources are free to use and will assist you with loading core SNOMED CT data and transitive closure tables into supported environments. These projects are hosted on Github and we welcome any feedback or community contributions. @@ -36,7 +36,7 @@ Subject: 20250701 SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the March 01, 2025 update of the SNOMEDCT US Edition. +NLM recently posted the September 01, 2025 update of the SNOMEDCT US Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. From 35d63a78f1f0d9d03e58dc8df9f08af52ceca0f8 Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 5 Jan 2026 19:06:15 -0800 Subject: [PATCH 91/95] OP-1929: SNOMEDCT INTL 20260101 --- README.md | 7 ++++--- pom.xml | 2 +- src/test/resources/README-announcements.txt | 12 ++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3e3a405..50b834e 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,11 @@ queries about "child of", "descendant of", and "descendant or self of". Minimum Specification --------------------- -- MySQL v8.+, MariaDB 10.+, MariaDB 11.+ +- MySQL v8.4 - MySQL v8 requires the server to run with "--local_infile=ON" -- Oracle v19.+ -- Postgres v13.+, v14.+, v15.+, v16.+, v17.+ +- MariaDB 10.+, MariaDB 11.+ +- Oracle v19.+, v21.+, v23.+ +- Postgres v14.+, v15.+, v16.+, v17.+, v18.+ Installation ------------ diff --git a/pom.xml b/pom.xml index 7ac50f4..8e5d147 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ true - 20250701 + 20260101 Core INT diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index e65c8db..18ebf52 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -2,10 +2,10 @@ ### Twitter --- SNOMED International July 1: +-- SNOMED International January 1: -Is it July already?! Announcing #SNOMEDCT DB load and transitive -closure scripts for the 20250701 International Edition! Out-of-the-box +Is it January already?! Announcing #SNOMEDCT DB load and transitive +closure scripts for the 20260101 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #MakingSnomedEasy #snomed https://www.westcoastinformatics.com/products/db-load-scripts @@ -20,7 +20,7 @@ https://www.westcoastinformatics.com/products/db-load-scripts ---- -The new year is here! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20250701 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +The new year is here! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20260101 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/products/db-load-scripts #MakingTerminologyEasy #MakingSnomedEasy #snomedct At West Coast Informatics, we are experts in loading healthcare terminology data @@ -32,11 +32,11 @@ These tools are designed to provide an easy mechanism to load SNOMEDCT into Post #MakingTerminologyEasy #MakingSnomedEasy #snomedct ### UMLS Users Mailing List -Subject: 20250701 SNOMEDCT DB load and transitive closure scripts +Subject: 20260101 SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the September 01, 2025 update of the SNOMEDCT US Edition. +NLM recently posted the January 01, 2026 update of the SNOMEDCT Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. From ea0fbeb74f12bca02f21319f2389af8634707306 Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 8 Jan 2026 15:38:44 -0800 Subject: [PATCH 92/95] OP-1929: Remove populate mariadb script from oracle and postgres artifacts --- src/main/assembly/oracle.xml | 1 + src/main/assembly/postgres.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/assembly/oracle.xml b/src/main/assembly/oracle.xml index acad967..93be388 100644 --- a/src/main/assembly/oracle.xml +++ b/src/main/assembly/oracle.xml @@ -11,6 +11,7 @@ rf1/** **/*mysql* + **/*maria* **/*postgres* **/*psql* diff --git a/src/main/assembly/postgres.xml b/src/main/assembly/postgres.xml index 3cb5007..6d97931 100644 --- a/src/main/assembly/postgres.xml +++ b/src/main/assembly/postgres.xml @@ -11,6 +11,7 @@ rf1/** **/*oracle* + **/*maria* **/*.ctl **/*mysql* From 5ca456c3efacaf2f8519ec315d091f1770cd7dc2 Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 5 Mar 2026 13:13:57 -0800 Subject: [PATCH 93/95] OP-2119: Update for SNOMEDCT US 20260301 --- pom.xml | 2 +- src/main/resources/HOWTO.md | 28 +++++++++++++++++++ src/main/resources/LICENSE.txt | 2 +- .../rf2/compute_transitive_closure.pl | 2 +- .../rf2/compute_transitive_closure.py | 2 +- src/test/resources/README-announcements.txt | 6 ++-- 6 files changed, 35 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 8e5d147..29d8ebd 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ US - 20250901 + 20260301 National US1000124 diff --git a/src/main/resources/HOWTO.md b/src/main/resources/HOWTO.md index 9b71d19..fb311f2 100644 --- a/src/main/resources/HOWTO.md +++ b/src/main/resources/HOWTO.md @@ -45,3 +45,31 @@ See [https://youtu.be/917T6D3b5ro](https://youtu.be/917T6D3b5ro) 7. Execute the "populate" script * Note: a complete log file will appear as `mysql.log`, `mariadb.log`, `postgres.log`, or `oracle.log` + +## Oracle: VARCHAR2 vs CLOB for description and text definition (4096 characters) + +SNOMED CT allows description and text definition terms up to 4096 characters. Oracle's default `VARCHAR2` limit is 4000 characters, so this package uses **CLOB** for: + +- `description.term` +- `textdefinition.term` + +**Writing queries** + +- **Simple SELECT:** Use the column as usual. Oracle converts CLOB to character data for display. + ```sql + SELECT term FROM description WHERE id = 12345; + SELECT term FROM textdefinitionwithnames WHERE conceptId = 12345; + ``` + +- **GROUP BY, ORDER BY, or DISTINCT** on these columns: Use `DBMS_LOB.SUBSTR` so Oracle can compare/sort. Use the same expression in both SELECT and GROUP BY when grouping by the term. + ```sql + SELECT DBMS_LOB.SUBSTR(term, 4000, 1) AS term, COUNT(*) + FROM description + WHERE active = 1 + GROUP BY DBMS_LOB.SUBSTR(term, 4000, 1); + ``` + +- **Views:** Views that expose these columns (e.g. `descriptionwithnames`, `textdefinitionwithnames`, `conceptwithnames` / preferred name) return CLOB. Same rules: simple SELECT is fine; for GROUP BY/ORDER BY on the term column, wrap in `DBMS_LOB.SUBSTR(column, 4000, 1)`. + +**Why CLOB and not VARCHAR2(4096)?** +`VARCHAR2(4096)` requires Oracle's `MAX_STRING_SIZE=EXTENDED`, which is not default and is not assumed for this package. Using CLOB works on all supported Oracle versions without that setting. diff --git a/src/main/resources/LICENSE.txt b/src/main/resources/LICENSE.txt index 9b836df..bf84c2d 100644 --- a/src/main/resources/LICENSE.txt +++ b/src/main/resources/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright 2025 West Coast Informatics, LLC +Copyright 2026 West Coast Informatics, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/main/resources/rf2/compute_transitive_closure.pl b/src/main/resources/rf2/compute_transitive_closure.pl index 9640794..313701b 100644 --- a/src/main/resources/rf2/compute_transitive_closure.pl +++ b/src/main/resources/rf2/compute_transitive_closure.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# Copyright 2025 West Coast Informatics, Inc +# Copyright 2026 West Coast Informatics, Inc # # Computes transitive closure from a snapshot inferred RF2 relationships file. # diff --git a/src/main/resources/rf2/compute_transitive_closure.py b/src/main/resources/rf2/compute_transitive_closure.py index 1c8b0ff..3993331 100644 --- a/src/main/resources/rf2/compute_transitive_closure.py +++ b/src/main/resources/rf2/compute_transitive_closure.py @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 2025 West Coast Informatics, Inc +# Copyright 2026 West Coast Informatics, Inc # # Computes transitive closure from a snapshot inferred RF2 relationships file. # diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index 18ebf52..c79e707 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -10,10 +10,10 @@ support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #MakingSnomedEasy #snomed https://www.westcoastinformatics.com/products/db-load-scripts --- US Edition September 1: +-- US Edition March 1: Spring is upon us! Announcing #SNOMEDCT DB load and transitive -closure scripts for the 20250901 US Edition! Out-of-the-box +closure scripts for the 20260301 US Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #snomedct #termhub https://www.westcoastinformatics.com/products/db-load-scripts @@ -25,7 +25,7 @@ See https://westcoastinformatics.com/products/db-load-scripts #MakingTerminolog At West Coast Informatics, we are experts in loading healthcare terminology data into standard databases. Announcing updates to our Database Load Scripts for the -20250901 US Edition of SNOMEDCT. +20260301 US Edition of SNOMEDCT. Download now at https://www.westcoastinformatics.com/products/db-load-scripts These tools are designed to provide an easy mechanism to load SNOMEDCT into Postgres, MySQL (or MariaDB), or Oracle databases. These resources are free to use and will assist you with loading core SNOMED CT data and transitive closure tables into supported environments. These projects are hosted on Github and we welcome any feedback or community contributions. From 7b1d84c2f7e2b6e39c9a32ac7ef605a81cf2ad07 Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 6 Jul 2026 13:15:18 -0700 Subject: [PATCH 94/95] OP-2512: July 1, 2026 release of SNOMEDCT Int'l. --- pom.xml | 2 +- src/test/resources/README-announcements.txt | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 29d8ebd..684d1d4 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ true - 20260101 + 20260701 Core INT diff --git a/src/test/resources/README-announcements.txt b/src/test/resources/README-announcements.txt index c79e707..196be50 100644 --- a/src/test/resources/README-announcements.txt +++ b/src/test/resources/README-announcements.txt @@ -2,10 +2,10 @@ ### Twitter --- SNOMED International January 1: +-- SNOMED International July 1: -Is it January already?! Announcing #SNOMEDCT DB load and transitive -closure scripts for the 20260101 International Edition! Out-of-the-box +Is it July already?! Announcing #SNOMEDCT DB load and transitive +closure scripts for the 20260701 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. #MakingTerminologyEasy #MakingSnomedEasy #snomed https://www.westcoastinformatics.com/products/db-load-scripts @@ -20,7 +20,7 @@ https://www.westcoastinformatics.com/products/db-load-scripts ---- -The new year is here! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20260101 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. +The new year is here! Announcing #SNOMEDCT DB load and transitive closure scripts for the 20260701 International Edition! Out-of-the-box support for #Postgres, #Oracle, #MySQL, and #MariaDB. See https://westcoastinformatics.com/products/db-load-scripts #MakingTerminologyEasy #MakingSnomedEasy #snomedct At West Coast Informatics, we are experts in loading healthcare terminology data @@ -32,11 +32,11 @@ These tools are designed to provide an easy mechanism to load SNOMEDCT into Post #MakingTerminologyEasy #MakingSnomedEasy #snomedct ### UMLS Users Mailing List -Subject: 20260101 SNOMEDCT DB load and transitive closure scripts +Subject: 20260701 SNOMEDCT DB load and transitive closure scripts Hi all, -NLM recently posted the January 01, 2026 update of the SNOMEDCT Edition. +NLM recently posted the July 01, 2026 update of the SNOMEDCT Edition. For those interested in interacting with SNOMEDCT data through a relational database, we have a utility to make it easy to load the data into a Postgres, Oracle, MySQL (or MariaDB) database. From 46228256ade62dc4cf3e09f7b2b2340efaddf9d8 Mon Sep 17 00:00:00 2001 From: = <=> Date: Tue, 7 Jul 2026 17:47:02 -0700 Subject: [PATCH 95/95] OP-2512: Update database versions --- README.md | 4 +-- src/test/resources/README-mysql-docker.md | 18 +++++++++++- src/test/resources/README-oracle-docker.md | 7 +++-- src/test/resources/README-postgres-docker.md | 30 ++++++++++---------- 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 50b834e..2d2d7ae 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ Minimum Specification --------------------- - MySQL v8.4 - MySQL v8 requires the server to run with "--local_infile=ON" -- MariaDB 10.+, MariaDB 11.+ -- Oracle v19.+, v21.+, v23.+ +- MariaDB v10.+, v11.+, v12.+ +- Oracle v19.+, v21.+, v26.+ - Postgres v14.+, v15.+, v16.+, v17.+, v18.+ Installation diff --git a/src/test/resources/README-mysql-docker.md b/src/test/resources/README-mysql-docker.md index 99d768f..698e12d 100644 --- a/src/test/resources/README-mysql-docker.md +++ b/src/test/resources/README-mysql-docker.md @@ -53,7 +53,23 @@ Follow the instructions for the version you are using below. root@842bfb3da1f1:/data/rf2# ./populate_mysql_db.sh ``` -### MariaDB - 11.4 +### MariaDB - 11.4, 11.8 + +1. Launch the container
+ `docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mariadb:11.4` + +2. Build Server + +``` + export dir=/wci/data/ + cd $dir + docker run -it -v $dir:/data mariadb:11.4 /bin/bash + + root@842bfb3da1f1:/# cd /data/rf2 + root@842bfb3da1f1:/data/rf2# ./populate_maria_db.sh +``` + +### MariaDB - 12.3 1. Launch the container
`docker run --name snomed-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=snomed -d --rm mariadb:11.4` diff --git a/src/test/resources/README-oracle-docker.md b/src/test/resources/README-oracle-docker.md index d0f152d..30c057e 100644 --- a/src/test/resources/README-oracle-docker.md +++ b/src/test/resources/README-oracle-docker.md @@ -1,4 +1,4 @@ -# Oracle 19c BUILD INSTRUCTIONS +# Oracle 19c, 21c, 26ai BUILD INSTRUCTIONS ## Prerequisites 1. Log into DockerHub and agree to Oracle's Terms of Service - [Oracle DB Enterprise Repository](https://container-registry.oracle.com/ords/f?p=113:1:103153009327673::::FSP_LANGUAGE_PREFERENCE:&cs=3vvrLolDIFGAxz-ReKVoNrPBwhCCJtGRffMagNzTnvafG3AeKT2KLWKQSclqKpS-c6TF2uprvjENxXOETZOmgfQ) @@ -6,6 +6,9 @@ - Pull the image from the Oracle Container Registry - `docker login container-registry.oracle.com` and enter your hub.docker.com credentials - `docker pull container-registry.oracle.com/database/enterprise:19.3.0.0` + - `docker pull container-registry.oracle.com/database/enterprise:21.3.0.0` + - `docker pull container-registry.oracle.com/database/enterprise:23.26.1.0` + 2. For testing oracle, run a docker oracle instance - https://dzone.com/articles/oracle-19c-image-installation-in-docker @@ -36,7 +39,7 @@ ``` ## Launch the container -Create log files and allow read/write to all users. +Create log files and allow read/write to all users. Use the appropriate image for the version you are using for 19c, 21c, or 26ai. ``` export dir=/wci/data/ cd $dir diff --git a/src/test/resources/README-postgres-docker.md b/src/test/resources/README-postgres-docker.md index 4a2d2c6..6543a1c 100644 --- a/src/test/resources/README-postgres-docker.md +++ b/src/test/resources/README-postgres-docker.md @@ -18,81 +18,81 @@ Add new versions, remove versions whose final release is the past and, bump the - For testing postgres, run a docker postgres instance - https://hub.docker.com/_/postgres -### Postgres 13.20 +### Postgres 14.23 1. Launch the container
- `docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:13.20` + `docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:14.23` 2. Build Server ``` export dir=/wci/data/ cd $dir - docker run -it -v "$dir":/data postgres:13.20 /bin/bash + docker run -it -v "$dir":/data postgres:14.23 /bin/bash root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh ``` -### Postgres 14.17 +### Postgres 15.18 1. Launch the container
- `docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:14.17` + `docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:15.1812` 2. Build Server ``` export dir=/wci/data/ cd $dir - docker run -it -v "$dir":/data postgres:14.17 /bin/bash + docker run -it -v "$dir":/data postgres:15.18 /bin/bash root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh ``` -### Postgres 15.12 +### Postgres 16.14 1. Launch the container
- `docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:15.12` + `docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:16.14` 2. Build Server ``` export dir=/wci/data/ cd $dir - docker run -it -v "$dir":/data postgres:15.12 /bin/bash + docker run -it -v "$dir":/data postgres:16.14 /bin/bash root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh ``` -### Postgres 16.8 +### Postgres 17.10 1. Launch the container
- `docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:16.8` + `docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:17.10` 2. Build Server ``` export dir=/wci/data/ cd $dir - docker run -it -v "$dir":/data postgres:16.8 /bin/bash + docker run -it -v "$dir":/data postgres:17.10 /bin/bash root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh ``` -### Postgres 17.4 +### Postgres 18.4 1. Launch the container
- `docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:17.4` + `docker run --name snomed-postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin -e POSTGRES_DB=snomed -d --rm postgres:18.4` 2. Build Server ``` export dir=/wci/data/ cd $dir - docker run -it -v "$dir":/data postgres:17.4 /bin/bash + docker run -it -v "$dir":/data postgres:18.4 /bin/bash root@842bfb3da1f1:/# cd /data/rf2 root@842bfb3da1f1:/data/rf2# ./populate_postgres_db.sh