I am looking for patients in MIMIC-III v1.3 who took stool softener drugs listed as "Senna, Dulcolax, docusate, milk of magnesia,Colace, MiraLAX, and bisacodyl" on their first ICU stay during the first hospital admission.
I found that the resulting number of people is disproportionately high. I wonder if someone can provide any insight into this issue. This is my code:
with first_admissions as ( SELECT p.subject_id,p.hadm_id , row_number() over (partition by p.subject_id order by p.admittime ASC) as r FROM mimiciii.admissions p ), first_icustays as ( SELECT p.subject_id,p.hadm_id, p.icustay_id , row_number() over (partition by p.subject_id order by p.intime ASC) as rn FROM mimiciii.icustays p ) , first_stays as( select a.subject_id,a.hadm_id,i.icustay_id from first_admissions a join first_icustays i on a.subject_id = i.subject_id where r=1 and rn=1 ) SELECT distinct on (p.subject_id) p.subject_id FROM firststays a, mimiciii.prescriptions p where a.subject_id = p.subject_id and a.icustay_id = p.icustay_id and a.hadm_id = p.hadm_id and p.drug @@ to_tsquery('senna | Dulcolax | docusate | magnesia | Colace | MiraLAX | bisacodyl') order by p.subject_id;