import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/medical_file_model.dart';
import 'package:doctor_app_flutter/core/service/medical_file_service.dart';

import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart';
import 'package:doctor_app_flutter/locator.dart';

class MedicalFileViewModel extends BaseViewModel {
  bool hasError = false;
  MedicalFileService _medicalFileService = locator<MedicalFileService>();

  List<MedicalFileModel> get medicalFileList =>
      _medicalFileService.medicalFileList;

  Future getMedicalFile({int mrn}) async {
    hasError = false;
    //_insuranceCardService.clearInsuranceCard();
    setState(ViewState.Busy);
    await _medicalFileService.getMedicalFile(mrn: mrn);
    if (_medicalFileService.hasError) {
      error = _medicalFileService.error;
      setState(ViewState.ErrorLocal);
    } else
      setState(ViewState.Idle);
  }
}
