Skip to contents

A shiny app that is designed for any diagnostics results from phenotypeR, this includes:

* A diagnostics on the database via `databaseDiagnostics`. * A diagnostics on the cohort_codelist attribute of the cohort via `codelistDiagnostics`. * A diagnostics on the cohort via `cohortDiagnostics`. * A diagnostics on the population via `populationDiagnostics`. * A diagnostics on the matched cohort via `matchedDiagnostics`.

Usage

shinyDiagnostics(result, directory, open = rlang::is_interactive())

Arguments

result

A summarised result

directory

Directory where to save report

open

If TRUE, the shiny app will be launched in a new session. If FALSE, the shiny app will be created but not launched.

Value

A shiny app

Examples

# \donttest{
  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_cohort_diag <- cdm$my_cohort |> phenotypeDiagnostics()
#> 
#> 
#>  Getting codelists from cohorts
#> Warning: No codelists found for the specified cohorts
#> Warning: Empty cohort_codelist attribute for cohort
#>  Returning an empty summarised result
#> 
#>  Getting cohort summary
#>  adding demographics columns
#>  adding tableIntersectCount 1/1
#>  summarising data
#>  summariseCharacteristics finished!
#>  Getting age density
#>  Getting cohort attrition
#> 
#>  Creating denominator for incidence and prevalence
#>  Sampling person table to 1e+06
#>  Creating denominator cohorts
#>  Cohorts created in 0 min and 7 sec
#>  Estimating incidence
#> Getting incidence for analysis 1 of 12
#> Getting incidence for analysis 2 of 12
#> Getting incidence for analysis 3 of 12
#> Getting incidence for analysis 4 of 12
#> Getting incidence for analysis 5 of 12
#> Getting incidence for analysis 6 of 12
#> Getting incidence for analysis 7 of 12
#> Getting incidence for analysis 8 of 12
#> Getting incidence for analysis 9 of 12
#> Getting incidence for analysis 10 of 12
#> Getting incidence for analysis 11 of 12
#> Getting incidence for analysis 12 of 12
#> Overall time taken: 0 mins and 9 secs
#>  Estimating prevalence
#> Getting prevalence for analysis 1 of 6
#> Getting prevalence for analysis 2 of 6
#> Getting prevalence for analysis 3 of 6
#> Getting prevalence for analysis 4 of 6
#> Getting prevalence for analysis 5 of 6
#> Getting prevalence for analysis 6 of 6
#> Time taken: 0 mins and 3 secs
#> 
#>  Taking 1000 person sample of cohorts
#>  Generating a age and sex matched cohorts
#> Starting matching
#> Warning: Multiple records per person detected. The matchCohorts() function is designed
#> to operate under the assumption that there is only one record per person within
#> each cohort. If this assumption is not met, each record will be treated
#> independently. As a result, the same individual may be matched multiple times,
#> leading to inconsistent and potentially misleading results.
#>  Creating copy of target cohort.
#>  1 cohort to be matched.
#>  Creating controls cohorts.
#>  Excluding cases from controls
#>  Matching by gender_concept_id and year_of_birth
#>  Removing controls that were not in observation at index date
#>  Excluding target records whose pair is not in observation
#>  Adjusting ratio
#> Binding cohorts
#>  Done
#>  adding demographics columns
#>  adding tableIntersectCount 1/1
#>  summarising data
#>  summariseCharacteristics finished!
#>  Running large scale characterisation
#>  Summarising large scale characteristics 
#> 
#>  - getting characteristics from table condition_occurrence (1 of 6)
#>  - getting characteristics from table visit_occurrence (2 of 6)
#>  - getting characteristics from table measurement (3 of 6)
#>  - getting characteristics from table procedure_occurrence (4 of 6)
#>  - getting characteristics from table observation (5 of 6)
#>  - getting characteristics from table drug_exposure (6 of 6)
#> 
  shinyDiagnostics(my_result_cohort_diag, tempdir())
# }