├── requirements.txt ├── Vagrantfile ├── provisioning ├── import_scripts │ ├── expected_row_counts.txt │ ├── validate_load.sh │ ├── load_data.sh │ ├── download_mimic.sh │ ├── extract_mimic.sh │ ├── add_indexes.sql │ └── create_tables.sql └── mimic.yml ├── .gitignore ├── README.md └── LICENSE /requirements.txt: -------------------------------------------------------------------------------- 1 | ansible==1.9.3 2 | ecdsa==0.13 3 | Jinja2==2.8 4 | MarkupSafe==0.23 5 | paramiko==1.15.2 6 | passlib==1.6.5 7 | powerline-status==2.2 8 | psycopg2==2.6.1 9 | pycrypto==2.2 10 | PyYAML==3.11 11 | six==1.9.0 12 | wheel==0.24.0 13 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | VAGRANTFILE_API_VERSION = "2" 5 | 6 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 7 | 8 | config.vm.box = "nshaas/ubuntu-14.04-large" 9 | 10 | config.vm.network "forwarded_port", guest: 5432, host: 2345 11 | 12 | config.vm.network "private_network", ip: "192.168.34.44" 13 | 14 | config.vm.provision :ansible do |ansible| 15 | 16 | ansible.playbook = "provisioning/mimic.yml" 17 | 18 | end 19 | 20 | end 21 | -------------------------------------------------------------------------------- /provisioning/import_scripts/expected_row_counts.txt: -------------------------------------------------------------------------------- 1 | 58976 ADMISSIONS 2 | 34499 CALLOUT 3 | 7567 CAREGIVERS 4 | 263201375 CHARTEVENTS 5 | 573146 CPTEVENTS 6 | 4486049 DATETIMEEVENTS 7 | 134 D_CPT 8 | 651047 DIAGNOSES_ICD 9 | 14567 D_ICD_DIAGNOSES 10 | 3882 D_ICD_PROCEDURES 11 | 12478 D_ITEMS 12 | 755 D_LABITEMS 13 | 125557 DRGCODES 14 | 61532 ICUSTAYS 15 | 17528894 INPUTEVENTS_CV 16 | 3618991 INPUTEVENTS_MV 17 | 27872575 LABEVENTS 18 | 328446 MICROBIOLOGYEVENTS 19 | 4349339 OUTPUTEVENTS 20 | 46520 PATIENTS 21 | 4156848 PRESCRIPTIONS 22 | 258066 PROCEDUREEVENTS_MV 23 | 240095 PROCEDURES_ICD 24 | 73343 SERVICES 25 | 261897 TRANSFERS 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | /.config 4 | /coverage/ 5 | /InstalledFiles 6 | /pkg/ 7 | /spec/reports/ 8 | /test/tmp/ 9 | /test/version_tmp/ 10 | /tmp/ 11 | 12 | ## Specific to RubyMotion: 13 | .dat* 14 | .repl_history 15 | build/ 16 | 17 | ## Documentation cache and generated files: 18 | /.yardoc/ 19 | /_yardoc/ 20 | /doc/ 21 | /rdoc/ 22 | 23 | ## Environment normalisation: 24 | /.bundle/ 25 | /vendor/bundle 26 | /lib/bundler/man/ 27 | 28 | # for a library or gem, you might want to ignore these files since the code is 29 | # intended to run in multiple environments; otherwise, check them in: 30 | # Gemfile.lock 31 | # .ruby-version 32 | # .ruby-gemset 33 | 34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: 35 | .rvmrc 36 | 37 | # Azure 38 | *.pem 39 | *.publishsettings 40 | 41 | # Chef 42 | chef/syntaxcache 43 | 44 | # Vim 45 | *.swo 46 | *.swp 47 | 48 | .vagrant/ 49 | 50 | .idea/ 51 | -------------------------------------------------------------------------------- /provisioning/import_scripts/validate_load.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | LOGFILE=/vagrant/validate_load.log 4 | 5 | DT="$(date)" 6 | echo "Running data validation script $DT" >> $LOGFILE 7 | 8 | ROW_COUNTS=$1 9 | 10 | ERRORS=0 11 | 12 | while read LINE 13 | do 14 | echo "$LINE" 15 | 16 | EXPECTED_ROWS="$(echo "$LINE" | cut -d ' ' -f 1)" 17 | TABLE_NAME=$(echo "$LINE" | cut -d ' ' -f 2) 18 | 19 | # Start log string 20 | LOG="$TABLE_NAME Expecting $EXPECTED_ROWS rows." 21 | 22 | LOADED=$(psql mimic -tc "SELECT COUNT(*) FROM $TABLE_NAME;") 23 | sleep 3 # Prevent too many accesses in sequence 24 | 25 | LOG="$LOG $LOADED found." 26 | 27 | if [ $LOADED -ne $EXPECTED_ROWS ] 28 | then 29 | ERRORS=1 30 | LOG="$LOG ** ERRORS FOUND. **" 31 | fi 32 | 33 | echo "$LOG" >> $LOGFILE 34 | 35 | done < $ROW_COUNTS 36 | 37 | if [ $ERRORS -eq 1 ] 38 | then 39 | DT="$(date)" 40 | echo "Row count(s) incorrect, exiting with non-zero status $DT" >> $LOGFILE 41 | exit 1 42 | fi 43 | 44 | DT="$(date)" 45 | echo "Data validation complete $DT" >> $LOGFILE 46 | 47 | -------------------------------------------------------------------------------- /provisioning/import_scripts/load_data.sh: -------------------------------------------------------------------------------- 1 | LOGFILE=/vagrant/load_data.log 2 | 3 | DT="$(date)" 4 | echo "Running data loader $DT" >> $LOGFILE 5 | 6 | DATA_DIR=$1 7 | 8 | # Load all tables except CHARTEVENTS first, so you can free up space 9 | for F in `find /home/vagrant/src/physionet/mimic-iii/unzipped -maxdepth 1 -type f -not -name '*CHARTEVENTS*' | xargs ls -Sr` 10 | do 11 | # Start creating log string 12 | LOG="$F" 13 | 14 | BASENAME="$(basename $F | sed s/.csv//)" 15 | TABLE_NAME=$BASENAME 16 | 17 | LOG="$LOG Loading $BASENAME.csv into table $TABLE_NAME." 18 | 19 | CMD="copy $TABLE_NAME FROM '$F' DELIMITER ',' CSV HEADER;" 20 | psql mimic -c "$CMD" 2>> $LOGFILE 21 | 22 | echo "$LOG Deleting loaded CSV file." 23 | rm $F 24 | 25 | echo "$LOG" >> $LOGFILE 26 | done 27 | 28 | unset F 29 | 30 | # Load the CHARTEVENTS table 31 | for F in `find /home/vagrant/src/physionet/mimic-iii/unzipped -maxdepth 1 -type f -name '*CHARTEVENTS*' | sort` 32 | do 33 | # Start creating log string 34 | LOG="$F" 35 | 36 | BASENAME="$(basename $F | sed s/.csv//)" 37 | TABLE_NAME="CHARTEVENTS" 38 | 39 | LOG="$LOG Loading $BASENAME.csv into table $TABLE_NAME." 40 | 41 | CMD="copy $TABLE_NAME FROM '$F' DELIMITER ',' CSV HEADER;" 42 | psql mimic -c "$CMD" 2>> $LOGFILE 43 | sleep 5 # Prevent too many accesses in sequence 44 | 45 | echo "$LOG Deleting loaded CSV file." 46 | rm $F 47 | 48 | echo "$LOG" >> $LOGFILE 49 | done 50 | 51 | DT="$(date)" 52 | echo "Data load complete $DT" >> $LOGFILE 53 | -------------------------------------------------------------------------------- /provisioning/import_scripts/download_mimic.sh: -------------------------------------------------------------------------------- 1 | LOGFILE=/vagrant/download_mimic.log 2 | 3 | DT="$(date)" 4 | echo "Running download script $DT" >> $LOGFILE 5 | 6 | for ITEM in ADMISSIONS CALLOUT CAREGIVERS CHARTEVENTS CPTEVENTS DATETIMEEVENTS DIAGNOSES_ICD DRGCODES D_CPT D_ICD_DIAGNOSES D_ICD_PROCEDURES D_ITEMS D_LABITEMS ICUSTAYS INPUTEVENTS_CV INPUTEVENTS_MV LABEVENTS MICROBIOLOGYEVENTS NOTEEVENTS OUTPUTEVENTS PATIENTS PRESCRIPTIONS PROCEDUREEVENTS_MV PROCEDURES_ICD SERVICES TRANSFERS 7 | do 8 | TAR_DIR=/home/vagrant/src/physionet/mimic-iii/tarballs 9 | DEST=$TAR_DIR/$ITEM.csv.gz 10 | BASE_URL=https://physionet.org/works/MIMICIIIClinicalDatabase/files 11 | URL=$BASE_URL/version_1_3/$ITEM.csv.gz 12 | 13 | # Start creating log string 14 | LOG="$DEST" 15 | 16 | # If ITEM exists, get checksum and don't re-download it if checksum is valid 17 | if [ -e $DEST ] 18 | then 19 | CHECKSUM="$(md5sum $DEST | cut -d ' ' -f 1)" 20 | LOG="$LOG File exists, validating its checksum $CHECKSUM." 21 | if ! grep -wq "$CHECKSUM" $TAR_DIR/../zipped_file_checksums.txt 22 | then 23 | LOG="$LOG Checksum not valid, re-downloading." 24 | rm $DEST 25 | wget --user $1 --password $2 --continue --no-check-certificate -O $DEST $URL 26 | else 27 | LOG="$LOG Checksum valid, skipping this download." 28 | fi 29 | else 30 | LOG="$LOG File does not exist, downloading." 31 | wget --user $1 --password $2 --continue --no-check-certificate -O $DEST $URL 32 | fi 33 | 34 | echo "$LOG" >> $LOGFILE 35 | done 36 | 37 | DT="$(date)" 38 | echo "Downloads complete $DT" >> $LOGFILE 39 | -------------------------------------------------------------------------------- /provisioning/import_scripts/extract_mimic.sh: -------------------------------------------------------------------------------- 1 | LOGFILE=/vagrant/extract_mimic.log 2 | 3 | DT="$(date)" 4 | echo "Running extraction script $DT" >> $LOGFILE 5 | 6 | TAR_DIR=$1 7 | UNZIP_DIR=$2 8 | 9 | echo "Removing orphaned CHARTEVENTSxx.csv files" >> $LOGFILE 10 | 11 | # Remove any orphaned split-files from the large CHARTEVENTS.csv. This will 12 | # allow creating new clean splits of CHARTEVENTS.csv when that is extracted. 13 | find $UNZIP_DIR -maxdepth 1 -type f -regextype sed -regex '.*/CHARTEVENTS[0-9]\{2\}.*' -exec rm -f {} \; 14 | find /home/vagrant -maxdepth 1 -type f -regextype sed -regex '.*/CHARTEVENTS[0-9]\{2\}.*' -exec rm -f {} \; 15 | 16 | echo "Ensuring all files have been downloaded" >> $LOGFILE 17 | 18 | # Ensure you have the correct number of downloaded files 19 | NUM_FILES="$(ls -q $TAR_DIR | wc -l)" 20 | if [ "$NUM_FILES" != "26" ] 21 | then 22 | echo "Incorrect number of files ($NUM_FILES), aborting" >> $LOGFILE 23 | exit 1 24 | fi 25 | 26 | echo "Validating all downloaded file checksums" >> $LOGFILE 27 | 28 | # Ensure downloaded file checksums are all valid 29 | for F in $TAR_DIR/*.csv.gz 30 | do 31 | CHECKSUM="$(md5sum $F | cut -d ' ' -f 1)" 32 | if ! grep -wq "$CHECKSUM" $TAR_DIR/../zipped_file_checksums.txt 33 | then 34 | echo "Checksum of $F invalid, aborting" >> $LOGFILE 35 | exit 1 36 | fi 37 | done 38 | 39 | for F in $TAR_DIR/*.csv.gz 40 | do 41 | # Start creating log string 42 | LOG="$F" 43 | 44 | UNZIP_NAME="$(basename $F | sed s/.gz//)" 45 | DEST=$UNZIP_DIR/$UNZIP_NAME 46 | # If unzipped file exists, get checksum and don't unzip if checksum is valid 47 | if [ -e $DEST ] 48 | then 49 | # Extracted file exists, check checksum 50 | CHECKSUM="$(md5sum $DEST | cut -d ' ' -f 1)" 51 | LOG="$LOG Extracted file exists, validating its checksum $CHECKSUM." 52 | if ! grep -wq "$CHECKSUM" $TAR_DIR/../unzipped_file_checksums.txt 53 | then 54 | # Checksum is invalid, remove existing file and re-extract 55 | LOG="$LOG Checksum not valid, re-extracting." 56 | rm $DEST 57 | gzip -d -c $F > $DEST 58 | fi 59 | else 60 | # Extracted file doesn't exist. Check if it's the CHARTEVENTS file - 61 | # that will never exists since you split it into multiple files upon 62 | # extraction. 63 | if [ "$UNZIP_NAME" = "CHARTEVENTS.csv" ] 64 | then 65 | LOG="$LOG Extracting into small files." 66 | # It's the CHARTEVENTS.csv.gz file. Extract it into several small 67 | # files. 68 | BASENAME="$(basename $F | sed s/.csv.gz//)" 69 | gzip -d -c $F | split -d -l 26000000 - $BASENAME 70 | LOG="$LOG Extraction complete. Adding CSV headers to split files." 71 | # Append .csv to the split files and move them to the unzip dir 72 | for SPLIT_CHARTEVENT_FILE in `ls -r /home/vagrant/$BASENAME*` 73 | do 74 | NEW_BASENAME="$(basename $SPLIT_CHARTEVENT_FILE)" 75 | # If it's not the first file, add the headers to the file 76 | FIRST_SPLIT_NAME=$BASENAME"00" 77 | if [ "$NEW_BASENAME" != "$FIRST_SPLIT_NAME" ] 78 | then 79 | # Add headers from first file to all other file 80 | HEADERS=$(head -n 1 /home/vagrant/$FIRST_SPLIT_NAME) 81 | sed -e "1i\\$HEADERS" $SPLIT_CHARTEVENT_FILE > $UNZIP_DIR/$NEW_BASENAME.csv 82 | rm -f $SPLIT_CHARTEVENT_FILE 83 | else 84 | mv $SPLIT_CHARTEVENT_FILE $UNZIP_DIR/$NEW_BASENAME.csv 85 | fi 86 | done 87 | else 88 | # It's all other files, just uncompress it 89 | LOG="$LOG Extracted file does not exist, extracting." 90 | gzip -d -c $F > $DEST 91 | fi 92 | fi 93 | 94 | echo "$LOG" >> $LOGFILE 95 | done 96 | 97 | DT="$(date)" 98 | echo "Extractions complete $DT" >> $LOGFILE 99 | -------------------------------------------------------------------------------- /provisioning/mimic.yml: -------------------------------------------------------------------------------- 1 | # Install PostgreSQL and load MIMIC-III data set. 2 | # 3 | # Edit hosts file with server configuration if you want to load 4 | # the MIMIC-III data to a server instead of a local Vagrant VM. 5 | # 6 | --- 7 | - hosts: all 8 | sudo: yes 9 | gather_facts: no 10 | 11 | vars: 12 | dest: /home/vagrant/src/physionet/mimic-iii 13 | 14 | tasks: 15 | - name: ensure apt cache is up to date 16 | apt: update_cache=yes 17 | - name: ensure packages are installed 18 | apt: name={{item}} 19 | with_items: 20 | - postgresql-9.3 21 | - libpq-dev 22 | - python-psycopg2 23 | - gzip 24 | 25 | - name: ensure directory to download mimic-iii files exists 26 | file: path={{dest}} state=directory mode=0755 owner=vagrant group=vagrant 27 | 28 | - name: ensure directory to store database exists 29 | file: path={{dest}}/db state=directory mode=0755 owner=postgres group=postgres 30 | 31 | 32 | - hosts: all 33 | sudo: no 34 | gather_facts: no 35 | 36 | vars_prompt: 37 | - name: "u" 38 | prompt: "PhysioNet username" 39 | private: yes 40 | - name: "p" 41 | prompt: "PhysioNet password" 42 | private: yes 43 | 44 | vars: 45 | dest: /home/vagrant/src/physionet/mimic-iii 46 | timeout: 30 47 | validate: no 48 | 49 | tasks: 50 | - name: ensure directory to download mimic-iii compressed data exists 51 | file: path={{dest}}/tarballs state=directory mode=0755 52 | 53 | - name: copy mimic-iii downloader script 54 | copy: src=import_scripts/download_mimic.sh dest={{dest}}/download_mimic.sh mode=0744 55 | 56 | - name: download zipped file checksums 57 | get_url: > 58 | url="https://physionet.org/works/MIMICIIIClinicalDatabase/files/version_1_3/checksum_md5_zipped.txt" 59 | dest="{{dest}}/zipped_file_checksums.txt" 60 | url_username="{{u}}" 61 | url_password="{{p}}" 62 | mode=0744 63 | 64 | - name: check checksums and download incomplete mimic-iii data files 65 | shell: "{{dest}}/download_mimic.sh {{u}} {{p}}" 66 | 67 | - name: ensure directory to extract mimic-iii into exists 68 | file: path={{dest}}/unzipped state=directory mode=0755 69 | 70 | - name: copy mimic-iii extractor script 71 | copy: src=import_scripts/extract_mimic.sh dest={{dest}}/extract_mimic.sh mode=0744 72 | 73 | - name: download unzipped file checksums 74 | get_url: > 75 | url="https://physionet.org/works/MIMICIIIClinicalDatabase/files/version_1_3/checksum_md5_unzipped.txt" 76 | dest="{{dest}}/unzipped_file_checksums.txt" 77 | url_username="{{u}}" 78 | url_password="{{p}}" 79 | mode=0744 80 | 81 | - name: validate checksums of unzipped data and extract remaining data files 82 | shell: "{{dest}}/extract_mimic.sh {{dest}}/tarballs {{dest}}/unzipped" 83 | 84 | 85 | # Create privileged database user to load the data 86 | - hosts: all 87 | sudo: yes 88 | sudo_user: postgres 89 | gather_facts: no 90 | 91 | handlers: 92 | - name: restart postgresql 93 | service: name=postgresql state=restarted 94 | 95 | vars: 96 | dbname: mimic 97 | schema: mimiciii 98 | dbuser: vagrant 99 | dbpassword: igMDi9RVEqaGMoi2 100 | 101 | # Step 1 - create the user and the DB 102 | tasks: 103 | - name: ensure postgresql is listening on all IPs 104 | lineinfile: dest=/etc/postgresql/9.3/main/postgresql.conf 105 | regexp="^#listen_addresses" 106 | line="listen_addresses = '*'" 107 | state=present 108 | 109 | - name: ensure postgresql allows access to all hosts 110 | copy: 111 | dest: /etc/postgresql/9.3/main/pg_hba.conf 112 | content: | 113 | local all postgres peer 114 | local all all peer 115 | host all all 0.0.0.0/0 md5 116 | notify: restart postgresql 117 | 118 | - name: drop pre-existing database if it exists 119 | command: psql postgres -c "DROP DATABASE IF EXISTS mimic;" 120 | 121 | - name: dropping pre-existing tablespace if it exists 122 | command: psql postgres -c "DROP TABLESPACE IF EXISTS mimic3v3;" 123 | 124 | - name: ensure the database is created 125 | postgresql_db: name={{dbname}} 126 | 127 | - name: ensure privileged user has access to database 128 | postgresql_user: db={{dbname}} name={{dbuser}} password={{dbpassword}} priv=ALL encrypted=false 129 | 130 | - name: ensure privileged user is the owner of the database 131 | postgresql_db: name={{dbname}} owner={{dbuser}} 132 | 133 | - name: ensure privileged user does not have unnecessary privilege 134 | postgresql_user: name={{dbuser}} role_attr_flags=SUPERUSER,NOCREATEDB 135 | 136 | - name: register existing schema 137 | command: psql -t -d mimic -c "\dn;" 138 | register: check_schema 139 | 140 | - name: ensure schema exists 141 | command: psql mimic -c 'CREATE SCHEMA IF NOT EXISTS mimiciii;' 142 | when: "'mimiciii' not in check_schema.stdout" 143 | 144 | - name: ensure postgresql search path for mimic db is set 145 | command: psql mimic -c 'ALTER DATABASE {{dbname}} SET search_path TO {{schema}},public;' 146 | when: "'mimiciii' not in check_schema.stdout" 147 | 148 | # Move database to new tablespace 149 | - hosts: all 150 | sudo: yes 151 | sudo_user: postgres 152 | gather_facts: no 153 | 154 | vars: 155 | dest: /home/vagrant/src/physionet/mimic-iii 156 | 157 | tasks: 158 | - name: create new tablespace 159 | command: psql mimic -c "CREATE TABLESPACE mimic3v3 OWNER vagrant LOCATION '{{dest}}/db';" 160 | 161 | - name: move database to newly created tablespace 162 | command: psql postgres -c "ALTER DATABASE mimic SET TABLESPACE mimic3v3;" 163 | 164 | - hosts: all 165 | sudo: yes 166 | sudo_user: postgres 167 | gather_facts: no 168 | 169 | # Create tables in DB 170 | - hosts: all 171 | sudo_user: postgres 172 | gather_facts: no 173 | 174 | vars: 175 | dest: /home/vagrant/src/physionet/mimic-iii 176 | 177 | tasks: 178 | - name: copy table creator 179 | copy: src=import_scripts/create_tables.sql dest={{dest}}/create_tables.sql mode=0744 180 | 181 | - name: create mimic-iii tables 182 | command: psql mimic -f {{dest}}/create_tables.sql 183 | 184 | # Create unpriveleged user to have READ access to database 185 | - hosts: all 186 | sudo: yes 187 | sudo_user: postgres 188 | gather_facts: no 189 | 190 | vars: 191 | dbname: mimic 192 | dbuser: mimic 193 | userpassword: oNuemmLeix9Yex7W 194 | schema: mimiciii 195 | dest: /home/vagrant/src/physionet/mimic-iii 196 | 197 | tasks: 198 | - name: ensure unpriveleged user exists 199 | postgresql_user: db={{dbname}} name={{dbuser}} password={{userpassword}} priv=CONNECT encrypted=false 200 | 201 | - name: ensure unprivileged user has read access to the database 202 | postgresql_privs: > 203 | db={{dbname}} 204 | privs=CONNECT 205 | type=database 206 | role={{dbuser}} 207 | 208 | - name: ensure unprivileged user has read access to the schema 209 | postgresql_privs: > 210 | db={{dbname}} 211 | type=schema 212 | objs={{schema}} 213 | privs=USAGE 214 | role={{dbuser}} 215 | 216 | - name: ensure unprivileged user has read access to the schema tables 217 | postgresql_privs: > 218 | db={{dbname}} 219 | schema={{schema}} 220 | type=table 221 | objs=ALL_IN_SCHEMA 222 | privs=SELECT 223 | role={{dbuser}} 224 | 225 | - name: ensure unprivileged user does not have unnecessary privilege 226 | postgresql_user: name={{dbuser}} role_attr_flags=NOSUPERUSER,NOCREATEDB 227 | 228 | # Load the data into the database 229 | - hosts: all 230 | sudo_user: postgres 231 | gather_facts: no 232 | 233 | vars: 234 | dest: /home/vagrant/src/physionet/mimic-iii 235 | 236 | tasks: 237 | - name: copy data loader 238 | copy: src=import_scripts/load_data.sh dest={{dest}}/load_data.sh mode=0744 239 | 240 | - name: load mimic-iii data into postgres 241 | shell: "{{dest}}/load_data.sh {{dest}}/unzipped" 242 | 243 | - name: copy data validator 244 | copy: src=import_scripts/validate_load.sh dest={{dest}}/validate_load.sh mode=0744 245 | 246 | - name: copy expected row counts 247 | copy: src=import_scripts/expected_row_counts.txt dest={{dest}}/expected_row_counts.txt 248 | 249 | - name: validate that all tables loaded correctly 250 | shell: "{{dest}}/validate_load.sh {{dest}}/expected_row_counts.txt" 251 | 252 | - name: copy index creator 253 | copy: src=import_scripts/add_indexes.sql dest={{dest}}/add_indexes.sql mode=0744 254 | 255 | - name: create indexes 256 | command: psql mimic -f {{dest}}/add_indexes.sql 257 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MIMIC-III VM 2 | 3 | This repo creates a virtual machine running PostgreSQL and loads the 4 | MIMIC-III data into a database on the VM. The MIMIC-III data will be 5 | accessible from your host machine by querying the PostgreSQL server on 6 | the VM. Hosting the MIMIC-III data in a VM can be desirable because this 7 | prevents collisions with data on your own computer, and the VM can easily be 8 | destroyed to reclaim disk space once experimentation with the data is complete. 9 | 10 | ## Requirements 11 | You will need to have [Vagrant](https://www.vagrantup.com/downloads.html) and 12 | [VirtualBox](https://www.virtualbox.org/wiki/Downloads) installed. It is 13 | recommended to update to the latest versions if they are already installed. 14 | Ansible is used to provision the Vagrant VM. Since Windows machines 15 | ~~cannot currently~~ can be Ansible controllers 16 | [with some work](http://www.azavea.com/blogs/labs/2014/10/running-vagrant-with-ansible-provisioning-on-windows/), 17 | this ~~will not~~ should also work on Windows. A Unix machine (e.g. Linux, 18 | Mac OS X) is preferred. 19 | 20 | System Requirements: 3GB RAM and 90GB Free HD Space. 21 | 22 | ## VM Provisioning (a.k.a. Installation) 23 | Clone the repo and create a virtualenv using the supplied `requirements.txt`. 24 | If using virtualenvwrapper, while in the repository's directory you can simply 25 | execute: 26 | 27 | ```bash 28 | mkvirtualenv mimic-iii-vm -a `pwd` -r requirements.txt 29 | ``` 30 | 31 | Then run `vagrant up` to boot the VM and run the Ansible provisioner. You 32 | will be prompted for your PhysioNet username and password so the database 33 | files can be downloaded to the VM as part of provisioning (this could 34 | take a while, depending on your internet connection). The entire dataset 35 | will be loaded into the database. A couple things to note: 36 | 37 | 1. There is an issue with non-private prompts for the Ansible provisioner 38 | on Vagrant, so all prompts are private and will conceal what you type. 39 | 2. Downloading and loading these records will take several hours, but once you 40 | input your username and password the entire process is automated. 41 | 42 | You can easily delete the VM and reclaim your disk space with `vagrant halt` 43 | (to stop the VM) and then `vagrant destroy` (to remove it). 44 | 45 | If at any point provisioning is interrupted, you can re-provision the VM with 46 | `vagrant --provision` or `vagrant reload --provision`. This will continue 47 | downloads from where they left off, but all data will be erased and reloaded 48 | into Postgres. 49 | 50 | Log files will be created throughout the provisioning process. If you would 51 | like to monitor these logs, they will be located in the folder for this repo 52 | (on your host machine). 53 | 54 | ## Connecting to the Database 55 | While the VM is booted, local port 2345 is forwarded to the guest VM port 56 | 5432 (Postgres server's default listening port). Therefore, generally 57 | speaking you can connect using the host _localhost_ and port 2345. 58 | 59 | There are two user accounts that have access to the database: 60 | 61 | 1. User `vagrant` with password `igMDi9RVEqaGMoi2` has read _and_ write access 62 | 2. User `mimic` with password `oNuemmLeix9Yex7W` has read-only access 63 | 64 | You can change these passwords by editing the file _provisioning/mimic.yml_ 65 | prior to installation. 66 | 67 | ### GUI 68 | A good GUI is pgAdmin3. It's included in the Windows PostgreSQL 69 | installer, but might not be included for Mac or Linux installers. It is 70 | available on Mac, Windows, and Linux. You can find non-bundled pgAdmin3 71 | installers for Windows, OS X, and several flavors of Linux after selecting 72 | a release version [here](http://www.postgresql.org/ftp/pgadmin3/release/). 73 | 74 | Once installed, the settings for connecting to the database are: 75 | 76 | * Host: localhost 77 | * Port: 2345 78 | * Maintenance DB: mimic 79 | * Username: `mimic` for read-only access (or `vagrant` if you 80 | need write access) 81 | * Password: `igMDi9RVEqaGMoi2` for user `vagrant`, or `oNuemmLeix9Yex7W` for 82 | user `mimic` 83 | 84 | You will find the data tables under the `mimiciii` schema. 85 | 86 | ### psql (command line) 87 | The Postgres client is accessed through the command line with `psql`. The 88 | command line bin is included with the OS-specific installers above, but 89 | has probably not been added to your `PATH`. If it works after running the 90 | installer, you're fine, otherwise: 91 | 92 | * OS X: Add the bin to your path, or instead you can install Postgres via 93 | Homebrew and download pgAdmin3 separately using the link above 94 | (recommended). 95 | 96 | ```bash 97 | brew install postgres 98 | initdb /usr/local/var/postgres -E utf8 99 | ``` 100 | 101 | * Windows: Either move `psql.exe` to your current path or specify the full 102 | path to it, which is something like 103 | 104 | ```bash 105 | "%PROGRAMFILES%\Postgresql\9.2\bin\psql.exe" 106 | ``` 107 | 108 | You can then connect with `psql -h localhost -p 2345 mimiciii mimic`. You 109 | will be prompted to enter the password for user `mimic` (see above for 110 | password). 111 | 112 | Below are some commands you can run in the *psql* client: 113 | 114 | #### List the tables 115 | You can list the tables, which are within the `mimiciii` schema with 116 | 117 | ```psql 118 | \dt mimiciii* 119 | ``` 120 | 121 | #### Describe the table `admissions`, including its size on disk 122 | 123 | ```psql 124 | \dt+ mimiciii.admissions 125 | ``` 126 | 127 | #### Show its columns and some basic info about them 128 | 129 | ```psql 130 | \d+ mimiciii.admissions 131 | ``` 132 | 133 | #### Show the first 10 rows 134 | 135 | ```psql 136 | SELECT * FROM mimiciii.admissions LIMIT 10; 137 | ``` 138 | 139 | #### The Postgres search path looks in the `mimiciii` schema first by default 140 | 141 | ```psql 142 | SELECT * FROM admissions LIMIT 10; 143 | ``` 144 | 145 | Above, `*` can also be replaced with a single column name. 146 | 147 | #### -- DANGER COMMANDS -- 148 | 149 | You can "reset" your database by deleting the schema: 150 | 151 | ```bash 152 | drop schema mimiciii cascade; # drop all tables in the schema. you need 153 | # to have read/write access to do so. 154 | ``` 155 | 156 | If you just deleted your data and want to reload it, execute 157 | `vagrant provision` to run the Ansible playbook again. 158 | 159 | ### Psycopg2 (Python client) 160 | One way to connect to the DB is through Psycopg2, a popular PostgreSQL client 161 | for Python. It is included in `requirements.txt` for this repo. 162 | 163 | ```python 164 | import psycopg2 165 | conn=psycopg2.connect( 166 | dbname='mimic', 167 | user='mimic', 168 | host='localhost', 169 | port=2345, 170 | password='oNuemmLeix9Yex7W' 171 | ) 172 | ``` 173 | 174 | Then, to execute queries: 175 | 176 | ```python 177 | # open a cursor to perform operations 178 | cur = conn.cursor() 179 | 180 | # query the 'admissions' table 181 | cur.execute("SELECT * FROM mimiciii.admissions LIMIT 10;") 182 | colnames = [desc[0] for desc in cur.description] 183 | print colnames 184 | # put results in a list var to print the subject_id 185 | row = cur.fetchall() 186 | for row in rows: 187 | print " ", row[1] 188 | ``` 189 | 190 | You can read this 191 | [quick guide](https://wiki.postgresql.org/wiki/Psycopg2_Tutorial) for the 192 | client and access the [documentation](http://initd.org/psycopg/docs/) for more 193 | information. 194 | 195 | ## A Word on Remote Connections 196 | PostgreSQL connections are *not encrypted*. If you are going to run this on a 197 | remote server, or connect to your VM over a network, you should encrypt your 198 | connection when accessing the database. One way of doing this is by creating an 199 | SSH tunnel to the VM: 200 | 201 | ```bash 202 | ssh -L 63333:localhost:5432 vagrant@192.168.34.44 203 | # this will open an SSH connection in your terminal which you should leave open. 204 | # if you're prompted for a password, try 'vagrant'. 205 | ``` 206 | 207 | Here, `192.168.34.44` is the IP address of your VM. Once the SSH tunnel is 208 | created, use local port `63333` to connect to the DB - this port is now 209 | forwarded to the remote port 5432 over SSH. For example, with pgAdmin3 210 | connecting over the SSH tunnel would use settings: 211 | 212 | * Host: localhost 213 | * Port: 63333 214 | * Maintenance DB: mimic 215 | * Username: `mimic` for read-only access (or `vagrant` if you 216 | need write access) 217 | * Password: `igMDi9RVEqaGMoi2` for user `vagrant`, or `oNuemmLeix9Yex7W` for 218 | user `mimic` 219 | 220 | Or, with psql: 221 | 222 | ```bash 223 | psql -h localhost -p 63333 mimic mimic 224 | ``` 225 | 226 | ## Shutting Down and Rebooting the VM 227 | You can shut down the VM with `vagrant halt`. To boot it up again, `cd` 228 | into the repository's directory and execute `vagrant up`. The data will 229 | remain in the VM and once the VM is finished booting you can make 230 | connections to the DB as before. 231 | -------------------------------------------------------------------------------- /provisioning/import_scripts/add_indexes.sql: -------------------------------------------------------------------------------- 1 | -- ---------------------------------------------------------------- 2 | -- 3 | -- This is a script to add the MIMIC-III indexes for Postgres. 4 | -- 5 | -- ---------------------------------------------------------------- 6 | 7 | -- Restoring search path to its default value can be accomplished as follows: 8 | -- SET search_path TO "$user",public; 9 | 10 | ------------- 11 | -- ADMISSIONS 12 | ------------- 13 | 14 | drop index IF EXISTS ADMISSIONS_idx01; 15 | CREATE INDEX ADMISSIONS_IDX01 16 | ON ADMISSIONS (SUBJECT_ID,HADM_ID); 17 | 18 | drop index IF EXISTS ADMISSIONS_idx02; 19 | CREATE INDEX ADMISSIONS_IDX02 20 | ON ADMISSIONS (ADMITTIME, DISCHTIME, DEATHTIME); 21 | 22 | drop index IF EXISTS ADMISSIONS_idx03; 23 | CREATE INDEX ADMISSIONS_IDX03 24 | ON ADMISSIONS (ADMISSION_TYPE); 25 | 26 | 27 | ----------- 28 | --CALLOUT-- 29 | ----------- 30 | 31 | drop index IF EXISTS CALLOUT_idx01; 32 | CREATE INDEX CALLOUT_IDX01 33 | ON CALLOUT (SUBJECT_ID, HADM_ID); 34 | 35 | drop index IF EXISTS CALLOUT_idx02; 36 | CREATE INDEX CALLOUT_IDX02 37 | ON CALLOUT (CURR_CAREUNIT); 38 | 39 | drop index IF EXISTS CALLOUT_idx03; 40 | CREATE INDEX CALLOUT_IDX03 41 | ON CALLOUT (CALLOUT_SERVICE); 42 | 43 | drop index IF EXISTS CALLOUT_idx04; 44 | CREATE INDEX CALLOUT_IDX04 45 | ON CALLOUT (CURR_WARDID, CALLOUT_WARDID, 46 | DISCHARGE_WARDID); 47 | 48 | drop index IF EXISTS CALLOUT_idx05; 49 | CREATE INDEX CALLOUT_IDX05 50 | ON CALLOUT (CALLOUT_STATUS, 51 | CALLOUT_OUTCOME); 52 | 53 | drop index IF EXISTS CALLOUT_idx06; 54 | CREATE INDEX CALLOUT_IDX06 55 | ON CALLOUT (CREATETIME, UPDATETIME, 56 | ACKNOWLEDGETIME, OUTCOMETIME); 57 | 58 | --------------- 59 | -- CAREGIVERS 60 | --------------- 61 | 62 | drop index IF EXISTS CAREGIVERS_idx01; 63 | CREATE INDEX CAREGIVERS_IDX01 64 | ON CAREGIVERS (CGID, LABEL); 65 | 66 | --------------- 67 | -- CHARTEVENTS 68 | --------------- 69 | drop index IF EXISTS CHARTEVENTS_idx01; 70 | CREATE INDEX CHARTEVENTS_idx01 71 | ON CHARTEVENTS (SUBJECT_ID, HADM_ID, ICUSTAY_ID); 72 | 73 | 74 | drop index IF EXISTS CHARTEVENTS_idx02; 75 | CREATE INDEX CHARTEVENTS_idx02 76 | ON CHARTEVENTS (ITEMID); 77 | 78 | 79 | -- drop index IF EXISTS CHARTEVENTS_idx03; 80 | -- CREATE INDEX CHARTEVENTS_idx03 81 | -- ON CHARTEVENTS (CHARTTIME, STORETIME); 82 | 83 | 84 | drop index IF EXISTS CHARTEVENTS_idx04; 85 | CREATE INDEX CHARTEVENTS_idx04 86 | ON CHARTEVENTS (CGID); 87 | 88 | -- Perhaps not useful to index on just value? Index just for popular subset? 89 | -- drop index IF EXISTS CHARTEVENTS_idx05; 90 | -- CREATE INDEX CHARTEVENTS_idx05 91 | -- ON CHARTEVENTS (VALUE); 92 | 93 | --------------- 94 | -- CPTEVENTS 95 | --------------- 96 | 97 | drop index IF EXISTS CPTEVENTS_idx01; 98 | CREATE INDEX CPTEVENTS_idx01 99 | ON CPTEVENTS (SUBJECT_ID, HADM_ID); 100 | 101 | drop index IF EXISTS CPTEVENTS_idx02; 102 | CREATE INDEX CPTEVENTS_idx02 103 | ON CPTEVENTS (CPT_CD, TICKET_ID_SEQ); 104 | 105 | ----------- 106 | -- D_CPT 107 | ----------- 108 | 109 | -- Table is 134 rows - doesn't need an index. 110 | 111 | -------------------- 112 | -- D_ICD_DIAGNOSES 113 | -------------------- 114 | 115 | -- drop index IF EXISTS D_ICD_DIAG_idx01; 116 | -- CREATE INDEX D_ICD_DIAG_idx01 117 | -- ON D_ICD_DIAGNOSES (ICD9_CODE, DIAG_OR_PROC); 118 | 119 | drop index IF EXISTS D_ICD_DIAG_idx02; 120 | CREATE INDEX D_ICD_DIAG_idx02 121 | ON D_ICD_DIAGNOSES (SHORT_TITLE, LONG_TITLE); 122 | 123 | -------------------- 124 | -- D_ICD_PROCEDURES 125 | -------------------- 126 | 127 | -- drop index IF EXISTS D_ICD_PROC_idx01; 128 | -- CREATE INDEX D_ICD_PROC_idx01 129 | -- ON D_ICD_PROCEDURES (ICD9_CODE, DIAG_OR_PROC); 130 | 131 | drop index IF EXISTS D_ICD_PROC_idx02; 132 | CREATE INDEX D_ICD_PROC_idx02 133 | ON D_ICD_PROCEDURES (SHORT_TITLE, LONG_TITLE); 134 | 135 | ----------- 136 | -- D_ITEMS 137 | ----------- 138 | 139 | drop index IF EXISTS D_ITEMS_idx01; 140 | CREATE INDEX D_ITEMS_idx01 141 | ON D_ITEMS (ITEMID); 142 | 143 | drop index IF EXISTS D_ITEMS_idx02; 144 | CREATE INDEX D_ITEMS_idx02 145 | ON D_ITEMS (LABEL, DBSOURCE); 146 | 147 | drop index IF EXISTS D_ITEMS_idx03; 148 | CREATE INDEX D_ITEMS_idx03 149 | ON D_ITEMS (CATEGORY); 150 | 151 | --------------- 152 | -- D_LABITEMS 153 | --------------- 154 | 155 | drop index IF EXISTS D_LABITEMS_idx01; 156 | CREATE INDEX D_LABITEMS_idx01 157 | ON D_LABITEMS (ITEMID); 158 | 159 | drop index IF EXISTS D_LABITEMS_idx02; 160 | CREATE INDEX D_LABITEMS_idx02 161 | ON D_LABITEMS (LABEL, FLUID, CATEGORY); 162 | 163 | drop index IF EXISTS D_LABITEMS_idx03; 164 | CREATE INDEX D_LABITEMS_idx03 165 | ON D_LABITEMS (LOINC_CODE); 166 | 167 | ------------------- 168 | -- DATETIMEEVENTS 169 | ------------------- 170 | 171 | drop index IF EXISTS DATETIMEEVENTS_idx01; 172 | CREATE INDEX DATETIMEEVENTS_idx01 173 | ON DATETIMEEVENTS (SUBJECT_ID, 174 | HADM_ID, ICUSTAY_ID); 175 | 176 | drop index IF EXISTS DATETIMEEVENTS_idx02; 177 | CREATE INDEX DATETIMEEVENTS_idx02 178 | ON DATETIMEEVENTS (ITEMID); 179 | 180 | drop index IF EXISTS DATETIMEEVENTS_idx03; 181 | CREATE INDEX DATETIMEEVENTS_idx03 182 | ON DATETIMEEVENTS (CHARTTIME); 183 | 184 | drop index IF EXISTS DATETIMEEVENTS_idx04; 185 | CREATE INDEX DATETIMEEVENTS_idx04 186 | ON DATETIMEEVENTS (CGID); 187 | 188 | drop index IF EXISTS DATETIMEEVENTS_idx05; 189 | CREATE INDEX DATETIMEEVENTS_idx05 190 | ON DATETIMEEVENTS (VALUE); 191 | 192 | ------------------ 193 | -- DIAGNOSES_ICD 194 | ------------------ 195 | 196 | drop index IF EXISTS DIAGNOSES_ICD_idx01; 197 | CREATE INDEX DIAGNOSES_ICD_idx01 198 | ON DIAGNOSES_ICD (SUBJECT_ID, HADM_ID); 199 | 200 | drop index IF EXISTS DIAGNOSES_ICD_idx02; 201 | CREATE INDEX DIAGNOSES_ICD_idx02 202 | ON DIAGNOSES_ICD (ICD9_CODE, SEQ_NUM); 203 | 204 | -------------- 205 | -- DRGCODES 206 | -------------- 207 | 208 | drop index IF EXISTS DRGCODES_idx01; 209 | CREATE INDEX DRGCODES_idx01 210 | ON DRGCODES (SUBJECT_ID, HADM_ID); 211 | 212 | drop index IF EXISTS DRGCODES_idx02; 213 | CREATE INDEX DRGCODES_idx02 214 | ON DRGCODES (DRG_CODE, DRG_TYPE); 215 | 216 | drop index IF EXISTS DRGCODES_idx03; 217 | CREATE INDEX DRGCODES_idx03 218 | ON DRGCODES (DESCRIPTION, DRG_SEVERITY); 219 | 220 | ------------------ 221 | -- ICUSTAYS 222 | ------------------ 223 | 224 | drop index IF EXISTS ICUSTAYS_idx01; 225 | CREATE INDEX ICUSTAYS_idx01 226 | ON ICUSTAYS (SUBJECT_ID, HADM_ID); 227 | 228 | drop index IF EXISTS ICUSTAYS_idx02; 229 | CREATE INDEX ICUSTAYS_idx02 230 | ON ICUSTAYS (ICUSTAY_ID, DBSOURCE); 231 | 232 | drop index IF EXISTS ICUSTAYS_idx03; 233 | CREATE INDEX ICUSTAYS_idx03 234 | ON ICUSTAYS (LOS); 235 | 236 | drop index IF EXISTS ICUSTAYS_idx04; 237 | CREATE INDEX ICUSTAYS_idx04 238 | ON ICUSTAYS (FIRST_CAREUNIT); 239 | 240 | drop index IF EXISTS ICUSTAYS_idx05; 241 | CREATE INDEX ICUSTAYS_idx05 242 | ON ICUSTAYS (LAST_CAREUNIT); 243 | 244 | ------------- 245 | -- INPUTEVENTS_CV 246 | ------------- 247 | 248 | drop index IF EXISTS INPUTEVENTS_CV_idx01; 249 | CREATE INDEX INPUTEVENTS_CV_idx01 250 | ON INPUTEVENTS_CV (SUBJECT_ID); 251 | 252 | drop index IF EXISTS INPUTEVENTS_CV_idx02; 253 | CREATE INDEX INPUTEVENTS_CV_idx02 254 | ON INPUTEVENTS_CV (HADM_ID); 255 | 256 | drop index IF EXISTS INPUTEVENTS_CV_idx03; 257 | CREATE INDEX INPUTEVENTS_CV_idx03 258 | ON INPUTEVENTS_CV (ICUSTAY_ID); 259 | 260 | drop index IF EXISTS INPUTEVENTS_CV_idx04; 261 | CREATE INDEX INPUTEVENTS_CV_idx04 262 | ON INPUTEVENTS_CV (CHARTTIME); 263 | 264 | drop index IF EXISTS INPUTEVENTS_CV_idx05; 265 | CREATE INDEX INPUTEVENTS_CV_idx05 266 | ON INPUTEVENTS_CV (ITEMID); 267 | 268 | drop index IF EXISTS INPUTEVENTS_CV_idx06; 269 | CREATE INDEX INPUTEVENTS_CV_idx06 270 | ON INPUTEVENTS_CV (RATE); 271 | 272 | drop index IF EXISTS INPUTEVENTS_CV_idx07; 273 | CREATE INDEX INPUTEVENTS_CV_idx07 274 | ON INPUTEVENTS_CV (AMOUNT); 275 | 276 | drop index IF EXISTS INPUTEVENTS_CV_idx08; 277 | CREATE INDEX INPUTEVENTS_CV_idx08 278 | ON INPUTEVENTS_CV (CGID); 279 | 280 | drop index IF EXISTS INPUTEVENTS_CV_idx09; 281 | CREATE INDEX INPUTEVENTS_CV_idx09 282 | ON INPUTEVENTS_CV (LINKORDERID, ORDERID); 283 | 284 | ------------- 285 | -- INPUTEVENTS_MV 286 | ------------- 287 | 288 | drop index IF EXISTS INPUTEVENTS_MV_idx01; 289 | CREATE INDEX INPUTEVENTS_MV_idx01 290 | ON INPUTEVENTS_MV (SUBJECT_ID); 291 | 292 | drop index IF EXISTS INPUTEVENTS_MV_idx02; 293 | CREATE INDEX INPUTEVENTS_MV_idx02 294 | ON INPUTEVENTS_MV (HADM_ID); 295 | 296 | drop index IF EXISTS INPUTEVENTS_MV_idx03; 297 | CREATE INDEX INPUTEVENTS_MV_idx03 298 | ON INPUTEVENTS_MV (ICUSTAY_ID); 299 | 300 | drop index IF EXISTS INPUTEVENTS_MV_idx04; 301 | CREATE INDEX INPUTEVENTS_MV_idx04 302 | ON INPUTEVENTS_MV (ENDTIME, STARTTIME); 303 | 304 | drop index IF EXISTS INPUTEVENTS_MV_idx05; 305 | CREATE INDEX INPUTEVENTS_MV_idx05 306 | ON INPUTEVENTS_MV (ITEMID); 307 | 308 | drop index IF EXISTS INPUTEVENTS_MV_idx06; 309 | CREATE INDEX INPUTEVENTS_MV_idx06 310 | ON INPUTEVENTS_MV (RATE); 311 | 312 | -- drop index IF EXISTS INPUTEVENTS_MV_idx07; 313 | -- CREATE INDEX INPUTEVENTS_MV_idx07 314 | -- ON INPUTEVENTS_MV (VOLUME); 315 | 316 | drop index IF EXISTS INPUTEVENTS_MV_idx08; 317 | CREATE INDEX INPUTEVENTS_MV_idx08 318 | ON INPUTEVENTS_MV (CGID); 319 | 320 | drop index IF EXISTS INPUTEVENTS_MV_idx09; 321 | CREATE INDEX INPUTEVENTS_MV_idx09 322 | ON INPUTEVENTS_MV (LINKORDERID, ORDERID); 323 | 324 | drop index IF EXISTS INPUTEVENTS_MV_idx10; 325 | CREATE INDEX INPUTEVENTS_MV_idx10 326 | ON INPUTEVENTS_MV (ORDERCATEGORYDESCRIPTION, 327 | ORDERCATEGORYNAME, SECONDARYORDERCATEGORYNAME); 328 | 329 | drop index IF EXISTS INPUTEVENTS_MV_idx11; 330 | CREATE INDEX INPUTEVENTS_MV_idx11 331 | ON INPUTEVENTS_MV (ORDERCOMPONENTTYPEDESCRIPTION, 332 | ORDERCATEGORYDESCRIPTION); 333 | 334 | 335 | -------------- 336 | -- LABEVENTS 337 | -------------- 338 | 339 | drop index IF EXISTS LABEVENTS_idx01; 340 | CREATE INDEX LABEVENTS_idx01 341 | ON LABEVENTS (SUBJECT_ID, HADM_ID); 342 | 343 | drop index IF EXISTS LABEVENTS_idx02; 344 | CREATE INDEX LABEVENTS_idx02 345 | ON LABEVENTS (ITEMID); 346 | 347 | drop index IF EXISTS LABEVENTS_idx03; 348 | CREATE INDEX LABEVENTS_idx03 349 | ON LABEVENTS (CHARTTIME); 350 | 351 | drop index IF EXISTS LABEVENTS_idx04; 352 | CREATE INDEX LABEVENTS_idx04 353 | ON LABEVENTS (VALUE, VALUENUM); 354 | 355 | ---------------------- 356 | -- MICROBIOLOGYEVENTS 357 | ---------------------- 358 | 359 | drop index IF EXISTS MICROBIOLOGYEVENTS_idx01; 360 | CREATE INDEX MICROBIOLOGYEVENTS_idx01 361 | ON MICROBIOLOGYEVENTS (SUBJECT_ID, HADM_ID); 362 | 363 | drop index IF EXISTS MICROBIOLOGYEVENTS_idx02; 364 | CREATE INDEX MICROBIOLOGYEVENTS_idx02 365 | ON MICROBIOLOGYEVENTS (CHARTDATE, CHARTTIME); 366 | 367 | drop index IF EXISTS MICROBIOLOGYEVENTS_idx03; 368 | CREATE INDEX MICROBIOLOGYEVENTS_idx03 369 | ON MICROBIOLOGYEVENTS (SPEC_ITEMID, 370 | ORG_ITEMID, AB_ITEMID); 371 | 372 | --------------- 373 | -- NOTEEVENTS 374 | --------------- 375 | 376 | drop index IF EXISTS NOTEEVENTS_idx01; 377 | CREATE INDEX NOTEEVENTS_idx01 378 | ON NOTEEVENTS (SUBJECT_ID, HADM_ID); 379 | 380 | drop index IF EXISTS NOTEEVENTS_idx02; 381 | CREATE INDEX NOTEEVENTS_idx02 382 | ON NOTEEVENTS (CHARTDATE); 383 | 384 | drop index IF EXISTS NOTEEVENTS_idx03; 385 | CREATE INDEX NOTEEVENTS_idx03 386 | ON NOTEEVENTS (CGID); 387 | 388 | -- drop index IF EXISTS NOTEEVENTS_idx04; 389 | -- CREATE INDEX NOTEEVENTS_idx04 390 | -- ON NOTEEVENTS (RECORD_ID); 391 | 392 | drop index IF EXISTS NOTEEVENTS_idx05; 393 | CREATE INDEX NOTEEVENTS_idx05 394 | ON NOTEEVENTS (CATEGORY, DESCRIPTION); 395 | 396 | 397 | --------------- 398 | -- OUTPUTEVENTS 399 | --------------- 400 | drop index IF EXISTS OUTPUTEVENTS_idx01; 401 | CREATE INDEX OUTPUTEVENTS_idx01 402 | ON OUTPUTEVENTS (SUBJECT_ID, HADM_ID, ICUSTAY_ID); 403 | 404 | 405 | drop index IF EXISTS OUTPUTEVENTS_idx02; 406 | CREATE INDEX OUTPUTEVENTS_idx02 407 | ON OUTPUTEVENTS (ITEMID); 408 | 409 | 410 | -- drop index IF EXISTS OUTPUTEVENTS_idx03; 411 | -- CREATE INDEX OUTPUTEVENTS_idx03 412 | -- ON OUTPUTEVENTS (CHARTTIME, STORETIME); 413 | 414 | 415 | drop index IF EXISTS OUTPUTEVENTS_idx04; 416 | CREATE INDEX OUTPUTEVENTS_idx04 417 | ON OUTPUTEVENTS (CGID); 418 | 419 | -- Perhaps not useful to index on just value? Index just for popular subset? 420 | -- drop index IF EXISTS OUTPUTEVENTS_idx05; 421 | -- CREATE INDEX OUTPUTEVENTS_idx05 422 | -- ON OUTPUTEVENTS (VALUE); 423 | 424 | 425 | ------------- 426 | -- PATIENTS 427 | ------------- 428 | 429 | -- Note that SUBJECT_ID is already indexed as it is unique 430 | 431 | drop index IF EXISTS PATIENTS_idx01; 432 | CREATE INDEX PATIENTS_idx01 433 | ON PATIENTS (EXPIRE_FLAG); 434 | 435 | 436 | ------------------ 437 | -- PRESCRIPTIONS 438 | ------------------ 439 | 440 | drop index IF EXISTS PRESCRIPTIONS_idx01; 441 | CREATE INDEX PRESCRIPTIONS_idx01 442 | ON PRESCRIPTIONS (SUBJECT_ID, HADM_ID); 443 | 444 | drop index IF EXISTS PRESCRIPTIONS_idx02; 445 | CREATE INDEX PRESCRIPTIONS_idx02 446 | ON PRESCRIPTIONS (ICUSTAY_ID); 447 | 448 | drop index IF EXISTS PRESCRIPTIONS_idx03; 449 | CREATE INDEX PRESCRIPTIONS_idx03 450 | ON PRESCRIPTIONS (DRUG_TYPE); 451 | 452 | drop index IF EXISTS PRESCRIPTIONS_idx04; 453 | CREATE INDEX PRESCRIPTIONS_idx04 454 | ON PRESCRIPTIONS (DRUG); 455 | 456 | drop index IF EXISTS PRESCRIPTIONS_idx05; 457 | CREATE INDEX PRESCRIPTIONS_idx05 458 | ON PRESCRIPTIONS (STARTTIME, ENDTIME); 459 | 460 | 461 | --------------------- 462 | -- PROCEDUREEVENTS_MV 463 | --------------------- 464 | 465 | drop index IF EXISTS PROCEDUREEVENTS_MV_idx01; 466 | CREATE INDEX PROCEDUREEVENTS_MV_idx01 467 | ON PROCEDUREEVENTS_MV (SUBJECT_ID); 468 | 469 | drop index IF EXISTS PROCEDUREEVENTS_MV_idx02; 470 | CREATE INDEX PROCEDUREEVENTS_MV_idx02 471 | ON PROCEDUREEVENTS_MV (HADM_ID); 472 | 473 | drop index IF EXISTS PROCEDUREEVENTS_MV_idx03; 474 | CREATE INDEX PROCEDUREEVENTS_MV_idx03 475 | ON PROCEDUREEVENTS_MV (ICUSTAY_ID); 476 | 477 | drop index IF EXISTS PROCEDUREEVENTS_MV_idx04; 478 | CREATE INDEX PROCEDUREEVENTS_MV_idx04 479 | ON PROCEDUREEVENTS_MV (ENDTIME, STARTTIME); 480 | 481 | drop index IF EXISTS PROCEDUREEVENTS_MV_idx05; 482 | CREATE INDEX PROCEDUREEVENTS_MV_idx05 483 | ON PROCEDUREEVENTS_MV (ITEMID); 484 | 485 | drop index IF EXISTS PROCEDUREEVENTS_MV_idx06; 486 | CREATE INDEX PROCEDUREEVENTS_MV_idx06 487 | ON PROCEDUREEVENTS_MV (VALUE); 488 | 489 | drop index IF EXISTS PROCEDUREEVENTS_MV_idx07; 490 | CREATE INDEX PROCEDUREEVENTS_MV_idx07 491 | ON PROCEDUREEVENTS_MV (CGID); 492 | 493 | drop index IF EXISTS PROCEDUREEVENTS_MV_idx08; 494 | CREATE INDEX PROCEDUREEVENTS_MV_idx08 495 | ON PROCEDUREEVENTS_MV (LINKORDERID, ORDERID); 496 | 497 | drop index IF EXISTS PROCEDUREEVENTS_MV_idx09; 498 | CREATE INDEX PROCEDUREEVENTS_MV_idx09 499 | ON PROCEDUREEVENTS_MV (ORDERCATEGORYDESCRIPTION, 500 | ORDERCATEGORYNAME, SECONDARYORDERCATEGORYNAME); 501 | 502 | ------------------- 503 | -- PROCEDURES_ICD 504 | ------------------- 505 | 506 | drop index IF EXISTS PROCEDURES_ICD_idx01; 507 | CREATE INDEX PROCEDURES_ICD_idx01 508 | ON PROCEDURES_ICD (SUBJECT_ID, HADM_ID); 509 | 510 | drop index IF EXISTS PROCEDURES_ICD_idx02; 511 | CREATE INDEX PROCEDURES_ICD_idx02 512 | ON PROCEDURES_ICD (ICD9_CODE, SEQ_NUM); 513 | 514 | ------------- 515 | -- SERVICES 516 | ------------- 517 | 518 | drop index IF EXISTS SERVICES_idx01; 519 | CREATE INDEX SERVICES_idx01 520 | ON SERVICES (SUBJECT_ID, HADM_ID); 521 | 522 | drop index IF EXISTS SERVICES_idx02; 523 | CREATE INDEX SERVICES_idx02 524 | ON SERVICES (TRANSFERTIME); 525 | 526 | drop index IF EXISTS SERVICES_idx03; 527 | CREATE INDEX SERVICES_idx03 528 | ON SERVICES (CURR_SERVICE, PREV_SERVICE); 529 | 530 | ------------- 531 | -- TRANSFERS 532 | ------------- 533 | 534 | drop index IF EXISTS TRANSFERS_idx01; 535 | CREATE INDEX TRANSFERS_idx01 536 | ON TRANSFERS (SUBJECT_ID, HADM_ID); 537 | 538 | drop index IF EXISTS TRANSFERS_idx02; 539 | CREATE INDEX TRANSFERS_idx02 540 | ON TRANSFERS (ICUSTAY_ID); 541 | 542 | drop index IF EXISTS TRANSFERS_idx03; 543 | CREATE INDEX TRANSFERS_idx03 544 | ON TRANSFERS (CURR_CAREUNIT, PREV_CAREUNIT); 545 | 546 | drop index IF EXISTS TRANSFERS_idx04; 547 | CREATE INDEX TRANSFERS_idx04 548 | ON TRANSFERS (INTIME, OUTTIME); 549 | 550 | drop index IF EXISTS TRANSFERS_idx05; 551 | CREATE INDEX TRANSFERS_idx05 552 | ON TRANSFERS (LOS); 553 | -------------------------------------------------------------------------------- /provisioning/import_scripts/create_tables.sql: -------------------------------------------------------------------------------- 1 | -- ----------------------------------------------------------------------------- 2 | -- 3 | -- Create the MIMIC-III tables 4 | -- 5 | -- ----------------------------------------------------------------------------- 6 | 7 | -------------------------------------------------------- 8 | -- File created - Thursday-November-28-2015 9 | -- File modified by Nikhil Haas Tuesday-January-5-2016 10 | -------------------------------------------------------- 11 | 12 | -------------------------------------------------------- 13 | -- DDL for Table ADMISSIONS 14 | -------------------------------------------------------- 15 | 16 | DROP TABLE IF EXISTS ADMISSIONS; 17 | CREATE TABLE ADMISSIONS 18 | ( 19 | ROW_ID INT NOT NULL, 20 | SUBJECT_ID INT NOT NULL, 21 | HADM_ID INT NOT NULL, 22 | ADMITTIME TIMESTAMP(0) NOT NULL, 23 | DISCHTIME TIMESTAMP(0) NOT NULL, 24 | DEATHTIME TIMESTAMP(0), 25 | ADMISSION_TYPE VARCHAR(50) NOT NULL, 26 | ADMISSION_LOCATION VARCHAR(50) NOT NULL, 27 | DISCHARGE_LOCATION VARCHAR(50) NOT NULL, 28 | INSURANCE VARCHAR(255) NOT NULL, 29 | LANGUAGE VARCHAR(10), 30 | RELIGION VARCHAR(50), 31 | MARITAL_STATUS VARCHAR(50), 32 | ETHNICITY VARCHAR(200) NOT NULL, 33 | EDREGTIME TIMESTAMP(0), 34 | EDOUTTIME TIMESTAMP(0), 35 | DIAGNOSIS VARCHAR(255), 36 | HOSPITAL_EXPIRE_FLAG SMALLINT, 37 | HAS_IOEVENTS_DATA SMALLINT NOT NULL, 38 | HAS_CHARTEVENTS_DATA SMALLINT NOT NULL, 39 | CONSTRAINT adm_rowid_pk PRIMARY KEY (ROW_ID), 40 | CONSTRAINT adm_hadm_unique UNIQUE (HADM_ID) 41 | ) ; 42 | 43 | -------------------------------------------------------- 44 | -- DDL for Table CALLOUT 45 | -------------------------------------------------------- 46 | 47 | DROP TABLE IF EXISTS CALLOUT; 48 | CREATE TABLE CALLOUT 49 | ( ROW_ID INT NOT NULL, 50 | SUBJECT_ID INT NOT NULL, 51 | HADM_ID INT NOT NULL, 52 | SUBMIT_WARDID INT, 53 | SUBMIT_CAREUNIT VARCHAR(15), 54 | CURR_WARDID INT, 55 | CURR_CAREUNIT VARCHAR(15), 56 | CALLOUT_WARDID INT, 57 | CALLOUT_SERVICE VARCHAR(10) NOT NULL, 58 | REQUEST_TELE SMALLINT NOT NULL, 59 | REQUEST_RESP SMALLINT NOT NULL, 60 | REQUEST_CDIFF SMALLINT NOT NULL, 61 | REQUEST_MRSA SMALLINT NOT NULL, 62 | REQUEST_VRE SMALLINT NOT NULL, 63 | CALLOUT_STATUS VARCHAR(20) NOT NULL, 64 | CALLOUT_OUTCOME VARCHAR(20) NOT NULL, 65 | DISCHARGE_WARDID INT, 66 | ACKNOWLEDGE_STATUS VARCHAR(20) NOT NULL, 67 | CREATETIME TIMESTAMP(0) NOT NULL, 68 | UPDATETIME TIMESTAMP(0) NOT NULL, 69 | ACKNOWLEDGETIME TIMESTAMP(0), 70 | OUTCOMETIME TIMESTAMP(0) NOT NULL, 71 | FIRSTRESERVATIONTIME TIMESTAMP(0), 72 | CURRENTRESERVATIONTIME TIMESTAMP(0), 73 | CONSTRAINT callout_rowid_pk PRIMARY KEY (ROW_ID) 74 | ); 75 | 76 | -------------------------------------------------------- 77 | -- DDL for Table CAREGIVERS 78 | -------------------------------------------------------- 79 | 80 | DROP TABLE IF EXISTS CAREGIVERS; 81 | CREATE TABLE CAREGIVERS 82 | ( ROW_ID INT NOT NULL, 83 | CGID INT NOT NULL, 84 | LABEL VARCHAR(15), 85 | DESCRIPTION VARCHAR(30), 86 | CONSTRAINT cg_rowid_pk PRIMARY KEY (ROW_ID), 87 | CONSTRAINT cg_cgid_unique UNIQUE (CGID) 88 | ) ; 89 | 90 | -------------------------------------------------------- 91 | -- DDL for Table CHARTEVENTS 92 | -------------------------------------------------------- 93 | 94 | DROP TABLE IF EXISTS CHARTEVENTS; 95 | CREATE TABLE CHARTEVENTS 96 | ( ROW_ID INT NOT NULL, 97 | SUBJECT_ID INT NOT NULL, 98 | HADM_ID INT, 99 | ICUSTAY_ID INT, 100 | ITEMID INT, 101 | CHARTTIME TIMESTAMP(0), 102 | STORETIME TIMESTAMP(0), 103 | CGID INT, 104 | VALUE VARCHAR(255), 105 | VALUENUM DOUBLE PRECISION, 106 | VALUEUOM VARCHAR(50), 107 | WARNING INT, 108 | ERROR INT, 109 | RESULTSTATUS VARCHAR(50), 110 | STOPPED VARCHAR(50), 111 | CONSTRAINT chartevents_rowid_pk PRIMARY KEY (ROW_ID) 112 | ); 113 | 114 | -------------------------------------------------------- 115 | -- DDL for Table CPTEVENTS 116 | -------------------------------------------------------- 117 | 118 | DROP TABLE IF EXISTS CPTEVENTS; 119 | CREATE TABLE CPTEVENTS 120 | ( ROW_ID INT NOT NULL, 121 | SUBJECT_ID INT NOT NULL, 122 | HADM_ID INT NOT NULL, 123 | COSTCENTER VARCHAR(10) NOT NULL, 124 | CHARTDATE TIMESTAMP(0), 125 | CPT_CD VARCHAR(10) NOT NULL, 126 | CPT_NUMBER INT, 127 | CPT_SUFFIX VARCHAR(5), 128 | TICKET_ID_SEQ INT, 129 | SECTIONHEADER VARCHAR(50), 130 | SUBSECTIONHEADER VARCHAR(255), 131 | DESCRIPTION VARCHAR(200), 132 | CONSTRAINT cpt_rowid_pk PRIMARY KEY (ROW_ID) 133 | ) ; 134 | 135 | -------------------------------------------------------- 136 | -- DDL for Table DATETIMEEVENTS 137 | -------------------------------------------------------- 138 | 139 | DROP TABLE IF EXISTS DATETIMEEVENTS; 140 | CREATE TABLE DATETIMEEVENTS 141 | ( ROW_ID INT NOT NULL, 142 | SUBJECT_ID INT NOT NULL, 143 | HADM_ID INT, 144 | ICUSTAY_ID INT, 145 | ITEMID INT NOT NULL, 146 | CHARTTIME TIMESTAMP(0) NOT NULL, 147 | STORETIME TIMESTAMP(0) NOT NULL, 148 | CGID INT NOT NULL, 149 | VALUE TIMESTAMP(0), 150 | VALUEUOM VARCHAR(50) NOT NULL, 151 | WARNING SMALLINT, 152 | ERROR SMALLINT, 153 | RESULTSTATUS VARCHAR(50), 154 | STOPPED VARCHAR(50), 155 | CONSTRAINT datetime_rowid_pk PRIMARY KEY (ROW_ID) 156 | ) ; 157 | 158 | -------------------------------------------------------- 159 | -- DDL for Table DIAGNOSES_ICD 160 | -------------------------------------------------------- 161 | 162 | DROP TABLE IF EXISTS DIAGNOSES_ICD; 163 | CREATE TABLE DIAGNOSES_ICD 164 | ( ROW_ID INT NOT NULL, 165 | SUBJECT_ID INT NOT NULL, 166 | HADM_ID INT NOT NULL, 167 | SEQ_NUM INT, 168 | ICD9_CODE VARCHAR(20), 169 | CONSTRAINT diagnosesicd_rowid_pk PRIMARY KEY (ROW_ID) 170 | ) ; 171 | 172 | -------------------------------------------------------- 173 | -- DDL for Table DRGCODES 174 | -------------------------------------------------------- 175 | 176 | DROP TABLE IF EXISTS DRGCODES; 177 | CREATE TABLE DRGCODES 178 | ( ROW_ID INT NOT NULL, 179 | SUBJECT_ID INT NOT NULL, 180 | HADM_ID INT NOT NULL, 181 | DRG_TYPE VARCHAR(20) NOT NULL, 182 | DRG_CODE VARCHAR(20) NOT NULL, 183 | DESCRIPTION VARCHAR(255), 184 | DRG_SEVERITY SMALLINT, 185 | DRG_MORTALITY SMALLINT, 186 | CONSTRAINT drg_rowid_pk PRIMARY KEY (ROW_ID) 187 | ) ; 188 | 189 | -------------------------------------------------------- 190 | -- DDL for Table D_CPT 191 | -------------------------------------------------------- 192 | 193 | DROP TABLE IF EXISTS D_CPT; 194 | CREATE TABLE D_CPT 195 | ( ROW_ID INT NOT NULL, 196 | CATEGORY SMALLINT NOT NULL, 197 | SECTIONRANGE VARCHAR(100) NOT NULL, 198 | SECTIONHEADER VARCHAR(50) NOT NULL, 199 | SUBSECTIONRANGE VARCHAR(100) NOT NULL, 200 | SUBSECTIONHEADER VARCHAR(255) NOT NULL, 201 | CODESUFFIX VARCHAR(5), 202 | MINCODEINSUBSECTION INT NOT NULL, 203 | MAXCODEINSUBSECTION INT NOT NULL, 204 | CONSTRAINT dcpt_ssrange_unique UNIQUE (SUBSECTIONRANGE), 205 | CONSTRAINT dcpt_rowid_pk PRIMARY KEY (ROW_ID) 206 | ) ; 207 | 208 | -------------------------------------------------------- 209 | -- DDL for Table D_ICD_DIAGNOSES 210 | -------------------------------------------------------- 211 | 212 | DROP TABLE IF EXISTS D_ICD_DIAGNOSES; 213 | CREATE TABLE D_ICD_DIAGNOSES 214 | ( ROW_ID INT NOT NULL, 215 | ICD9_CODE VARCHAR(10) NOT NULL, 216 | SHORT_TITLE VARCHAR(50) NOT NULL, 217 | LONG_TITLE VARCHAR(255) NOT NULL, 218 | CONSTRAINT d_icd_diag_code_unique UNIQUE (ICD9_CODE), 219 | CONSTRAINT d_icd_diag_rowid_pk PRIMARY KEY (ROW_ID) 220 | ) ; 221 | 222 | -------------------------------------------------------- 223 | -- DDL for Table D_ICD_PROCEDURES 224 | -------------------------------------------------------- 225 | 226 | DROP TABLE IF EXISTS D_ICD_PROCEDURES; 227 | CREATE TABLE D_ICD_PROCEDURES 228 | ( ROW_ID INT NOT NULL, 229 | ICD9_CODE VARCHAR(10) NOT NULL, 230 | SHORT_TITLE VARCHAR(50) NOT NULL, 231 | LONG_TITLE VARCHAR(255) NOT NULL, 232 | CONSTRAINT d_icd_proc_code_unique UNIQUE (ICD9_CODE), 233 | CONSTRAINT d_icd_proc_rowid_pk PRIMARY KEY (ROW_ID) 234 | ) ; 235 | 236 | -------------------------------------------------------- 237 | -- DDL for Table D_ITEMS 238 | -------------------------------------------------------- 239 | 240 | DROP TABLE IF EXISTS D_ITEMS; 241 | CREATE TABLE D_ITEMS 242 | ( ROW_ID INT NOT NULL, 243 | ITEMID INT NOT NULL, 244 | LABEL VARCHAR(200), 245 | ABBREVIATION VARCHAR(100), 246 | DBSOURCE VARCHAR(20), 247 | LINKSTO VARCHAR(50), 248 | CATEGORY VARCHAR(100), 249 | UNITNAME VARCHAR(100), 250 | PARAM_TYPE VARCHAR(30), 251 | CONCEPTID INT, 252 | CONSTRAINT ditems_itemid_unique UNIQUE (ITEMID), 253 | CONSTRAINT ditems_rowid_pk PRIMARY KEY (ROW_ID) 254 | ) ; 255 | 256 | -------------------------------------------------------- 257 | -- DDL for Table D_LABITEMS 258 | -------------------------------------------------------- 259 | 260 | DROP TABLE IF EXISTS D_LABITEMS; 261 | CREATE TABLE D_LABITEMS 262 | ( ROW_ID INT NOT NULL, 263 | ITEMID INT NOT NULL, 264 | LABEL VARCHAR(100) NOT NULL, 265 | FLUID VARCHAR(100) NOT NULL, 266 | CATEGORY VARCHAR(100) NOT NULL, 267 | LOINC_CODE VARCHAR(100), 268 | CONSTRAINT dlabitems_itemid_unique UNIQUE (ITEMID), 269 | CONSTRAINT dlabitems_rowid_pk PRIMARY KEY (ROW_ID) 270 | ) ; 271 | 272 | -------------------------------------------------------- 273 | -- DDL for Table ICUSTAYS 274 | -------------------------------------------------------- 275 | 276 | DROP TABLE IF EXISTS ICUSTAYS; 277 | CREATE TABLE ICUSTAYS 278 | ( ROW_ID INT NOT NULL, 279 | SUBJECT_ID INT NOT NULL, 280 | HADM_ID INT NOT NULL, 281 | ICUSTAY_ID INT NOT NULL, 282 | DBSOURCE VARCHAR(20) NOT NULL, 283 | FIRST_CAREUNIT VARCHAR(20) NOT NULL, 284 | LAST_CAREUNIT VARCHAR(20) NOT NULL, 285 | FIRST_WARDID SMALLINT NOT NULL, 286 | LAST_WARDID SMALLINT NOT NULL, 287 | INTIME TIMESTAMP(0) NOT NULL, 288 | OUTTIME TIMESTAMP(0), 289 | LOS DOUBLE PRECISION, 290 | CONSTRAINT icustay_icustayid_unique UNIQUE (ICUSTAY_ID), 291 | CONSTRAINT icustay_rowid_pk PRIMARY KEY (ROW_ID) 292 | ) ; 293 | 294 | -------------------------------------------------------- 295 | -- DDL for Table INPUTEVENTS_CV 296 | -------------------------------------------------------- 297 | 298 | DROP TABLE IF EXISTS INPUTEVENTS_CV; 299 | CREATE TABLE INPUTEVENTS_CV 300 | ( ROW_ID INT NOT NULL, 301 | SUBJECT_ID INT NOT NULL, 302 | HADM_ID INT, 303 | ICUSTAY_ID INT, 304 | CHARTTIME TIMESTAMP(0), 305 | ITEMID INT, 306 | AMOUNT DOUBLE PRECISION, 307 | AMOUNTUOM VARCHAR(30), 308 | RATE DOUBLE PRECISION, 309 | RATEUOM VARCHAR(30), 310 | STORETIME TIMESTAMP(0), 311 | CGID INT, 312 | ORDERID INT, 313 | LINKORDERID INT, 314 | STOPPED VARCHAR(30), 315 | NEWBOTTLE INT, 316 | ORIGINALAMOUNT DOUBLE PRECISION, 317 | ORIGINALAMOUNTUOM VARCHAR(30), 318 | ORIGINALROUTE VARCHAR(30), 319 | ORIGINALRATE DOUBLE PRECISION, 320 | ORIGINALRATEUOM VARCHAR(30), 321 | ORIGINALSITE VARCHAR(30), 322 | CONSTRAINT inputevents_cv_rowid_pk PRIMARY KEY (ROW_ID) 323 | ) ; 324 | 325 | -------------------------------------------------------- 326 | -- DDL for Table INPUTEVENTS_MV 327 | -------------------------------------------------------- 328 | 329 | DROP TABLE IF EXISTS INPUTEVENTS_MV; 330 | CREATE TABLE INPUTEVENTS_MV 331 | ( ROW_ID INT NOT NULL, 332 | SUBJECT_ID INT NOT NULL, 333 | HADM_ID INT, 334 | ICUSTAY_ID INT, 335 | STARTTIME TIMESTAMP(0), 336 | ENDTIME TIMESTAMP(0), 337 | ITEMID INT, 338 | AMOUNT DOUBLE PRECISION, 339 | AMOUNTUOM VARCHAR(30), 340 | RATE DOUBLE PRECISION, 341 | RATEUOM VARCHAR(30), 342 | STORETIME TIMESTAMP(0), 343 | CGID INT, 344 | ORDERID INT, 345 | LINKORDERID INT, 346 | ORDERCATEGORYNAME VARCHAR(100), 347 | SECONDARYORDERCATEGORYNAME VARCHAR(100), 348 | ORDERCOMPONENTTYPEDESCRIPTION VARCHAR(200), 349 | ORDERCATEGORYDESCRIPTION VARCHAR(50), 350 | PATIENTWEIGHT DOUBLE PRECISION, 351 | TOTALAMOUNT DOUBLE PRECISION, 352 | TOTALAMOUNTUOM VARCHAR(50), 353 | ISOPENBAG SMALLINT, 354 | CONTINUEINNEXTDEPT SMALLINT, 355 | CANCELREASON SMALLINT, 356 | STATUSDESCRIPTION VARCHAR(30), 357 | COMMENTS_EDITEDBY VARCHAR(30), 358 | COMMENTS_CANCELEDBY VARCHAR(40), 359 | COMMENTS_DATE TIMESTAMP(0), 360 | ORIGINALAMOUNT DOUBLE PRECISION, 361 | ORIGINALRATE DOUBLE PRECISION, 362 | CONSTRAINT inputevents_mv_rowid_pk PRIMARY KEY (ROW_ID) 363 | ) ; 364 | 365 | -------------------------------------------------------- 366 | -- DDL for Table LABEVENTS 367 | -------------------------------------------------------- 368 | 369 | DROP TABLE IF EXISTS LABEVENTS; 370 | CREATE TABLE LABEVENTS 371 | ( ROW_ID INT NOT NULL, 372 | SUBJECT_ID INT NOT NULL, 373 | HADM_ID INT, 374 | ITEMID INT NOT NULL, 375 | CHARTTIME TIMESTAMP(0), 376 | VALUE VARCHAR(200), 377 | VALUENUM DOUBLE PRECISION, 378 | VALUEUOM VARCHAR(20), 379 | FLAG VARCHAR(20), 380 | CONSTRAINT labevents_rowid_pk PRIMARY KEY (ROW_ID) 381 | ) ; 382 | 383 | -------------------------------------------------------- 384 | -- DDL for Table MICROBIOLOGYEVENTS 385 | -------------------------------------------------------- 386 | 387 | DROP TABLE IF EXISTS MICROBIOLOGYEVENTS; 388 | CREATE TABLE MICROBIOLOGYEVENTS 389 | ( ROW_ID INT NOT NULL, 390 | SUBJECT_ID INT NOT NULL, 391 | HADM_ID INT, 392 | CHARTDATE TIMESTAMP(0), 393 | CHARTTIME TIMESTAMP(0), 394 | SPEC_ITEMID INT, 395 | SPEC_TYPE_DESC VARCHAR(100), 396 | ORG_ITEMID INT, 397 | ORG_NAME VARCHAR(100), 398 | ISOLATE_NUM SMALLINT, 399 | AB_ITEMID INT, 400 | AB_NAME VARCHAR(30), 401 | DILUTION_TEXT VARCHAR(10), 402 | DILUTION_COMPARISON VARCHAR(20), 403 | DILUTION_VALUE DOUBLE PRECISION, 404 | INTERPRETATION VARCHAR(5), 405 | CONSTRAINT micro_rowid_pk PRIMARY KEY (ROW_ID) 406 | ) ; 407 | 408 | -------------------------------------------------------- 409 | -- DDL for Table NOTEEVENTS 410 | -------------------------------------------------------- 411 | 412 | DROP TABLE IF EXISTS NOTEEVENTS; 413 | CREATE TABLE NOTEEVENTS 414 | ( ROW_ID INT NOT NULL, 415 | SUBJECT_ID INT NOT NULL, 416 | HADM_ID INT, 417 | CHARTDATE TIMESTAMP(0), 418 | CHARTTIME TIMESTAMP(0), 419 | STORETIME TIMESTAMP(0), 420 | CATEGORY VARCHAR(50), 421 | DESCRIPTION VARCHAR(255), 422 | CGID INT, 423 | ISERROR CHAR(1), 424 | TEXT TEXT, 425 | CONSTRAINT noteevents_rowid_pk PRIMARY KEY (ROW_ID) 426 | ) ; 427 | 428 | -------------------------------------------------------- 429 | -- DDL for Table OUTPUTEVENTS 430 | -------------------------------------------------------- 431 | 432 | DROP TABLE IF EXISTS OUTPUTEVENTS; 433 | CREATE TABLE OUTPUTEVENTS 434 | ( ROW_ID INT NOT NULL, 435 | SUBJECT_ID INT NOT NULL, 436 | HADM_ID INT, 437 | ICUSTAY_ID INT, 438 | CHARTTIME TIMESTAMP(0), 439 | ITEMID INT, 440 | VALUE DOUBLE PRECISION, 441 | VALUEUOM VARCHAR(30), 442 | STORETIME TIMESTAMP(0), 443 | CGID INT, 444 | STOPPED VARCHAR(30), 445 | NEWBOTTLE CHAR(1), 446 | ISERROR INT, 447 | CONSTRAINT outputevents_cv_rowid_pk PRIMARY KEY (ROW_ID) 448 | ) ; 449 | 450 | -------------------------------------------------------- 451 | -- DDL for Table PATIENTS 452 | -------------------------------------------------------- 453 | 454 | DROP TABLE IF EXISTS PATIENTS; 455 | CREATE TABLE PATIENTS 456 | ( ROW_ID INT NOT NULL, 457 | SUBJECT_ID INT NOT NULL, 458 | GENDER VARCHAR(5) NOT NULL, 459 | DOB TIMESTAMP(0) NOT NULL, 460 | DOD TIMESTAMP(0), 461 | DOD_HOSP TIMESTAMP(0), 462 | DOD_SSN TIMESTAMP(0), 463 | EXPIRE_FLAG VARCHAR(5) NOT NULL, 464 | CONSTRAINT pat_subid_unique UNIQUE (SUBJECT_ID), 465 | CONSTRAINT pat_rowid_pk PRIMARY KEY (ROW_ID) 466 | ) ; 467 | 468 | -------------------------------------------------------- 469 | -- DDL for Table PRESCRIPTIONS 470 | -------------------------------------------------------- 471 | 472 | DROP TABLE IF EXISTS PRESCRIPTIONS; 473 | CREATE TABLE PRESCRIPTIONS 474 | ( ROW_ID INT NOT NULL, 475 | SUBJECT_ID INT NOT NULL, 476 | HADM_ID INT NOT NULL, 477 | ICUSTAY_ID INT, 478 | STARTTIME TIMESTAMP(0), 479 | ENDTIME TIMESTAMP(0), 480 | DRUG_TYPE VARCHAR(100) NOT NULL, 481 | DRUG VARCHAR(100) NOT NULL, 482 | DRUG_NAME_POE VARCHAR(100), 483 | DRUG_NAME_GENERIC VARCHAR(100), 484 | FORMULARY_DRUG_CD VARCHAR(120), 485 | GSN VARCHAR(200), 486 | NDC VARCHAR(120), 487 | PROD_STRENGTH VARCHAR(120), 488 | DOSE_VAL_RX VARCHAR(120), 489 | DOSE_UNIT_RX VARCHAR(120), 490 | FORM_VAL_DISP VARCHAR(120), 491 | FORM_UNIT_DISP VARCHAR(120), 492 | ROUTE VARCHAR(120), 493 | CONSTRAINT prescription_rowid_pk PRIMARY KEY (ROW_ID) 494 | ) ; 495 | 496 | -------------------------------------------------------- 497 | -- DDL for Table PROCEDUREEVENTS_MV 498 | -------------------------------------------------------- 499 | 500 | DROP TABLE IF EXISTS PROCEDUREEVENTS_MV; 501 | CREATE TABLE PROCEDUREEVENTS_MV 502 | ( ROW_ID INT NOT NULL, 503 | SUBJECT_ID INT NOT NULL, 504 | HADM_ID INT NOT NULL, 505 | ICUSTAY_ID INT, 506 | STARTTIME TIMESTAMP(0), 507 | ENDTIME TIMESTAMP(0), 508 | ITEMID INT, 509 | VALUE DOUBLE PRECISION, 510 | VALUEUOM VARCHAR(30), 511 | LOCATION VARCHAR(30), 512 | LOCATIONCATEGORY VARCHAR(30), 513 | STORETIME TIMESTAMP(0), 514 | CGID INT, 515 | ORDERID INT, 516 | LINKORDERID INT, 517 | ORDERCATEGORYNAME VARCHAR(100), 518 | SECONDARYORDERCATEGORYNAME VARCHAR(100), 519 | ORDERCATEGORYDESCRIPTION VARCHAR(50), 520 | ISOPENBAG SMALLINT, 521 | CONTINUEINNEXTDEPT SMALLINT, 522 | CANCELREASON SMALLINT, 523 | STATUSDESCRIPTION VARCHAR(30), 524 | COMMENTS_EDITEDBY VARCHAR(30), 525 | COMMENTS_CANCELEDBY VARCHAR(30), 526 | COMMENTS_DATE TIMESTAMP(0), 527 | CONSTRAINT procedureevents_mv_rowid_pk PRIMARY KEY (ROW_ID) 528 | ) ; 529 | 530 | -------------------------------------------------------- 531 | -- DDL for Table PROCEDURES_ICD 532 | -------------------------------------------------------- 533 | 534 | DROP TABLE IF EXISTS PROCEDURES_ICD; 535 | CREATE TABLE PROCEDURES_ICD 536 | ( ROW_ID INT NOT NULL, 537 | SUBJECT_ID INT NOT NULL, 538 | HADM_ID INT NOT NULL, 539 | SEQ_NUM INT NOT NULL, 540 | ICD9_CODE VARCHAR(20) NOT NULL, 541 | CONSTRAINT proceduresicd_rowid_pk PRIMARY KEY (ROW_ID) 542 | ) ; 543 | 544 | -------------------------------------------------------- 545 | -- DDL for Table SERVICES 546 | -------------------------------------------------------- 547 | 548 | DROP TABLE IF EXISTS SERVICES; 549 | CREATE TABLE SERVICES 550 | ( ROW_ID INT NOT NULL, 551 | SUBJECT_ID INT NOT NULL, 552 | HADM_ID INT NOT NULL, 553 | TRANSFERTIME TIMESTAMP(0) NOT NULL, 554 | PREV_SERVICE VARCHAR(20), 555 | CURR_SERVICE VARCHAR(20), 556 | CONSTRAINT services_rowid_pk PRIMARY KEY (ROW_ID) 557 | ) ; 558 | 559 | -------------------------------------------------------- 560 | -- DDL for Table TRANSFERS 561 | -------------------------------------------------------- 562 | 563 | DROP TABLE IF EXISTS TRANSFERS; 564 | CREATE TABLE TRANSFERS 565 | ( ROW_ID INT NOT NULL, 566 | SUBJECT_ID INT NOT NULL, 567 | HADM_ID INT NOT NULL, 568 | ICUSTAY_ID INT, 569 | DBSOURCE VARCHAR(20) NOT NULL, 570 | EVENTTYPE VARCHAR(20), 571 | PREV_CAREUNIT VARCHAR(20), 572 | CURR_CAREUNIT VARCHAR(20), 573 | PREV_WARDID SMALLINT, 574 | CURR_WARDID SMALLINT, 575 | INTIME TIMESTAMP(0), 576 | OUTTIME TIMESTAMP(0), 577 | LOS DOUBLE PRECISION, 578 | CONSTRAINT transfers_rowid_pk PRIMARY KEY (ROW_ID) 579 | ) ; 580 | 581 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | 341 | --------------------------------------------------------------------------------