import 'package:diplomaticquarterapp/config/config.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:flutter/cupertino.dart';

class MedicalService extends BaseService {
  List<AppoitmentAllHistoryResultList> appoitmentAllHistoryResultList = List();

  getAppointmentHistory({bool isActiveAppointment = false}) async {
    hasError = false;
    super.error = "";
    Map<String, dynamic> body = Map();
    if(isActiveAppointment) {
      body['IsActiveAppointment'] = true;
      body['isDentalAllowedBackend'] = false;
    }

    await baseAppClient.post(GET_PATIENT_APPOINTMENT_HISTORY,
        onSuccess: (response, statusCode) async {
      appoitmentAllHistoryResultList.clear();
      response['AppoimentAllHistoryResultList'].forEach((appoitment) {
        appoitmentAllHistoryResultList
            .add(AppoitmentAllHistoryResultList.fromJson(appoitment));
      });
    }, 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);
  }
}
