From eeb222fdbf29cde46970953e5c274a70c40a4674 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fabr=C3=ADcio=20Kury?= Then we plot all data for the chosen patient (pid =
- At the end of this report I include a large table with all the
data for this patient, directly from the record sources, for maximum
verification. Here we use Phea to
compute the overt disseminated intravascular coagulation score produced
by the International Society for Thrombosis and Hemostasis:Kidney injury lab presentation
# Connect to SQL server.
<- DBI::dbConnect(RPostgres::Postgres(),
- dbcon host = 'localhost', port = 7654, dbname = 'fort',
+ host = 'localhost', port = 8765, dbname = 'fort',
user = cred$pg$user, password = cred$pg$pass)
# Call setup_phea so we can use sqlt() and sql0().
@@ -2471,11 +2471,68 @@ Calculate the phenotype
FALSE
+
+2
+1
+2016-03-11
+00:00:00
+1.3
+1.3
+1.3
+120.9
+NA
+2016-03-11
+2016-03-11
+2016-03-11
+2016-03-11
+NA
+FALSE
+FALSE
+FALSE
+
+
+3
+1
+2018-03-16
+00:00:00
+1.3
+1.3
+1.3
+151.7
+NA
+2018-03-16
+2018-03-16
+2018-03-16
+2018-03-16
+NA
+FALSE
+FALSE
+FALSE
+
+
+12
+1
+2020-03-20
+00:00:00
+1.3
+1.3
+1.3
+107.3
+NA
+2020-03-20
+2020-03-20
+2020-03-20
+2020-03-20
+NA
+FALSE
+FALSE
+FALSE
+
-5
1
2022-02-11
00:00:00
-1.8
+1.5
1.5
1.5
84.8
@@ -2485,11 +2542,11 @@ Calculate the phenotype
2022-02-11
2022-02-11
NA
-TRUE
+FALSE
FALSE
FALSE
+
-16
1
2022-03-25
@@ -2497,7 +2554,7 @@ Calculate the phenotype
1.5
1.5
1.5
-84.1
+105.7
NA
2022-03-25
2022-02-11
@@ -2508,7 +2565,7 @@ Calculate the phenotype
FALSE
FALSE
+
-17
3
2004-11-26
@@ -2527,211 +2584,154 @@ Calculate the phenotype
FALSE
FALSE
- 60
+
+
-47
3
-2016-01-29
-490 days
-2.6
-2.1
-2.1
-65.5
-124.1
-2016-01-29
-2016-01-29
-2016-01-29
-2016-01-29
-2014-09-26
-TRUE
+2005-12-02
+00:00:00
+1.5
+1.5
+1.5
+114.0
+NA
+2005-12-02
+2005-12-02
+2005-12-02
+2005-12-02
+NA
FALSE
FALSE
-
-
33
-3
-2016-11-11
-777 days
-3.7
-2.0
-2.0
-64.5
-124.1
-2016-11-11
-2016-11-11
-2016-11-11
-2016-11-11
-2014-09-26
-TRUE
-TRUE
FALSE
-
63
+19
3
-2017-02-03
-861 days
-3.5
-3.5
-2.0
-37.0
-124.1
-2017-02-03
-2017-02-03
-2016-11-11
-2017-02-03
-2014-09-26
+2006-12-08
+00:00:00
+1.5
+1.5
+1.5
+111.9
+NA
+2006-12-08
+2006-12-08
+2006-12-08
+2006-12-08
+NA
+FALSE
FALSE
-TRUE
FALSE
-
-64
+49
3
-2017-02-17
-98 days
-2.3
-2.3
-2.0
-57.4
-34.3
-2017-02-17
-2017-02-03
-2016-11-11
-2017-02-17
-2016-11-11
+2007-12-14
+00:00:00
+1.4
+1.4
+1.4
+131.9
+NA
+2007-12-14
+2007-12-14
+2007-12-14
+2007-12-14
+NA
FALSE
FALSE
-TRUE
-
-
-69
-3
-2019-02-15
-133 days
-3.9
-3.9
-2.6
-33.0
-49.3
-2019-02-15
-2019-02-15
-2018-10-05
-2019-02-15
-2018-10-05
FALSE
-TRUE
-TRUE
- 70
+
+
-50
3
-2020-02-21
-504 days
-2.5
-2.5
-2.5
-50.6
-49.3
-2020-02-21
-2020-02-21
-2020-02-21
-2020-02-21
-2018-10-05
+2008-12-19
+00:00:00
+1.3
+1.3
+1.3
+147.5
+NA
+2008-12-19
+2008-12-19
+2008-12-19
+2008-12-19
+NA
FALSE
FALSE
-TRUE
-
-
74
-3
-2022-05-20
-210 days
-4.0
-4.0
-2.2
-31.1
-33.6
-2022-05-20
-2022-05-20
-2021-10-22
-2022-05-20
-2021-10-22
FALSE
-TRUE
-TRUE
-
75
-6
-2022-07-06
+22
+3
+2009-12-25
00:00:00
-1.1
-1.1
-1.1
-NA
+1.3
+1.3
+1.3
+149.6
NA
-2022-07-06
-2022-07-06
-2022-07-06
-NA
+2009-12-25
+2009-12-25
+2009-12-25
+2009-12-25
NA
FALSE
FALSE
-NA
+FALSE
-
76
-14
-2021-02-08
+23
+3
+2010-12-31
00:00:00
-2.7
-2.7
-2.7
-78.8
+1.3
+1.3
+1.3
+132.3
NA
-2021-02-08
-2021-02-08
-2021-02-08
-2021-02-08
+2010-12-31
+2010-12-31
+2010-12-31
+2010-12-31
NA
FALSE
FALSE
FALSE
-
80
-18
-2003-05-04
-00:00:00
-0.9
-0.9
-0.9
-NA
-NA
-2003-05-04
-2003-05-04
-2003-05-04
-NA
-NA
+24
+3
+2011-04-15
+105 days
+1.4
+1.4
+1.3
+142.0
+132.3
+2011-04-15
+2011-04-15
+2010-12-31
+2011-04-15
+2010-12-31
+FALSE
FALSE
FALSE
-NA
-
100
-19
-2003-08-03
-00:00:00
-1.4
-1.4
-1.4
-133.9
-NA
-2003-08-03
-2003-08-03
-2003-08-03
-2003-08-03
-NA
+54
+3
+2012-01-06
+371 days
+1.5
+1.5
+1.5
+91.6
+132.3
+2012-01-06
+2012-01-06
+2012-01-06
+2012-01-06
+2010-12-31
FALSE
FALSE
FALSE
@@ -2761,17 +2761,17 @@ Plot the phenotype for a random patient
<- sample(patients, 1)
random_patient
message('Sampled patient: ', random_patient)
-#> Sampled patient: 1010
+#> Sampled patient: 19
1010
).19
).
|>
scr_change select(-ends_with('datetime')) |>
mutate(
scr_case_a_or_b = scr_case_a | scr_case_b) |>
phea_plot(random_patient)
#> Collecting lazy table, done. (turn this message off with `verbose = FALSE`)
Obtain the SQL query that computes the phenotype
"scr_7d_min_measurement_datetime",
"gfr_measurement_datetime",
"gfr_prior_measurement_datetime",
- "scr_case_a",
- "scr_case_b",
- "gfr_case_c"
+ - scr_48h_min_value_as_number >= 0.3 AS "scr_case_a",
+ scr_value_as_number / scr_7d_min_value_as_number >= 1.5 AS "scr_case_b",
+ scr_value_as_number < 60 AND gfr_prior_value_as_number < 60 AS "gfr_case_c"
gfr_value_as_number FROM (
SELECT
*,
- lag(phea_kco_var1) OVER (PARTITION BY "pid" ORDER BY "ts") AS "phea_kco_lag1",
- lag(phea_kco_var2) OVER (PARTITION BY "pid" ORDER BY "ts") AS "phea_kco_lag2",
- lag(phea_kco_var3) OVER (PARTITION BY "pid" ORDER BY "ts") AS "phea_kco_lag3",
- lag(phea_kco_var4) OVER (PARTITION BY "pid" ORDER BY "ts") AS "phea_kco_lag4"
- FROM (
- SELECT
- *,
- AS "phea_kco_var1",
- pid AS "phea_kco_var2",
- scr_case_a AS "phea_kco_var3",
- scr_case_b AS "phea_kco_var4"
- gfr_case_c FROM (
- SELECT
- "row_id",
- "pid",
- "ts",
- "window",
- "scr_value_as_number",
- "scr_48h_min_value_as_number",
- "scr_7d_min_value_as_number",
- "gfr_value_as_number",
- "gfr_prior_value_as_number",
- "scr_measurement_datetime",
- "scr_48h_min_measurement_datetime",
- "scr_7d_min_measurement_datetime",
- "gfr_measurement_datetime",
- "gfr_prior_measurement_datetime",
- - scr_48h_min_value_as_number >= 0.3 AS "scr_case_a",
- scr_value_as_number / scr_7d_min_value_as_number >= 1.5 AS "scr_case_b",
- scr_value_as_number < 60 AND gfr_prior_value_as_number < 60 AS "gfr_case_c"
- gfr_value_as_number FROM (
- SELECT
- *,
- greatest(scr_ts, scr_48h_min_ts, scr_7d_min_ts, gfr_ts, gfr_prior_ts) - least(scr_ts, scr_48h_min_ts, scr_7d_min_ts, gfr_ts, gfr_prior_ts) AS "window",
- last_value(row_id) over (partition by "pid", "ts") AS "phea_ts_row"
- FROM (
- SELECT
- "row_id",
- "pid",
- "ts",
- MAX("scr_measurement_datetime") OVER (PARTITION BY "pid", "..dbplyr_partion_1") AS "scr_measurement_datetime",
- MAX("scr_value_as_number") OVER (PARTITION BY "pid", "..dbplyr_partion_2") AS "scr_value_as_number",
- MAX("scr_ts") OVER (PARTITION BY "pid", "..dbplyr_partion_3") AS "scr_ts",
- MAX("scr_48h_min_measurement_datetime") OVER (PARTITION BY "pid", "..dbplyr_partion_4") AS "scr_48h_min_measurement_datetime",
- MAX("scr_48h_min_value_as_number") OVER (PARTITION BY "pid", "..dbplyr_partion_5") AS "scr_48h_min_value_as_number",
- MAX("scr_48h_min_ts") OVER (PARTITION BY "pid", "..dbplyr_partion_6") AS "scr_48h_min_ts",
- MAX("scr_7d_min_measurement_datetime") OVER (PARTITION BY "pid", "..dbplyr_partion_7") AS "scr_7d_min_measurement_datetime",
- MAX("scr_7d_min_value_as_number") OVER (PARTITION BY "pid", "..dbplyr_partion_8") AS "scr_7d_min_value_as_number",
- MAX("scr_7d_min_ts") OVER (PARTITION BY "pid", "..dbplyr_partion_9") AS "scr_7d_min_ts",
- MAX("gfr_measurement_datetime") OVER (PARTITION BY "pid", "..dbplyr_partion_10") AS "gfr_measurement_datetime",
- MAX("gfr_value_as_number") OVER (PARTITION BY "pid", "..dbplyr_partion_11") AS "gfr_value_as_number",
- MAX("gfr_ts") OVER (PARTITION BY "pid", "..dbplyr_partion_12") AS "gfr_ts",
- MAX("gfr_prior_measurement_datetime") OVER (PARTITION BY "pid", "..dbplyr_partion_13") AS "gfr_prior_measurement_datetime",
- MAX("gfr_prior_value_as_number") OVER (PARTITION BY "pid", "..dbplyr_partion_14") AS "gfr_prior_value_as_number",
- MAX("gfr_prior_ts") OVER (PARTITION BY "pid", "..dbplyr_partion_15") AS "gfr_prior_ts"
- FROM (
- SELECT
- *,
- SUM(CASE WHEN (("scr_measurement_datetime" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_1",
- SUM(CASE WHEN (("scr_value_as_number" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_2",
- SUM(CASE WHEN (("scr_ts" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_3",
- SUM(CASE WHEN (("scr_48h_min_measurement_datetime" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_4",
- SUM(CASE WHEN (("scr_48h_min_value_as_number" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_5",
- SUM(CASE WHEN (("scr_48h_min_ts" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_6",
- SUM(CASE WHEN (("scr_7d_min_measurement_datetime" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_7",
- SUM(CASE WHEN (("scr_7d_min_value_as_number" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_8",
- SUM(CASE WHEN (("scr_7d_min_ts" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_9",
- SUM(CASE WHEN (("gfr_measurement_datetime" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_10",
- SUM(CASE WHEN (("gfr_value_as_number" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_11",
- SUM(CASE WHEN (("gfr_ts" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_12",
- SUM(CASE WHEN (("gfr_prior_measurement_datetime" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_13",
- SUM(CASE WHEN (("gfr_prior_value_as_number" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_14",
- SUM(CASE WHEN (("gfr_prior_ts" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_15"
- FROM (
- SELECT
- row_number() over () AS "row_id",
- "pid",
- "ts",
- last_value(case when "name" = 'f4enaijqlv6k' then "measurement_datetime" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "scr_measurement_datetime",
- last_value(case when "name" = 'f4enaijqlv6k' then "value_as_number" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "scr_value_as_number",
- last_value(case when "name" = 'f4enaijqlv6k' then "ts" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "scr_ts",
- min(case when "name" = 'f4enaijqlv6k' then "measurement_datetime" else null end) over (partition by "pid", "name" order by "ts" range between '48 days'::interval preceding and current row) AS "scr_48h_min_measurement_datetime",
- min(case when "name" = 'f4enaijqlv6k' then "value_as_number" else null end) over (partition by "pid", "name" order by "ts" range between '48 days'::interval preceding and current row) AS "scr_48h_min_value_as_number",
- last_value(case when "name" = 'f4enaijqlv6k' then "ts" else null end) over (partition by "pid", "name" order by "ts" range between '48 days'::interval preceding and current row) AS "scr_48h_min_ts",
- min(case when "name" = 'f4enaijqlv6k' then "measurement_datetime" else null end) over (partition by "pid", "name" order by "ts" range between '7 months'::interval preceding and current row) AS "scr_7d_min_measurement_datetime",
- min(case when "name" = 'f4enaijqlv6k' then "value_as_number" else null end) over (partition by "pid", "name" order by "ts" range between '7 months'::interval preceding and current row) AS "scr_7d_min_value_as_number",
- last_value(case when "name" = 'f4enaijqlv6k' then "ts" else null end) over (partition by "pid", "name" order by "ts" range between '7 months'::interval preceding and current row) AS "scr_7d_min_ts",
- last_value(case when "name" = 'ydcetbw9y26i' then "measurement_datetime" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "gfr_measurement_datetime",
- last_value(case when "name" = 'ydcetbw9y26i' then "value_as_number" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "gfr_value_as_number",
- last_value(case when "name" = 'ydcetbw9y26i' then "ts" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "gfr_ts",
- min(case when "name" = 'ydcetbw9y26i' then "measurement_datetime" else null end) over (partition by "pid", "name" order by "ts" range between '5 months'::interval preceding and '3 months days'::interval preceding) AS "gfr_prior_measurement_datetime",
- min(case when "name" = 'ydcetbw9y26i' then "value_as_number" else null end) over (partition by "pid", "name" order by "ts" range between '5 months'::interval preceding and '3 months days'::interval preceding) AS "gfr_prior_value_as_number",
- last_value(case when "name" = 'ydcetbw9y26i' then "ts" else null end) over (partition by "pid", "name" order by "ts" range between '5 months'::interval preceding and '3 months days'::interval preceding) AS "gfr_prior_ts"
- FROM (
-
- (SELECT
- 'f4enaijqlv6k' AS "name",
- "person_id" AS "pid",
- "measurement_datetime" AS "ts",
- "measurement_datetime",
- "value_as_number"
- FROM (
-
- (SELECT *
- FROM "cdm_new_york3"."measurement"
- WHERE ("measurement_concept_id" IN (3051825.0, 3016723.0) AND "unit_source_value" = 'mg/dL')
-
- )UNION ALL
-
- (SELECT
- "measurement_id",
- "person_id",
- "measurement_concept_id",
- "measurement_date",
- "measurement_datetime",
- "measurement_time",
- "measurement_type_concept_id",
- "operator_concept_id",
- "value_as_number" / 88.42 AS "value_as_number",
- "value_as_concept_id",
- "unit_concept_id",
- "range_low",
- "range_high",
- "provider_id",
- "visit_occurrence_id",
- "visit_detail_id",
- "measurement_source_value",
- "measurement_source_concept_id",
- 'mg/dL' AS "unit_source_value",
- "unit_source_concept_id",
- "value_source_value",
- "measurement_event_id",
- "meas_event_field_concept_id"
- FROM "cdm_new_york3"."measurement"
- WHERE ("measurement_concept_id" IN (3051825.0, 3016723.0) AND "unit_source_value" = 'µmol/L')
-
- )"q01"
- )
- )UNION ALL
-
- (SELECT
- 'ydcetbw9y26i' AS "name",
- "person_id" AS "pid",
- "measurement_datetime" AS "ts",
- "measurement_datetime",
- "value_as_number"
- FROM "cdm_new_york3"."measurement"
- WHERE ("measurement_concept_id" = 46236952.0)
-
- )"q02"
- ) "q03"
- ) "q04"
- ) "q05"
- ) "q06"
- ) WHERE ("row_id" = "phea_ts_row")
- "q07"
- ) "q08"
- ) "q09"
- ) WHERE ((("phea_kco_lag1" IS NULL) AND NOT(("phea_kco_var1" IS NULL))) OR "phea_kco_lag1" != "phea_kco_var1" OR (("phea_kco_lag2" IS NULL) AND NOT(("phea_kco_var2" IS NULL))) OR "phea_kco_lag2" != "phea_kco_var2" OR (("phea_kco_lag3" IS NULL) AND NOT(("phea_kco_var3" IS NULL))) OR "phea_kco_lag3" != "phea_kco_var3" OR (("phea_kco_lag4" IS NULL) AND NOT(("phea_kco_var4" IS NULL))) OR "phea_kco_lag4" != "phea_kco_var4")
+greatest(scr_ts, scr_48h_min_ts, scr_7d_min_ts, gfr_ts, gfr_prior_ts) - least(scr_ts, scr_48h_min_ts, scr_7d_min_ts, gfr_ts, gfr_prior_ts) AS "window",
+ last_value(row_id) over (partition by "pid", "ts") AS "phea_ts_row"
+ FROM (
+ SELECT
+ "row_id",
+ "pid",
+ "ts",
+ MAX("scr_measurement_datetime") OVER (PARTITION BY "pid", "..dbplyr_partion_1") AS "scr_measurement_datetime",
+ MAX("scr_value_as_number") OVER (PARTITION BY "pid", "..dbplyr_partion_2") AS "scr_value_as_number",
+ MAX("scr_ts") OVER (PARTITION BY "pid", "..dbplyr_partion_3") AS "scr_ts",
+ MAX("scr_48h_min_measurement_datetime") OVER (PARTITION BY "pid", "..dbplyr_partion_4") AS "scr_48h_min_measurement_datetime",
+ MAX("scr_48h_min_value_as_number") OVER (PARTITION BY "pid", "..dbplyr_partion_5") AS "scr_48h_min_value_as_number",
+ MAX("scr_48h_min_ts") OVER (PARTITION BY "pid", "..dbplyr_partion_6") AS "scr_48h_min_ts",
+ MAX("scr_7d_min_measurement_datetime") OVER (PARTITION BY "pid", "..dbplyr_partion_7") AS "scr_7d_min_measurement_datetime",
+ MAX("scr_7d_min_value_as_number") OVER (PARTITION BY "pid", "..dbplyr_partion_8") AS "scr_7d_min_value_as_number",
+ MAX("scr_7d_min_ts") OVER (PARTITION BY "pid", "..dbplyr_partion_9") AS "scr_7d_min_ts",
+ MAX("gfr_measurement_datetime") OVER (PARTITION BY "pid", "..dbplyr_partion_10") AS "gfr_measurement_datetime",
+ MAX("gfr_value_as_number") OVER (PARTITION BY "pid", "..dbplyr_partion_11") AS "gfr_value_as_number",
+ MAX("gfr_ts") OVER (PARTITION BY "pid", "..dbplyr_partion_12") AS "gfr_ts",
+ MAX("gfr_prior_measurement_datetime") OVER (PARTITION BY "pid", "..dbplyr_partion_13") AS "gfr_prior_measurement_datetime",
+ MAX("gfr_prior_value_as_number") OVER (PARTITION BY "pid", "..dbplyr_partion_14") AS "gfr_prior_value_as_number",
+ MAX("gfr_prior_ts") OVER (PARTITION BY "pid", "..dbplyr_partion_15") AS "gfr_prior_ts"
+ FROM (
+ SELECT
+ *,
+ SUM(CASE WHEN (("scr_measurement_datetime" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_1",
+ SUM(CASE WHEN (("scr_value_as_number" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_2",
+ SUM(CASE WHEN (("scr_ts" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_3",
+ SUM(CASE WHEN (("scr_48h_min_measurement_datetime" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_4",
+ SUM(CASE WHEN (("scr_48h_min_value_as_number" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_5",
+ SUM(CASE WHEN (("scr_48h_min_ts" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_6",
+ SUM(CASE WHEN (("scr_7d_min_measurement_datetime" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_7",
+ SUM(CASE WHEN (("scr_7d_min_value_as_number" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_8",
+ SUM(CASE WHEN (("scr_7d_min_ts" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_9",
+ SUM(CASE WHEN (("gfr_measurement_datetime" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_10",
+ SUM(CASE WHEN (("gfr_value_as_number" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_11",
+ SUM(CASE WHEN (("gfr_ts" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_12",
+ SUM(CASE WHEN (("gfr_prior_measurement_datetime" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_13",
+ SUM(CASE WHEN (("gfr_prior_value_as_number" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_14",
+ SUM(CASE WHEN (("gfr_prior_ts" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_15"
+ FROM (
+ SELECT
+ row_number() over () AS "row_id",
+ "pid",
+ "ts",
+ last_value(case when "name" = 'xl450dcw' then "measurement_datetime" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "scr_measurement_datetime",
+ last_value(case when "name" = 'xl450dcw' then "value_as_number" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "scr_value_as_number",
+ last_value(case when "name" = 'xl450dcw' then "ts" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "scr_ts",
+ min(case when "name" = 'xl450dcw' then "measurement_datetime" else null end) over (partition by "pid", "name" order by "ts" range between '48 days'::interval preceding and current row) AS "scr_48h_min_measurement_datetime",
+ min(case when "name" = 'xl450dcw' then "value_as_number" else null end) over (partition by "pid", "name" order by "ts" range between '48 days'::interval preceding and current row) AS "scr_48h_min_value_as_number",
+ last_value(case when "name" = 'xl450dcw' then "ts" else null end) over (partition by "pid", "name" order by "ts" range between '48 days'::interval preceding and current row) AS "scr_48h_min_ts",
+ min(case when "name" = 'xl450dcw' then "measurement_datetime" else null end) over (partition by "pid", "name" order by "ts" range between '7 months'::interval preceding and current row) AS "scr_7d_min_measurement_datetime",
+ min(case when "name" = 'xl450dcw' then "value_as_number" else null end) over (partition by "pid", "name" order by "ts" range between '7 months'::interval preceding and current row) AS "scr_7d_min_value_as_number",
+ last_value(case when "name" = 'xl450dcw' then "ts" else null end) over (partition by "pid", "name" order by "ts" range between '7 months'::interval preceding and current row) AS "scr_7d_min_ts",
+ last_value(case when "name" = 'jfawg3sk' then "measurement_datetime" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "gfr_measurement_datetime",
+ last_value(case when "name" = 'jfawg3sk' then "value_as_number" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "gfr_value_as_number",
+ last_value(case when "name" = 'jfawg3sk' then "ts" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "gfr_ts",
+ min(case when "name" = 'jfawg3sk' then "measurement_datetime" else null end) over (partition by "pid", "name" order by "ts" range between '5 months'::interval preceding and '3 months days'::interval preceding) AS "gfr_prior_measurement_datetime",
+ min(case when "name" = 'jfawg3sk' then "value_as_number" else null end) over (partition by "pid", "name" order by "ts" range between '5 months'::interval preceding and '3 months days'::interval preceding) AS "gfr_prior_value_as_number",
+ last_value(case when "name" = 'jfawg3sk' then "ts" else null end) over (partition by "pid", "name" order by "ts" range between '5 months'::interval preceding and '3 months days'::interval preceding) AS "gfr_prior_ts"
+ FROM (
+
+ (SELECT
+ 'xl450dcw' AS "name",
+ "person_id" AS "pid",
+ "measurement_datetime" AS "ts",
+ "measurement_datetime",
+ "value_as_number"
+ FROM (
+
+ (SELECT *
+ FROM "cdm_new_york3"."measurement"
+ WHERE ("measurement_concept_id" IN (3051825.0, 3016723.0) AND "unit_source_value" = 'mg/dL')
+
+ )UNION ALL
+
+ (SELECT
+ "measurement_id",
+ "person_id",
+ "measurement_concept_id",
+ "measurement_date",
+ "measurement_datetime",
+ "measurement_time",
+ "measurement_type_concept_id",
+ "operator_concept_id",
+ "value_as_number" / 88.42 AS "value_as_number",
+ "value_as_concept_id",
+ "unit_concept_id",
+ "range_low",
+ "range_high",
+ "provider_id",
+ "visit_occurrence_id",
+ "visit_detail_id",
+ "measurement_source_value",
+ "measurement_source_concept_id",
+ 'mg/dL' AS "unit_source_value",
+ "unit_source_concept_id",
+ "value_source_value",
+ "measurement_event_id",
+ "meas_event_field_concept_id"
+ FROM "cdm_new_york3"."measurement"
+ WHERE ("measurement_concept_id" IN (3051825.0, 3016723.0) AND "unit_source_value" = 'µmol/L')
+
+ )"q01"
+ )
+ )UNION ALL
+
+ (SELECT
+ 'jfawg3sk' AS "name",
+ "person_id" AS "pid",
+ "measurement_datetime" AS "ts",
+ "measurement_datetime",
+ "value_as_number"
+ FROM "cdm_new_york3"."measurement"
+ WHERE ("measurement_concept_id" = 46236952.0)
+
+ )"q02"
+ ) "q03"
+ ) "q04"
+ ) "q05"
+ ) "q06"
+ ) WHERE ("row_id" = "phea_ts_row")
See the raw data that went into
@@ -2996,717 +2959,395 @@
Serum creatinine records
-
412430
-1010
-1975-05-23
-1.0
+6543
+19
+2003-08-03
+1.4
mg/dL
-
414817
-1010
-1976-04-01
-3.1
+6065
+19
+2004-08-08
+1.6
mg/dL
-
413259
-1010
-1976-05-28
-1.1
+6080
+19
+2004-08-08
+1.5
mg/dL
-
413703
-1010
-1977-04-01
-2.9
+5933
+19
+2005-08-14
+1.6
mg/dL
-
412468
-1010
-1977-06-03
-0.9
+5937
+19
+2005-08-14
+1.7
mg/dL
-
414266
-1010
-1978-04-01
-3.0
+6708
+19
+2005-11-27
+2.6
mg/dL
-
412982
-1010
-1978-05-19
-1.1
+6158
+19
+2006-08-20
+3.9
mg/dL
-
412995
-1010
-1978-05-19
-1.4
+6140
+19
+2006-09-24
+3.2
mg/dL
-
414044
-1010
-1978-06-09
-1.3
+5465
+19
+2007-08-26
+2.8
mg/dL
-
414058
-1010
-1978-06-09
-1.6
+6260
+19
+2007-10-14
+4.4
mg/dL
-
414445
-1010
-1978-06-23
-1.3
+6004
+19
+2007-11-18
+4.3
mg/dL
-
413888
-1010
-1978-07-14
-1.4
+5367
+19
+2008-04-13
+2.9
mg/dL
-
412766
-1010
-1978-08-25
-1.1
+5612
+19
+2008-08-31
+3.8
mg/dL
-
412405
-1010
-1979-04-01
-3.2
+6223
+19
+2009-02-08
+4.1
mg/dL
-
414188
-1010
-1979-06-15
-1.0
+5414
+19
+2009-09-06
+2.8
mg/dL
-
413420
-1010
-1979-10-12
-1.2
+6757
+19
+2009-11-01
+2.8
mg/dL
-
413814
-1010
-1980-03-31
-3.2
+6473
+19
+2010-05-02
+2.7
mg/dL
-
413608
-1010
-1980-06-20
-1.2
+5695
+19
+2010-09-12
+3.6
mg/dL
-
413974
-1010
-1980-10-31
-1.2
+6623
+19
+2011-09-18
+3.5
mg/dL
-
412874
-1010
-1981-03-06
-1.4
+6288
+19
+2011-12-25
+2.9
mg/dL
-
414611
-1010
-1981-03-31
-3.1
+6438
+19
+2012-02-19
+3.4
mg/dL
-
413530
-1010
-1981-05-01
-1.2
+5754
+19
+2012-09-23
+2.4
mg/dL
-
413037
-1010
-1981-06-26
-1.4
+6672
+19
+2013-01-20
+3.3
mg/dL
-
414777
-1010
-1981-07-10
-1.0
+5717
+19
+2013-09-29
+3.2
mg/dL
-
413293
-1010
-1981-10-30
-1.1
+6371
+19
+2014-08-10
+2.9
mg/dL
-
412331
-1010
-1982-03-31
-2.9
+6385
+19
+2014-08-10
+2.2
mg/dL
-
414703
-1010
-1982-05-28
-1.2
+5517
+19
+2014-10-05
+2.3
mg/dL
-
414861
-1010
-1982-07-02
-1.1
+6686
+19
+2014-11-02
+2.4
mg/dL
-
412678
-1010
-1982-10-22
-1.2
+5657
+19
+2015-08-31
+3.5
mg/dL
-
414399
-1010
-1983-03-31
-3.0
+6108
+19
+2015-10-11
+3.4
mg/dL
-
413942
-1010
-1983-07-08
-1.2
+5791
+19
+2016-02-28
+3.4
mg/dL
-
413993
-1010
-1984-01-20
-1.3
+5546
+19
+2016-08-30
+2.9
mg/dL
-
412651
-1010
-1984-03-30
-3.4
+5982
+19
+2016-10-16
+2.2
mg/dL
-
413009
-1010
-1984-05-18
-1.0
+5879
+19
+2016-11-27
+3.8
mg/dL
-
414382
-1010
-1984-07-13
-1.1
+6213
+19
+2016-12-25
+3.3
mg/dL
-
414729
-1010
-1984-10-12
-1.0
+5644
+19
+2017-08-30
+2.9
mg/dL
-
412487
-1010
-1985-01-11
-1.1
+6517
+19
+2017-10-22
+2.2
mg/dL
-
412591
-1010
-1985-03-30
-2.8
+6490
+19
+2018-08-30
+3.1
mg/dL
-
414652
-1010
-1985-07-12
-1.0
+5915
+19
+2018-10-28
+2.9
mg/dL
-
414488
-1010
-1985-07-26
-1.1
+5853
+19
+2018-11-18
+2.5
mg/dL
-
412304
-1010
-1986-03-30
-2.8
+6575
+19
+2018-12-16
+3.3
mg/dL
-
412660
-1010
-1986-08-01
-1.2
+6113
+19
+2019-08-30
+2.6
mg/dL
-
413298
-1010
-1987-03-30
-2.7
+6618
+19
+2019-09-22
+2.4
mg/dL
-
412536
-1010
-1987-07-03
-1.0
+5623
+19
+2019-11-03
+3.4
mg/dL
-
-414505
-1010
-1987-08-07
-1.3
-mg/dL
-
-
-413369
-1010
-1988-01-29
-1.4
-mg/dL
-
-
-414023
-1010
-1988-03-29
-3.4
-mg/dL
-
-
-414128
-1010
-1988-08-12
-1.2
-mg/dL
-
-
-414663
-1010
-1988-12-23
-1.8
-mg/dL
-
-
-414546
-1010
-1989-02-17
-1.5
-mg/dL
-
-
-413578
-1010
-1989-03-29
-3.3
-mg/dL
-
-
-413772
-1010
-1989-04-21
-2.5
-mg/dL
-
-
-413392
-1010
-1989-07-28
-2.0
-mg/dL
-
-
-413443
-1010
-1989-08-18
-2.2
-mg/dL
-
-
-412396
-1010
-1989-09-15
-1.8
-mg/dL
-
-
-414835
-1010
-1989-10-20
-1.5
-mg/dL
-
-
-412859
-1010
-1990-01-19
-1.9
-mg/dL
-
-
-414097
-1010
-1990-03-29
-3.3
-mg/dL
-
-
-412572
-1010
-1990-04-13
-1.4
-mg/dL
-
-
-412913
-1010
-1990-07-13
-2.0
-mg/dL
-
-
-413837
-1010
-1990-08-10
-2.0
-mg/dL
-
-
-413145
-1010
-1990-08-24
-1.8
-mg/dL
-
-
-414421
-1010
-1990-10-12
-2.0
-mg/dL
-
-
-414321
-1010
-1991-01-11
-1.7
-mg/dL
-
-
-412337
-1010
-1991-02-15
-1.4
-mg/dL
-
-
-413475
-1010
-1991-03-29
+6022
+19
+2020-07-12
3.0
mg/dL
-
-413661
-1010
-1991-03-29
-2.3
-mg/dL
-
-
-412380
-1010
-1991-04-19
-1.9
-mg/dL
-
-
414562
-1010
-1991-05-17
-2.1
-mg/dL
-
-
-412627
-1010
-1991-06-07
-1.5
-mg/dL
-
-
-413542
-1010
-1991-08-30
-2.1
-mg/dL
-
-
-413128
-1010
-1991-10-11
-1.5
-mg/dL
-
-
-412718
-1010
-1991-12-06
-1.3
-mg/dL
-
-
-412549
-1010
-1992-03-13
-1.5
-mg/dL
-
-
-414718
-1010
-1992-03-28
-2.6
-mg/dL
-
-
-412733
-1010
-1992-04-10
-2.0
-mg/dL
-
-
-413177
-1010
-1992-09-04
-1.3
-mg/dL
-
-
-414580
-1010
-1992-09-18
-1.4
-mg/dL
-
-
-414019
-1010
-1992-10-02
-1.3
-mg/dL
-
-
-413325
-1010
-1992-11-27
-2.1
-mg/dL
-
-
-413365
-1010
-1993-01-29
-1.7
-mg/dL
-
-
-413197
-1010
-1993-03-28
-3.1
-mg/dL
-
-
-413203
-1010
-1993-04-02
-1.9
-mg/dL
-
-
-413634
-1010
-1993-04-30
-2.1
-mg/dL
-
-
-413693
-1010
-1993-07-04
-2.2
-mg/dL
-
-
-413782
-1010
-1993-07-23
-1.6
-mg/dL
-
-
-412786
-1010
-1993-08-27
-1.4
-mg/dL
-
-
414241
-1010
-1993-09-10
-1.2
+5529
+19
+2020-08-29
+2.7
mg/dL
-
412606
-1010
-1993-09-24
-1.7
+6733
+19
+2020-10-04
+2.9
mg/dL
-
414876
-1010
-1993-11-26
-1.3
+6305
+19
+2020-11-08
+2.9
mg/dL
-
414757
-1010
-1993-12-31
-1.4
+5488
+19
+2020-11-22
+3.5
mg/dL
-
414217
-1010
-1994-01-19
-1.3
+5401
+19
+2021-07-04
+3.5
mg/dL
-
414350
-1010
-1994-01-19
-1.3
+6414
+19
+2021-08-01
+2.8
mg/dL
-
413917
-1010
-1994-03-04
-1.2
+5567
+19
+2021-08-29
+2.9
mg/dL
-
413240
-1010
-1994-03-28
+6182
+19
+2021-10-03
2.7
mg/dL
-
-413505
-1010
-1994-06-03
-2.0
-mg/dL
-
-
-413742
-1010
-1994-07-19
-1.6
-mg/dL
-
-
-414149
-1010
-1994-07-19
-1.6
-mg/dL
-
-
-414525
-1010
-1994-09-16
-1.4
-mg/dL
-
-
412899
-1010
-1994-10-07
-1.7
+6775
+19
+2021-11-14
+3.5
mg/dL
-
412811
-1010
-1995-01-16
-1.9
+5774
+19
+2022-08-29
+3.3
mg/dL
-
@@ -3739,705 +3380,397 @@ 413805
-1010
-1995-03-28
-2.6
+6515
+19
+2022-10-30
+2.5
mg/dL
Glomerular filtration rate records
-
-412459
-1010
-1975-05-23
-120.2
-mL/min/{1.73_m2}
-
-
-414811
-1010
-1976-04-01
-72.9
-mL/min
-
-
413273
-1010
-1976-05-28
-83.7
+6552
+19
+2003-08-03
+133.9
mL/min/{1.73_m2}
-
-413706
-1010
-1977-04-01
-67.1
-mL/min
-
-
-412473
-1010
-1977-06-03
-106.8
+6076
+19
+2004-08-08
+83.5
mL/min/{1.73_m2}
-
414273
-1010
-1978-04-01
-84.6
-mL/min
-
-
412966
-1010
-1978-05-19
-124.3
+6086
+19
+2004-08-08
+141.2
mL/min
-
412993
-1010
-1978-05-19
-80.5
+5922
+19
+2005-08-14
+82.8
mL/min/{1.73_m2}
-
414074
-1010
-1978-06-09
-100.4
+5966
+19
+2005-08-14
+91.2
mL/min
-
414080
-1010
-1978-06-09
-70.1
+6719
+19
+2005-11-27
+52.4
mL/min/{1.73_m2}
-
414434
-1010
-1978-06-23
-68.3
+6156
+19
+2006-08-20
+34.1
mL/min/{1.73_m2}
-
-413904
-1010
-1978-07-14
-63.8
-mL/min/{1.73_m2}
-
-
-412778
-1010
-1978-08-25
-80.4
+6146
+19
+2006-09-24
+41.6
mL/min/{1.73_m2}
-
412419
-1010
-1979-04-01
-83.3
-mL/min
-
-
-414178
-1010
-1979-06-15
-89.2
-mL/min/{1.73_m2}
-
-
-413455
-1010
-1979-10-12
-74.8
+5453
+19
+2007-08-26
+47.8
mL/min/{1.73_m2}
-
413820
-1010
-1980-03-31
-82.6
-mL/min
-
-
413604
-1010
-1980-06-20
-77.7
+6258
+19
+2007-10-14
+30.2
mL/min/{1.73_m2}
-
-413960
-1010
-1980-10-31
-79.7
-mL/min/{1.73_m2}
-
-
-412885
-1010
-1981-03-06
-64.2
+5996
+19
+2007-11-18
+30.8
mL/min/{1.73_m2}
-
414617
-1010
-1981-03-31
-89.5
-mL/min
-
-
413538
-1010
-1981-05-01
-72.9
+5388
+19
+2008-04-13
+44.3
mL/min/{1.73_m2}
-
413023
-1010
-1981-06-26
-64.4
+5611
+19
+2008-08-31
+34.0
mL/min/{1.73_m2}
-
-414785
-1010
-1981-07-10
-86.7
-mL/min/{1.73_m2}
-
-
-413284
-1010
-1981-10-30
-85.7
+6235
+19
+2009-02-08
+31.5
mL/min/{1.73_m2}
-
412322
-1010
-1982-03-31
-67.7
-mL/min
-
-
414669
-1010
-1982-05-28
-77.3
+5435
+19
+2009-09-06
+45.9
mL/min/{1.73_m2}
-
-414853
-1010
-1982-07-02
-84.8
-mL/min/{1.73_m2}
-
-
-412685
-1010
-1982-10-22
-77.5
+6746
+19
+2009-11-01
+46.9
mL/min/{1.73_m2}
-
414390
-1010
-1983-03-31
-69.1
-mL/min
-
-
-413950
-1010
-1983-07-08
-76.7
-mL/min/{1.73_m2}
-
-
-413986
-1010
-1984-01-20
-67.5
+6462
+19
+2010-05-02
+46.5
mL/min/{1.73_m2}
-
412642
-1010
-1984-03-30
-87.1
-mL/min
-
-
413020
-1010
-1984-05-18
-86.0
+5694
+19
+2010-09-12
+35.9
mL/min/{1.73_m2}
-
414362
-1010
-1984-07-13
-80.7
+6638
+19
+2011-09-18
+35.6
mL/min/{1.73_m2}
-
-414745
-1010
-1984-10-12
-86.8
-mL/min/{1.73_m2}
-
-
-412492
-1010
-1985-01-11
-82.0
+6276
+19
+2011-12-25
+43.3
mL/min/{1.73_m2}
-
412585
-1010
-1985-03-30
-67.4
-mL/min
-
-
414631
-1010
-1985-07-12
-85.2
+6449
+19
+2012-02-19
+36.3
mL/min/{1.73_m2}
-
414484
-1010
-1985-07-26
-76.4
+5764
+19
+2012-09-23
+53.1
mL/min/{1.73_m2}
-
-412299
-1010
-1986-03-30
-71.2
-mL/min
-
-
-412668
-1010
-1986-08-01
-68.9
+6670
+19
+2013-01-20
+37.0
mL/min/{1.73_m2}
-
413317
-1010
-1987-03-30
-85.4
-mL/min
-
-
412507
-1010
-1987-07-03
-87.1
+5741
+19
+2013-09-29
+38.6
mL/min/{1.73_m2}
-
414494
-1010
-1987-08-07
-61.8
+6366
+19
+2014-08-10
+56.6
mL/min/{1.73_m2}
-
-413377
-1010
-1988-01-29
-60.4
-mL/min/{1.73_m2}
-
-
-414029
-1010
-1988-03-29
-73.1
+6402
+19
+2014-08-10
+89.2
mL/min
-
414130
-1010
-1988-08-12
-67.5
-mL/min/{1.73_m2}
-
-
414705
-1010
-1988-12-23
-44.3
+5508
+19
+2014-10-05
+52.3
mL/min/{1.73_m2}
-
414559
-1010
-1989-02-17
-53.5
+6677
+19
+2014-11-02
+50.2
mL/min/{1.73_m2}
-
413565
-1010
-1989-03-29
-86.0
+5659
+19
+2015-08-31
+68.2
mL/min
-
-413781
-1010
-1989-04-21
-31.7
-mL/min/{1.73_m2}
-
-
-413405
-1010
-1989-07-28
-39.9
-mL/min/{1.73_m2}
-
-
-413432
-1010
-1989-08-18
-37.2
-mL/min/{1.73_m2}
-
-
-412404
-1010
-1989-09-15
-44.9
-mL/min/{1.73_m2}
-
-
414824
-1010
-1989-10-20
-52.6
+6101
+19
+2015-10-11
+35.5
mL/min/{1.73_m2}
-
412854
-1010
-1990-01-19
-43.1
+5780
+19
+2016-02-28
+35.0
mL/min/{1.73_m2}
-
414098
-1010
-1990-03-29
-83.8
+5543
+19
+2016-08-30
+75.5
mL/min
-
-412564
-1010
-1990-04-13
-56.9
-mL/min/{1.73_m2}
-
-
-412917
-1010
-1990-07-13
-40.2
-mL/min/{1.73_m2}
-
-
-413845
-1010
-1990-08-10
-40.6
-mL/min/{1.73_m2}
-
-
-413163
-1010
-1990-08-24
-44.1
-mL/min/{1.73_m2}
-
-
414411
-1010
-1990-10-12
-40.0
+5971
+19
+2016-10-16
+55.4
mL/min/{1.73_m2}
-
414306
-1010
-1991-01-11
-43.8
+5870
+19
+2016-11-27
+31.9
mL/min/{1.73_m2}
-
412350
-1010
-1991-02-15
-55.8
+6206
+19
+2016-12-25
+36.5
mL/min/{1.73_m2}
-
413469
-1010
-1991-03-29
-79.3
+5650
+19
+2017-08-30
+69.1
mL/min
-
-413650
-1010
-1991-03-29
-31.9
-mL/min/{1.73_m2}
-
-
-412360
-1010
-1991-04-19
-38.4
-mL/min/{1.73_m2}
-
-
414592
-1010
-1991-05-17
-34.8
+6536
+19
+2017-10-22
+54.1
mL/min/{1.73_m2}
-
412638
-1010
-1991-06-07
-50.0
-mL/min/{1.73_m2}
+6477
+19
+2018-08-30
+66.6
+mL/min
-
413550
-1010
-1991-08-30
-33.5
+5895
+19
+2018-10-28
+40.5
mL/min/{1.73_m2}
-
413132
-1010
-1991-10-11
-47.0
+5842
+19
+2018-11-18
+47.1
mL/min/{1.73_m2}
-
412707
-1010
-1991-12-06
-54.4
+6579
+19
+2018-12-16
+35.3
mL/min/{1.73_m2}
-
-412530
-1010
-1992-03-13
-47.8
-mL/min/{1.73_m2}
-
-
-414725
-1010
-1992-03-28
-69.9
+6121
+19
+2019-08-30
+71.7
mL/min
-
-412734
-1010
-1992-04-10
-35.7
-mL/min/{1.73_m2}
-
-
-413169
-1010
-1992-09-04
-55.9
-mL/min/{1.73_m2}
-
-
414597
-1010
-1992-09-18
-50.4
-mL/min/{1.73_m2}
-
-
414012
-1010
-1992-10-02
-54.1
+6615
+19
+2019-09-22
+48.9
mL/min/{1.73_m2}
-
413326
-1010
-1992-11-27
-32.7
+5633
+19
+2019-11-03
+34.0
mL/min/{1.73_m2}
-
413359
-1010
-1993-01-29
-40.3
+6033
+19
+2020-07-12
+38.6
mL/min/{1.73_m2}
-
413218
-1010
-1993-03-28
-65.2
+5535
+19
+2020-08-29
+76.4
mL/min
-
-413205
-1010
-1993-04-02
-37.0
-mL/min/{1.73_m2}
-
-
-413623
-1010
-1993-04-30
-33.4
+6724
+19
+2020-10-04
+39.4
mL/min/{1.73_m2}
-
413673
-1010
-1993-07-04
-31.5
-mL/min
-
-
412758
-1010
-1993-08-27
-48.3
+6308
+19
+2020-11-08
+39.6
mL/min/{1.73_m2}
-
414233
-1010
-1993-09-10
-58.6
+5477
+19
+2020-11-22
+32.6
mL/min/{1.73_m2}
-
412596
-1010
-1993-09-24
-41.4
+5412
+19
+2021-07-04
+32.5
mL/min/{1.73_m2}
-
-414880
-1010
-1993-11-26
-55.1
-mL/min/{1.73_m2}
-
-
-414761
-1010
-1993-12-31
-50.2
+6416
+19
+2021-08-01
+40.1
mL/min/{1.73_m2}
-
414231
-1010
-1994-01-19
-53.8
-mL/min
-
-
414378
-1010
-1994-01-19
-53.8
+5561
+19
+2021-08-29
+74.6
mL/min
-
413908
-1010
-1994-03-04
-57.7
+6184
+19
+2021-10-03
+42.0
mL/min/{1.73_m2}
-
-413251
-1010
-1994-03-28
-86.1
-mL/min
-
-
-413515
-1010
-1994-06-03
-33.9
+6779
+19
+2021-11-14
+31.9
mL/min/{1.73_m2}
-
413722
-1010
-1994-07-19
-43.3
-mL/min
-
-
414143
-1010
-1994-07-19
-43.3
+5703
+19
+2022-08-29
+67.6
mL/min
-
-414536
-1010
-1994-09-16
-47.8
-mL/min/{1.73_m2}
-
-
-412888
-1010
-1994-10-07
-40.6
+6508
+19
+2022-10-30
+45.5
mL/min/{1.73_m2}
-
413798
-1010
-1995-03-28
-72.3
-mL/min
-Produce events for Atlas
-
-2022-02-11
-1
-0.3
-2000000001
-
-2016-01-29
3
0.5
2000000001
+
-2014-08-10
19
0.7
2000000001
+
-2016-11-27
19
1.6
2000000001
+
-2018-12-16
19
0.8
2000000001
+
-2019-11-03
19
1.0
2000000001
+
-2020-11-22
19
0.6
2000000001
+
-2021-11-14
19
0.8
2000000001
+
-2021-02-21
30
0.4
2000000001
+
+2021-02-23
30
0.3
2000000001
+
-
-
+
+
2021-02-24
+30
+0.3
+2000000001
+Computing aggregates from a phenotype result
@@ -2530,71 +2530,71 @@ Computing aggregates from a phenotype result
11872
34.82498
-36.71216
+36.72123
38.41281
81
22242
27.40980
-28.88162
+28.91259
30.29330
78
22906
27.58095
-29.15314
+29.46034
30.35070
76
4191
27.40982
-28.88852
+28.92541
30.28767
75
20198
27.53843
-29.02783
+29.35831
30.34387
73
5274
27.42844
-29.11970
+29.46449
30.36412
72
18843
27.14441
-28.85581
+29.09229
30.09168
71
-
-1665
-27.32200
-28.79019
-30.09031
-69
-
+10583
27.57425
-29.13246
+29.14332
30.36699
69
+
1665
+27.32200
+29.18407
+30.09031
+69
+
-
@@ -2607,93 +2607,74 @@ 5333
-27.27405
-28.78132
-30.08615
+8055
+27.60844
+28.86689
+30.37667
68
Obtain SQL query that computes the phenotype
.clip_sql
option in calculate_formula()
.
code_shot(bmi)
SELECT
-"row_id",
- "pid",
- "ts",
- "window",
- "height_value_as_number",
- "weight_value_as_number",
- "height_in_meters",
- "bmi"
- FROM (
-SELECT
- *,
- lag(pid) OVER (PARTITION BY "pid" ORDER BY "ts") AS "phea_kco_lag1",
- lag(height_in_meters) OVER (PARTITION BY "pid" ORDER BY "ts") AS "phea_kco_lag2",
- lag(bmi) OVER (PARTITION BY "pid" ORDER BY "ts") AS "phea_kco_lag3"
- FROM (
- SELECT
- *,
- / (height_in_meters * height_in_meters) AS "bmi"
- weight_value_as_number FROM (
- SELECT
- "row_id",
- "pid",
- "ts",
- "window",
- "height_value_as_number",
- "weight_value_as_number",
- / 100 AS "height_in_meters"
- height_value_as_number FROM (
- SELECT
- *,
- greatest(weight_ts, height_ts) - least(weight_ts, height_ts) AS "window",
- last_value(row_id) over (partition by "pid", "ts") AS "phea_ts_row"
+ *,
+ / (height_in_meters * height_in_meters) AS "bmi"
+ weight_value_as_number FROM (
+SELECT
+ "row_id",
+ "pid",
+ "ts",
+ "window",
+ "height_value_as_number",
+ "weight_value_as_number",
+ / 100 AS "height_in_meters"
+ height_value_as_number FROM (
+ SELECT
+ *,
+ greatest(weight_ts, height_ts) - least(weight_ts, height_ts) AS "window",
+ last_value(row_id) over (partition by "pid", "ts") AS "phea_ts_row"
+ FROM (
+ SELECT
+ "row_id",
+ "pid",
+ "ts",
+ MAX("weight_value_as_number") OVER (PARTITION BY "pid", "..dbplyr_partion_1") AS "weight_value_as_number",
+ MAX("weight_ts") OVER (PARTITION BY "pid", "..dbplyr_partion_2") AS "weight_ts",
+ MAX("height_value_as_number") OVER (PARTITION BY "pid", "..dbplyr_partion_3") AS "height_value_as_number",
+ MAX("height_ts") OVER (PARTITION BY "pid", "..dbplyr_partion_4") AS "height_ts"
+ FROM (
+ SELECT
+ *,
+ SUM(CASE WHEN (("weight_value_as_number" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_1",
+ SUM(CASE WHEN (("weight_ts" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_2",
+ SUM(CASE WHEN (("height_value_as_number" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_3",
+ SUM(CASE WHEN (("height_ts" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_4"
FROM (
SELECT
- "row_id",
+ row_number() over () AS "row_id",
"pid",
"ts",
- MAX("weight_value_as_number") OVER (PARTITION BY "pid", "..dbplyr_partion_1") AS "weight_value_as_number",
- MAX("weight_ts") OVER (PARTITION BY "pid", "..dbplyr_partion_2") AS "weight_ts",
- MAX("height_value_as_number") OVER (PARTITION BY "pid", "..dbplyr_partion_3") AS "height_value_as_number",
- MAX("height_ts") OVER (PARTITION BY "pid", "..dbplyr_partion_4") AS "height_ts"
+ last_value(case when "name" = 'sh6icwld' then "value_as_number" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "weight_value_as_number",
+ last_value(case when "name" = 'sh6icwld' then "ts" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "weight_ts",
+ last_value(case when "name" = 'fx43o2rt' then "value_as_number" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "height_value_as_number",
+ last_value(case when "name" = 'fx43o2rt' then "ts" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "height_ts"
FROM (
- SELECT
- *,
- SUM(CASE WHEN (("weight_value_as_number" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_1",
- SUM(CASE WHEN (("weight_ts" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_2",
- SUM(CASE WHEN (("height_value_as_number" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_3",
- SUM(CASE WHEN (("height_ts" IS NULL)) THEN 0 ELSE 1 END) OVER (PARTITION BY "pid" ORDER BY "pid", "ts" ROWS UNBOUNDED PRECEDING) AS "..dbplyr_partion_4"
- FROM (
- SELECT
- row_number() over () AS "row_id",
- "pid",
- "ts",
- last_value(case when "name" = 'tkvriq8w' then "value_as_number" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "weight_value_as_number",
- last_value(case when "name" = 'tkvriq8w' then "ts" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "weight_ts",
- last_value(case when "name" = 'dfjwhsaq' then "value_as_number" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "height_value_as_number",
- last_value(case when "name" = 'dfjwhsaq' then "ts" else null end) over (partition by "pid", "name" order by "ts" rows between unbounded preceding and current row) AS "height_ts"
- FROM (
-
- (SELECT
- 'tkvriq8w' AS "name",
- "person_id" AS "pid",
- "measurement_datetime" AS "ts",
- "value_as_number"
- FROM "cdm_new_york3"."measurement"
- WHERE ("measurement_concept_id" = 3025315.0)
-
- )UNION ALL
-
- (SELECT
- 'dfjwhsaq' AS "name",
- "person_id" AS "pid",
- "measurement_datetime" AS "ts",
- "value_as_number"
- FROM "cdm_new_york3"."measurement"
- WHERE ("measurement_concept_id" = 3036277.0)
-
- )"q01"
- ) "q02"
- ) "q03"
- ) "q04"
- ) "q05"
- ) WHERE ("row_id" = "phea_ts_row")
- "q06"
- ) "q07"
- ) "q08"
- ) WHERE ((("phea_kco_lag1" IS NULL) AND NOT(("pid" IS NULL))) OR "phea_kco_lag1" != "pid" OR (("phea_kco_lag2" IS NULL) AND NOT(("height_in_meters" IS NULL))) OR "phea_kco_lag2" != "height_in_meters" OR (("phea_kco_lag3" IS NULL) AND NOT(("bmi" IS NULL))) OR "phea_kco_lag3" != "bmi")
Computing the ISTH disseminated
-
For this vignette, we will assume you have a SQL server at
localhost
, with patient data in OMOP Common Data Model v5.4
format, inside schema cdm_new_york3
.
phea_plot(dic_score, sample(pids, 1))
#> Collecting lazy table, done. (turn this message off with `verbose = FALSE`)