import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/model/live_care/AlternativeServicesList.dart'; import 'package:doctor_app_flutter/core/model/live_care/PendingPatientERForDoctorAppRequestModel.dart'; import 'package:doctor_app_flutter/core/model/live_care/live_care_login_reguest_model.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 { // List _patientList = []; List patientList = []; List alternativeServicesList = []; bool _isFinished = false; bool _isLive = true; bool get isFinished => _isFinished; setFinished(bool isFinished) { _isFinished = isFinished; } var endCallResponse = {}; var transferToAdminResponse = {}; var isLoginResponse = {}; StartCallRes _startCallRes; StartCallRes get startCallRes => _startCallRes; Future getPendingPatientERForDoctorApp( PendingPatientERForDoctorAppRequestModel pendingPatientERForDoctorAppRequestModel, {bool isSecondTime = false }) 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, 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; super.error = error; }, body: pendingPatientERForDoctorAppRequestModel.toJson(), ); } Future endCall(EndCallReq endCallReq) async { hasError = false; await baseAppClient.post(END_CALL, onSuccess: (response, statusCode) async { endCallResponse = response; }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: endCallReq.toJson(), isLiveCare: _isLive); } 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: _isLive); } Future endCallWithCharge(int vcID, List altServiceList) async { hasError = false; await baseAppClient.post(END_CALL_WITH_CHARGE, onSuccess: (dynamic response, int statusCode) { endCallResponse = response; }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: { "VC_ID": vcID, "AltServiceList": altServiceList, "generalid":GENERAL_ID }, isLiveCare: _isLive); } Future transferToAdmin(int vcID, String notes) async { hasError = false; await baseAppClient.post(TRANSFERT_TO_ADMIN, onSuccess: (dynamic response, int statusCode) { transferToAdminResponse = response; }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: { "VC_ID": vcID, "IsOutKsa": false, "Notes": notes, }, isLiveCare: _isLive); } Future sendSMSInstruction(int vcID) async { hasError = false; await baseAppClient.post(SEND_SMS_INSTRUCTIONS, onSuccess: (dynamic response, int statusCode) { transferToAdminResponse = response; }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: { "VC_ID": vcID, "generalid": GENERAL_ID }, isLiveCare: _isLive); } Future isLogin({LiveCareUserLoginRequestModel isLoginRequestModel, int loginStatus}) async { hasError = false; await getDoctorProfile( ); isLoginRequestModel.doctorId = super.doctorProfile.doctorID; await baseAppClient.post(LIVE_CARE_IS_LOGIN, onSuccess: (response, statusCode) async { isLoginResponse = response; }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: isLoginRequestModel.toJson(), isLiveCare: _isLive); } Future getAlternativeServices(int vcID) async { hasError = false; alternativeServicesList.clear(); await baseAppClient.post(GET_ALTERNATIVE_SERVICE, onSuccess: (dynamic response, int statusCode) { response['AlternativeServicesList'].forEach((v) { alternativeServicesList.add(AlternativeService.fromJson(v)); }); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: { "VC_ID": vcID, "generalid": GENERAL_ID }, isLiveCare: _isLive); } }