pyhealth.data.Event#
One basic data structure in the package. It is a simple container for a single event. It contains all necessary attributes for supporting various healthcare tasks.
- class pyhealth.data.Event(code=None, table=None, vocabulary=None, visit_id=None, patient_id=None, timestamp=None, **attr)[source]#
Bases:
object
Contains information about a single event.
An event can be anything from a diagnosis to a prescription or a lab test that happened in a visit of a patient at a specific time.
- Parameters:
code (
Optional
[str
]) – code of the event. E.g., “428.0” for congestive heart failure.table (
Optional
[str
]) – name of the table where the event is recorded. This corresponds to the raw csv file name in the dataset. E.g., “DIAGNOSES_ICD”.vocabulary (
Optional
[str
]) – vocabulary of the code. E.g., “ICD9CM” for ICD-9 diagnosis codes.patient_id (
Optional
[str
]) – unique identifier of the patient.timestamp (
Optional
[datetime
]) – timestamp of the event. Default is None.**attr – optional attributes to add to the event as key=value pairs.
- attr_dict#
Dict, dictionary of visit attributes. Each key is an attribute name and each value is the attribute’s value.
Examples
>>> from pyhealth.data import Event >>> event = Event( ... code="00069153041", ... table="PRESCRIPTIONS", ... vocabulary="NDC", ... visit_id="v001", ... patient_id="p001", ... dosage="250mg", ... ) >>> event Event with NDC code 00069153041 from table PRESCRIPTIONS >>> event.attr_dict {'dosage': '250mg'}