Removed references to OMOP CDM v4. Updated Readme to include changes from v5 to v5.1
This commit is contained in:
parent
5643fc5107
commit
7bba78ac08
42
README.md
42
README.md
|
@ -2,3 +2,45 @@ Common-Data-Model
|
|||
=================
|
||||
|
||||
See full CDM specification file on our [Wiki](http://www.ohdsi.org/web/wiki/doku.php?id=documentation:cdm:single-page) or in the [CDM V5 PDF](https://github.com/OHDSI/CommonDataModel/blob/master/OMOP%20CDM%20v5.pdf)
|
||||
|
||||
Release Notes
|
||||
=============
|
||||
This version is bases on this CDM working group [proposal](http://www.ohdsi.org/web/wiki/doku.php?id=documentation:next_cdm:time). The proposed and accepted changes include adding a datetime field to every table that had a date column. These were the new columns added:
|
||||
|
||||
**PERSON**
|
||||
birth_datetime, not required
|
||||
|
||||
**SPECIMEN**
|
||||
specimen_datetime, not required
|
||||
|
||||
**DEATH**
|
||||
death_datetime, not required
|
||||
|
||||
**VISIT_OCCURRENCE**
|
||||
visit_start_datetime, not required
|
||||
visit_end_datetime, not required
|
||||
|
||||
**PROCEDURE_OCCURRENCE**
|
||||
procedure_datetime, not required
|
||||
|
||||
**DRUG_EXPOSURE**
|
||||
drug_exposure_start_datetime, not required
|
||||
drug_exposure_end_datetime, not required
|
||||
|
||||
**DEVICE_EXPOSURE**
|
||||
device_exposure_start_datetime, not required
|
||||
device_exposure_end_datetime, not required
|
||||
|
||||
**CONDITION_OCCURRENCE**
|
||||
condition_start_datetime, not required
|
||||
condition_end_datetime, not required
|
||||
|
||||
**MEASUREMENT**
|
||||
measurement_datetime as time, not required
|
||||
|
||||
**OBSERVATION**
|
||||
observation_datetime, not required
|
||||
|
||||
**NOTE**
|
||||
note_datetime, not required
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
@ -1,60 +0,0 @@
|
|||
Conversion from CDM v4 to CDM v5
|
||||
==============================================================
|
||||
|
||||
The scripts in this directory will aid you in moving your data from the Common Data Model (CDM) version 4 to version 5.
|
||||
|
||||
Overview
|
||||
==============================================================
|
||||
|
||||
The resources in this folder provide you with a means for converting your CDM V4 database to CDM V5. The goal of these scripts is to provide a path for converting your data to the CDM V5 to take advantage of the other tools that are being built to support research on CDM V5. These scripts are **NOT** designed to replace a proper ETL from your source data to CDM V5.
|
||||
|
||||
One of the most important aspects to this conversion script is the use of the **[Standarized Vocabularies](http://www.ohdsi.org/web/wiki/doku.php?id=documentation:vocabulary:introduction "Standarized Vocabularies")** to map from tables in the V4 database to their cooresponding V5 table using the vocabulary **[domains](http://www.ohdsi.org/web/wiki/doku.php?id=documentation:vocabulary:domains "domains")**. At the beginning of the conversion script, we create a #concept\_map temporary table which holds a mapping from source_concept_id's to standard target_concept_ids for each of the domains. This table is then used throughout the remainder of the script to map rows from each of the source V4 tables (i.e. condition\_occurrence) to the proper table in the V5 data model. As a result, the number of rows in the V4 condition\_occurrence will not be the same as in V5 since some rows may be converted to a different table based on the standard concept mapping.
|
||||
|
||||
Assumptions
|
||||
==============================================================
|
||||
|
||||
We have created a directory per Relational Database Management System (RDBMS) that contains the conversion script for that database platform. All of the scripts have the same assumptions:
|
||||
|
||||
1. Your source CDM V4 database is on the same sever as your target CDM v5 database.
|
||||
2. You have read rights to the CDM V4 database and database owner privileges on the target V5 database as this script will create an "ETL_WARNINGS" table in the process.
|
||||
3. You have enough storage on your database server to perform the conversion.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
1. **Create your V5 Target Database:** Create a CDM V5 database on the same server as your CDM V4 database by using the **[Common Data Model Scripts](https://github.com/OHDSI/CommonDataModel "Common Data Model Scripts")** for your RDBMS. **NOTE: Please review the data types that exist on your V4 database and ensure you carry forward any data type changes from V4 to V5. For example, if you converted columns from an INT to a BIGINT to accommodate tables with > 2.1 Billion Rows, you will need to make the corresponding changes in your V5 Database and potentially to this conversion script**
|
||||
|
||||
2. **Load the V5 Vocabulary**: Download the V5 vocabulary from **[Athena](http://www.ohdsi.org/web/athena/ "Athena")** and load them into the V5 database created in step 1 above.
|
||||
|
||||
2. **Download the conversion script:** The **[CDM V4 to V5 Conversion](https://github.com/OHDSI/CommonDataModel/tree/master/Version4%20To%20Version5%20Conversion "CDM V4 to V5 Conversion Directory")** folder has subfolders with scripts that will work on each RDBMS. In order to make this file work in your environment, you will need to perform a global "FIND AND REPLACE" on the conversion script to fill in the file with values that pertain to your environment. The following are the tokens you should use when doing your "FIND AND REPLACE" operation:
|
||||
|
||||
* [SOURCE_CDMV4] - Your V4 database name
|
||||
* [SOURCE_CDMV4].[SCHEMA] - Your V4 database name + schema
|
||||
* [TARGET_CDMV5] - Your V5 database name
|
||||
* [TARGET_CDMV5].[SCHEMA] - Your V5 database name + schema
|
||||
|
||||
3. Run the resulting script on your target RDBDMS. ** **NOTE** ** If you are running the Oracle script via Sql Developer or similar, you may need to alter the script to include the appropriate "/" symbols to mark the end of the anonymous code blocks. This has been done in the Oracle script that has been provided in this repository.
|
||||
4. At the end of the conversion process, several tables will be produced that will help you to understand how your data has changed as a result of the conversion process. This is described in the Quality Assurance section below.
|
||||
|
||||
|
||||
Quality Assurance
|
||||
===================
|
||||
|
||||
At the end of the conversion script, there are 3 queries which will provide information on the conversion process. For reference, this section of the conversion script has a header comment:
|
||||
|
||||
/**** QUALITY ASSURANCE OUTPUT ****/
|
||||
|
||||
The first query provides a means for comparing the table row counts between the V4 and V5 databases. As mentioned in the overview section above, table row counts will differ between V4 and V5 based on the way that the standard vocabulary maps the data. The next set of queries will help to tie out the row count changes in these tables.
|
||||
|
||||
The second query shows the source V4 table (i.e condition\_occurrence) and how the row counts maps to the V5 domain. This table is useful to understand how the data from the V4 source was distributed into the V5 tables. As a note, 1 record in the V4 table could map to multiple records in V5 as some concepts will map to multiple standard domains.
|
||||
|
||||
The third query uses the information from the second query and provides a summary for each V5 domain. This is useful for tying out the rowcounts we'd expect from the script with the actual results observed in the first query.
|
||||
|
||||
We have included a spreadsheet called "QA-Results.xlsx" which provides an example of how to utilize these 3 result queries to understand the results of the conversion process. The results of the first query go into the "Rowcounts" worksheet. The results of the second and third queries go into the "Classification Map Results" worksheet. If the conversion process worked as expected, all of the "Difference" columns should equal 0 in the "Classification Map Results" worksheet.
|
||||
|
||||
Getting Involved
|
||||
==============================================================
|
||||
Each script found in the RDBMS directory was generated from the OHDSI-SQL file: *OMOP CDMv4 to CDMv5 - OHDSI-SQL.sql* found in the root of this directory. If you would like to contribute to this script, we'd suggest you modify this script and use **[SqlRender](https://github.com/OHDSI/SqlRender "SqlRender")** to re-generate the specific RDBMS scripts. We have also supplied a basic R script in this directory to help re-generate the scripts using SqlRender.
|
||||
|
||||
Developer questions/comments/feedback: OHDSI Forum
|
||||
We use the GitHub issue tracker for all bugs/issues/enhancements
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,310 +0,0 @@
|
|||
/*********************************************************************************
|
||||
# Copyright 2015 Observational Health Data Sciences and Informatics
|
||||
#
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.4
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # ## #######
|
||||
# # ## ## # # # # # # # # ## ## # # # # #
|
||||
# # # # # # # # # # # # # # # # # # # # # #
|
||||
# # # # # # # ###### # # # # # # # # ####### #######
|
||||
# # # # # # # # # # # # # # # #
|
||||
# # # # # # # # # # # # # # # # # #
|
||||
####### # # ####### # ##### ###### # # ## # # #####
|
||||
|
||||
|
||||
script to create OMOP common data model, version 5.0 for Oracle database
|
||||
|
||||
last revised: 1 Mar 2015
|
||||
|
||||
author: Christian Reich
|
||||
|
||||
|
||||
*************************/
|
||||
|
||||
CREATE TABLE concept
|
||||
(
|
||||
concept_id INTEGER NOT NULL,
|
||||
concept_name VARCHAR2(256 BYTE) NOT NULL,
|
||||
concept_level NUMBER NOT NULL,
|
||||
concept_class VARCHAR2(60 BYTE) NOT NULL,
|
||||
vocabulary_id INTEGER NOT NULL,
|
||||
concept_code VARCHAR2(40 BYTE) NOT NULL,
|
||||
valid_start_date DATE NOT NULL,
|
||||
valid_end_date DATE DEFAULT '31-Dec-2099' NOT NULL,
|
||||
invalid_reason CHAR(1 BYTE)
|
||||
) NOLOGGING;
|
||||
|
||||
COMMENT ON TABLE concept IS 'A list of all valid terminology concepts across domains and their attributes. Concepts are derived from existing standards.';
|
||||
|
||||
COMMENT ON COLUMN concept.concept_id IS 'A system-generated identifier to uniquely identify each concept across all concept types.';
|
||||
|
||||
COMMENT ON COLUMN concept.concept_name IS 'An unambiguous, meaningful and descriptive name for the concept.';
|
||||
|
||||
COMMENT ON COLUMN concept.concept_level IS 'The level of hierarchy associated with the concept. Different concept levels are assigned to concepts to depict their seniority in a clearly defined hierarchy, such as drugs, conditions, etc. A concept level of 0 is assigned to concepts that are not part of a standard vocabulary, but are part of the vocabulary for reference purposes (e.g. drug form).';
|
||||
|
||||
COMMENT ON COLUMN concept.concept_class IS 'The category or class of the concept along both the hierarchical tree as well as different domains within a vocabulary. Examples are ''Clinical Drug'', ''Ingredient'', ''Clinical Finding'' etc.';
|
||||
|
||||
COMMENT ON COLUMN concept.vocabulary_id IS 'A foreign key to the vocabulary table indicating from which source the concept has been adapted.';
|
||||
|
||||
COMMENT ON COLUMN concept.concept_code IS 'The concept code represents the identifier of the concept in the source data it originates from, such as SNOMED-CT concept IDs, RxNorm RXCUIs etc. Note that concept codes are not unique across vocabularies.';
|
||||
|
||||
COMMENT ON COLUMN concept.valid_start_date IS 'The date when the was first recorded.';
|
||||
|
||||
COMMENT ON COLUMN concept.valid_end_date IS 'The date when the concept became invalid because it was deleted or superseded (updated) by a new concept. The default value is 31-Dec-2099.';
|
||||
|
||||
COMMENT ON COLUMN concept.invalid_reason IS 'Concepts that are replaced with a new concept are designated "Updated" (U) and concepts that are removed without replacement are "Deprecated" (D).';
|
||||
|
||||
CREATE INDEX concept_code ON concept (concept_code, vocabulary_id);
|
||||
CREATE UNIQUE INDEX XPKconcept ON concept (concept_id);
|
||||
|
||||
ALTER TABLE concept ADD (
|
||||
CHECK ( invalid_reason IN ('D', 'U'))
|
||||
ENABLE VALIDATE,
|
||||
CONSTRAINT XPKCONCEPT
|
||||
PRIMARY KEY
|
||||
(concept_id)
|
||||
USING INDEX XPKCONCEPT
|
||||
ENABLE VALIDATE);
|
||||
|
||||
--add table RELATIONSHIP
|
||||
|
||||
CREATE TABLE relationship
|
||||
(
|
||||
relationship_id INTEGER NOT NULL,
|
||||
relationship_name VARCHAR2(256 BYTE) NOT NULL,
|
||||
is_hierarchical INTEGER NOT NULL,
|
||||
defines_ancestry INTEGER DEFAULT 1 NOT NULL,
|
||||
reverse_relationship INTEGER
|
||||
) NOLOGGING;
|
||||
|
||||
COMMENT ON TABLE relationship IS 'A list of relationship between concepts. Some of these relationships are generic (e.g. "Subsumes" relationship), others are domain-specific.';
|
||||
|
||||
COMMENT ON COLUMN relationship.relationship_id IS 'The type of relationship captured by the relationship record.';
|
||||
|
||||
COMMENT ON COLUMN relationship.relationship_name IS 'The text that describes the relationship type.';
|
||||
|
||||
COMMENT ON COLUMN relationship.is_hierarchical IS 'Defines whether a relationship defines concepts into classes or hierarchies. Values are Y for hierarchical relationship or NULL if not';
|
||||
|
||||
COMMENT ON COLUMN relationship.defines_ancestry IS 'Defines whether a hierarchical relationship contributes to the concept_ancestor table. These are subsets of the hierarchical relationships. Valid values are Y or NULL.';
|
||||
|
||||
COMMENT ON COLUMN relationship.reverse_relationship IS 'relationship ID of the reverse relationship to this one. Corresponding records of reverse relationships have their concept_id_1 and concept_id_2 swapped.';
|
||||
|
||||
CREATE UNIQUE INDEX XPKRELATIONHIP_TYPE ON relationship
|
||||
(relationship_id);
|
||||
|
||||
ALTER TABLE relationship ADD (
|
||||
CONSTRAINT xpkrelationship_type
|
||||
PRIMARY KEY
|
||||
(relationship_id)
|
||||
USING INDEX xpkrelationship_type
|
||||
ENABLE VALIDATE);
|
||||
|
||||
--add table concept_relationship
|
||||
|
||||
CREATE TABLE concept_relationship
|
||||
(
|
||||
concept_id_1 INTEGER NOT NULL,
|
||||
concept_id_2 INTEGER NOT NULL,
|
||||
relationship_id INTEGER NOT NULL,
|
||||
valid_start_date DATE NOT NULL,
|
||||
valid_end_date DATE DEFAULT '31-Dec-2099' NOT NULL,
|
||||
invalid_reason CHAR(1 BYTE)
|
||||
) NOLOGGING;
|
||||
|
||||
COMMENT ON TABLE concept_relationship IS 'A list of relationship between concepts. Some of these relationships are generic (e.g. ''Subsumes'' relationship), others are domain-specific.';
|
||||
|
||||
COMMENT ON COLUMN concept_relationship.concept_id_1 IS 'A foreign key to the concept in the concept table associated with the relationship. relationships are directional, and this field represents the source concept designation.';
|
||||
|
||||
COMMENT ON COLUMN concept_relationship.concept_id_2 IS 'A foreign key to the concept in the concept table associated with the relationship. relationships are directional, and this field represents the destination concept designation.';
|
||||
|
||||
COMMENT ON COLUMN concept_relationship.relationship_id IS 'The type of relationship as defined in the relationship table.';
|
||||
|
||||
COMMENT ON COLUMN concept_relationship.valid_start_date IS 'The date when the the relationship was first recorded.';
|
||||
|
||||
COMMENT ON COLUMN concept_relationship.valid_end_date IS 'The date when the relationship became invalid because it was deleted or superseded (updated) by a new relationship. Default value is 31-Dec-2099.';
|
||||
|
||||
COMMENT ON COLUMN concept_relationship.invalid_reason IS 'Reason the relationship was invalidated. Possible values are D (deleted), U (replaced with an update) or NULL when valid_end_date has the default value.';
|
||||
|
||||
CREATE UNIQUE INDEX xpkconcept_relationship ON concept_relationship
|
||||
(concept_id_1, concept_id_2, relationship_id);
|
||||
|
||||
|
||||
ALTER TABLE concept_relationship ADD (
|
||||
CHECK ( invalid_reason IN ('D', 'U'))
|
||||
ENABLE VALIDATE,
|
||||
CHECK ( invalid_reason IN ('D', 'U'))
|
||||
ENABLE VALIDATE,
|
||||
CHECK (invalid_reason in ('D', 'U'))
|
||||
ENABLE VALIDATE,
|
||||
CONSTRAINT xpkconcept_relationship
|
||||
PRIMARY KEY
|
||||
(concept_id_1, concept_id_2, relationship_id)
|
||||
USING INDEX xpkconcept_relationship
|
||||
ENABLE VALIDATE);
|
||||
|
||||
|
||||
ALTER TABLE concept_relationship ADD (
|
||||
CONSTRAINT concept_REL_CHILD_FK
|
||||
FOREIGN KEY (concept_id_2)
|
||||
REFERENCES concept (concept_id)
|
||||
ENABLE VALIDATE,
|
||||
CONSTRAINT concept_REL_PARENT_FK
|
||||
FOREIGN KEY (concept_id_1)
|
||||
REFERENCES concept (concept_id)
|
||||
ENABLE VALIDATE,
|
||||
CONSTRAINT concept_REL_REL_type_FK
|
||||
FOREIGN KEY (relationship_id)
|
||||
REFERENCES relationship (relationship_id)
|
||||
ENABLE VALIDATE);
|
||||
|
||||
--add table concept_ancestor
|
||||
|
||||
CREATE TABLE concept_ancestor
|
||||
(
|
||||
ancestor_concept_id INTEGER NOT NULL,
|
||||
descendant_concept_id INTEGER NOT NULL,
|
||||
max_levels_of_separation NUMBER,
|
||||
min_levels_of_separation NUMBER
|
||||
) NOLOGGING;
|
||||
|
||||
COMMENT ON TABLE concept_ancestor IS 'A specialized table containing only hierarchical relationship between concepts that may span several generations.';
|
||||
|
||||
COMMENT ON COLUMN concept_ancestor.ancestor_concept_id IS 'A foreign key to the concept code in the concept table for the higher-level concept that forms the ancestor in the relationship.';
|
||||
|
||||
COMMENT ON COLUMN concept_ancestor.descendant_concept_id IS 'A foreign key to the concept code in the concept table for the lower-level concept that forms the descendant in the relationship.';
|
||||
|
||||
COMMENT ON COLUMN concept_ancestor.max_levels_of_separation IS 'The maximum separation in number of levels of hierarchy between ancestor and descendant concepts. This is an optional attribute that is used to simplify hierarchic analysis. ';
|
||||
|
||||
COMMENT ON COLUMN concept_ancestor.min_levels_of_separation IS 'The minimum separation in number of levels of hierarchy between ancestor and descendant concepts. This is an optional attribute that is used to simplify hierarchic analysis.';
|
||||
|
||||
CREATE UNIQUE INDEX xpkconcept_ancestor ON concept_ancestor
|
||||
(ancestor_concept_id, descendant_concept_id);
|
||||
|
||||
ALTER TABLE concept_ancestor ADD (
|
||||
CONSTRAINT xpkconcept_ancestor
|
||||
PRIMARY KEY
|
||||
(ancestor_concept_id, descendant_concept_id)
|
||||
USING INDEX xpkconcept_ancestor
|
||||
ENABLE VALIDATE);
|
||||
|
||||
ALTER TABLE concept_ancestor ADD (
|
||||
CONSTRAINT concept_ancestor_FK
|
||||
FOREIGN KEY (ancestor_concept_id)
|
||||
REFERENCES concept (concept_id)
|
||||
ENABLE VALIDATE,
|
||||
CONSTRAINT concept_descendant_FK
|
||||
FOREIGN KEY (descendant_concept_id)
|
||||
REFERENCES concept (concept_id)
|
||||
ENABLE VALIDATE);
|
||||
|
||||
--add table concept_synonym
|
||||
|
||||
CREATE TABLE concept_synonym
|
||||
(
|
||||
concept_synonym_id INTEGER NOT NULL,
|
||||
concept_id INTEGER NOT NULL,
|
||||
concept_synonym_name VARCHAR2(1000 BYTE) NOT NULL
|
||||
) NOLOGGING;
|
||||
|
||||
COMMENT ON TABLE concept_synonym IS 'A table with synonyms for concepts that have more than one valid name or description.';
|
||||
|
||||
COMMENT ON COLUMN concept_synonym.concept_synonym_id IS 'A system-generated unique identifier for each concept synonym.';
|
||||
|
||||
COMMENT ON COLUMN concept_synonym.concept_id IS 'A foreign key to the concept in the concept table. ';
|
||||
|
||||
COMMENT ON COLUMN concept_synonym.concept_synonym_name IS 'The alternative name for the concept.';
|
||||
|
||||
CREATE UNIQUE INDEX xpkconcept_synonym ON concept_synonym
|
||||
(concept_synonym_id);
|
||||
|
||||
ALTER TABLE concept_synonym ADD (
|
||||
CONSTRAINT xpkconcept_synonym
|
||||
PRIMARY KEY
|
||||
(concept_synonym_id)
|
||||
USING INDEX xpkconcept_synonym
|
||||
ENABLE VALIDATE);
|
||||
|
||||
ALTER TABLE concept_synonym ADD (
|
||||
CONSTRAINT concept_synonym_concept_FK
|
||||
FOREIGN KEY (concept_id)
|
||||
REFERENCES concept (concept_id)
|
||||
ENABLE VALIDATE);
|
||||
|
||||
--add table source_to_concept_map
|
||||
|
||||
CREATE TABLE source_to_concept_map
|
||||
(
|
||||
source_code VARCHAR2(40 BYTE) NOT NULL,
|
||||
source_vocabulary_id INTEGER NOT NULL,
|
||||
source_code_description VARCHAR2(256 BYTE),
|
||||
target_concept_id INTEGER NOT NULL,
|
||||
target_vocabulary_id INTEGER NOT NULL,
|
||||
mapping_type VARCHAR2(256 BYTE),
|
||||
primary_map CHAR(1 BYTE),
|
||||
valid_start_date DATE NOT NULL,
|
||||
valid_end_date DATE NOT NULL,
|
||||
invalid_reason CHAR(1 BYTE)
|
||||
) NOLOGGING;
|
||||
|
||||
CREATE INDEX SOURCE_TO_concept_SOURCE_idX ON source_to_concept_map
|
||||
(SOURCE_CODE);
|
||||
|
||||
CREATE UNIQUE INDEX xpksource_to_concept_map ON source_to_concept_map
|
||||
(SOURCE_vocabulary_id, TARGET_concept_id, SOURCE_CODE, valid_end_date);
|
||||
|
||||
ALTER TABLE source_to_concept_map ADD (
|
||||
CHECK (primary_map in ('Y'))
|
||||
ENABLE VALIDATE,
|
||||
CHECK (invalid_reason in ('D', 'U'))
|
||||
ENABLE VALIDATE,
|
||||
CONSTRAINT xpksource_to_concept_map
|
||||
PRIMARY KEY
|
||||
(SOURCE_vocabulary_id, TARGET_concept_id, SOURCE_CODE, valid_end_date)
|
||||
USING INDEX xpksource_to_concept_map
|
||||
ENABLE VALIDATE);
|
||||
|
||||
ALTER TABLE source_to_concept_map ADD (
|
||||
CONSTRAINT SOURCE_TO_concept_concept
|
||||
FOREIGN KEY (TARGET_concept_id)
|
||||
REFERENCES concept (concept_id)
|
||||
ENABLE VALIDATE);
|
||||
|
||||
--add table drug_strength
|
||||
|
||||
CREATE TABLE drug_strength
|
||||
(
|
||||
drug_concept_id INTEGER NOT NULL,
|
||||
ingredient_concept_id INTEGER NOT NULL,
|
||||
amount_value NUMBER,
|
||||
amount_unit VARCHAR2 (60 BYTE),
|
||||
concentration_value NUMBER,
|
||||
concentration_enum_unit VARCHAR2 (60 BYTE),
|
||||
concentration_denom_unit VARCHAR2 (60 BYTE),
|
||||
valid_start_date DATE NOT NULL,
|
||||
valid_end_date DATE NOT NULL,
|
||||
invalid_reason VARCHAR2 (1 BYTE)
|
||||
);
|
||||
|
||||
--add table vocabulary
|
||||
|
||||
CREATE TABLE VOCABULARY
|
||||
(
|
||||
VOCABULARY_ID INTEGER NOT NULL,
|
||||
VOCABULARY_NAME VARCHAR2 (256 BYTE) NOT NULL
|
||||
);
|
||||
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
Common-Data-Model / Oracle
|
||||
=================
|
||||
|
||||
This folder contains the SQL scripts for Oracle.
|
||||
|
||||
In order to create your instantiation of the Common Data Model, we recommend following these steps:
|
||||
|
||||
1. Create an empty schema.
|
||||
|
||||
2. Execute the script `CDM V4 ddl.sql` to create the tables and fields.
|
||||
|
||||
3. Load your data into the schema using the loading scripts in VocabImport
|
||||
|
||||
Note: you could also apply the constraints and the indexes after loading the data, this will speed up the insertion of the data considerably.
|
|
@ -1,51 +0,0 @@
|
|||
/*********************************************************************************
|
||||
# Copyright 2015 Observational Health Data Sciences and Informatics
|
||||
#
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.4
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # ## #######
|
||||
# # ## ## # # # # # # # # ## ## # # # # #
|
||||
# # # # # # # # # # # # # # # # # # # # # #
|
||||
# # # # # # # ###### # # # # # # # # ####### #######
|
||||
# # # # # # # # # # # # # # # #
|
||||
# # # # # # # # # # # # # # # # # #
|
||||
####### # # ####### # ##### ###### # # ## # # #####
|
||||
|
||||
|
||||
script to load the Vocabulary related tables in the OMOP common data model, version 4.5 for Oracle database
|
||||
|
||||
last revised: 19 Mar 2015
|
||||
|
||||
author: Lee Evans
|
||||
|
||||
Notes
|
||||
|
||||
1) This script assumes the CDM version 4.5 vocabulary zip file has been unzipped into the "C:\CDM" directory.
|
||||
2) If you unzipped your CDM version 4.5 vocabulary files into a different directory then replace all file paths below, with your directory path.
|
||||
3) If you have existing data in your CDM vocabulary tables then backup that data (if needed) and truncate those tables before loading
|
||||
|
||||
|
||||
*************************/
|
||||
|
||||
sqlldr CDM/<password> CONTROL=CONCEPT.ctl LOG=C:\CDM\CONCEPT.log BAD=C:\CDM\CONCEPT.bad
|
||||
sqlldr CDM/<password> CONTROL=CONCEPT_ANCESTOR.ctl LOG=C:\CDM\CONCEPT_ANCESTOR.log BAD=C:\CDM\CONCEPT_ANCESTOR.bad
|
||||
sqlldr CDM/<password> CONTROL=CONCEPT_RELATIONSHIP.ctl LOG=C:\CDM\CONCEPT_RELATIONSHIP.log BAD=C:\CDM\CONCEPT_RELATIONSHIP.bad
|
||||
sqlldr CDM/<password> CONTROL=CONCEPT_SYNONYM.ctl LOG=C:\CDM\CONCEPT_SYNONYM.log BAD=C:\CDM\CONCEPT_SYNONYM.bad
|
||||
sqlldr CDM/<password> CONTROL=DRUG_STRENGTH.ctl LOG=C:\CDM\DRUG_STRENGTH.log BAD=C:\CDM\DRUG_STRENGTH.bad
|
||||
sqlldr CDM/<password> CONTROL=RELATIONSHIP.ctl LOG=C:\CDM\RELATIONSHIP.log BAD=C:\CDM\RELATIONSHIP.bad
|
||||
sqlldr CDM/<password> CONTROL=VOCABULARY.ctl LOG=C:\CDM\VOCABULARY.log BAD=C:\CDM\VOCABULARY.bad
|
||||
sqlldr CDM/<password> CONTROL=SOURCE_TO_CONCEPT_MAP.ctl LOG=C:\CDM\SOURCE_TO_CONCEPT_MAP.log BAD=C:\CDM\SOURCE_TO_CONCEPT_MAP.bad
|
|
@ -1,18 +0,0 @@
|
|||
options (skip=1)
|
||||
load data
|
||||
infile concept.csv
|
||||
into table concept
|
||||
replace
|
||||
fields terminated by '\t'
|
||||
trailing nullcols
|
||||
(
|
||||
concept_id,
|
||||
concept_name CHAR(256),
|
||||
concept_level,
|
||||
concept_class,
|
||||
vocabulary_id,
|
||||
concept_code,
|
||||
valid_start_date DATE 'YYYYMMDD',
|
||||
valid_end_date DATE 'YYYYMMDD',
|
||||
invalid_reason
|
||||
)
|
|
@ -1,13 +0,0 @@
|
|||
options (skip=1)
|
||||
load data
|
||||
infile concept_ancestor.csv
|
||||
into table concept_ancestor
|
||||
replace
|
||||
fields terminated by '\t'
|
||||
trailing nullcols
|
||||
(
|
||||
ancestor_concept_id,
|
||||
descendant_concept_id,
|
||||
min_levels_of_separation,
|
||||
max_levels_of_separation
|
||||
)
|
|
@ -1,15 +0,0 @@
|
|||
options (skip=1)
|
||||
load data
|
||||
infile concept_relationship.csv
|
||||
into table concept_relationship
|
||||
replace
|
||||
fields terminated by '\t'
|
||||
trailing nullcols
|
||||
(
|
||||
concept_id_1,
|
||||
concept_id_2,
|
||||
relationship_id,
|
||||
valid_start_date DATE 'YYYYMMDD',
|
||||
valid_end_date DATE 'YYYYMMDD',
|
||||
invalid_reason
|
||||
)
|
|
@ -1,12 +0,0 @@
|
|||
options (skip=1)
|
||||
load data
|
||||
infile concept_synonym.csv
|
||||
into table concept_synonym
|
||||
replace
|
||||
fields terminated by '\t'
|
||||
trailing nullcols
|
||||
(
|
||||
concept_synonym_id,
|
||||
concept_id,
|
||||
concept_synonym_name CHAR(1000)
|
||||
)
|
|
@ -1,19 +0,0 @@
|
|||
options (skip=1)
|
||||
load data
|
||||
infile drug_strength.csv
|
||||
into table drug_strength
|
||||
replace
|
||||
fields terminated by '\t'
|
||||
trailing nullcols
|
||||
(
|
||||
drug_concept_id,
|
||||
ingredient_concept_id,
|
||||
amount_value,
|
||||
amount_unit,
|
||||
concentration_value,
|
||||
concentration_enum_unit,
|
||||
concentration_denom_unit,
|
||||
valid_start_date DATE 'YYYYMMDD',
|
||||
valid_end_date DATE 'YYYYMMDD',
|
||||
invalid_reason
|
||||
)
|
|
@ -1,14 +0,0 @@
|
|||
options (skip=1)
|
||||
load data
|
||||
infile relationship.csv
|
||||
into table relationship
|
||||
replace
|
||||
fields terminated by '\t'
|
||||
trailing nullcols
|
||||
(
|
||||
relationship_id,
|
||||
relationship_name,
|
||||
is_hierarchical,
|
||||
defines_ancestry,
|
||||
reverse_relationship
|
||||
)
|
|
@ -1,19 +0,0 @@
|
|||
options (skip=1)
|
||||
load data
|
||||
infile source_to_concept_map.csv
|
||||
into table source_to_concept_map
|
||||
replace
|
||||
fields terminated by '\t'
|
||||
trailing nullcols
|
||||
(
|
||||
source_code,
|
||||
source_vocabulary_id,
|
||||
source_code_description CHAR(256),
|
||||
target_concept_id,
|
||||
target_vocabulary_id,
|
||||
mapping_type,
|
||||
primary_map,
|
||||
valid_start_date DATE 'YYYYMMDD',
|
||||
valid_end_date DATE 'YYYYMMDD',
|
||||
invalid_reason
|
||||
)
|
|
@ -1,11 +0,0 @@
|
|||
options (skip=1)
|
||||
load data
|
||||
infile vocabulary.csv
|
||||
into table vocabulary
|
||||
replace
|
||||
fields terminated by '\t'
|
||||
trailing nullcols
|
||||
(
|
||||
vocabulary_id,
|
||||
vocabulary_name
|
||||
)
|
|
@ -1,131 +0,0 @@
|
|||
|
||||
/*********************************************************************************
|
||||
# Copyright 2015 Observational Health Data Sciences and Informatics
|
||||
#
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.4
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # ## #######
|
||||
# # ## ## # # # # # # # # ## ## # # # # #
|
||||
# # # # # # # # # # # # # # # # # # # # # #
|
||||
# # # # # # # ###### # # # # # # # # ####### #######
|
||||
# # # # # # # # # # # # # # # #
|
||||
# # # # # # # # # # # # # # # # # #
|
||||
####### # # ####### # ##### ###### # # ## # # #####
|
||||
|
||||
|
||||
script to create OMOP common data model, version 4.5 for PostgreSQL database
|
||||
|
||||
last revised: 20 Mar 2015
|
||||
|
||||
author: Lee Evans
|
||||
|
||||
|
||||
*************************/
|
||||
|
||||
CREATE TABLE concept (
|
||||
concept_id integer NOT NULL,
|
||||
concept_name varchar(256) NOT NULL,
|
||||
concept_level integer NOT NULL,
|
||||
concept_class varchar(60) NOT NULL,
|
||||
vocabulary_id integer NOT NULL,
|
||||
concept_code varchar(40) NOT NULL,
|
||||
valid_start_date date NOT NULL,
|
||||
valid_end_date date NOT NULL DEFAULT '2099-12-31'::date,
|
||||
invalid_reason varchar(1)
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
CREATE TABLE concept_ancestor (
|
||||
ancestor_concept_id INTEGER NOT NULL,
|
||||
descendant_concept_id INTEGER NOT NULL,
|
||||
min_levels_of_separation INTEGER NOT NULL,
|
||||
max_levels_of_separation INTEGER NOT NULL
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
CREATE TABLE concept_relationship (
|
||||
concept_id_1 integer NOT NULL,
|
||||
concept_id_2 integer NOT NULL,
|
||||
relationship_id integer NOT NULL,
|
||||
valid_start_date date NOT NULL,
|
||||
valid_end_date date NOT NULL DEFAULT '2099-12-31'::date,
|
||||
invalid_reason varchar(1)
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
CREATE TABLE concept_synonym (
|
||||
concept_synonym_id integer NOT NULL,
|
||||
concept_id integer NOT NULL,
|
||||
concept_synonym_name varchar(1000) NOT NULL
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
|
||||
CREATE TABLE drug_strength (
|
||||
drug_concept_id integer NOT NULL,
|
||||
ingredient_concept_id integer NOT NULL,
|
||||
amount_value double precision,
|
||||
amount_unit varchar(60),
|
||||
concentration_value double precision,
|
||||
concentration_enum_unit character varying(60),
|
||||
concentration_denom_unit character varying(60),
|
||||
valid_start_date date NOT NULL,
|
||||
valid_end_date date NOT NULL,
|
||||
invalid_reason varchar(1)
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
CREATE TABLE relationship (
|
||||
relationship_id VARCHAR(20) NOT NULL,
|
||||
relationship_name VARCHAR(256) NOT NULL,
|
||||
is_hierarchical integer NOT NULL,
|
||||
defines_ancestry integer DEFAULT 1,
|
||||
reverse_relationship integer
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
|
||||
CREATE TABLE source_to_concept_map (
|
||||
source_code VARCHAR(40) NOT NULL,
|
||||
source_vocabulary_id INTEGER NOT NULL,
|
||||
source_code_description VARCHAR(256),
|
||||
target_concept_id INTEGER NOT NULL,
|
||||
target_vocabulary_id INTEGER NOT NULL,
|
||||
mapping_type VARCHAR(256),
|
||||
primary_map VARCHAR(1),
|
||||
valid_start_date DATE NOT NULL,
|
||||
valid_end_date DATE NOT NULL,
|
||||
invalid_reason VARCHAR(1) NULL
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
CREATE TABLE vocabulary (
|
||||
vocabulary_id integer NOT NULL,
|
||||
vocabulary_name VARCHAR(256) NOT NULL
|
||||
)
|
||||
;
|
|
@ -1,13 +0,0 @@
|
|||
Common-Data-Model / PostgreSQL
|
||||
=================
|
||||
|
||||
This folder contains the SQL scripts for PostgreSQL.
|
||||
|
||||
In order to create your instantiation of the Common Data Model, we recommend following these steps:
|
||||
|
||||
1. Create an empty schema.
|
||||
|
||||
2. Execute the script `CDM V4 ddl.sql` to create the tables and fields.
|
||||
|
||||
3. Load your data into the schema.
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
/*********************************************************************************
|
||||
# Copyright 2015 Observational Health Data Sciences and Informatics
|
||||
#
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # #######
|
||||
# # ## ## # # # # # # # # ## ## # # #
|
||||
# # # # # # # # # # # # # # # # # # # #
|
||||
# # # # # # # ###### # # # # # # # # ######
|
||||
# # # # # # # # # # # # # # #
|
||||
# # # # # # # # # # # # # # # # #
|
||||
####### # # ####### # ##### ###### # # ## #####
|
||||
|
||||
|
||||
Script to load the common data model, version 4.5 vocabulary tables for PostgreSQL database
|
||||
|
||||
Notes
|
||||
|
||||
1) This script assumes the CDM version 4.5 vocabulary zip file has been unzipped into the "C:\CDM" directory.
|
||||
2) If you unzipped your CDM version 4.5 vocabulary files into a different directory then replace all file paths below, with your directory path.
|
||||
3) Run this SQL query script in the database where you created your CDM Version 4.5 tables
|
||||
|
||||
last revised: 20th March 2015
|
||||
|
||||
author: Lee Evans
|
||||
|
||||
|
||||
*************************/
|
||||
|
||||
COPY CONCEPT FROM 'C:\CDM\CONCEPT.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ;
|
||||
COPY CONCEPT_ANCESTOR FROM 'C:\CDM\CONCEPT_ANCESTOR.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ;
|
||||
COPY CONCEPT_RELATIONSHIP FROM 'C:\CDM\CONCEPT_RELATIONSHIP.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ;
|
||||
COPY CONCEPT_SYNONYM FROM 'C:\CDM\CONCEPT_SYNONYM.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ;
|
||||
COPY DRUG_STRENGTH FROM 'C:\CDM\DRUG_STRENGTH.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ;
|
||||
COPY RELATIONSHIP FROM 'C:\CDM\RELATIONSHIP.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ;
|
||||
COPY SOURCE_TO_CONCEPT_MAP FROM 'C:\CDM\SOURCE_TO_CONCEPT_MAP.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ;
|
||||
COPY VOCABULARY FROM 'C:\CDM\VOCABULARY.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ;
|
||||
|
||||
|
||||
|
|
@ -1,117 +0,0 @@
|
|||
/*********************************************************************************
|
||||
# Copyright 2015 Observational Health Data Sciences and Informatics
|
||||
#
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.4
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # ## #######
|
||||
# # ## ## # # # # # # # # ## ## # # # # #
|
||||
# # # # # # # # # # # # # # # # # # # # # #
|
||||
# # # # # # # ###### # # # # # # # # ####### #######
|
||||
# # # # # # # # # # # # # # # #
|
||||
# # # # # # # # # # # # # # # # # #
|
||||
####### # # ####### # ##### ###### # # ## # # #####
|
||||
|
||||
|
||||
script to create OMOP common data model, version 4.5 for Sql Server database
|
||||
|
||||
last revised: 20 Mar 2015
|
||||
|
||||
author: Lee Evans
|
||||
|
||||
|
||||
*************************/
|
||||
|
||||
|
||||
CREATE TABLE CONCEPT(
|
||||
CONCEPT_ID int NOT NULL,
|
||||
CONCEPT_NAME varchar(256) NOT NULL,
|
||||
CONCEPT_LEVEL int NOT NULL,
|
||||
CONCEPT_CLASS varchar(60) NOT NULL,
|
||||
VOCABULARY_ID int NOT NULL,
|
||||
CONCEPT_CODE varchar(40) NOT NULL,
|
||||
VALID_START_DATE date NOT NULL,
|
||||
VALID_END_DATE date NOT NULL DEFAULT ('31-Dec-2099'),
|
||||
INVALID_REASON char(1) NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE CONCEPT_ANCESTOR(
|
||||
ANCESTOR_CONCEPT_ID int NOT NULL,
|
||||
DESCENDANT_CONCEPT_ID int NOT NULL,
|
||||
MAX_LEVELS_OF_SEPARATION int NULL,
|
||||
MIN_LEVELS_OF_SEPARATION int NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE CONCEPT_RELATIONSHIP(
|
||||
CONCEPT_ID_1 int NOT NULL,
|
||||
CONCEPT_ID_2 int NOT NULL,
|
||||
RELATIONSHIP_ID int NOT NULL,
|
||||
VALID_START_DATE date NOT NULL,
|
||||
VALID_END_DATE date NOT NULL DEFAULT ('31-Dec-2099'),
|
||||
INVALID_REASON char(1) NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE CONCEPT_SYNONYM(
|
||||
CONCEPT_SYNONYM_ID int NOT NULL,
|
||||
CONCEPT_ID int NOT NULL,
|
||||
CONCEPT_SYNONYM_NAME varchar(1000) NOT NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE DRUG_STRENGTH(
|
||||
DRUG_CONCEPT_ID int NOT NULL,
|
||||
INGREDIENT_CONCEPT_ID int NOT NULL,
|
||||
AMOUNT_VALUE float NULL,
|
||||
AMOUNT_UNIT varchar(60) NULL,
|
||||
CONCENTRATION_VALUE float NULL,
|
||||
CONCENTRATION_ENUM_UNIT varchar(60) NULL,
|
||||
CONCENTRATION_DENOM_UNIT varchar(60) NULL,
|
||||
VALID_START_DATE date NOT NULL,
|
||||
VALID_END_DATE date NOT NULL,
|
||||
INVALID_REASON varchar(1) NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE RELATIONSHIP(
|
||||
RELATIONSHIP_ID int NOT NULL,
|
||||
RELATIONSHIP_NAME varchar(256) NOT NULL,
|
||||
IS_HIERARCHICAL int NOT NULL,
|
||||
DEFINES_ANCESTRY int NOT NULL DEFAULT ((1)),
|
||||
REVERSE_RELATIONSHIP int NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE SOURCE_TO_CONCEPT_MAP(
|
||||
SOURCE_CODE varchar(40) NOT NULL,
|
||||
SOURCE_VOCABULARY_ID int NOT NULL,
|
||||
SOURCE_CODE_DESCRIPTION varchar(256) NULL,
|
||||
TARGET_CONCEPT_ID int NOT NULL,
|
||||
TARGET_VOCABULARY_ID int NOT NULL,
|
||||
MAPPING_TYPE varchar(256) NULL,
|
||||
PRIMARY_MAP char(1) NULL,
|
||||
VALID_START_DATE date NOT NULL,
|
||||
VALID_END_DATE date NOT NULL DEFAULT ('31-Dec-2099'),
|
||||
INVALID_REASON char(1) NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE VOCABULARY(
|
||||
VOCABULARY_ID int NOT NULL,
|
||||
VOCABULARY_NAME varchar(256) NOT NULL
|
||||
);
|
|
@ -1,14 +0,0 @@
|
|||
Common-Data-Model / SQL Server
|
||||
=================
|
||||
|
||||
This folder contains the SQL scripts for SQL Server.
|
||||
|
||||
In order to create your instantiation of the Common Data Model, we recommend following these steps:
|
||||
|
||||
1. Create an empty schema.
|
||||
|
||||
2. Execute the script `CDM V4 ddl.sql` to create the tables and fields.
|
||||
|
||||
3. Load your data into the schema using the loading scripts in VocabImport
|
||||
|
||||
Note: you could also apply the constraints and the indexes after loading the data, this will speed up the insertion of the data considerably.
|
|
@ -1,130 +0,0 @@
|
|||
/*********************************************************************************
|
||||
# Copyright 2015 Observational Health Data Sciences and Informatics
|
||||
#
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # #######
|
||||
# # ## ## # # # # # # # # ## ## # # #
|
||||
# # # # # # # # # # # # # # # # # # # #
|
||||
# # # # # # # ###### # # # # # # # # ######
|
||||
# # # # # # # # # # # # # # #
|
||||
# # # # # # # # # # # # # # # # #
|
||||
####### # # ####### # ##### ###### # # ## #####
|
||||
|
||||
|
||||
Script to load the common data model, version 4.5 vocabulary tables for SQL Server database
|
||||
|
||||
Notes
|
||||
|
||||
1) This script assumes the CDM version 4.5 vocabulary zip file has been unzipped into the "C:\CDM" directory.
|
||||
2) If you unzipped your CDM version 4.5 vocabulary files into a different directory then replace all file paths below, with your directory path.
|
||||
3) Run this SQL query script in the database where you created your CDM Version 4.5 tables
|
||||
|
||||
last revised: 20th March 2015
|
||||
|
||||
author: Lee Evans
|
||||
|
||||
|
||||
*************************/
|
||||
|
||||
TRUNCATE TABLE CONCEPT;
|
||||
BULK INSERT CONCEPT
|
||||
FROM 'C:\CDM\CONCEPT.csv'
|
||||
WITH (
|
||||
FIRSTROW = 2,
|
||||
FIELDTERMINATOR = '\t',
|
||||
ROWTERMINATOR = '0x0a',
|
||||
ERRORFILE = 'C:\CDM\CONCEPT.bad',
|
||||
TABLOCK
|
||||
);
|
||||
|
||||
TRUNCATE TABLE CONCEPT_ANCESTOR;
|
||||
BULK INSERT CONCEPT_ANCESTOR
|
||||
FROM 'C:\CDM\CONCEPT_ANCESTOR.csv'
|
||||
WITH (
|
||||
FIRSTROW = 2,
|
||||
FIELDTERMINATOR = '\t',
|
||||
ROWTERMINATOR = '0x0a',
|
||||
ERRORFILE = 'C:\CDM\CONCEPT_ANCESTOR.bad',
|
||||
TABLOCK
|
||||
);
|
||||
|
||||
TRUNCATE TABLE CONCEPT_RELATIONSHIP;
|
||||
BULK INSERT CONCEPT_RELATIONSHIP
|
||||
FROM 'C:\CDM\CONCEPT_RELATIONSHIP.csv'
|
||||
WITH (
|
||||
FIRSTROW = 2,
|
||||
FIELDTERMINATOR = '\t',
|
||||
ROWTERMINATOR = '0x0a',
|
||||
ERRORFILE = 'C:\CDM\CONCEPT_RELATIONSHIP.bad',
|
||||
TABLOCK
|
||||
);
|
||||
|
||||
TRUNCATE TABLE CONCEPT_SYNONYM;
|
||||
BULK INSERT CONCEPT_SYNONYM
|
||||
FROM 'C:\CDM\CONCEPT_SYNONYM.csv'
|
||||
WITH (
|
||||
FIRSTROW = 2,
|
||||
FIELDTERMINATOR = '\t',
|
||||
ROWTERMINATOR = '0x0a',
|
||||
ERRORFILE = 'C:\CDM\CONCEPT_SYNONYM.bad',
|
||||
TABLOCK
|
||||
);
|
||||
|
||||
TRUNCATE TABLE DRUG_STRENGTH;
|
||||
BULK INSERT DRUG_STRENGTH
|
||||
FROM 'C:\CDM\DRUG_STRENGTH.csv'
|
||||
WITH (
|
||||
FIRSTROW = 2,
|
||||
FIELDTERMINATOR = '\t',
|
||||
ROWTERMINATOR = '0x0a',
|
||||
ERRORFILE = 'C:\CDM\DRUG_STRENGTH.bad',
|
||||
TABLOCK
|
||||
);
|
||||
|
||||
TRUNCATE TABLE RELATIONSHIP;
|
||||
BULK INSERT RELATIONSHIP
|
||||
FROM 'C:\CDM\RELATIONSHIP.csv'
|
||||
WITH (
|
||||
FIRSTROW = 2,
|
||||
FIELDTERMINATOR = '\t',
|
||||
ROWTERMINATOR = '0x0a',
|
||||
ERRORFILE = 'C:\CDM\RELATIONSHIP.bad',
|
||||
TABLOCK
|
||||
);
|
||||
|
||||
TRUNCATE TABLE SOURCE_TO_CONCEPT_MAP;
|
||||
BULK INSERT SOURCE_TO_CONCEPT_MAP
|
||||
FROM 'C:\CDM\SOURCE_TO_CONCEPT_MAP.csv'
|
||||
WITH (
|
||||
FIRSTROW = 2,
|
||||
FIELDTERMINATOR = '\t',
|
||||
ROWTERMINATOR = '0x0a',
|
||||
ERRORFILE = 'C:\CDM\SOURCE_TO_CONCEPT_MAP.bad',
|
||||
TABLOCK
|
||||
);
|
||||
|
||||
TRUNCATE TABLE VOCABULARY;
|
||||
BULK INSERT VOCABULARY
|
||||
FROM 'C:\CDM\VOCABULARY.csv'
|
||||
WITH (
|
||||
FIRSTROW = 2,
|
||||
FIELDTERMINATOR = '\t',
|
||||
ROWTERMINATOR = '0x0a',
|
||||
ERRORFILE = 'C:\CDM\VOCABULARY.bad',
|
||||
TABLOCK
|
||||
);
|
Loading…
Reference in New Issue