MIT-LCP / mimic-code

MIMIC Code Repository: Code shared by the research community for the MIMIC family of databases
https://mimic.mit.edu
MIT License
2.57k stars 1.52k forks source link

Drugs mentioned in the discharge summaries do not appear in the prescriptions data (MIMIC III) #1105

Open fireindark707 opened 3 years ago

fireindark707 commented 3 years ago

Prerequisites

Description

Hi MIMIC team:

I have recently been trying to analyse the MIMIC III data and I am focusing on the medication prescriptions and discharge summaries. However, I have found some questions that I would like to ask:

The first problem is that many of the discharge summaries do not correspond to the drug prescriptions by subject_id and hadm_id, amounting to 6402 (about 10.73% of all discharge summaries).

Another problem is that some of the discharge summaries, although they do correspond to drug prescriptions, have many omissions. By this I mean that the drugs mentioned in the discharge summaries do not appear in the prescriptions data. subject_id = 14291, hadm_id = 139852 is an example of this. Only one of the nine drugs mentioned in the MEDICATIONS section of the discharge summary appears in the PRESCRIPTIONS table. POST DISCHARGE MEDICATIONS has 5 drugs in the PRESCRIPTIONS section, but there are still drugs such as Augmentin and donepezile that are missing.

I would like to ask why this is the case. Why is there a mismatch between the drug prescriptions and the discharge notes?

Thank you for all your work

tompollard commented 3 years ago

Thanks for raising this issue, which sounds like it needs some exploration. As a reminder, the Data Use Agreement that you have signed states that the data must not be shared. We have a copy of the data ourselves, so providing queries and IDs is sufficient.

tompollard commented 3 years ago

@fireindark707 if possible, please could you post the query/code that you are using to cross-check the discharge summary medications with the prescriptions table?

lceli commented 3 years ago

Prescription Table contains medications given in the hospital while the discharge medications are medications that the patient is supposed to take when she/he gets home. They don't have to be the same. Please work with a clinician.Thanks,Leo On Friday, August 6, 2021, 09:56:46 AM EDT, Tom Pollard @.***> wrote:

@fireindark707 if possible, please could you post the query/code that you are using to cross-check the discharge summary medications with the prescriptions table?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

fireindark707 commented 3 years ago

Thanks for raising this issue, which sounds like it needs some exploration. As a reminder, the Data Use Agreement that you have signed states that the data must not be shared. We have a copy of the data ourselves, so providing queries and IDs is sufficient.

Sorry for sharing data. Thanks for the reminder

fireindark707 commented 3 years ago

Prescription Table contains medications given in the hospital while the discharge medications are medications that the patient is supposed to take when she/he gets home. They don't have to be the same. Please work with a clinician.Thanks,Leo On Friday, August 6, 2021, 09:56:46 AM EDT, Tom Pollard @.***> wrote: @fireindark707 if possible, please could you post the query/code that you are using to cross-check the discharge summary medications with the prescriptions table? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

Thanks to you and tompollard for your responses. I think that the discharge summaries will contain some instructions for the medication to be administered during the hospital stay. For example, the Medication section in the example I gave. I don't think that would be discharge medication, otherwise there wouldn't be two sections. But strangely enough, the medication in this section does not appear in the Prescription.

On the other hand, I would also like to ask about the first question, why are there many discharge summaries that do not correspond to Prescription? Do you know the possible causes?

Thank you both again.

fireindark707 commented 3 years ago

@fireindark707 if possible, please could you post the query/code that you are using to cross-check the discharge summary medications with the prescriptions table?

output different categories' notes

category = ['Discharge summary','Nursing','Nursing/other']
for ca in category:
    for start_id in range(0,length,100):
        end_id = start_id + 100
        query = \
        """
        SELECT n.row_id, n.subject_id, n.hadm_id, n.category, n.description, n.text
        FROM noteevents n
        WHERE n.category like '{}'
        and n.row_id >= {} and n.row_id <{};
        """.format(ca,start_id,end_id)
        data = pd.read_sql_query(query,con)            
        output_notes(data,ca.replace('/','_'))

Get the notes to be analysed

def output_notes(data, category):
    for i in range(len(data)):
        row_id = str(data.iloc[i,0])
        subject_id = str(data.iloc[i,1])
        hadm_id = str(data.iloc[i,2])
        notes = data.iloc[i,5]
        with open('noteevents/'+category+'/'+ row_id + '_'+subject_id +'_' + hadm_id +'.txt','w') as f:
            f.write(notes)

query = \
    """
    SELECT p.row_id, p.subject_id, p.hadm_id, p.drug
    FROM mimiciii.prescriptions p
    WHERE p.subject_id = {} and p.hadm_id = {};
    """.format(subject_id,hamd_id)