import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/service/base/base_service.dart';
import 'package:doctor_app_flutter/core/model/dashboard/get_special_clinical_care_List_Respose_Model.dart';
import 'package:doctor_app_flutter/core/model/dashboard/get_special_clinical_care_mapping_List_Respose_Model.dart';

class SpecialClinicsService extends BaseService {
  List<GetSpecialClinicalCareListResponseModel> _specialClinicalCareList = [];

  List<GetSpecialClinicalCareListResponseModel> get specialClinicalCareList =>
      _specialClinicalCareList;

  List<GetSpecialClinicalCareMappingListResponseModel>
      _specialClinicalCareMappingList = [];

  List<GetSpecialClinicalCareMappingListResponseModel>
      get specialClinicalCareMappingList => _specialClinicalCareMappingList;

  Future getSpecialClinicalCareList() async {
    hasError = false;
    await baseAppClient.post(
      GET_SPECIAL_CLINICAL_CARE_LIST,
      onSuccess: (dynamic response, int statusCode) {
        _specialClinicalCareList.clear();
        response['List_SpecialClinicalCareList'].forEach((v) {
          _specialClinicalCareList
              .add(GetSpecialClinicalCareListResponseModel.fromJson(v));
        });
      },
      onFailure: (String error, int statusCode) {
        hasError = true;
        super.error = error;
      },
      body: {},
    );
  }

  Future getSpecialClinicalCareMappingList(int clinicId) async {
    hasError = false;
    await baseAppClient.post(
      GET_SPECIAL_CLINICAL_CARE_MAPPING_LIST,
      onSuccess: (dynamic response, int statusCode) {
        _specialClinicalCareMappingList.clear();
        response['List_SpecialClinicalCareMappingList'].forEach((v) {
          _specialClinicalCareMappingList
              .add(GetSpecialClinicalCareMappingListResponseModel.fromJson(v));
        });
      },
      onFailure: (String error, int statusCode) {
        hasError = true;
        super.error = error;
      },
      body: {"ClinicID": clinicId, "DoctorID": 0, "EditedBy": 0},
    );
  }
}
