From 330f2d6c86d204a0ab58fb90aa767a16da93bb1a Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Thu, 9 Dec 2021 12:05:25 +0300 Subject: [PATCH] Fixes & updates --- lib/config/config.dart | 9 +++- lib/core/model/pharmacies/orders_model.dart | 3 ++ .../order_model_view_model.dart | 4 +- .../syncHealthData.dart | 50 +++++++++++++++++-- .../product-details/availability_info.dart | 35 ++++++------- .../pharmacies/widgets/home/BannerPager.dart | 3 +- lib/pages/pharmacy/order/OrderDetails.dart | 11 +--- .../orderDetails_service.dart | 4 +- .../pharmacy_services/order_service.dart | 2 +- .../pharmacy_services/wishList_service.dart | 25 +++++----- lib/widgets/hospital_location.dart | 32 +++++------- lib/widgets/in_app_browser/InAppBrowser.dart | 17 ++++--- 12 files changed, 114 insertions(+), 81 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 42861cce..f68ce30e 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -68,7 +68,9 @@ const GET_DOCTOR_RATING_DETAILS = const GET_DOCTOR_RATING = 'Services/Doctors.svc/REST/dr_GetAvgDoctorRating'; ///Prescriptions -const PRESCRIPTIONS = 'Services/Patients.svc/REST/GetPrescriptionApptList'; +// const PRESCRIPTIONS = 'Services/Patients.svc/REST/GetPrescriptionApptList'; +const PRESCRIPTIONS = 'Services/Patients.svc/REST/GetPrescriptionApptList_Async'; + const GET_PRESCRIPTIONS_ALL_ORDERS = 'Services/Patients.svc/REST/PatientER_GetPatientAllPresOrders'; const GET_PRESCRIPTION_REPORT = @@ -570,7 +572,10 @@ const TRANSFER_YAHALA_LOYALITY_POINTS = "Services/Patients.svc/REST/TransferYaHalaLoyaltyPoints"; const LAKUM_GET_USER_TERMS_AND_CONDITIONS = "Services/ERP.svc/REST/GetUserTermsAndConditionsForEPharmcy"; -const PRESCRIPTION = 'Services/Patients.svc/REST/GetPrescriptionApptList'; + +// const PRESCRIPTION = 'Services/Patients.svc/REST/GetPrescriptionApptList'; +const PRESCRIPTION = 'Services/Patients.svc/REST/GetPrescriptionApptList_Async'; + const GET_RECOMMENDED_PRODUCT = 'alsoProduct/'; const GET_MOST_VIEWED_PRODUCTS = "mostview"; const GET_NEW_PRODUCTS = "newproducts"; diff --git a/lib/core/model/pharmacies/orders_model.dart b/lib/core/model/pharmacies/orders_model.dart index cef20c30..ad2c533a 100644 --- a/lib/core/model/pharmacies/orders_model.dart +++ b/lib/core/model/pharmacies/orders_model.dart @@ -31,6 +31,7 @@ class Orders { String orderStatusn; bool canCancel; bool canRefund; + String orderGuid; dynamic customerId; dynamic orderSubtotalExclTax; dynamic orderShippingExclTax; @@ -47,6 +48,7 @@ class Orders { this.orderStatusn, this.canCancel, this.canRefund, + this.orderGuid, this.customerId, this.orderShippingExclTax, this.orderSubtotalExclTax, @@ -63,6 +65,7 @@ class Orders { orderStatusn = json['order_statusn']; canCancel = json['can_cancel']; canRefund = json['can_refund']; + orderGuid = json['order_guid']; customerId = json['customer_id']; orderSubtotalExclTax= json["order_subtotal_excl_tax"]; orderShippingExclTax= json["order_shipping_excl_tax"]; diff --git a/lib/core/viewModels/pharmacyModule/order_model_view_model.dart b/lib/core/viewModels/pharmacyModule/order_model_view_model.dart index 7d6979cc..0ea53363 100644 --- a/lib/core/viewModels/pharmacyModule/order_model_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/order_model_view_model.dart @@ -49,9 +49,9 @@ class OrderModelViewModel extends BaseViewModel { } } - Future getOrderDetails(OrderId) async { + Future getOrderDetails(OrderId, orderGUID) async { setState(ViewState.Busy); - await _orderDetailsService.getOrderDetails(OrderId); + await _orderDetailsService.getOrderDetails(OrderId, orderGUID); if (_orderDetailsService.hasError) { error = _orderDetailsService.error; setState(ViewState.Error); diff --git a/lib/pages/medical/smart_watch_health_data/syncHealthData.dart b/lib/pages/medical/smart_watch_health_data/syncHealthData.dart index f6ad1ce7..5a0b95b5 100644 --- a/lib/pages/medical/smart_watch_health_data/syncHealthData.dart +++ b/lib/pages/medical/smart_watch_health_data/syncHealthData.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:collection/collection.dart'; import 'package:diplomaticquarterapp/models/SmartWatch/HealthData.dart'; import 'package:diplomaticquarterapp/services/smartwatch_integration/SmartWatchIntegrationService.dart'; @@ -8,6 +10,7 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:fit_kit/fit_kit.dart'; import 'package:flutter/material.dart'; +import 'package:health/health.dart'; import 'package:intl/intl.dart'; class syncHealthDataButton extends StatefulWidget { @@ -26,6 +29,8 @@ class syncHealthDataButton extends StatefulWidget { class _syncHealthDataButtonState extends State { List dataTypes = List(); + List _healthDataList = []; + List Med_InsertTransactionsInputsList = new List(); List Med_InsertTransactionsInputsList2 = new List(); @@ -56,12 +61,53 @@ class _syncHealthDataButtonState extends State { padding: const EdgeInsets.all(20.0), child: DefaultButton(TranslationBase.of(context).syncHealthData, () { print("ReadAll"); - readAll(); + fetchData(); + // readAll(); }), ), ); } + Future fetchData() async { + // get everything from midnight until now + DateTime startDate = DateTime(2021, 11, 01, 0, 0, 0); + DateTime endDate = DateTime(2021, 12, 06, 23, 59, 59); + + HealthFactory health = HealthFactory(); + + // define the types to get + List types = [ + HealthDataType.STEPS, + HealthDataType.HEART_RATE, + Platform.isAndroid ? HealthDataType.DISTANCE_DELTA : HealthDataType.DISTANCE_WALKING_RUNNING + ]; + + // you MUST request access to the data types before reading them + // bool accessWasGranted = await health.requestAuthorization(types); + await health.requestAuthorization(types); + + int steps = 0; + try { + List healthData = await health.getHealthDataFromTypes(startDate, endDate, types); + _healthDataList.addAll(healthData); + } catch (e) { + print("Caught exception in getHealthDataFromTypes: $e"); + } + + // filter out duplicates + _healthDataList = HealthFactory.removeDuplicates(_healthDataList); + + // print the results + _healthDataList.forEach((x) { + if(x.type == HealthDataType.STEPS) { + print("Data point: $x"); + steps += x.value.round(); + } + }); + + print("Steps: $steps"); + } + void readAll() async { TransactionsListID = 1; var MedSubCategoryID = 0; @@ -160,7 +206,6 @@ class _syncHealthDataButtonState extends State { void getAllHealthDataLists() { var totalSteps = 0.0; var totalDistance = 0.0; - // double totalCalories = 0.0 ; double totalHeartRate = 0.0; double avgTotalHeartRate = 0.0; var counter = 0; @@ -190,7 +235,6 @@ class _syncHealthDataButtonState extends State { value.forEach((element) { if (element['MedCategoryID'] == 6) { MedCategoryID = 6; - totalSteps += element['Value']; } else if (element['MedCategoryID'] == 7) { MedCategoryID = 7; diff --git a/lib/pages/pharmacies/screens/product-details/availability_info.dart b/lib/pages/pharmacies/screens/product-details/availability_info.dart index 5cacf64d..9264cac6 100644 --- a/lib/pages/pharmacies/screens/product-details/availability_info.dart +++ b/lib/pages/pharmacies/screens/product-details/availability_info.dart @@ -1,15 +1,16 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; -import 'package:maps_launcher/maps_launcher.dart'; -import 'package:url_launcher/url_launcher.dart'; +import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:map_launcher/map_launcher.dart'; -import 'dart:io' show Platform; +import 'package:url_launcher/url_launcher.dart'; class AvailabilityInfo extends StatelessWidget { final ProductDetailViewModel previousModel; - const AvailabilityInfo({Key key, this.previousModel}) : super(key: key); + final InAppBrowser browser = new InAppBrowser(); + + AvailabilityInfo({Key key, this.previousModel}) : super(key: key); @override Widget build(BuildContext context) { @@ -22,8 +23,8 @@ class AvailabilityInfo extends StatelessWidget { ), ) : Container( - margin: EdgeInsets.only(bottom: 40), - child: ListView.builder( + margin: EdgeInsets.only(bottom: 40), + child: ListView.builder( physics: ScrollPhysics(), scrollDirection: Axis.vertical, shrinkWrap: true, @@ -55,20 +56,14 @@ class AvailabilityInfo extends StatelessWidget { child: IconButton( icon: Icon(Icons.location_on), color: Colors.red, - onPressed: () { - if (Platform.isIOS) { MapLauncher.showMarker( - mapType: MapType.apple, - coords: Coords(double.parse(previousModel.productLocationService[index].latitude), - double.parse(previousModel.productLocationService[index].longitude)), - title: previousModel.productLocationService[index].locationDescription,); - } else { MapLauncher.showMarker( - mapType: MapType.google, - coords: Coords(double.parse(previousModel.productLocationService[index].latitude), - double.parse(previousModel.productLocationService[index].longitude)), + onPressed: () async { + // if (await MapLauncher.isMapAvailable(MapType.apple)) { + await MapLauncher.showMarker( + mapType: MapType.google, + coords: Coords(double.parse(previousModel.productLocationService[index].latitude), double.parse(previousModel.productLocationService[index].longitude)), title: previousModel.productLocationService[index].locationDescription, - // description: location.locationName, - ); } - // MapsLauncher.launchCoordinates(double.parse(previousModel.productLocationService[index].latitude), double.parse(previousModel.productLocationService[index].longitude), previousModel.productLocationService[index].locationDescription); + ); + // } }, ), ), @@ -90,7 +85,7 @@ class AvailabilityInfo extends StatelessWidget { ); }, ), - ); + ); } convertCityName(txt) { diff --git a/lib/pages/pharmacies/widgets/home/BannerPager.dart b/lib/pages/pharmacies/widgets/home/BannerPager.dart index 8c62f458..bf7ca715 100644 --- a/lib/pages/pharmacies/widgets/home/BannerPager.dart +++ b/lib/pages/pharmacies/widgets/home/BannerPager.dart @@ -104,7 +104,8 @@ class _BannerPagerState extends State { } break; case 2: { - Navigator.push(context, FadePage(page: LakumActivationVidaPage())); + // Navigator.push(context, FadePage(page: LakumActivationVidaPage())); + Navigator.push(context, FadePage(page: LakumMainPage())); } break; case 5: { diff --git a/lib/pages/pharmacy/order/OrderDetails.dart b/lib/pages/pharmacy/order/OrderDetails.dart index 6b7c957e..0a735d8c 100644 --- a/lib/pages/pharmacy/order/OrderDetails.dart +++ b/lib/pages/pharmacy/order/OrderDetails.dart @@ -74,7 +74,7 @@ class _OrderDetailsPageState extends State { this.context = context; return BaseView( onModelReady: (model) { - model.getOrderDetails(widget.orderModel.id).then((value) { + model.getOrderDetails(widget.orderModel.id, widget.orderModel.orderGuid).then((value) { setState(() { isActiveDelivery = (value.orderStatusId == 995 && (value.driverID != null && value.driverID.isNotEmpty)); }); @@ -533,10 +533,6 @@ class _OrderDetailsPageState extends State { model.orderListModel[0].orderStatusId == 10 ? InkWell( onTap: () { - print(widget.orderModel.toString()); - print(model.orderListModel.toString()); - print("calc = ${5.9 * 3}"); - // TODO MOSA openPayment(model.orderListModel[0], model.user); }, child: Container( @@ -672,11 +668,6 @@ class _OrderDetailsPageState extends State { } } - /*** - * - * Online payment methods - */ - openPayment( OrderDetailModel order, AuthenticatedUser authenticatedUser, diff --git a/lib/services/pharmacy_services/orderDetails_service.dart b/lib/services/pharmacy_services/orderDetails_service.dart index 2f4a1d56..3b03dabc 100644 --- a/lib/services/pharmacy_services/orderDetails_service.dart +++ b/lib/services/pharmacy_services/orderDetails_service.dart @@ -20,10 +20,10 @@ class OrderDetailsService extends BaseService{ List get orderList => _orderList; - Future getOrderDetails(OrderId) async { + Future getOrderDetails(OrderId, orderGUID) async { var customerGUID = await sharedPref.getObject(PHARMACY_CUSTOMER_GUID); hasError = false; - await baseAppClient.getPharmacy(GET_ORDER_DETAILS+OrderId + "/$customerGUID", + await baseAppClient.getPharmacy(GET_ORDER_DETAILS+OrderId + "/$orderGUID", onSuccess: (dynamic response, int statusCode) { _orderList.clear(); response['orders'].forEach((item) { diff --git a/lib/services/pharmacy_services/order_service.dart b/lib/services/pharmacy_services/order_service.dart index 373f2819..ed2391d8 100644 --- a/lib/services/pharmacy_services/order_service.dart +++ b/lib/services/pharmacy_services/order_service.dart @@ -20,7 +20,7 @@ class OrderService extends BaseService { hasError = false; // url =GET_ORDER+"customer=1,fields=id,order_total,order_status,order_statusn,order_status_id,created_on_utc&page=1&limit=200&customer_id=1367368"; // url =GET_ORDER+"customer=1,fields=id,order_total,order_status,order_statusn,order_status_id,created_on_utc&page=$pageId&limit=200&customer_id=$customerId"; - url = GET_ORDER + "customer=1&fields=id,order_total,order_status,order_statusn,order_status_id,created_on_utc,product_count,can_cancel,can_refund&page=$pageId&limit=200&customer_id=$customerId&CustomerguId=$customerGUID"; + url = GET_ORDER + "customer=1&fields=id,order_total,order_status,order_statusn,order_status_id,created_on_utc,product_count,can_cancel,can_refund,order_guid&page=$pageId&limit=200&customer_id=$customerId&CustomerguId=$customerGUID"; print(url); await baseAppClient.getPharmacy(url, onSuccess: (dynamic response, int statusCode) { diff --git a/lib/services/pharmacy_services/wishList_service.dart b/lib/services/pharmacy_services/wishList_service.dart index ce55a40b..ab347307 100644 --- a/lib/services/pharmacy_services/wishList_service.dart +++ b/lib/services/pharmacy_services/wishList_service.dart @@ -4,11 +4,11 @@ import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/models/pharmacy/Wishlist.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; - class WishListService extends BaseService { AppSharedPreferences sharedPref = AppSharedPreferences(); bool isLogin = false; List _wishListProducts = List(); + List get wishListProducts => _wishListProducts; // Future getWishlist() async { @@ -52,18 +52,17 @@ class WishListService extends BaseService { Future getWishlist() async { //TODO we need to check why the customer id comes null - String customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID)?? "0"; + String customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID) ?? "0"; + var customerGUID = await sharedPref.getObject(PHARMACY_CUSTOMER_GUID); hasError = false; - await baseAppClient.getPharmacy(GET_WISHLIST+customerId +"?shopping_cart_type=2", - onSuccess: (dynamic response, int statusCode) { - _wishListProducts.clear(); - response['shopping_carts'].forEach((item) { - _wishListProducts.add(Wishlist.fromJson(item)); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }); + await baseAppClient.getPharmacy(GET_WISHLIST + customerId + "/$customerGUID/" + "?shopping_cart_type=2", onSuccess: (dynamic response, int statusCode) { + _wishListProducts.clear(); + response['shopping_carts'].forEach((item) { + _wishListProducts.add(Wishlist.fromJson(item)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }); } - } diff --git a/lib/widgets/hospital_location.dart b/lib/widgets/hospital_location.dart index edd7f473..0e898ee1 100644 --- a/lib/widgets/hospital_location.dart +++ b/lib/widgets/hospital_location.dart @@ -2,21 +2,18 @@ import 'package:diplomaticquarterapp/core/model/contactus/get_hmg_locations.dart import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; -import 'package:maps_launcher/maps_launcher.dart'; +import 'package:map_launcher/map_launcher.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; -import 'package:map_launcher/map_launcher.dart'; import 'avatar/large_avatar.dart'; import 'my_rich_text.dart'; -import 'dart:io' show Platform; class HospitalLocation extends StatelessWidget { final GetHMGLocationsModel location; final bool showCity; final String waitingTime; - HospitalLocation(this.location, {Key key, this.showCity = false, this.waitingTime}) : super(key: key); @override @@ -76,20 +73,17 @@ class HospitalLocation extends StatelessWidget { ), Column( children: [ - contactButton(Icons.location_on, TranslationBase.of(context).locationa, () { - // MapsLauncher.launchCoordinates(double.parse(location.latitude), double.parse(location.longitude), location.locationName); - if (Platform.isIOS) { MapLauncher.showMarker( -// mapType: MapType.google, - mapType: MapType.apple, - coords: Coords(double.parse(location.latitude), double.parse(location.longitude)), - title: location.locationName,); - } else { MapLauncher.showMarker( - mapType: MapType.google, - coords: Coords(double.parse(location.latitude), double.parse(location.longitude)), - title: location.locationName, - // description: location.locationName, - ); }} - ), + contactButton( + Icons.location_on, + TranslationBase.of(context).locationa, + () async { + await MapLauncher.showMarker( + mapType: MapType.google, + coords: Coords(double.parse(location.latitude), double.parse(location.longitude)), + title: location.locationName, + ); + }, + ), SizedBox(height: 10), contactButton(Icons.call, TranslationBase.of(context).callNow, () { launch("tel://" + location.phoneNumber); @@ -121,6 +115,4 @@ class HospitalLocation extends StatelessWidget { ), ); } - - } diff --git a/lib/widgets/in_app_browser/InAppBrowser.dart b/lib/widgets/in_app_browser/InAppBrowser.dart index 5ae0d119..49e23271 100644 --- a/lib/widgets/in_app_browser/InAppBrowser.dart +++ b/lib/widgets/in_app_browser/InAppBrowser.dart @@ -28,15 +28,13 @@ var _InAppBrowserOptions = InAppBrowserClassOptions( class MyInAppBrowser extends InAppBrowser { _PAYMENT_TYPE paymentType; - // static String SERVICE_URL = - // 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT + static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT - static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE + // static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE - // static String PREAUTH_SERVICE_URL = - // 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort PreAuth Payment Gateway URL UAT + static String PREAUTH_SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort PreAuth Payment Gateway URL UAT - static String PREAUTH_SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort PreAuth Payment Gateway URL Live Store + // static String PREAUTH_SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort PreAuth Payment Gateway URL Live Store // static String PRESCRIPTION_PAYMENT_WITH_ORDERID = // 'https://uat.hmgwebservices.com/epharmacy/checkout/OpcCompleteRedirectionPaymentClientbyOrder?orderID='; @@ -204,9 +202,14 @@ class MyInAppBrowser extends InAppBrowser { openPharmacyPaymentBrowser(OrderDetailModel order, double amount, String orderDesc, String transactionID, String emailId, String paymentMethod, String patientName, dynamic patientID, AuthenticatedUser authenticatedUser, InAppBrowser browser) { this.browser = browser; + MyChromeSafariBrowser safariBrowser = new MyChromeSafariBrowser(new MyInAppBrowser(), onExitCallback: browser.onExit, onLoadStartCallback: this.browser.onLoadStart, appo: this.appo); getPatientData(); generatePharmacyURL(order, amount, orderDesc, transactionID, emailId, paymentMethod, patientName, patientID, authenticatedUser).then((value) { - this.browser.openUrl(url: value); + if (order.customValuesXml.contains("ApplePay")) { + safariBrowser.open(url: value); + } else { + this.browser.openUrl(url: value); + } }); }