123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380 |
- import 'dart:convert';
- import 'package:fis_jsonrpc/rpc.dart';
- import 'package:get/get.dart';
- import 'package:intl/intl.dart';
- import 'package:vitalapp/architecture/defines.dart';
- import 'package:vitalapp/architecture/utils/datetime.dart';
- import 'package:vitalapp/components/dialog_profile_time_input.dart';
- import 'package:vitalapp/consts/rpc_enum_labels.dart';
- import 'widgets/ext_model.dart';
- class HealthModel {
- final List<String>? historyDrugAllergies;
- final List<String>? historyExposure;
- final List<String>? historyPreviousDisease;
- final String? historyPreviousDiseaseOther;
- ///既往疾病史-职业病
- final String? historyPreviousDiseaseOccupationalDisease;
- ///既往疾病史-恶性肿瘤
- final String? historyPreviousDiseaseMalignancy;
- final String? operation;
- final String? trauma;
- final String? transfusion;
- final List<String>? father;
- final String? fatherOther;
- final List<String>? mother;
- final String? motherOther;
- final List<String>? sibling;
- final String? siblingOther;
- final List<String>? children;
- final String? childrenOther;
- final String? historyGenetic;
- final String? historyGeneticName;
- final List<String>? disabilitySituation;
- final String? disabilitySituationOther;
- final String? kitchenExhaustFacilities;
- final String? fuel;
- final String? fuelOther;
- final String? drinkingWater;
- final String? drinkingWaterOther;
- final String? toilet;
- final String? animalPen;
- final String? historyDrugAllergiesOther;
- final VProfileTimeInputModel? operationOne;
- final VProfileTimeInputModel? operationTwo;
- final VProfileTimeInputModel? traumaOne;
- final VProfileTimeInputModel? traumaTwo;
- final VProfileTimeInputModel? transfusionOne;
- final VProfileTimeInputModel? transfusionTwo;
- final Map<String, DateTime> diseaseDiagnosisTime;
- ///详细信息
- final String? workUnit; //工作单位
- final String? contactName; //联系人姓名
- final String? contactPhone; //联系人电话
- final String? permanentlyResideType; //常住类型
- final String? bloodType; //血型
- final String? rh; //RH
- final String? educationLevel; //文化程度
- final String? career; //职业
- final String? maritalStatus; //婚姻状况
- final String? providerPayments; //医疗费用支付方式
- final String? providerPaymentsOther; //医疗费用支付方式
- HealthModel({
- required this.historyDrugAllergies,
- required this.historyExposure,
- required this.historyPreviousDisease,
- required this.historyPreviousDiseaseOther,
- required this.historyPreviousDiseaseOccupationalDisease,
- required this.historyPreviousDiseaseMalignancy,
- required this.operation,
- required this.trauma,
- required this.transfusion,
- required this.father,
- required this.fatherOther,
- required this.mother,
- required this.motherOther,
- required this.sibling,
- required this.siblingOther,
- required this.children,
- required this.childrenOther,
- required this.historyGenetic,
- required this.historyGeneticName,
- required this.disabilitySituation,
- required this.disabilitySituationOther,
- required this.kitchenExhaustFacilities,
- required this.fuel,
- required this.fuelOther,
- required this.drinkingWater,
- required this.drinkingWaterOther,
- required this.toilet,
- required this.animalPen,
- required this.historyDrugAllergiesOther,
- required this.operationOne,
- required this.operationTwo,
- required this.traumaOne,
- required this.traumaTwo,
- required this.transfusionOne,
- required this.transfusionTwo,
- required this.diseaseDiagnosisTime,
- required this.workUnit,
- required this.contactName,
- required this.contactPhone,
- required this.permanentlyResideType,
- required this.bloodType,
- required this.rh,
- required this.educationLevel,
- required this.career,
- required this.maritalStatus,
- required this.providerPayments,
- required this.providerPaymentsOther,
- });
- factory HealthModel.fromJson(Map<String, dynamic> jsonMap) {
- return HealthModel(
- historyDrugAllergies:
- jsonMap["historyDrugAllergies"]?.cast<String>().toList(),
- historyExposure: jsonMap["historyExposure"]?.cast<String>().toList(),
- historyPreviousDisease:
- jsonMap["historyPreviousDisease"]?.cast<String>().toList(),
- historyPreviousDiseaseOther: jsonMap["historyPreviousDiseaseOther"],
- historyPreviousDiseaseOccupationalDisease:
- jsonMap["historyPreviousDiseaseOccupationalDisease"],
- historyPreviousDiseaseMalignancy:
- jsonMap["historyPreviousDiseaseMalignancy"],
- operation: jsonMap["operation"],
- trauma: jsonMap["trauma"],
- transfusion: jsonMap["transfusion"],
- father: jsonMap["father"]?.cast<String>().toList(),
- fatherOther: jsonMap["fatherOther"],
- mother: jsonMap["mother"]?.cast<String>().toList(),
- motherOther: jsonMap["motherOther"],
- sibling: jsonMap["sibling"]?.cast<String>().toList(),
- siblingOther: jsonMap["siblingOther"],
- children: jsonMap["children"]?.cast<String>().toList(),
- childrenOther: jsonMap["childrenOther"],
- historyGenetic: jsonMap["historyGenetic"],
- historyGeneticName: jsonMap["historyGeneticName"],
- disabilitySituation:
- jsonMap["disabilitySituation"]?.cast<String>().toList(),
- disabilitySituationOther: jsonMap["disabilitySituationOther"],
- kitchenExhaustFacilities: jsonMap["kitchenExhaustFacilities"],
- fuel: jsonMap["fuel"],
- fuelOther: jsonMap["fuelOther"],
- drinkingWater: jsonMap["drinkingWater"],
- drinkingWaterOther: jsonMap["drinkingWaterOther"],
- toilet: jsonMap["toilet"],
- animalPen: jsonMap["animalPen"],
- historyDrugAllergiesOther: jsonMap["historyDrugAllergiesOther"],
- operationOne: jsonMap["operationOne"] != null &&
- jsonMap["operationOne"] != "{}"
- ? VProfileTimeInputModel.fromJson(jsonDecode(jsonMap["operationOne"]))
- : null,
- operationTwo: jsonMap["operationTwo"] != null &&
- jsonMap["operationTwo"] != "{}"
- ? VProfileTimeInputModel.fromJson(jsonDecode(jsonMap["operationTwo"]))
- : null,
- traumaOne: jsonMap["traumaOne"] != null && jsonMap["traumaOne"] != "{}"
- ? VProfileTimeInputModel.fromJson(jsonDecode(jsonMap["traumaOne"]))
- : null,
- traumaTwo: jsonMap["traumaTwo"] != null && jsonMap["traumaTwo"] != "{}"
- ? VProfileTimeInputModel.fromJson(jsonDecode(jsonMap["traumaTwo"]))
- : null,
- transfusionOne:
- jsonMap["transfusionOne"] != null && jsonMap["transfusionOne"] != "{}"
- ? VProfileTimeInputModel.fromJson(
- jsonDecode(jsonMap["transfusionOne"]))
- : null,
- transfusionTwo:
- jsonMap["transfusionTwo"] != null && jsonMap["transfusionTwo"] != "{}"
- ? VProfileTimeInputModel.fromJson(
- jsonDecode(jsonMap["transfusionTwo"]))
- : null,
- diseaseDiagnosisTime:
- Map<String, dynamic>.from(jsonDecode(jsonMap["diseaseDiagnosisTime"]))
- .map((key, value) {
- return MapEntry(key, DateTime.parse(value));
- }),
- workUnit: jsonMap["workUnit"],
- contactName: jsonMap["contactName"],
- contactPhone: jsonMap["contactPhone"],
- permanentlyResideType: jsonMap["permanentlyResideType"],
- bloodType: jsonMap["bloodType"],
- rh: jsonMap["rh"],
- educationLevel: jsonMap["educationLevel"],
- career: jsonMap["career"],
- maritalStatus: jsonMap["maritalStatus"],
- providerPayments: jsonMap["providerPayments"],
- providerPaymentsOther: jsonMap["providerPaymentsOther"],
- );
- }
- Map<String, dynamic> toJson() {
- Map<String, dynamic> jsonMap = <String, dynamic>{};
- {
- if (historyDrugAllergies != null) {
- jsonMap["historyDrugAllergies"] = historyDrugAllergies;
- }
- if (historyExposure != null) jsonMap["historyExposure"] = historyExposure;
- if (historyPreviousDisease != null) {
- jsonMap["historyPreviousDisease"] = historyPreviousDisease;
- }
- if (historyPreviousDiseaseOther != null) {
- jsonMap["historyPreviousDiseaseOther"] = historyPreviousDiseaseOther;
- }
- if (historyPreviousDiseaseOccupationalDisease != null) {
- jsonMap["historyPreviousDiseaseOccupationalDisease"] =
- historyPreviousDiseaseOccupationalDisease;
- }
- if (historyPreviousDiseaseMalignancy != null) {
- jsonMap["historyPreviousDiseaseMalignancy"] =
- historyPreviousDiseaseMalignancy;
- }
- if (operation != null) jsonMap["operation"] = operation;
- if (trauma != null) jsonMap["trauma"] = trauma;
- if (transfusion != null) jsonMap["transfusion"] = transfusion;
- if (father != null) jsonMap["father"] = father;
- if (fatherOther != null) jsonMap["fatherOther"] = fatherOther;
- if (mother != null) jsonMap["mother"] = mother;
- if (motherOther != null) jsonMap["motherOther"] = motherOther;
- if (sibling != null) jsonMap["sibling"] = sibling;
- if (siblingOther != null) jsonMap["siblingOther"] = siblingOther;
- if (children != null) jsonMap["children"] = children;
- if (childrenOther != null) jsonMap["childrenOther"] = childrenOther;
- if (historyGenetic != null) jsonMap["historyGenetic"] = historyGenetic;
- if (historyGeneticName != null) {
- jsonMap["historyGeneticName"] = historyGeneticName;
- }
- if (disabilitySituation != null) {
- jsonMap["disabilitySituation"] = disabilitySituation;
- }
- if (disabilitySituationOther != null) {
- jsonMap["disabilitySituationOther"] = disabilitySituationOther;
- }
- if (kitchenExhaustFacilities != null) {
- jsonMap["kitchenExhaustFacilities"] = kitchenExhaustFacilities;
- }
- if (fuel != null) jsonMap["fuel"] = fuel;
- if (fuelOther != null) jsonMap["fuelOther"] = fuelOther;
- if (drinkingWater != null) jsonMap["drinkingWater"] = drinkingWater;
- if (drinkingWaterOther != null) {
- jsonMap["drinkingWaterOther"] = drinkingWaterOther;
- }
- if (toilet != null) jsonMap["toilet"] = toilet;
- if (animalPen != null) jsonMap["animalPen"] = animalPen;
- if (historyDrugAllergiesOther != null) {
- jsonMap["historyDrugAllergiesOther"] = historyDrugAllergiesOther;
- }
- if (operationOne != null) {
- jsonMap["operationOne"] = jsonEncode(operationOne?.toJson());
- }
- if (operationTwo != null) {
- jsonMap["operationTwo"] = jsonEncode(operationTwo?.toJson());
- }
- if (traumaOne != null) {
- jsonMap["traumaOne"] = jsonEncode(traumaOne?.toJson());
- }
- if (traumaTwo != null) {
- jsonMap["traumaTwo"] = jsonEncode(traumaTwo?.toJson());
- }
- if (transfusionOne != null) {
- jsonMap["transfusionOne"] = jsonEncode(transfusionOne?.toJson());
- }
- if (transfusionTwo != null) {
- jsonMap["transfusionTwo"] = jsonEncode(transfusionTwo?.toJson());
- }
- jsonMap["diseaseDiagnosisTime"] = jsonEncode(diseaseDiagnosisTime
- .map((key, value) => MapEntry(key, value.toIso8601String())));
- if (workUnit != null) {
- jsonMap["workUnit"] = workUnit;
- }
- if (contactName != null) {
- jsonMap["contactName"] = contactName;
- }
- if (contactPhone != null) {
- jsonMap["contactPhone"] = contactPhone;
- }
- if (permanentlyResideType != null) {
- jsonMap["permanentlyResideType"] = permanentlyResideType;
- }
- if (bloodType != null) {
- jsonMap["bloodType"] = bloodType;
- }
- if (rh != null) {
- jsonMap["rh"] = rh;
- }
- if (educationLevel != null) {
- jsonMap["educationLevel"] = educationLevel;
- }
- if (career != null) {
- jsonMap["career"] = career;
- }
- if (maritalStatus != null) {
- jsonMap["maritalStatus"] = maritalStatus;
- }
- if (providerPayments != null) {
- jsonMap["providerPayments"] = providerPayments;
- }
- if (providerPaymentsOther != null) {
- jsonMap["providerPaymentsOther"] = providerPaymentsOther;
- }
- return jsonMap;
- }
- }
- }
- class PatientInfoState {
- final Rx<NavAnchorType> _anchor = NavAnchorType.base.obs;
- /// 导航锚点
- NavAnchorType get anchor => _anchor.value;
- set anchor(NavAnchorType val) => _anchor.updateValue(val);
- final Rx<PatientDTO> _dto = Rx<PatientDTO>(
- PatientDTO(),
- );
- String healthCode = "";
- DateTime extractBirthDateFromIDCard(String idCardNumber) {
- final idCardRegex = RegExp(r'^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})(\d|X)$');
- final match = idCardRegex.firstMatch(idCardNumber);
- if (match != null) {
- final year = int.parse(match.group(2)!);
- final month = int.parse(match.group(3)!);
- final day = int.parse(match.group(4)!);
- final birthDate = DateTime(year, month, day);
- return birthDate;
- }
- return DateTime(1970, 1, 1); // 返回一个默认值,表示无法提取出生日期
- }
- }
- enum NavAnchorType {
- base,
- detail,
- health,
- }
|