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 PatientInPatientService extends BaseService {
  List<PatiantInformtion> inPatientList = List();

  Future getInPatientList(
      PatientSearchRequestModel requestModel, bool isMyInpatient) async {
    hasError = false;
    await getDoctorProfile();

    if (isMyInpatient) {
      requestModel.doctorID = doctorProfile.doctorID;
    }else {
      requestModel.doctorID = 0;
    }

    await baseAppClient.post(
      GET_PATIENT_IN_PATIENT_LIST,
      onSuccess: (dynamic response, int statusCode) {
        inPatientList.clear();

        response['List_MyInPatient'].forEach((v) {
          inPatientList.add(PatiantInformtion.fromJson(v));
        });
      },
      onFailure: (String error, int statusCode) {
        hasError = true;
        super.error = error;
      },
      body: requestModel.toJson(),
    );
  }
}
