From 5d0a7a4045742fb971876f4e7c9fb93c98165eba Mon Sep 17 00:00:00 2001 From: mosazaid Date: Sun, 6 Jun 2021 17:08:12 +0300 Subject: [PATCH 1/2] livecare changes --- lib/config/config.dart | 5 +- .../live_care/AlternativeServicesList.dart | 42 ++++++ .../patient/LiveCarePatientServices.dart | 94 +++++++----- .../viewModel/LiveCarePatientViewModel.dart | 63 ++++++++ lib/screens/home/home_screen.dart | 2 + lib/screens/live_care/TestScreen.dart | 136 ++++++++++++++++++ lib/screens/live_care/end_call_screen.dart | 1 + 7 files changed, 302 insertions(+), 41 deletions(-) create mode 100644 lib/core/model/live_care/AlternativeServicesList.dart create mode 100644 lib/screens/live_care/TestScreen.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index c8af8ad9..41e3313d 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -5,8 +5,8 @@ const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/'; -const BASE_URL = 'https://hmgwebservices.com/'; -// const BASE_URL = 'https://uat.hmgwebservices.com/'; +// const BASE_URL = 'https://hmgwebservices.com/'; +const BASE_URL = 'https://uat.hmgwebservices.com/'; const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh"; const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = "Services/DoctorApplication.svc/REST/GetProgressNoteForInPatient"; @@ -89,6 +89,7 @@ const CHECK_ACTIVATION_CODE_FOR_DOCTOR_APP = 'Services/DoctorApplication.svc/RES const GET_DOC_PROFILES = 'Services/Doctors.svc/REST/GetDocProfiles'; const TRANSFERT_TO_ADMIN = 'LiveCareApi/DoctorApp/TransferToAdmin'; +const GET_ALTERNATIVE_SERVICE = 'LiveCareApi/DoctorApp/GetAlternativeServices'; const END_CALL = 'LiveCareApi/DoctorApp/EndCall'; const END_CALL_WITH_CHARGE = 'LiveCareApi/DoctorApp/CompleteCallWithCharge'; const GET_DASHBOARD = 'Services/DoctorApplication.svc/REST/GetDoctorDashboardKPI'; diff --git a/lib/core/model/live_care/AlternativeServicesList.dart b/lib/core/model/live_care/AlternativeServicesList.dart new file mode 100644 index 00000000..fab11b71 --- /dev/null +++ b/lib/core/model/live_care/AlternativeServicesList.dart @@ -0,0 +1,42 @@ +import 'package:flutter/material.dart'; + +class AlternativeService { + int serviceID; + String serviceName; + bool isSelected; + + AlternativeService( + {this.serviceID, this.serviceName, this.isSelected = false}); + + AlternativeService.fromJson(Map json) { + serviceID = json['ServicID']; + serviceName = json['ServiceName']; + } + + Map toJson() { + final Map data = new Map(); + data['ServicID'] = this.serviceID; + data['ServiceName'] = this.serviceName; + return data; + } +} + +class AlternativeServicesList with ChangeNotifier { + List _alternativeServicesList; + + getServicesList(){ + return _alternativeServicesList; + } + + setServicesList(List alternativeServicesList) { + this._alternativeServicesList = alternativeServicesList; + notifyListeners(); + } + + setSelected(AlternativeService service, bool isSelected) { + List alternativeService = _alternativeServicesList.where((element) => service.serviceID == element.serviceID).toList(); + + alternativeService[0].isSelected = isSelected; + notifyListeners(); + } +} diff --git a/lib/core/service/patient/LiveCarePatientServices.dart b/lib/core/service/patient/LiveCarePatientServices.dart index cbb596b6..05b73393 100644 --- a/lib/core/service/patient/LiveCarePatientServices.dart +++ b/lib/core/service/patient/LiveCarePatientServices.dart @@ -1,4 +1,7 @@ +import 'dart:collection'; + import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/model/live_care/AlternativeServicesList.dart'; import 'package:doctor_app_flutter/core/model/live_care/PendingPatientERForDoctorAppRequestModel.dart'; import 'package:doctor_app_flutter/core/service/base/base_service.dart'; import 'package:doctor_app_flutter/models/livecare/end_call_req.dart'; @@ -11,24 +14,28 @@ class LiveCarePatientServices extends BaseService { List get patientList => _patientList; + List alternativeServicesList = []; + bool _isFinished = false; bool _isLive = false; bool get isFinished => _isFinished; - setFinished(bool isFinished){ + setFinished(bool isFinished) { _isFinished = isFinished; } - var endCallResponse = {}; var transferToAdminResponse = {}; StartCallRes _startCallRes; + StartCallRes get startCallRes => _startCallRes; - Future getPendingPatientERForDoctorApp(PendingPatientERForDoctorAppRequestModel pendingPatientERForDoctorAppRequestModel) async{ + Future getPendingPatientERForDoctorApp( + PendingPatientERForDoctorAppRequestModel + pendingPatientERForDoctorAppRequestModel) async { hasError = false; await baseAppClient.post( GET_PENDING_PATIENT_ER_FOR_DOCTOR_APP, @@ -49,58 +56,67 @@ class LiveCarePatientServices extends BaseService { Future endCall(EndCallReq endCallReq) async { hasError = false; await baseAppClient.post(END_CALL, onSuccess: (response, statusCode) async { - endCallResponse = response; }, onFailure: (String error, int statusCode) { - hasError = true; super.error = error; - }, body: endCallReq.toJson(),isLiveCare:_isLive); + }, body: endCallReq.toJson(), isLiveCare: _isLive); } Future startCall(StartCallReq startCallReq) async { hasError = false; await baseAppClient.post(START_LIVE_CARE_CALL, onSuccess: (response, statusCode) async { - _startCallRes = StartCallRes.fromJson(response); + _startCallRes = StartCallRes.fromJson(response); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - }, body: startCallReq.toJson(),isLiveCare:_isLive); + }, body: startCallReq.toJson(), isLiveCare: _isLive); } - Future endCallWithCharge(int vcID) async{ + + Future endCallWithCharge(int vcID) async { hasError = false; - await baseAppClient.post( - END_CALL_WITH_CHARGE, - onSuccess: (dynamic response, int statusCode) { - endCallResponse = response; - }, - onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, - body: { - "VC_ID": vcID,"generalid":"Cs2020@2016\$2958", - },isLiveCare:_isLive - ); + await baseAppClient.post(END_CALL_WITH_CHARGE, + onSuccess: (dynamic response, int statusCode) { + endCallResponse = response; + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: { + "VC_ID": vcID, + "generalid": "Cs2020@2016\$2958", + }, isLiveCare: _isLive); } - Future transferToAdmin(int vcID, String notes) async{ + Future transferToAdmin(int vcID, String notes) async { hasError = false; - await baseAppClient.post( - TRANSFERT_TO_ADMIN, - onSuccess: (dynamic response, int statusCode) { - transferToAdminResponse = response; - }, - onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, - body: { - "VC_ID": vcID, - "IsOutKsa": false, - "Notes": notes, - },isLiveCare:_isLive - ); + await baseAppClient.post(TRANSFERT_TO_ADMIN, + onSuccess: (dynamic response, int statusCode) { + transferToAdminResponse = response; + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: { + "VC_ID": vcID, + "IsOutKsa": false, + "Notes": notes, + }, isLiveCare: _isLive); + } + + Future getAlternativeServices(int vcID) async { + hasError = false; + alternativeServicesList.clear(); + + await baseAppClient.post(GET_ALTERNATIVE_SERVICE, + onSuccess: (dynamic response, int statusCode) { + response['AlternativeServicesList'].forEach((v) { + alternativeServicesList.add(AlternativeService.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: { + "VC_ID": vcID, + }, isLiveCare: _isLive); } -} \ No newline at end of file +} diff --git a/lib/core/viewModel/LiveCarePatientViewModel.dart b/lib/core/viewModel/LiveCarePatientViewModel.dart index 844ebf55..a64552aa 100644 --- a/lib/core/viewModel/LiveCarePatientViewModel.dart +++ b/lib/core/viewModel/LiveCarePatientViewModel.dart @@ -1,5 +1,6 @@ import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/model/live_care/AlternativeServicesList.dart'; import 'package:doctor_app_flutter/core/model/live_care/PendingPatientERForDoctorAppRequestModel.dart'; import 'package:doctor_app_flutter/core/service/home/dasboard_service.dart'; import 'package:doctor_app_flutter/core/service/patient/LiveCarePatientServices.dart'; @@ -19,6 +20,8 @@ class LiveCarePatientViewModel extends BaseViewModel { StartCallRes get startCallRes => _liveCarePatientServices.startCallRes; + List get alternativeServicesList => _liveCarePatientServices.alternativeServicesList; + DashboardService _dashboardService = locator(); getPendingPatientERForDoctorApp({bool isFromTimer = false}) async { @@ -115,6 +118,17 @@ class LiveCarePatientViewModel extends BaseViewModel { } } + Future getAlternativeServices(int vcID) async { + setState(ViewState.BusyLocal); + await _liveCarePatientServices.getAlternativeServices(vcID); + if (_liveCarePatientServices.hasError) { + error = _liveCarePatientServices.error; + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Idle); + } + } + searchData(String str) { var strExist = str.length > 0 ? true : false; if (strExist) { @@ -139,4 +153,53 @@ class LiveCarePatientViewModel extends BaseViewModel { notifyListeners(); } } + + // AlternativeServicesList demoServicesList = AlternativeServicesList(); + + setDemoData(){ + alternativeServicesList.clear(); + alternativeServicesList.add( + AlternativeService(serviceID: 1, serviceName: "Medicine Home Delivery"), + ); + alternativeServicesList.add( + AlternativeService(serviceID: 2, serviceName: "LABORATORY"), + ); + alternativeServicesList.add( + AlternativeService( + serviceID: 3, serviceName: "RADIOLOGY(ULTRASOUND) For pregnant only"), + ); + alternativeServicesList.add( + AlternativeService(serviceID: 4, serviceName: "VACCINATIONS"), + ); + alternativeServicesList.add( + AlternativeService(serviceID: 5, serviceName: "ER SERVICES"), + ); + alternativeServicesList.add( + AlternativeService(serviceID: 6, serviceName: "PHYSIOTHERAPY"), + ); + alternativeServicesList.add( + AlternativeService(serviceID: 7, serviceName: "DRESSING"), + ); + alternativeServicesList.add( + AlternativeService(serviceID: 8, serviceName: "INJECTION"), + ); + alternativeServicesList.add( + AlternativeService(serviceID: 9, serviceName: "FAMILY MEDICIN DR"), + ); + alternativeServicesList.add( + AlternativeService( + serviceID: 10, serviceName: "FOLYS CATHETER INSERTION"), + ); + alternativeServicesList.add( + AlternativeService(serviceID: 11, serviceName: "GASTRIC TUBE CHANGE"), + ); + } + + setSelected(AlternativeService service, bool isSelected) { + int index = alternativeServicesList.indexOf(service); + if(index !=-1) + alternativeServicesList[index].isSelected = isSelected; + notifyListeners(); + } + } diff --git a/lib/screens/home/home_screen.dart b/lib/screens/home/home_screen.dart index c305b752..d079a477 100644 --- a/lib/screens/home/home_screen.dart +++ b/lib/screens/home/home_screen.dart @@ -13,6 +13,7 @@ import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/home/dashboard_slider-item-widget.dart'; import 'package:doctor_app_flutter/screens/home/dashboard_swipe_widget.dart'; import 'package:doctor_app_flutter/screens/home/home_patient_card.dart'; +import 'package:doctor_app_flutter/screens/live_care/TestScreen.dart'; import 'package:doctor_app_flutter/screens/live_care/live_care_patient_screen.dart'; import 'package:doctor_app_flutter/screens/medicine/medicine_search_screen.dart'; import 'package:doctor_app_flutter/screens/patients/PatientsInPatientScreen.dart'; @@ -341,6 +342,7 @@ class _HomeScreenState extends State { context, FadePage( page: LiveCarePatientScreen(), + // page: TestScreen(), ), ); }, diff --git a/lib/screens/live_care/TestScreen.dart b/lib/screens/live_care/TestScreen.dart new file mode 100644 index 00000000..974f2351 --- /dev/null +++ b/lib/screens/live_care/TestScreen.dart @@ -0,0 +1,136 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/model/live_care/AlternativeServicesList.dart'; +import 'package:doctor_app_flutter/core/viewModel/LiveCarePatientViewModel.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class TestScreen extends StatefulWidget { + @override + _TestScreenState createState() => _TestScreenState(); +} + +class _TestScreenState extends State { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.setDemoData(), + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + appBarTitle: TranslationBase.of(context).patientProfile, + backgroundColor: Theme.of(context).scaffoldBackgroundColor, + isShowAppBar: false, + body: Container( + child: Center( + child: AppButton( + fontWeight: FontWeight.w700, + color: Colors.red[600], + title: "open dialog", //TranslationBase.of(context).close, + onPressed: () { + showAlternativesDialog(context, model, () { + model.alternativeServicesList.map((e) => () { + if (e.isSelected) { + print(e.serviceName); + } + }); + Navigator.of(context).pop(); + }); + }, + ), + ), + ), + ), + ); + } + + showAlternativesDialog(BuildContext context, LiveCarePatientViewModel model, Function okFunction) { + return showDialog( + context: context, + barrierDismissible: false, // user must tap button! + builder: (_) { + return Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AlertDialog( + title: null, + content: Container( + height: MediaQuery.of(context).size.height / 2, + child: CheckBoxListWidget(model: model,), + ), + actions: [ + AppButton( + onPressed: (){ + okFunction(); + }, + title: TranslationBase.of(context).noteConfirm, + fontColor: Colors.white, + color: Colors.green[600], + ), + AppButton( + onPressed: () { + Navigator.of(context).pop(); + }, + title: TranslationBase.of(context).cancel, + fontColor: Colors.white, + color: Colors.red[600], + ), + ], + ), + ], + ), + ); + }); + } +} + +class CheckBoxListWidget extends StatefulWidget { + final LiveCarePatientViewModel model; + const CheckBoxListWidget({ + Key key, this.model, + }) : super(key: key); + + @override + _CheckBoxListState createState() => _CheckBoxListState(); +} + +class _CheckBoxListState extends State { + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + child: Column( + children: [ + ...widget.model + .alternativeServicesList + .map( + (element) => Container( + child: CheckboxListTile( + title: AppText( + element.serviceName, + fontWeight: FontWeight.normal, + fontSize: SizeConfig.textMultiplier * 2.2, + ), + value: element.isSelected, + onChanged: (newValue) { + setState(() { + widget.model.setSelected( + element, newValue); + }); + }, + activeColor: Color(0xFFD02127), + controlAffinity: + ListTileControlAffinity.leading, + contentPadding: EdgeInsets.all(0), + ), + ), + ) + .toList() + ], + ), + ); + } +} diff --git a/lib/screens/live_care/end_call_screen.dart b/lib/screens/live_care/end_call_screen.dart index d4e9120e..22f31188 100644 --- a/lib/screens/live_care/end_call_screen.dart +++ b/lib/screens/live_care/end_call_screen.dart @@ -108,6 +108,7 @@ class _EndCallScreenState extends State { if (liveCareModel.state == ViewState.ErrorLocal) { DrAppToastMsg.showErrorToast(liveCareModel.error); } else { + // todo mosa add new service Navigator.of(context).pop(); Navigator.of(context).pop(); } From 0afe3b3afd56a4957e263de5b1fc4ef39546e8f4 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Mon, 7 Jun 2021 10:41:30 +0300 Subject: [PATCH 2/2] livecare changes --- .../patient/LiveCarePatientServices.dart | 4 +- .../viewModel/LiveCarePatientViewModel.dart | 52 +++-- lib/screens/home/home_screen.dart | 7 - lib/screens/live_care/TestScreen.dart | 136 ------------- lib/screens/live_care/end_call_screen.dart | 181 ++++++++++++++---- .../live-care_transfer_to_admin.dart | 3 +- 6 files changed, 182 insertions(+), 201 deletions(-) delete mode 100644 lib/screens/live_care/TestScreen.dart diff --git a/lib/core/service/patient/LiveCarePatientServices.dart b/lib/core/service/patient/LiveCarePatientServices.dart index 05b73393..b8712a9b 100644 --- a/lib/core/service/patient/LiveCarePatientServices.dart +++ b/lib/core/service/patient/LiveCarePatientServices.dart @@ -74,7 +74,7 @@ class LiveCarePatientServices extends BaseService { }, body: startCallReq.toJson(), isLiveCare: _isLive); } - Future endCallWithCharge(int vcID) async { + Future endCallWithCharge(int vcID, String altServiceList) async { hasError = false; await baseAppClient.post(END_CALL_WITH_CHARGE, onSuccess: (dynamic response, int statusCode) { @@ -84,7 +84,7 @@ class LiveCarePatientServices extends BaseService { super.error = error; }, body: { "VC_ID": vcID, - "generalid": "Cs2020@2016\$2958", + "AltServiceList": altServiceList, }, isLiveCare: _isLive); } diff --git a/lib/core/viewModel/LiveCarePatientViewModel.dart b/lib/core/viewModel/LiveCarePatientViewModel.dart index a64552aa..032c7a07 100644 --- a/lib/core/viewModel/LiveCarePatientViewModel.dart +++ b/lib/core/viewModel/LiveCarePatientViewModel.dart @@ -20,7 +20,8 @@ class LiveCarePatientViewModel extends BaseViewModel { StartCallRes get startCallRes => _liveCarePatientServices.startCallRes; - List get alternativeServicesList => _liveCarePatientServices.alternativeServicesList; + List get alternativeServicesList => + _liveCarePatientServices.alternativeServicesList; DashboardService _dashboardService = locator(); @@ -94,9 +95,22 @@ class LiveCarePatientViewModel extends BaseViewModel { } } - Future endCallWithCharge(int vcID) async { + setSelectedCheckboxValues(AlternativeService service, bool isSelected) { + int index = alternativeServicesList.indexOf(service); + if (index != -1) alternativeServicesList[index].isSelected = isSelected; + notifyListeners(); + } + + Future endCallWithCharge(int vcID, bool isConfirmed) async { setState(ViewState.BusyLocal); - await _liveCarePatientServices.endCallWithCharge(vcID); + + String selectedServicesString = ""; + if (isConfirmed) { + selectedServicesString = getSelectedAlternativeServices(); + } + + await _liveCarePatientServices.endCallWithCharge( + vcID, selectedServicesString); if (_liveCarePatientServices.hasError) { error = _liveCarePatientServices.error; setState(ViewState.ErrorLocal); @@ -106,25 +120,35 @@ class LiveCarePatientViewModel extends BaseViewModel { } } - Future transferToAdmin(int vcID, String notes) async { + String getSelectedAlternativeServices() { + List selectedServices = List(); + for (AlternativeService service in alternativeServicesList) { + if (service.isSelected) { + selectedServices.add(service.serviceID); + } + } + return selectedServices.toString(); + } + + Future getAlternativeServices(int vcID) async { setState(ViewState.BusyLocal); - await _liveCarePatientServices.transferToAdmin(vcID, notes); + await _liveCarePatientServices.getAlternativeServices(vcID); if (_liveCarePatientServices.hasError) { error = _liveCarePatientServices.error; setState(ViewState.ErrorLocal); } else { - await getPendingPatientERForDoctorApp(); setState(ViewState.Idle); } } - Future getAlternativeServices(int vcID) async { + Future transferToAdmin(int vcID, String notes) async { setState(ViewState.BusyLocal); - await _liveCarePatientServices.getAlternativeServices(vcID); + await _liveCarePatientServices.transferToAdmin(vcID, notes); if (_liveCarePatientServices.hasError) { error = _liveCarePatientServices.error; setState(ViewState.ErrorLocal); } else { + await getPendingPatientERForDoctorApp(); setState(ViewState.Idle); } } @@ -154,9 +178,7 @@ class LiveCarePatientViewModel extends BaseViewModel { } } - // AlternativeServicesList demoServicesList = AlternativeServicesList(); - - setDemoData(){ + setDemoData() { alternativeServicesList.clear(); alternativeServicesList.add( AlternativeService(serviceID: 1, serviceName: "Medicine Home Delivery"), @@ -194,12 +216,4 @@ class LiveCarePatientViewModel extends BaseViewModel { AlternativeService(serviceID: 11, serviceName: "GASTRIC TUBE CHANGE"), ); } - - setSelected(AlternativeService service, bool isSelected) { - int index = alternativeServicesList.indexOf(service); - if(index !=-1) - alternativeServicesList[index].isSelected = isSelected; - notifyListeners(); - } - } diff --git a/lib/screens/home/home_screen.dart b/lib/screens/home/home_screen.dart index d079a477..85ea3506 100644 --- a/lib/screens/home/home_screen.dart +++ b/lib/screens/home/home_screen.dart @@ -1,19 +1,14 @@ -import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/model/patient_muse/PatientSearchRequestModel.dart'; import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/dashboard_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; -import 'package:doctor_app_flutter/models/dashboard/dashboard_model.dart'; -import 'package:doctor_app_flutter/models/doctor/clinic_model.dart'; import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; -import 'package:doctor_app_flutter/models/patient/patient_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/home/dashboard_slider-item-widget.dart'; import 'package:doctor_app_flutter/screens/home/dashboard_swipe_widget.dart'; import 'package:doctor_app_flutter/screens/home/home_patient_card.dart'; -import 'package:doctor_app_flutter/screens/live_care/TestScreen.dart'; import 'package:doctor_app_flutter/screens/live_care/live_care_patient_screen.dart'; import 'package:doctor_app_flutter/screens/medicine/medicine_search_screen.dart'; import 'package:doctor_app_flutter/screens/patients/PatientsInPatientScreen.dart'; @@ -22,7 +17,6 @@ import 'package:doctor_app_flutter/screens/patients/patient_search/patient_searc import 'package:doctor_app_flutter/screens/patients/profile/referral/patient_referral_screen.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; -import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/profile-welcome-widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; @@ -342,7 +336,6 @@ class _HomeScreenState extends State { context, FadePage( page: LiveCarePatientScreen(), - // page: TestScreen(), ), ); }, diff --git a/lib/screens/live_care/TestScreen.dart b/lib/screens/live_care/TestScreen.dart deleted file mode 100644 index 974f2351..00000000 --- a/lib/screens/live_care/TestScreen.dart +++ /dev/null @@ -1,136 +0,0 @@ -import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/core/model/live_care/AlternativeServicesList.dart'; -import 'package:doctor_app_flutter/core/viewModel/LiveCarePatientViewModel.dart'; -import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -class TestScreen extends StatefulWidget { - @override - _TestScreenState createState() => _TestScreenState(); -} - -class _TestScreenState extends State { - @override - Widget build(BuildContext context) { - return BaseView( - onModelReady: (model) => model.setDemoData(), - builder: (_, model, w) => AppScaffold( - baseViewModel: model, - appBarTitle: TranslationBase.of(context).patientProfile, - backgroundColor: Theme.of(context).scaffoldBackgroundColor, - isShowAppBar: false, - body: Container( - child: Center( - child: AppButton( - fontWeight: FontWeight.w700, - color: Colors.red[600], - title: "open dialog", //TranslationBase.of(context).close, - onPressed: () { - showAlternativesDialog(context, model, () { - model.alternativeServicesList.map((e) => () { - if (e.isSelected) { - print(e.serviceName); - } - }); - Navigator.of(context).pop(); - }); - }, - ), - ), - ), - ), - ); - } - - showAlternativesDialog(BuildContext context, LiveCarePatientViewModel model, Function okFunction) { - return showDialog( - context: context, - barrierDismissible: false, // user must tap button! - builder: (_) { - return Container( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - AlertDialog( - title: null, - content: Container( - height: MediaQuery.of(context).size.height / 2, - child: CheckBoxListWidget(model: model,), - ), - actions: [ - AppButton( - onPressed: (){ - okFunction(); - }, - title: TranslationBase.of(context).noteConfirm, - fontColor: Colors.white, - color: Colors.green[600], - ), - AppButton( - onPressed: () { - Navigator.of(context).pop(); - }, - title: TranslationBase.of(context).cancel, - fontColor: Colors.white, - color: Colors.red[600], - ), - ], - ), - ], - ), - ); - }); - } -} - -class CheckBoxListWidget extends StatefulWidget { - final LiveCarePatientViewModel model; - const CheckBoxListWidget({ - Key key, this.model, - }) : super(key: key); - - @override - _CheckBoxListState createState() => _CheckBoxListState(); -} - -class _CheckBoxListState extends State { - @override - Widget build(BuildContext context) { - return SingleChildScrollView( - child: Column( - children: [ - ...widget.model - .alternativeServicesList - .map( - (element) => Container( - child: CheckboxListTile( - title: AppText( - element.serviceName, - fontWeight: FontWeight.normal, - fontSize: SizeConfig.textMultiplier * 2.2, - ), - value: element.isSelected, - onChanged: (newValue) { - setState(() { - widget.model.setSelected( - element, newValue); - }); - }, - activeColor: Color(0xFFD02127), - controlAffinity: - ListTileControlAffinity.leading, - contentPadding: EdgeInsets.all(0), - ), - ), - ) - .toList() - ], - ), - ); - } -} diff --git a/lib/screens/live_care/end_call_screen.dart b/lib/screens/live_care/end_call_screen.dart index 22f31188..ee1a036d 100644 --- a/lib/screens/live_care/end_call_screen.dart +++ b/lib/screens/live_care/end_call_screen.dart @@ -1,4 +1,5 @@ import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/viewModel/LiveCarePatientViewModel.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; @@ -51,41 +52,48 @@ class _EndCallScreenState extends State { GifLoaderDialogUtils.showMyDialog(context); await liveCareModel .startCall(isReCall: false, vCID: widget.patient.vcId) - .then((value) async{ + .then((value) async { await liveCareModel.getDoctorProfile(); GifLoaderDialogUtils.hideDialog(context); if (liveCareModel.state == ViewState.ErrorLocal) { DrAppToastMsg.showErrorToast(liveCareModel.error); - }else - await VideoChannel.openVideoCallScreen( - kToken: liveCareModel.startCallRes.openTokenID, - kSessionId: liveCareModel.startCallRes.openSessionID, - kApiKey: '46209962', - vcId: widget.patient.vcId, - tokenID: await liveCareModel.getToken(), - generalId: GENERAL_ID, - doctorId: liveCareModel.doctorProfile.doctorID, - onFailure: (String error) { - DrAppToastMsg.showErrorToast(error); - }, - onCallEnd: () async{ - GifLoaderDialogUtils.showMyDialog(context); - GifLoaderDialogUtils.showMyDialog(context); - await liveCareModel.endCall(widget.patient.vcId, false,); - GifLoaderDialogUtils.hideDialog(context); - if (liveCareModel.state == ViewState.ErrorLocal) { - DrAppToastMsg.showErrorToast(liveCareModel.error); - } - }, - onCallNotRespond: (SessionStatusModel sessionStatusModel) async{ - GifLoaderDialogUtils.showMyDialog(context); - GifLoaderDialogUtils.showMyDialog(context); - await liveCareModel.endCall(widget.patient.vcId, sessionStatusModel.sessionStatus == 3,); - GifLoaderDialogUtils.hideDialog(context); - if (liveCareModel.state == ViewState.ErrorLocal) { - DrAppToastMsg.showErrorToast(liveCareModel.error); - } - }); + } else + await VideoChannel.openVideoCallScreen( + kToken: liveCareModel.startCallRes.openTokenID, + kSessionId: liveCareModel.startCallRes.openSessionID, + kApiKey: '46209962', + vcId: widget.patient.vcId, + tokenID: await liveCareModel.getToken(), + generalId: GENERAL_ID, + doctorId: liveCareModel.doctorProfile.doctorID, + onFailure: (String error) { + DrAppToastMsg.showErrorToast(error); + }, + onCallEnd: () async { + GifLoaderDialogUtils.showMyDialog(context); + GifLoaderDialogUtils.showMyDialog(context); + await liveCareModel.endCall( + widget.patient.vcId, + false, + ); + GifLoaderDialogUtils.hideDialog(context); + if (liveCareModel.state == ViewState.ErrorLocal) { + DrAppToastMsg.showErrorToast(liveCareModel.error); + } + }, + onCallNotRespond: + (SessionStatusModel sessionStatusModel) async { + GifLoaderDialogUtils.showMyDialog(context); + GifLoaderDialogUtils.showMyDialog(context); + await liveCareModel.endCall( + widget.patient.vcId, + sessionStatusModel.sessionStatus == 3, + ); + GifLoaderDialogUtils.hideDialog(context); + if (liveCareModel.state == ViewState.ErrorLocal) { + DrAppToastMsg.showErrorToast(liveCareModel.error); + } + }); }); GifLoaderDialogUtils.hideDialog(context); if (liveCareModel.state == ViewState.ErrorLocal) { @@ -103,14 +111,23 @@ class _EndCallScreenState extends State { () async { Navigator.of(context).pop(); GifLoaderDialogUtils.showMyDialog(context); - await liveCareModel.endCallWithCharge(widget.patient.vcId); + await liveCareModel.getAlternativeServices(widget.patient.vcId); GifLoaderDialogUtils.hideDialog(context); if (liveCareModel.state == ViewState.ErrorLocal) { DrAppToastMsg.showErrorToast(liveCareModel.error); } else { - // todo mosa add new service - Navigator.of(context).pop(); - Navigator.of(context).pop(); + showAlternativesDialog(context, liveCareModel, (bool isConfirmed) async { + GifLoaderDialogUtils.showMyDialog(context); + await liveCareModel.endCallWithCharge(widget.patient.vcId, isConfirmed); + GifLoaderDialogUtils.hideDialog(context); + if (liveCareModel.state == ViewState.ErrorLocal) { + DrAppToastMsg.showErrorToast(liveCareModel.error); + } else { + DrAppToastMsg.showSuccesToast("You successfully completed call with charge"); + Navigator.of(context).pop(); + Navigator.of(context).pop(); + } + }); } }); }, isDartIcon: true, dartIcon: DoctorApp.end_consultaion), @@ -247,7 +264,7 @@ class _EndCallScreenState extends State { fontWeight: FontWeight.w700, color: Colors.red[600], title: "Close", //TranslationBase.of(context).close, - onPressed: () { + onPressed: () { Navigator.of(context).pop(); }, ), @@ -263,4 +280,96 @@ class _EndCallScreenState extends State { ), ); } + + showAlternativesDialog(BuildContext context, LiveCarePatientViewModel model, + Function(bool) okFunction) { + return showDialog( + context: context, + barrierDismissible: false, // user must tap button! + builder: (_) { + return Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AlertDialog( + title: null, + content: Container( + height: MediaQuery.of(context).size.height / 2, + child: CheckBoxListWidget( + model: model, + ), + ), + actions: [ + AppButton( + onPressed: (){ + Navigator.of(context).pop(); + okFunction(true); + }, + title: TranslationBase.of(context).noteConfirm, + fontColor: Colors.white, + color: Colors.green[600], + ), + AppButton( + onPressed: () { + Navigator.of(context).pop(); + okFunction(false); + }, + title: TranslationBase.of(context).cancel, + fontColor: Colors.white, + color: Colors.red[600], + ), + ], + ), + ], + ), + ); + }); + } +} + +class CheckBoxListWidget extends StatefulWidget { + final LiveCarePatientViewModel model; + + const CheckBoxListWidget({ + Key key, + this.model, + }) : super(key: key); + + @override + _CheckBoxListState createState() => _CheckBoxListState(); +} + +class _CheckBoxListState extends State { + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + child: Column( + children: [ + ...widget.model.alternativeServicesList + .map( + (element) => Container( + child: CheckboxListTile( + title: AppText( + element.serviceName, + fontWeight: FontWeight.normal, + fontSize: SizeConfig.textMultiplier * 2.2, + ), + value: element.isSelected, + onChanged: (newValue) { + setState(() { + widget.model + .setSelectedCheckboxValues(element, newValue); + }); + }, + activeColor: Color(0xFFD02127), + controlAffinity: ListTileControlAffinity.leading, + contentPadding: EdgeInsets.all(0), + ), + ), + ) + .toList() + ], + ), + ); + } } diff --git a/lib/screens/live_care/live-care_transfer_to_admin.dart b/lib/screens/live_care/live-care_transfer_to_admin.dart index c5bcf304..2d0fb7d7 100644 --- a/lib/screens/live_care/live-care_transfer_to_admin.dart +++ b/lib/screens/live_care/live-care_transfer_to_admin.dart @@ -120,11 +120,12 @@ class _LivaCareTransferToAdminState extends State { () async { Navigator.of(context).pop(); GifLoaderDialogUtils.showMyDialog(context); - model.endCallWithCharge(widget.patient.vcId); + model.transferToAdmin(widget.patient.vcId, noteController.text); GifLoaderDialogUtils.hideDialog(context); if (model.state == ViewState.ErrorLocal) { DrAppToastMsg.showErrorToast(model.error); } else { + DrAppToastMsg.showSuccesToast("You successfully transfer to admin"); Navigator.of(context).pop(); Navigator.of(context).pop(); Navigator.of(context).pop();