-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from OHDSI/cran_deps
all deps from cran
- Loading branch information
Showing
4 changed files
with
97 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,24 @@ | ||
#' Create a report summarising your phenotyping results | ||
#' | ||
#' @inheritParams resultDoc | ||
#' @inheritParams directoryDoc | ||
#' | ||
#' @return A report | ||
#' @noRd | ||
reportDiagnostics <- function(result, | ||
directory = here::here()){ | ||
|
||
input <- system.file("rmd", "phenotype_report.Rmd", | ||
package = "PhenotypeR") | ||
|
||
cohortNames <- result |> | ||
visOmopResults::addSettings() |> | ||
omopgenerics::filter(.data$result_type == "summarised_characteristics") |> | ||
dplyr::filter(.data$group_level != "overall") |> | ||
dplyr::select("group_level") |> | ||
dplyr::distinct() |> | ||
dplyr::pull() | ||
cohortNames <- paste0(cohortNames, collapse = "; ") | ||
workingTitle <- paste('PhenotypeR results for cohort', cohortNames) | ||
|
||
rmarkdown::render(input = input, | ||
params = list(title = workingTitle, | ||
result = result), | ||
output_file = "report.html", | ||
output_dir = directory, | ||
clean = TRUE) | ||
} | ||
# reportDiagnostics <- function(result, | ||
# directory = here::here()){ | ||
# | ||
# input <- system.file("rmd", "phenotype_report.Rmd", | ||
# package = "PhenotypeR") | ||
# | ||
# cohortNames <- result |> | ||
# visOmopResults::addSettings() |> | ||
# omopgenerics::filter(.data$result_type == "summarised_characteristics") |> | ||
# dplyr::filter(.data$group_level != "overall") |> | ||
# dplyr::select("group_level") |> | ||
# dplyr::distinct() |> | ||
# dplyr::pull() | ||
# cohortNames <- paste0(cohortNames, collapse = "; ") | ||
# workingTitle <- paste('PhenotypeR results for cohort', cohortNames) | ||
# | ||
# rmarkdown::render(input = input, | ||
# params = list(title = workingTitle, | ||
# result = result), | ||
# output_file = "report.html", | ||
# output_dir = directory, | ||
# clean = TRUE) | ||
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,72 @@ | ||
test_that("basic working example with one cohort", { | ||
|
||
cdm_local <- omock::mockCdmReference() |> | ||
omock::mockPerson(nPerson = 100) |> | ||
omock::mockObservationPeriod() |> | ||
omock::mockConditionOccurrence() |> | ||
omock::mockDrugExposure() |> | ||
omock::mockObservation() |> | ||
omock::mockMeasurement() |> | ||
omock::mockCohort(name = "my_cohort") | ||
cdm_local$visit_occurrence <- dplyr::tibble( | ||
person_id = 1L, | ||
visit_occurrence_id = 1L, | ||
visit_concept_id = 1L, | ||
visit_start_date = as.Date("2000-01-01"), | ||
visit_end_date = as.Date("2000-01-01"), | ||
visit_type_concept_id = 1L | ||
) | ||
cdm_local$procedure_occurrence <- dplyr::tibble( | ||
person_id = 1L, | ||
procedure_occurrence_id = 1L, | ||
procedure_concept_id = 1L, | ||
procedure_date = as.Date("2000-01-01"), | ||
procedure_type_concept_id = 1L | ||
) | ||
|
||
db <- DBI::dbConnect(duckdb::duckdb()) | ||
cdm <- CDMConnector::copyCdmTo(con = db, cdm = cdm_local, | ||
schema ="main", overwrite = TRUE) | ||
my_result <- cdm$my_cohort |> cohortDiagnostics() | ||
expect_no_error(reportDiagnostics(result = my_result)) | ||
|
||
CDMConnector::cdm_disconnect(cdm ) | ||
}) | ||
|
||
test_that("basic working example with two cohorts", { | ||
|
||
cdm_local <- omock::mockCdmReference() |> | ||
omock::mockPerson(nPerson = 100) |> | ||
omock::mockObservationPeriod() |> | ||
omock::mockConditionOccurrence() |> | ||
omock::mockDrugExposure() |> | ||
omock::mockObservation() |> | ||
omock::mockMeasurement() |> | ||
omock::mockCohort(name = "my_cohort", | ||
numberCohorts = 2) | ||
cdm_local$visit_occurrence <- dplyr::tibble( | ||
person_id = 1L, | ||
visit_occurrence_id = 1L, | ||
visit_concept_id = 1L, | ||
visit_start_date = as.Date("2000-01-01"), | ||
visit_end_date = as.Date("2000-01-01"), | ||
visit_type_concept_id = 1L | ||
) | ||
cdm_local$procedure_occurrence <- dplyr::tibble( | ||
person_id = 1L, | ||
procedure_occurrence_id = 1L, | ||
procedure_concept_id = 1L, | ||
procedure_date = as.Date("2000-01-01"), | ||
procedure_type_concept_id = 1L | ||
) | ||
|
||
db <- DBI::dbConnect(duckdb::duckdb()) | ||
cdm <- CDMConnector::copyCdmTo(con = db, cdm = cdm_local, | ||
schema ="main", overwrite = TRUE) | ||
my_result <- cdm$my_cohort |> cohortDiagnostics() | ||
expect_no_error(reportDiagnostics(result = my_result)) | ||
|
||
CDMConnector::cdm_disconnect(cdm ) | ||
|
||
|
||
}) | ||
# test_that("basic working example with one cohort", { | ||
# | ||
# cdm_local <- omock::mockCdmReference() |> | ||
# omock::mockPerson(nPerson = 100) |> | ||
# omock::mockObservationPeriod() |> | ||
# omock::mockConditionOccurrence() |> | ||
# omock::mockDrugExposure() |> | ||
# omock::mockObservation() |> | ||
# omock::mockMeasurement() |> | ||
# omock::mockCohort(name = "my_cohort") | ||
# cdm_local$visit_occurrence <- dplyr::tibble( | ||
# person_id = 1L, | ||
# visit_occurrence_id = 1L, | ||
# visit_concept_id = 1L, | ||
# visit_start_date = as.Date("2000-01-01"), | ||
# visit_end_date = as.Date("2000-01-01"), | ||
# visit_type_concept_id = 1L | ||
# ) | ||
# cdm_local$procedure_occurrence <- dplyr::tibble( | ||
# person_id = 1L, | ||
# procedure_occurrence_id = 1L, | ||
# procedure_concept_id = 1L, | ||
# procedure_date = as.Date("2000-01-01"), | ||
# procedure_type_concept_id = 1L | ||
# ) | ||
# | ||
# db <- DBI::dbConnect(duckdb::duckdb()) | ||
# cdm <- CDMConnector::copyCdmTo(con = db, cdm = cdm_local, | ||
# schema ="main", overwrite = TRUE) | ||
# my_result <- cdm$my_cohort |> cohortDiagnostics() | ||
# expect_no_error(reportDiagnostics(result = my_result)) | ||
# | ||
# CDMConnector::cdm_disconnect(cdm ) | ||
# }) | ||
# | ||
# test_that("basic working example with two cohorts", { | ||
# | ||
# cdm_local <- omock::mockCdmReference() |> | ||
# omock::mockPerson(nPerson = 100) |> | ||
# omock::mockObservationPeriod() |> | ||
# omock::mockConditionOccurrence() |> | ||
# omock::mockDrugExposure() |> | ||
# omock::mockObservation() |> | ||
# omock::mockMeasurement() |> | ||
# omock::mockCohort(name = "my_cohort", | ||
# numberCohorts = 2) | ||
# cdm_local$visit_occurrence <- dplyr::tibble( | ||
# person_id = 1L, | ||
# visit_occurrence_id = 1L, | ||
# visit_concept_id = 1L, | ||
# visit_start_date = as.Date("2000-01-01"), | ||
# visit_end_date = as.Date("2000-01-01"), | ||
# visit_type_concept_id = 1L | ||
# ) | ||
# cdm_local$procedure_occurrence <- dplyr::tibble( | ||
# person_id = 1L, | ||
# procedure_occurrence_id = 1L, | ||
# procedure_concept_id = 1L, | ||
# procedure_date = as.Date("2000-01-01"), | ||
# procedure_type_concept_id = 1L | ||
# ) | ||
# | ||
# db <- DBI::dbConnect(duckdb::duckdb()) | ||
# cdm <- CDMConnector::copyCdmTo(con = db, cdm = cdm_local, | ||
# schema ="main", overwrite = TRUE) | ||
# my_result <- cdm$my_cohort |> cohortDiagnostics() | ||
# expect_no_error(reportDiagnostics(result = my_result)) | ||
# | ||
# CDMConnector::cdm_disconnect(cdm ) | ||
# | ||
# | ||
# }) |