import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/HHC_get_all_services_request_modle.dart';
import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/HHC_get_all_services_response_model.dart';
import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_hHC_all_pres_orders_request_model.dart';
import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_hhc_all_pres_orders_response_model.dart';
import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/update_pres_oreder_request_model.dart';

import '../base_service.dart';

class HomeHealthCareService extends BaseService {
  List<HHCGetAllServicesResponseModel> hhcAllServicesList = List();
  List<GetHHCAllPresOrdersResponseModel> hhcAllPresOrdersList = List();
  bool isOrderUpdated;
  Future getHHCAllServices(
      HHCGetAllServicesRequestModel hHCGetAllServicesRequestModel) async {
    hasError = false;
    await baseAppClient.post(HHC_GET_ALL_SERVICES,
        onSuccess: (dynamic response, int statusCode) {
      hhcAllServicesList.clear();
      response['PatientER_HHC_GetAllServicesList'].forEach((data) {
        hhcAllServicesList.add(HHCGetAllServicesResponseModel.fromJson(data));
      });
    }, onFailure: (String error, int statusCode) {
      hasError = true;
      super.error = error;
    }, body: hHCGetAllServicesRequestModel.toJson());
  }



  Future getHHCAllPresOrders() async {

    GetHHCAllPresOrdersRequestModel getHHCAllPresOrdersRequestModel= GetHHCAllPresOrdersRequestModel();
    hasError = false;
    await baseAppClient.post(GET_PATIENT_ALL_PRES_ORDERS,
        onSuccess: (dynamic response, int statusCode) {
          hhcAllPresOrdersList.clear();
          response['PatientER_GetPatientAllPresOrdersList'].forEach((data) {
            hhcAllPresOrdersList.add(GetHHCAllPresOrdersResponseModel.fromJson(data));
          });
        }, onFailure: (String error, int statusCode) {
          hasError = true;
          super.error = error;
        }, body: getHHCAllPresOrdersRequestModel.toJson());
  }

  Future updateHHCPresOrder(UpdatePresOrderRequestModel updatePresOrderRequestModel) async {

    hasError = false;
    await baseAppClient.post(PATIENT_ER_UPDATE_PRES_ORDER,
        onSuccess: (dynamic response, int statusCode) {
           isOrderUpdated = true;
        }, onFailure: (String error, int statusCode) {
          hasError = true;
          super.error = error;
        }, body: updatePresOrderRequestModel.toJson());
  }
}
