import 'package:fis_jsonrpc/rpc.dart';
import 'package:get/get.dart';
import 'package:vnoteapp/architecture/utils/datetime.dart';
import 'package:vnoteapp/consts/rpc_enum_labels.dart';

class PatientDetailState {
  final Rx<PatientDTO> _dto = Rx<PatientDTO>(
    PatientDTO(
      patientName: "",
      patientGender: GenderEnum.Unknown,
      phone: "",
      birthday: DateTime(1900, 1, 1),
      patientAddress: "",
      crowdLabels: null,
    ),
  );

  /// 病人编号
  String code = "";

  /// 姓名
  String get name => _dto.value.patientName!;

  /// 年龄
  int get age => DataTimeUtils.calculateAge(_dto.value.birthday!);

  /// 手机号
  String get phone => _dto.value.phone!;

  /// 地址
  String get address => _dto.value.patientAddress!;

  /// 性别
  String get genderDesc => RpcEnumLabels.gender[_dto.value.patientGender]!;

  /// 人群分类编号集合
  List<String>? get crowdLabelCodes => _dto.value.crowdLabels;

  void updateDto(PatientDTO dto) {
    _dto.value = dto;
  }
}
