Skip to content

Commit

Permalink
Casting of time series results for Andromeda work
Browse files Browse the repository at this point in the history
  • Loading branch information
azimov committed Mar 29, 2023
1 parent acf7d74 commit 7caa095
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ License: Apache License
VignetteBuilder: knitr
URL: https://ohdsi.github.io/CohortDiagnostics, https://github.com/OHDSI/CohortDiagnostics
BugReports: https://github.com/OHDSI/CohortDiagnostics/issues
RoxygenNote: 7.2.1
RoxygenNote: 7.2.3
Encoding: UTF-8
Language: en-US
StagedInstall: no
Expand Down
5 changes: 3 additions & 2 deletions R/TimeSeries.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ runCohortTimeSeriesDiagnostics <- function(connectionDetails = NULL,
return(NULL)
}
}

## Calendar period----
ParallelLogger::logTrace(" - Preparing calendar table for time series computation.")
# note calendar span is created based on all dates in observation period table,
Expand Down Expand Up @@ -529,7 +528,7 @@ executeTimeSeriesDiagnostics <- function(connection,
if (runCohortTimeSeries & nrow(cohortDefinitionSet) > 0) {
subset <- subsetToRequiredCohorts(
cohorts = cohortDefinitionSet %>%
dplyr::filter(cohortId %in% instantiatedCohorts),
dplyr::filter(.data$cohortId %in% instantiatedCohorts),
task = "runCohortTimeSeries",
incremental = incremental,
recordKeepingFile = recordKeepingFile
Expand Down Expand Up @@ -587,6 +586,7 @@ executeTimeSeriesDiagnostics <- function(connection,
)
}
)

data <- makeDataExportable(
x = data,
tableName = "time_series",
Expand Down Expand Up @@ -648,6 +648,7 @@ executeTimeSeriesDiagnostics <- function(connection,
)
}
)

data <- makeDataExportable(
x = data,
tableName = "time_series",
Expand Down
2 changes: 1 addition & 1 deletion inst/sql/sql_server/ComputeTimeSeries1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

SELECT cohort_definition_id cohort_id,
time_id,
{@stratify_by_gender} ? {gender,} : {CAST(NULL AS VARCHAR) gender, }
{@stratify_by_gender} ? { CASE WHEN gender IS NULL THEN 'NULL' ELSE gender END} : {'NULL'} gender,
{@stratify_by_age_group} ? {FLOOR((YEAR(period_begin) - year_of_birth) / 10) age_group,} : {CAST(NULL AS INT) age_group, }
COUNT_BIG(DISTINCT CONCAT(cast(subject_id AS VARCHAR(30)), '_', cast(cohort_start_date AS VARCHAR(30)))) records,
-- records in calendar period
Expand Down
2 changes: 1 addition & 1 deletion inst/sql/sql_server/ComputeTimeSeries2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

SELECT cohort_definition_id cohort_id,
time_id,
{@stratify_by_gender} ? {gender,} : {CAST(NULL AS VARCHAR) gender, }
{@stratify_by_gender} ? {CASE WHEN gender IS NULL THEN 'NULL' ELSE gender END} : {'NULL'} gender,
{@stratify_by_age_group} ? {FLOOR((YEAR(period_begin) - year_of_birth) / 10) AS age_group,} : {CAST(NULL AS INT) age_group, }
COUNT_BIG(DISTINCT CONCAT(cast(subject_id AS VARCHAR(30)), '_', cast(observation_period_start_date AS VARCHAR(30)))) records, -- records in calendar month
COUNT_BIG(DISTINCT subject_id) subjects, -- unique subjects
Expand Down
2 changes: 1 addition & 1 deletion inst/sql/sql_server/ComputeTimeSeries3.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

SELECT -44819062 cohort_id,
time_id,
{@stratify_by_gender} ? {p.gender,} : {CAST(NULL AS VARCHAR) gender, }
{@stratify_by_gender} ? { CASE WHEN p.gender IS NULL THEN 'NULL' ELSE p.gender END} : {'NULL'} gender,
{@stratify_by_age_group} ? {FLOOR((YEAR(period_begin) - year_of_birth) / 10) AS age_group,} : {CAST(NULL AS INT) age_group, }
COUNT_BIG(DISTINCT CONCAT(cast(o.person_id AS VARCHAR(30)), '_', cast(observation_period_start_date AS VARCHAR(30)))) records, -- records in calendar month
COUNT_BIG(DISTINCT o.person_id) subjects, -- unique subjects
Expand Down

0 comments on commit 7caa095

Please sign in to comment.