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.
83 lines
3.8 KiB
Dart
83 lines
3.8 KiB
Dart
import 'package:diplomaticquarterapp/config/config.dart';
|
|
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
|
import 'package:diplomaticquarterapp/core/model/er/PatientER.dart';
|
|
import 'package:diplomaticquarterapp/core/service/base_service.dart';
|
|
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
|
|
import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
|
|
import 'package:diplomaticquarterapp/pages/MyAppointments/models/DoctorScheduleResponse.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
class MedicalService extends BaseService {
|
|
List<AppoitmentAllHistoryResultList> appoitmentAllHistoryResultList = List();
|
|
List<DoctorScheduleResponse> doctorScheduleResponse = List();
|
|
List<String> freeSlots = [];
|
|
getAppointmentHistory({bool isActiveAppointment = false}) async {
|
|
hasError = false;
|
|
super.error = "";
|
|
Map<String, dynamic> body = Map();
|
|
if (isActiveAppointment) {
|
|
body['IsActiveAppointment'] = true;
|
|
body['isDentalAllowedBackend'] = false;
|
|
}
|
|
var appoHistory = await sharedPref.getObject(APPOINTMENT_HISTORY_MEDICAL);
|
|
if (appoHistory != null) {
|
|
appoitmentAllHistoryResultList.clear();
|
|
appoHistory.forEach((appoitment) {
|
|
appoitmentAllHistoryResultList.add(AppoitmentAllHistoryResultList.fromJson(appoitment));
|
|
});
|
|
} else {
|
|
await baseAppClient.post(GET_PATIENT_APPOINTMENT_HISTORY, onSuccess: (response, statusCode) async {
|
|
appoitmentAllHistoryResultList.clear();
|
|
response['AppoimentAllHistoryResultList'].forEach((appoitment) {
|
|
appoitmentAllHistoryResultList.add(AppoitmentAllHistoryResultList.fromJson(appoitment));
|
|
});
|
|
sharedPref.setObject(APPOINTMENT_HISTORY_MEDICAL, response['AppoimentAllHistoryResultList']);
|
|
}, onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
}, body: body);
|
|
}
|
|
}
|
|
|
|
addAmbulanceRequest({@required PatientER patientER}) async {
|
|
hasError = false;
|
|
super.error = "";
|
|
Map<String, dynamic> body = Map();
|
|
body['RequesterFileNo'] = user.patientID;
|
|
body['RequesterMobileNo'] = user.mobileNumber;
|
|
body['RequesterIsOutSA'] = user.outSA;
|
|
await baseAppClient.post(GET_PATIENT_APPOINTMENT_HISTORY, onSuccess: (response, statusCode) async {}, onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
}, body: body);
|
|
}
|
|
|
|
getSchedule(DoctorList doctorRequest) async {
|
|
Map<String, dynamic> request;
|
|
request = {'DoctorID': doctorRequest.doctorID, 'ProjectID': doctorRequest.projectID, 'ClinicID': doctorRequest.clinicID, 'DoctorWorkingHoursDays': 7};
|
|
dynamic localRes;
|
|
await baseAppClient.post(DOCTOR_SCHEDULE_URL, onSuccess: (response, statusCode) async {
|
|
localRes = response;
|
|
}, onFailure: (String error, int statusCode) {
|
|
throw error;
|
|
}, body: request);
|
|
doctorScheduleResponse.clear();
|
|
localRes['List_DoctorWorkingHoursTable'].forEach((item) => {doctorScheduleResponse.add(DoctorScheduleResponse.fromJson(item))});
|
|
}
|
|
|
|
getFreeSlot(DoctorList doctorRequest) async {
|
|
Map<String, dynamic> request;
|
|
request = {'DoctorID': doctorRequest.doctorID, 'ProjectID': doctorRequest.projectID, 'ClinicID': doctorRequest.clinicID, 'DoctorWorkingHoursDays': 7};
|
|
dynamic localRes;
|
|
await baseAppClient.post(GET_DOCTOR_FREE_SLOTS, onSuccess: (response, statusCode) async {
|
|
localRes = response;
|
|
}, onFailure: (String error, int statusCode) {
|
|
throw error;
|
|
}, body: request);
|
|
freeSlots.clear();
|
|
localRes['FreeTimeSlots'].forEach((item) => freeSlots.add(item));
|
|
// localRes['List_DoctorWorkingHoursTable'].forEach((item) =>
|
|
// {doctorScheduleResponse.add(DoctorScheduleResponse.fromJson(item))});
|
|
}
|
|
}
|