import 'package:fis_jsonrpc/rpc.dart';
import 'package:get/get.dart';

class CreatecheckState {
  final Rx<String> _patientCode = Rx('');
  final Rx<String> _organizationName = Rx('');
  final Rx<String> _selectString = Rx('GestationalAgeOrigin.LMP');
  final Rx<Map<String, dynamic>> _patientInfo = Rx(<String, dynamic>{});
  // final Rx<Map<String, dynamic>> _contents = Rx(<String, dynamic>{});
  // final Map<String, dynamic>  _weekAndDayContents = <String, dynamic>{}.obs;
  /// TODO 待优化 保存的检查信息

  final Map<String, dynamic> contents = <String, dynamic>{}.obs;

  /// TODO 保存的周——日组件的检查信息

  final Map<String, dynamic> weekAndDayContents = <String, dynamic>{}.obs;
  final Rx<List<Map<String, dynamic>>> _checkLists =
      Rx(<Map<String, dynamic>>[]);
  final Rx<List<SelectModel>> _deviceOptions = Rx(<SelectModel>[]);
  final Rx<List> _selectCheckList = Rx([]);
  final Rx<String?> _deviceCode = Rx(null);
  final Rx<List<SelectModel>> _checkHasSelect = Rx(<SelectModel>[]);
  final Rx<List<DataItemDTO>> _contentsList = Rx(<DataItemDTO>[]);
  final Rx<List<PatientInfoExt>> _patientInfoExt = Rx(<PatientInfoExt>[]);
  final Rx<DataItemDTO> _contentsListItem = Rx(DataItemDTO());

  /// 病人编码
  set patientCode(value) => _patientCode.value = value;
  String get patientCode => _patientCode.value;

  /// 病人信息
  set patientInfo(value) => _patientInfo.value = value;
  get patientInfo => _patientInfo.value;

  /// 选中的项
  set selectCheckList(List value) => _selectCheckList(value);
  List get selectCheckList => _selectCheckList.value;

  /// 组织名称
  set organizationName(value) => _organizationName.value = value;
  get organizationName => _organizationName.value;

  /// 选择列表
  set checkLists(List<Map<String, dynamic>> value) => _checkLists(value);
  List<Map<String, dynamic>> get checkLists => _checkLists.value;

  /// 描述项
  set deviceOptions(List<SelectModel> value) => _deviceOptions(value);
  List<SelectModel> get deviceOptions => _deviceOptions.value;

  /// 选中的检查
  set checkHasSelect(List<SelectModel> value) => _checkHasSelect(value);
  List<SelectModel> get checkHasSelect => _checkHasSelect.value;

  /// 下发设备编码
  set deviceCode(value) => _deviceCode.value = value;
  get deviceCode => _deviceCode.value;

  /// 重构保存每项的 单独检查项目
  set contentsList(List<DataItemDTO> value) => _contentsList(value);
  List<DataItemDTO> get contentsList => _contentsList.value;

  /// 重构保存
  set patientInfoExt(List<PatientInfoExt> value) => _patientInfoExt(value);
  List<PatientInfoExt> get patientInfoExt => _patientInfoExt.value;

  /// 计算方式
  set selectString(value) => _selectString.value = value;
  get selectString => _selectString.value;

  /// 设置单项最小单元
  set contentsListItem(DataItemDTO value) => _contentsListItem.value = value;
  DataItemDTO get contentsListItem => _contentsListItem.value;
}

class SelectModel {
  SelectModel({required this.name, required this.code});
  final String name;
  final String code;
}
