From 5009e48f641c16beda7aa941648762dae6e41584 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 23 Aug 2021 11:09:19 +0300 Subject: [PATCH] Updates in Ambulance Request & Covid test --- lib/core/model/er/PatientER.dart | 4 +- ..._all_transportation_method_list_model.dart | 111 +++++++----------- lib/core/service/client/base_app_client.dart | 3 +- lib/core/service/er/am_service.dart | 33 ++++-- .../covid-drivethru-location.dart | 4 +- .../BillAmount.dart | 4 +- .../SelectTransportationMethod.dart | 10 +- .../AmbulanceRequestIndexPages/Summary.dart | 4 +- 8 files changed, 79 insertions(+), 94 deletions(-) diff --git a/lib/core/model/er/PatientER.dart b/lib/core/model/er/PatientER.dart index f1694f9e..99063530 100644 --- a/lib/core/model/er/PatientER.dart +++ b/lib/core/model/er/PatientER.dart @@ -160,11 +160,11 @@ class PatientER { data['LanguageID'] = this.languageID; data['IPAdress'] = this.iPAdress; data['generalid'] = this.generalid; - data['PatientOutSA'] = this.patientOutSA; + data['PatientOutSA'] = this.patientOutSA == 0 ? false : true; data['SessionID'] = this.sessionID; data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; data['DeviceTypeID'] = this.deviceTypeID; - data['PatientID'] = this.patientID; + data['PatientID'] = this.patientID.toString(); data['TokenID'] = this.tokenID; data['PatientTypeID'] = this.patientTypeID; data['PatientType'] = this.patientType; diff --git a/lib/core/model/er/get_all_transportation_method_list_model.dart b/lib/core/model/er/get_all_transportation_method_list_model.dart index ebc9caf7..1f0a91c3 100644 --- a/lib/core/model/er/get_all_transportation_method_list_model.dart +++ b/lib/core/model/er/get_all_transportation_method_list_model.dart @@ -1,79 +1,56 @@ -import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; class PatientERTransportationMethod { - dynamic id; - DateTime createDate; - DateTime lastEditDate; - dynamic createdBy; - dynamic lastEditBy; - bool isActive; - String title; - String titleAR; + int id; + String serviceID; + int orderServiceID; + String text; + String textN; dynamic price; - dynamic isDefault; - dynamic visibility; - dynamic durationId; - String description; - String descriptionAR; - dynamic totalPrice; - dynamic vAT; + dynamic priceVAT; + dynamic priceTotal; + bool isEnabled; + int orderId; + int quantity; PatientERTransportationMethod( - { - this.id, - this.createDate, - this.lastEditDate, - this.createdBy, - this.lastEditBy, - this.isActive, - this.title, - this.titleAR, + {this.id, + this.serviceID, + this.orderServiceID, + this.text, + this.textN, this.price, - this.isDefault, - this.visibility, - this.durationId, - this.description, - this.descriptionAR, - this.totalPrice, - this.vAT}); + this.priceVAT, + this.priceTotal, + this.isEnabled, + this.orderId, + this.quantity}); - PatientERTransportationMethod.fromJson( - Map json) { - id = json['Id']; - createDate = DateUtil.convertStringToDate(json['CreateDate']); - lastEditDate = DateUtil.convertStringToDate(json['LastEditDate']); - createdBy = json['CreatedBy']; - lastEditBy = json['LastEditBy']; - isActive = json['IsActive']; - title = json['Title']; - titleAR = json['TitleAR']; - price = json['Price']; - isDefault = json['isDefault']; - visibility = json['Visibility']; - durationId = json['DurationId']; - description = json['Description']; - descriptionAR = json['DescriptionAR']; - totalPrice = json['TotalPrice']; - vAT = json['VAT']; + PatientERTransportationMethod.fromJson(Map json) { + id = json['id']; + serviceID = json['serviceID']; + orderServiceID = json['orderServiceID']; + text = json['text']; + textN = json['textN']; + price = json['price']; + priceVAT = json['priceVAT']; + priceTotal = json['priceTotal']; + isEnabled = json['isEnabled']; + orderId = json['orderId']; + quantity = json['quantity']; } Map toJson() { final Map data = new Map(); - data['Id'] = this.id; - data['CreateDate'] = this.createDate; - data['LastEditDate'] = this.lastEditDate; - data['CreatedBy'] = this.createdBy; - data['LastEditBy'] = this.lastEditBy; - data['IsActive'] = this.isActive; - data['Title'] = this.title; - data['TitleAR'] = this.titleAR; - data['Price'] = this.price; - data['isDefault'] = this.isDefault; - data['Visibility'] = this.visibility; - data['DurationId'] = this.durationId; - data['Description'] = this.description; - data['DescriptionAR'] = this.descriptionAR; - data['TotalPrice'] = this.totalPrice; - data['VAT'] = this.vAT; + data['id'] = this.id; + data['serviceID'] = this.serviceID; + data['orderServiceID'] = this.orderServiceID; + data['text'] = this.text; + data['textN'] = this.textN; + data['price'] = this.price; + data['priceVAT'] = this.priceVAT; + data['priceTotal'] = this.priceTotal; + data['isEnabled'] = this.isEnabled; + data['orderId'] = this.orderId; + data['quantity'] = this.quantity; return data; } -} \ No newline at end of file +} diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 43c39fec..a6a2fb02 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -118,7 +118,8 @@ class BaseAppClient { } print("URL : $url"); - print("Body : ${json.encode(body)}"); + final jsonBody = json.encode(body); + print(jsonBody); if (await Utils.checkConnection()) { final response = await http.post(url.trim(), body: json.encode(body), headers: headers); diff --git a/lib/core/service/er/am_service.dart b/lib/core/service/er/am_service.dart index 2e9460b8..22db55a3 100644 --- a/lib/core/service/er/am_service.dart +++ b/lib/core/service/er/am_service.dart @@ -1,11 +1,11 @@ import 'package:diplomaticquarterapp/config/config.dart'; -import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/enum/OrderService.dart'; import 'package:diplomaticquarterapp/core/model/er/PatientAllPresOrders.dart'; import 'package:diplomaticquarterapp/core/model/er/PatientER.dart'; import 'package:diplomaticquarterapp/core/model/er/PickUpRequestPresOrder.dart'; import 'package:diplomaticquarterapp/core/model/er/get_all_transportation_method_list_model.dart'; import 'package:flutter/cupertino.dart'; + import '../base_service.dart'; class AmService extends BaseService { @@ -22,16 +22,27 @@ class AmService extends BaseService { Map body = Map(); body['isDentalAllowedBackend'] = false; body['IdentificationNo'] = user.patientIdentificationNo; - await baseAppClient.post(GET_AMBULANCE_REQUEST, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.get( + GET_ALL_TRANSPORTATIONS_RC + "?patientID=" + user.patientID.toString(), + isExternal: false, onSuccess: (dynamic response, int statusCode) { amModelList.clear(); - response['PatientER_RRT_GetAllTransportationMethodList'].forEach((item) { + response['data']['transportationservices'].forEach((item) { amModelList.add(PatientERTransportationMethod.fromJson(item)); }); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - }, body: body); + }); + // await baseAppClient.post(GET_AMBULANCE_REQUEST, + // onSuccess: (dynamic response, int statusCode) { + // amModelList.clear(); + // response['PatientER_RRT_GetAllTransportationMethodList'].forEach((item) { + // amModelList.add(PatientERTransportationMethod.fromJson(item)); + // }); + // }, onFailure: (String error, int statusCode) { + // hasError = true; + // super.error = error; + // }, body: body); } Future getPatientAllPresOrdersList() async { @@ -85,9 +96,8 @@ class AmService extends BaseService { body['PresOrderStatus'] = OrderService.AMBULANCE.getIdOrderService(); body['isDentalAllowedBackend'] = false; await baseAppClient.post(UPDATE_PRESS_ORDER, - onSuccess: (dynamic response, int statusCode) { - - }, onFailure: (String error, int statusCode) { + onSuccess: (dynamic response, int statusCode) {}, + onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); @@ -96,10 +106,9 @@ class AmService extends BaseService { Future insertERPressOrder({@required PatientER patientER}) async { hasError = false; - await baseAppClient.post(INSERT_ER_INERT_PRES_ORDER, - onSuccess: (dynamic response, int statusCode) { - - }, onFailure: (String error, int statusCode) { + await baseAppClient.post(INSERT_TRANSPORTATION_ORDER_RC, + onSuccess: (dynamic response, int statusCode) {}, + onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: patientER.toJson()); diff --git a/lib/pages/Covid-DriveThru/covid-drivethru-location.dart b/lib/pages/Covid-DriveThru/covid-drivethru-location.dart index 31ea3e93..eccf48fc 100644 --- a/lib/pages/Covid-DriveThru/covid-drivethru-location.dart +++ b/lib/pages/Covid-DriveThru/covid-drivethru-location.dart @@ -36,9 +36,6 @@ class _CovidDrivethruLocationState extends State { @override void initState() { - WidgetsBinding.instance - .addPostFrameCallback((_) => getProjectsList(context)); - imagesInfo.add( ImagesInfo( imageEn: 'https://hmgwebservices.com/Images/MobileApp/covid/en/0.png', @@ -353,6 +350,7 @@ class _CovidDrivethruLocationState extends State { CovidDriveThruService service = new CovidDriveThruService(); GifLoaderDialogUtils.showMyDialog(context); service.getCovidProjectsList(context).then((res) { + projectsList.clear(); if (res['MessageStatus'] == 1) { setState(() { res['List_COVID19_ProjectDriveThroughTestingCenter'].forEach((v) { diff --git a/lib/pages/ErService/AmbulanceRequestIndexPages/BillAmount.dart b/lib/pages/ErService/AmbulanceRequestIndexPages/BillAmount.dart index 59528df6..3a89a551 100644 --- a/lib/pages/ErService/AmbulanceRequestIndexPages/BillAmount.dart +++ b/lib/pages/ErService/AmbulanceRequestIndexPages/BillAmount.dart @@ -126,7 +126,7 @@ class _BillAmountState extends State { child: Padding( padding: const EdgeInsets.all(8.0), child: Texts( - TranslationBase.of(context).sar+' ${widget.patientER.patientERTransportationMethod.vAT}', + TranslationBase.of(context).sar+' ${widget.patientER.patientERTransportationMethod.priceVAT}', color: Colors.black, fontSize: 15, textAlign: TextAlign.start, @@ -167,7 +167,7 @@ class _BillAmountState extends State { child: Padding( padding: const EdgeInsets.all(8.0), child: Texts( - TranslationBase.of(context).sar+' ${widget.patientER.patientERTransportationMethod.totalPrice}', + TranslationBase.of(context).sar+' ${widget.patientER.patientERTransportationMethod.priceTotal}', color: Colors.black, fontSize: 15, textAlign: TextAlign.start, diff --git a/lib/pages/ErService/AmbulanceRequestIndexPages/SelectTransportationMethod.dart b/lib/pages/ErService/AmbulanceRequestIndexPages/SelectTransportationMethod.dart index 6f3281dc..5bfac450 100644 --- a/lib/pages/ErService/AmbulanceRequestIndexPages/SelectTransportationMethod.dart +++ b/lib/pages/ErService/AmbulanceRequestIndexPages/SelectTransportationMethod.dart @@ -97,9 +97,9 @@ class _SelectTransportationMethodState child: ListTile( title: Texts(projectViewModel.isArabic ? widget.amRequestViewModel - .amRequestModeList[index].titleAR + .amRequestModeList[index].textN : widget.amRequestViewModel - .amRequestModeList[index].title), + .amRequestModeList[index].text), leading: Radio( value: widget .amRequestViewModel.amRequestModeList[index], @@ -317,10 +317,10 @@ class _SelectTransportationMethodState _orderService.getIdOrderService(); widget.patientER.pickupUrgency = 1; widget.patientER.lineItemNo = 1; - widget.patientER.cost = _erTransportationMethod.price; - widget.patientER.vAT = _erTransportationMethod.vAT ?? 0; + widget.patientER.cost = _erTransportationMethod.price.toDouble(); + widget.patientER.vAT = _erTransportationMethod.priceVAT ?? 0; widget.patientER.totalPrice = - _erTransportationMethod.totalPrice; + _erTransportationMethod.priceTotal.toDouble(); widget.changeCurrentTab(1); }); }, diff --git a/lib/pages/ErService/AmbulanceRequestIndexPages/Summary.dart b/lib/pages/ErService/AmbulanceRequestIndexPages/Summary.dart index d6d4372e..867b6583 100644 --- a/lib/pages/ErService/AmbulanceRequestIndexPages/Summary.dart +++ b/lib/pages/ErService/AmbulanceRequestIndexPages/Summary.dart @@ -44,7 +44,7 @@ class _SummaryState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts(TranslationBase.of(context).transportMethod,color: Colors.grey,), - Texts('${widget.patientER.patientERTransportationMethod.title}',bold: true,), + Texts('${widget.patientER.patientERTransportationMethod.text}',bold: true,), SizedBox(height: 8,), Texts(TranslationBase.of(context).directions,color: Colors.grey,), @@ -84,7 +84,7 @@ class _SummaryState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Texts(TranslationBase.of(context).patientShareTotal+':'), - Texts(TranslationBase.of(context).sar+' ${widget.patientER.patientERTransportationMethod.totalPrice}') + Texts(TranslationBase.of(context).sar+' ${widget.patientER.patientERTransportationMethod.priceTotal}') ], ), ),