You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: concepts/README.md
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,12 +29,12 @@ This can be done as follows:
29
29
30
30
1. Open a terminal in the `concepts` folder.
31
31
2. Run [postgres-functions.sql](postgres-functions.sql).
32
-
* e.g. `psql -f postgres-functions.sql`
33
-
* This script creates functions which emulate BigQuery syntax.
32
+
* e.g. `psql -f postgres-functions.sql`
33
+
* This script creates functions which emulate BigQuery syntax.
34
34
3. Run [postgres_make_concepts.sh](postgres_make_concepts.sh).
35
-
* e.g. `bash postgres_make_concepts.sh`
36
-
* This file runs the scripts after applying a few regular expressions which convert table references and date calculations appropriately.
37
-
* This file generates all concepts on the `public` schema.
35
+
* e.g. `bash postgres_make_concepts.sh`
36
+
* This file runs the scripts after applying a few regular expressions which convert table references and date calculations appropriately.
37
+
* This file generates all concepts on the `public` schema.
38
38
39
39
If you do not have access to a PostgreSQL database with MIMIC, you can read more about building the data within one in the [buildmimic/postgres](https://github.com/MIT-LCP/mimic-code/tree/master/buildmimic/postgres) folder.
40
40
@@ -43,17 +43,17 @@ If you do not have access to a PostgreSQL database with MIMIC, you can read more
43
43
On Windows, it is a bit more complex to generate the concepts in the PostgreSQL database. The approach relies on using \*nix command line tools which are not available by default in a Windows installation. Instead, we have adapted the script into a `.bat` file which relies on the Windows Subsystem for Linux in order to run the shell commands. The steps are:
44
44
45
45
1. Install the [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10).
46
-
* If you don't have a preference, follow the steps to install a Ubuntu system. The bat file was tested with Ubuntu, though the commands should work with any flavor of \*nix since we rely on the utils rather than the kernel.
46
+
* If you don't have a preference, follow the steps to install a Ubuntu system. The bat file was tested with Ubuntu, though the commands should work with any flavor of \*nix since we rely on the utils rather than the kernel.
47
47
2. Verify you can use the wsl.exe utilities in command prompt.
48
-
* Go to run and type `cmd`, or type "command prompt" in the search.
49
-
* Run `wsl.exe echo "hi"` - this should print out `hi` back to you
48
+
* Go to run and type `cmd`, or type "command prompt" in the search.
49
+
* Run `wsl.exe echo "hi"` - this should print out `hi` back to you
50
50
3. Change to your local folder where these concepts are stored
51
-
* e.g. `cd C:\Tools\mimic-code-master\concepts`
51
+
* e.g. `cd C:\Tools\mimic-code-master\concepts`
52
52
4. Modify the .bat file: update the `CONNSTR` and `PSQL_PATH` variables.
53
-
* Replace `INSERT_PASSWORD_HERE` in `CONNSTR` with your password; or remove it if you have a `.pgpass` file or other form of authentication. If you have a different username or database location, be sure to update those as well.
54
-
* Change `PSQL_PATH` to point to your `psql.exe` file. It is currently set to the default location for a PostgreSQL 13 installation.
53
+
* Replace `INSERT_PASSWORD_HERE` in `CONNSTR` with your password; or remove it if you have a `.pgpass` file or other form of authentication. If you have a different username or database location, be sure to update those as well.
54
+
* Change `PSQL_PATH` to point to your `psql.exe` file. It is currently set to the default location for a PostgreSQL 13 installation.
55
55
5. Run the .bat file
56
-
* In the command prompt, type `postgres_make_concepts_windows.bat`
56
+
* In the command prompt, type `postgres_make_concepts_windows.bat`
57
57
58
58
The script echos the commands and the outputs as they run. If it is running successfully, you should see a `SELECT` statement after each command, with the number of rows generated in the table.
59
59
@@ -65,13 +65,13 @@ First, generate the necessary functions as above, by running `postgres-functions
65
65
Once that's done, you need to do the following text replacements in all the SQL files:
66
66
67
67
1. Replace ````physionet-data.mimiciii_clinical.<table_name>````, ````physionet-data.mimiciii_derived.<table_name>```` , and ````physionet-data.mimiciii_notes.<table_name>```` with just `<table_name>`.
68
-
* This is done by the `REGEX_SCHEMA` variable in the `postgres_make_concepts.sh` script.
69
-
* Ideally you should set your search path with `set search_path to public,mimiciii;`. This will create the concepts on `public`, and read data from `mimiciii`. This distinction isn't strictly necessary, but many find it useful.
68
+
* This is done by the `REGEX_SCHEMA` variable in the `postgres_make_concepts.sh` script.
69
+
* Ideally you should set your search path with `set search_path to public,mimiciii;`. This will create the concepts on `public`, and read data from `mimiciii`. This distinction isn't strictly necessary, but many find it useful.
70
70
2. Replace `DATETIME_DIFF(date1, date2, DATE_PART)` with `DATETIME_DIFF(date1, date2, 'DATE_PART')`.
71
-
* This adds single quotes around any `DATE_PART`, which is required by PostgreSQL.
72
-
* This is done by the `REGEX_DATETIME_DIFF ` variable in the `postgres_make_concepts.sh` script.
71
+
* This adds single quotes around any `DATE_PART`, which is required by PostgreSQL.
72
+
* This is done by the `REGEX_DATETIME_DIFF ` variable in the `postgres_make_concepts.sh` script.
73
73
3. Add a create table statement at the top of the file, e.g. if the file is named `echo_data.sql`, add `CREATE TABLE echo_data AS` at the top of the file.
74
-
* This is done by the `echo` calls in the shell script.
74
+
* This is done by the `echo` calls in the shell script.
75
75
4. Run each file individually in the order specified by the make concepts script.
76
76
77
77
The above steps replicate what is done in the shell script (postgres_make_concepts.sh).
0 commit comments