12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import 'dart:collection';
- import 'package:fis_jsonrpc/rpc.dart';
- import 'package:get/get.dart';
- import 'package:vitalapp/architecture/defines.dart';
- import 'package:vitalapp/architecture/types/index.dart';
- import 'package:vitalapp/architecture/utils/datetime.dart';
- import 'package:vitalapp/pages/controllers/crowd_labels.dart';
- import 'package:vitalapp/pages/patient_info/controller.dart';
- import 'package:vitalapp/pages/patient_info/state.dart';
- import 'package:vitalapp/store/store.dart';
- class CreatePatientState {
- final RxBool _isCreateOnly = RxBool(false);
- final RxList<String> _crowdLabelCodes = RxList();
- final patientInfomationController = Get.find<PatientInfomationController>();
- PatientInfomationState get patientInfomationState =>
- patientInfomationController.state;
- void reset() {
- var crowdLabelController = Get.find<CrowdLabelsController>();
- crowdLabelController.state.selectedNormalCodes = [];
- crowdLabelController.state.selectedDiseaseCodes = [];
- crowdLabelController.state.selectedSpecialCareCodes = [];
- patientInfomationState.name = "";
- patientInfomationState.cardType = CardTypeEnum.Identity;
- patientInfomationState.cardNo = "";
- patientInfomationState.nation = "";
- patientInfomationState.gender = null;
- patientInfomationState.birthday = null;
- patientInfomationState.permanentResidenceAddress = "";
- patientInfomationState.address = "";
- patientInfomationState.villageCode = "";
- patientInfomationState.phoneNo = "";
- patientInfomationState.emergencyPhone = "";
- crowdLabelCodes = [];
- patientInfomationState.isSyncAddresses = true;
- }
- ///头像(用于人脸识别没有识别到时新增档案后自动绑定头像)
- String headImage = '';
- //用于识别是否是家医
- bool isVital = true;
- /// 机构名称
- String get organizationName => Store.user.organizationName;
- /// 村选项集合
- List<StringKVModel> get villageOptions => Store.user.residence;
- /// 是否只创建档案
- bool get isCreateOnly => _isCreateOnly.value;
- set isCreateOnly(bool val) => _isCreateOnly.updateValue(val);
- DateTime extractBirthDateFromIDCard(String idCardNumber) {
- if (idCardNumber.isEmpty) return DateTime(1970, 1, 1);
- 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); // 返回一个默认值,表示无法提取出生日期
- }
- /// 人群分类集合
- List<String> get crowdLabelCodes =>
- UnmodifiableListView(_crowdLabelCodes.toList());
- set crowdLabelCodes(List<String> val) => _crowdLabelCodes.value = val;
- }
|