From 29eeb21e76ccc08f8c30f6f2a6ed45c9c5a25cb6 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Sun, 27 Jun 2021 14:50:29 +0300 Subject: [PATCH] finalize create episode on Live care. --- .../patient/LiveCarePatientServices.dart | 130 ++---------------- .../viewModel/LiveCarePatientViewModel.dart | 4 +- .../live_care/live_care_patient_screen.dart | 2 +- .../patient_profile_screen.dart | 84 +++++------ 4 files changed, 61 insertions(+), 159 deletions(-) diff --git a/lib/core/service/patient/LiveCarePatientServices.dart b/lib/core/service/patient/LiveCarePatientServices.dart index 0e531501..b6ed526a 100644 --- a/lib/core/service/patient/LiveCarePatientServices.dart +++ b/lib/core/service/patient/LiveCarePatientServices.dart @@ -10,9 +10,9 @@ 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 { - // List _patientList = []; + List _patientList = []; - List patientList = []; + List get patientList => _patientList; List alternativeServicesList = []; @@ -36,145 +36,41 @@ class LiveCarePatientServices extends BaseService { Future getPendingPatientERForDoctorApp( PendingPatientERForDoctorAppRequestModel - pendingPatientERForDoctorAppRequestModel, {bool isSecondTime = false }) async { + pendingPatientERForDoctorAppRequestModel) async { hasError = false; await baseAppClient.post( GET_PENDING_PATIENT_ER_FOR_DOCTOR_APP, onSuccess: (dynamic response, int statusCode) { List localPatientList= []; - localPatientList.clear(); + response['List_PendingPatientList'].forEach((v) { localPatientList.add(PatiantInformtion.fromJson(v)); }); - localPatientList.add(PatiantInformtion.fromJson({ - "AcceptedBy": null, - "AcceptedOn": null, - "Age": 34, - "AppointmentDate": null, - "AppointmentNo": null, - "ArrivalTime": "2021-06-09 16:24", - "ArrivalTimeD": "/Date(1623245082567+0300)/", - "CallStatus": 1, - "CallStatusDisc": null, - "CallTypeID": 1, - "ClientRequestID": "2344670985-1231755-1621862656", - "ClinicName": "ENT", - "ConsoltationEnd": null, - "ConsultationNotes": null, - "CreatedOn": null, - "DateOfBirth": "1987-01-04", - "DeviceToken": "fYjscrPmRQk:APA91bHP3zv4YhxMc4v5cTgbY1TZQFj5hIzrS0VUsTqhsaeNOpWwGgrOTpl2S7xD1-98nOaTmEwNqZwgbZeJVBNPATHOBBXQmMht3yh91jobpYCht4vfmIcvFMl87MhrnWbaVz9nJy_5", - "DeviceType": "Android", - "DoctorName": null, - "EditOn": "/Date(1623230039447+0300)/", - "Gender": "1", - "IsFlutter": null, - "IsFollowUP": false, - "IsFromVida": false, - "IsLoginB": 0, - "IsOutKSA": false, - "IsRejected": 0, - "Language": "AR ", - "Latitude": 24.708887, - "Longitude": 46.665832, - "MobileNumber": "0537503378", - "OpenSession": null, - "OpenTokenID": "T1==cGFydG5lcl9pZD00NjIwOTk2MiZzaWc9NjYzMzhlOGNjMTdmNTU3ZjcxOTU1ZTg5ZGUxNzQyZDRiMDkwMjU2YjpzZXNzaW9uX2lkPTFfTVg0ME5qSXdPVGsyTW41LU1UWXlNVGcyTWpjNU9ESXhPWDUxV0hsSGVUTjZObFJoTldaV1ZFWlRkekpJV0hWM0sydC1mZyZjcmVhdGVfdGltZT0xNjIxODYyNzk5Jm5vbmNlPTE4MzE1Mi", - "PatientID": "1231755", - "PatientName": "TAMER FANASHEH", - "PatientStatus": 1, - "PreferredLanguage": "En", - "ProjectID": 0, - "Scoring": 0.00, - "ServiceID": 7, - "TokenID": null, - "VC_ID": 4475, - "VoipToken": null - })); - - if(isSecondTime) { - localPatientList.add(PatiantInformtion.fromJson({ - "AcceptedBy": null, - "AcceptedOn": null, - "Age": 34, - "AppointmentDate": null, - "AppointmentNo": null, - "ArrivalTime": "2021-06-09 16:24", - "ArrivalTimeD": "/Date(1623245082567+0300)/", - "CallStatus": 1, - "CallStatusDisc": null, - "CallTypeID": 1, - "ClientRequestID": "2344670985-1231755-1621862656", - "ClinicName": "ENT", - "ConsoltationEnd": null, - "ConsultationNotes": null, - "CreatedOn": null, - "DateOfBirth": "1987-01-04", - "DeviceToken": "fYjscrPmRQk:APA91bHP3zv4YhxMc4v5cTgbY1TZQFj5hIzrS0VUsTqhsaeNOpWwGgrOTpl2S7xD1-98nOaTmEwNqZwgbZeJVBNPATHOBBXQmMht3yh91jobpYCht4vfmIcvFMl87MhrnWbaVz9nJy_5", - "DeviceType": "Android", - "DoctorName": null, - "EditOn": "/Date(1623230039447+0300)/", - "Gender": "1", - "IsFlutter": null, - "IsFollowUP": false, - "IsFromVida": false, - "IsLoginB": 0, - "IsOutKSA": false, - "IsRejected": 0, - "Language": "AR ", - "Latitude": 24.708887, - "Longitude": 46.665832, - "MobileNumber": "0537503378", - "OpenSession": null, - "OpenTokenID": "T1==cGFydG5lcl9pZD00NjIwOTk2MiZzaWc9NjYzMzhlOGNjMTdmNTU3ZjcxOTU1ZTg5ZGUxNzQyZDRiMDkwMjU2YjpzZXNzaW9uX2lkPTFfTVg0ME5qSXdPVGsyTW41LU1UWXlNVGcyTWpjNU9ESXhPWDUxV0hsSGVUTjZObFJoTldaV1ZFWlRkekpJV0hWM0sydC1mZyZjcmVhdGVfdGltZT0xNjIxODYyNzk5Jm5vbmNlPTE4MzE1Mi", - "PatientID": "12317552222", - "PatientName": "TAMER FANASHEH", - "PatientStatus": 1, - "PreferredLanguage": "En", - "ProjectID": 0, - "Scoring": 0.00, - "ServiceID": 7, - "TokenID": null, - "VC_ID": 4475, - "VoipToken": null - })); - } - - /// add new items. localPatientList.forEach((element) { - // if (!_patientList.contains(element)) { - // _patientList.add(element); - // } - - if ((patientList.singleWhere((it) => it.patientId == element.patientId, + if ((_patientList.singleWhere((it) => it.patientId == element.patientId, orElse: () => null)) == null) { - patientList.add(element); + _patientList.add(element); } }); - - - - print(patientList); /// remove items. - patientList.forEach((element) { - // if (!localPatientList.contains(element)) { - // _patientList.remove(element); - // } - + List removedPatientList= []; + removedPatientList.clear(); + _patientList.forEach((element) { if ((localPatientList.singleWhere((it) => it.patientId == element.patientId, orElse: () => null)) == null) { - patientList.remove(element); + removedPatientList.add(element); } }); - print(patientList); - + removedPatientList.forEach((element) { + _patientList.remove(element); + }); }, onFailure: (String error, int statusCode) { hasError = true; diff --git a/lib/core/viewModel/LiveCarePatientViewModel.dart b/lib/core/viewModel/LiveCarePatientViewModel.dart index 42028c52..638306f7 100644 --- a/lib/core/viewModel/LiveCarePatientViewModel.dart +++ b/lib/core/viewModel/LiveCarePatientViewModel.dart @@ -25,7 +25,7 @@ class LiveCarePatientViewModel extends BaseViewModel { DashboardService _dashboardService = locator(); - getPendingPatientERForDoctorApp({bool isFromTimer = false, bool isSecondTime = false}) async { + getPendingPatientERForDoctorApp({bool isFromTimer = false}) async { if (isFromTimer) { setState(ViewState.Idle); } else { @@ -34,7 +34,7 @@ class LiveCarePatientViewModel extends BaseViewModel { PendingPatientERForDoctorAppRequestModel pendingPatientERForDoctorAppRequestModel = PendingPatientERForDoctorAppRequestModel(sErServiceID: _dashboardService.sServiceID, outSA: false); - await _liveCarePatientServices.getPendingPatientERForDoctorApp(pendingPatientERForDoctorAppRequestModel, isSecondTime: isSecondTime); + await _liveCarePatientServices.getPendingPatientERForDoctorApp(pendingPatientERForDoctorAppRequestModel); if (_liveCarePatientServices.hasError) { error = _liveCarePatientServices.error; diff --git a/lib/screens/live_care/live_care_patient_screen.dart b/lib/screens/live_care/live_care_patient_screen.dart index edd0e243..d98e1701 100644 --- a/lib/screens/live_care/live_care_patient_screen.dart +++ b/lib/screens/live_care/live_care_patient_screen.dart @@ -32,7 +32,7 @@ class _LiveCarePatientScreenState extends State { super.initState(); timer = Timer.periodic(Duration(seconds: 10), (Timer t) { if (_liveCareViewModel != null) { - _liveCareViewModel.getPendingPatientERForDoctorApp(isFromTimer: true, isSecondTime: true); + _liveCareViewModel.getPendingPatientERForDoctorApp(isFromTimer: true); } }); } 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 87b5489a..f4b68456 100644 --- a/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart +++ b/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart @@ -1,14 +1,17 @@ import 'dart:async'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/service/VideoCallService.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/models/SOAP/PostEpisodeReqModel.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/NotificationPermissionUtils.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'; @@ -19,6 +22,7 @@ import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:quiver/async.dart'; +import '../../../../locator.dart'; import '../../../../routes.dart'; class PatientProfileScreen extends StatefulWidget { @@ -293,46 +297,48 @@ class _PatientProfileScreenState extends State with Single : TranslationBase.of(context).initiateCall, disabled: isCallStarted || model.state == ViewState.BusyLocal, onPressed: () async { + if (isCallFinished) { + Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => + EndCallScreen(patient: patient))); + } else { + GifLoaderDialogUtils.showMyDialog(context); + await model.startCall( + isReCall: false, vCID: patient.vcId); - model.updateInCallPatient( - patient: patient, - appointmentNo: 0 ); - setState(() { - patient.episodeNo = 0 ; - patient.appointmentNo = 0; - }); - // Navigator.push(context, MaterialPageRoute( - // builder: (BuildContext context) => - // EndCallScreen(patient:patient))); - - // if (isCallFinished) { - // Navigator.push( - // context, - // MaterialPageRoute( - // builder: (BuildContext context) => EndCallScreen(patient: patient))); - // } 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(); - // patient.appointmentNo = int.parse(model.startCallRes.appointmentNo.toString()); - // patient.episodeNo = 0; - // setState(() { - // isCallStarted = true; - // }); - // GifLoaderDialogUtils.hideDialog(context); - // AppPermissionsUtils.requestVideoCallPermission( - // context: context, - // onTapGrant: () { - // locator() - // .openVideo(model.startCallRes, patient, callConnected, callDisconnected); - // }); - // } - // } + if (model.state == ViewState.ErrorLocal) { + GifLoaderDialogUtils.hideDialog(context); + Helpers.showErrorToast(model.error); + } else { + await model.getDoctorProfile(); + patient.appointmentNo = int.parse(model + .startCallRes.appointmentNo + .toString()); + patient.episodeNo = 0; + model.updateInCallPatient( + patient: patient, + appointmentNo: int.parse(model + .startCallRes.appointmentNo + .toString())); + setState(() { + isCallStarted = true; + }); + GifLoaderDialogUtils.hideDialog(context); + AppPermissionsUtils + .requestVideoCallPermission( + context: context, + onTapGrant: () { + locator() + .openVideo( + model.startCallRes, + patient, + callConnected, + callDisconnected); + }); + } + } }, ), ),