ER Online CheckIn implementation contd

dev_3.3_ER_Online_CheckIn
haroon amjad 1 year ago
parent f5df1b1d01
commit f65fe26fd2

@ -601,9 +601,9 @@ var GET_DENTAL_APPOINTMENT_INVOICE = "Services/Patients.svc/REST/HIS_eInvoiceFor
var SEND_DENTAL_APPOINTMENT_INVOICE_EMAIL = "Services/Notifications.svc/REST/SendInvoiceForDental";
var GET_TAMARA_PLAN = 'https://mdlaboratories.com/tamaralive/Home/GetInstallments';
var GET_TAMARA_PLAN = 'https://mdlaboratories.com/tamara/Home/GetInstallments';
var GET_TAMARA_PAYMENT_STATUS = 'https://mdlaboratories.com/tamaralive/api/OnlineTamara/order_status?orderid=';
var GET_TAMARA_PAYMENT_STATUS = 'https://mdlaboratories.com/tamara/api/OnlineTamara/order_status?orderid=';
var UPDATE_TAMARA_STATUS = 'Services/PayFort_Serv.svc/REST/Tamara_UpdateRequestStatus';
@ -637,6 +637,10 @@ var GET_ER_ONLINE_PAYMENT_DETAILS = 'Services/OUTPs.svc/Rest/Outp_GetPatientPaym
var AUTO_GENERATE_INVOICE_ER = 'Services/OUTPs.svc/Rest/Outp_AutoGenerateInvoiceForER';
var CHECK_IF_PATIENT_ARRIVED_ER_ONLINE_CHECKIN = 'Services/OUTPs.svc/Rest/IsPatientArrived';
var GET_PROJECT_FROM_NFC = 'Services/OUTPs.svc/Rest/GetProjectByNFC';
//PAYFORT
var getPayFortProjectDetails = "Services/PayFort_Serv.svc/REST/GetPayFortProjectDetails";
var addPayFortApplePayResponse = "Services/PayFort_Serv.svc/REST/AddResponse";

@ -1,8 +1,10 @@
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/ErService/EROnlineCheckIn/EROnlineCheckInBookAppointment.dart';
import 'package:diplomaticquarterapp/pages/ErService/EROnlineCheckIn/EROnlineCheckInPaymentDetails.dart';
import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
@ -21,10 +23,18 @@ class EROnlineCheckInHomePage extends StatefulWidget {
State<EROnlineCheckInHomePage> createState() => _EROnlineCheckInHomePageState();
}
class _EROnlineCheckInHomePageState extends State<EROnlineCheckInHomePage> {
class _EROnlineCheckInHomePageState extends State<EROnlineCheckInHomePage> with SingleTickerProviderStateMixin {
ProjectViewModel projectViewModel;
bool _supportsNFC = false;
bool isPatientArrived = false;
@override
void initState() {
WidgetsBinding.instance.addPostFrameCallback((_) {
checkIfPatientHasArrived();
});
super.initState();
}
@override
Widget build(BuildContext context) {
@ -263,46 +273,99 @@ class _EROnlineCheckInHomePageState extends State<EROnlineCheckInHomePage> {
height: 80,
color: CustomColors.white,
padding: EdgeInsets.fromLTRB(12.0, 12.0, 12.0, 25.0),
child: Row(
children: [
Expanded(
flex: 1,
child: DefaultButton(
TranslationBase.of(context).checkinOptions,
() {
if (_supportsNFC) {
Future.delayed(const Duration(milliseconds: 500), () {
showNfcReader(context, onNcfScan: (String nfcId) {
Future.delayed(const Duration(milliseconds: 100), () {
print(nfcId);
Navigator.push(context, FadePage(page: EROnlineCheckInPaymentDetails()));
child: isPatientArrived
? Container(
child: DefaultButton(
TranslationBase.of(context).arrived,
() {
if (_supportsNFC) {
Future.delayed(const Duration(milliseconds: 500), () {
showNfcReader(context, onNcfScan: (String nfcId) {
Future.delayed(const Duration(milliseconds: 100), () {
print(nfcId);
// Navigator.push(context, FadePage(page: EROnlineCheckInPaymentDetails()));
});
}, onCancel: () {
Navigator.of(context).pop();
});
}, onCancel: () {
Navigator.of(context).pop();
});
});
} else {
//NFCNotSupported
AppToast.showErrorToast(message: TranslationBase.of(context).NFCNotSupported);
}
},
color: CustomColors.green,
),
),
mWidth(12),
Expanded(
flex: 1,
child: DefaultButton(
TranslationBase.of(context).bookAppo,
() {
Navigator.push(context, FadePage(page: EROnlineCheckInBookAppointment()));
},
color: CustomColors.accentColor,
} else {
//NFCNotSupported
AppToast.showErrorToast(message: TranslationBase.of(context).NFCNotSupported);
}
},
color: CustomColors.accentColor,
),
)
: Row(
children: [
Expanded(
flex: 1,
child: DefaultButton(
TranslationBase.of(context).checkinOptions,
() {
if (_supportsNFC) {
Future.delayed(const Duration(milliseconds: 500), () {
showNfcReader(context, onNcfScan: (String nfcId) {
Future.delayed(const Duration(milliseconds: 100), () {
print(nfcId);
getProjectIDFromNFC(nfcId);
});
}, onCancel: () {
Navigator.of(context).pop();
});
});
} else {
//NFCNotSupported
AppToast.showErrorToast(message: TranslationBase.of(context).NFCNotSupported);
}
},
color: CustomColors.green,
),
),
mWidth(12),
Expanded(
flex: 1,
child: DefaultButton(
TranslationBase.of(context).bookAppo,
() {
Navigator.push(context, FadePage(page: EROnlineCheckInBookAppointment()));
},
color: CustomColors.accentColor,
),
),
],
),
),
],
),
),
);
}
void getProjectIDFromNFC(String nfcID) {
GifLoaderDialogUtils.showMyDialog(context);
ClinicListService ancillaryOrdersService = new ClinicListService();
ancillaryOrdersService.getProjectIDFromNFC(nfcID).then((response) {
print(response["GetProjectByNFC"]);
int projectID = response['GetProjectByNFC'][0]["ProjectID"];
GifLoaderDialogUtils.hideDialog(context);
Navigator.push(context, FadePage(page: EROnlineCheckInPaymentDetails(projectID: projectID)));
}).catchError((err) {
AppToast.showErrorToast(message: err.toString());
GifLoaderDialogUtils.hideDialog(context);
});
}
void checkIfPatientHasArrived() {
GifLoaderDialogUtils.showMyDialog(context);
ClinicListService ancillaryOrdersService = new ClinicListService();
ancillaryOrdersService.checkIfPatientHasArrived(15, 10).then((response) {
print(response["IsPatientArrivedResponse"]);
isPatientArrived = response['IsPatientArrivedResponse']["IsPatientArrived"];
GifLoaderDialogUtils.hideDialog(context);
// erOnlineCheckInPaymentDetailsResponse = EROnlineCheckInPaymentDetailsResponse.fromJson(response["ResponsePatientShare"]);
setState(() {});
}).catchError((err) {
AppToast.showErrorToast(message: err.toString());
GifLoaderDialogUtils.hideDialog(context);
});
}
}

@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/enum/PayfortEnums.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
import 'package:diplomaticquarterapp/models/Clinics/EROnlineCheckInPaymentDetailsResponse.dart';
import 'package:diplomaticquarterapp/models/LiveCare/ApplePayInsertRequest.dart';
import 'package:diplomaticquarterapp/pages/ToDoList/payment_method_select.dart';
@ -22,12 +23,16 @@ import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/dragable_sheet.dart';
import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class EROnlineCheckInPaymentDetails extends StatefulWidget {
const EROnlineCheckInPaymentDetails();
int projectID = 0;
EROnlineCheckInPaymentDetails({@required this.projectID});
@override
State<EROnlineCheckInPaymentDetails> createState() => _EROnlineCheckInPaymentDetailsState();
@ -39,6 +44,7 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
String selectedPaymentMethod;
String selectedInstallmentPlan;
String transID = "";
MyInAppBrowser browser;
@override
void initState() {
@ -299,10 +305,12 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
if (projectViewModel.havePrivilege(103)) {
startApplePay();
} else {
// openPayment(selectedPaymentMethod, projectViewModel.user, erOnlineCheckInPaymentDetailsResponse.patientShareWithTax, null, selectedInstallmentPlan);
AppoitmentAllHistoryResultList appo = new AppoitmentAllHistoryResultList();
appo.projectID = widget.projectID;
openPayment(selectedPaymentMethod, projectViewModel.user, erOnlineCheckInPaymentDetailsResponse.patientShareWithTax, null);
}
} else {
// openPayment(selectedPaymentMethod, projectViewModel.user, erOnlineCheckInPaymentDetailsResponse.patientShareWithTax, null, selectedInstallmentPlan);
openPayment(selectedPaymentMethod, projectViewModel.user, erOnlineCheckInPaymentDetailsResponse.patientShareWithTax, null);
}
},
patientShare: erOnlineCheckInPaymentDetailsResponse.patientShareWithTax,
@ -311,8 +319,43 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
);
}
openPayment(String paymentMethod, AuthenticatedUser authenticatedUser, num amount, AppoitmentAllHistoryResultList appo) {
transID = Utils.getAdvancePaymentTransID(widget.projectID, projectViewModel.user.patientID);
browser = new MyInAppBrowser(onExitCallback: onBrowserExit, appo: appo, onLoadStartCallback: onBrowserLoadStart);
browser.openPaymentBrowser(amount, "ER Online Check-In Payment", transID, widget.projectID.toString(), authenticatedUser.emailAddress,
paymentMethod, authenticatedUser.patientType, authenticatedUser.firstName, authenticatedUser.patientID, authenticatedUser, browser, false, "3", "", null);
}
onBrowserLoadStart(String url) {
print("onBrowserLoadStart");
print(url);
MyInAppBrowser.successURLS.forEach((element) {
if (url.contains(element)) {
if (browser.isOpened()) browser.close();
MyInAppBrowser.isPaymentDone = true;
return;
}
});
MyInAppBrowser.errorURLS.forEach((element) {
if (url.contains(element)) {
if (browser.isOpened()) browser.close();
MyInAppBrowser.isPaymentDone = false;
return;
}
});
}
onBrowserExit(AppoitmentAllHistoryResultList appo, bool isPaymentMade) {
print("onBrowserExit Called!!!!");
checkPaymentStatus(appo);
}
void startApplePay() async {
transID = Utils.getAdvancePaymentTransID(15, projectViewModel.user.patientID);
transID = Utils.getAdvancePaymentTransID(widget.projectID, projectViewModel.user.patientID);
print("TransactionID: $transID");
GifLoaderDialogUtils.showMyDialog(context);
@ -321,7 +364,7 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
ApplePayInsertRequest applePayInsertRequest = new ApplePayInsertRequest();
PayfortProjectDetailsRespModel payfortProjectDetailsRespModel;
await context.read<PayfortViewModel>().getProjectDetailsForPayfort(projectId: 15, serviceId: ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum()).then((value) {
await context.read<PayfortViewModel>().getProjectDetailsForPayfort(projectId: widget.projectID, serviceId: ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum()).then((value) {
payfortProjectDetailsRespModel = value;
});
@ -335,7 +378,7 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
applePayInsertRequest.deviceToken = await AppSharedPreferences().getString(PUSH_TOKEN);
applePayInsertRequest.voipToken = await AppSharedPreferences().getString(ONESIGNAL_APNS_TOKEN);
applePayInsertRequest.doctorID = 0;
applePayInsertRequest.projectID = "15";
applePayInsertRequest.projectID = widget.projectID.toString();
applePayInsertRequest.serviceID = ServiceTypeEnum.advancePayment.getIdFromServiceEnum().toString();
applePayInsertRequest.channelID = 3;
applePayInsertRequest.patientID = projectViewModel.user.patientID;
@ -343,7 +386,7 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
applePayInsertRequest.patientOutSA = projectViewModel.user.outSA;
applePayInsertRequest.appointmentDate = null;
applePayInsertRequest.appointmentNo = 0;
applePayInsertRequest.orderDescription = "Ancillary Order Payment";
applePayInsertRequest.orderDescription = "ER Online Check-In Payment";
applePayInsertRequest.liveServiceID = "0";
applePayInsertRequest.latitude = "0.0";
applePayInsertRequest.longitude = "0.0";
@ -372,7 +415,7 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
customerName: projectViewModel.user.firstName + " " + projectViewModel.user.lastName,
// customerEmail: projectViewModel.authenticatedUserObject.user.emailAddress,
customerEmail: "CustID_${projectViewModel.user.patientID}@HMG.com",
orderDescription: "Ancillary Order Payment",
orderDescription: "ER Online Check-In Payment",
orderAmount: erOnlineCheckInPaymentDetailsResponse.patientShareWithTax,
merchantReference: transID,
payfortProjectDetailsRespModel: payfortProjectDetailsRespModel,
@ -387,7 +430,7 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
GifLoaderDialogUtils.hideDialog(context);
checkPaymentStatus(AppoitmentAllHistoryResultList());
},
projectId: 15,
projectId: widget.projectID,
serviceTypeEnum: ServiceTypeEnum.appointmentPayment,
);
} else {
@ -423,11 +466,11 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
createAdvancePayment(paymentRes, AppoitmentAllHistoryResultList appo) {
DoctorsListService service = new DoctorsListService();
String paymentReference = paymentRes['Fort_id'].toString();
service.HIS_createAdvancePayment(appo, "15", paymentRes['Amount'], paymentRes['Fort_id'], paymentRes['PaymentMethod'], projectViewModel.user.patientType,
service.HIS_createAdvancePayment(appo, widget.projectID.toString(), paymentRes['Amount'], paymentRes['Fort_id'], paymentRes['PaymentMethod'], projectViewModel.user.patientType,
projectViewModel.user.firstName + " " + projectViewModel.user.lastName, projectViewModel.user.patientID, context)
.then((res) {
addAdvancedNumberRequest(
Utils.isVidaPlusProject(projectViewModel, 15) ? res['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString() : res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(),
Utils.isVidaPlusProject(projectViewModel, widget.projectID) ? res['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString() : res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(),
paymentReference,
0,
appo,
@ -452,7 +495,7 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
autoGenerateInvoiceER(res) {
DoctorsListService service = new DoctorsListService();
service.autoGenerateInvoiceERClinic(15, 4, res['Fort_id'], res['Amount'], res['PaymentMethod'], res['CardNumber'], res['Merchant_Reference'], res['RRN']).then((res) {
service.autoGenerateInvoiceERClinic(widget.projectID, 4, res['Fort_id'], res['Amount'], res['PaymentMethod'], res['CardNumber'], res['Merchant_Reference'], res['RRN']).then((res) {
GifLoaderDialogUtils.hideDialog(context);
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
@ -464,7 +507,7 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
getEROnlineCheckInPaymentDetails() {
GifLoaderDialogUtils.showMyDialog(context);
ClinicListService ancillaryOrdersService = new ClinicListService();
ancillaryOrdersService.getEROnlineCheckInPaymentDetails(15, 10).then((response) {
ancillaryOrdersService.getEROnlineCheckInPaymentDetails(widget.projectID, 10).then((response) {
erOnlineCheckInPaymentDetailsResponse = EROnlineCheckInPaymentDetailsResponse.fromJson(response["ResponsePatientShare"]);
GifLoaderDialogUtils.hideDialog(context);
setState(() {});

@ -187,4 +187,25 @@ class ClinicListService extends BaseService {
return Future.value(localRes);
}
Future<Map> checkIfPatientHasArrived(int projectID, int clinicID) async {
Map<String, dynamic> request = {"ProjectID": projectID, "ClinicID": clinicID};
dynamic localRes;
await baseAppClient.post(CHECK_IF_PATIENT_ARRIVED_ER_ONLINE_CHECKIN, onSuccess: (response, statusCode) async {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: request, isAllowAny: true);
return Future.value(localRes);
}
Future<Map> getProjectIDFromNFC(String nfcID) async {
Map<String, dynamic> request = {"nFC_Code": nfcID};
dynamic localRes;
await baseAppClient.post(GET_PROJECT_FROM_NFC, onSuccess: (response, statusCode) async {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: request, isAllowAny: true);
return Future.value(localRes);
}
}

Loading…
Cancel
Save