import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/model/PatientSearchRequestModel.dart';
import 'package:doctor_app_flutter/core/service/base/base_service.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';

class OutPatientService extends BaseService {
  List<PatiantInformtion> _patientList = [];
  List<PatiantInformtion> get patientList => _patientList;


  Future getOutPatient(PatientSearchRequestModel patientSearchRequestModel) async {
    hasError = false;
    await baseAppClient.post(
      GET_MY_OUT_PATIENT,
      onSuccess: (dynamic response, int statusCode) {
        _patientList.clear();
        response['List_MyOutPatient'].forEach((v) {
          _patientList.add(PatiantInformtion.fromJson(v));
        });
      },
      onFailure: (String error, int statusCode) {
        hasError = true;
        super.error = error;
      },
      body: patientSearchRequestModel.toJson(),
    );
  }
  Future getPatientFileInformation(PatientSearchRequestModel patientSearchRequestModel) async {
    hasError = false;
    await baseAppClient.post(
      PRM_SEARCH_PATIENT,
      onSuccess: (dynamic response, int statusCode) {
        _patientList.clear();
        response['GetPatientFileInformation_PRMList'].forEach((v) {
          _patientList.add(PatiantInformtion.fromJson(v));
        });
      },
      onFailure: (String error, int statusCode) {
        hasError = true;
        super.error = error;
      },
      body: patientSearchRequestModel.toJson(),
    );
  }
}
