Skip to content

Commit

Permalink
429 save cdm database name (#430)
Browse files Browse the repository at this point in the history
* save dev database name and schema in trainDetails
  • Loading branch information
egillax authored Mar 18, 2024
1 parent 6233377 commit 11122d4
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 18 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/R_CMD_check_Hades.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ jobs:
path: check/*.tar.gz

- name: Install covr
if: runner.os == 'Windows'
if: runner.os == 'Linux'
run: |
remotes::install_cran("covr")
shell: Rscript {0}

- name: Test coverage
if: runner.os == 'Windows'
if: runner.os == 'Linux'
run: covr::codecov()
shell: Rscript {0}

Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ Remotes:
ohdsi/FeatureExtraction,
ohdsi/ShinyAppBuilder,
ohdsi/ResultModelManager,
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Encoding: UTF-8
8 changes: 4 additions & 4 deletions R/AdditionalCovariates.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#' @param cohortTable the table name that contains the target population cohort
#' @param rowIdField string representing the unique identifier in the target population cohort
#' @param aggregated whether the covariate should be aggregated
#' @param cohortId cohort id for the target cohort
#' @param cohortIds cohort id for the target cohort
#' @param covariateSettings settings for the covariate cohorts and time periods
#'
#' @return
Expand All @@ -45,7 +45,7 @@ getCohortCovariateData <- function(
cohortTable = "#cohort_person",
rowIdField = "row_id",
aggregated,
cohortId,
cohortIds,
covariateSettings
){

Expand All @@ -69,7 +69,7 @@ getCohortCovariateData <- function(
sql,
covariate_cohort_schema = covariateSettings$cohortDatabaseSchema,
covariate_cohort_table = covariateSettings$cohortTable,
covariate_cohort_id = covariateSettings$cohortId,
covariate_cohort_id = covariateSettings$cohortIds,
cohort_temp_table = cohortTable,
row_id_field = rowIdField,
startDay = covariateSettings$startDay,
Expand Down Expand Up @@ -191,7 +191,7 @@ createCohortCovariateSettings <- function(
covariateId = cohortId*100000+settingId*1000+analysisId,
cohortDatabaseSchema = cohortDatabaseSchema,
cohortTable = cohortTable,
cohortId = cohortId,
cohortIds = cohortId,
startDay = startDay,
endDays = endDay,
count = count,
Expand Down
3 changes: 2 additions & 1 deletion R/CyclopsModels.R
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ fitCyclopsModel <- function(
trainDetails = list(
analysisId = analysisId,
analysisSource = '', #TODO add from model
developmentDatabase = attr(trainData, "metaData")$cdmDatabaseSchema,
developmentDatabase = attr(trainData, "metaData")$cdmDatabaseName,
developmentDatabaseSchema = attr(trainData, "metaData")$cdmDatabaseSchema,
attrition = attr(trainData, "metaData")$attrition,
trainingTime = paste(as.character(abs(comp)), attr(comp,'units')),
trainingDate = Sys.Date(),
Expand Down
2 changes: 2 additions & 0 deletions R/DataSplitting.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ splitData <- function(plpData = plpData,
outcomeId = attr(population, "metaData")$outcomeId,
targetId = attr(population, "metaData")$targetId,
cdmDatabaseSchema = plpData$metaData$databaseDetails$cdmDatabaseSchema,
cdmDatabaseName = plpData$metaData$databaseDetails$cdmDatabaseName,
cdmDatabaseId = plpData$metaData$databaseDetails$cdmDatabaseId,
restrictPlpDataSettings = attr(population, "metaData")$restrictPlpDataSettings,
covariateSettings = plpData$metaData$covariateSettings,
Expand Down Expand Up @@ -186,6 +187,7 @@ splitData <- function(plpData = plpData,
outcomeId = attr(population, "metaData")$outcomeId,
targetId = attr(population, "metaData")$targetId,
cdmDatabaseSchema = plpData$metaData$databaseDetails$cdmDatabaseSchema,
cdmDatabaseName = plpData$metaData$databaseDetails$cdmDatabaseName,
cdmDatabaseId = plpData$metaData$databaseDetails$cdmDatabaseId,
restrictPlpDataSettings = attr(population, "metaData")$restrictPlpDataSettings,
covariateSettings = plpData$metaData$covariateSettings,
Expand Down
2 changes: 2 additions & 0 deletions R/HelperFunctions.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# fix issue with nrow - temp fix for me locally
nrow <- function(x){UseMethod("nrow",x)}
#' @exportS3Method NULL
nrow.default <- base::nrow
#' @exportS3Method NULL
nrow.tbl <- function(x){x %>% dplyr::tally() %>% dplyr::pull()}


Expand Down
3 changes: 2 additions & 1 deletion R/KNN.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ fitKNN <- function(trainData, modelSettings, search = 'none', analysisId, ...){

trainDetails = list(
analysisId = analysisId,
developmentDatabase = attr(trainData, "metaData")$cdmDatabaseSchema,
developmentDatabase = attr(trainData, "metaData")$cdmDatabaseName,
developmentDatabaseSchema = attr(trainData, "metaData")$cdmDatabaseSchema,
attrition = attr(trainData, "metaData")$attrition,
trainingTime = paste(as.character(abs(comp)), attr(comp,'units')),
trainingDate = Sys.Date(),
Expand Down
3 changes: 1 addition & 2 deletions R/PatientLevelPrediction.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
#'
#' @description A package for running predictions using data in the OMOP CDM
#'
#' @docType package
#' @name PatientLevelPrediction
#' @keywords internal
#' @importFrom dplyr %>%
#' @importFrom rlang .data
NULL
"_PACKAGE"

#' A simulation profile
#' @docType data
Expand Down
3 changes: 2 additions & 1 deletion R/RClassifier.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ fitRclassifier <- function(
trainDetails = list(
analysisId = analysisId,
analysisSource = '', #TODO add from model
developmentDatabase = attr(trainData, "metaData")$cdmDatabaseSchema,
developmentDatabase = attr(trainData, "metaData")$cdmDatabaseName,
developmentDatabaseSchema = attr(trainData, "metaData")$cdmDatabaseSchema,
attrition = attr(trainData, "metaData")$attrition,
trainingTime = paste(as.character(abs(comp)), attr(comp,'units')),
trainingDate = Sys.Date(),
Expand Down
3 changes: 2 additions & 1 deletion R/Simulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ simulatePlpData <- function(plpDataSimulationProfile, n = 10000) {
metaData = list()

metaData$databaseDetails <- list(
cdmDatabaseSchema = 'Profile',
cdmDatabaseSchema = 'CDM_SCHEMA',
cdmDatabaseName = "CDM_NAME",
outcomeDatabaseSchema = NULL,
cohortDatabaseSchema = NULL,
connectionDetails = NULL,
Expand Down
3 changes: 2 additions & 1 deletion R/SklearnClassifier.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ fitSklearn <- function(
trainDetails = list(
analysisId = analysisId,
analysisSource = '', #TODO add from model
developmentDatabase = attr(trainData, "metaData")$cdmDatabaseSchema,
developmentDatabase = attr(trainData, "metaData")$cdmDatabaseName,
developmentDatabaseSchema = attr(trainData, "metaData")$cdmDatabaseSchema,
attrition = attr(trainData, "metaData")$attrition,
trainingTime = paste(as.character(abs(comp)), attr(comp,'units')),
trainingDate = Sys.Date(),
Expand Down
23 changes: 23 additions & 0 deletions man/PatientLevelPrediction.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/getCohortCovariateData.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-covariateExtras.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ covs <- FeatureExtraction::getDbCovariateData(
cohortTable = "cohort",
cohortDatabaseSchema = "main",
cohortTableIsTemp = F,
cohortId = 1,
cohortIds = c(1),
rowIdField = 'rowId',
covariateSettings = covSet,
aggregated = F
Expand Down

0 comments on commit 11122d4

Please sign in to comment.