diff --git a/lib/config/config.dart b/lib/config/config.dart index 85815f7f..588976ba 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -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 d05f6dd9..ed09bbb9 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/model/live_care/live_care_login_reguest_model.dart'; import 'package:doctor_app_flutter/core/service/base/base_service.dart'; @@ -12,6 +15,8 @@ class LiveCarePatientServices extends BaseService { List get patientList => _patientList; + List alternativeServicesList = []; + bool _isFinished = false; bool _isLive = false; @@ -27,10 +32,12 @@ class LiveCarePatientServices extends BaseService { var isLoginResponse = {}; StartCallRes _startCallRes; + StartCallRes get startCallRes => _startCallRes; Future getPendingPatientERForDoctorApp( - PendingPatientERForDoctorAppRequestModel pendingPatientERForDoctorAppRequestModel) async { + PendingPatientERForDoctorAppRequestModel + pendingPatientERForDoctorAppRequestModel) async { hasError = false; await baseAppClient.post( GET_PENDING_PATIENT_ER_FOR_DOCTOR_APP, @@ -68,7 +75,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) { endCallResponse = response; @@ -77,7 +84,7 @@ class LiveCarePatientServices extends BaseService { super.error = error; }, body: { "VC_ID": vcID, - "generalid": "Cs2020@2016\$2958", + "AltServiceList": altServiceList, }, isLiveCare: _isLive); } @@ -104,4 +111,21 @@ class LiveCarePatientServices extends BaseService { super.error = error; }, body: isLoginRequestModel.toJson(), 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); + } } diff --git a/lib/core/viewModel/LiveCarePatientViewModel.dart b/lib/core/viewModel/LiveCarePatientViewModel.dart index b1b18672..a3d82907 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/model/live_care/live_care_login_reguest_model.dart'; import 'package:doctor_app_flutter/core/service/home/dasboard_service.dart'; @@ -19,6 +20,9 @@ class LiveCarePatientViewModel extends BaseViewModel { StartCallRes get startCallRes => _liveCarePatientServices.startCallRes; + List get alternativeServicesList => + _liveCarePatientServices.alternativeServicesList; + DashboardService _dashboardService = locator(); getPendingPatientERForDoctorApp({bool isFromTimer = false}) async { @@ -88,9 +92,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); @@ -100,6 +117,27 @@ class LiveCarePatientViewModel extends BaseViewModel { } } + 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.getAlternativeServices(vcID); + if (_liveCarePatientServices.hasError) { + error = _liveCarePatientServices.error; + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Idle); + } + } + Future transferToAdmin(int vcID, String notes) async { setState(ViewState.BusyLocal); await _liveCarePatientServices.transferToAdmin(vcID, notes); @@ -149,4 +187,43 @@ class LiveCarePatientViewModel extends BaseViewModel { setState(ViewState.Idle); } } + + 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"), + ); + } } diff --git a/lib/screens/home/home_screen.dart b/lib/screens/home/home_screen.dart index c305b752..85ea3506 100644 --- a/lib/screens/home/home_screen.dart +++ b/lib/screens/home/home_screen.dart @@ -1,14 +1,10 @@ -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'; @@ -21,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'; diff --git a/lib/screens/live_care/end_call_screen.dart b/lib/screens/live_care/end_call_screen.dart index d4e9120e..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,13 +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 { - 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), @@ -246,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(); }, ), @@ -262,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();