addLastDose: Add Lastdose Data

View source: R/addLastDose.R

addLastDoseR Documentation

Add Lastdose Data

Description

Add lastdose data to data set from the buildDose process.

Usage

addLastDose(buildData, lastdoseData)

Arguments

buildData

data.frame, output of buildDose function.

lastdoseData

data.frame with columns filename, ld_start, lastdose, raw_time, time_type

Details

Lastdose is a datetime string associated with dose data. Information on time of last dose can be extracted within the extractMed function (i.e., medExtractR) using the argument lastdose=TRUE. Raw extracted times should first be processed using the processLastDose function to convert to datetime format before providing to addLastDose. This function then combines the processed last dose times with output from the buildDose process by file name to pair last dose times with dosing regimens based on position. Alternatively, the user can provide their own table of lastdose data. In this case, with position information absent, the lastdose data should be restricted to one unique last dose time per unique patient ID-date identifier.

In the case where lastdoseData is output from processLastDose, it is possible to have more than one extracted last dose time. In this case, rules are applied to determine which time should be kept. First, we give preference to an explicit time expression (e.g., "10:30pm") over a duration expression (e.g., "14 hour level"). Then, we pair last dose times with drug regimens based on minimum distance between last dose time start position and drug name start position.

See EHR Vignette for Extract-Med and Pro-Med-NLP for details.

Value

a data.frame with the ‘lastdose’ column added.

Examples

# Get build data
data(tac_mxr_parsed)
# don't combine lastdose at this stage
tac_build <- buildDose(tac_mxr_parsed, preserve = 'lastdose')
# Get processed last dose data
tac_mxr <- read.csv(system.file("examples", "tac_mxr.csv", package = "EHR"))
data(tac_metadata)
data(tac_lab)
ld_data <- processLastDose(tac_mxr, tac_metadata, tac_lab)

addLastDose(tac_build, ld_data)


EHR documentation built on Dec. 28, 2022, 1:31 a.m.