How to Accurately Determine Medication Administration in MIMIC-IV v3.1?
I am conducting an exploration of medication usage in MIMIC-IV v3.1. While collecting data, I noticed that the pharmacy and prescriptions tables do not provide clear information on when medications were actually administered. To address this, I cross-referenced the EMAR table, but I found that even for patients present in the EMAR table, medication records are incomplete.
For example, I examined the medication records for a patient with hadm_id = '28166872'. This patient underwent 'Endovascular (total) embolization or occlusion of head and neck vessels' on 2201-11-08 and 2201-11-04. However, I could not find any records of anesthetic medications administered on these dates in the prescriptions, pharmacy, or EMAR tables. Interestingly, I did find records of anesthetic medications in the inputevents table.
Questions:
How can we accurately determine when medications were administered in MIMIC-IV?
Are there any best practices or additional tables I should consider to ensure comprehensive medication tracking?
Could you review my code for querying medication data to see if it is reasonable? Below is my code snippet:
sql:
--把我这批患者使用药物的emar表都拿过来看: select distinct a.subject_id,a.hadm_id,pa.anchor_year_group,--emar information was only available for patients admitted after 2014 2014年以后入院的患者才有emar信息
a.admittime,a.dischtime,a.first_icuintime,last_icuouttime,c.emar_id,c.emar_seq,c.poe_id,c.pharmacy_id,c.charttime,c.medication,c.event_txt,--Later find out if the medication is used according to event_txt后面根据event_txt查明药物是否使用。 c.scheduletime,c.storetime,p.medication as medication2,p.route ,p.pharmacy_id as pharmacy_id2,p.status,p.poe_id as poe_id2,p.starttime,p.stoptime,p.dose_val_rx,p.prod_strength --,p.gsn --into emar_alltime0228
from select_use0110 a
left join mimiciv_hosp.emar c using (hadm_id)
left join mimiciv_hosp.patients pa on pa.subject_id=c.subject_id
left join( SELECT DISTINCT s.subject_id,s.hadm_id, s.admittime,s.dischtime,P.starttime,pharmacy_id,poe_id,P.stoptime, P.medication,P.status,P.route,P.frequency,p.dose_val_rx ,prod_strength FROM select_use0110 s LEFT JOIN (SELECT DISTINCT p1.*,p2.gsn, p2.prod_strength,p2.dose_val_rx,p2.form_val_disp FROM mimiciv_hosp.pharmacy p1 LEFT JOIN mimiciv_hosp.prescriptions p2 USING ( pharmacy_id ) ) P USING ( hadm_id )
--WHERE P.status IN ( 'Discontinued', 'Discontinued via patient discharge' ) There are four drug states in pharmcy, the other two being inactive; expired, these are the only two that indicate the use of medication pharmcy中一共是4个用药状态,其他两个是:inactive;expired,只有这两个表示使用了药物吧
ORDER BY P.starttime )p on p.pharmacy_id=c.pharmacy_id and p.hadm_id=c.hadm_id
where c.medication is not null
order by subject_id,pharmacy_id --800 persons
I am particularly interested in anesthetic medications administered around the time of surgical procedures.
I have already checked the prescriptions, pharmacy, and EMAR tables but found gaps in the data.
The inputevents table seems to have more complete records, but I am unsure if this is the most reliable source for medication administration.
Thank you in advance for your help and insights!
@xiangxiang121 We’ve encountered a similar challenge while analyzing antibiotic usage and are working through it as well. We’ve had some conversations with the authors involved, and we’re considering putting together a set of best practices and preprocessing recommendations for working with eMAR data. This could be really helpful for others in the community who might face similar issues now or in the future. Is there any way we can connect and discuss further? I’d love to collaborate and share insights!
Thanks for responding. My email is [email protected]