state.dart 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. import 'dart:convert';
  2. import 'package:fis_jsonrpc/rpc.dart';
  3. import 'package:get/get.dart';
  4. import 'package:intl/intl.dart';
  5. import 'package:vitalapp/architecture/defines.dart';
  6. import 'package:vitalapp/architecture/utils/datetime.dart';
  7. import 'package:vitalapp/components/dialog_profile_time_input.dart';
  8. import 'package:vitalapp/consts/rpc_enum_labels.dart';
  9. import 'widgets/ext_model.dart';
  10. class HealthModel {
  11. final List<String>? historyDrugAllergies;
  12. final List<String>? historyExposure;
  13. final List<String>? historyPreviousDisease;
  14. final String? historyPreviousDiseaseOther;
  15. ///既往疾病史-职业病
  16. final String? historyPreviousDiseaseOccupationalDisease;
  17. ///既往疾病史-恶性肿瘤
  18. final String? historyPreviousDiseaseMalignancy;
  19. final String? operation;
  20. final String? trauma;
  21. final String? transfusion;
  22. final List<String>? father;
  23. final String? fatherOther;
  24. final List<String>? mother;
  25. final String? motherOther;
  26. final List<String>? sibling;
  27. final String? siblingOther;
  28. final List<String>? children;
  29. final String? childrenOther;
  30. final String? historyGenetic;
  31. final String? historyGeneticName;
  32. final List<String>? disabilitySituation;
  33. final String? disabilitySituationOther;
  34. final String? kitchenExhaustFacilities;
  35. final String? fuel;
  36. final String? fuelOther;
  37. final String? drinkingWater;
  38. final String? drinkingWaterOther;
  39. final String? toilet;
  40. final String? animalPen;
  41. final String? historyDrugAllergiesOther;
  42. final VProfileTimeInputModel? operationOne;
  43. final VProfileTimeInputModel? operationTwo;
  44. final VProfileTimeInputModel? traumaOne;
  45. final VProfileTimeInputModel? traumaTwo;
  46. final VProfileTimeInputModel? transfusionOne;
  47. final VProfileTimeInputModel? transfusionTwo;
  48. final Map<String, DateTime> diseaseDiagnosisTime;
  49. ///详细信息
  50. final String? workUnit; //工作单位
  51. final String? contactName; //联系人姓名
  52. final String? contactPhone; //联系人电话
  53. final String? permanentlyResideType; //常住类型
  54. final String? bloodType; //血型
  55. final String? rh; //RH
  56. final String? educationLevel; //文化程度
  57. final String? career; //职业
  58. final String? maritalStatus; //婚姻状况
  59. final String? providerPayments; //医疗费用支付方式
  60. final String? providerPaymentsOther; //医疗费用支付方式
  61. HealthModel({
  62. required this.historyDrugAllergies,
  63. required this.historyExposure,
  64. required this.historyPreviousDisease,
  65. required this.historyPreviousDiseaseOther,
  66. required this.historyPreviousDiseaseOccupationalDisease,
  67. required this.historyPreviousDiseaseMalignancy,
  68. required this.operation,
  69. required this.trauma,
  70. required this.transfusion,
  71. required this.father,
  72. required this.fatherOther,
  73. required this.mother,
  74. required this.motherOther,
  75. required this.sibling,
  76. required this.siblingOther,
  77. required this.children,
  78. required this.childrenOther,
  79. required this.historyGenetic,
  80. required this.historyGeneticName,
  81. required this.disabilitySituation,
  82. required this.disabilitySituationOther,
  83. required this.kitchenExhaustFacilities,
  84. required this.fuel,
  85. required this.fuelOther,
  86. required this.drinkingWater,
  87. required this.drinkingWaterOther,
  88. required this.toilet,
  89. required this.animalPen,
  90. required this.historyDrugAllergiesOther,
  91. required this.operationOne,
  92. required this.operationTwo,
  93. required this.traumaOne,
  94. required this.traumaTwo,
  95. required this.transfusionOne,
  96. required this.transfusionTwo,
  97. required this.diseaseDiagnosisTime,
  98. required this.workUnit,
  99. required this.contactName,
  100. required this.contactPhone,
  101. required this.permanentlyResideType,
  102. required this.bloodType,
  103. required this.rh,
  104. required this.educationLevel,
  105. required this.career,
  106. required this.maritalStatus,
  107. required this.providerPayments,
  108. required this.providerPaymentsOther,
  109. });
  110. factory HealthModel.fromJson(Map<String, dynamic> jsonMap) {
  111. return HealthModel(
  112. historyDrugAllergies:
  113. jsonMap["historyDrugAllergies"]?.cast<String>().toList(),
  114. historyExposure: jsonMap["historyExposure"]?.cast<String>().toList(),
  115. historyPreviousDisease:
  116. jsonMap["historyPreviousDisease"]?.cast<String>().toList(),
  117. historyPreviousDiseaseOther: jsonMap["historyPreviousDiseaseOther"],
  118. historyPreviousDiseaseOccupationalDisease:
  119. jsonMap["historyPreviousDiseaseOccupationalDisease"],
  120. historyPreviousDiseaseMalignancy:
  121. jsonMap["historyPreviousDiseaseMalignancy"],
  122. operation: jsonMap["operation"],
  123. trauma: jsonMap["trauma"],
  124. transfusion: jsonMap["transfusion"],
  125. father: jsonMap["father"]?.cast<String>().toList(),
  126. fatherOther: jsonMap["fatherOther"],
  127. mother: jsonMap["mother"]?.cast<String>().toList(),
  128. motherOther: jsonMap["motherOther"],
  129. sibling: jsonMap["sibling"]?.cast<String>().toList(),
  130. siblingOther: jsonMap["siblingOther"],
  131. children: jsonMap["children"]?.cast<String>().toList(),
  132. childrenOther: jsonMap["childrenOther"],
  133. historyGenetic: jsonMap["historyGenetic"],
  134. historyGeneticName: jsonMap["historyGeneticName"],
  135. disabilitySituation:
  136. jsonMap["disabilitySituation"]?.cast<String>().toList(),
  137. disabilitySituationOther: jsonMap["disabilitySituationOther"],
  138. kitchenExhaustFacilities: jsonMap["kitchenExhaustFacilities"],
  139. fuel: jsonMap["fuel"],
  140. fuelOther: jsonMap["fuelOther"],
  141. drinkingWater: jsonMap["drinkingWater"],
  142. drinkingWaterOther: jsonMap["drinkingWaterOther"],
  143. toilet: jsonMap["toilet"],
  144. animalPen: jsonMap["animalPen"],
  145. historyDrugAllergiesOther: jsonMap["historyDrugAllergiesOther"],
  146. operationOne: jsonMap["operationOne"] != null &&
  147. jsonMap["operationOne"] != "{}"
  148. ? VProfileTimeInputModel.fromJson(jsonDecode(jsonMap["operationOne"]))
  149. : null,
  150. operationTwo: jsonMap["operationTwo"] != null &&
  151. jsonMap["operationTwo"] != "{}"
  152. ? VProfileTimeInputModel.fromJson(jsonDecode(jsonMap["operationTwo"]))
  153. : null,
  154. traumaOne: jsonMap["traumaOne"] != null && jsonMap["traumaOne"] != "{}"
  155. ? VProfileTimeInputModel.fromJson(jsonDecode(jsonMap["traumaOne"]))
  156. : null,
  157. traumaTwo: jsonMap["traumaTwo"] != null && jsonMap["traumaTwo"] != "{}"
  158. ? VProfileTimeInputModel.fromJson(jsonDecode(jsonMap["traumaTwo"]))
  159. : null,
  160. transfusionOne:
  161. jsonMap["transfusionOne"] != null && jsonMap["transfusionOne"] != "{}"
  162. ? VProfileTimeInputModel.fromJson(
  163. jsonDecode(jsonMap["transfusionOne"]))
  164. : null,
  165. transfusionTwo:
  166. jsonMap["transfusionTwo"] != null && jsonMap["transfusionTwo"] != "{}"
  167. ? VProfileTimeInputModel.fromJson(
  168. jsonDecode(jsonMap["transfusionTwo"]))
  169. : null,
  170. diseaseDiagnosisTime:
  171. Map<String, dynamic>.from(jsonDecode(jsonMap["diseaseDiagnosisTime"]))
  172. .map((key, value) {
  173. return MapEntry(key, DateTime.parse(value));
  174. }),
  175. workUnit: jsonMap["workUnit"],
  176. contactName: jsonMap["contactName"],
  177. contactPhone: jsonMap["contactPhone"],
  178. permanentlyResideType: jsonMap["permanentlyResideType"],
  179. bloodType: jsonMap["bloodType"],
  180. rh: jsonMap["rh"],
  181. educationLevel: jsonMap["educationLevel"],
  182. career: jsonMap["career"],
  183. maritalStatus: jsonMap["maritalStatus"],
  184. providerPayments: jsonMap["providerPayments"],
  185. providerPaymentsOther: jsonMap["providerPaymentsOther"],
  186. );
  187. }
  188. Map<String, dynamic> toJson() {
  189. Map<String, dynamic> jsonMap = <String, dynamic>{};
  190. {
  191. if (historyDrugAllergies != null) {
  192. jsonMap["historyDrugAllergies"] = historyDrugAllergies;
  193. }
  194. if (historyExposure != null) jsonMap["historyExposure"] = historyExposure;
  195. if (historyPreviousDisease != null) {
  196. jsonMap["historyPreviousDisease"] = historyPreviousDisease;
  197. }
  198. if (historyPreviousDiseaseOther != null) {
  199. jsonMap["historyPreviousDiseaseOther"] = historyPreviousDiseaseOther;
  200. }
  201. if (historyPreviousDiseaseOccupationalDisease != null) {
  202. jsonMap["historyPreviousDiseaseOccupationalDisease"] =
  203. historyPreviousDiseaseOccupationalDisease;
  204. }
  205. if (historyPreviousDiseaseMalignancy != null) {
  206. jsonMap["historyPreviousDiseaseMalignancy"] =
  207. historyPreviousDiseaseMalignancy;
  208. }
  209. if (operation != null) jsonMap["operation"] = operation;
  210. if (trauma != null) jsonMap["trauma"] = trauma;
  211. if (transfusion != null) jsonMap["transfusion"] = transfusion;
  212. if (father != null) jsonMap["father"] = father;
  213. if (fatherOther != null) jsonMap["fatherOther"] = fatherOther;
  214. if (mother != null) jsonMap["mother"] = mother;
  215. if (motherOther != null) jsonMap["motherOther"] = motherOther;
  216. if (sibling != null) jsonMap["sibling"] = sibling;
  217. if (siblingOther != null) jsonMap["siblingOther"] = siblingOther;
  218. if (children != null) jsonMap["children"] = children;
  219. if (childrenOther != null) jsonMap["childrenOther"] = childrenOther;
  220. if (historyGenetic != null) jsonMap["historyGenetic"] = historyGenetic;
  221. if (historyGeneticName != null) {
  222. jsonMap["historyGeneticName"] = historyGeneticName;
  223. }
  224. if (disabilitySituation != null) {
  225. jsonMap["disabilitySituation"] = disabilitySituation;
  226. }
  227. if (disabilitySituationOther != null) {
  228. jsonMap["disabilitySituationOther"] = disabilitySituationOther;
  229. }
  230. if (kitchenExhaustFacilities != null) {
  231. jsonMap["kitchenExhaustFacilities"] = kitchenExhaustFacilities;
  232. }
  233. if (fuel != null) jsonMap["fuel"] = fuel;
  234. if (fuelOther != null) jsonMap["fuelOther"] = fuelOther;
  235. if (drinkingWater != null) jsonMap["drinkingWater"] = drinkingWater;
  236. if (drinkingWaterOther != null) {
  237. jsonMap["drinkingWaterOther"] = drinkingWaterOther;
  238. }
  239. if (toilet != null) jsonMap["toilet"] = toilet;
  240. if (animalPen != null) jsonMap["animalPen"] = animalPen;
  241. if (historyDrugAllergiesOther != null) {
  242. jsonMap["historyDrugAllergiesOther"] = historyDrugAllergiesOther;
  243. }
  244. if (operationOne != null) {
  245. jsonMap["operationOne"] = jsonEncode(operationOne?.toJson());
  246. }
  247. if (operationTwo != null) {
  248. jsonMap["operationTwo"] = jsonEncode(operationTwo?.toJson());
  249. }
  250. if (traumaOne != null) {
  251. jsonMap["traumaOne"] = jsonEncode(traumaOne?.toJson());
  252. }
  253. if (traumaTwo != null) {
  254. jsonMap["traumaTwo"] = jsonEncode(traumaTwo?.toJson());
  255. }
  256. if (transfusionOne != null) {
  257. jsonMap["transfusionOne"] = jsonEncode(transfusionOne?.toJson());
  258. }
  259. if (transfusionTwo != null) {
  260. jsonMap["transfusionTwo"] = jsonEncode(transfusionTwo?.toJson());
  261. }
  262. jsonMap["diseaseDiagnosisTime"] = jsonEncode(diseaseDiagnosisTime
  263. .map((key, value) => MapEntry(key, value.toIso8601String())));
  264. if (workUnit != null) {
  265. jsonMap["workUnit"] = workUnit;
  266. }
  267. if (contactName != null) {
  268. jsonMap["contactName"] = contactName;
  269. }
  270. if (contactPhone != null) {
  271. jsonMap["contactPhone"] = contactPhone;
  272. }
  273. if (permanentlyResideType != null) {
  274. jsonMap["permanentlyResideType"] = permanentlyResideType;
  275. }
  276. if (bloodType != null) {
  277. jsonMap["bloodType"] = bloodType;
  278. }
  279. if (rh != null) {
  280. jsonMap["rh"] = rh;
  281. }
  282. if (educationLevel != null) {
  283. jsonMap["educationLevel"] = educationLevel;
  284. }
  285. if (career != null) {
  286. jsonMap["career"] = career;
  287. }
  288. if (maritalStatus != null) {
  289. jsonMap["maritalStatus"] = maritalStatus;
  290. }
  291. if (providerPayments != null) {
  292. jsonMap["providerPayments"] = providerPayments;
  293. }
  294. if (providerPaymentsOther != null) {
  295. jsonMap["providerPaymentsOther"] = providerPaymentsOther;
  296. }
  297. return jsonMap;
  298. }
  299. }
  300. }
  301. class PatientInfoState {
  302. final Rx<NavAnchorType> _anchor = NavAnchorType.base.obs;
  303. /// 导航锚点
  304. NavAnchorType get anchor => _anchor.value;
  305. set anchor(NavAnchorType val) => _anchor.updateValue(val);
  306. final Rx<PatientDTO> _dto = Rx<PatientDTO>(
  307. PatientDTO(),
  308. );
  309. String healthCode = "";
  310. DateTime extractBirthDateFromIDCard(String idCardNumber) {
  311. final idCardRegex = RegExp(r'^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})(\d|X)$');
  312. final match = idCardRegex.firstMatch(idCardNumber);
  313. if (match != null) {
  314. final year = int.parse(match.group(2)!);
  315. final month = int.parse(match.group(3)!);
  316. final day = int.parse(match.group(4)!);
  317. final birthDate = DateTime(year, month, day);
  318. return birthDate;
  319. }
  320. return DateTime(1970, 1, 1); // 返回一个默认值,表示无法提取出生日期
  321. }
  322. }
  323. enum NavAnchorType {
  324. base,
  325. detail,
  326. health,
  327. }