Skip to main content

api

API stubs for interacting with NextGen services.

Classes

AppointmentTemporalState

class AppointmentTemporalState(*args, **kwds):

Denotes whether appointment is in the past or the future.

Ancestors

Variables

  • static FUTURE
  • static PAST

NextGenEnterpriseAPI

class NextGenEnterpriseAPI(    session: BearerAuthSession | NextGenAuthSession,    next_gen_enterprise_url: str = 'https://nativeapi.nextgen.com/nge/prod/nge-api/api',):

API for interacting with the NextGen Enterprise API.

Create a new instance for interacting with the NextGen Enterprise API.

Arguments

  • session: Session containing bearer token information for NextGen API.
  • next_gen_enterprise_url: Base URL of the FHIR API endpoint. Should be of a similar style to https://nativeapi.nextgen.com/nge/prod/nge-api/api/.

Variables

  • static DATETIME_STR_FORMAT
  • static DEFAULT_NEXT_GEN_ENTERPRISE_URL : Final[str]

Methods


download_documents_batch

def download_documents_batch(    self,    path: Path,    patient_id: str,    document_infos: List[EHRDocumentInfo],)> tuple[list[DownloadedEHRDocumentInfo], list[FailedEHRDocumentInfo]]:

Downloads a batch of documents given a list of document ids.

Arguments

  • path: Download path for the document to be saved.
  • patient_id: The ID of the patient.
  • document_infos: List of document IDs to be downloaded.

Returns A tuple containing:

  • list of info of documents that were successfully downloaded.
  • list of documents that could not be downloaded.

get_appointments_information

def get_appointments_information(    self,    patient_id: str,    appointment_temporal_state: Optional[AppointmentTemporalState] = None,    expand_options: Optional[Collection[str]] = None,)> Optional[list[NextGenEnterpriseAppointmentsEntryJSON]]:

Retrieve the upcoming appointments information for a patient.

Arguments

  • patient_id: The NextGen patient identifier for the target patient.
  • appointment_temporal_state: Filter for appointments either in past or future. If None, returns all appointments.
  • expand_options: $expand query args to pass through to the API call. This will always include at least Appointment.

Returns A list of JSON objects containing information on appointments for a patient. The list may be empty. If there was no such list in the JSON at all, return None.

get_appointments_information_for_dump

def get_appointments_information_for_dump(    self,    patient_id: str,)> Optional[list[NextGenEnterpriseAppointmentsEntryJSON]]:

Retrieve the all appointments information for a patient for JSON dump.

Includes predefined $expand options we want for JSON dumping purposes.

Arguments

  • patient_id: The NextGen patient identifier for the target patient.

Returns A list of JSON objects containing information on appointments for a patient. The list may be empty. If there was no such list in the JSON at all, return None.

get_bulk_patient_info

def get_bulk_patient_info(    self, patient_id: str,)> Optional[BulkPatientInfo]:

Retrieve bulk patient information for a given patient ID.

If unable to find, or patient has no relevant information, return None.

This method is a sugar method for the cases where all information for a given patient might be needed. Generally the specific calls should be used in preference to avoid unnecessary API calls to NextGen.

Returned patient information contains: - list of diagnoses/conditions for the patient - list of procedures for the patient - list of future appointments - list of past appointments

Arguments

  • patient_id: The NextGen patient identifier for the target patient.

Returns A BulkPatientInfo object containing information on the patient. If no information could be retrieved, returns None.

get_conditions_information

def get_conditions_information(    self,    patient_id: str,    expand_options: Optional[Collection[str]] = None,)> Optional[list[NextGenEnterpriseDiagnosesEntryJSON]]:

Retrieve the diagnoses/conditions information for a patient.

Arguments

  • patient_id: The NextGen patient identifier for the target patient.
  • expand_options: $expand query args to pass through to the API call.

Returns A list of JSON objects containing information on diagnoses/conditions of the patient. The list may be empty. If there was no such list in the JSON at all, return None.

get_conditions_information_for_dump

def get_conditions_information_for_dump(    self,    patient_id: str,)> Optional[list[NextGenEnterpriseDiagnosesEntryJSON]]:

Retrieve the diagnoses/conditions information for a patient for JSON dump.

Includes predefined $expand options we want for JSON dumping purposes.

Arguments

  • patient_id: The NextGen patient identifier for the target patient.

Returns A list of JSON objects containing information on diagnoses/conditions of the patient. The list may be empty. If there was no such list in the JSON at all, return None.

get_diagnoses_information

def get_diagnoses_information(    self,    patient_id: str,)> Optional[list[NextGenEnterpriseDiagnosesEntryJSON]]:

Retrieve the diagnoses/conditions information for a patient.

Arguments

  • patient_id: The NextGen patient identifier for the target patient.

Returns A list of JSON objects containing information on diagnoses/conditions of the patient. If there was no such list, return None.

get_documents_information

def get_documents_information(    self,    patient_id: str,    params: Optional[dict[str, str]] = None,)> Tuple[List[EHRDocumentInfo], Optional[pydantic_core._pydantic_core.Url]]:

Get a single page of documents information for a patient.

Will return an empty list if no documents were found.

Will also return the next page URL if present, else None.

Arguments

  • patient_id: The ID of the patient.
  • params: Any additional query params to include in the request, usually the $skip= param for pagination.

Returns A tuple containing:

  • the list of EHRDocumentInfo if present, else [].
  • the next page URL, if present, else None

get_encounters

def get_encounters(    self,    patient_id: str,    expand_options: Optional[Collection[str]] = None,)> Optional[list[NextGenEnterpriseEncountersEntryJSON]]:

Retrieve the encounters information for a patient.

Arguments

  • patient_id: The NextGen patient identifier for the target patient.
  • expand_options: $expand query args to pass through to the API call.

Returns A list of JSON objects containing information on encounters for a patient. The list may be empty. If there was no such list in the JSON at all, return None.

get_encounters_for_dump

def get_encounters_for_dump(    self,    patient_id: str,)> Optional[list[NextGenEnterpriseEncountersEntryJSON]]:

Retrieve the encounters information for a patient for JSON dump.

Includes predefined $expand options we want for JSON dumping purposes.

Arguments

  • patient_id: The NextGen patient identifier for the target patient.

Returns A list of JSON objects containing information on encounters for a patient. The list may be empty. If there was no such list in the JSON at all, return None.

get_medications

def get_medications(    self,    patient_id: str,    expand_options: Optional[Collection[str]] = None,)> Optional[list[NextGenEnterpriseMedicationsEntryJSON]]:

Retrieve the medications information for a patient.

Arguments

  • patient_id: The NextGen patient identifier for the target patient.
  • expand_options: $expand query args to pass through to the API call.

Returns A list of JSON objects containing information on medications for a patient. The list may be empty. If there was no such list in the JSON at all, return None.

get_medications_for_dump

def get_medications_for_dump(    self,    patient_id: str,)> Optional[list[NextGenEnterpriseMedicationsEntryJSON]]:

Retrieve the medications information for a patient for JSON dump.

Includes predefined $expand options we want for JSON dumping purposes.

Arguments

  • patient_id: The NextGen patient identifier for the target patient.

Returns A list of JSON objects containing information on medications for a patient. The list may be empty. If there was no such list in the JSON at all, return None.

get_patient_chart

def get_patient_chart(    self, patient_id: str, expand_options: Optional[Collection[str]] = None,)> Optional[list[NextGenEnterpriseChartEntryJSON]]:

Retrieve the chart information for a patient.

Arguments

  • patient_id: The NextGen patient identifier for the target patient.
  • expand_options: $expand query args to pass through to the API call.

Returns A JSON object containing the chart of the patient. If there was no such object in the JSON at all, return None.

get_patient_chart_for_dump

def get_patient_chart_for_dump(    self, patient_id: str,)> Optional[list[NextGenEnterpriseChartEntryJSON]]:

Retrieve the chart information for a patient for JSON dump.

Includes predefined $expand options we want for JSON dumping purposes.

Arguments

  • patient_id: The NextGen patient identifier for the target patient.

Returns A JSON object containing the chart of the patient. If there was no such object in the JSON at all, return None.

get_person_information

def get_person_information(    self, patient_id: str, expand_options: Optional[Collection[str]] = None,)> Optional[NextGenEnterprisePersonJSON]:

Retrieve the personal information for a patient.

Arguments

  • patient_id: The NextGen patient identifier for the target patient.
  • expand_options: $expand query args to pass through to the API call.

Returns A JSON object containing the personal information of the patient. If there was no such object in the JSON at all, return None.

get_person_information_for_dump

def get_person_information_for_dump(    self, patient_id: str,)> Optional[NextGenEnterprisePersonJSON]:

Retrieve the personal information for a patient for JSON dump.

Includes predefined $expand options we want for JSON dumping purposes.

Arguments

  • patient_id: The NextGen patient identifier for the target patient.

Returns A JSON object containing the personal information of the patient. If there was no such object in the JSON at all, return None.

get_procedures_information

def get_procedures_information(    self,    patient_id: str,    expand_options: Optional[Collection[str]] = None,)> Optional[list[NextGenEnterpriseProceduresEntryJSON]]:

Retrieve the procedures information for a patient.

Arguments

  • patient_id: The NextGen patient identifier for the target patient.
  • expand_options: $expand query args to pass through to the API call.

Returns A list of JSON objects containing information on procedures of the patient. The list may be empty. If there was no such list in the JSON at all, return None.

get_procedures_information_for_dump

def get_procedures_information_for_dump(    self,    patient_id: str,)> Optional[list[NextGenEnterpriseProceduresEntryJSON]]:

Retrieve the procedures information for a patient for JSON dump.

Includes predefined $expand options we want for JSON dumping purposes.

Arguments

  • patient_id: The NextGen patient identifier for the target patient.

Returns A list of JSON objects containing information on procedures of the patient. The list may be empty. If there was no such list in the JSON at all, return None.

get_social_history

def get_social_history(    self,    patient_id: str,    expand_options: Optional[Collection[str]] = None,)> Optional[list[NextGenEnterpriseSocialHistoryEntryJSON]]:

Retrieve the social history information for a patient.

Arguments

  • patient_id: The NextGen patient identifier for the target patient.
  • expand_options: $expand query args to pass through to the API call.

Returns A list of JSON objects containing information on social history for a patient. The list may be empty. If there was no such list in the JSON at all, return None.

yield_document_infos

def yield_document_infos(    self, patient_id: str,)> Iterable[List[EHRDocumentInfo]]:

Yields pages of document infos.

NextGenFHIRAPI

class NextGenFHIRAPI(    session: BearerAuthSession | NextGenAuthSession,    next_gen_fhir_url: str = 'https://fhir.nextgen.com/nge/prod/fhir-api-r4/fhir/R4',):

API for interacting with the NextGen FHIR API.

Create a new instance for interacting with the NextGen FHIR API.

Arguments

  • session: Session containing bearer token information for NextGen API.
  • next_gen_fhir_url: Base URL of the FHIR API endpoint. Should be of a similar style to https://fhir.nextgen.com/nge/prod/fhir-api-r4/fhir/R4/.

Variables

  • static DEFAULT_NEXT_GEN_FHIR_URL : Final[str]

Methods


get_patient_info

def get_patient_info(    self,    dob: str | date,    given_name: Optional[str] = None,    family_name: Optional[str] = None,)> Optional[RetrievedPatientDetailsJSON]:

Search for a patient info given patient information.

If unable to find, or unable to narrow down to a specific patient, return None.

Arguments except for DoB are optional, but additional arguments will help to narrow down the patients to a singular patient.

Arguments

  • dob: Date of birth as either a string (must contain YMD information as minimum and in that order) or an existing date/datetime object representing the date of birth.
  • given_name: The given name of the patient. Can be a portion of the given name as will be substring-matched.
  • family_name: The family name of the patient. Can be a portion of the given name as will be substring-matched.

Returns The patient info if a singular match was found, otherwise None.

Raises

  • ValueError: if no criteria are supplied.

get_patient_info_by_mrn

def get_patient_info_by_mrn(    self, mrn: str,)> Optional[RetrievedPatientDetailsJSON]:

Search for a patient info given MRN.

Arguments

  • mrn: Medical Record Number

Returns The patient info if a singular match was found, otherwise None.