import 'package:doctor_app_flutter/core/enum/view_state.dart';
import 'package:doctor_app_flutter/core/model/ER_sign_in/doctor_ER_sign_assessment_req_model.dart';
import 'package:doctor_app_flutter/core/service/patient_medical_file/ER_signin/ER_signin_service.dart';
import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart';
import 'package:doctor_app_flutter/locator.dart';

class ERSignInViewModel extends BaseViewModel {
  bool hasError = false;

  ERSignInService _ERSignInService = locator<ERSignInService>();

  Future signInERPatient({required int patientId, required int signInType}) async {
    hasError = false;
    await getDoctorProfile();
    DoctorErSignAssessmentReqModel doctorErSignAssessmentReqModel = new DoctorErSignAssessmentReqModel(signInType: signInType, loginDoctorID: doctorProfile!.doctorID, patientID: patientId);
    setState(ViewState.BusyLocal);
    await _ERSignInService.signInERPatient(doctorErSignAssessmentReqModel: doctorErSignAssessmentReqModel);
    if (_ERSignInService.hasError) {
      error = _ERSignInService.error;
      setState(ViewState.ErrorLocal);
    } else
      setState(ViewState.Idle);
  }
}
