This is a function to calculate the drug era
getDrugEra( df, window = 30, MemberIDColName = MemberID, DrugColName = Drug, DispenseDateColName, DaysSupplyColName, StartDateColName, EndDateColName )
| df | data.frame with MemberID ,Drug,DispenseDate ,DaysSupply, or with MemberID ,Drug, StartDate, EndDate |
|---|---|
| window | allowed gap between pharmacy claims, default is 30 |
| DrugColName | a column name for drug which patient use |
| DispenseDateColName | a column name for dispense date |
| DaysSupplyColName | A column for drug supply days |
| StartDateColName | a column name for patient use drug start day |
| EndDateColName | a column name for patient use drug end day |
A new data.table with following columns.
MemberId patient Id
DispenseDate patient`s drug dispensed date, and the time interval is from 2025-12-06 to 2038-01-25
NationalDrugCode drug NDC, total of 17,326 different drug codes
Quantity drug ration
DaysSupply days of patient`s drug supplied
Drug Era the row of medicine records belongs to the drug era
Drug Era Start Date the begin date to calculate drug era
Drug Era End Date the end date to calculate drug era
Gap interval between each drug delivery record date and the previous medication end date
Exposure Days number of days of drug era
Supply Days the days of drug era that patient`s drug supplied
Because the patient does not seek medical treatment every time to treat a specific disease, in the medication records, the continuous drug record is not necessarily the drug for the treatment of a specific disease. The patient's medication records for the treatment of a particular disease are often scattered throughout the data, so the serialization of these discrete drug records into a continuous medication is an important step in the analysis.
This can be used to merge pharmacy claims data into drug era with defined window and Exposure days will be cacluated, too. An event of the time interval is according to the prescription's dispense date plus the prescription's drug supply days. There are two calculation models:
1.If the time interval gap between the patient taking the drug exceeds the persistent window, these two events are regarded as two different drug era.
2.If the time interval gap between the patient taking the drug less than the persistent window, these two events are regarded as same drug era.
This function provides user to concatenate continuous prescription medications into a single prescription length.
#sample of calculating drug era. getDrugEra(MemberIDColName = MemberId,sample_data_subset,DrugColName = NationalDrugCode,DispenseDateColName = DispenseDate,DaysSupplyColName = DaysSupply)#> Error in arrange(case, MemberID, Drug, DispenseDate) %>% as.data.table(): 沒有這個函數 "%>%"