startVisitByEmergency method

void startVisitByEmergency(
  1. BuildContext context,
  2. String otpCode
)

Implementation

void startVisitByEmergency(BuildContext context, String otpCode) {
  final IGraphQlClient? client = AppWrapperBase.of(context)?.graphQLClient;

  final String? patientID =
      state.clinicalState?.patientPayload?.patientRecord?.id;
  if (patientID == null) {
    throw const UserException('failed to start visit, patient ID not found');
  }
  const String providerCode = '123';
  const String practitionerUID = '12';
  final String? providerPhone =
      state.userState?.userProfile?.primaryPhoneNumber?.getValue();
  if (providerPhone == null) {
    throw const UserException(
        'failed to start visit, provider phone number not found');
  }

  final String? patientPhone = getPatientPhoneNumber();
  if (patientPhone == null) {
    throw const UserException(
        'failed to start visit, patient phone number not found');
  }

  final BreakGlassEpisodeCreationInput breakGlassEpisodeCreationInput =
      BreakGlassEpisodeCreationInput(
          patientID: patientID,
          providerCode: providerCode,
          practitionerUID: practitionerUID,
          providerPhone: providerPhone,
          otp: otpCode,
          fullAccess: false,
          patientPhone: patientPhone);

  dispatch(StartVisitEmergencyAction(
      client: client,
      breakGlassEpisodeCreationInput: breakGlassEpisodeCreationInput));
}