querier
Provides a high-level abstraction for extracting patient info from NextGen.
Classes
FromPatientQueryError
class FromPatientQueryError(*args, **kwargs):
No patient was returned when constructing from query.
Ancestors
- NextGenFHIRAPIError
- NextGenAPIError
- BitfountError
- builtins.Exception
- builtins.BaseException
GetPatientInfoError
class GetPatientInfoError(*args, **kwargs):
Could not retrieve patient info.
Ancestors
- NextGenEnterpriseAPIError
- NextGenAPIError
- BitfountError
- builtins.Exception
- builtins.BaseException
NextGenPatientQuerier
class NextGenPatientQuerier( patient_id: str, *, fhir_api: NextGenFHIRAPI, enterprise_api: NextGenEnterpriseAPI, fhir_patient_info: Optional[RetrievedPatientDetailsJSON] = None,):
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.
Create a NextGenPatientQuerier instance.
Arguments
patient_id
: The patient ID this querier corresponds to.fhir_api
: NextGenFHIRAPI instance.enterprise_api
: NextGenEnterpriseAPI instance.fhir_patient_info
: FHIR Patient Info as obtained from the FHIR API
Static methods
from_nextgen_session
def from_nextgen_session( patient_id: str, nextgen_session: NextGenAuthSession, fhir_url: str = 'https://fhir.nextgen.com/nge/prod/fhir-api-r4/fhir/R4', enterprise_url: str = 'https://nativeapi.nextgen.com/nge/prod/nge-api/api',) ‑> NextGenPatientQuerier:
Build a NextGenPatientQuerier from a NextGenAuthSession.
Arguments
patient_id
: The patient ID this querier will correspond to.nextgen_session
: NextGenAuthSession for constructing API instances against.fhir_url
: Optional, the FHIR API url to use.enterprise_url
: Optional, the Enterprise API url to use.
Returns NextGenPatientQuerier for the target patient.
from_patient_query
def from_patient_query( patient_dob: str | date, given_name: Optional[str] = None, family_name: Optional[str] = None, *, fhir_api: Optional[NextGenFHIRAPI] = None, enterprise_api: Optional[NextGenEnterpriseAPI] = None, nextgen_session: Optional[NextGenAuthSession] = None, fhir_url: str = 'https://fhir.nextgen.com/nge/prod/fhir-api-r4/fhir/R4', enterprise_url: str = 'https://nativeapi.nextgen.com/nge/prod/nge-api/api',) ‑> NextGenPatientQuerier:
Build a NextGenPatientQuerier from patient query details.
Arguments
patient_dob
: Patient date of birth.given_name
: Patient given name.family_name
: Patient family name.fhir_api
: Optional, NextGenFHIRAPI instance. If not provided,nextgen_session
must be.enterprise_api
: Optional, NextGenEnterpriseAPI instance. If not provided,nextgen_session
must be.nextgen_session
: Optional, NextGenAuthSession instance. Only needed iffhir_api
orenterprise_api
are not provided.fhir_url
: Optional, FHIR API url. Only needed iffhir_api
is not provided and a non-default URL is wanted.enterprise_url
: Optional, Enterprise API url. Only needed iffhir_api
is not provided and a non-default URL is wanted.
Returns NextGenPatientQuerier for the target patient.
Raises
FromPatientQueryError
: if patient ID could not be found (maybe because multiple patients match the criteria, or none do)ValueError
: if unable to construct the API instances because session information was not provided.
Methods
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
GetPatientInfoError
: If unable to retrieve patient information.
get_patient_code_states
def get_patient_code_states( self, icd10_codes_to_check: set[str], cpt4_codes_to_check: set[str],) ‑> PatientCodeDetails:
Get information of ICD-10 and CPT-4 codes this patient has.
Sugar method that combines get_patient_icd10_code_states() and get_patient_cpt4_code_states() and returns a pre-constructed PatientCodeDetails container.
Arguments
icd10_codes_to_check
: The set of ICD-10 codes to check against and output the presence/absence of.cpt4_codes_to_check
: The set of CPT-4 codes to check against and output the presence/absence of.
Returns A PatientCodeDetails instance detailing the presence or absence of the provided ICD-10 and CPT-4 codes for the patient.
get_patient_cpt4_code_states
def get_patient_cpt4_code_states( self, cpt4_codes_to_check: set[str],) ‑> dict[str, PatientCodeStatus]:
Get information of CPT-4 codes this patient has.
Arguments
cpt4_codes_to_check
: The set of CPT-4 codes to check against and output the presence/absence of.
Returns
A mapping of CPT-4 codes from cpt4_codes_to_check
to their
PatientCodeStatus value indicating presence or absence.
Raises
GetPatientInfoError
: If unable to retrieve patient procedures information.
get_patient_icd10_code_states
def get_patient_icd10_code_states( self, icd10_codes_to_check: set[str],) ‑> dict[str, PatientCodeStatus]:
Get information of ICD-10 codes this patient has.
Arguments
icd10_codes_to_check
: The set of ICD-10 codes to check against and output the presence/absence of.
Returns
A mapping of ICD-10 codes from icd10_codes_to_check
to their
PatientCodeStatus value indicating presence or absence.
Raises
GetPatientInfoError
: If unable to retrieve patient condition information.
get_previous_appointment_details
def get_previous_appointment_details( self,) ‑> list[NextGenEnterpriseAppointmentsEntryJSON]:
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.
Raises
GetPatientInfoError
: If unable to retrieve patient information.