import 'package:fis_ui/index.dart';
import 'package:flyinsono/architecture/states/states.dart';
import 'package:flyinsono/managers/interfaces/entities/patient_Info.dart';
import 'package:flyinsono/views/desktop/appointment_consultation/entitys/patient_model.dart';
import 'package:flyinsono/views/desktop/appointment_consultation/index.dart';
import 'package:get/get.dart';

import 'entitys/appointment_model.dart';

/// 预约会诊申请状态
class AppotintmentConsultationState {
  final Rx<List<PatientInfo>> _patientList = Rx(<PatientInfo>[]);
  final Rx<String> _patientName = Rx('');
  final Rx<PatientInfo?> _currentPatient = Rx(
    PatientInfo(
      isValid: true,
      createTime: DateTime.now(),
      patientCode: '',
      ageUnits: 'Year',
    ),
  );
  final Rx<List<FSelectModel>> _deviceList = Rx(<FSelectModel>[]);
  final Rx<List<FSelectModel>> _scannDoctorList = Rx(<FSelectModel>[]);
  final Rx<List<FSelectModel>> _scanPositionsList = Rx(<FSelectModel>[]);
  final Rx<List<FSelectModel>> _consultationInstitution = Rx(<FSelectModel>[]);
  final Rx<List<FSelectModel>> _competentExperts = Rx(<FSelectModel>[]);
  final Rx<List<FSelectModel>> _organizationAssistants = Rx(<FSelectModel>[]);
  final Rx<AppointmentInformations?> _appointmentInformation =
      Rx(AppointmentInformations());
  final Rx<bool> _isAddPatient = Rx(true);
  final Rx<String> _primaryDiagnosis = Rx('');
  final Rx<List<PatientModel>> _patientKeyList = Rx(<PatientModel>[]);
  final Rx<List<AppointmentModel>> _appointmentKeyList =
      Rx(<AppointmentModel>[]);
  final Rx<String> _scanPositionsString = Rx('');

  /// 病人数据列表
  List<PatientInfo> get patientList => _patientList.value;
  set patientList(List<PatientInfo> value) => _patientList(value);

  /// 输入的病人名字
  String get patientName => _patientName.value;
  set patientName(String value) => _patientName(value);

  /// 当前选中的病人
  PatientInfo get currentPatient =>
      _currentPatient.value ??
      PatientInfo(
        isValid: true,
        createTime: DateTime.now(),
        patientCode: '',
        ageUnits: 'Year',
      );
  set currentPatient(PatientInfo value) => _currentPatient(value);

  /// 个人设备列表
  List<FSelectModel> get deviceList => _deviceList.value;
  set deviceList(List<FSelectModel> value) => _deviceList(value);

  /// 扫查部位列表
  List<FSelectModel> get scanPositionsList => _scanPositionsList.value;
  set scanPositionsList(List<FSelectModel> value) => _scanPositionsList(value);

  /// 扫查医生列表
  List<FSelectModel> get scannDoctorList => _scannDoctorList.value;
  set scannDoctorList(List<FSelectModel> value) => _scannDoctorList(value);

  /// 会诊机构列表
  List<FSelectModel> get consultationInstitution =>
      _consultationInstitution.value;
  set consultationInstitution(List<FSelectModel> value) =>
      _consultationInstitution(value);

  /// 主管专家列表
  List<FSelectModel> get competentExperts => _competentExperts.value;
  set competentExperts(List<FSelectModel> value) => _competentExperts(value);

  /// 申请人列表
  List<FSelectModel> get organizationAssistants =>
      _organizationAssistants.value;
  set organizationAssistants(List<FSelectModel> value) =>
      _organizationAssistants(value);

  /// 预约信息对象
  AppointmentInformations get appointmentInformation =>
      _appointmentInformation.value ?? AppointmentInformations();
  set appointmentInformation(AppointmentInformations value) =>
      _appointmentInformation(value);

  /// 是否新增病人
  bool get isAddPatient => _isAddPatient.value;
  set isAddPatient(bool value) => _isAddPatient(value);

  /// 初步诊断
  String get primaryDiagnosis => _primaryDiagnosis.value;
  set primaryDiagnosis(String value) => _primaryDiagnosis(value);

  /// 病人配置列表
  List<PatientModel> get patientKeyList => _patientKeyList.value;
  set patientKeyList(List<PatientModel> value) => _patientKeyList(value);

  /// 预约信息配置列表
  List<AppointmentModel> get appointmentKeyList => _appointmentKeyList.value;
  set appointmentKeyList(List<AppointmentModel> value) =>
      _appointmentKeyList(value);

  /// 扫查部位
  String get scanPositionsString => _scanPositionsString.value;
  set scanPositionsString(String value) => _scanPositionsString(value);

  /// 专家助理才有的权限 申请人权限
  bool get isApplyUserField => Store.user.hasFeature('ApplyUserField');

  ///之前已选择的会诊设备
  String? selectedDeviceCode;

  ///之前已选择的扫查医生
  String? appointmentDocter;

  ///之前已选择的会诊机构
  String? selectedconsultationInstitution;
}
