getPatientPhoneNumber method

String? getPatientPhoneNumber()

Implementation

String? getPatientPhoneNumber() {
  final List<ContactPoint?>? telecoms =
      state.clinicalState?.patientPayload?.patientRecord?.telecom;

  if (telecoms == null) {
    // no phone numbers in patient record
    return null;
  }

  final List<ContactPoint?> phoneNumbers = telecoms
      .where((ContactPoint? contactPoint) =>
          contactPoint?.system == ContactPointSystemEnum.phone)
      .toList();

  if (phoneNumbers.isEmpty) {
    // no phone numbers in patient record
    return null;
  }

  final String? phoneNumber = phoneNumbers.first?.value;

  return phoneNumber;
}