makeDose: Make Dose Data

View source: R/makeDose.R

makeDoseR Documentation

Make Dose Data

Description

Takes parsed and paired medication data, calculates dose intake and daily dose, and removes redundant information at the note and date level.

Usage

makeDose(x, noteMetaData, naFreq = "most")

Arguments

x

data.frame containing the output of buildDose, or the output of addLastDose if last dose information is being incorporated.

noteMetaData

data.frame containing identifying meta data for each note, including patient ID, date of the note, and note ID. Column names should be set to ‘filename’, ‘pid’, ‘date’, ‘note’. Date should have format YYYY-MM-DD.

naFreq

Replacing missing frequencies with this value, or by default the most common value across the entire set in x.

Details

This function standardizes frequency, route, and duration entities. Dose amount, strength, and frequency entities are converted to numeric. Rows with only drug name and/or route are removed. If there are drug name changes in adjacent rows (e.g., from a generic to brand name), these rows are collapsed into one row if there are no conflicts. Missing strengths, dose amounts, frequencies, and routes are borrowed or imputed using various rules (see McNeer et al., 2020 for details). Dose given intake and daily dose are calculated. Redundancies are removed at the date and note level. If time of last dose is being used and it is unique within the level of collapsing, it is borrowed across all rows.

Value

A list containing two dataframes, one with the note level and one with the date level collapsed data.

Examples

data(lam_mxr_parsed)
data(lam_metadata)

lam_build_out <- buildDose(lam_mxr_parsed)

lam_collapsed <- makeDose(lam_build_out, lam_metadata)
lam_collapsed[[1]] # Note level collapsing
lam_collapsed[[2]] # Date level collapsing

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