From d535cb421d0f6836b33826e82811efaaedf0ef3b Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Wed, 29 Sep 2021 15:13:33 +0300 Subject: [PATCH] bug fixes --- lib/config/config.dart | 4 +- .../service/medical/BloodSugarService.dart | 56 +++++--------- .../medical/prescriptions_service.dart | 24 +++--- .../medical/prescriptions_view_model.dart | 32 ++------ .../prescription_items_page.dart | 9 ++- lib/widgets/drawer/app_drawer_widget.dart | 76 +++++-------------- 6 files changed, 65 insertions(+), 136 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 6bf726ac..0b3fc7ea 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -12,8 +12,8 @@ const PACKAGES_PRODUCTS = '/api/products'; const PACKAGES_CUSTOMER = '/api/customers'; const PACKAGES_SHOPPING_CART = '/api/shopping_cart_items'; const PACKAGES_ORDERS = '/api/orders'; -// const BASE_URL = 'https://uat.hmgwebservices.com/'; -const BASE_URL = 'https://hmgwebservices.com/'; +const BASE_URL = 'https://uat.hmgwebservices.com/'; +// const BASE_URL = 'https://hmgwebservices.com/'; // Pharmacy UAT URLs const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; diff --git a/lib/core/service/medical/BloodSugarService.dart b/lib/core/service/medical/BloodSugarService.dart index 4de444ea..84b932e8 100644 --- a/lib/core/service/medical/BloodSugarService.dart +++ b/lib/core/service/medical/BloodSugarService.dart @@ -19,8 +19,7 @@ class BloodSugarService extends BaseService { hasError = false; Map body = Map(); body['isDentalAllowedBackend'] = false; - await baseAppClient.post(GET_DIABETIC_RESULT_AVERAGE, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(GET_DIABETIC_RESULT_AVERAGE, onSuccess: (dynamic response, int statusCode) { monthDiabtectResultAverageList.clear(); weekDiabtectResultAverageList.clear(); yearDiabtecResultAverageList.clear(); @@ -30,18 +29,15 @@ class BloodSugarService extends BaseService { yearDiabtecPatientResult.clear(); response['List_MonthDiabtectResultAverage'].forEach((item) { - monthDiabtectResultAverageList - .add(MonthDiabtectResultAverage.fromJson(item)); + monthDiabtectResultAverageList.add(MonthDiabtectResultAverage.fromJson(item)); }); response['List_WeekDiabtectResultAverage'].forEach((item) { - weekDiabtectResultAverageList - .add(WeekDiabtectResultAverage.fromJson(item)); + weekDiabtectResultAverageList.add(WeekDiabtectResultAverage.fromJson(item)); }); response['List_YearDiabtecResultAverage'].forEach((item) { - yearDiabtecResultAverageList - .add(YearDiabtecResultAverage.fromJson(item)); + yearDiabtecResultAverageList.add(YearDiabtecResultAverage.fromJson(item)); }); }, onFailure: (String error, int statusCode) { hasError = true; @@ -51,8 +47,7 @@ class BloodSugarService extends BaseService { Future getDiabtecResults() async { hasError = false; - await baseAppClient.post(GET_DIABTEC_RESULT, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(GET_DIABTEC_RESULT, onSuccess: (dynamic response, int statusCode) { monthDiabtecPatientResult.clear(); weekDiabtecPatientResult.clear(); yearDiabtecPatientResult.clear(); @@ -69,7 +64,6 @@ class BloodSugarService extends BaseService { yearDiabtecPatientResult.add(DiabtecPatientResult.fromJson(item)); }); }, onFailure: (String error, int statusCode) { - hasError = true; super.error = error; }, body: Map()); } @@ -81,17 +75,15 @@ class BloodSugarService extends BaseService { body['BloodSugerDateChart'] = bloodSugerDateChart; body['BloodSugerResult'] = bloodSugerResult; body['DiabtecUnit'] = diabtecUnit; - body['MeasuredTime'] = measuredTime+1; + body['MeasuredTime'] = measuredTime + 1; body['isDentalAllowedBackend'] = false; - await baseAppClient.post(ADD_DIABTEC_RESULT, - onSuccess: (response, statusCode) async {}, - onFailure: (String error, int statusCode) { + await baseAppClient.post(ADD_DIABTEC_RESULT, onSuccess: (response, statusCode) async {}, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); } - updateDiabtecResult({DateTime month,DateTime hour,String bloodSugerResult,String diabtecUnit, int measuredTime,int lineItemNo}) async { + updateDiabtecResult({DateTime month, DateTime hour, String bloodSugerResult, String diabtecUnit, int measuredTime, int lineItemNo}) async { hasError = false; super.error = ""; Map body = Map(); @@ -99,11 +91,9 @@ class BloodSugarService extends BaseService { body['DiabtecUnit'] = diabtecUnit; body['BloodSugerDateChart'] = '${month.year}-${month.month}-${month.day} ${hour.hour}:${hour.minute}:00'; body['isDentalAllowedBackend'] = false; - body['MeasuredTime'] = measuredTime+1; + body['MeasuredTime'] = measuredTime + 1; body['LineItemNo'] = lineItemNo; - await baseAppClient.post(UPDATE_DIABETIC_RESULT, - onSuccess: (response, statusCode) async {}, - onFailure: (String error, int statusCode) { + await baseAppClient.post(UPDATE_DIABETIC_RESULT, onSuccess: (response, statusCode) async {}, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); @@ -115,25 +105,21 @@ class BloodSugarService extends BaseService { Map body = Map(); body['isDentalAllowedBackend'] = false; body['To'] = user.emailAddress; - await baseAppClient.post(SEND_AVERAGE_BLOOD_SUGAR_REPORT, - onSuccess: (response, statusCode) async {}, - onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: body); + await baseAppClient.post(SEND_AVERAGE_BLOOD_SUGAR_REPORT, onSuccess: (response, statusCode) async {}, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); } - Future deactivateDiabeticStatus({int lineItemNo }) async { - hasError = false; + Future deactivateDiabeticStatus({int lineItemNo}) async { + hasError = false; super.error = ""; Map body = Map(); body['isDentalAllowedBackend'] = false; - body['LineItemNo'] =lineItemNo; - await baseAppClient.post(DEACTIVATE_DIABETIC_STATUS, - onSuccess: (response, statusCode) async {}, - onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: body); + body['LineItemNo'] = lineItemNo; + await baseAppClient.post(DEACTIVATE_DIABETIC_STATUS, onSuccess: (response, statusCode) async {}, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); } } diff --git a/lib/core/service/medical/prescriptions_service.dart b/lib/core/service/medical/prescriptions_service.dart index d815ea30..587297eb 100644 --- a/lib/core/service/medical/prescriptions_service.dart +++ b/lib/core/service/medical/prescriptions_service.dart @@ -18,7 +18,7 @@ class PrescriptionsService extends BaseService { List prescriptionsList = List(); List prescriptionReportListINP = List(); List prescriptionsOrderList = List(); - + var isMedDeliveryAllowed; Future getPrescriptions() async { hasError = false; Map body = Map(); @@ -48,8 +48,7 @@ class PrescriptionsService extends BaseService { }, body: body); } - RequestPrescriptionReport _requestPrescriptionReport = - RequestPrescriptionReport(appointmentNo: 0, isDentalAllowedBackend: false); + RequestPrescriptionReport _requestPrescriptionReport = RequestPrescriptionReport(appointmentNo: 0, isDentalAllowedBackend: false); List prescriptionReportList = List(); Future getPrescriptionReport({Prescriptions prescriptions}) async { @@ -65,10 +64,10 @@ class PrescriptionsService extends BaseService { _requestPrescriptionReport.episodeID = prescriptions.episodeID; _requestPrescriptionReport.appointmentNo = prescriptions.appointmentNo; - await baseAppClient.post(prescriptions.isInOutPatient ? GET_PRESCRIPTION_REPORT_ENH : GET_PRESCRIPTION_REPORT, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(prescriptions.isInOutPatient ? GET_PRESCRIPTION_REPORT_ENH : GET_PRESCRIPTION_REPORT, onSuccess: (dynamic response, int statusCode) { prescriptionReportList.clear(); prescriptionReportEnhList.clear(); + isMedDeliveryAllowed = response['IsHomeMedicineDeliverySupported']; if (prescriptions.isInOutPatient) { response['ListPRM'].forEach((prescriptions) { prescriptionReportList.add(PrescriptionReport.fromJson(prescriptions)); @@ -90,8 +89,7 @@ class PrescriptionsService extends BaseService { isDentalAllowedBackend: false, ); - Future sendPrescriptionEmail( - String appointmentDate, int patientID, String clinicName, String doctorName, int doctorID, int projectID) async { + Future sendPrescriptionEmail(String appointmentDate, int patientID, String clinicName, String doctorName, int doctorID, int projectID) async { _requestSendPrescriptionEmail.listPrescriptions = prescriptionReportList; _requestSendPrescriptionEmail.appointmentDate = appointmentDate; _requestSendPrescriptionEmail.patientID = patientID; @@ -107,15 +105,13 @@ class PrescriptionsService extends BaseService { _requestSendPrescriptionEmail.setupID = user.setupID; _requestSendPrescriptionEmail.to = user.emailAddress; hasError = false; - await baseAppClient.post(SEND_PRESCRIPTION_EMAIL, onSuccess: (response, statusCode) {}, - onFailure: (String error, int statusCode) { + await baseAppClient.post(SEND_PRESCRIPTION_EMAIL, onSuccess: (response, statusCode) {}, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: _requestSendPrescriptionEmail.toJson()); } - RequestGetListPharmacyForPrescriptions requestGetListPharmacyForPrescriptions = - RequestGetListPharmacyForPrescriptions( + RequestGetListPharmacyForPrescriptions requestGetListPharmacyForPrescriptions = RequestGetListPharmacyForPrescriptions( latitude: 0, longitude: 0, isDentalAllowedBackend: false, @@ -174,8 +170,7 @@ class PrescriptionsService extends BaseService { hasError = false; - await baseAppClient.post(isInPatient ? GET_PRESCRIPTION_REPORT_ENH : GET_PRESCRIPTION_REPORT, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(isInPatient ? GET_PRESCRIPTION_REPORT_ENH : GET_PRESCRIPTION_REPORT, onSuccess: (dynamic response, int statusCode) { prescriptionReportEnhList.clear(); if (isInPatient) { @@ -203,8 +198,7 @@ class PrescriptionsService extends BaseService { body['RejectionReason'] = ''; body['PresOrderStatus'] = 4; body['isDentalAllowedBackend'] = false; - await baseAppClient.post(UPDATE_PRESS_ORDER, onSuccess: (dynamic response, int statusCode) {}, - onFailure: (String error, int statusCode) { + await baseAppClient.post(UPDATE_PRESS_ORDER, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); diff --git a/lib/core/viewModels/medical/prescriptions_view_model.dart b/lib/core/viewModels/medical/prescriptions_view_model.dart index 2fe174e5..43f3b90c 100644 --- a/lib/core/viewModels/medical/prescriptions_view_model.dart +++ b/lib/core/viewModels/medical/prescriptions_view_model.dart @@ -29,9 +29,8 @@ class PrescriptionsViewModel extends BaseViewModel { List get pharmacyPrescriptionsList => _prescriptionsService.pharmacyPrescriptionsList; - List get prescriptionsOrderList => - filterType == FilterType.Clinic ? _prescriptionsOrderListClinic : _prescriptionsOrderListHospital; - + List get prescriptionsOrderList => filterType == FilterType.Clinic ? _prescriptionsOrderListClinic : _prescriptionsOrderListHospital; + get isMedDeliveryAllowed => _prescriptionsService.isMedDeliveryAllowed; getPrescriptions() async { setState(ViewState.Busy); await _prescriptionsService.getPrescriptions(); @@ -48,17 +47,12 @@ class PrescriptionsViewModel extends BaseViewModel { void _filterList() { _prescriptionsService.prescriptionsList.forEach((element) { /// PrescriptionsList list sort clinic - List prescriptionsByClinic = _prescriptionsOrderListClinic - .where((elementClinic) => elementClinic.filterName == element.clinicDescription) - .toList(); + List prescriptionsByClinic = _prescriptionsOrderListClinic.where((elementClinic) => elementClinic.filterName == element.clinicDescription).toList(); if (prescriptionsByClinic.length != 0) { - _prescriptionsOrderListClinic[_prescriptionsOrderListClinic.indexOf(prescriptionsByClinic[0])] - .prescriptionsList - .add(element); + _prescriptionsOrderListClinic[_prescriptionsOrderListClinic.indexOf(prescriptionsByClinic[0])].prescriptionsList.add(element); } else { - _prescriptionsOrderListClinic - .add(PrescriptionsList(filterName: element.clinicDescription, prescriptions: element)); + _prescriptionsOrderListClinic.add(PrescriptionsList(filterName: element.clinicDescription, prescriptions: element)); } /// PrescriptionsList list sort via hospital @@ -69,9 +63,7 @@ class PrescriptionsViewModel extends BaseViewModel { .toList(); if (prescriptionsByHospital.length != 0) { - _prescriptionsOrderListHospital[_prescriptionsOrderListHospital.indexOf(prescriptionsByHospital[0])] - .prescriptionsList - .add(element); + _prescriptionsOrderListHospital[_prescriptionsOrderListHospital.indexOf(prescriptionsByHospital[0])].prescriptionsList.add(element); } else { _prescriptionsOrderListHospital.add(PrescriptionsList(filterName: element.name, prescriptions: element)); } @@ -104,17 +96,9 @@ class PrescriptionsViewModel extends BaseViewModel { } } - sendPrescriptionEmail( - {String appointmentDate, - int patientID, - String clinicName, - String doctorName, - int doctorID, - String mes, - int projectID}) async { + sendPrescriptionEmail({String appointmentDate, int patientID, String clinicName, String doctorName, int doctorID, String mes, int projectID}) async { setState(ViewState.BusyLocal); - await _prescriptionsService.sendPrescriptionEmail( - appointmentDate, patientID, clinicName, doctorName, doctorID, projectID); + await _prescriptionsService.sendPrescriptionEmail(appointmentDate, patientID, clinicName, doctorName, doctorID, projectID); if (_prescriptionsService.hasError) { error = _prescriptionsService.error; setState(ViewState.ErrorLocal); diff --git a/lib/pages/medical/prescriptions/prescription_items_page.dart b/lib/pages/medical/prescriptions/prescription_items_page.dart index 2b12304a..8951236c 100644 --- a/lib/pages/medical/prescriptions/prescription_items_page.dart +++ b/lib/pages/medical/prescriptions/prescription_items_page.dart @@ -16,7 +16,7 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; - +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import '../../../widgets/dialogs/confirm_send_email_dialog.dart'; import 'PrescriptionIDeliveryAddressPage.dart'; @@ -328,9 +328,10 @@ class PrescriptionItemsPage extends StatelessWidget { padding: EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 20), child: Container( width: MediaQuery.of(context).size.width * 0.8, - child: DefaultButton( - TranslationBase.of(context).resendOrder, - () { + child: SecondaryButton( + label: TranslationBase.of(context).resendOrder, + disabled: (!projectViewModel.havePrivilege(62)) || projectViewModel.user.outSA == 1 || model.isMedDeliveryAllowed == false, + onTap: () { Navigator.push( context, FadePage( diff --git a/lib/widgets/drawer/app_drawer_widget.dart b/lib/widgets/drawer/app_drawer_widget.dart index f5e633ec..d1623c86 100644 --- a/lib/widgets/drawer/app_drawer_widget.dart +++ b/lib/widgets/drawer/app_drawer_widget.dart @@ -47,6 +47,7 @@ class _AppDrawerState extends State { @override void initState() { super.initState(); + checkUserData(); } @@ -173,17 +174,14 @@ class _AppDrawerState extends State { children: [ (user.isFamily == null || user.isFamily == false) ? InkWell( - child: DrawerItem( - TranslationBase.of(context).family, - SvgPicture.asset("assets/images/new/family_files.svg"), - isImageIcon: true, - bottomLine: false, - textColor: Theme.of(context).textTheme.bodyText1.color, - iconColor: Theme.of(context).textTheme.bodyText1.color, - sideArrow: true, - letterSpacing: -0.84, - projectProvider: projectProvider - ), + child: DrawerItem(TranslationBase.of(context).family, SvgPicture.asset("assets/images/new/family_files.svg"), + isImageIcon: true, + bottomLine: false, + textColor: Theme.of(context).textTheme.bodyText1.color, + iconColor: Theme.of(context).textTheme.bodyText1.color, + sideArrow: true, + letterSpacing: -0.84, + projectProvider: projectProvider), onTap: () { Navigator.of(context).pop(); Navigator.of(context).pushNamed( @@ -306,16 +304,9 @@ class _AppDrawerState extends State { ), mHeight(20), InkWell( - child: DrawerItem( - TranslationBase.of(context).arabicChange, - Padding(child: Image.asset('assets/images/lang.png'), padding: EdgeInsets.only(left: 3, right: 3, top: 3, bottom: projectProvider.isArabic ? 3 : 0)), - isImageIcon: true, - bottomLine: false, - letterSpacing: -0.84, - fontSize: 14, - fontHeight: projectProvider.isArabic ? 1 : 0.8, - projectProvider: projectProvider - ), + child: DrawerItem(TranslationBase.of(context).arabicChange, + Padding(child: Image.asset('assets/images/lang.png'), padding: EdgeInsets.only(left: 3, right: 3, top: 3, bottom: projectProvider.isArabic ? 3 : 0)), + isImageIcon: true, bottomLine: false, letterSpacing: -0.84, fontSize: 14, fontHeight: projectProvider.isArabic ? 1 : 0.8, projectProvider: projectProvider), onTap: () { sharedPref.remove(APPOINTMENT_HISTORY_MEDICAL); sharedPref.setBool(IS_ROBOT_INIT, null); @@ -371,15 +362,8 @@ class _AppDrawerState extends State { ), if (projectProvider.havePrivilege(3)) InkWell( - child: DrawerItem( - TranslationBase.of(context).appsetting, - SvgPicture.asset("assets/images/new/app_setting.svg"), - isImageIcon: true, - bottomLine: false, - letterSpacing: -0.84, - fontSize: 14, - projectProvider: projectProvider - ), + child: DrawerItem(TranslationBase.of(context).appsetting, SvgPicture.asset("assets/images/new/app_setting.svg"), + isImageIcon: true, bottomLine: false, letterSpacing: -0.84, fontSize: 14, projectProvider: projectProvider), onTap: () { Navigator.of(context).pushNamed( SETTINGS, @@ -387,14 +371,7 @@ class _AppDrawerState extends State { }, ), InkWell( - child: DrawerItem( - TranslationBase.of(context).rateApp, - Icons.star, - bottomLine: false, - letterSpacing: -0.84, - fontSize: 14, - projectProvider: projectProvider - ), + child: DrawerItem(TranslationBase.of(context).rateApp, Icons.star, bottomLine: false, letterSpacing: -0.84, fontSize: 14, projectProvider: projectProvider), onTap: () { if (Platform.isIOS) { launch("https://apps.apple.com/sa/app/dr-suliaman-alhabib/id733503978"); @@ -404,15 +381,8 @@ class _AppDrawerState extends State { }, ), InkWell( - child: DrawerItem( - TranslationBase.of(context).logout, - SvgPicture.asset("assets/images/new/logout.svg"), - isImageIcon: true, - bottomLine: false, - letterSpacing: -0.84, - fontSize: 14, - projectProvider: projectProvider - ), + child: DrawerItem(TranslationBase.of(context).logout, SvgPicture.asset("assets/images/new/logout.svg"), + isImageIcon: true, bottomLine: false, letterSpacing: -0.84, fontSize: 14, projectProvider: projectProvider), onTap: () { logout(); }, @@ -420,15 +390,8 @@ class _AppDrawerState extends State { ], ) : InkWell( - child: DrawerItem( - TranslationBase.of(context).loginregister, - SvgPicture.asset("assets/images/new/logout.svg"), - isImageIcon: true, - letterSpacing: -0.84, - fontSize: 14, - bottomLine: false, - projectProvider: projectProvider - ), + child: DrawerItem(TranslationBase.of(context).loginregister, SvgPicture.asset("assets/images/new/logout.svg"), + isImageIcon: true, letterSpacing: -0.84, fontSize: 14, bottomLine: false, projectProvider: projectProvider), onTap: () { login(); }, @@ -499,6 +462,7 @@ class _AppDrawerState extends State { this.mainUser = data2; }); } + notificationCount = await sharedPref.getString(NOTIFICATION_COUNT); } logout() async {