diff --git a/lib/core/service/patient/LiveCarePatientServices.dart b/lib/core/service/patient/LiveCarePatientServices.dart index 29b120ec..fff803d8 100644 --- a/lib/core/service/patient/LiveCarePatientServices.dart +++ b/lib/core/service/patient/LiveCarePatientServices.dart @@ -41,9 +41,33 @@ class LiveCarePatientServices extends BaseService { await baseAppClient.post( GET_PENDING_PATIENT_ER_FOR_DOCTOR_APP, onSuccess: (dynamic response, int statusCode) { - _patientList.clear(); + + List localPatientList= []; + response['List_PendingPatientList'].forEach((v) { - _patientList.add(PatiantInformtion.fromJson(v)); + localPatientList.add(PatiantInformtion.fromJson(v)); + }); + + /// add new items. + localPatientList.forEach((element) { + if ((_patientList.singleWhere((it) => it.patientId == element.patientId, + orElse: () => null)) == null) { + _patientList.add(element); + } + }); + + /// remove items. + List removedPatientList= []; + _patientList.forEach((element) { + if ((localPatientList.singleWhere((it) => it.patientId == element.patientId, + orElse: () => null)) == null) { + removedPatientList.add(element); + } + }); + + + removedPatientList.forEach((element) { + _patientList.remove(element); }); }, onFailure: (String error, int statusCode) { diff --git a/lib/core/viewModel/LiveCarePatientViewModel.dart b/lib/core/viewModel/LiveCarePatientViewModel.dart index 378013bd..03cb0a7b 100644 --- a/lib/core/viewModel/LiveCarePatientViewModel.dart +++ b/lib/core/viewModel/LiveCarePatientViewModel.dart @@ -238,4 +238,18 @@ 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; + return; + } + }); + + setState(ViewState.Idle); + + } } 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 983f0af4..1674e5e8 100644 --- a/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart +++ b/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart @@ -1,12 +1,10 @@ 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'; @@ -14,11 +12,8 @@ import 'package:doctor_app_flutter/screens/patients/profile/profile_screen/profi 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'; @@ -306,45 +301,48 @@ class _PatientProfileScreenState extends State with Single : TranslationBase.of(context).initiateCall, disabled: isCallStarted || model.state == ViewState.BusyLocal, onPressed: () async { - // Navigator.push(context, MaterialPageRoute( - // builder: (BuildContext context) => - // EndCallScreen(patient:patient))); - if (isCallFinished) { Navigator.push( context, MaterialPageRoute( - builder: (BuildContext context) => EndCallScreen(patient: patient))); + builder: (BuildContext context) => + EndCallScreen(patient: patient))); } else { GifLoaderDialogUtils.showMyDialog(context); - await model.startCall(isReCall: false, vCID: patient.vcId); + 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.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, model.startCallRes.isRecording, callConnected, callDisconnected); - }); + AppPermissionsUtils + .requestVideoCallPermission( + context: context, + onTapGrant: () { + locator() + .openVideo( + model.startCallRes, + patient, + model.startCallRes.isRecording, callConnected, + callDisconnected); + }); } } - - // AppPermissionsUtils.requestVideoCallPermission( - // context: context, - // onTapGrant: () { - // locator() - // .openVideo(model.startCallRes, patient, true, callConnected, callDisconnected); - // }); }, ), ),