import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/service/base/base_service.dart';
import 'package:doctor_app_flutter/models/SOAP/GetAssessmentResModel.dart';
import 'package:doctor_app_flutter/models/pharmacies/pharmacies_List_request_model.dart';
import 'package:doctor_app_flutter/models/pharmacies/pharmacies_items_request_model.dart';

class MedicineService extends BaseService {
  var _pharmacyItemsList = [];
  var _pharmaciesList = [];
  get pharmacyItemsList => _pharmacyItemsList;
  get pharmaciesList => _pharmaciesList;
  String searchText='';
  List<GetAssessmentResModel> patientAssessmentList = [];

  PharmaciesItemsRequestModel _itemsRequestModel =
      PharmaciesItemsRequestModel();
  PharmaciesListRequestModel _listRequestModel = PharmaciesListRequestModel();

  Future getMedicineItem(String itemName) async {
    _itemsRequestModel.pHRItemName = itemName;
    searchText =itemName;
    await baseAppClient.post(
      PHARMACY_ITEMS_URL,
      onSuccess: (dynamic response, int statusCode) {
        _pharmacyItemsList.clear();
        _pharmacyItemsList = response['ListPharmcy_Region_enh'];
      },
      onFailure: (String error, int statusCode) {
        hasError = true;
        super.error = error;
      },
      body: _itemsRequestModel.toJson(),
    );
  }

  Future getPharmaciesList(int itemId) async {
    _listRequestModel.itemID = itemId;
    await baseAppClient.post(
      PHARMACY_LIST_URL,
      onSuccess: (dynamic response, int statusCode) {
        _pharmaciesList.clear();
        _pharmaciesList = response['PharmList'];
      },
      onFailure: (String error, int statusCode) {
        hasError = true;
        super.error = error;
      },
      body: _listRequestModel.toJson(),
    );
  }
}
