From 80ef1a241dfa6e684efc7487d8ee97f0c9258ddc Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Sun, 27 Jun 2021 13:00:02 +0300 Subject: [PATCH] first step from fix episode in patient live care list --- .../patient/LiveCarePatientServices.dart | 140 +++++++++++++++++- .../viewModel/LiveCarePatientViewModel.dart | 17 ++- .../live_care/live_care_patient_screen.dart | 2 +- .../patient_profile_screen.dart | 77 +++++----- 4 files changed, 187 insertions(+), 49 deletions(-) diff --git a/lib/core/service/patient/LiveCarePatientServices.dart b/lib/core/service/patient/LiveCarePatientServices.dart index 29b120ec..0e531501 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 get patientList => _patientList; + List patientList = []; List alternativeServicesList = []; @@ -36,15 +36,145 @@ class LiveCarePatientServices extends BaseService { Future getPendingPatientERForDoctorApp( PendingPatientERForDoctorAppRequestModel - pendingPatientERForDoctorAppRequestModel) async { + pendingPatientERForDoctorAppRequestModel, {bool isSecondTime = false }) async { hasError = false; await baseAppClient.post( GET_PENDING_PATIENT_ER_FOR_DOCTOR_APP, onSuccess: (dynamic response, int statusCode) { - _patientList.clear(); + + List localPatientList= []; + + localPatientList.clear(); response['List_PendingPatientList'].forEach((v) { - _patientList.add(PatiantInformtion.fromJson(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, + orElse: () => null)) == null) { + patientList.add(element); + } + }); + + + + + print(patientList); + /// remove items. + patientList.forEach((element) { + // if (!localPatientList.contains(element)) { + // _patientList.remove(element); + // } + + if ((localPatientList.singleWhere((it) => it.patientId == element.patientId, + orElse: () => null)) == null) { + patientList.remove(element); + } + }); + + print(patientList); + + }, onFailure: (String error, int statusCode) { hasError = true; diff --git a/lib/core/viewModel/LiveCarePatientViewModel.dart b/lib/core/viewModel/LiveCarePatientViewModel.dart index 378013bd..42028c52 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}) async { + getPendingPatientERForDoctorApp({bool isFromTimer = false, bool isSecondTime = 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); + await _liveCarePatientServices.getPendingPatientERForDoctorApp(pendingPatientERForDoctorAppRequestModel, isSecondTime: isSecondTime); if (_liveCarePatientServices.hasError) { error = _liveCarePatientServices.error; @@ -238,4 +238,17 @@ class LiveCarePatientViewModel extends BaseViewModel { AlternativeService(serviceID: 11, serviceName: "GASTRIC TUBE CHANGE"), ); } + + updateInCallPatient({PatiantInformtion patient, appointmentNo}){ + + _liveCarePatientServices.patientList.forEach((e) { + if(e.patientId == patient.patientId) { + e.episodeNo = 0 ; + e.appointmentNo = appointmentNo; + } + }); + + setState(ViewState.Idle); + + } } diff --git a/lib/screens/live_care/live_care_patient_screen.dart b/lib/screens/live_care/live_care_patient_screen.dart index d98e1701..edd0e243 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); + _liveCareViewModel.getPendingPatientERForDoctorApp(isFromTimer: true, isSecondTime: 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 7a70e379..87b5489a 100644 --- a/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart +++ b/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart @@ -1,24 +1,16 @@ import 'dart:async'; -import 'package:doctor_app_flutter/config/config.dart'; 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/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/NotificationPermissionUtils.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-app-bar.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'; import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; @@ -27,7 +19,6 @@ 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 { @@ -302,42 +293,46 @@ class _PatientProfileScreenState extends State with Single : TranslationBase.of(context).initiateCall, disabled: isCallStarted || model.state == ViewState.BusyLocal, onPressed: () async { + + 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); - }); - } - } - - // AppPermissionsUtils.requestVideoCallPermission(context: context,onTapGrant: (){ - // locator().openVideo(model.startCallRes, patient, callConnected, callDisconnected); - // }); + // 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); + // }); + // } + // } }, ), ),