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

class AllergiesService extends BaseService {
  List<Allergy> allergies = List();

  getAllergies() async {
    hasError = false;
    super.error = "";
    Map<String, dynamic> body = Map();
    body['isDentalAllowedBackend'] = false;
    body['OutSA'] = 0;
    await baseAppClient.post(GET_PATIENT_ALLERGIES,
        onSuccess: (response, statusCode) async {
      allergies.clear();
      response['Patient_Allergies'].forEach((allergy) {
        allergies.add(Allergy.fromJson(allergy));
      });
    }, onFailure: (String error, int statusCode) {
      hasError = true;
      super.error = error;
    }, body: body);
  }
}
