You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RSGDoctorApp/lib/core/viewModel/LiveCarePatientViewModel.dart

220 lines
7.5 KiB
Dart

import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
5 years ago
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/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';
class LiveCarePatientViewModel extends BaseViewModel {
List<PatiantInformtion> filterData = [];
LiveCarePatientServices _liveCarePatientServices =
locator<LiveCarePatientServices>();
StartCallRes get startCallRes => _liveCarePatientServices.startCallRes;
5 years ago
List<AlternativeService> get alternativeServicesList =>
_liveCarePatientServices.alternativeServicesList;
5 years ago
5 years ago
DashboardService _dashboardService = locator<DashboardService>();
getPendingPatientERForDoctorApp({bool isFromTimer = false}) async {
if (isFromTimer) {
setState(ViewState.Idle);
} else {
setState(ViewState.BusyLocal);
}
PendingPatientERForDoctorAppRequestModel
pendingPatientERForDoctorAppRequestModel =
5 years ago
PendingPatientERForDoctorAppRequestModel(
sErServiceID: _dashboardService.sServiceID, outSA: false);
await _liveCarePatientServices.getPendingPatientERForDoctorApp(
pendingPatientERForDoctorAppRequestModel);
if (_liveCarePatientServices.hasError) {
error = _liveCarePatientServices.error;
setState(ViewState.ErrorLocal);
} else {
filterData = _liveCarePatientServices.patientList;
setState(ViewState.Idle);
}
}
Future endCall(int vCID, bool isPatient) async {
await getDoctorProfile(isGetProfile: true);
EndCallReq endCallReq = new EndCallReq();
endCallReq.doctorId = doctorProfile.doctorID;
endCallReq.generalid = 'Cs2020@2016\$2958';
endCallReq.vCID = vCID;
endCallReq.isDestroy = isPatient;
setState(ViewState.BusyLocal);
5 years ago
await _liveCarePatientServices.endCall(endCallReq);
if (_liveCarePatientServices.hasError) {
error = _liveCarePatientServices.error;
setState(ViewState.ErrorLocal);
} else {
setState(ViewState.Idle);
}
}
5 years ago
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);
}
}
5 years ago
5 years ago
setSelectedCheckboxValues(AlternativeService service, bool isSelected) {
int index = alternativeServicesList.indexOf(service);
if (index != -1) alternativeServicesList[index].isSelected = isSelected;
notifyListeners();
}
Future endCallWithCharge(int vcID, bool isConfirmed) async {
5 years ago
setState(ViewState.BusyLocal);
5 years ago
String selectedServicesString = "";
if (isConfirmed) {
selectedServicesString = getSelectedAlternativeServices();
}
await _liveCarePatientServices.endCallWithCharge(
vcID, selectedServicesString);
5 years ago
if (_liveCarePatientServices.hasError) {
error = _liveCarePatientServices.error;
setState(ViewState.ErrorLocal);
} else {
await getPendingPatientERForDoctorApp();
setState(ViewState.Idle);
}
}
5 years ago
String getSelectedAlternativeServices() {
List<int> selectedServices = List();
for (AlternativeService service in alternativeServicesList) {
if (service.isSelected) {
selectedServices.add(service.serviceID);
}
}
return selectedServices.toString();
}
Future getAlternativeServices(int vcID) async {
setState(ViewState.BusyLocal);
5 years ago
await _liveCarePatientServices.getAlternativeServices(vcID);
if (_liveCarePatientServices.hasError) {
5 years ago
error = _liveCarePatientServices.error;
setState(ViewState.ErrorLocal);
} else {
setState(ViewState.Idle);
}
}
5 years ago
Future transferToAdmin(int vcID, String notes) async {
5 years ago
setState(ViewState.BusyLocal);
5 years ago
await _liveCarePatientServices.transferToAdmin(vcID, notes);
5 years ago
if (_liveCarePatientServices.hasError) {
error = _liveCarePatientServices.error;
setState(ViewState.ErrorLocal);
} else {
5 years ago
await getPendingPatientERForDoctorApp();
5 years ago
setState(ViewState.Idle);
}
}
searchData(String str) {
5 years ago
var strExist = str.length > 0 ? true : false;
if (strExist) {
filterData = [];
for (var i = 0; i < _liveCarePatientServices.patientList.length; i++) {
String fullName =
5 years ago
_liveCarePatientServices.patientList[i].fullName.toUpperCase();
String patientID =
5 years ago
_liveCarePatientServices.patientList[i].patientId.toString();
String mobile =
5 years ago
_liveCarePatientServices.patientList[i].mobileNumber.toUpperCase();
if (fullName.contains(str.toUpperCase()) ||
5 years ago
patientID.contains(str) ||
mobile.contains(str)) {
filterData.add(_liveCarePatientServices.patientList[i]);
}
}
notifyListeners();
} else {
filterData = _liveCarePatientServices.patientList;
notifyListeners();
}
}
5 years ago
5 years ago
setDemoData() {
5 years ago
alternativeServicesList.clear();
alternativeServicesList.add(
AlternativeService(serviceID: 1, serviceName: "Medicine Home Delivery"),
);
alternativeServicesList.add(
AlternativeService(serviceID: 2, serviceName: "LABORATORY"),
);
alternativeServicesList.add(
AlternativeService(
serviceID: 3, serviceName: "RADIOLOGY(ULTRASOUND) For pregnant only"),
);
alternativeServicesList.add(
AlternativeService(serviceID: 4, serviceName: "VACCINATIONS"),
);
alternativeServicesList.add(
AlternativeService(serviceID: 5, serviceName: "ER SERVICES"),
);
alternativeServicesList.add(
AlternativeService(serviceID: 6, serviceName: "PHYSIOTHERAPY"),
);
alternativeServicesList.add(
AlternativeService(serviceID: 7, serviceName: "DRESSING"),
);
alternativeServicesList.add(
AlternativeService(serviceID: 8, serviceName: "INJECTION"),
);
alternativeServicesList.add(
AlternativeService(serviceID: 9, serviceName: "FAMILY MEDICIN DR"),
);
alternativeServicesList.add(
AlternativeService(
serviceID: 10, serviceName: "FOLYS CATHETER INSERTION"),
);
alternativeServicesList.add(
AlternativeService(serviceID: 11, serviceName: "GASTRIC TUBE CHANGE"),
);
}
}