From 17e788690779081162b156c41be70084011e574a Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Thu, 25 May 2023 09:36:16 +0300 Subject: [PATCH] VidaPlus Project changes --- .../privilege/VidaPlusProjectListModel.dart | 15 ++++++++ lib/core/service/medical/labs_service.dart | 20 ++++++----- .../service/medical/radiology_service.dart | 13 ++++--- lib/core/service/privilege_service.dart | 12 +++++-- .../viewModels/medical/labs_view_model.dart | 12 +++---- lib/core/viewModels/project_view_model.dart | 34 ++++++++++++------- .../medical/labs/laboratory_result_page.dart | 15 ++++---- lib/splashPage.dart | 1 + lib/uitl/utils.dart | 12 +++++++ .../LabResult/laboratory_result_widget.dart | 3 +- 10 files changed, 96 insertions(+), 41 deletions(-) create mode 100644 lib/core/model/privilege/VidaPlusProjectListModel.dart diff --git a/lib/core/model/privilege/VidaPlusProjectListModel.dart b/lib/core/model/privilege/VidaPlusProjectListModel.dart new file mode 100644 index 00000000..e56b82db --- /dev/null +++ b/lib/core/model/privilege/VidaPlusProjectListModel.dart @@ -0,0 +1,15 @@ +class VidaPlusProjectListModel { + int projectID; + + VidaPlusProjectListModel({this.projectID}); + + VidaPlusProjectListModel.fromJson(Map json) { + projectID = json['ProjectID']; + } + + Map toJson() { + final Map data = new Map(); + data['ProjectID'] = this.projectID; + return data; + } +} diff --git a/lib/core/service/medical/labs_service.dart b/lib/core/service/medical/labs_service.dart index 9703874e..e9c9d846 100644 --- a/lib/core/service/medical/labs_service.dart +++ b/lib/core/service/medical/labs_service.dart @@ -32,12 +32,14 @@ class LabsService extends BaseService { List labResultList = List(); List labOrdersResultsList = List(); - Future getLaboratoryResult({String projectID, int clinicID, String invoiceNo, String orderNo, String setupID}) async { + Future getLaboratoryResult({String projectID, int clinicID, String invoiceNo, String orderNo, String setupID, bool isVidaPlus}) async { hasError = false; _requestPatientLabSpecialResult.projectID = projectID; _requestPatientLabSpecialResult.clinicID = clinicID; - _requestPatientLabSpecialResult.invoiceNo = "0"; - _requestPatientLabSpecialResult.invoiceNoVP = invoiceNo; + + _requestPatientLabSpecialResult.invoiceNo = isVidaPlus ? "0" : invoiceNo; + _requestPatientLabSpecialResult.invoiceNoVP = isVidaPlus ? invoiceNo : "0"; + _requestPatientLabSpecialResult.orderNo = orderNo; _requestPatientLabSpecialResult.setupID = setupID; @@ -52,11 +54,11 @@ class LabsService extends BaseService { }, body: _requestPatientLabSpecialResult.toJson()); } - Future getPatientLabResult({PatientLabOrders patientLabOrder}) async { + Future getPatientLabResult({PatientLabOrders patientLabOrder, bool isVidaPlus}) async { hasError = false; Map body = Map(); - body['InvoiceNo_VP'] = patientLabOrder.invoiceNo; - body['InvoiceNo'] = "0"; + body['InvoiceNo_VP'] = isVidaPlus ? patientLabOrder.invoiceNo : "0"; + body['InvoiceNo'] = isVidaPlus ? "0" : patientLabOrder.invoiceNo; body['OrderNo'] = patientLabOrder.orderNo; body['isDentalAllowedBackend'] = false; body['SetupID'] = patientLabOrder.setupID; @@ -179,10 +181,10 @@ class LabsService extends BaseService { RequestSendLabReportEmail _requestSendLabReportEmail = RequestSendLabReportEmail(); - Future sendLabReportEmail({PatientLabOrders patientLabOrder, AuthenticatedUser userObj}) async { + Future sendLabReportEmail({PatientLabOrders patientLabOrder, AuthenticatedUser userObj, bool isVidaPlus}) async { _requestSendLabReportEmail.projectID = patientLabOrder.projectID; - _requestSendLabReportEmail.invoiceNo = "0"; - _requestSendLabReportEmail.invoiceNoVP = patientLabOrder.invoiceNo; + _requestSendLabReportEmail.invoiceNo = isVidaPlus ? "0" : patientLabOrder.invoiceNo; + _requestSendLabReportEmail.invoiceNoVP = isVidaPlus ? patientLabOrder.invoiceNo : "0"; _requestSendLabReportEmail.doctorName = patientLabOrder.doctorName; _requestSendLabReportEmail.clinicName = patientLabOrder.clinicDescription; _requestSendLabReportEmail.patientName = userObj.firstName + " " + userObj.lastName; diff --git a/lib/core/service/medical/radiology_service.dart b/lib/core/service/medical/radiology_service.dart index 44940b31..6c8ed698 100644 --- a/lib/core/service/medical/radiology_service.dart +++ b/lib/core/service/medical/radiology_service.dart @@ -1,7 +1,6 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/radiology/final_radiology.dart'; import 'package:diplomaticquarterapp/core/model/radiology/request_send_rad_report_email.dart'; -import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; @@ -29,9 +28,15 @@ class RadiologyService extends BaseService { await baseAppClient.post(GET_PATIENT_ORDERS, onSuccess: (dynamic response, int statusCode) { finalRadiologyList.clear(); // response['FinalRadiologyList'].forEach((radiology) { - response['FinalRadiologyListAPI'].forEach((radiology) { - finalRadiologyList.add(FinalRadiology.fromJson(radiology)); - }); + if (response['FinalRadiologyList'].length != 0) { + response['FinalRadiologyList'].forEach((radiology) { + finalRadiologyList.add(FinalRadiology.fromJson(radiology)); + }); + } else { + response['FinalRadiologyListAPI'].forEach((radiology) { + finalRadiologyList.add(FinalRadiology.fromJson(radiology)); + }); + } }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; diff --git a/lib/core/service/privilege_service.dart b/lib/core/service/privilege_service.dart index 5beef992..e9b2d8a9 100644 --- a/lib/core/service/privilege_service.dart +++ b/lib/core/service/privilege_service.dart @@ -1,19 +1,25 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/privilege/PrivilegeModel.dart'; +import 'package:diplomaticquarterapp/core/model/privilege/VidaPlusProjectListModel.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; class PrivilegeService extends BaseService { - List privilegeModelList = List(); + List vidaPlusProjectListModel = List(); Future getPrivilege() async { Map body = Map(); body['PatientType'] = 4; - await baseAppClient.post(GET_PRIVILEGE, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(GET_PRIVILEGE, onSuccess: (dynamic response, int statusCode) { response['ServicePrivilegeList'].forEach((item) { privilegeModelList.add(PrivilegeModel.fromJson(item)); }); + + if (response['ProjectListVidaPlus'].length != 0) { + response['ProjectListVidaPlus'].forEach((item) { + vidaPlusProjectListModel.add(VidaPlusProjectListModel.fromJson(item)); + }); + } }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; diff --git a/lib/core/viewModels/medical/labs_view_model.dart b/lib/core/viewModels/medical/labs_view_model.dart index e42dbbb4..3d4b1039 100644 --- a/lib/core/viewModels/medical/labs_view_model.dart +++ b/lib/core/viewModels/medical/labs_view_model.dart @@ -72,9 +72,9 @@ class LabsViewModel extends BaseViewModel { List labResultLists = List(); - getLaboratoryResult({String projectID, int clinicID, String invoiceNo, String orderNo, String setupID}) async { + getLaboratoryResult({String projectID, int clinicID, String invoiceNo, String orderNo, String setupID, bool isVidaPlus}) async { setState(ViewState.Busy); - await _labsService.getLaboratoryResult(invoiceNo: invoiceNo, orderNo: orderNo, projectID: projectID, clinicID: clinicID, setupID: setupID); + await _labsService.getLaboratoryResult(invoiceNo: invoiceNo, orderNo: orderNo, projectID: projectID, clinicID: clinicID, setupID: setupID, isVidaPlus: isVidaPlus); if (_labsService.hasError) { error = _labsService.error; setState(ViewState.Error); @@ -83,9 +83,9 @@ class LabsViewModel extends BaseViewModel { } } - getPatientLabResult({PatientLabOrders patientLabOrder}) async { + getPatientLabResult({PatientLabOrders patientLabOrder, bool isVidaPlus}) async { setState(ViewState.Busy); - await _labsService.getPatientLabResult(patientLabOrder: patientLabOrder); + await _labsService.getPatientLabResult(patientLabOrder: patientLabOrder, isVidaPlus: isVidaPlus); if (_labsService.hasError) { error = _labsService.error; setState(ViewState.Error); @@ -135,8 +135,8 @@ class LabsViewModel extends BaseViewModel { } } - sendLabReportEmail({PatientLabOrders patientLabOrder, String mes, AuthenticatedUser userObj}) async { - await _labsService.sendLabReportEmail(patientLabOrder: patientLabOrder, userObj: userObj); + sendLabReportEmail({PatientLabOrders patientLabOrder, String mes, AuthenticatedUser userObj, bool isVidaPlus}) async { + await _labsService.sendLabReportEmail(patientLabOrder: patientLabOrder, userObj: userObj, isVidaPlus: isVidaPlus); if (_labsService.hasError) { error = _labsService.error; } else diff --git a/lib/core/viewModels/project_view_model.dart b/lib/core/viewModels/project_view_model.dart index c45e7dd8..d3b7566c 100644 --- a/lib/core/viewModels/project_view_model.dart +++ b/lib/core/viewModels/project_view_model.dart @@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/analytics/google-analytics.dart'; import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/privilege/PrivilegeModel.dart'; +import 'package:diplomaticquarterapp/core/model/privilege/VidaPlusProjectListModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/models/Appointments/laser_body_parts.dart'; @@ -15,8 +16,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; var isAppArabic = false; -class ProjectViewModel extends BaseViewModel { +class ProjectViewModel extends BaseViewModel { GAnalytics get analytics => locator(); // Platform Bridge @@ -39,10 +40,14 @@ class ProjectViewModel extends BaseViewModel { double _latitude; double _longitude; - RegisterInfoResponse _registerInfo =RegisterInfoResponse(); + RegisterInfoResponse _registerInfo = RegisterInfoResponse(); + double get latitude => _latitude; + double get longitude => _longitude; - RegisterInfoResponse get registerInfo=> _registerInfo; + + RegisterInfoResponse get registerInfo => _registerInfo; + dynamic get searchValue => searchvalue; Locale get appLocal => _appLocale; @@ -54,9 +59,11 @@ class ProjectViewModel extends BaseViewModel { bool isLoginChild = false; List privilegeRootUser = List(); List privilegeChildUser = List(); + List _vidaPlusProjectListModel = List(); - List get privileges => - isLoginChild ? privilegeChildUser : privilegeChildUser; + List get privileges => isLoginChild ? privilegeChildUser : privilegeChildUser; + + List get vidaPlusProjectList => _vidaPlusProjectListModel; List selectedBodyPartList = []; @@ -64,9 +71,7 @@ class ProjectViewModel extends BaseViewModel { ProjectViewModel() { loadSharedPrefLanguage(); - subscription = Connectivity() - .onConnectivityChanged - .listen((ConnectivityResult result) { + subscription = Connectivity().onConnectivityChanged.listen((ConnectivityResult result) { switch (result) { case ConnectivityResult.wifi: isInternetConnection = true; @@ -89,8 +94,7 @@ class ProjectViewModel extends BaseViewModel { } Future loadSharedPrefLanguage() async { - currentLanguage = - await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); + currentLanguage = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); _appLocale = Locale(currentLanguage); isAppArabic = _isArabic = currentLanguage == 'ar'; notifyListeners(); @@ -121,6 +125,11 @@ class ProjectViewModel extends BaseViewModel { notifyListeners(); } + setVidaPlusProjectList(List vidaPlusProjectListModelInput) { + _vidaPlusProjectListModel = vidaPlusProjectListModelInput; + notifyListeners(); + } + setPrivilege({privilegeList, bool isLoginChild = false}) { List privilege = List(); @@ -166,8 +175,9 @@ class ProjectViewModel extends BaseViewModel { searchvalue = data; notifyListeners(); } - setRegisterData(RegisterInfoResponse data){ - _registerInfo =data; + + setRegisterData(RegisterInfoResponse data) { + _registerInfo = data; notifyListeners(); } } diff --git a/lib/pages/medical/labs/laboratory_result_page.dart b/lib/pages/medical/labs/laboratory_result_page.dart index 847f979b..2a77436f 100644 --- a/lib/pages/medical/labs/laboratory_result_page.dart +++ b/lib/pages/medical/labs/laboratory_result_page.dart @@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.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/data_display/medical/LabResult/laboratory_result_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; @@ -25,11 +26,13 @@ class _LaboratoryResultPageState extends State { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getLaboratoryResult( - invoiceNo: widget.patientLabOrders.invoiceNo, - clinicID: widget.patientLabOrders.clinicID, - projectID: widget.patientLabOrders.projectID, - orderNo: widget.patientLabOrders.orderNo, - setupID: widget.patientLabOrders.setupID), + invoiceNo: widget.patientLabOrders.invoiceNo, + clinicID: widget.patientLabOrders.clinicID, + projectID: widget.patientLabOrders.projectID, + orderNo: widget.patientLabOrders.orderNo, + setupID: widget.patientLabOrders.setupID, + isVidaPlus: Utils.isVidaPlusProject(projectViewModel, num.parse(widget.patientLabOrders.projectID)), + ), builder: (_, model, w) => AppScaffold( isShowAppBar: true, appBarTitle: widget.patientLabOrders.doctorName, @@ -43,7 +46,7 @@ class _LaboratoryResultPageState extends State { itemBuilder: (context, index) => LaboratoryResultWidget( onTap: () async { GifLoaderDialogUtils.showMyDialog(context); - await model.sendLabReportEmail(patientLabOrder: widget.patientLabOrders, mes: TranslationBase.of(context).sendSuc, userObj: projectViewModel.user); + await model.sendLabReportEmail(patientLabOrder: widget.patientLabOrders, mes: TranslationBase.of(context).sendSuc, userObj: projectViewModel.user, isVidaPlus: Utils.isVidaPlusProject(projectViewModel, num.parse(widget.patientLabOrders.projectID))); GifLoaderDialogUtils.hideDialog(context); }, billNo: widget.patientLabOrders.invoiceNo, diff --git a/lib/splashPage.dart b/lib/splashPage.dart index 5876ed99..04e1c3b5 100644 --- a/lib/splashPage.dart +++ b/lib/splashPage.dart @@ -54,6 +54,7 @@ class _SplashScreenState extends State { await _privilegeService.getPrivilege(); ProjectViewModel projectProvider = Provider.of(context, listen: false); projectProvider.setPrivilegeModelList(privilege: _privilegeService.privilegeModelList); + projectProvider.setVidaPlusProjectList(_privilegeService.vidaPlusProjectListModel); AppSharedPreferences().clear(); // Clearing Shared Preferences On App Launch AppSharedPreferences().setString(APP_LANGUAGE, projectProvider.isArabic ? "ar" : "en"); var themeNotifier = Provider.of(context, listen: false); diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index 001baf50..a417f40b 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -809,6 +809,18 @@ class Utils { static String generateMd5Hash(String input) { return crypto.md5.convert(utf8.encode(input)).toString(); } + + static bool isVidaPlusProject(ProjectViewModel projectViewModel, int projectID) { + bool isVidaPlus = false; + projectViewModel.vidaPlusProjectList.forEach((element) { + if (element.projectID == projectID) { + isVidaPlus = true; + } else { + isVidaPlus = false; + } + }); + return isVidaPlus; + } } Widget applyShadow({Color color = Colors.grey, double shadowOpacity = 0.5, double spreadRadius = 2, double blurRadius = 7, Offset offset = const Offset(2, 2), @required Widget child}) { diff --git a/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart b/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart index d54249da..3436523d 100644 --- a/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart +++ b/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart @@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/header_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/new_design/doctor_header.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:flutter/cupertino.dart'; @@ -35,7 +36,7 @@ class _LaboratoryResultWidgetState extends State { Widget build(BuildContext context) { projectViewModel = Provider.of(context); return BaseView( - onModelReady: (model) => model.getPatientLabResult(patientLabOrder: widget.patientLabOrder), + onModelReady: (model) => model.getPatientLabResult(isVidaPlus: Utils.isVidaPlusProject(projectViewModel, num.parse(widget.patientLabOrder.projectID)), patientLabOrder: widget.patientLabOrder), builder: (_, model, w) => NetworkBaseView( baseViewModel: model, child: Column(