diff --git a/lib/config/config.dart b/lib/config/config.dart index e5ed9690..4a4a2d1c 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -68,6 +68,9 @@ const GET_PENDING_REFERRAL_PATIENT = const CREATE_REFERRAL_PATIENT = 'Services/DoctorApplication.svc/REST/CreateReferral'; +const RESPONSE_PENDING_REFERRAL_PATIENT = + 'Services/DoctorApplication.svc/REST/CreateReferral'; + const GET_DOCTOR_WORKING_HOURS_TABLE = 'Services/Doctors.svc/REST/GetDoctorWorkingHoursTable'; diff --git a/lib/core/service/patient-doctor-referral-service.dart b/lib/core/service/patient-doctor-referral-service.dart index ad108c3b..a15ed05a 100644 --- a/lib/core/service/patient-doctor-referral-service.dart +++ b/lib/core/service/patient-doctor-referral-service.dart @@ -162,6 +162,31 @@ class PatientReferralService extends LookupService { ); } + Future responseReferral(PendingReferral pendingReferral, bool isAccepted) async { + hasError = false; + DoctorProfileModel doctorProfile = await getDoctorProfile(); + + Map body = Map(); + body['IsAccepted'] = isAccepted; + body['AppointmentNo'] = pendingReferral.sourceAppointmentNo; + body['PatientMRN'] = pendingReferral.patientID; + body['PatientName'] = pendingReferral.patientName; + body['ReferralResponse'] = pendingReferral.remarksFromSource; + body['SetupID'] = pendingReferral.sourceSetupID; + body['DoctorName'] = doctorProfile.doctorName; + + await baseAppClient.post( + RESPONSE_PENDING_REFERRAL_PATIENT, + onSuccess: (dynamic response, int statusCode) { + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: body, + ); + } + Future makeReferral( PatientArrivalEntity patientArrivalEntity, String isoStringDate, diff --git a/lib/core/viewModel/patient-referral-viewmodel.dart b/lib/core/viewModel/patient-referral-viewmodel.dart index 6fa72f6f..9662a910 100644 --- a/lib/core/viewModel/patient-referral-viewmodel.dart +++ b/lib/core/viewModel/patient-referral-viewmodel.dart @@ -107,6 +107,16 @@ class PatientReferralViewModel extends BaseViewModel { setState(ViewState.Idle); } + Future responseReferral(PendingReferral pendingReferral, bool isAccepted) async { + setState(ViewState.Busy); + await _referralPatientService.responseReferral(pendingReferral, isAccepted); + if (_referralPatientService.hasError) { + error = _referralPatientService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + Future getPatientArrivalList(String date) async { setState(ViewState.Busy); await _referralPatientService.getPatientArrivalList(date); diff --git a/lib/screens/patients/profile/referral/my-referral-detail-screen.dart b/lib/screens/patients/profile/referral/my-referral-detail-screen.dart index 5f38f190..4c9d41e0 100644 --- a/lib/screens/patients/profile/referral/my-referral-detail-screen.dart +++ b/lib/screens/patients/profile/referral/my-referral-detail-screen.dart @@ -119,7 +119,9 @@ class MyReferralDetailScreen extends StatelessWidget { fontSize: 16, hPadding: 8, vPadding: 12, - handler: null, + handler: (){ + model.responseReferral(pendingReferral, true); + }, ), ), SizedBox( @@ -133,7 +135,9 @@ class MyReferralDetailScreen extends StatelessWidget { fontSize: 16, hPadding: 8, vPadding: 12, - handler: null, + handler: (){ + model.responseReferral(pendingReferral, false); + }, ), ), ],