### Load Libraries and Create CDM Reference Source: https://github.com/darwin-eu/drugutilisation/blob/main/README.md Loads necessary R libraries and creates a mock CDM reference for testing purposes. For real database connections, refer to CDMConnector documentation. ```r library(DrugUtilisation) library(dplyr) library(CDMConnector) cdm <- mockDrugUtilisation(numberIndividual = 100, source = "duckdb") ``` -------------------------------- ### Add Initial Daily Dose with Missing Ingredient ID or Concept Set Source: https://github.com/darwin-eu/drugutilisation/blob/main/tests/testthat/_snaps/addDrugUtilisation.md Demonstrates the error from `addInitialDailyDose` when neither `ingredientConceptId` nor `conceptSet` is supplied. The function requires at least one of these parameters. ```r addInitialDailyDose(cdm$dus_cohort, NULL) ``` -------------------------------- ### Add Initial Quantity with NULL Concept Set Source: https://github.com/darwin-eu/drugutilisation/blob/main/tests/testthat/_snaps/addDrugUtilisation.md Highlights the error generated by `addInitialQuantity` when `conceptSet` is NULL. A named list of concept IDs is mandatory. ```r addInitialQuantity(cdm$dus_cohort, NULL) ``` -------------------------------- ### Generate Ingredient Cohort Set for Acetaminophen Users Source: https://github.com/darwin-eu/drugutilisation/blob/main/README.md Creates a cohort of acetaminophen users by concatenating drug records with less than 7 days gap. Filters for the first drug entry per person and requires at least 30 days of prior observation. ```r cdm <- generateIngredientCohortSet( cdm = cdm, name = "dus_cohort", ingredient = "acetaminophen", gapEra = 7 ) cdm$dus_cohort |> requireIsFirstDrugEntry() |> requireObservationBeforeDrug(days = 30) ``` -------------------------------- ### Add Days Exposed with NULL Concept Set Source: https://github.com/darwin-eu/drugutilisation/blob/main/tests/testthat/_snaps/addDrugUtilisation.md Illustrates the error when `addDaysExposed` is used without a valid `conceptSet`. A named list of concept IDs is required. ```r addDaysExposed(cdm$dus_cohort, NULL, gapEra = 1) ``` -------------------------------- ### Create Indication Cohorts Source: https://github.com/darwin-eu/drugutilisation/blob/main/README.md Defines and generates cohorts for specific indications like headache and influenza. These are used to categorize patients based on their medical conditions. ```r indications <- list(headache = 378253, influenza = 4266367) cdm <- generateConceptCohortSet( cdm = cdm, conceptSet = indications, name = "indications_cohort" ) ``` -------------------------------- ### Add Time to Exposure with NULL Concept Set Source: https://github.com/darwin-eu/drugutilisation/blob/main/tests/testthat/_snaps/addDrugUtilisation.md Shows the error message when `addTimeToExposure` is called with a NULL `conceptSet`. The function expects a named list of concept IDs. ```r addTimeToExposure(cdm$dus_cohort, NULL) ``` -------------------------------- ### Add Number of Eras with NULL Concept Set Source: https://github.com/darwin-eu/drugutilisation/blob/main/tests/testthat/_snaps/addDrugUtilisation.md Demonstrates the error when `addNumberEras` is called with a NULL `conceptSet`. The `conceptSet` must be a named list of concept IDs. ```r addNumberEras(cdm$dus_cohort, NULL, gapEra = 1) ``` -------------------------------- ### Add Drug Utilization with Missing Ingredient ID or Concept Set Source: https://github.com/darwin-eu/drugutilisation/blob/main/tests/testthat/_snaps/addDrugUtilisation.md Illustrates the error when `addDrugUtilisation` is called without providing `ingredientConceptId` or `conceptSet`. One of these is mandatory for the function to execute. ```r addDrugUtilisation(cdm$dus_cohort, gapEra = 1) ``` -------------------------------- ### Add Number of Exposures with NULL Concept Set Source: https://github.com/darwin-eu/drugutilisation/blob/main/tests/testthat/_snaps/addDrugUtilisation.md Illustrates the error when `addNumberExposures` is called with a NULL `conceptSet`. A named list of concept IDs is required for this function. ```r addNumberExposures(cdm$dus_cohort, NULL) ``` -------------------------------- ### Summarise Indications Source: https://github.com/darwin-eu/drugutilisation/blob/main/README.md Summarizes the indications for a given cohort, specifying the indication cohort name and the time window relative to the index date. Requires the 'condition_occurrence' table for unknown indications. ```r indication_summary <- cdm$dus_cohort | summariseIndication( indicationCohortName = "indications_cohort", unknownIndicationTable = "condition_occurrence", indicationWindow = list(c(-30, 0)) ) indication_summary |> glimpse() ``` -------------------------------- ### Summarise Drug Utilisation Source: https://github.com/darwin-eu/drugutilisation/blob/main/README.md Calculates a summary of drug utilization for a specified ingredient concept ID and gap era. This provides metrics such as number of records, subjects, days exposed, and cumulative dose. ```r drug_utilisation_summary <- cdm$dus_cohort | summariseDrugUtilisation( ingredientConceptId = 1125315, gapEra = 7 ) drug_utilisation_summary |> glimpse() ``` ```r table(drug_utilisation_summary$variable_name) ``` -------------------------------- ### Add Cumulative Quantity with NULL Concept Set Source: https://github.com/darwin-eu/drugutilisation/blob/main/tests/testthat/_snaps/addDrugUtilisation.md Demonstrates the error from `addCumulativeQuantity` when `conceptSet` is not provided. The function requires a named list of concept IDs. ```r addCumulativeQuantity(cdm$dus_cohort, NULL) ``` -------------------------------- ### Combine and Suppress Drug Utilization Results in R Source: https://github.com/darwin-eu/drugutilisation/blob/main/README.md Combines results from indication and drug utilization summaries and suppresses counts less than 5. Use this to prepare data for sharing. ```r results <- bind( indication_summary, drug_utilisation_summary ) |> suppress(minCellCount = 5) results |> glimpse() #> Rows: 84 #> Columns: 13 #> $ result_id 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,… #> $ cdm_name "DUS MOCK", "DUS MOCK", "DUS MOCK", "DUS MOCK", "DUS … #> $ group_name "cohort_name", "cohort_name", "cohort_name", "cohort_… #> $ group_level "acetaminophen", "acetaminophen", "acetaminophen", "a… #> $ strata_name "overall", "overall", "overall", "overall", "overall"… #> $ strata_level "overall", "overall", "overall", "overall", "overall"… #> $ variable_name "Indication from 30 days before to the index date", "… #> $ variable_level "headache", "headache", "influenza", "influenza", "he… #> $ estimate_name "count", "percentage", "count", "percentage", "count"… #> $ estimate_type "integer", "percentage", "integer", "percentage", "in… #> $ estimate_value "10", "17.5438596491228", "11", "19.2982456140351", "… #> $ additional_name "window_name", "window_name", "window_name", "window_… #> $ additional_level "-30 to 0", "-30 to 0", "-30 to 0", "-30 to 0", "-30 … ``` -------------------------------- ### Add Cumulative Dose with Missing Ingredient ID or Concept Set Source: https://github.com/darwin-eu/drugutilisation/blob/main/tests/testthat/_snaps/addDrugUtilisation.md Shows the error message when `addCumulativeDose` is called without specifying either `ingredientConceptId` or `conceptSet`. One of these must be provided. ```r addCumulativeDose(cdm$dus_cohort, NULL) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.