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.
PatientApp-KKUMC/lib/core/service/appointment_rate_service.dart

96 lines
3.9 KiB
Dart

import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/model/rate/appointment_details.dart';
import 'package:diplomaticquarterapp/core/model/rate/appointment_rate.dart';
import 'package:diplomaticquarterapp/core/model/rate/appoitment_rated.dart';
import 'package:diplomaticquarterapp/core/service/base_service.dart';
class AppointmentRateService extends BaseService {
List<AppoitmentRated> appointmentRatedList = List();
AppointmentDetails appointmentDetails;
Future getIsLastAppointmentRatedList(int languageID) async {
hasError = false;
Map<String, dynamic> bodyData = Map();
bodyData['LanguageID'] = languageID;
await baseAppClient.post(IS_LAST_APPOITMENT_RATED, onSuccess: (dynamic response, int statusCode) {
appointmentRatedList.clear();
response['IsLastAppoitmentRatedList'].forEach((appoint) {
appointmentRatedList.add(AppoitmentRated.fromJson(appoint));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: bodyData);
}
Future getAppointmentDetails() async {
hasError = false;
Map<String, dynamic> bodyData = Map();
bodyData['AppointmentNumber'] = appointmentRatedList[0].appointmentNo;
bodyData['ProjectID'] = appointmentRatedList[0].projectID;
await baseAppClient.post(GET_APPOINTMENT_DETAILS_BY_NO, onSuccess: (dynamic response, int statusCode) {
if (response['AppointmentDetails'] != null) appointmentDetails = AppointmentDetails.fromJson(response['AppointmentDetails']);
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: bodyData);
}
Future sendAppointmentRate(int rate, int appointmentNo, int projectID, int doctorID, int clinicID, String note) async {
hasError = false;
AppointmentRate appointmentRate = AppointmentRate();
appointmentRate.rate = rate;
appointmentRate.appointmentNo = appointmentNo;
appointmentRate.projectID = projectID;
appointmentRate.doctorID = doctorID;
appointmentRate.clinicID = clinicID;
appointmentRate.note = note;
appointmentRate.createdBy = 2;
appointmentRate.editedBy = 2;
await baseAppClient.post(NEW_RATE_APPOINTMENT_URL, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: appointmentRate.toJson());
}
Future sendDoctorRate(int rate, int appointmentNo, int projectID, int doctorID, int clinicID, String note, String appoDate, String docName, String projectName, String clinicName) async {
Map<String, dynamic> request;
hasError = false;
request = {
"DoctorID": doctorID,
"Rate": rate,
"ClinicID": clinicID,
"ProjectID": projectID,
"AppointmentNo": appointmentNo,
"Note": note,
"MobileNumber": authenticatedUserObject.user.mobileNumber,
"AppointmentDate": appoDate,
"DoctorName": docName,
"ProjectName": projectName,
"COCTypeName": 1,
"PatientName": authenticatedUserObject.user.firstName + " " + authenticatedUserObject.user.lastName,
"PatientOutSA": authenticatedUserObject.user.outSA,
"PatientTypeID": authenticatedUserObject.user.patientType,
"ClinicName": clinicName,
"PatientIdentificationID": authenticatedUserObject.user.patientIdentificationNo
};
await baseAppClient.post(NEW_RATE_DOCTOR_URL, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: request);
}
AppoitmentRated get lastAppointmentRated {
if (appointmentRatedList.length > 0) return appointmentRatedList[appointmentRatedList.length - 1];
return null;
}
deleteAppointmentRated(AppoitmentRated appointmentRated) {
appointmentRatedList.remove(appointmentRated);
}
deleteAllAppAppointmentRate() => appointmentRatedList.clear();
}