pyhealth.tasks.drug_recommendation#
- pyhealth.tasks.drug_recommendation.drug_recommendation_mimic3_fn(patient)[source]#
Processes a single patient for the drug recommendation task.
Drug recommendation aims at recommending a set of drugs given the patient health history (e.g., conditions and procedures).
- Parameters:
patient (
Patient
) – a Patient object- Returns:
- a list of samples, each sample is a dict with patient_id, visit_id,
and other task-specific attributes as key, like this {
”patient_id”: xxx, “visit_id”: xxx, “conditions”: [list of diag in visit 1, list of diag in visit 2, …, list of diag in visit N], “procedures”: [list of prod in visit 1, list of prod in visit 2, …, list of prod in visit N], “drugs_hist”: [list of drug in visit 1, list of drug in visit 2, …, list of drug in visit (N-1)], “drugs”: list of drug in visit N, # this is the predicted target
}
- Return type:
samples
Examples
>>> from pyhealth.datasets import MIMIC3Dataset >>> mimic3_base = MIMIC3Dataset( ... root="/srv/local/data/physionet.org/files/mimiciii/1.4", ... tables=["DIAGNOSES_ICD", "PROCEDURES_ICD", "PRESCRIPTIONS"], ... code_mapping={"ICD9CM": "CCSCM"}, ... ) >>> from pyhealth.tasks import drug_recommendation_mimic3_fn >>> mimic3_sample = mimic3_base.set_task(drug_recommendation_mimic3_fn) >>> mimic3_sample.samples[0] { 'visit_id': '174162', 'patient_id': '107', 'conditions': [['139', '158', '237', '99', '60', '101', '51', '54', '53', '133', '143', '140', '117', '138', '55']], 'procedures': [['4443', '4513', '3995']], 'drugs_hist': [[]], 'drugs': ['0000', '0033', '5817', '0057', '0090', '0053', '0', '0012', '6332', '1001', '6155', '1001', '6332', '0033', '5539', '6332', '5967', '0033', '0040', '5967', '5846', '0016', '5846', '5107', '5551', '6808', '5107', '0090', '5107', '5416', '0033', '1150', '0005', '6365', '0090', '6155', '0005', '0090', '0000', '6373'], }
- pyhealth.tasks.drug_recommendation.drug_recommendation_mimic4_fn(patient)[source]#
Processes a single patient for the drug recommendation task.
Drug recommendation aims at recommending a set of drugs given the patient health history (e.g., conditions and procedures).
- Parameters:
patient (
Patient
) – a Patient object- Returns:
- a list of samples, each sample is a dict with patient_id, visit_id,
and other task-specific attributes as key {
”patient_id”: xxx, “visit_id”: xxx, “conditions”: [list of diag in visit 1, list of diag in visit 2, …, list of diag in visit N], “procedures”: [list of prod in visit 1, list of prod in visit 2, …, list of prod in visit N], “drugs_hist”: [list of drug in visit 1, list of drug in visit 2, …, list of drug in visit (N-1)], “drugs”: list of drug in visit N, # this is the predicted target
}
- Return type:
samples
Examples
>>> from pyhealth.datasets import MIMIC4Dataset >>> mimic4_base = MIMIC4Dataset( ... root="/srv/local/data/physionet.org/files/mimiciv/2.0/hosp", ... tables=["diagnoses_icd", "procedures_icd"], ... code_mapping={"ICD10PROC": "CCSPROC"}, ... ) >>> from pyhealth.tasks import drug_recommendation_mimic4_fn >>> mimic4_sample = mimic4_base.set_task(drug_recommendation_mimic4_fn) >>> mimic4_sample.samples[0] [{'visit_id': '130744', 'patient_id': '103', 'conditions': [['42', '109', '19', '122', '98', '663', '58', '51']], 'procedures': [['1']], 'label': [['2', '3', '4']]}]
- pyhealth.tasks.drug_recommendation.drug_recommendation_eicu_fn(patient)[source]#
Processes a single patient for the drug recommendation task.
Drug recommendation aims at recommending a set of drugs given the patient health history (e.g., conditions and procedures).
- Parameters:
patient (
Patient
) – a Patient object- Returns:
- a list of samples, each sample is a dict with patient_id, visit_id,
and other task-specific attributes as key
- Return type:
samples
Examples
>>> from pyhealth.datasets import eICUDataset >>> eicu_base = eICUDataset( ... root="/srv/local/data/physionet.org/files/eicu-crd/2.0", ... tables=["diagnosis", "medication"], ... code_mapping={}, ... dev=True ... ) >>> from pyhealth.tasks import drug_recommendation_eicu_fn >>> eicu_sample = eicu_base.set_task(drug_recommendation_eicu_fn) >>> eicu_sample.samples[0] [{'visit_id': '130744', 'patient_id': '103', 'conditions': [['42', '109', '98', '663', '58', '51']], 'procedures': [['1']], 'label': [['2', '3', '4']]}]
- pyhealth.tasks.drug_recommendation.drug_recommendation_omop_fn(patient)[source]#
Processes a single patient for the drug recommendation task.
Drug recommendation aims at recommending a set of drugs given the patient health history (e.g., conditions and procedures).
- Parameters:
patient (
Patient
) – a Patient object- Returns:
- a list of samples, each sample is a dict with patient_id, visit_id,
and other task-specific attributes as key
- Return type:
samples
Examples
>>> from pyhealth.datasets import OMOPDataset >>> omop_base = OMOPDataset( ... root="https://storage.googleapis.com/pyhealth/synpuf1k_omop_cdm_5.2.2", ... tables=["condition_occurrence", "procedure_occurrence"], ... code_mapping={}, ... ) >>> from pyhealth.tasks import drug_recommendation_omop_fn >>> omop_sample = omop_base.set_task(drug_recommendation_eicu_fn) >>> omop_sample.samples[0] [{'visit_id': '130744', 'patient_id': '103', 'conditions': [['42', '109', '98', '663', '58', '51'], ['98', '663', '58', '51']], 'procedures': [['1'], ['2', '3']], 'label': [['2', '3', '4'], ['0', '1', '4', '5']]}]