createMedicationTimeBlocks: Calculates the time block data for prescriptions

View source: R/createMedicationTimeBlocks.R

createMedicationTimeBlocksR Documentation

Calculates the time block data for prescriptions

Description

Calculates the time block data for prescriptions

Usage

createMedicationTimeBlocks(
  serialDf,
  baselineInfo,
  studyStartDate,
  studyEndDate,
  atcCode = "C09",
  blockDays = 365.25,
  useDoses = FALSE,
  idColumn = "PATIENT",
  dateColumn = "VISIT",
  atcColumn = "ATC",
  dddColumn = "cDDD",
  dataName = "prescription",
  longFormat = TRUE,
  noUseAtBaseline = FALSE
)

Arguments

serialDf

the data frame with the serial data

baselineInfo

dataframe with ID and baseline date

studyStartDate

start Date of the study (has to be of class Date)

studyEndDate

end Date of the study (has to be of class Date)

atcCode

regular expression for the class of medication ATC code (default: C09 which stands for any RAAS)

blockDays

length of a time block in days (default 365.25 days)

useDoses

flag indicating whether presence of prescription events or sum of doses should be used in a block (default FALSE)

idColumn

name of ID column: default is PATIENT

dateColumn

name of date column: default is VISIT. This column has to be of class Date

atcColumn

name of the column with the ATC codes: default is ATC

dddColumn

name of the column with the dosage information: default is cDDD

dataName

set a user specified name for the data column in the output: default is prescription

Value

time block data and dates in wide format

Examples

## Not run: 
baselinePatients <- read_tsv('../data/ourBaselinePatients.txt', guess_max = 3582) %>%
    select(PATIENT, VISIT = VISIT_TL)
allFimea <- read_tsv('../data/all_fimea_kela.txt')
allFimea <- allFimea %>% mutate(VISIT = ymd(allFimea$ostopv))
allFimea <- allFimea %>% mutate(PATIENT = fd)
allFimea <- allFimea %>% filter(!is.na(all_ddd)) #check these as they should not exists
medResLong <- createMedicationTimeBlocks(allFimea, baselinePatients,
   studyStartDate = as.Date('1995-01-01', '%Y-%m-%d'),
   studyEndDate = as.Date('2015-12-31', '%Y-%m-%d'),
   atcCode = 'C09', blockDays = 365.25, useDoses = FALSE, idColumn = "PATIENT", dateColumn = "VISIT",
   atcColumn = "ATC_FIMEA", dddColumn = 'all_ddd', dataName = "anyRAAS", longFormat = TRUE,
   noUseAtBaseline = FALSE)
medResWide <- createMedicationTimeBlocks(allFimea, baselinePatients,
   studyStartDate = as.Date('1995-01-01', '%Y-%m-%d'),
   studyEndDate = as.Date('2015-12-31', '%Y-%m-%d'),
   atcCode = 'C09', blockDays = 365.25, useDoses = FALSE, idColumn = "PATIENT", dateColumn = "VISIT",
   atcColumn = "ATC_FIMEA", dddColumn = 'all_ddd', dataName = "anyRAAS", longFormat = FALSE,
   noUseAtBaseline = FALSE)

## End(Not run)

smm52/timeBlocks documentation built on Nov. 27, 2022, 3:54 a.m.