Skip to content

Commit

Permalink
refactor therapy_table slots and methods to longitudinal_table in sup…
Browse files Browse the repository at this point in the history
…port of feature #86
  • Loading branch information
peterdutey committed Aug 2, 2022
1 parent 959e06e commit 0256ad7
Show file tree
Hide file tree
Showing 16 changed files with 160 additions and 166 deletions.
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ export(load_inpatient_episodes)
export(load_inpatient_investigations)
export(load_inpatient_microbiology)
export(load_medications)
export(longitudinal_table)
export(map_ICD10_CCS)
export(map_ICD10_CCSR)
export(map_charlson_comorbidities)
export(map_infections_abx_indications)
export(parenteral_changes)
export(therapy_table)
export(therapy_timeline)
export(transitive_closure_control)
export(validate_administrations)
Expand All @@ -47,7 +47,7 @@ exportMethods(clinical_feature_interval)
exportMethods(clinical_feature_last)
exportMethods(clinical_feature_mean)
exportMethods(clinical_feature_ols_trend)
exportMethods(therapy_table)
exportMethods(longitudinal_table)
exportMethods(therapy_timeline)
import(methods)
importClassesFrom(duckdb,duckdb_connection)
Expand Down
30 changes: 15 additions & 15 deletions R/clinical_features.R
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
if(compute) {
x <- compute(x)
}
TT <- x@therapy_table
TT <- x@longitudinal_table

therapy_record <- collect(x)
field_name <- .clinical_feature_field_name_generate(
Expand All @@ -200,7 +200,7 @@
t,
{{field_name}} := observation_value_numeric)

x@therapy_table <- dplyr::left_join(
x@longitudinal_table <- dplyr::left_join(
TT,
observations_linked,
by = c("patient_id", "t")
Expand Down Expand Up @@ -245,7 +245,7 @@
#' observation_code = "8310-5",
#' hours = 24
#' )
#' str(therapy_table(temperature_check, collect = TRUE))
#' str(longitudinal_table(temperature_check, collect = TRUE))
#' }
setGeneric(
"clinical_feature_last",
Expand Down Expand Up @@ -286,7 +286,7 @@ setMethod(
if(compute) {
x <- compute(x)
}
TT <- x@therapy_table
TT <- x@longitudinal_table

therapy_record <- collect(x)
field_name <- .clinical_feature_field_name_generate(
Expand All @@ -311,7 +311,7 @@ setMethod(
{{field_name_N}} := dplyr::n()
)

x@therapy_table <- dplyr::left_join(
x@longitudinal_table <- dplyr::left_join(
TT,
observations_linked,
by = c("patient_id", "t")
Expand Down Expand Up @@ -360,7 +360,7 @@ setMethod(
#' observation_code = "8310-5",
#' hours = 24
#' )
#' str(therapy_table(temperature_check, collect = TRUE))
#' str(longitudinal_table(temperature_check, collect = TRUE))
#' }
setGeneric(
"clinical_feature_mean",
Expand Down Expand Up @@ -400,7 +400,7 @@ setMethod(
if(compute) {
x <- compute(x)
}
TT <- x@therapy_table
TT <- x@longitudinal_table

therapy_record <- collect(x)
field_name <- .clinical_feature_field_name_generate(
Expand Down Expand Up @@ -465,7 +465,7 @@ setMethod(
{{field_name_slope}} := final_slope,
{{field_name_N}} := regression_N)

x@therapy_table <- dplyr::left_join(
x@longitudinal_table <- dplyr::left_join(
TT,
observations_linked,
by = c("patient_id", "t")
Expand Down Expand Up @@ -520,7 +520,7 @@ setMethod(
#' observation_code = "8310-5",
#' hours = 24
#' )
#' str(therapy_table(temperature_check, collect = TRUE))
#' str(longitudinal_table(temperature_check, collect = TRUE))
#' }
setGeneric(
"clinical_feature_ols_trend",
Expand Down Expand Up @@ -558,7 +558,7 @@ setMethod(
if(compute) {
x <- compute(x)
}
TT <- x@therapy_table
TT <- x@longitudinal_table
therapy_record <- collect(x)
field_name <- .clinical_feature_field_name_generate(
conn = x@conn,
Expand Down Expand Up @@ -591,7 +591,7 @@ setMethod(
dplyr::sql(sql_over) ~ 1L, TRUE ~ 0L
), na.rm = TRUE))

x@therapy_table <- dplyr::left_join(
x@longitudinal_table <- dplyr::left_join(
TT,
observations_linked,
by = c("patient_id", "t")
Expand All @@ -609,7 +609,7 @@ setMethod(
if(compute) {
x <- compute(x)
}
TT <- x@therapy_table
TT <- x@longitudinal_table
therapy_record <- collect(x)
field_name <- .clinical_feature_field_name_generate(
conn = x@conn,
Expand Down Expand Up @@ -646,7 +646,7 @@ setMethod(
dplyr::sql(sql_over) ~ 1L, TRUE ~ 0L
), na.rm = TRUE))

x@therapy_table <- dplyr::left_join(
x@longitudinal_table <- dplyr::left_join(
TT,
observations_linked,
by = c("patient_id", "t")
Expand Down Expand Up @@ -695,14 +695,14 @@ setMethod(
#' observation_intervals = list("8310-5" = c(36, 38)),
#' hours = 24
#' )
#' str(therapy_table(temperature_interval, collect = TRUE))
#' str(longitudinal_table(temperature_interval, collect = TRUE))
#'
#' temperature_threshold <- clinical_feature_interval(
#' TherapyEpisode(conSQLite, "4d611fc8886c23ab047ad5f74e5080d7"),
#' observation_intervals = list("8310-5" = 38),
#' hours = 24
#' )
#' str(therapy_table(temperature_threshold, collect = TRUE))
#' str(longitudinal_table(temperature_threshold, collect = TRUE))
#' }
#' @include objects.R
setGeneric(
Expand Down
Loading

0 comments on commit 0256ad7

Please sign in to comment.