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/client/base_app_client.dart b/lib/client/base_app_client.dart index 7a8baa56..824b8189 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -21,8 +21,12 @@ class BaseAppClient { {Map body, Function(dynamic response, int statusCode) onSuccess, Function(String error, int statusCode) onFailure, - bool isAllowAny = false}) async { - String url = BASE_URL + endPoint; + bool isAllowAny = false,bool isLiveCare = false}) async { + String url; + if(isLiveCare) + url = BASE_URL_LIVE_CARE + endPoint; + else + url = BASE_URL + endPoint; bool callLog = true; try { diff --git a/lib/config/config.dart b/lib/config/config.dart index f1d642eb..86c42f8d 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -4,8 +4,9 @@ const MAX_SMALL_SCREEN = 660; const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; -// const BASE_URL = 'https://hmgwebservices.com/'; -const BASE_URL = 'https://uat.hmgwebservices.com/'; +const BASE_URL_LIVE_CARE = 'https://livecare.hmg.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 = @@ -47,7 +48,7 @@ const GET_RADIOLOGY = 'Services/DoctorApplication.svc/REST/GetPatientRadResult'; const GET_LIVECARE_PENDINGLIST = 'Services/DoctorApplication.svc/REST/GetPendingPatientER'; -const START_LIVECARE_CALL = 'LiveCareApi/DoctorApp/CallPatient'; +const START_LIVE_CARE_CALL = 'LiveCareApi/DoctorApp/CallPatient'; const LIVE_CARE_STATISTICS_FOR_CERTAIN_DOCTOR_URL = "Lists.svc/REST/DashBoard_GetLiveCareDoctorsStatsticsForCertainDoctor"; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 20bcd1d7..c5460859 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -774,7 +774,7 @@ const Map> localizedValues = { 'appointmentDate': {'en': "Appointment Date", 'ar': "تاريخ الموعد"}, 'arrived_p': {'en': "Arrived", 'ar': "وصل"}, 'details': {'en': 'Details', 'ar': 'التفاصيل'}, - "liveCare": {"en": "Live Care", "ar": "لايف كير"}, + "liveCare": {"en": "LiveCare", "ar": "لايف كير"}, "out-patient": {"en": "OutPatient", "ar": "عيادات خارجية"}, "BillNo": {"en": "Bill No :", "ar": "رقم الفاتورة"}, "labResults": {"en": "Lab Result", "ar": "نتيجة المختبر"}, @@ -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": "تعليمات"}, @@ -997,5 +997,5 @@ const Map> localizedValues = { "impressionRecommendation": {"en": "Impression and Recommendation", "ar": "الانطباع والتوصية"}, "onHold": {"en": "On Hold", "ar": "قيد الانتظار"}, "verified": {"en": "Verified", "ar": "تم التحقق"}, - "endCall": {"en": "'End'", "ar": "انهاء"}, + "endCall": {"en": "End Call", "ar": "انهاء"}, }; diff --git a/lib/core/service/home/dasboard_service.dart b/lib/core/service/home/dasboard_service.dart index a1072676..ba836287 100644 --- a/lib/core/service/home/dasboard_service.dart +++ b/lib/core/service/home/dasboard_service.dart @@ -32,6 +32,7 @@ class DashboardService extends BaseService { Future checkDoctorHasLiveCare() async { hasError = false; + await getDoctorProfile(isGetProfile: true); await baseAppClient.post( DOCTOR_CHECK_HAS_LIVE_CARE, onSuccess: (dynamic response, int statusCode) { @@ -43,7 +44,7 @@ class DashboardService extends BaseService { super.error = error; }, body: { - "DoctorID": 9920 + "DoctorID": doctorProfile.doctorID// test user 9920 }, ); } diff --git a/lib/core/service/patient/LiveCarePatientServices.dart b/lib/core/service/patient/LiveCarePatientServices.dart index 0a8c4894..4fc25094 100644 --- a/lib/core/service/patient/LiveCarePatientServices.dart +++ b/lib/core/service/patient/LiveCarePatientServices.dart @@ -2,18 +2,30 @@ import 'package:doctor_app_flutter/config/config.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'; +import 'package:doctor_app_flutter/models/livecare/start_call_req.dart'; +import 'package:doctor_app_flutter/models/livecare/start_call_res.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; -class LiveCarePatientServices extends BaseService{ +class LiveCarePatientServices extends BaseService { List _patientList = []; + List get patientList => _patientList; bool _isFinished = false; - bool get isFinished => _isFinished; + + bool get isFinished => _isFinished; + + setFinished(bool isFinished){ + _isFinished = isFinished; + } + var endCallResponse = {}; var transferToAdminResponse = {}; + StartCallRes _startCallRes; + StartCallRes get startCallRes => _startCallRes; + Future getPendingPatientERForDoctorApp(PendingPatientERForDoctorAppRequestModel pendingPatientERForDoctorAppRequestModel) async{ hasError = false; await baseAppClient.post( @@ -33,16 +45,27 @@ 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; - throw error; - }, body: endCallReq.toJson()); + + hasError = true; + super.error = error; + }, body: endCallReq.toJson(),isLiveCare: true); } + Future startCall(StartCallReq startCallReq) async { + hasError = false; + await baseAppClient.post(START_LIVE_CARE_CALL, + onSuccess: (response, statusCode) async { + _startCallRes = StartCallRes.fromJson(response); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: startCallReq.toJson(),isLiveCare: true); + } Future endCallWithCharge(int vcID) async{ hasError = false; await baseAppClient.post( @@ -55,8 +78,8 @@ class LiveCarePatientServices extends BaseService{ super.error = error; }, body: { - "VC_ID": vcID, - }, + "VC_ID": vcID,"generalid":"Cs2020@2016\$2958", + },isLiveCare: true ); } @@ -75,7 +98,7 @@ class LiveCarePatientServices extends BaseService{ "VC_ID": vcID, "IsOutKsa": false, "Notes": notes, - }, + },isLiveCare: true ); } } \ No newline at end of file diff --git a/lib/core/viewModel/LiveCarePatientViewModel.dart b/lib/core/viewModel/LiveCarePatientViewModel.dart index e8b07cba..59706429 100644 --- a/lib/core/viewModel/LiveCarePatientViewModel.dart +++ b/lib/core/viewModel/LiveCarePatientViewModel.dart @@ -1,9 +1,12 @@ +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'; import 'package:doctor_app_flutter/core/service/patient/LiveCarePatientServices.dart'; import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; import 'package:doctor_app_flutter/models/livecare/end_call_req.dart'; +import 'package:doctor_app_flutter/models/livecare/start_call_req.dart'; +import 'package:doctor_app_flutter/models/livecare/start_call_res.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import '../../locator.dart'; @@ -14,7 +17,8 @@ class LiveCarePatientViewModel extends BaseViewModel { LiveCarePatientServices _liveCarePatientServices = locator(); - bool get isFinished => _liveCarePatientServices.isFinished; + + StartCallRes get startCallRes => _liveCarePatientServices.startCallRes; DashboardService _dashboardService = locator(); @@ -36,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); @@ -49,14 +53,41 @@ class LiveCarePatientViewModel extends BaseViewModel { .endCall(endCallReq); if (_liveCarePatientServices.hasError) { error = _liveCarePatientServices.error; - setState(ViewState.ErrorLocal); } else { - filterData = _liveCarePatientServices.patientList; setState(ViewState.Idle); } } + getToken()async{ + String token = await sharedPref.getString(TOKEN); + return token; + } + + Future startCall({int vCID, bool isReCall}) async { + StartCallReq startCallReq = new StartCallReq(); + await getDoctorProfile(); + startCallReq.clinicId = super.doctorProfile.clinicID; + startCallReq.vCID = vCID; //["VC_ID"]; + startCallReq.isrecall = isReCall; + startCallReq.doctorId = doctorProfile.doctorID; + startCallReq.isOutKsa = false; //["IsOutKSA"]; + startCallReq.projectName = doctorProfile.projectName; + startCallReq.docotrName = doctorProfile.doctorName; + startCallReq.clincName = doctorProfile.clinicDescription; + startCallReq.docSpec = doctorProfile.doctorTitleForProfile; + startCallReq.generalid = 'Cs2020@2016\$2958'; + + setState(ViewState.BusyLocal); + await _liveCarePatientServices.startCall(startCallReq); + if (_liveCarePatientServices.hasError) { + error = _liveCarePatientServices.error; + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Idle); + } + + } Future endCallWithCharge(int vcID) async { setState(ViewState.BusyLocal); await _liveCarePatientServices diff --git a/lib/core/viewModel/livecare_view_model.dart b/lib/core/viewModel/livecare_view_model.dart index f6ef42e7..de586e1e 100644 --- a/lib/core/viewModel/livecare_view_model.dart +++ b/lib/core/viewModel/livecare_view_model.dart @@ -66,7 +66,7 @@ class LiveCareViewModel with ChangeNotifier { newRequest.docSpec = profile["DoctorTitleForProfile"]; newRequest.generalid = 'Cs2020@2016\$2958'; isFinished = false; - await baseAppClient.post(START_LIVECARE_CALL, + await baseAppClient.post(START_LIVE_CARE_CALL, onSuccess: (response, statusCode) async { isFinished = true; inCallResponse = StartCallRes.fromJson(response); diff --git a/lib/core/viewModel/procedure_View_model.dart b/lib/core/viewModel/procedure_View_model.dart index 3bdd676f..4411f7b5 100644 --- a/lib/core/viewModel/procedure_View_model.dart +++ b/lib/core/viewModel/procedure_View_model.dart @@ -60,6 +60,8 @@ class ProcedureViewModel extends BaseViewModel { Future getProcedure({int mrn, String patientType}) async { hasError = false; + await getDoctorProfile(); + doctorProfile.doctorID; //_insuranceCardService.clearInsuranceCard(); setState(ViewState.Busy); await _procedureService.getProcedure(mrn: mrn); @@ -289,7 +291,6 @@ class ProcedureViewModel extends BaseViewModel { } } - getPatientLabOrdersResults( {PatientLabOrders patientLabOrder, String procedure, diff --git a/lib/models/patient/patiant_info_model.dart b/lib/models/patient/patiant_info_model.dart index fc77af66..1fcce8eb 100644 --- a/lib/models/patient/patiant_info_model.dart +++ b/lib/models/patient/patiant_info_model.dart @@ -5,8 +5,8 @@ class PatiantInformtion { int genderInt; dynamic age; String appointmentDate; - int appointmentNo; - String appointmentType; + dynamic appointmentNo; + dynamic appointmentType; int appointmentTypeId; String arrivedOn; int clinicGroupId; @@ -23,7 +23,7 @@ class PatiantInformtion { String nationality; int projectId; int clinicId; - int patientId; + dynamic patientId; String doctorName; String doctorNameN; String firstName; 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/live_care/panding_list.dart b/lib/screens/live_care/panding_list.dart index 8c9851db..f081479c 100644 --- a/lib/screens/live_care/panding_list.dart +++ b/lib/screens/live_care/panding_list.dart @@ -204,13 +204,13 @@ class _LiveCarePandingListState extends State { // .pushNamed( // VIDEO_CALL, // item) - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - VideoCallPage( - item, - context))) + // Navigator.push( + // context, + // MaterialPageRoute( + // builder: (context) => + // VideoCallPage( + // item, + // context))) }, ), ) diff --git a/lib/screens/live_care/video_call.dart b/lib/screens/live_care/video_call.dart index 321a7e0f..c6f9a885 100644 --- a/lib/screens/live_care/video_call.dart +++ b/lib/screens/live_care/video_call.dart @@ -1,10 +1,12 @@ import 'dart:async'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; +import 'package:doctor_app_flutter/core/viewModel/LiveCarePatientViewModel.dart'; import 'package:doctor_app_flutter/core/viewModel/livecare_view_model.dart'; import 'package:doctor_app_flutter/models/livecare/get_pending_res_list.dart'; import 'package:doctor_app_flutter/models/livecare/session_status_model.dart'; import 'package:doctor_app_flutter/models/livecare/start_call_res.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/util/VideoChannel.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; @@ -13,9 +15,10 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class VideoCallPage extends StatefulWidget { - final LiveCarePendingListResponse patientData; + final PatiantInformtion patientData; final listContext; - VideoCallPage(this.patientData, this.listContext); + final LiveCarePatientViewModel model; + VideoCallPage({this.patientData, this.listContext, this.model}); @override _VideoCallPageState createState() => _VideoCallPageState(); @@ -41,7 +44,8 @@ class _VideoCallPageState extends State { super.didChangeDependencies(); if (_isInit) { _liveCareProvider = Provider.of(context); - startCall(false); + connectOpenTok(widget.model.startCallRes); + // widget.model.startCall(vCID: widget.patientData.vcId, isReCall: false); } _isInit = false; } @@ -61,7 +65,7 @@ class _VideoCallPageState extends State { kSessionId: tokenData.openSessionID, //'1_MX40NjgwMzIyNH5-MTU5MzY4MzYzODYwM35ucExWYVRVSm5Hcy9uWGZmM1lOa3czZHV-fg', kApiKey: '46209962', - vcId: widget.patientData.vCID, + vcId: widget.patientData.vcId, tokenID: token, //"hfkjshdf347r8743", generalId: "Cs2020@2016\$2958", doctorId: doctorprofile['DoctorID'], @@ -130,7 +134,7 @@ class _VideoCallPageState extends State { height: MediaQuery.of(context).size.height * 0.02, ), Text( - widget.patientData.patientName, + widget.patientData.fullName, style: TextStyle( color: Colors.deepPurpleAccent, fontWeight: FontWeight.w900, @@ -319,7 +323,7 @@ class _VideoCallPageState extends State { endCallWithCharge() { _liveCareProvider - .endCallWithCharge(widget.patientData.vCID, doctorprofile['DoctorID']) + .endCallWithCharge(widget.patientData.vcId, doctorprofile['DoctorID']) .then((result) { closeRoute(); print('end callwith charge'); 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 138fc840..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,13 +1,18 @@ +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/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'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; @@ -31,7 +36,7 @@ class _PatientProfileScreenState extends State bool isFromLiveCare = false; bool isInpatient = false; - + bool isCallFinished = false; bool isDischargedPatient = false; bool isSearchAndOut = false; String patientType; @@ -272,20 +277,67 @@ 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))); - // } else { - // // TODO Call initiateCall service - // } + } else { + 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); + 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/screens/procedures/ProcedureCard.dart b/lib/screens/procedures/ProcedureCard.dart index 3448d0be..d998ca58 100644 --- a/lib/screens/procedures/ProcedureCard.dart +++ b/lib/screens/procedures/ProcedureCard.dart @@ -28,6 +28,7 @@ class ProcedureCard extends StatelessWidget { this.patient, this.doctorID, }) : super(key: key); + @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); @@ -253,9 +254,9 @@ class ProcedureCard extends StatelessWidget { fontSize: 12, ), ), - if (entityList.categoryID == 2 || - entityList.categoryID == 4 && - doctorID == entityList.doctorID) + if ((entityList.categoryID == 2 || + entityList.categoryID == 4) && + doctorID == entityList.doctorID) InkWell( child: Icon(DoctorApp.edit), onTap: onTap, diff --git a/lib/screens/procedures/procedure_screen.dart b/lib/screens/procedures/procedure_screen.dart index 986d3cc1..b6bd705a 100644 --- a/lib/screens/procedures/procedure_screen.dart +++ b/lib/screens/procedures/procedure_screen.dart @@ -92,9 +92,7 @@ class ProcedureScreen extends StatelessWidget { fontSize: 13, ), AppText( - TranslationBase - .of(context) - .procedure, + TranslationBase.of(context).procedure, bold: true, fontSize: 22, ), @@ -102,15 +100,14 @@ class ProcedureScreen extends StatelessWidget { ), ), if ((patient.patientStatusType != null && - patient.patientStatusType == 43) || + patient.patientStatusType == 43) || (isFromLiveCare && patient.appointmentNo != null)) InkWell( onTap: () { Navigator.push( context, MaterialPageRoute( - builder: (context) => - AddProcedureHome( + builder: (context) => AddProcedureHome( patient: patient, model: model, )), @@ -192,7 +189,7 @@ class ProcedureScreen extends StatelessWidget { // 'You Cant Update This Procedure'); }, patient: patient, - doctorID: doctorNameP, + doctorID: model.doctorProfile.doctorID, ), ), if (model.state == ViewState.ErrorLocal || diff --git a/lib/util/VideoChannel.dart b/lib/util/VideoChannel.dart index bf255b54..a0962010 100644 --- a/lib/util/VideoChannel.dart +++ b/lib/util/VideoChannel.dart @@ -20,7 +20,7 @@ class VideoChannel{ "kSessionId": kSessionId, "kToken": kToken, "appLang": "en", - "baseUrl": BASE_URL, + "baseUrl": BASE_URL_LIVE_CARE,//TODO change it to live "VC_ID": vcId, "TokenID": tokenID, "generalId": generalId, 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];