getPatientInfo function

PatientInfo getPatientInfo()

getPatientInfo retrieves the patient's information including the Patient ID, Patient Reference, Name, Encounter ID and Encounter Reference

returns a PatientInfo object

Implementation

PatientInfo getPatientInfo() {
  final PatientConnection? patientConnection =
      CurrentPatientInEpisode().patientConnection.valueOrNull;
  final String encounterId =
      CurrentPatientInEpisode().encounterID.valueOrNull.toString();

  /// A Patient ID is in the format 6247a19b-c37a-434b-a0af-216da1dbc4c6
  /// A Patient Reference is in the format
  /// ====> Patient/6247a19b-c37a-434b-a0af-216da1dbc4c6
  return PatientInfo(
    patientId: patientConnection?.edges!.first!.node!.id,
    patientReference: 'Patient/${patientConnection?.edges!.first!.node!.id!}',
    patientName: patientConnection?.edges!.first!.node!.name!.first!.text,
    encounterId: encounterId,
    encounterReference: 'Encounter/$encounterId',
  );
}