base_querier
Provides query/data extraction methods for a given patient.
This class is a higher-level abstraction than the direct API interactions, providing methods for extracting/munging data from the API responses.
Classes
BaseEHRQuerier
class BaseEHRQuerier(patient_id: str):Base Class for various EHR Queriers.
Arguments
patient_id: The patient ID this querier corresponds to.
Subclasses
Methods
download_all_documents
def download_all_documents(self, save_path: Path) ‑> list[pathlib.Path]:Download PDF documents for the current patient.
Arguments
save_path: Documents path for the PDF documents to be saved.
get_next_appointment
def get_next_appointment(self) ‑> Optional[datetime.date]:Get the next appointment date for the patient.
Returns The next appointment date for the patient from today, or None if they have no future appointment.
Raises
NextGenGetPatientInfoError: If unable to retrieve patient information.
get_patient_code_states
def get_patient_code_states(self) ‑> PatientCodeDetails:Get information of Condition and Procedure codes this patient has.
Sugar method that combines get_patient_condition_code_states() and get_patient_procedure_code_states() and returns a pre-constructed PatientCodeDetails container.
Returns A PatientCodeDetails instance detailing the presence or absence of the provided Condition and Procedure codes for the patient.
get_patient_condition_code_states
def get_patient_condition_code_states( self, statuses_filter: Optional[list[ClinicalStatus]] = None, code_types_filter: Optional[list[CodeSystems]] = None,) ‑> list[str]:Get condition codes related to this patient.
get_patient_latest_medical_practitioner
def get_patient_latest_medical_practitioner(self) ‑> Optional[str]:Retrieves the latest medical practitioner for the patient.
This is the rendering provider for the patient's last encounter.
Returns The name of the latest medical practitioner for the patient, or None if there is no name listed on the latest encounter.
Raises
NextGenGetPatientInfoError: If unable to retrieve patient encounter information.
get_patient_procedure_code_states
def get_patient_procedure_code_states( self, statuses_filter: Optional[list[ProcedureStatus]] = None, code_types_filter: Optional[list[CodeSystems]] = None,) ‑> list[str]:Get information of procedure codes this patient has.
Returns A list of procedure codes relevant for the patient.
get_previous_appointment_details
def get_previous_appointment_details( self, include_maybe_attended: bool = True,) ‑> list[EHRAppointment]:Get the details of previous appointments for the patient.
Returns The list of previous appointments for the patient, or an empty list if they have no previous appointments.
produce_json_dump
def produce_json_dump( self, save_path: Path, elements_to_dump: Container[str] = frozenset({'conditions', 'patientInfo', 'chart', 'procedures', 'medications', 'encounters', 'appointments'}),) ‑> None:Produce a JSON dump of patient information for the target patient.
Saves the JSON dump out to file and the contents can be controlled by
elements_to_dump.
The following options are recognised: - "patientInfo":
Arguments
save_path: The file location to save the JSON dump to.elements_to_dump: Collection of elements to include in the dump. See above for what options can be included.