Skip to main content

ehr_base_algorithm

Base class for EHR algorithms.

This module implements a base algorithm for any algos that need to set up a NextGen and FHIR R4 sessions and queriers. It sets up EHR secrets as well as required URL and other config in its initialise method. It provides functionality to:

  • Work with NextGen's FHIR, Enterprise, and SMART on FHIR APIs
  • Work with generic FHIR R4 compatible systems

Classes​

BaseEHRWorkerAlgorithm​

class BaseEHRWorkerAlgorithm(    *,    hub: BitfountHub | None = None,    session: BitfountSession | None = None,    **kwargs: Any,):

EHR Base worker algorithm for workers that need to access EHR.

Init method for EHR Base worker algorithm.

Arguments

  • hub: BitfountHub for Hub API access (NextGen, SMART Backend).
  • session: BitfountSession object for use with SMARTOnFHIR service. Will be created if not provided. (nextgen only)
  • **kwargs: Additional keyword arguments.

Methods​


get_patient_lister​

def get_patient_lister(self) ‑> BaseEHRPatientLister:

Get Patient Lister for paginated patient ID listing.

get_patient_querier​

def get_patient_querier(    self,    patient: PatientDetails,) ‑> NextGenPatientQuerier | FHIRR4PatientQuerier:

Get Patient Querier class for this patient.

The querier class is selected by self.querier_type. Within each class, the construction method is chosen by the patient details variant: EHRIDPatientDetails builds via from_patient_id (no demographic search), and NameDOBPatientDetails builds via from_patient_query.

initialise​

def initialise(    self,    *,    datasource: BaseSource,    data_splitter: DatasetSplitter | None = None,    ehr_secrets: RefreshableJWT | None = None,    ehr_config: EHRConfig | None = None,    **kwargs: Any,) ‑> None:

Sets Datasource and EHR secrets, and initialise EHR sessions.

initialise_data​

def initialise_data(    self,    datasource: BaseSource,    data_splitter: DatasetSplitter | None = None,    cached_data: pd.DataFrame | None = None,) ‑> None:

Inherited from:

BaseWorkerAlgorithm.initialise_data :

Initialises the algorithm with data.

This method will be called once per task batch. It is expected that algorithms will override this method to initialise their data in the required way.

note

This is called by the initialise method and should not be called directly by the algorithm or protocol.

EHRIDPatientDetails​

class EHRIDPatientDetails(ehr_patient_id: str):

Patient identifying information when the EHR patient ID is already known.

Using this variant skips the name/DOB search; the patient data is queried directly against the EHR patient ID.

Variables​

  • static ehr_patient_id : str
  • log_identifier : str - Human-readable identifier for logs/progress messages.

NameDOBPatientDetails​

class NameDOBPatientDetails(    bitfount_patient_id: str,    dob: str | date,    given_name: str | None = None,    family_name: str | None = None,):

Patient identifying information for name/DOB search lookup.

Variables​

  • static bitfount_patient_id : str
  • static family_name : str | None
  • static given_name : str | None
  • log_identifier : str - Human-readable identifier for logs/progress messages.

QuerierType​

class QuerierType(*args, **kwds):

EHR Querier for use in algorithm.

Ancestors​

Variables​

  • static FHIR_R4
  • static NEXTGEN