Covid Drive-Thru implemented

merge-requests/268/head
haroon amjad 4 years ago
parent ba10014b46
commit 5e8e3806d6

@ -0,0 +1,14 @@
{
"client":{
"appType":"1",
"cp_id":"2640966000002322881",
"product_id":"736430079244816576",
"client_id":"563737844552565952",
"client_secret":"9C9A2C272576B8AE6E886C78AF944E8354B91F0AF3381129BB8369FB35E41C47",
"project_id":"736430079244816576",
"app_id":"103856487",
"api_key":"CgB6e3x90XxBrOCMun809w+DOzcFEettcBDUF3fqaLry1ViqTeJqoPwpfaOq/uGw//x0oYwucu9aWazs+Rdj0GUF",
"package_name":"com.cloud.diplomaticquarterapp"
},
"configuration_version":"1.0"
}

@ -0,0 +1,14 @@
{
"client":{
"appType":"1",
"cp_id":"2640966000002322881",
"product_id":"736430079244816567",
"client_id":"563735388191982656",
"client_secret":"650C7C799812AFFD53A10C7756CF05FB9F215A7E49032ABA8EBF3E14B77535CF",
"project_id":"736430079244816567",
"app_id":"102857389",
"api_key":"CgB6e3x9DJzMgRCmnT6dyUEkp6UsIfddb6l3w0ZEXzeiRMHEFi3400Z5fJ5qaHneU0OrAI/JRpk+DMGVs3QpUxlI",
"package_name":"com.ejada.hmg"
},
"configuration_version":"1.0"
}

@ -1332,6 +1332,8 @@ const Map localizedValues = {
"app-update": { "app-update": {
"en": "UPDATE THE APP", "en": "UPDATE THE APP",
"ar": "تحديث التطبيق" "ar": "تحديث التطبيق"
}, "covid-alert": {
"en": "Alert",
"ar": "تنبيه"
}, },
// "visit": {"en" : "Visit", "ar": "الزيارة"},
}; };

@ -5,8 +5,8 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/service/medical/vital_sign_service.dart'; import 'package:diplomaticquarterapp/core/service/medical/vital_sign_service.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/pages/appUpdatePage/app_update_page.dart'; import 'package:diplomaticquarterapp/pages/appUpdatePage/app_update_page.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -46,7 +46,7 @@ class BaseAppClient {
//Map profile = await sharedPref.getObj(DOCTOR_PROFILE); //Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
var pharmacyToken = await sharedPref.getString(PHARMACY_AUTORZIE_TOKEN); var pharmacyToken = await sharedPref.getString(PHARMACY_AUTORZIE_TOKEN);
var user = await sharedPref.getObject(USER_PROFILE); var user = await sharedPref.getObject(USER_PROFILE);
Map<String,String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Accept': 'application/json' 'Accept': 'application/json'
}; };
@ -125,8 +125,7 @@ class BaseAppClient {
if (await Utils.checkConnection()) { if (await Utils.checkConnection()) {
final response = await http.post(url.trim(), final response = await http.post(url.trim(),
body: json.encode(body), body: json.encode(body), headers: headers);
headers: headers);
final int statusCode = response.statusCode; final int statusCode = response.statusCode;
print("statusCode :$statusCode"); print("statusCode :$statusCode");
if (statusCode < 200 || statusCode >= 400 || json == null) { if (statusCode < 200 || statusCode >= 400 || json == null) {
@ -164,21 +163,24 @@ class BaseAppClient {
onSuccess(parsed, statusCode); onSuccess(parsed, statusCode);
} else if (parsed['MessageStatus'] == 2 && } else if (parsed['MessageStatus'] == 2 &&
parsed['IsAuthenticated']) { parsed['IsAuthenticated']) {
if (parsed['message'] == null && if (parsed['SameClinicApptList'] != null) {
parsed['ErrorEndUserMessage'] == null) { onSuccess(parsed, statusCode);
if(parsed['ErrorSearchMsg'] == null ){ } else {
onFailure("Server Error found with no available message", if (parsed['message'] == null &&
statusCode); parsed['ErrorEndUserMessage'] == null) {
}else { if (parsed['ErrorSearchMsg'] == null) {
onFailure(parsed['ErrorSearchMsg'], onFailure("Server Error found with no available message",
statusCode);
} else {
onFailure(parsed['ErrorSearchMsg'], statusCode);
}
} else {
onFailure(
parsed['message'] ??
parsed['ErrorEndUserMessage'] ??
parsed['ErrorMessage'],
statusCode); statusCode);
} }
} else {
onFailure(
parsed['message'] ??
parsed['ErrorEndUserMessage'] ??
parsed['ErrorMessage'],
statusCode);
} }
} else if (!parsed['IsAuthenticated']) { } else if (!parsed['IsAuthenticated']) {
await logout(); await logout();
@ -260,8 +262,7 @@ class BaseAppClient {
Function(String error, int statusCode) onFailure, Function(String error, int statusCode) onFailure,
bool isAllowAny = false, bool isAllowAny = false,
bool isExternal = false, bool isExternal = false,
Map<String, dynamic> queryParams}) async { Map<String, dynamic> queryParams}) async {
String url; String url;
if (isExternal) { if (isExternal) {
url = endPoint; url = endPoint;

@ -1,3 +1,4 @@
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
import 'package:diplomaticquarterapp/models/Appointments/FreeSlot.dart'; import 'package:diplomaticquarterapp/models/Appointments/FreeSlot.dart';
@ -13,9 +14,11 @@ import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.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:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:table_calendar/table_calendar.dart'; import 'package:table_calendar/table_calendar.dart';
class CovidTimeSlots extends StatefulWidget { class CovidTimeSlots extends StatefulWidget {
@ -28,6 +31,8 @@ class CovidTimeSlots extends StatefulWidget {
int selectedClinicID; int selectedClinicID;
int selectedDoctorID; int selectedDoctorID;
var language;
PatientShareResponse patientShareResponse; PatientShareResponse patientShareResponse;
CovidTimeSlots({@required this.projectID}); CovidTimeSlots({@required this.projectID});
@ -89,10 +94,10 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
super.dispose(); super.dispose();
} }
void _onDaySelected(DateTime day, List events) { void _onDaySelected(DateTime day, List events, ProjectViewModel projectViewModel) {
final DateFormat formatter = DateFormat('yyyy-MM-dd'); final DateFormat formatter = DateFormat('yyyy-MM-dd');
setState(() { setState(() {
this.selectedDate = DateUtil.getMonthDayYearDateFormatted(day); this.selectedDate = DateUtil.getWeekDayMonthDayYearDateFormatted(day, projectViewModel.isArabic ? "ar" : "en");
openTimeSlotsPickerForDate(day, docFreeSlots); openTimeSlotsPickerForDate(day, docFreeSlots);
CovidTimeSlots.selectedDate = formatter.format(day); CovidTimeSlots.selectedDate = formatter.format(day);
print(CovidTimeSlots.selectedDate); print(CovidTimeSlots.selectedDate);
@ -111,6 +116,7 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context);
return AppScaffold( return AppScaffold(
appBarTitle: TranslationBase.of(context).covidTest, appBarTitle: TranslationBase.of(context).covidTest,
isShowAppBar: true, isShowAppBar: true,
@ -170,11 +176,12 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
borderRadius: BorderRadius.circular(10.0), borderRadius: BorderRadius.circular(10.0),
color: Colors.white), color: Colors.white),
margin: EdgeInsets.fromLTRB(0.0, 20.0, 0.0, 5.0), margin: EdgeInsets.fromLTRB(0.0, 20.0, 0.0, 5.0),
padding: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 20.0), padding: EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 20.0),
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 0.65, // height: MediaQuery.of(context).size.height * 0.65,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: <Widget>[ children: <Widget>[
Container( Container(
margin: EdgeInsets.all(10.0), margin: EdgeInsets.all(10.0),
@ -219,7 +226,7 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
}, },
), ),
), ),
_buildTableCalendarWithBuilders(), _buildTableCalendarWithBuilders(projectViewModel),
], ],
), ),
), ),
@ -253,7 +260,7 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
onPressed: () { onPressed: () {
bookCovidTestAppointment(); bookCovidTestAppointment();
}, },
child: Text("BOOK", style: TextStyle(fontSize: 18.0)), child: Text(TranslationBase.of(context).bookNow, style: TextStyle(fontSize: 18.0)),
), ),
), ),
), ),
@ -264,9 +271,9 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
); );
} }
Widget _buildTableCalendarWithBuilders() { Widget _buildTableCalendarWithBuilders(ProjectViewModel projectViewModel) {
return TableCalendar( return TableCalendar(
locale: 'en_US', locale: projectViewModel.isArabic ? 'ar_SA' : 'en_US',
calendarController: _calendarController, calendarController: _calendarController,
events: _events, events: _events,
initialCalendarFormat: CalendarFormat.month, initialCalendarFormat: CalendarFormat.month,
@ -351,6 +358,7 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
_onDaySelected( _onDaySelected(
date, date,
event, event,
projectViewModel
); );
_animationController.forward(from: 0.0); _animationController.forward(from: 0.0);
}, },
@ -488,7 +496,6 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
CovidTimeSlots.selectedDate, CovidTimeSlots.selectedDate,
context) context)
.then((res) { .then((res) {
print(res);
if (res['MessageStatus'] == 1) { if (res['MessageStatus'] == 1) {
AppToast.showSuccessToast(message: "Appointment Booked Successfully"); AppToast.showSuccessToast(message: "Appointment Booked Successfully");
getPatientShare(context, res['AppointmentNo'], docObject.clinicID, getPatientShare(context, res['AppointmentNo'], docObject.clinicID,
@ -525,8 +532,8 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
cancelAppointment(DoctorList docObject, AppoitmentAllHistoryResultList appo, cancelAppointment(DoctorList docObject, AppoitmentAllHistoryResultList appo,
BuildContext context) { BuildContext context) {
GifLoaderDialogUtils.showMyDialog(context);
ConfirmDialog.closeAlertDialog(context); ConfirmDialog.closeAlertDialog(context);
GifLoaderDialogUtils.showMyDialog(context);
DoctorsListService service = new DoctorsListService(); DoctorsListService service = new DoctorsListService();
service.cancelAppointment(appo, context).then((res) { service.cancelAppointment(appo, context).then((res) {
if (res['MessageStatus'] == 1) { if (res['MessageStatus'] == 1) {
@ -560,10 +567,12 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
navigateToPaymentAlert() { navigateToPaymentAlert() {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( FadePage(
builder: (context) => CovidPaymentAlert( page: CovidPaymentAlert(
patientShareResponse: widget.patientShareResponse))); patientShareResponse: widget.patientShareResponse),
),
);
} }
getCovidFreeSlots(BuildContext context, int projectID) { getCovidFreeSlots(BuildContext context, int projectID) {

@ -1,7 +1,13 @@
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/models/Appointments/PatientShareResposne.dart'; import 'package:diplomaticquarterapp/models/Appointments/PatientShareResposne.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
import 'package:diplomaticquarterapp/pages/Covid-DriveThru/covid-payment-summary.dart';
import 'package:diplomaticquarterapp/pages/ToDoList/payment_method_select.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.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:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
@ -15,10 +21,13 @@ class CovidPaymentAlert extends StatefulWidget {
} }
class _CovidPaymentAlertState extends State<CovidPaymentAlert> { class _CovidPaymentAlertState extends State<CovidPaymentAlert> {
AppSharedPreferences sharedPref = AppSharedPreferences();
AuthenticatedUser authUser;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AppScaffold( return AppScaffold(
appBarTitle: "COVID-19 TEST", appBarTitle: TranslationBase.of(context).covidTest,
isShowAppBar: true, isShowAppBar: true,
body: SingleChildScrollView( body: SingleChildScrollView(
child: Column( child: Column(
@ -43,7 +52,7 @@ class _CovidPaymentAlertState extends State<CovidPaymentAlert> {
children: <Widget>[ children: <Widget>[
Container( Container(
margin: EdgeInsets.only(left: 30.0, right: 20.0), margin: EdgeInsets.only(left: 30.0, right: 20.0),
child: Text("Alert", child: Text(TranslationBase.of(context).covidAlert,
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -54,7 +63,8 @@ class _CovidPaymentAlertState extends State<CovidPaymentAlert> {
margin: EdgeInsets.only( margin: EdgeInsets.only(
left: 30.0, right: 20.0, top: 5.0), left: 30.0, right: 20.0, top: 5.0),
child: Text( child: Text(
"Pay With-in 15 mins to confirm the appointment", TranslationBase.of(context).covidAlertHeader,
// "Pay With-in 15 mins to confirm the appointment",
overflow: TextOverflow.clip, overflow: TextOverflow.clip,
style: TextStyle( style: TextStyle(
color: Colors.white, fontSize: 20.0)), color: Colors.white, fontSize: 20.0)),
@ -72,7 +82,7 @@ class _CovidPaymentAlertState extends State<CovidPaymentAlert> {
children: <Widget>[ children: <Widget>[
Container( Container(
alignment: Alignment.center, alignment: Alignment.center,
child: Text("Pay With-in 15 mins", child: Text(TranslationBase.of(context).covidAlertMins,
overflow: TextOverflow.clip, overflow: TextOverflow.clip,
style: TextStyle( style: TextStyle(
color: new Color(0xFFc5272d), color: new Color(0xFFc5272d),
@ -83,7 +93,7 @@ class _CovidPaymentAlertState extends State<CovidPaymentAlert> {
alignment: Alignment.center, alignment: Alignment.center,
margin: EdgeInsets.only(top: 15.0), margin: EdgeInsets.only(top: 15.0),
child: Text( child: Text(
"Payment for Covid-19 Test should Be made with-in 15 mins otherwise The system will Cancel the Scheduled appointment automatically.", TranslationBase.of(context).covidAlertInfo,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
color: Colors.grey[700], color: Colors.grey[700],
@ -115,7 +125,7 @@ class _CovidPaymentAlertState extends State<CovidPaymentAlert> {
Container( Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(
top: 15.0, bottom: 10.0, left: 20.0, right: 20.0), top: 15.0, bottom: 10.0, left: 20.0, right: 20.0),
child: Text("COVID-19 TEST", child: Text(TranslationBase.of(context).covidTest,
style: TextStyle( style: TextStyle(
fontSize: 18.0, fontSize: 18.0,
color: Colors.black, color: Colors.black,
@ -137,10 +147,12 @@ class _CovidPaymentAlertState extends State<CovidPaymentAlert> {
child: Text( child: Text(
widget.patientShareResponse.projectName != widget.patientShareResponse.projectName !=
null null
? widget.patientShareResponse.projectName ? widget
.patientShareResponse.projectName
: "NULL", : "NULL",
style: TextStyle( style: TextStyle(
fontSize: 18.0, color: Colors.grey[700])), fontSize: 18.0,
color: Colors.grey[700])),
), ),
], ],
), ),
@ -159,14 +171,16 @@ class _CovidPaymentAlertState extends State<CovidPaymentAlert> {
)), )),
Container( Container(
child: Text( child: Text(
widget.patientShareResponse.appointmentDate != widget.patientShareResponse
.appointmentDate !=
null null
? getDate(widget.patientShareResponse ? getDate(widget.patientShareResponse
.appointmentDate) .appointmentDate)
.split(" ")[0] .split(" ")[0]
: "NULL", : "NULL",
style: TextStyle( style: TextStyle(
fontSize: 18.0, color: Colors.grey[700])), fontSize: 18.0,
color: Colors.grey[700])),
), ),
], ],
), ),
@ -185,14 +199,16 @@ class _CovidPaymentAlertState extends State<CovidPaymentAlert> {
)), )),
Container( Container(
child: Text( child: Text(
widget.patientShareResponse.appointmentDate != widget.patientShareResponse
.appointmentDate !=
null null
? getDate(widget.patientShareResponse ? getDate(widget.patientShareResponse
.appointmentDate) .appointmentDate)
.split(" ")[1] .split(" ")[1]
: "NULL", : "NULL",
style: TextStyle( style: TextStyle(
fontSize: 18.0, color: Colors.grey[700])), fontSize: 18.0,
color: Colors.grey[700])),
), ),
], ],
), ),
@ -216,7 +232,8 @@ class _CovidPaymentAlertState extends State<CovidPaymentAlert> {
.patientShareResponse.doctorNameObj .patientShareResponse.doctorNameObj
: "NULL", : "NULL",
style: TextStyle( style: TextStyle(
fontSize: 18.0, color: Colors.grey[700])), fontSize: 18.0,
color: Colors.grey[700])),
), ),
], ],
), ),
@ -251,9 +268,9 @@ class _CovidPaymentAlertState extends State<CovidPaymentAlert> {
disabledTextColor: Colors.white, disabledTextColor: Colors.white,
disabledColor: Colors.grey[500], disabledColor: Colors.grey[500],
onPressed: () { onPressed: () {
// bookCovidTestAppointment(); startPaymentProcess();
}, },
child: Text("NEXT", style: TextStyle(fontSize: 18.0)), child: Text(TranslationBase.of(context).next, style: TextStyle(fontSize: 18.0)),
), ),
), ),
), ),
@ -264,6 +281,37 @@ class _CovidPaymentAlertState extends State<CovidPaymentAlert> {
); );
} }
startPaymentProcess() {
navigateToPaymentMethod(context, widget.patientShareResponse);
}
Future navigateToPaymentMethod(
context, PatientShareResponse patientShareResponse) async {
if (await this.sharedPref.getObject(USER_PROFILE) != null) {
var data = AuthenticatedUser.fromJson(
await this.sharedPref.getObject(USER_PROFILE));
setState(() {
authUser = data;
});
}
Navigator.push(
context, MaterialPageRoute(builder: (context) => PaymentMethod()))
.then((value) {
print(value);
if (value != null) {
Navigator.push(
context,
FadePage(
page: CovidPaymentSummary(
patientShareResponse: widget.patientShareResponse,
selectedPaymentMethod: value.toString()),
),
);
}
});
}
String getDate(String appoDate) { String getDate(String appoDate) {
var appoDateFormatted = ""; var appoDateFormatted = "";

@ -0,0 +1,331 @@
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
import 'package:diplomaticquarterapp/models/Appointments/PatientShareResposne.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
import 'package:diplomaticquarterapp/pages/Blood/new_text_Field.dart';
import 'package:diplomaticquarterapp/pages/BookAppointment/QRCode.dart';
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.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.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.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 CovidPaymentSummary extends StatefulWidget {
PatientShareResponse patientShareResponse;
final String selectedPaymentMethod;
MyInAppBrowser browser;
AuthenticatedUser authenticatedUser;
AppSharedPreferences sharedPref = AppSharedPreferences();
String transID = "";
CovidPaymentSummary(
{@required this.patientShareResponse, this.selectedPaymentMethod});
@override
_CovidPaymentSummaryState createState() => _CovidPaymentSummaryState();
}
class _CovidPaymentSummaryState extends State<CovidPaymentSummary> {
@override
Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context);
return AppScaffold(
appBarTitle: TranslationBase.of(context).covidTest,
isShowAppBar: true,
body: SingleChildScrollView(
physics: ScrollPhysics(),
child: Container(
margin: EdgeInsets.all(12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Texts(
TranslationBase.of(context).confirmThePayment,
textAlign: TextAlign.center,
fontWeight: FontWeight.w500,
fontSize: 24,
),
SizedBox(
height: 12,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
height: 100.0,
padding: EdgeInsets.all(7.0),
width: MediaQuery.of(context).size.width * 0.45,
child:
Image.asset(getImagePath(widget.selectedPaymentMethod)),
),
Texts(
'${widget.patientShareResponse.patientShareWithTax} ' + TranslationBase.of(context).sar,
fontSize: 26,
bold: true,
)
],
),
SizedBox(
height: 12,
),
Row(
children: [
Expanded(
child: Container(
margin: EdgeInsets.all(3),
child: NewTextFields(
hintText: TranslationBase.of(context).fileNumber,
initialValue:
projectViewModel.user.patientID.toString(),
isEnabled: false,
),
),
),
Expanded(
child: Container(
margin: EdgeInsets.all(3),
child: NewTextFields(
hintText: TranslationBase.of(context).name,
initialValue: projectViewModel.user.firstName,
isEnabled: false,
),
),
),
],
),
SizedBox(
height: 12,
),
NewTextFields(
hintText: TranslationBase.of(context).mobileNumber,
initialValue: projectViewModel.user.mobileNumber,
isEnabled: false,
),
SizedBox(
height: 12,
),
NewTextFields(
hintText: TranslationBase.of(context).depositorName,
initialValue: projectViewModel.user.firstName +
" " +
projectViewModel.user.middleName +
" " +
projectViewModel.user.lastName,
isEnabled: false,
),
],
),
),
),
bottomSheet: Container(
height: MediaQuery.of(context).size.height * 0.1,
width: double.infinity,
padding: EdgeInsets.all(12),
child: SecondaryButton(
textColor: Colors.white,
color: Theme.of(context).primaryColor,
label: TranslationBase.of(context).confirm.toUpperCase(),
onTap: () {
startPaymentProcess(projectViewModel.user);
},
),
),
);
}
startPaymentProcess(AuthenticatedUser authenticatedUser) {
AppoitmentAllHistoryResultList appo = new AppoitmentAllHistoryResultList();
appo.projectID = widget.patientShareResponse.projectID;
appo.clinicID = widget.patientShareResponse.clinicID;
appo.appointmentNo = widget.patientShareResponse.appointmentNo;
openPayment(
widget.selectedPaymentMethod,
authenticatedUser,
double.parse(
widget.patientShareResponse.patientShareWithTax.toString()),
widget.patientShareResponse,
appo);
}
openPayment(
String paymentMethod,
AuthenticatedUser authenticatedUser,
double amount,
PatientShareResponse patientShareResponse,
AppoitmentAllHistoryResultList appo) async {
if (paymentMethod == "ApplePay") {
// await widget.chromeBrowser.open(
// url: "https://applepay-datatrans-sample.herokuapp.com/",
// options: ChromeSafariBrowserClassOptions(
// android: AndroidChromeCustomTabsOptions(
// addDefaultShareMenuItem: false),
// ios: IOSSafariOptions(barCollapsingEnabled: true)));
} else {
widget.browser = new MyInAppBrowser(
onExitCallback: onBrowserExit,
appo: appo,
onLoadStartCallback: onBrowserLoadStart);
widget.browser.openPaymentBrowser(
amount,
"Appointment check in",
Utils.getAppointmentTransID(
appo.projectID, appo.clinicID, appo.appointmentNo),
appo.projectID.toString(),
authenticatedUser.emailAddress,
paymentMethod,
authenticatedUser.patientType,
authenticatedUser.firstName,
authenticatedUser.patientID,
authenticatedUser,
widget.browser,
widget.patientShareResponse.isLiveCareAppointment,
widget.patientShareResponse.appointmentDate,
widget.patientShareResponse.appointmentNo,
widget.patientShareResponse.clinicID,
widget.patientShareResponse.doctorID);
}
}
onBrowserLoadStart(String url) {
print("onBrowserLoadStart");
print(url);
MyInAppBrowser.successURLS.forEach((element) {
if (url.contains(element)) {
if (widget.browser.isOpened()) widget.browser.close();
MyInAppBrowser.isPaymentDone = true;
return;
}
});
MyInAppBrowser.errorURLS.forEach((element) {
if (url.contains(element)) {
if (widget.browser.isOpened()) widget.browser.close();
MyInAppBrowser.isPaymentDone = false;
return;
}
});
}
onBrowserExit(AppoitmentAllHistoryResultList appo, bool isPaymentMade) {
print("onBrowserExit Called!!!!");
if (isPaymentMade) checkPaymentStatus(appo);
}
checkPaymentStatus(AppoitmentAllHistoryResultList appo) {
GifLoaderDialogUtils.showMyDialog(context);
DoctorsListService service = new DoctorsListService();
service
.checkPaymentStatus(
Utils.getAppointmentTransID(
appo.projectID, appo.clinicID, appo.appointmentNo),
context)
.then((res) {
print("Printing Payment Status Reponse!!!!");
print(res);
String paymentInfo = res['Response_Message'];
if (paymentInfo == 'Success') {
createAdvancePayment(res, appo);
} else {
GifLoaderDialogUtils.hideDialog(context);
AppToast.showErrorToast(message: res['Response_Message']);
}
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
AppToast.showErrorToast(message: err);
print(err);
});
}
createAdvancePayment(res, AppoitmentAllHistoryResultList appo) {
DoctorsListService service = new DoctorsListService();
String paymentReference = res['Fort_id'].toString();
service
.createAdvancePayment(appo, appo.projectID.toString(), res['Amount'],
res['Fort_id'], res['PaymentMethod'], context)
.then((res) {
print(res['OnlineCheckInAppointments'][0]['AdvanceNumber']);
addAdvancedNumberRequest(
res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(),
paymentReference,
appo.appointmentNo.toString());
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
AppToast.showErrorToast(message: err);
print(err);
});
}
addAdvancedNumberRequest(
String advanceNumber, String paymentReference, String appointmentID) {
DoctorsListService service = new DoctorsListService();
service
.addAdvancedNumberRequest(
advanceNumber, paymentReference, appointmentID, context)
.then((res) {
print(res);
getAppoQR(context);
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
AppToast.showErrorToast(message: err);
print(err);
});
}
getAppoQR(context) {
DoctorsListService service = new DoctorsListService();
service
.generateAppointmentQR(widget.patientShareResponse, context)
.then((res) {
print(res);
GifLoaderDialogUtils.hideDialog(context);
navigateToQR(context, res['AppointmentQR']);
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
AppToast.showErrorToast(message: err);
print(err);
});
}
Future navigateToQR(context, String appoQR) async {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => QRCode(
patientShareResponse: widget.patientShareResponse,
appoQR: appoQR,
)));
}
String getImagePath(String paymentMethod) {
switch (paymentMethod) {
case "MADA":
return 'assets/images/new-design/mada.png';
break;
case "SADAD":
return 'assets/images/new-design/sadad.png';
break;
case "VISA":
return 'assets/images/new-design/visa.png';
break;
case "MASTERCARD":
return 'assets/images/new-design/mastercard.png';
break;
case "Installment":
return 'assets/images/new-design/installment.png';
break;
}
return 'assets/images/new-design/mada.png';
}
}

@ -27,7 +27,7 @@ class _PaymentMethodState extends State<PaymentMethod> {
Container( Container(
margin: EdgeInsets.fromLTRB(0.0, 15.0, 0.0, 0.0), margin: EdgeInsets.fromLTRB(0.0, 15.0, 0.0, 0.0),
alignment: Alignment.center, alignment: Alignment.center,
child: Text("Select Payment Method", child: Text(TranslationBase.of(context).selectPaymentOption,
style: TextStyle( style: TextStyle(
fontSize: 26.0, fontWeight: FontWeight.bold)), fontSize: 26.0, fontWeight: FontWeight.bold)),
), ),

@ -2,7 +2,7 @@ import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/steps
import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:fit_kit/fit_kit.dart'; // import 'package:fit_kit/fit_kit.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class HealthDataList extends StatefulWidget { class HealthDataList extends StatefulWidget {
@ -12,15 +12,15 @@ class HealthDataList extends StatefulWidget {
class _HealthDataListState extends State<HealthDataList> { class _HealthDataListState extends State<HealthDataList> {
List<DataType> dataTypes = List(); // List<DataType> dataTypes = List();
@override @override
void initState() { void initState() {
dataTypes.add(DataType.DISTANCE); // dataTypes.add(DataType.DISTANCE);
dataTypes.add(DataType.STEP_COUNT); // dataTypes.add(DataType.STEP_COUNT);
dataTypes.add(DataType.HEART_RATE); // dataTypes.add(DataType.HEART_RATE);
dataTypes.add(DataType.SLEEP); // dataTypes.add(DataType.SLEEP);
dataTypes.add(DataType.ENERGY); // dataTypes.add(DataType.ENERGY);
super.initState(); super.initState();
} }
@ -164,7 +164,7 @@ class _HealthDataListState extends State<HealthDataList> {
InkWell( InkWell(
onTap: () { onTap: () {
print("ReadLast"); print("ReadLast");
readLast(); // readLast();
}, },
child:Container( child:Container(
height: (MediaQuery height: (MediaQuery
@ -193,26 +193,26 @@ class _HealthDataListState extends State<HealthDataList> {
} }
void readLast() async { // void readLast() async {
print("ReadLast"); // print("ReadLast");
final result = await FitKit.readLast(DataType.DISTANCE); // final result = await FitKit.readLast(DataType.DISTANCE);
print(result); // print(result);
print(result); // print(result);
} // }
//
void readAll() async { // void readAll() async {
if (await FitKit.requestPermissions(dataTypes)) { // if (await FitKit.requestPermissions(dataTypes)) {
for (DataType type in dataTypes) { // for (DataType type in dataTypes) {
final results = await FitKit.read( // final results = await FitKit.read(
type, // type,
dateFrom: DateTime.now().subtract(Duration(days: 7)), // dateFrom: DateTime.now().subtract(Duration(days: 7)),
dateTo: DateTime.now(), // dateTo: DateTime.now(),
limit: 100, // limit: 100,
); // );
print(results); // print(results);
print(results.length); // print(results.length);
} // }
readLast(); // readLast();
} // }
} // }
} }

@ -1107,6 +1107,7 @@ class TranslationBase {
String get submitncontinue => localizedValues["submitncontinue"][locale.languageCode]; String get submitncontinue => localizedValues["submitncontinue"][locale.languageCode];
String get areyousure => localizedValues["areyousure"][locale.languageCode]; String get areyousure => localizedValues["areyousure"][locale.languageCode];
String get preferredunit => localizedValues["preferredunit"][locale.languageCode]; String get preferredunit => localizedValues["preferredunit"][locale.languageCode];
String get covidAlert => localizedValues["covid-alert"][locale.languageCode];
} }
class TranslationBaseDelegate extends LocalizationsDelegate<TranslationBase> { class TranslationBaseDelegate extends LocalizationsDelegate<TranslationBase> {

Loading…
Cancel
Save