getPhoneNumber method

String? getPhoneNumber()

the current patient's phone number

Implementation

String? getPhoneNumber() {
  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;
  }

  return phoneNumbers.first?.value;
}