Online CheckIn CR implementation Contd.

dev_3.3_ER_Online_CheckIn
haroon amjad 5 months ago
parent 3a64858905
commit 9a0a658083

@ -1,6 +1,15 @@
import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.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';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
@ -11,8 +20,20 @@ class EROnlineCheckInBookAppointment extends StatefulWidget {
State<EROnlineCheckInBookAppointment> createState() => _EROnlineCheckInBookAppointmentState();
}
class _EROnlineCheckInBookAppointmentState extends State<EROnlineCheckInBookAppointment> {
class _EROnlineCheckInBookAppointmentState extends State<EROnlineCheckInBookAppointment> with SingleTickerProviderStateMixin {
ProjectViewModel projectViewModel;
List<HospitalsModel> projectsList = [];
final GlobalKey projectDropdownKey = GlobalKey();
HospitalsModel selectedHospital;
String projectDropdownValue = "";
@override
void initState() {
WidgetsBinding.instance.addPostFrameCallback((_) {
getProjectsList();
});
super.initState();
}
@override
Widget build(BuildContext context) {
@ -28,9 +49,155 @@ class _EROnlineCheckInBookAppointmentState extends State<EROnlineCheckInBookAppo
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [],
children: [
InkWell(
onTap: () {
openDropdown(projectDropdownKey);
},
child: Container(
width: double.infinity,
decoration: containerRadius(Colors.white, 12),
padding: EdgeInsets.only(left: 10, right: 10, top: 12, bottom: 12),
child: Row(
children: [
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
TranslationBase.of(context).selectHospital,
style: TextStyle(
fontSize: 11,
letterSpacing: -0.44,
fontWeight: FontWeight.w600,
),
),
Container(
height: 18,
child: DropdownButtonHideUnderline(
child: DropdownButton<HospitalsModel>(
key: projectDropdownKey,
hint: new Text(TranslationBase.of(context).selectHospital),
value: selectedHospital,
iconSize: 0,
isExpanded: true,
style: TextStyle(fontSize: 14, letterSpacing: -0.56, color: Colors.black),
items: projectsList.map((item) {
return new DropdownMenuItem<HospitalsModel>(
value: item,
child: new Text(item.name),
);
}).toList(),
onChanged: (newValue) async {
setState(() {
selectedHospital = newValue;
projectDropdownValue = newValue.mainProjectID.toString();
});
},
),
),
),
],
),
),
Icon(Icons.keyboard_arrow_down),
],
),
),
),
mHeight(16),
Container(
width: double.infinity,
decoration: containerRadius(Colors.white, 12),
padding: EdgeInsets.only(left: 10, right: 10, top: 12, bottom: 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
TranslationBase.of(context).clinicName,
style: TextStyle(
fontSize: 11,
letterSpacing: -0.44,
fontWeight: FontWeight.w600,
),
),
Text(
"ER Clinic",
style: TextStyle(fontSize: 14, letterSpacing: -0.56, color: Colors.black),
),
],
),
),
],
),
),
bottomSheet: Container(
height: 80,
color: CustomColors.white,
padding: EdgeInsets.fromLTRB(12.0, 12.0, 12.0, 25.0),
child: DefaultButton(
TranslationBase.of(context).bookAppo,
() {
if (projectDropdownValue == "" || selectedHospital == null) {
AppToast.showErrorToast(message: TranslationBase.of(context).selectHospital);
} else {
Navigator.push(
context,
FadePage(
page: EROnlineCheckInPaymentDetails(
projectID: selectedHospital.iD,
isERBookAppointment: true,
projectName: selectedHospital.name,
),
),
);
}
},
color: CustomColors.accentColor,
),
),
);
}
getProjectsList() {
int languageID = projectViewModel.isArabic ? 1 : 2;
GifLoaderDialogUtils.showMyDialog(context);
ClinicListService service = new ClinicListService();
List<HospitalsModel> projectsListLocal = [];
service.getProjectsList(languageID, context).then((res) {
GifLoaderDialogUtils.hideDialog(context);
if (res['MessageStatus'] == 1) {
setState(() {
res['ListProject'].forEach((v) {
projectsListLocal.add(new HospitalsModel.fromJson(v));
});
projectsList = projectsListLocal;
});
}
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
print(err);
});
}
void openDropdown(GlobalKey key) {
GestureDetector detector;
void searchForGestureDetector(BuildContext element) {
element.visitChildElements((element) {
if (element.widget != null && element.widget is GestureDetector) {
detector = element.widget;
return false;
} else {
searchForGestureDetector(element);
}
return true;
});
}
searchForGestureDetector(key.currentContext);
assert(detector != null);
detector.onTap();
}
}

@ -347,8 +347,18 @@ class _EROnlineCheckInHomePageState extends State<EROnlineCheckInHomePage> with
if (response["GetProjectByNFC"].length != 0) {
print(response["GetProjectByNFC"]);
int projectID = response['GetProjectByNFC'][0]["ProjectID"];
String projectName = response['GetProjectByNFC'][0]["ProjectName"];
GifLoaderDialogUtils.hideDialog(context);
Navigator.push(context, FadePage(page: EROnlineCheckInPaymentDetails(projectID: projectID)));
Navigator.push(
context,
FadePage(
page: EROnlineCheckInPaymentDetails(
projectID: projectID,
isERBookAppointment: false,
projectName: projectName,
),
),
);
} else {
AppToast.showErrorToast(message: "Invalid NFC Card Scanned.");
}

@ -29,10 +29,11 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class EROnlineCheckInPaymentDetails extends StatefulWidget {
int projectID = 0;
bool isERBookAppointment = false;
String projectName = "";
EROnlineCheckInPaymentDetails({@required this.projectID});
EROnlineCheckInPaymentDetails({@required this.projectID, @required this.isERBookAppointment, @required this.projectName});
@override
State<EROnlineCheckInPaymentDetails> createState() => _EROnlineCheckInPaymentDetailsState();
@ -181,7 +182,7 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
),
mWidth(3),
Text(
"Olaya Hospital",
widget.projectName,
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 14,
@ -324,8 +325,8 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
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);
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) {
@ -470,7 +471,9 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
projectViewModel.user.firstName + " " + projectViewModel.user.lastName, projectViewModel.user.patientID, context)
.then((res) {
addAdvancedNumberRequest(
Utils.isVidaPlusProject(projectViewModel, widget.projectID) ? 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,
@ -485,7 +488,15 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
addAdvancedNumberRequest(String advanceNumber, String paymentReference, dynamic appointmentID, AppoitmentAllHistoryResultList appo, paymentRes) {
DoctorsListService service = new DoctorsListService();
service.addAdvancedNumberRequest(advanceNumber, paymentReference, appointmentID, context).then((res) {
autoGenerateInvoiceER(paymentRes);
if(widget.isERBookAppointment) {
GifLoaderDialogUtils.hideDialog(context);
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);
Navigator.pop(context);
} else {
autoGenerateInvoiceER(paymentRes);
}
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
AppToast.showErrorToast(message: err.toString());
@ -495,7 +506,7 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
autoGenerateInvoiceER(res) {
DoctorsListService service = new DoctorsListService();
service.autoGenerateInvoiceERClinic(widget.projectID, 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'], true).then((res) {
GifLoaderDialogUtils.hideDialog(context);
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);

@ -1372,7 +1372,7 @@ class DoctorsListService extends BaseService {
Future<Map> HIS_createAdvancePayment(AppoitmentAllHistoryResultList appo, String projectID, double payedAmount, String paymentReference, String paymentMethodName, dynamic patientType,
String patientName, dynamic patientID, BuildContext context,
{bool isAncillaryOrder = false}) async {
{bool isAncillaryOrder = false, int clinicID = 0}) async {
Map<String, dynamic> request;
if (await this.sharedPref.getObject(USER_PROFILE) != null) {
var data = AuthenticatedUser.fromJson(await this.sharedPref.getObject(USER_PROFILE));
@ -1764,7 +1764,7 @@ class DoctorsListService extends BaseService {
return Future.value(localRes);
}
Future<Map> autoGenerateInvoiceERClinic(int projectID, int paymentMethod, String paymentReferenceNo, num amount, String cardType, String cardNumber, String orderID, String rrn) async {
Future<Map> autoGenerateInvoiceERClinic(int projectID, int paymentMethod, String paymentReferenceNo, num amount, String cardType, String cardNumber, String orderID, String rrn, bool isAdvanceAvailable) async {
Map<String, dynamic> request;
request = {
"ProjectID": projectID,
@ -1776,7 +1776,8 @@ class DoctorsListService extends BaseService {
"CardNumber": cardNumber,
"OrderId": orderID,
"MemberID": 102,
"RRN": rrn
"RRN": rrn,
"IsAdvanceAvailable": isAdvanceAvailable
};
dynamic localRes;
await baseAppClient.post(AUTO_GENERATE_INVOICE_ER, onSuccess: (response, statusCode) async {

Loading…
Cancel
Save