import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/model/sick_leave/sick_leave.dart';
import 'package:diplomaticquarterapp/core/service/base_service.dart';

class PatientSickLeaveService extends BaseService {
  List<SickLeave> sickLeaveList = List();

  getSickLeave() async {
    hasError = false;
    super.error = "";
    await baseAppClient.post(GET_PATIENT_SICK_LEAVE,
        onSuccess: (response, statusCode) async {
      sickLeaveList.clear();
      response['List_SickLeave'].forEach((sickLeave) {
        sickLeaveList.add(SickLeave.fromJson(sickLeave));
      });
    }, onFailure: (String error, int statusCode) {
      hasError = true;
      super.error = error;
    }, body: Map());
  }

  sendSickLeaveEmail(
      {int requestNo,
      String projectName,
      String doctorName,
      int projectID,
      String setupID}) async {
    hasError = false;
    super.error = "";
    Map<String, dynamic> body = Map();
    body['RequestNo'] = requestNo;
    body['To'] = user.emailAddress;
    body['DateofBirth'] = user.dateofBirth;
    body['PatientIditificationNum'] = user.patientIdentificationNo;
    body['PatientMobileNumber'] = user.mobileNumber;
    body['PatientName'] = user.firstName + " " + user.firstName;
    body['ProjectName'] = projectName;
    body['DoctorName'] = doctorName;
    body['ProjectID'] = projectID;
    body['SetupID'] = setupID;
    await baseAppClient
        .post(SendSickLeaveEmail, onSuccess: (response, statusCode) async {},
            onFailure: (String error, int statusCode) {
      hasError = true;
      super.error = error;
    }, body: body);
  }
}
