From ac701c98064a6612ee286de875872454365f5fd0 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Sun, 23 May 2021 17:22:37 +0300 Subject: [PATCH] fix live care issues --- ios/Podfile.lock | 2 +- lib/config/localized_values.dart | 6 +- .../patient/LiveCarePatientServices.dart | 10 ++- .../viewModel/LiveCarePatientViewModel.dart | 18 +++-- lib/screens/live_care/end_call_screen.dart | 75 ++++++++++++++++--- .../patient_profile_screen.dart | 65 ++++++++++++---- lib/util/translations_delegate_base.dart | 4 +- 7 files changed, 138 insertions(+), 42 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 1cf7499c..59cdf14c 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -328,4 +328,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 649616dc336b3659ac6b2b25159d8e488e042b69 -COCOAPODS: 1.10.0.rc.1 +COCOAPODS: 1.10.1 diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 6c0e0d83..64a353fd 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -982,7 +982,7 @@ const Map> localizedValues = { "medicalReportAdd": {"en": "Add Medical Report", "ar": "إضافة تقرير طبي"}, "medicalReportVerify": {"en": "Verify Medical Report", "ar": "تحقق من التقرير الطبي"}, "comments": {"en": "Comments", "ar": "تعليقات"}, - "initiateCall ": {"en": "Initiate Call ", "ar": "بدء الاتصال"}, + "initiateCall": {"en": "Initiate Call ", "ar": "بدء الاتصال"}, "transferTo": {"en": "Transfer To ", "ar": "حول إلى"}, "admin": {"en": "Admin", "ar": "مشرف"}, "instructions": {"en": "Instructions", "ar": "تعليمات"}, @@ -996,6 +996,6 @@ const Map> localizedValues = { "laboratoryPhysicalData": {"en": "Laboratory and Physical Data", "ar": "المعامل والبيانات الفيزيائية"}, "impressionRecommendation": {"en": "Impression and Recommendation", "ar": "الانطباع والتوصية"}, "onHold": {"en": "'On Hold'", "ar": "قيد الانتظار"}, - "verified": {"en": "'Verified'", "ar": "Verified"}, - "endCall": {"en": "'End'", "ar": "انهاء"}, + "verified": {"en": "Verified", "ar": "Verified"}, + "endCall": {"en": "End Call", "ar": "انهاء"}, }; diff --git a/lib/core/service/patient/LiveCarePatientServices.dart b/lib/core/service/patient/LiveCarePatientServices.dart index cb8cf61d..27dd666f 100644 --- a/lib/core/service/patient/LiveCarePatientServices.dart +++ b/lib/core/service/patient/LiveCarePatientServices.dart @@ -15,6 +15,10 @@ class LiveCarePatientServices extends BaseService { bool get isFinished => _isFinished; + setFinished(bool isFinished){ + _isFinished = isFinished; + } + var endCallResponse = {}; var transferToAdminResponse = {}; @@ -43,10 +47,10 @@ class LiveCarePatientServices extends BaseService { Future endCall(EndCallReq endCallReq) async { hasError = false; await baseAppClient.post(END_CALL, onSuccess: (response, statusCode) async { - _isFinished = true; + endCallResponse = response; }, onFailure: (String error, int statusCode) { - _isFinished = true; + hasError = true; super.error = error; }, body: endCallReq.toJson()); @@ -74,7 +78,7 @@ class LiveCarePatientServices extends BaseService { super.error = error; }, body: { - "VC_ID": vcID, + "VC_ID": vcID,"generalid":"Cs2020@2016\$2958", }, ); } diff --git a/lib/core/viewModel/LiveCarePatientViewModel.dart b/lib/core/viewModel/LiveCarePatientViewModel.dart index a7e0024f..59706429 100644 --- a/lib/core/viewModel/LiveCarePatientViewModel.dart +++ b/lib/core/viewModel/LiveCarePatientViewModel.dart @@ -1,3 +1,4 @@ +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/PendingPatientERForDoctorAppRequestModel.dart'; import 'package:doctor_app_flutter/core/service/home/dasboard_service.dart'; @@ -16,7 +17,7 @@ class LiveCarePatientViewModel extends BaseViewModel { LiveCarePatientServices _liveCarePatientServices = locator(); - bool get isFinished => _liveCarePatientServices.isFinished; + StartCallRes get startCallRes => _liveCarePatientServices.startCallRes; DashboardService _dashboardService = @@ -39,12 +40,12 @@ class LiveCarePatientViewModel extends BaseViewModel { } } - Future endCall(request, isPatient, doctorID) async { - + Future endCall(int vCID, bool isPatient) async { + await getDoctorProfile(isGetProfile: true); EndCallReq endCallReq = new EndCallReq(); - endCallReq.doctorId = doctorID; //profile["DoctorID"]; + endCallReq.doctorId = doctorProfile.doctorID; endCallReq.generalid = 'Cs2020@2016\$2958'; - endCallReq.vCID = request.vCID; //["VC_ID"]; + endCallReq.vCID = vCID; endCallReq.isDestroy = isPatient; setState(ViewState.BusyLocal); @@ -58,6 +59,10 @@ class LiveCarePatientViewModel extends BaseViewModel { } } + getToken()async{ + String token = await sharedPref.getString(TOKEN); + return token; + } Future startCall({int vCID, bool isReCall}) async { StartCallReq startCallReq = new StartCallReq(); @@ -74,8 +79,7 @@ class LiveCarePatientViewModel extends BaseViewModel { startCallReq.generalid = 'Cs2020@2016\$2958'; setState(ViewState.BusyLocal); - await _liveCarePatientServices - .startCall(startCallReq); + await _liveCarePatientServices.startCall(startCallReq); if (_liveCarePatientServices.hasError) { error = _liveCarePatientServices.error; setState(ViewState.ErrorLocal); diff --git a/lib/screens/live_care/end_call_screen.dart b/lib/screens/live_care/end_call_screen.dart index e33d476c..d4e9120e 100644 --- a/lib/screens/live_care/end_call_screen.dart +++ b/lib/screens/live_care/end_call_screen.dart @@ -1,10 +1,13 @@ +import 'package:doctor_app_flutter/config/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'; +import 'package:doctor_app_flutter/models/livecare/session_status_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/live_care/live-care_transfer_to_admin.dart'; import 'package:doctor_app_flutter/screens/patients/profile/profile_screen/PatientProfileCardModel.dart'; +import 'package:doctor_app_flutter/util/VideoChannel.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'; @@ -44,10 +47,51 @@ class _EndCallScreenState extends State { final List cardsList = [ PatientProfileCardModel(TranslationBase.of(context).resume, TranslationBase.of(context).theCall, '', 'patient/vital_signs.png', - isInPatient: isInpatient, - onTap: () {}, - isDartIcon: true, - dartIcon: DoctorApp.call), + isInPatient: isInpatient, onTap: () async { + GifLoaderDialogUtils.showMyDialog(context); + await liveCareModel + .startCall(isReCall: false, vCID: widget.patient.vcId) + .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); + } + }); + }); + GifLoaderDialogUtils.hideDialog(context); + if (liveCareModel.state == ViewState.ErrorLocal) { + DrAppToastMsg.showErrorToast(liveCareModel.error); + } + }, isDartIcon: true, dartIcon: DoctorApp.call), PatientProfileCardModel( TranslationBase.of(context).endLC, TranslationBase.of(context).consultation, @@ -59,7 +103,7 @@ class _EndCallScreenState extends State { () async { Navigator.of(context).pop(); GifLoaderDialogUtils.showMyDialog(context); - liveCareModel.endCallWithCharge(widget.patient.vcId); + await liveCareModel.endCallWithCharge(widget.patient.vcId); GifLoaderDialogUtils.hideDialog(context); if (liveCareModel.state == ViewState.ErrorLocal) { DrAppToastMsg.showErrorToast(liveCareModel.error); @@ -77,14 +121,19 @@ class _EndCallScreenState extends State { onTap: () {}, isInPatient: isInpatient, isDartIcon: true, + isDisable: true, dartIcon: DoctorApp.send_instruction), - PatientProfileCardModel(TranslationBase.of(context).transferTo, - TranslationBase.of(context).admin, '', 'patient/health_summary.png', - onTap: () { - Navigator.push(context, MaterialPageRoute( + PatientProfileCardModel( + TranslationBase.of(context).transferTo, + TranslationBase.of(context).admin, + '', + 'patient/health_summary.png', onTap: () { + Navigator.push( + context, + MaterialPageRoute( builder: (BuildContext context) => - LivaCareTransferToAdmin(patient:widget.patient))); - }, + LivaCareTransferToAdmin(patient: widget.patient))); + }, isInPatient: isInpatient, isDartIcon: true, dartIcon: DoctorApp.transfer_to_admin), @@ -197,7 +246,9 @@ class _EndCallScreenState extends State { fontWeight: FontWeight.w700, color: Colors.red[600], title: "Close", //TranslationBase.of(context).close, - onPressed: () async {}, + onPressed: () { + Navigator.of(context).pop(); + }, ), ), ), diff --git a/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart b/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart index f90e9f33..ae5406d5 100644 --- a/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart +++ b/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart @@ -1,15 +1,17 @@ +import 'package:doctor_app_flutter/config/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/core/viewModel/SOAP_view_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/models/SOAP/PostEpisodeReqModel.dart'; +import 'package:doctor_app_flutter/models/livecare/session_status_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/live_care/end_call_screen.dart'; -import 'package:doctor_app_flutter/screens/live_care/video_call.dart'; import 'package:doctor_app_flutter/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart'; import 'package:doctor_app_flutter/screens/patients/profile/profile_screen/profile_gird_for_other.dart'; import 'package:doctor_app_flutter/screens/patients/profile/profile_screen/profile_gird_for_search.dart'; +import 'package:doctor_app_flutter/util/VideoChannel.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/patient-profile-header-new-design-app-bar.dart'; @@ -34,7 +36,7 @@ class _PatientProfileScreenState extends State bool isFromLiveCare = false; bool isInpatient = false; - + bool isCallFinished = false; bool isDischargedPatient = false; bool isSearchAndOut = false; String patientType; @@ -275,15 +277,13 @@ class _PatientProfileScreenState extends State child: Center( child: AppButton( fontWeight: FontWeight.w700, - color: model.isFinished?Colors.red[600]:Colors.green[600], - title: model.isFinished?TranslationBase - .of(context) - .endCall:TranslationBase - .of(context) - .initiateCall, + color: isCallFinished?Colors.red[600]:Colors.green[600], + title: isCallFinished? + TranslationBase.of(context).endCall: + TranslationBase.of(context).initiateCall, disabled: model.state == ViewState.BusyLocal, onPressed: () async { - if(model.isFinished) { + if(isCallFinished) { Navigator.push(context, MaterialPageRoute( builder: (BuildContext context) => EndCallScreen(patient:patient))); @@ -291,14 +291,51 @@ class _PatientProfileScreenState extends State GifLoaderDialogUtils.showMyDialog(context); await model.startCall( isReCall : false, vCID: patient.vcId); if(model.state == ViewState.ErrorLocal) { - // GifLoaderDialogUtils.hideDialog(context); Helpers.showErrorToast(model.error); } else { + await model.getDoctorProfile(); GifLoaderDialogUtils.hideDialog(context); - Navigator.push(context, MaterialPageRoute( - builder: (BuildContext context) => - VideoCallPage(patientData: patient,listContext: "dfd",model: model,))); + await VideoChannel.openVideoCallScreen( + kToken: model.startCallRes.openTokenID, + kSessionId: model.startCallRes.openSessionID, + kApiKey: '46209962', + vcId: patient.vcId, + tokenID: await model.getToken(), + generalId: GENERAL_ID, + doctorId: model.doctorProfile.doctorID, + onFailure: (String error) { + DrAppToastMsg.showErrorToast(error); + }, + onCallEnd: () { + WidgetsBinding.instance.addPostFrameCallback((_) { + GifLoaderDialogUtils.showMyDialog(context); + model.endCall(patient.vcId, false,).then((value) { + GifLoaderDialogUtils.hideDialog(context); + if (model.state == ViewState.ErrorLocal) { + DrAppToastMsg.showErrorToast(model.error); + } + setState(() { + isCallFinished = true; + }); + }); + }); + }, + onCallNotRespond: (SessionStatusModel sessionStatusModel) { + WidgetsBinding.instance.addPostFrameCallback((_) { + GifLoaderDialogUtils.showMyDialog(context); + model.endCall(patient.vcId, sessionStatusModel.sessionStatus == 3,).then((value) { + GifLoaderDialogUtils.hideDialog(context); + if (model.state == ViewState.ErrorLocal) { + DrAppToastMsg.showErrorToast(model.error); + } + setState(() { + isCallFinished = true; + }); + }); + + }); + }); } } diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index a4ecc977..9ed00146 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -1338,8 +1338,8 @@ class TranslationBase { String get medicalReportAdd => localizedValues['medicalReportAdd'][locale.languageCode]; String get medicalReportVerify => localizedValues['medicalReportVerify'][locale.languageCode]; String get comments => localizedValues['comments'][locale.languageCode]; - String get initiateCall => localizedValues['initiateCall '][locale.languageCode]; - String get endCall => localizedValues['endCall '][locale.languageCode]; + String get initiateCall => localizedValues['initiateCall'][locale.languageCode]; + String get endCall => localizedValues['endCall'][locale.languageCode]; String get transferTo => localizedValues['transferTo'][locale.languageCode]; String get admin => localizedValues['admin'][locale.languageCode];