startVisitByRequestAccess method
Implementation
void startVisitByRequestAccess(BuildContext context, String otpCode) {
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'; // TODO: get the real provider code from the state
final String? msisdn = state
.clinicalState?.patientPayload?.patientRecord?.telecom?.first?.value;
if (msisdn == null) {
throw const UserException(
'failed to start visit patient phone number not found');
}
final OTPEpisodeCreationInput otpEpisodeCreationInput =
OTPEpisodeCreationInput(
patientID: patientID,
providerCode: providerCode,
msisdn: msisdn,
otp: otpCode,
fullAccess: false,
);
final IGraphQlClient? client = AppWrapperBase.of(context)?.graphQLClient;
dispatch(StartVisitByRequestAccessAction(
client: client, otpEpisodeCreationInput: otpEpisodeCreationInput));
}