processLastDose: Process and standardize extracted last dose times

View source: R/processLastDose.R

processLastDoseR Documentation

Process and standardize extracted last dose times


This function takes last dose times extracted using the medExtractR system and processes the times into standardized datetime objects using recorded lab data where necessary. The raw output from extractMed is filtered to just the LastDose extractions. Time expressions are standardized into HH:MM:SS format based on what category they fall into (e.g., a time represented with AM/PM, 24-hour military time, etc.). When the last dose time is after 12pm, it is assumed to have been taken one day previous to the note's date. For any duration extractions (e.g. "14 hour level"), the last dose time is calculated from the labtime by extracting the appropriate number of hours. The final dataset is returned with last dose time formatted into a POSIXct variable.


processLastDose(mxrData, noteMetaData, labData)



data.frame containing output from the medExtractR system


data.frame with meta data (pid (patient ID) and date) for the file names contained within mxrData


data.frame that contains lab dates and times associated with the file names within mxrData. Must contain columns pid and date, as well as labtime. The date column must be in the same format as date in noteMetaData, and labtime must be a POSIXct


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


data.frame with identifying information (e.g., filename, etc) as well as processed and standardized last dose times as a POSIXct column


tac_mxr <- read.csv(system.file("examples", "tac_mxr.csv", package = "EHR"))

processLastDose(mxrData = tac_mxr, noteMetaData = tac_metadata, labData = tac_lab)

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