import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/vital_sign/vital_sign_res_model.dart';
import 'package:diplomaticquarterapp/core/service/medical/vital_sign_service.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';

import '../../../locator.dart';

class VitalSignViewModel extends BaseViewModel {
  VitalSignService _vitalSignService = locator<VitalSignService>();

  List<VitalSignResModel> get vitalSignResModelList =>
      _vitalSignService.vitalSignResModelList;

  getPatientRadOrders({int appointmentNo, int projectID}) async {
    setState(ViewState.Busy);

    if (appointmentNo != null && projectID != null) {
      await _vitalSignService.getPatientRadOrders(
          appointmentNo: appointmentNo, projectID: projectID);
    } else {
      await _vitalSignService.getPatientRadOrders();
    }
    if (_vitalSignService.hasError) {
      error = _vitalSignService.error;
      setState(ViewState.Error);
    } else
      setState(ViewState.Idle);
  }
}
