@ -8,6 +8,7 @@ import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.da
import ' package:diplomaticquarterapp/models/Clinics/EROnlineCheckInPaymentDetailsResponse.dart ' ;
import ' package:diplomaticquarterapp/models/LiveCare/ApplePayInsertRequest.dart ' ;
import ' package:diplomaticquarterapp/pages/ToDoList/payment_method_select.dart ' ;
import ' package:diplomaticquarterapp/pages/landing/landing_page.dart ' ;
import ' package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart ' ;
import ' package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart ' ;
import ' package:diplomaticquarterapp/services/livecare_services/livecare_provider.dart ' ;
@ -452,7 +453,12 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
String paymentInfo = res [ ' Response_Message ' ] ;
if ( paymentInfo = = ' Success ' ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
createAdvancePayment ( res , appo ) ;
if ( widget . isERBookAppointment ) {
/ / createAdvancePayment ( res , appo ) ;
ER_createAdvancePayment ( res , appo ) ;
} else {
autoGenerateInvoiceER ( res ) ;
}
} else {
GifLoaderDialogUtils . hideDialog ( context ) ;
AppToast . showErrorToast ( message: res [ ' Response_Message ' ] ) ;
@ -464,7 +470,30 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
} ) ;
}
ER_createAdvancePayment ( payment_res , AppoitmentAllHistoryResultList appo ) {
GifLoaderDialogUtils . showMyDialog ( context ) ;
DoctorsListService service = new DoctorsListService ( ) ;
String paymentReference = payment_res [ ' Fort_id ' ] . toString ( ) ;
service . ER_createAdvancePayment ( appo , widget . projectID . toString ( ) , payment_res [ ' Amount ' ] , payment_res [ ' Fort_id ' ] , payment_res [ ' PaymentMethod ' ] , context ) . then ( ( res ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
addAdvancedNumberRequest (
/ / Utils . isVidaPlusProject ( projectViewModel , widget . projectID )
/ / ? res [ ' OnlineCheckInAppointments ' ] [ 0 ] [ ' AdvanceNumber_VP ' ] . toString ( )
/ / : res [ ' OnlineCheckInAppointments ' ] [ 0 ] [ ' AdvanceNumber ' ] . toString ( ) ,
res [ ' ER_AdvancePaymentResponse ' ] [ ' AdvanceNumber ' ] . toString ( ) ,
paymentReference ,
0 ,
appo ,
payment_res ) ;
} ) . catchError ( ( err ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
AppToast . showErrorToast ( message: err ) ;
print ( err ) ;
} ) ;
}
createAdvancePayment ( paymentRes , AppoitmentAllHistoryResultList appo ) {
GifLoaderDialogUtils . showMyDialog ( context ) ;
DoctorsListService service = new DoctorsListService ( ) ;
String paymentReference = paymentRes [ ' Fort_id ' ] . toString ( ) ;
service . HIS_createAdvancePayment ( appo , widget . projectID . toString ( ) , paymentRes [ ' Amount ' ] , paymentRes [ ' Fort_id ' ] , paymentRes [ ' PaymentMethod ' ] , projectViewModel . user . patientType ,
@ -486,10 +515,11 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
}
addAdvancedNumberRequest ( String advanceNumber , String paymentReference , dynamic appointmentID , AppoitmentAllHistoryResultList appo , paymentRes ) {
GifLoaderDialogUtils . showMyDialog ( context ) ;
DoctorsListService service = new DoctorsListService ( ) ;
service . addAdvancedNumberRequest ( advanceNumber , paymentReference , appointmentID , context ) . then ( ( res ) {
if ( widget . isERBookAppointment ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
if ( widget . isERBookAppointment ) {
AppToast . showSuccessToast ( message: " Your appointment has been booked successfully. Please perform Check-In once you arrive at the hospital. " ) ;
Navigator . pop ( context ) ;
Navigator . pop ( context ) ;
@ -505,9 +535,11 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
}
autoGenerateInvoiceER ( res ) {
GifLoaderDialogUtils . showMyDialog ( context ) ;
DoctorsListService service = new DoctorsListService ( ) ;
service . autoGenerateInvoiceERClinic ( widget . projectID , 4 , res [ ' Fort_id ' ] , res [ ' Amount ' ] , res [ ' PaymentMethod ' ] , res [ ' CardNumber ' ] , res [ ' Merchant_Reference ' ] , res [ ' RRN ' ] , tru e) . then ( ( res ) {
service . autoGenerateInvoiceERClinic ( widget . projectID , 4 , res [ ' Fort_id ' ] , res [ ' Amount ' ] , res [ ' PaymentMethod ' ] , res [ ' CardNumber ' ] , res [ ' Merchant_Reference ' ] , res [ ' RRN ' ] , fals e) . then ( ( res ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
_showMyDialog ( TranslationBase . of ( context ) . ERCheckInSuccess , context ) ;
} ) . catchError ( ( err ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
AppToast . showErrorToast ( message: err ) ;
@ -515,6 +547,34 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
} ) ;
}
Future < void > _showMyDialog ( String message , BuildContext context ) async {
return showDialog < void > (
context: context ,
barrierDismissible: true , / / user must tap button !
builder: ( BuildContext context ) {
return AlertDialog (
title: const Text ( ' Alert ' ) ,
content: SingleChildScrollView (
child: ListBody (
children: < Widget > [
Text ( message ) ,
] ,
) ,
) ,
actions: < Widget > [
TextButton (
child: const Text ( ' OK ' ) ,
onPressed: ( ) {
Navigator . of ( context ) . pop ( ) ;
Navigator . pushAndRemoveUntil ( context , MaterialPageRoute ( builder: ( context ) = > LandingPage ( ) ) , ( Route < dynamic > r ) = > false ) ;
} ,
) ,
] ,
) ;
} ,
) ;
}
getEROnlineCheckInPaymentDetails ( ) {
GifLoaderDialogUtils . showMyDialog ( context ) ;
ClinicListService ancillaryOrdersService = new ClinicListService ( ) ;