import 'package:get/get.dart';

/// 病人信息
class PatientInfo {
  PatientInfo({
    required this.patientCode,
    this.isValid,
    this.name,
    this.phone,
    this.identityCard,
    this.insuranceCode,
    this.age,
    this.sex,
    this.species,
    this.breed,
    this.headImgUrl,
    this.referralRecordCode,
    this.isReferral,
    this.birthday,
    this.ageUnits = 'Year',
    this.ageYear,
    this.ageMonth,
    this.ageWeek,
    this.ageDay,
    this.outUserName,
    this.inUserName,
    this.organizationName,
    this.anamnesis,
    this.createTime,
    this.visibleName,
    this.medicalHistory,
    this.examiningPhysician,
  });
  bool? isValid = true;
  String patientCode;

  ///姓名（可能是隐私保护的，带**的）
  String? name;
  String? phone;
  String? identityCard;
  String? insuranceCode;
  String? age;
  String? sex;
  String? species;
  String? breed;
  String? headImgUrl;
  String? referralRecordCode;
  String? birthday;
  String? ageUnits;
  String? ageYear;
  String? ageMonth;
  String? ageWeek;
  String? ageDay;
  bool? isReferral;
  String? outUserName;
  String? inUserName;
  String? organizationName;
  String? anamnesis;

  ///病史
  String? medicalHistory;

  ///检查医师
  String? examiningPhysician;

  ///明文姓名（非加密）
  String? visibleName;
  DateTime? createTime;
  Rx<bool> _checked = Rx(false);
  Rx<bool> _exportMode = Rx(false);

  ///是否全选
  set isChecked(bool v) => _checked.value = v;
  bool get isChecked => _checked.value;

  ///是否为导出模式
  set exportMode(bool v) => _exportMode.value = v;
  bool get exportMode => _exportMode.value;

  factory PatientInfo.fromJson(Map<String, dynamic> map) {
    return PatientInfo(
      patientCode: map['PatientCode'],
      isValid: map['IsValid'],
      name: map['Name'],
      phone: map['Phone'],
      identityCard: map['IdentityCard'],
      insuranceCode: map['InsuranceCode'],
      age: map['Age'],
      sex: map['Sex'],
      species: map['Species'],
      breed: map['Breed'],
      headImgUrl: map['HeadImgUrl'],
      referralRecordCode: map['ReferralRecordCode'],
      birthday: map['Birthday'],
      ageUnits: map['AgeUnits'],
      ageDay: map['AgeDay'],
      ageWeek: map['AgeWeek'],
      ageMonth: map['AgeMonth'],
      ageYear: map['AgeYear'],
      inUserName: map['InUserName'],
      outUserName: map['OutUserName'],
      medicalHistory: map["MedicalHistory"],
      examiningPhysician: map["ExaminingPhysician"],
    );
  }

  Map<String, dynamic> toJson() {
    final map = Map<String, dynamic>();
    map['PatientCode'] = patientCode;
    map['IsValid'] = isValid;
    map['Name'] = name;
    map['Phone'] = phone;
    map['IdentityCard'] = identityCard;
    map['InsuranceCode'] = insuranceCode;
    map['Age'] = age;
    map['Sex'] = sex;
    map['Species'] = species;
    map['Breed'] = breed;
    map['HeadImgUrl'] = headImgUrl;
    map['ReferralRecordCode'] = referralRecordCode;
    map['Birthday'] = birthday;
    map['AgeUnits'] = ageUnits;
    map['AgeDay'] = ageDay;
    map['AgeWeek'] = ageWeek;
    map['AgeMonth'] = ageMonth;
    map['AgeYear'] = ageYear;
    map['InUserName'] = inUserName;
    map['OutUserName'] = outUserName;
    return map;
  }
}
