The Patient class manages all clinical events for a single patient.
It supports efficient event-type partitioning, fast time-range slicing, and flexible multi-condition filtering.
Details
Data is held as a data.frame.
Events can be retrieved as either raw data frames or Event object lists.
Public fields
patient_idCharacter. Unique identifier for the patient.
data_sourcedata.frame. All events for this patient, sorted by timestamp.
event_type_partitionsList. Mapping event type to corresponding data.frames.
Methods
Method new()
Create a Patient object.
Usage
Patient$new(patient_id, data_source)Method filter_by_time_range_regular()
Filter events by time range (O(n), regular scan).
Method filter_by_time_range_fast()
Efficient time range filter via binary search (O(log n)), requires sorted data.
Method get_events()
Get events with optional type, time, and custom attribute filters.
Usage
Patient$get_events(
event_type = NULL,
start = NULL,
end = NULL,
filters = NULL,
return_df = FALSE
)Arguments
event_typeCharacter. (Optional) Filter by event type.
startCharacter/POSIXct. (Optional) Start time for filtering events.
endCharacter/POSIXct. (Optional) End time for filtering events.
filtersList of lists. (Optional) Each filter: list(attr, op, value) e.g. list(list("dose", ">", 10)).
return_dfLogical. If TRUE, return as data.frame; else as Event object list.