Potential bug: Question about heparin dosing
Hello :] This question has already been asked in the discussions section, but there's still no answer there What is the dosing of heparin in the inputevents table with itemid = 225975. It says amount=1 and amountuom=dose in there, but it is how clear to me how much is 1 dose of heparin. Is there a link to other tables maybe? A significant amount of stay_ids received this drug, so I'd like to include it in my research. I apologise for duplicating this question
Update: as I mentioned, most stay_ids (>15k) have amount=1 in the inputevents table for itemid = 225975 but there are also other values in the amount column( I filtered by some other features first, so the numbers are only valid for patients that received continuous heparin):
amount: number of unique stay_ids 5000.000 5 1100.000 2 6500.000 1 1700.000 1 0.000 1
Are those typos? Is 1 actually 1000(units?). This medication is given as Bolus.
Update I think the dose can be derived from the prescriptions table, given drug=Heparin, formulary_drug_cd = HEPA5I: 1 dose = 1ml vial = 5000 Units. The timings between inputevents and prescriptions don't always coincide, so if anyone has a more formation about the dosing please let me know
You might also try looking at eMAR, which is only available for a subset of patients, but gives more granular information. I've copied this code out of a random notebook I had, but it should give you a head start for comparing the dosing:
hadm_id = 27882036
stay_id = 37319793
query = f"""
SELECT *
FROM `physionet-data.mimiciv_hosp.prescriptions`
WHERE hadm_id = {hadm_id}
"""
pr = run_query(query).sort_values('starttime')
query = f"""
SELECT *
FROM `physionet-data.mimiciv_hosp.emar`
WHERE hadm_id = {hadm_id}
"""
emar = run_query(query)
idx = emar['medication'].isin(['Heparin', 'Enoxaparin Sodium'])
df_emar = emar.loc[idx].copy().sort_values('charttime')
query = f"""
SELECT *
FROM `physionet-data.mimiciv_icu.inputevents`
WHERE stay_id = {stay_id}
"""
inp = run_query(query).sort_values('starttime')
plt.figure(figsize=[16, 12])
# ICU documentation (inputevents) of heparin administration
inp_labels = {
225152: 'Heparin (inputevents)'
}
for itemid, label in inp_labels.items():
idx = inp['itemid'] == itemid
dff = inp.loc[idx].sort_values('starttime')
# first, plot bolus heparin
idx = dff['rate'].isnull()
plt.plot(dff.loc[idx, 'starttime'], dff.loc[idx, 'amount'], 'd', markersize=12, label='Heparin bolus (inputevents)')
for i, row in dff.iterrows():
rate = pd.to_numeric(row['rate'])
plt.plot([row['starttime'], row['endtime']], [rate, rate], 'o-', linewidth=4, color='#fc8d62', label=label)
# disable legend plotting in future rows
label = '__no_legend__'
# plt.fill_between([row['starttime'], row['endtime']], [0, 0], [rate, rate], color='#fc8d62', alpha=0.8)
# eMAR documentation of heparin
med = 'Heparin'
idx_med = (df_emar['medication'] == med)
# first, plot bolus separately
idx = idx_med & (df_emar['administration_type'] == 'Heparin IV Bolus')
plt.plot(df_emar.loc[idx, 'charttime'], df_emar.loc[idx, 'dose_due'], 's', color='#80a0cb', markersize=16, alpha=0.5, label='Heparin bolus (eMAR)')
idx = idx_med & (df_emar['administration_type'] != 'Heparin IV Bolus')
plt.plot(df_emar.loc[idx, 'charttime'], df_emar.loc[idx, 'dose_due'], 'o', color='#1f78b4', markersize=12, alpha=0.9, label='Heparin (eMAR)')
# prescriptions documentation of heparin
meds = ['Heparin', 'Heparin Sodium']
colors = {
'Heparin': '#1b9e77',
'Heparin Sodium': '#1b9e77',
}
idx = pr['drug'].isin(meds)
df = pr.loc[idx].copy()
for med in meds:
label = med + ' (prescriptions)'
color = colors[med]
idx = df['drug'] == med
n = 0
for i, row in df.loc[idx].iterrows():
if n > 0:
# do not add to the legend if we have already plotted at least once
med = '__no_legend__'
xi = [row['starttime'], row['stoptime']]
dose = row['dose_val_rx']
if '-' in dose:
# plot upper/lower ranges
dose_lower, dose_upper = dose.split('-')
dose_lower = int(dose_lower)
dose_upper = int(dose_upper)
plt.fill_between(xi, [dose_lower, dose_lower], [dose_upper, dose_upper], color=color, alpha=0.5, label=label)
else:
dose = pd.to_numeric(dose.replace(',', ''))
dose = dose / 24
plt.plot(xi, [dose, dose], '*-', color=color, label=label)
label = '__no_legend__'
n += 1
# shade in their ICU stay
upper = 3000
for i, row in tr.iterrows():
if row['careunit'] is None:
continue
#if 'ICU' in row['careunit']:
#plt.fill_between([row['intime'], row['outtime']], [0, 0], [upper, upper], color='#ababab', alpha=0.2)
plt.legend(loc='upper right')
plt.xticks(rotation=45)
plt.ylabel('Heparin administration (units/hour)')
# concise dates on the x-axis
ax = plt.gca()
locator = mdates.AutoDateLocator(minticks=3, maxticks=7)
formatter = mdates.ConciseDateFormatter(locator)
ax.xaxis.set_major_locator(locator)
ax.xaxis.set_major_formatter(formatter)
plt.show()
This gives me an image like this:
I don't know what this would look like for those with dose values of 1.
Thanks @alistairewj , I will take a look at the eMAR table. Another question that is related to heparin in MIMIC-III(CareVue subset):
MIMIC-III patients received Bolus more often than MIMIC-IV patients, almost hourly parallel to the continuous infusion. Is this normal? You can take itemid=30025 and icustay_id = 203487 as an example.
CareVue had a different documentation pattern. It could be that those were just validating the rate for a continuous infusion.
Thank you for the feedback! I think this is the really case. But this also makes it difficult(impossible?) to differentiate between "validation" events and bolus administration. The validation events have "Intravenous Push" as original route, which i though was a label for Bolus administrations