From efa9eb700674d1b9185df1532d15f737805f2b93 Mon Sep 17 00:00:00 2001 From: psy01212 <34636332+psy01212@users.noreply.github.com> Date: Wed, 10 Jan 2018 14:31:42 -0500 Subject: [PATCH 01/15] Creating new directory --- concepts/Code_status/Readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 concepts/Code_status/Readme.md diff --git a/concepts/Code_status/Readme.md b/concepts/Code_status/Readme.md new file mode 100644 index 0000000..0601a09 --- /dev/null +++ b/concepts/Code_status/Readme.md @@ -0,0 +1 @@ +tbd From 2b095a71573d442594e335dcc1126b8376f78a33 Mon Sep 17 00:00:00 2001 From: psy01212 <34636332+psy01212@users.noreply.github.com> Date: Wed, 7 Feb 2018 12:21:55 -0500 Subject: [PATCH 02/15] Add files via upload --- .../Code_status/carePlan_getItemValues.Rmd | 34 ++++++++++ .../Code_status/carePlan_getPatientCode.Rmd | 64 +++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 concepts/Code_status/carePlan_getItemValues.Rmd create mode 100644 concepts/Code_status/carePlan_getPatientCode.Rmd diff --git a/concepts/Code_status/carePlan_getItemValues.Rmd b/concepts/Code_status/carePlan_getItemValues.Rmd new file mode 100644 index 0000000..71582c3 --- /dev/null +++ b/concepts/Code_status/carePlan_getItemValues.Rmd @@ -0,0 +1,34 @@ +--- +title: "carePlan_getItemValues" +output: html_document +--- + +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +``` + +Connect to database. + +```{r} +require("RPostgreSQL") +drv <- dbDriver("PostgreSQL") +con <- dbConnect(drv, dbname = "eicu", + host = "localhost", port = 5432, + user = "josephpark", password = rstudioapi::askForPassword("Database password"), + options = "--search_path=eicu") +dbExistsTable(con, "patient") +``` + +Write cplitemvalues to file "possible_status" for inspection on which items indicate patient code status. +All cplitemvalues that were chosen were in cplgroup = 'Care Limitation' (all cplitemvalues in this cplgroup was used), + except cplitemvalue = 'End of life', which was in cplgroup = 'Ordered Protocols'. + +```{r, connection = con} +library(dplyr) +carePlanGeneral_tbl <- tbl(con, "careplangeneral") +possible_status <- carePlanGeneral_tbl %>% + group_by(cplitemvalue) %>% + summarize(n=n()) %>% + arrange(desc(n)) +write.csv(possible_status, "possible_status.csv") +``` \ No newline at end of file diff --git a/concepts/Code_status/carePlan_getPatientCode.Rmd b/concepts/Code_status/carePlan_getPatientCode.Rmd new file mode 100644 index 0000000..e1c9aaf --- /dev/null +++ b/concepts/Code_status/carePlan_getPatientCode.Rmd @@ -0,0 +1,64 @@ +--- +title: "carePlan_getPatientCode" +output: html_document +--- + +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +``` + +Connect to database. + +```{r} +require("RPostgreSQL") +drv <- dbDriver("PostgreSQL") +con <- dbConnect(drv, dbname = "eicu", + host = "localhost", port = 5432, + user = "josephpark", password = rstudioapi::askForPassword("Database password"), + options = "--search_path=eicu") +dbExistsTable(con, "patient") +``` + +After inspecting table generated from careplan_getitemvalues.Rmd, the values in cpitemvalue_code were selected to relate to patient code status. + +```{r, connection = con} +library(dplyr) +carePlanGeneral_tbl <- tbl(con, "careplangeneral") +cplitemvalue_code = c('Full therapy', 'Do not resuscitate', 'No CPR', 'No intubation', 'Comfort measures only', + 'No cardioversion', 'No vasopressors/inotropes', 'No augmentation of care', + 'End of life', 'No blood products', 'No blood draws', 'Advance directives') +``` + +Generate table that lists the patient along with code status. + +```{r, connection = con} +patientCodeStatus <- carePlanGeneral_tbl %>% + filter(cplitemvalue %in% cplitemvalue_code) %>% + select(patientunitstayid, cplitemoffset, cplgroup, cplitemvalue) %>% + arrange(patientunitstayid, cplitemoffset, cplitemvalue) %>% + group_by(patientunitstayid, cplitemoffset) %>% + summarize(cplitemvalue = paste(cplitemvalue, collapse=", ")) +patientCodeStatus +``` + +Output the file as a csv. + +```{r, connection = con} +write.csv(patientCodeStatus, "patient_status_table.csv", row.names=FALSE) +``` + +Optional: sorts patients by which patient had the most number of status updates. + +```{r, connection = con,eval=FALSE} +patientCodeStatus %>% + group_by(patientunitstayid) %>% + summarize(n = n()) %>% + arrange(desc(n)) +``` + +Example of a patient. This patient was strange with both full therapy and no CPR at the same time. + +```{r, connection = con,eval=FALSE} +patientCodeStatus %>% + filter(patientunitstayid == 266999) +``` From d5e66ac244ada744b792a02981ca8f766cbefc35 Mon Sep 17 00:00:00 2001 From: psy01212 <34636332+psy01212@users.noreply.github.com> Date: Thu, 15 Feb 2018 10:00:19 -0500 Subject: [PATCH 03/15] Added SQL files --- concepts/Code_status/carePlan_getItemValues.sql | 4 ++++ concepts/Code_status/carePlan_getPatientCode.sql | 8 ++++++++ 2 files changed, 12 insertions(+) create mode 100644 concepts/Code_status/carePlan_getItemValues.sql create mode 100644 concepts/Code_status/carePlan_getPatientCode.sql diff --git a/concepts/Code_status/carePlan_getItemValues.sql b/concepts/Code_status/carePlan_getItemValues.sql new file mode 100644 index 0000000..5af8825 --- /dev/null +++ b/concepts/Code_status/carePlan_getItemValues.sql @@ -0,0 +1,4 @@ +SELECT "cplitemvalue", count(*) AS "n" +FROM "careplangeneral" +GROUP BY "cplitemvalue" +ORDER BY "n" DESC \ No newline at end of file diff --git a/concepts/Code_status/carePlan_getPatientCode.sql b/concepts/Code_status/carePlan_getPatientCode.sql new file mode 100644 index 0000000..da01046 --- /dev/null +++ b/concepts/Code_status/carePlan_getPatientCode.sql @@ -0,0 +1,8 @@ +SELECT "patientunitstayid", "cplitemoffset", string_agg("cplitemvalue", ', ') AS "cplitemvalue" +FROM (SELECT * +FROM (SELECT "patientunitstayid" AS "patientunitstayid", "cplitemoffset" AS "cplitemoffset", "cplgroup" AS "cplgroup", "cplitemvalue" AS "cplitemvalue" +FROM (SELECT * +FROM "careplangeneral" +WHERE ("cplitemvalue" IN ('Full therapy', 'Do not resuscitate', 'No CPR', 'No intubation', 'Comfort measures only', 'No cardioversion', 'No vasopressors/inotropes', 'No augmentation of care', 'End of life', 'No blood products', 'No blood draws', 'Advance directives'))) "ivtmaaxwzk") "oytldaespk" +ORDER BY "patientunitstayid", "cplitemoffset", "cplitemvalue") "vrxthajevr" +GROUP BY "patientunitstayid", "cplitemoffset" \ No newline at end of file From 0f8b6ea0b76bb2b6df11ac721f624b77095a0bf8 Mon Sep 17 00:00:00 2001 From: psy01212 <34636332+psy01212@users.noreply.github.com> Date: Thu, 15 Feb 2018 10:48:25 -0500 Subject: [PATCH 04/15] Added readme --- concepts/Code_status/Readme.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/concepts/Code_status/Readme.md b/concepts/Code_status/Readme.md index 0601a09..6641fe6 100644 --- a/concepts/Code_status/Readme.md +++ b/concepts/Code_status/Readme.md @@ -1 +1,4 @@ -tbd +The files here create a patient table that tracks the changes to the patient code status. There are two versions of the files: .Rmd and .sql. The Rmd version is the supported version, while the SQL version is not supported and was added just as a template. + +carePlan_getItemValues creates a csv that contains all the cplitemvalues for inspection, in order to choose the values that correspond to patient code status. +carePlan_getPatientCode creates a table that lists the recorded patient code status at a certain time (offset). From 32bd42db10571bbfdc3a66e9070c6c4bacf4e703 Mon Sep 17 00:00:00 2001 From: psy01212 <34636332+psy01212@users.noreply.github.com> Date: Thu, 15 Feb 2018 10:49:40 -0500 Subject: [PATCH 05/15] Added not supported comments to sql files --- concepts/Code_status/carePlan_getItemValues.sql | 2 ++ concepts/Code_status/carePlan_getPatientCode.sql | 2 ++ 2 files changed, 4 insertions(+) diff --git a/concepts/Code_status/carePlan_getItemValues.sql b/concepts/Code_status/carePlan_getItemValues.sql index 5af8825..49cf917 100644 --- a/concepts/Code_status/carePlan_getItemValues.sql +++ b/concepts/Code_status/carePlan_getItemValues.sql @@ -1,3 +1,5 @@ +-- NOT SUPPORTED + SELECT "cplitemvalue", count(*) AS "n" FROM "careplangeneral" GROUP BY "cplitemvalue" diff --git a/concepts/Code_status/carePlan_getPatientCode.sql b/concepts/Code_status/carePlan_getPatientCode.sql index da01046..4fd87f8 100644 --- a/concepts/Code_status/carePlan_getPatientCode.sql +++ b/concepts/Code_status/carePlan_getPatientCode.sql @@ -1,3 +1,5 @@ +-- NOT SUPPORTED + SELECT "patientunitstayid", "cplitemoffset", string_agg("cplitemvalue", ', ') AS "cplitemvalue" FROM (SELECT * FROM (SELECT "patientunitstayid" AS "patientunitstayid", "cplitemoffset" AS "cplitemoffset", "cplgroup" AS "cplgroup", "cplitemvalue" AS "cplitemvalue" From 766ac8b9bcb9f24b6ccd5ba9719d44911f7d6650 Mon Sep 17 00:00:00 2001 From: psy01212 <34636332+psy01212@users.noreply.github.com> Date: Wed, 21 Feb 2018 03:31:33 -0500 Subject: [PATCH 06/15] Added materialized view in sql getPatientCode --- concepts/Code_status/carePlan_getPatientCode.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/concepts/Code_status/carePlan_getPatientCode.sql b/concepts/Code_status/carePlan_getPatientCode.sql index 4fd87f8..c474ec2 100644 --- a/concepts/Code_status/carePlan_getPatientCode.sql +++ b/concepts/Code_status/carePlan_getPatientCode.sql @@ -1,5 +1,8 @@ -- NOT SUPPORTED +DROP MATERIALIZED VIEW IF EXISTS patientCodeStatus +CREATE MATERIALIZED VIEW patientCodeStatus AS + SELECT "patientunitstayid", "cplitemoffset", string_agg("cplitemvalue", ', ') AS "cplitemvalue" FROM (SELECT * FROM (SELECT "patientunitstayid" AS "patientunitstayid", "cplitemoffset" AS "cplitemoffset", "cplgroup" AS "cplgroup", "cplitemvalue" AS "cplitemvalue" From 5349bfe58c20a3965d27877fae8266fa0c55dfbd Mon Sep 17 00:00:00 2001 From: psy01212 <34636332+psy01212@users.noreply.github.com> Date: Fri, 2 Mar 2018 13:47:54 -0500 Subject: [PATCH 07/15] fixed semicolon errors --- concepts/Code_status/carePlan_getPatientCode.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/concepts/Code_status/carePlan_getPatientCode.sql b/concepts/Code_status/carePlan_getPatientCode.sql index c474ec2..82f127b 100644 --- a/concepts/Code_status/carePlan_getPatientCode.sql +++ b/concepts/Code_status/carePlan_getPatientCode.sql @@ -1,6 +1,6 @@ -- NOT SUPPORTED -DROP MATERIALIZED VIEW IF EXISTS patientCodeStatus +DROP MATERIALIZED VIEW IF EXISTS patientCodeStatus; CREATE MATERIALIZED VIEW patientCodeStatus AS SELECT "patientunitstayid", "cplitemoffset", string_agg("cplitemvalue", ', ') AS "cplitemvalue" @@ -10,4 +10,4 @@ FROM (SELECT * FROM "careplangeneral" WHERE ("cplitemvalue" IN ('Full therapy', 'Do not resuscitate', 'No CPR', 'No intubation', 'Comfort measures only', 'No cardioversion', 'No vasopressors/inotropes', 'No augmentation of care', 'End of life', 'No blood products', 'No blood draws', 'Advance directives'))) "ivtmaaxwzk") "oytldaespk" ORDER BY "patientunitstayid", "cplitemoffset", "cplitemvalue") "vrxthajevr" -GROUP BY "patientunitstayid", "cplitemoffset" \ No newline at end of file +GROUP BY "patientunitstayid", "cplitemoffset"; \ No newline at end of file From a26dab32d386b16dbbebdeed40620f5c79141727 Mon Sep 17 00:00:00 2001 From: psy01212 <34636332+psy01212@users.noreply.github.com> Date: Fri, 2 Mar 2018 13:54:25 -0500 Subject: [PATCH 08/15] getItemValues.sql creates a materialized view --- concepts/Code_status/carePlan_getItemValues.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/concepts/Code_status/carePlan_getItemValues.sql b/concepts/Code_status/carePlan_getItemValues.sql index 49cf917..8d5acfe 100644 --- a/concepts/Code_status/carePlan_getItemValues.sql +++ b/concepts/Code_status/carePlan_getItemValues.sql @@ -1,6 +1,9 @@ -- NOT SUPPORTED +DROP MATERIALIZED VIEW IF EXISTS possibleCodeStatus; +CREATE MATERIALIZED VIEW possibleCodeStatus AS + SELECT "cplitemvalue", count(*) AS "n" FROM "careplangeneral" GROUP BY "cplitemvalue" -ORDER BY "n" DESC \ No newline at end of file +ORDER BY "n" DESC; \ No newline at end of file From 6ffa417aafb8777ab260add132bc057956320858 Mon Sep 17 00:00:00 2001 From: psy01212 <34636332+psy01212@users.noreply.github.com> Date: Sat, 3 Mar 2018 17:23:41 -0500 Subject: [PATCH 09/15] Update Readme.md --- concepts/Code_status/Readme.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/concepts/Code_status/Readme.md b/concepts/Code_status/Readme.md index 6641fe6..4c4ed7b 100644 --- a/concepts/Code_status/Readme.md +++ b/concepts/Code_status/Readme.md @@ -1,4 +1,9 @@ -The files here create a patient table that tracks the changes to the patient code status. There are two versions of the files: .Rmd and .sql. The Rmd version is the supported version, while the SQL version is not supported and was added just as a template. +The files here create a patient table that tracks the changes to the patient code status. The careplangeneral table was used instead of careplaneol because careplaneol had much less recorded patients, and the type of code status change was recorded in careplangeneral. There are two versions of the files: .Rmd and .sql. The Rmd version is the supported version, while the SQL version is not supported and was added just as a template. -carePlan_getItemValues creates a csv that contains all the cplitemvalues for inspection, in order to choose the values that correspond to patient code status. -carePlan_getPatientCode creates a table that lists the recorded patient code status at a certain time (offset). +Rmd: + - carePlan_getItemValues creates a csv that contains all the cplitemvalues for inspection, in order to choose the values that correspond to patient code status. + - carePlan_getPatientCode creates a table that lists the recorded patient code status at a certain time (offset). + +SQL: + - carePlan_getItemValues creates a materialized view that lists all the cplitemvalues (possible statuses) in descending order of the counts +  - carePlan_getPatientCode creates a materialized view that lists the recorded patient code status at a certain time (offset). From 13bc85e0a8312a10136a28ae5e0251dbaeb33fe0 Mon Sep 17 00:00:00 2001 From: Joseph Park <34636332+psy01212@users.noreply.github.com> Date: Mon, 3 Dec 2018 15:19:56 -0500 Subject: [PATCH 10/15] Added config settings for connecting to database. --- .../Code_status/carePlan_getItemValues.Rmd | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/concepts/Code_status/carePlan_getItemValues.Rmd b/concepts/Code_status/carePlan_getItemValues.Rmd index 71582c3..447ee02 100644 --- a/concepts/Code_status/carePlan_getItemValues.Rmd +++ b/concepts/Code_status/carePlan_getItemValues.Rmd @@ -7,15 +7,27 @@ output: html_document knitr::opts_chunk$set(echo = TRUE) ``` +Load configuration settings. Password requested by rstudioapi. + +```{r} +dbdriver <- 'PostgreSQL' +host <- 'localhost' +port <- '5432' +user <- 'josephpark' +dbname <- 'eicu' +schema <- 'eicu' +options <- paste("--search_path", schema, sep="") +``` + Connect to database. ```{r} require("RPostgreSQL") -drv <- dbDriver("PostgreSQL") -con <- dbConnect(drv, dbname = "eicu", - host = "localhost", port = 5432, - user = "josephpark", password = rstudioapi::askForPassword("Database password"), - options = "--search_path=eicu") +drv <- dbDriver(dbdriver) +con <- dbConnect(drv, dbname = dbname, + host = host, port = port, + user = user, password = rstudioapi::askForPassword("Database password"), + options = options) dbExistsTable(con, "patient") ``` @@ -31,4 +43,4 @@ possible_status <- carePlanGeneral_tbl %>% summarize(n=n()) %>% arrange(desc(n)) write.csv(possible_status, "possible_status.csv") -``` \ No newline at end of file +``` From 26cf2f6185d05743e391fd2d011a9e60a2106338 Mon Sep 17 00:00:00 2001 From: Joseph Park Date: Mon, 3 Dec 2018 15:31:10 -0500 Subject: [PATCH 11/15] Renamed files/directory to only use lowercase --- concepts/{Code_status => code_status}/Readme.md | 8 ++++---- .../carePlan_getPatientCode.sql | 0 .../careplan_getitemvalues.Rmd} | 0 .../careplan_getitemvalues.sql} | 0 .../careplan_getpatientcode.Rmd} | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename concepts/{Code_status => code_status}/Readme.md (74%) rename concepts/{Code_status => code_status}/carePlan_getPatientCode.sql (100%) rename concepts/{Code_status/carePlan_getItemValues.Rmd => code_status/careplan_getitemvalues.Rmd} (100%) rename concepts/{Code_status/carePlan_getItemValues.sql => code_status/careplan_getitemvalues.sql} (100%) rename concepts/{Code_status/carePlan_getPatientCode.Rmd => code_status/careplan_getpatientcode.Rmd} (100%) diff --git a/concepts/Code_status/Readme.md b/concepts/code_status/Readme.md similarity index 74% rename from concepts/Code_status/Readme.md rename to concepts/code_status/Readme.md index 4c4ed7b..1faff60 100644 --- a/concepts/Code_status/Readme.md +++ b/concepts/code_status/Readme.md @@ -1,9 +1,9 @@ The files here create a patient table that tracks the changes to the patient code status. The careplangeneral table was used instead of careplaneol because careplaneol had much less recorded patients, and the type of code status change was recorded in careplangeneral. There are two versions of the files: .Rmd and .sql. The Rmd version is the supported version, while the SQL version is not supported and was added just as a template. Rmd: - - carePlan_getItemValues creates a csv that contains all the cplitemvalues for inspection, in order to choose the values that correspond to patient code status. - - carePlan_getPatientCode creates a table that lists the recorded patient code status at a certain time (offset). + - careplan_getitemvalues creates a csv that contains all the cplitemvalues for inspection, in order to choose the values that correspond to patient code status. + - careplan_getpatientcode creates a table that lists the recorded patient code status at a certain time (offset). SQL: - - carePlan_getItemValues creates a materialized view that lists all the cplitemvalues (possible statuses) in descending order of the counts -  - carePlan_getPatientCode creates a materialized view that lists the recorded patient code status at a certain time (offset). + - careplan_getitemvalues creates a materialized view that lists all the cplitemvalues (possible statuses) in descending order of the counts +  - careplan_getpatientcode creates a materialized view that lists the recorded patient code status at a certain time (offset). diff --git a/concepts/Code_status/carePlan_getPatientCode.sql b/concepts/code_status/carePlan_getPatientCode.sql similarity index 100% rename from concepts/Code_status/carePlan_getPatientCode.sql rename to concepts/code_status/carePlan_getPatientCode.sql diff --git a/concepts/Code_status/carePlan_getItemValues.Rmd b/concepts/code_status/careplan_getitemvalues.Rmd similarity index 100% rename from concepts/Code_status/carePlan_getItemValues.Rmd rename to concepts/code_status/careplan_getitemvalues.Rmd diff --git a/concepts/Code_status/carePlan_getItemValues.sql b/concepts/code_status/careplan_getitemvalues.sql similarity index 100% rename from concepts/Code_status/carePlan_getItemValues.sql rename to concepts/code_status/careplan_getitemvalues.sql diff --git a/concepts/Code_status/carePlan_getPatientCode.Rmd b/concepts/code_status/careplan_getpatientcode.Rmd similarity index 100% rename from concepts/Code_status/carePlan_getPatientCode.Rmd rename to concepts/code_status/careplan_getpatientcode.Rmd From bf803b83a3518cc594464bb503c1e47358467c74 Mon Sep 17 00:00:00 2001 From: Joseph Park Date: Mon, 3 Dec 2018 15:36:33 -0500 Subject: [PATCH 12/15] Renamed to use lowercase --- .../{carePlan_getPatientCode.sql => careplan_getpatientcode.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename concepts/code_status/{carePlan_getPatientCode.sql => careplan_getpatientcode.sql} (100%) diff --git a/concepts/code_status/carePlan_getPatientCode.sql b/concepts/code_status/careplan_getpatientcode.sql similarity index 100% rename from concepts/code_status/carePlan_getPatientCode.sql rename to concepts/code_status/careplan_getpatientcode.sql From f172f8fda71a3d2a6728b3b26aebe0fd313e79e1 Mon Sep 17 00:00:00 2001 From: Joseph Park Date: Mon, 3 Dec 2018 19:27:45 -0500 Subject: [PATCH 13/15] Added explanation of how .sql files were autogenerated --- concepts/code_status/Readme.md | 4 ++-- concepts/code_status/careplan_getitemvalues.Rmd | 2 ++ concepts/code_status/careplan_getitemvalues.sql | 3 ++- concepts/code_status/careplan_getpatientcode.Rmd | 2 ++ concepts/code_status/careplan_getpatientcode.sql | 3 ++- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/concepts/code_status/Readme.md b/concepts/code_status/Readme.md index 1faff60..17fb02c 100644 --- a/concepts/code_status/Readme.md +++ b/concepts/code_status/Readme.md @@ -1,4 +1,4 @@ -The files here create a patient table that tracks the changes to the patient code status. The careplangeneral table was used instead of careplaneol because careplaneol had much less recorded patients, and the type of code status change was recorded in careplangeneral. There are two versions of the files: .Rmd and .sql. The Rmd version is the supported version, while the SQL version is not supported and was added just as a template. +The files here create a patient table that tracks the changes to the patient code status. The careplangeneral table was used instead of careplaneol because careplaneol had much less recorded patients, and the type of code status change was recorded in careplangeneral. There are two versions of the files: .Rmd and .sql. The Rmd version is the supported version, while the SQL version, having been mostly autogenerated using show_query(), is not supported and was added just as a template. Rmd: - careplan_getitemvalues creates a csv that contains all the cplitemvalues for inspection, in order to choose the values that correspond to patient code status. @@ -6,4 +6,4 @@ Rmd: SQL: - careplan_getitemvalues creates a materialized view that lists all the cplitemvalues (possible statuses) in descending order of the counts -  - careplan_getpatientcode creates a materialized view that lists the recorded patient code status at a certain time (offset). +  - careplan_getpatientcode creates a materialized view that lists the recorded patient code status at a certain time (offset). \ No newline at end of file diff --git a/concepts/code_status/careplan_getitemvalues.Rmd b/concepts/code_status/careplan_getitemvalues.Rmd index 447ee02..ab14231 100644 --- a/concepts/code_status/careplan_getitemvalues.Rmd +++ b/concepts/code_status/careplan_getitemvalues.Rmd @@ -1,6 +1,7 @@ --- title: "carePlan_getItemValues" output: html_document +author: Joseph Park --- ```{r setup, include=FALSE} @@ -34,6 +35,7 @@ dbExistsTable(con, "patient") Write cplitemvalues to file "possible_status" for inspection on which items indicate patient code status. All cplitemvalues that were chosen were in cplgroup = 'Care Limitation' (all cplitemvalues in this cplgroup was used), except cplitemvalue = 'End of life', which was in cplgroup = 'Ordered Protocols'. +SQL command was generated using show_query() for possible_status ```{r, connection = con} library(dplyr) diff --git a/concepts/code_status/careplan_getitemvalues.sql b/concepts/code_status/careplan_getitemvalues.sql index 8d5acfe..8db17fb 100644 --- a/concepts/code_status/careplan_getitemvalues.sql +++ b/concepts/code_status/careplan_getitemvalues.sql @@ -1,4 +1,5 @@ --- NOT SUPPORTED +-- author: Joseph Park +-- NOT SUPPORTED: autogenerated from careplan_getitemvalues.Rmd by using show_query() DROP MATERIALIZED VIEW IF EXISTS possibleCodeStatus; CREATE MATERIALIZED VIEW possibleCodeStatus AS diff --git a/concepts/code_status/careplan_getpatientcode.Rmd b/concepts/code_status/careplan_getpatientcode.Rmd index e1c9aaf..f1158ca 100644 --- a/concepts/code_status/careplan_getpatientcode.Rmd +++ b/concepts/code_status/careplan_getpatientcode.Rmd @@ -1,6 +1,7 @@ --- title: "carePlan_getPatientCode" output: html_document +author: Joseph Park --- ```{r setup, include=FALSE} @@ -30,6 +31,7 @@ cplitemvalue_code = c('Full therapy', 'Do not resuscitate', 'No CPR', 'No intuba ``` Generate table that lists the patient along with code status. +SQL command was generated using show_query() for patientCodeStatus ```{r, connection = con} patientCodeStatus <- carePlanGeneral_tbl %>% diff --git a/concepts/code_status/careplan_getpatientcode.sql b/concepts/code_status/careplan_getpatientcode.sql index 82f127b..0626552 100644 --- a/concepts/code_status/careplan_getpatientcode.sql +++ b/concepts/code_status/careplan_getpatientcode.sql @@ -1,4 +1,5 @@ --- NOT SUPPORTED +-- author: Joseph Park +-- NOT SUPPORTED: autogenerated from careplan_getpatientcode.Rmd by using show_query() DROP MATERIALIZED VIEW IF EXISTS patientCodeStatus; CREATE MATERIALIZED VIEW patientCodeStatus AS From f3186eb324db502be24ad22c35b57993429fe2f9 Mon Sep 17 00:00:00 2001 From: Joseph Park Date: Wed, 12 Dec 2018 11:53:18 -0500 Subject: [PATCH 14/15] Added configuration settings for getpatientcode --- .../code_status/careplan_getpatientcode.Rmd | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/concepts/code_status/careplan_getpatientcode.Rmd b/concepts/code_status/careplan_getpatientcode.Rmd index f1158ca..9396928 100644 --- a/concepts/code_status/careplan_getpatientcode.Rmd +++ b/concepts/code_status/careplan_getpatientcode.Rmd @@ -8,15 +8,27 @@ author: Joseph Park knitr::opts_chunk$set(echo = TRUE) ``` +Load configuration settings. Password requested by rstudioapi. + +```{r} +dbdriver <- 'PostgreSQL' +host <- 'localhost' +port <- '5432' +user <- 'josephpark' +dbname <- 'eicu' +schema <- 'eicu' +options <- paste("--search_path", schema, sep="") +``` + Connect to database. ```{r} require("RPostgreSQL") -drv <- dbDriver("PostgreSQL") -con <- dbConnect(drv, dbname = "eicu", - host = "localhost", port = 5432, - user = "josephpark", password = rstudioapi::askForPassword("Database password"), - options = "--search_path=eicu") +drv <- dbDriver(dbdriver) +con <- dbConnect(drv, dbname = dbname, + host = host, port = port, + user = user, password = rstudioapi::askForPassword("Database password"), + options = options) dbExistsTable(con, "patient") ``` From 4dd353b4ab1a44fe79c9c38d7d53184f9ca05481 Mon Sep 17 00:00:00 2001 From: Joseph Park Date: Wed, 12 Dec 2018 11:59:27 -0500 Subject: [PATCH 15/15] Fixed small typo --- concepts/code_status/careplan_getitemvalues.Rmd | 2 +- concepts/code_status/careplan_getpatientcode.Rmd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/concepts/code_status/careplan_getitemvalues.Rmd b/concepts/code_status/careplan_getitemvalues.Rmd index ab14231..1b333f3 100644 --- a/concepts/code_status/careplan_getitemvalues.Rmd +++ b/concepts/code_status/careplan_getitemvalues.Rmd @@ -17,7 +17,7 @@ port <- '5432' user <- 'josephpark' dbname <- 'eicu' schema <- 'eicu' -options <- paste("--search_path", schema, sep="") +options <- paste("--search_path=", schema, sep="") ``` Connect to database. diff --git a/concepts/code_status/careplan_getpatientcode.Rmd b/concepts/code_status/careplan_getpatientcode.Rmd index 9396928..f674f42 100644 --- a/concepts/code_status/careplan_getpatientcode.Rmd +++ b/concepts/code_status/careplan_getpatientcode.Rmd @@ -17,7 +17,7 @@ port <- '5432' user <- 'josephpark' dbname <- 'eicu' schema <- 'eicu' -options <- paste("--search_path", schema, sep="") +options <- paste("--search_path=", schema, sep="") ``` Connect to database.