1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822 |
- import 'dart:convert';
- import 'package:fis_common/event/event_type.dart';
- import 'package:fis_common/index.dart';
- import 'package:fis_common/logger/logger.dart';
- import 'package:fis_jsonrpc/rpc.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:get/get.dart';
- import 'package:intl/intl.dart';
- import 'package:vitalapp/architecture/utils/prompt_box.dart';
- import 'package:vitalapp/components/appbar.dart';
- import 'package:vitalapp/components/button.dart';
- import 'package:vitalapp/components/dialog_date.dart';
- import 'package:vitalapp/components/dialog_input.dart';
- import 'package:vitalapp/components/dialog_number.dart';
- import 'package:vitalapp/components/dynamic_drawer.dart';
- import 'package:vitalapp/managers/interfaces/cachedRecord.dart';
- import 'package:vitalapp/managers/interfaces/patient.dart';
- import 'package:vitalapp/managers/interfaces/registration.dart';
- import 'package:vitalapp/managers/interfaces/template.dart';
- import 'package:vitalapp/pages/check/models/form.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_ability_radio.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_abnormal.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_blood_pressure.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_blood_sugar.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_body_temperature.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_body_weight.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_boold_oxygen.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_check_box.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_check_guidance.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_checkbox_frequency.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_dentition.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_input.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_number_input.dart';
- import 'dart:math' as math;
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_radio.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_radio_score.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_risk_factor_control.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_table.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_toxic_substance.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_urinalys.dart';
- import 'package:vitalapp/pages/check/widgets/exam_table/homecare_bed_history_from.dart';
- import 'package:vitalapp/pages/check/widgets/exam_table/hospitalization_history_from.dart';
- import 'package:vitalapp/pages/check/widgets/exam_table/inoculate_history_from.dart';
- import 'package:vitalapp/pages/check/widgets/exam_table/main_medication_status_from.dart';
- import 'package:vitalapp/pages/medical/controller.dart';
- import 'package:vitalapp/store/store.dart';
- class NewConfigurableCard extends StatefulWidget {
- final String cardKey;
- final Future<bool> Function(String, String, dynamic, bool) callBack;
- final Widget? followUpWidget;
- final String? patientCode;
- final String? examData;
- final FEventHandler<bool>? onChangeCurrentKeyEvent;
- final FEventHandler<bool>? onSubmitEvent;
- final String physicalExamNumber;
- final bool? isAllSelectZQCT;
- final Function(bool)? onAllSelectZQCTChange;
- const NewConfigurableCard({
- super.key,
- required this.cardKey,
- required this.callBack,
- required this.physicalExamNumber,
- this.followUpWidget,
- this.patientCode,
- this.examData,
- this.onSubmitEvent,
- this.isAllSelectZQCT,
- this.onChangeCurrentKeyEvent,
- this.onAllSelectZQCTChange,
- });
- @override
- State<NewConfigurableCard> createState() => NewConfigurableFormState();
- }
- class NewConfigurableFormState extends State<NewConfigurableCard> {
- /// 当前最新的模板的键值对
- Map<String, dynamic> templateRelation = {};
- String templateCode = '';
- /// 当前模板数据
- List<FormObject> currentTemplate = [];
- /// 当前title的下标
- // int currentTitleIndex = 0;
- Map<String, dynamic> formValue = {};
- var scaffoldKey = GlobalKey<ScaffoldState>();
- final _templateManager = Get.find<ITemplateManager>();
- final _cachedRecordManager = Get.find<ICachedRecordManager>();
- final arrowHeight = math.tan(120 / 180) * 19;
- List<String> deviceList = [
- 'Temp',
- 'GLU',
- 'NIBP',
- 'SpO2',
- 'BMI',
- "Urinary_Pro",
- ];
- Map<String, dynamic> deviceCached = {};
- Map currentTable = {};
- ScrollController _examScrollController = ScrollController();
- ExamDTO? _currentExam;
- bool _isAllSelectZQCT = false;
- @override
- void initState() {
- print("formValue:$formValue");
- _isAllSelectZQCT = widget.isAllSelectZQCT ?? false;
- initAddListener();
- super.initState();
- WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
- if (mounted) {
- initTemplate();
- }
- });
- widget.onSubmitEvent?.addListener(submitEvent);
- _examScrollController.addListener(_scrollListener);
- }
- @override
- void dispose() {
- super.dispose();
- widget.onSubmitEvent?.removeListener(submitEvent);
- _examScrollController.removeListener(_scrollListener);
- _examScrollController.dispose();
- }
- void submitEvent(sender, e) {
- if (mounted) {
- if (formValue.isNotEmpty) {
- submit(e);
- }
- }
- }
- /// 是否有健康检测的页面权限
- bool _hasHealthMonitor() {
- bool hasAuth = false;
- Store.user.menuPermissionList?.forEach((element) {
- if (element.code == "JKJC") {
- hasAuth = true;
- }
- });
- return hasAuth;
- }
- /// 判断是否有健康检测的页面
- void initAddListener() {
- if (_hasHealthMonitor()) {
- var medicalController = Get.find<MedicalController>();
- medicalController.setExamData.addListener(onSetExamDataEvent);
- }
- }
- void onSetExamDataEvent(sender, Map<String, dynamic> e) {
- try {
- Map<String, dynamic> examData = {};
- Map<String, dynamic> blood = {
- "BloodPressure": {
- "left": "",
- "right": "",
- }
- };
- e.forEach((key, value) {
- if (value is Map && value.isEmpty) {
- return;
- }
- if (key != "Urine") {
- /// 血压处理
- if (value["Sbp_Left"] != null && value["Dbp_Left"] != null) {
- blood["BloodPressure"]["left"] =
- jsonEncode([value["Sbp_Left"], value["Dbp_Left"]]);
- }
- if (value["Sbp_Right"] != null && value["Dbp_Right"] != null) {
- blood["BloodPressure"]["right"] =
- jsonEncode([value["Sbp_Right"], value["Dbp_Right"]]);
- }
- if (blood["BloodPressure"]["left"] != null ||
- blood["BloodPressure"]["right"] != null) {
- examData.addAll(blood);
- }
- examData.addAll(Map<String, dynamic>.from(value));
- } else {
- examData.addAll({"Urinary_Pro": value});
- }
- });
- Map<String, dynamic> newMap = Map.from(examData);
- if (examData["sugar"]?.isNotEmpty ?? false) {
- newMap.remove("sugar");
- // 将"sugar"的值作为"Fasting_Glucose_Mmol"键的值添加到新的Map中
- newMap["Fasting_Glucose_Mmol"] = examData["sugar"] ?? '';
- }
- formValue.addAll(newMap);
- submitExamData();
- ///MedicalController => submitDiagnosis =》 initRecordDataState =》deleteDirectory
- if (mounted) {
- setState(() {});
- }
- } catch (err) {
- logger.e("健康检测数据回填错误:$err");
- }
- }
- Future<void> submitExamData() async {
- Map<String, dynamic> normalItems = {};
- Map<String, dynamic> urinaryItems = {};
- Map<String, dynamic> organsItems = {};
- formValue.forEach((key, value) {
- if (key == "Urinary_Pro" || key == "Fasting_Glucose_Mmol") {
- urinaryItems[key] = value;
- } else if (key == "HEART") {
- organsItems[key] = value;
- } else {
- normalItems[key] = value;
- }
- });
- if (urinaryItems.isNotEmpty) {
- await widget.callBack(
- //辅助检查
- "FZJC",
- templateCode,
- jsonEncode(urinaryItems),
- false,
- );
- }
- if (normalItems.isNotEmpty) {
- await widget.callBack(
- //一般状况
- "ZZYBZK",
- templateCode,
- jsonEncode(normalItems),
- false,
- );
- }
- if (organsItems.isNotEmpty) {
- await widget.callBack(
- //脏器及查体
- "ZQCT",
- templateCode,
- jsonEncode(organsItems),
- false,
- );
- }
- }
- Future<void> submit(bool isManual) async {
- await widget.callBack(
- widget.cardKey,
- templateCode,
- jsonEncode(formValue),
- isManual,
- );
- }
- Future<void> initTemplate() async {
- try {
- Store.app.busy = true;
- await fetchTemplateIndex();
- await fetchTemplate(widget.cardKey);
- await fetchTemplateData();
- if (widget.cardKey == "ZQCT") {
- var isAllSelectZQCT = CalculatesWhetherTheSelectAllButtonIsSelected();
- _isAllSelectZQCT = isAllSelectZQCT;
- if (widget.onAllSelectZQCTChange != null) {
- widget.onAllSelectZQCTChange!(isAllSelectZQCT);
- }
- }
- Store.app.busy = false;
- setState(() {});
- } catch (e) {
- Store.app.busy = false;
- print(e.toString());
- logger.e("模版错误:" + e.toString());
- }
- }
- /// 读取健康检测的缓存
- Future<String?> readCachedRecord(String currentDevice) async {
- if (widget.patientCode == null) {
- return null;
- }
- String? value = await _cachedRecordManager.readCachedRecord(
- currentDevice,
- widget.patientCode!,
- //诊疗展示
- 'ZLZS',
- );
- return value;
- }
- /// 读取体检的缓存
- Future<String?> readCachedCheck() async {
- if (widget.patientCode == null) {
- return null;
- }
- String? value = await _cachedRecordManager.readCachedRecord(
- widget.cardKey,
- widget.patientCode!,
- 'exam',
- );
- return value;
- }
- Future<void> readCached() async {
- for (var element in deviceList) {
- String? value = await readCachedRecord(element);
- if (value?.isNotEmpty ?? false) {
- deviceCached.addAll(jsonDecode(value!));
- }
- }
- }
- Future<void> fetchTemplateIndex() async {
- try {
- /// 获取模板的键值对
- String? templates;
- templates = await _templateManager.readTemplateRelation(
- 'templateRelation',
- );
- templateRelation = jsonDecode(templates!);
- } catch (error) {
- print('发生错误: $error');
- logger.e("发生错误" + error.toString());
- }
- }
- Future<void> setExamData() async {
- if (widget.physicalExamNumber.isNotEmpty) {
- List<ExamDTO>? examList = await Get.find<IRegistrationManager>()
- .getExamListByPhysicalExamNumberAsync(
- physicalExamNumber: widget.physicalExamNumber,
- );
- ExamDTO? currentExam = examList?.firstWhereOrNull(
- (element) => element.key == widget.cardKey,
- );
- _currentExam = currentExam;
- } else if (widget.cardKey == "YZJSZABCXX") {
- PatientExtensionDTO? patientExtensionDTO =
- await Get.find<IPatientManager>()
- .getPatientExtensionDetailByCodeAndKey(
- widget.cardKey,
- widget.patientCode ?? '',
- );
- if (patientExtensionDTO != null) {
- String extensionData = patientExtensionDTO.extensionData ?? '';
- _currentExam = ExamDTO(
- code: patientExtensionDTO.code,
- patientCode: patientExtensionDTO.patientCode,
- examData: extensionData,
- key: patientExtensionDTO.key,
- );
- }
- }
- }
- Future<void> fetchTemplateData() async {
- await setExamData();
- if (_currentExam?.examData != null) {
- formValue = jsonDecode(_currentExam?.examData ?? '');
- } else if (widget.examData != null) {
- formValue = jsonDecode(widget.examData ?? '');
- } else {
- return;
- }
- formValue.forEach(
- (key, value) {
- if (value is List<String>) {
- formValue[key] = List<String>.from(formValue[key]);
- } else if (value is List<Map>) {
- formValue[key] = List<Map>.from(formValue[key]);
- }
- },
- );
- }
- Future<String> loadJsonFromAssets(String filePath) async {
- String jsonString = await rootBundle.loadString(filePath);
- return jsonString;
- }
- Future<void> fetchTemplate(String key) async {
- try {
- // String? templateContent = "";
- // String? template = "";
- // if (key == "YZJSZABCXX") {
- // templateContent =
- // await loadJsonFromAssets('assets/严重精神障碍患者个人信息补充表.json');
- // }
- // if (templateRelation[key] == null && templateContent.isNullOrEmpty) {
- if (templateRelation[key] == null) {
- logger.i(
- "ConfigurableCard - fetchTemplate Template not exist key: $key.");
- currentTemplate = [];
- setState(() {});
- if (!FPlatform.isWindows) {
- return;
- }
- }
- // if (templateContent.isNullOrEmpty)
- // template = await _templateManager.readTemplate(templateRelation[key]!);
- // if (templateContent.isNullOrEmpty)
- // templateContent =
- String? template;
- if (templateRelation.containsKey(key)) {
- templateCode = templateRelation[key]!;
- template = await _templateManager.readTemplate(templateCode);
- }
- List<Map<String, dynamic>> list = [];
- if (template == null) {
- var json = await loadJsonFromAssets('assets/templates/${key}.json');
- list = jsonDecode(json)["Content"].cast<Map<String, dynamic>>();
- } else {
- var templateContent =
- TemplateDTO.fromJson(jsonDecode(template)).templateContent!;
- list = jsonDecode(templateContent).cast<Map<String, dynamic>>();
- }
- for (var i in list) {
- if (i['children'] != null) {
- List<FormObject> currentChildren = [];
- for (var j in i['children']) {
- currentChildren.add(FormObject.fromJson(j));
- }
- i['children'] = currentChildren;
- }
- var item = FormObject.fromJson(i);
- currentTemplate.add(item);
- }
- } catch (error) {
- print('发生错误: $error');
- logger.e("发生错误: fetchTemplate" + error.toString());
- }
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- key: scaffoldKey,
- appBar: widget.cardKey == "YZJSZABCXX"
- ? VAppBar(
- titleText: "精神障碍患者补充表",
- actions: [
- TextButton(
- onPressed: () {
- widget.callBack(
- widget.cardKey,
- templateRelation[widget.cardKey]!,
- jsonEncode(formValue),
- false,
- );
- },
- child: Text(
- "保存",
- style: TextStyle(fontSize: 24, color: Colors.white),
- ),
- ),
- ],
- )
- : null,
- endDrawer: VDynamicDrawerWrapper(scaffoldKey: scaffoldKey),
- resizeToAvoidBottomInset: false,
- body: Column(
- children: [
- Expanded(
- child: Stack(
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- // _buildDiagram(),
- _buildContent(),
- ],
- ),
- if (widget.cardKey == "ZQCT")
- Positioned(
- right: 30,
- bottom: 20,
- child: Container(
- width: 150,
- height: 50,
- child: Row(
- children: [
- Switch(
- activeTrackColor: Colors.blueAccent,
- value: _isAllSelectZQCT,
- onChanged: (value) {
- _isAllSelectZQCT = !_isAllSelectZQCT;
- widget.onAllSelectZQCTChange!(value);
- for (var element in currentTemplate) {
- for (var child in element.children!) {
- if ([
- "Vision_Left",
- "Vision_Right",
- "Vision_Corrective_Left",
- "Vision_Corrective_Right",
- "Heart_Rate",
- "Examination_Other",
- "Pedal_Artery",
- "Rectal_Touch",
- "Mammary",
- "Vulvar",
- "Vagina",
- "Cervical",
- "Uteri_Body",
- "Uteri_Adnexa",
- "Eye_Ground"
- ].contains(child.key)) {
- continue;
- }
- if (_isAllSelectZQCT) {
- if (child.key == "Dentition") {
- formValue[child.key!] = {
- 'status': [0],
- 'detail_a': [],
- 'detail_b': [],
- 'detail_c': [],
- };
- } else if (child.type == "checkbox") {
- formValue[child.key!] = ["1"];
- } else {
- formValue[child.key!] = "1";
- }
- } else {
- formValue.remove(child.key);
- }
- }
- }
- setState(() {});
- }),
- Text(
- '全选正常',
- style: TextStyle(fontSize: 18),
- ),
- ],
- ),
- ),
- ),
- ],
- ),
- )
- ],
- ),
- );
- }
- bool CalculatesWhetherTheSelectAllButtonIsSelected() {
- bool isAllSelect = true;
- for (var element in currentTemplate) {
- for (var child in element.children!) {
- if ([
- "Vision_Left",
- "Vision_Right",
- "Vision_Corrective_Left",
- "Vision_Corrective_Right",
- "Heart_Rate",
- "Examination_Other",
- "Pedal_Artery",
- "Rectal_Touch",
- "Mammary",
- "Vulvar",
- "Vagina",
- "Cervical",
- "Uteri_Body",
- "Uteri_Adnexa",
- "Eye_Ground"
- ].contains(child.key)) {
- continue;
- }
- if (child.key == "Dentition") {
- dynamic dentitionValue = formValue[child.key!] ?? {};
- Map currentValue = {};
- if (!(dentitionValue is Map)) {
- currentValue = {};
- isAllSelect = false;
- } else {
- currentValue = dentitionValue;
- }
- if (currentValue["status"][0] != 0) {
- isAllSelect = false;
- }
- } else {
- var currentValue = formValue[child.key!];
- if (currentValue == null) {
- isAllSelect = false;
- } else {
- if (currentValue != "1") {
- isAllSelect = false;
- }
- }
- }
- if (!isAllSelect) {
- break;
- }
- }
- }
- return isAllSelect;
- }
- Widget buildSingleItem(Widget item, int span) {
- return FractionallySizedBox(
- widthFactor: span == 24 ? 1 : 0.5,
- child: item,
- );
- }
- Widget buildWidget(FormObject? currentFormObject) {
- Map<String, Widget Function(FormObject)> widgetMap = {
- 'checkbox': _buildCheckBox,
- 'numberInput': _buildNumberInput,
- 'input': _buildInput,
- 'radio': _buildRadio,
- 'radioScore': _buildRadioScore,
- 'bloodPressure': _buildBloodPressure,
- 'bodyTemperature': _buildBodyTemperature,
- 'weight': _buildBodyWeight,
- 'sugar': _buildBodySugar,
- 'bloodOxygen': _buildBloodOxygen,
- 'medicalHistory': _buildMedicalHistory,
- 'homecareBedHistor': _buildHomecareBedHistory,
- 'table': _buildMainMedicationHistory,
- 'inoculateHistory': _buildInoculateHistory,
- 'safetyPrecautions': _buildToxicSubstance,
- 'urinalys': _buildUrinalysis,
- "dentition": _buildDentition,
- "abnormal": _buildAbnormal,
- "riskFactorControl": _buildRiskFactorControl,
- 'ability_radio': _buildAbilityRadio,
- 'checkBoxFrequency': _buildCheckBoxFrequency,
- 'checkBoxIncludeOther': _buildCheckBoxIncludeOther,
- // 'inputHospitalizationTimes': _buildInputHospitalizationTimes,
- 'radioExtraDescription': _buildRadioExtraDescription,
- 'inputDiagnose': _buildInputDiagnose,
- 'radioInformedConsent': _buildRadioInformedConsent,
- 'date': _buildDate,
- 'checkbox_guidance': _buildGuidance,
- 'radioPreviousTreatment': _buildRadioPreviousTreatment,
- };
- Widget Function(FormObject) builder =
- widgetMap[currentFormObject?.type] ?? _buildInput;
- return builder(currentFormObject!);
- }
- Widget flowCardList() {
- int itemCount = 0;
- List<Widget> _cardList = [];
- bool currentTemplateOptionsIsNotEmpty = false;
- if (currentTemplate.isNotEmpty) {
- for (int i = 0; i < currentTemplate.length; i++) {
- itemCount = currentTemplate[i].children?.length ?? 0;
- currentTemplateOptionsIsNotEmpty =
- currentTemplate[i].options?.isNotEmpty ?? false;
- List<Widget> items = List.generate(itemCount, (index) {
- FormObject? currentFormObject = currentTemplate[i].children?[index];
- int span = currentFormObject?.span ?? 12;
- //父结构的options不等于空或null
- if (true) {
- //子结构的options若是无值则取父类的options值
- if (currentTemplateOptionsIsNotEmpty) {
- currentFormObject!.options = currentTemplate[i].options;
- }
- }
- return buildSingleItem(buildWidget(currentFormObject), span);
- });
- _cardList.addAll(items);
- }
- }
- return Scrollbar(
- thumbVisibility: true,
- controller: _examScrollController,
- child: SingleChildScrollView(
- controller: _examScrollController,
- child: Container(
- alignment: Alignment.topCenter,
- padding: const EdgeInsets.all(15),
- child: Wrap(
- runSpacing: 20, // 纵向元素间距
- alignment: WrapAlignment.start,
- children: _cardList,
- ),
- ),
- ),
- );
- }
- void _scrollListener() {
- if (mounted) {
- if (_examScrollController.position.pixels ==
- _examScrollController.position.maxScrollExtent) {
- // 滚动到底部
- _onScrollEnd();
- }
- }
- }
- void _onScrollEnd() {
- // 在这里触发您想要执行的方法
- print('Scroll to the bottom!');
- // widget.onChangeCurrentKeyEvent?.emit(this, true);
- }
- /// 主页面
- Widget _buildContent() {
- return Expanded(
- flex: 2,
- child: flowCardList(),
- );
- }
- /// 指导模块
- Widget _buildGuidance(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- List<dynamic> prescriptionList = formValue["PrescriptionList"] ?? [];
- List<dynamic> currentSelectedCheckBox = [];
- if (formValue[currentFormObject.key!] is List) {
- currentSelectedCheckBox = formValue[currentFormObject.key!] ?? [];
- }
- dynamic disabledValue = currentFormObject.disabledValue;
- List exclusiveValue = currentFormObject.exclusiveValue ?? [];
- void selectCheckBoxChange(Option e) {
- // 互斥项预处理
- if (exclusiveValue.isNotEmpty && exclusiveValue.contains(e.value)) {
- currentSelectedCheckBox.removeWhere((element) =>
- exclusiveValue.contains(element) && element != e.value);
- }
- if (currentSelectedCheckBox.contains(e.value)) {
- currentSelectedCheckBox.remove(e.value);
- } else {
- if (disabledValue == e.value) {
- currentSelectedCheckBox = [disabledValue];
- } else {
- if (currentSelectedCheckBox.contains(disabledValue)) {
- // PromptBox.toast('选项冲突');
- } else {
- // 最大可选处理
- if (currentFormObject.maxItems != null &&
- currentSelectedCheckBox.length >= currentFormObject.maxItems!) {
- PromptBox.toast('最多选择${currentFormObject.maxItems}项');
- return;
- }
- currentSelectedCheckBox.add(e.value ?? '');
- }
- }
- }
- formValue[currentFormObject.key!] = currentSelectedCheckBox;
- setState(() {});
- }
- createPrescription(Map prescription) {
- prescriptionList.add(prescription);
- formValue["PrescriptionList"] = prescriptionList;
- setState(() {});
- }
- removePrescription(Map prescription) {
- prescriptionList.remove(prescription);
- formValue["PrescriptionList"] = prescriptionList;
- setState(() {});
- }
- // void deletePrescription(int index) {
- // prescriptionList.removeAt(index);
- // formValue["PrescriptionList"] = prescriptionList;
- // setState(() {});
- // }
- return ExamCheckBoxGuidance(
- options: options,
- currentSelectedCheckBox: currentSelectedCheckBox,
- currentFormObject: currentFormObject,
- selectCheckBoxChange: selectCheckBoxChange,
- disbaleOthers: currentSelectedCheckBox.contains(disabledValue),
- physicalExamNumber: widget.physicalExamNumber,
- patientCode: widget.patientCode!,
- createPrescription: createPrescription,
- removePrescription: removePrescription,
- prescriptionList: prescriptionList,
- );
- }
- Widget _buildRadioPreviousTreatment(FormObject currentFormObject) {
- DateFormat format = DateFormat('yyyy-MM-dd');
- String currentSelected = formValue[currentFormObject.key!] ?? '';
- String firstAntipsyTreatDate =
- formValue[currentFormObject.childrenKey!.first] ?? '';
- String pastPsyInpatTimes =
- formValue[currentFormObject.childrenKey!.last] ?? '';
- Future<void> commonInput() async {
- String? result = await VDialogNumber(
- title: "曾住精神专科医院/综合医院精神专科次数",
- initialValue: pastPsyInpatTimes,
- ).show();
- if (result?.isNotEmpty ?? false) {
- formValue[currentFormObject.childrenKey!.last] = result;
- pastPsyInpatTimes = formValue[currentFormObject.childrenKey!.last];
- setState(() {});
- }
- }
- void selectRaidoChange(Option e) {
- if (currentSelected == e.value) {
- currentSelected = '';
- } else {
- currentSelected = e.value ?? '';
- }
- formValue[currentFormObject.key!] = currentSelected;
- setState(() {});
- }
- Future<void> commonInputDate() async {
- DateTime? result = await VDialogDate(
- title: "首次抗精神病药治疗时间",
- initialValue: firstAntipsyTreatDate.isNotNullOrEmpty
- ? format.parse(firstAntipsyTreatDate)
- : DateTime.now(),
- ).show();
- if (result != null) {
- firstAntipsyTreatDate = DateFormat("yyyy-MM-dd").format(result);
- formValue[currentFormObject.childrenKey!.first] = firstAntipsyTreatDate;
- setState(() {});
- }
- }
- return ExamRadioPreviousTreatment(
- currentSelected: currentSelected,
- options: currentFormObject.options!,
- commonInput: commonInput,
- commonInputDate: commonInputDate,
- selectRaidoChange: selectRaidoChange,
- firstAntipsyTreatDate: firstAntipsyTreatDate,
- pastPsyInpatTimes: pastPsyInpatTimes,
- currentFormObject: currentFormObject,
- );
- }
- /// 多选框组件
- Widget _buildCheckBox(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- List<dynamic> currentSelectedCheckBox = [];
- if (formValue[currentFormObject.key!] is List) {
- currentSelectedCheckBox = formValue[currentFormObject.key!] ?? [];
- }
- dynamic disabledValue = currentFormObject.disabledValue;
- List exclusiveValue = currentFormObject.exclusiveValue ?? [];
- void selectCheckBoxChange(Option e) {
- // 互斥项预处理
- if (exclusiveValue.isNotEmpty && exclusiveValue.contains(e.value)) {
- currentSelectedCheckBox.removeWhere((element) =>
- exclusiveValue.contains(element) && element != e.value);
- }
- if (currentSelectedCheckBox.contains(e.value)) {
- currentSelectedCheckBox.remove(e.value);
- } else {
- if (disabledValue == e.value) {
- currentSelectedCheckBox = [disabledValue];
- } else {
- if (currentSelectedCheckBox.contains(disabledValue)) {
- // PromptBox.toast('选项冲突');
- } else {
- // 最大可选处理
- if (currentFormObject.maxItems != null &&
- currentSelectedCheckBox.length >= currentFormObject.maxItems!) {
- PromptBox.toast('最多选择${currentFormObject.maxItems}项');
- return;
- }
- currentSelectedCheckBox.add(e.value ?? '');
- }
- }
- }
- formValue[currentFormObject.key!] = currentSelectedCheckBox;
- setState(() {});
- }
- return ExamCheckBox(
- options: options,
- currentSelectedCheckBox: currentSelectedCheckBox,
- currentFormObject: currentFormObject,
- selectCheckBoxChange: selectCheckBoxChange,
- disbaleOthers: currentSelectedCheckBox.contains(disabledValue),
- );
- }
- /// 数字输入框组件
- Widget _buildNumberInput(FormObject currentFormObject) {
- String currentInputValue = formValue[currentFormObject.key!] ?? '';
- if ((formValue['Height']?.isNotEmpty ?? false) &&
- (formValue['Weight']?.isNotEmpty ?? false)) {
- formValue['Bmi'] = (double.parse(formValue['Weight']) /
- ((double.parse(formValue['Height']) / 100) *
- (double.parse(formValue['Height']) / 100)))
- .toStringAsFixed(2);
- }
- Future<void> commonInput() async {
- String? result = await VDialogNumber(
- title: currentFormObject.label,
- initialValue: formValue[currentFormObject.key],
- ).show();
- if (result?.isNotEmpty ?? false) {
- formValue[currentFormObject.key!] = result;
- currentInputValue = formValue[currentFormObject.key!];
- setState(() {});
- } else {
- formValue[currentFormObject.key!] = '';
- currentInputValue = formValue[currentFormObject.key!];
- setState(() {});
- }
- }
- void specialInput(String value) {
- formValue[currentFormObject.key!] = value;
- currentInputValue = formValue[currentFormObject.key!];
- setState(() {});
- }
- return ExamNumberInput(
- currentInputValue: currentInputValue,
- commonInput: commonInput,
- specialInput: specialInput,
- currentFormObject: currentFormObject,
- );
- }
- Widget _buildInput(FormObject currentFormObject) {
- String currentInputValue = formValue[currentFormObject.key!] ?? '';
- Future<void> commonInput() async {
- String? result = await VDialogInput(
- title: currentFormObject.label,
- initialValue: formValue[currentFormObject.key],
- ).show();
- if (result?.isNotEmpty ?? false) {
- formValue[currentFormObject.key!] = result;
- currentInputValue = formValue[currentFormObject.key!];
- setState(() {});
- }
- }
- return ExamInput(
- currentInputValue: currentInputValue,
- commonInput: commonInput,
- currentFormObject: currentFormObject,
- );
- }
- ///住院次数
- // Widget _buildInputHospitalizationTimes(FormObject currentFormObject) {
- // DateFormat format = DateFormat('yyyy-MM-dd');
- // String currentSelected = formValue[currentFormObject.key!] ?? '';
- // String firstAntipsyTreatDate =
- // formValue[currentFormObject.childrenKey!.first] ?? '';
- // String pastPsyInpatTimes =
- // formValue[currentFormObject.childrenKey!.last] ?? '';
- // Future<void> commonInput() async {
- // String? result = await VDialogNumber(
- // title: "曾住精神专科医院/综合医院精神专科次数",
- // initialValue: formValue[currentFormObject.key],
- // ).show();
- // if (result?.isNotEmpty ?? false) {
- // formValue[currentFormObject.childrenKey!.last] = result;
- // pastPsyInpatTimes = formValue[currentFormObject.childrenKey!.last];
- // setState(() {});
- // }
- // }
- // void selectRaidoChange(Option e) {
- // if (currentSelected == e.value) {
- // currentSelected = '';
- // } else {
- // currentSelected = e.value ?? '';
- // }
- // formValue[currentFormObject.key!] = currentSelected;
- // setState(() {});
- // }
- // Future<void> commonInputDate() async {
- // DateTime? result = await VDialogDate(
- // title: "签字时间",
- // initialValue: firstAntipsyTreatDate.isNotNullOrEmpty
- // ? format.parse(firstAntipsyTreatDate)
- // : DateTime.now(),
- // ).show();
- // if (result != null) {
- // firstAntipsyTreatDate = DateFormat("yyyy-MM-dd").format(result);
- // formValue[currentFormObject.childrenKey!.last] = firstAntipsyTreatDate;
- // setState(() {});
- // }
- // }
- // return ExamRadioPreviousTreatment(
- // currentSelected: currentSelected,
- // options: currentFormObject.options!,
- // commonInput: commonInput,
- // commonInputDate: commonInputDate,
- // selectRaidoChange: selectRaidoChange,
- // firstAntipsyTreatDate: firstAntipsyTreatDate,
- // pastPsyInpatTimes: pastPsyInpatTimes,
- // currentFormObject: currentFormObject,
- // );
- // }
- ///目前诊断情况
- Widget _buildInputDiagnose(FormObject currentFormObject) {
- DateFormat format = DateFormat('yyyy-MM-dd');
- String currentInputValue =
- formValue[currentFormObject.childrenKey![0]] ?? '';
- String currentConfirmationHospitals =
- formValue[currentFormObject.childrenKey![1]] ?? '';
- String currentTimeDiagnosis =
- formValue[currentFormObject.childrenKey![2]] ?? '';
- Future<void> commonInput() async {
- String? result = await VDialogInput(
- title: "诊断",
- initialValue: formValue[currentFormObject.childrenKey![0]],
- ).show();
- if (result?.isNotEmpty ?? false) {
- formValue[currentFormObject.key!] = result;
- currentInputValue = formValue[currentFormObject.key!];
- setState(() {});
- }
- }
- Future<void> commonConfirmationHospitals() async {
- String? result = await VDialogInput(
- title: "确诊医院",
- initialValue: currentConfirmationHospitals,
- ).show();
- if (result?.isNotEmpty ?? false) {
- formValue[currentFormObject.childrenKey![1]] = result;
- currentConfirmationHospitals = formValue[currentFormObject.key!];
- setState(() {});
- }
- }
- Future<void> commonTimeDiagnosis() async {
- DateTime? result = await VDialogDate(
- title: "确诊日期",
- initialValue: currentTimeDiagnosis.isNotNullOrEmpty
- ? format.parse(currentTimeDiagnosis)
- : DateTime.now(),
- maxValue: DateTime.now(),
- ).show();
- if (result != null) {
- formValue[currentFormObject.childrenKey![2]] =
- DateFormat("yyyy-MM-dd").format(result);
- currentTimeDiagnosis = formValue[currentFormObject.childrenKey![2]];
- setState(() {});
- }
- }
- return ExamInputDiagnose(
- currentInputValue: currentInputValue,
- currentConfirmationHospitals: currentConfirmationHospitals,
- currentTimeDiagnosis: currentTimeDiagnosis,
- commonInput: commonInput,
- currentFormObject: currentFormObject,
- commonConfirmationHospitals: commonConfirmationHospitals,
- commonTimeDiagnosis: commonTimeDiagnosis,
- );
- }
- ///签字同意
- Widget _buildRadioInformedConsent(FormObject currentFormObject) {
- DateFormat format = DateFormat('yyyy-MM-dd');
- List<Option> options = currentFormObject.options ?? [];
- var currentValue = formValue[currentFormObject.key!] ?? '';
- String currentSelected = "";
- if (currentValue is String) {
- currentSelected = currentValue;
- }
- String sign = formValue[currentFormObject.childrenKey!.first] ?? "";
- String signingTime = formValue[currentFormObject.childrenKey!.last] ?? "";
- void selectRaidoChange(Option e) {
- currentSelected = e.value ?? '';
- formValue[currentFormObject.key!] = currentSelected;
- setState(() {});
- }
- Future<void> commonInput() async {
- String? result = await VDialogInput(
- title: "签字",
- initialValue: sign,
- ).show();
- if (result?.isNotEmpty ?? false) {
- sign = result ?? '';
- formValue[currentFormObject.childrenKey!.first] = sign;
- setState(() {});
- }
- }
- Future<void> commonInputDate() async {
- DateTime? result = await VDialogDate(
- title: "签字时间",
- initialValue: signingTime.isNotNullOrEmpty
- ? format.parse(signingTime)
- : DateTime.now(),
- ).show();
- if (result != null) {
- signingTime = DateFormat("yyyy-MM-dd").format(result);
- formValue[currentFormObject.childrenKey!.last] = signingTime;
- setState(() {});
- }
- }
- return ExamRadioInformedConsent(
- options: options,
- currentFormObject: currentFormObject,
- selectRaidoChange: selectRaidoChange,
- currentSelected: currentSelected,
- commonInput: commonInput,
- commonInputDate: commonInputDate,
- sign: sign,
- signingTime: signingTime,
- );
- }
- ///时间组件
- Widget _buildDate(FormObject currentFormObject) {
- String currentInputValue = formValue[currentFormObject.key!] ?? '';
- DateTime currentDateValue = DateTime.now();
- if (currentInputValue.isNotNullOrEmpty) {
- DateFormat format = DateFormat('yyyy-MM-dd');
- currentDateValue = format.parse(currentInputValue);
- }
- Future<void> commonInput() async {
- DateTime? result = await VDialogDate(
- title: currentFormObject.label,
- initialValue: currentDateValue,
- maxValue: DateTime.now(),
- ).show();
- if (result != null) {
- formValue[currentFormObject.key!] =
- DateFormat("yyyy-MM-dd").format(result);
- currentInputValue = formValue[currentFormObject.key!];
- setState(() {});
- }
- }
- return ExamInput(
- currentInputValue: currentInputValue,
- commonInput: commonInput,
- currentFormObject: currentFormObject,
- );
- }
- /// 血压组件
- Widget _buildBloodPressure(FormObject currentFormObject) {
- Map currentValue = formValue[currentFormObject.key!] ?? {};
- print(currentFormObject.key!);
- void bloodPressure(Map value) {
- currentValue = value;
- formValue[currentFormObject.key!] = currentValue;
- // setState(() {});
- }
- return ExamBloodPressure(
- currentValue: currentValue,
- bloodPressure: bloodPressure,
- );
- }
- Widget _buildUrinalysis(FormObject currentFormObject) {
- Map currentValue = formValue[currentFormObject.key!] ?? {};
- void urinalysis(Map value) {
- currentValue = value;
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- return ExamUrinalysis(
- currentValue: currentValue,
- urinalysis: urinalysis,
- );
- }
- Widget _buildDentition(FormObject currentFormObject) {
- dynamic dentitionValue = formValue[currentFormObject.key!] ?? {};
- Map currentValue = {};
- if (!(dentitionValue is Map)) {
- currentValue = {};
- } else {
- currentValue = dentitionValue;
- }
- void onValueChange(Map value) {
- currentValue = value;
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- if (widget.cardKey == "ZQCT") {
- var isAllSelectZQCT = CalculatesWhetherTheSelectAllButtonIsSelected();
- _isAllSelectZQCT = isAllSelectZQCT;
- if (widget.onAllSelectZQCTChange != null) {
- widget.onAllSelectZQCTChange!(isAllSelectZQCT);
- }
- }
- }
- return ExamDentition(
- currentValue: currentValue,
- onValueChange: onValueChange,
- );
- }
- Widget _buildRiskFactorControl(FormObject currentFormObject) {
- dynamic value = formValue[currentFormObject.key!] ?? {};
- Map currentValue = {};
- if (value is Map) {
- currentValue = value;
- }
- void onValueChange(Map value) {
- currentValue = value;
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- return ExamRiskFactorControl(
- currentValue: currentValue,
- onValueChange: onValueChange,
- );
- }
- Widget _buildAbilityRadio(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- String currentSelected = formValue[currentFormObject.key!] ?? "";
- String abilityCode = formValue["Ability_Code"] ?? '';
- void selectRaidoChange(Option e) {
- if (currentSelected == e.value) {
- currentSelected = '';
- } else {
- currentSelected = e.value ?? '';
- }
- formValue[currentFormObject.key!] = currentSelected;
- setState(() {});
- }
- void examAbilityCodeChange(String? e) {
- formValue["Ability_Code"] = e;
- setState(() {});
- }
- return ExamAbilityRadio(
- options: options,
- currentFormObject: currentFormObject,
- selectRaidoChange: selectRaidoChange,
- currentSelected: currentSelected,
- patientCode: widget.patientCode!,
- lNRZLPGCode: abilityCode,
- physicalExamNumber: widget.physicalExamNumber,
- examAbilityCodeChange: examAbilityCodeChange,
- );
- }
- /// 危险行为
- Widget _buildCheckBoxFrequency(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- List<dynamic> currentFormObjectFrom =
- formValue[currentFormObject.key!] ?? [];
- List<DangerFrequency> currentSelectedCheckBox =
- currentFormObjectFrom.map((e) {
- if (e is Map<String, dynamic>) {
- return DangerFrequency.fromJson(e);
- } else {
- return DangerFrequency.fromJson(e.toJson());
- }
- }).toList();
- dynamic disabledValue = currentFormObject.disabledValue;
- Future<void> selectCheckBoxChange(Option e) async {
- var ddd =
- currentSelectedCheckBox.firstWhereOrNull((f) => f.value == e.value);
- if (ddd != null) {
- currentSelectedCheckBox.remove(ddd);
- } else {
- if (disabledValue == e.value) {
- currentSelectedCheckBox = [
- DangerFrequency(frequency: "0", value: disabledValue)
- ];
- } else {
- var ccc = currentSelectedCheckBox
- .firstWhereOrNull((f) => f.value == disabledValue);
- if (ccc != null) {
- // PromptBox.toast('选项冲突');
- } else {
- String? result = await VDialogNumber(
- title: "${e.label}次数",
- // initialValue: formValue[currentFormObject.key],
- ).show();
- if (result?.isNotEmpty ?? false) {
- currentSelectedCheckBox.add(
- DangerFrequency(frequency: result, value: e.value ?? ''));
- }
- }
- }
- }
- formValue[currentFormObject.key!] = currentSelectedCheckBox;
- setState(() {});
- }
- return ExamCheckBoxFrequency(
- options: options,
- currentSelectedCheckBox: currentSelectedCheckBox,
- currentFormObject: currentFormObject,
- func: selectCheckBoxChange,
- disbaleOthers: currentSelectedCheckBox
- .firstWhereOrNull((f) => f.value == disabledValue) !=
- null,
- );
- }
- Widget _buildCheckBoxIncludeOther(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- List<dynamic> currentSelected = formValue[currentFormObject.key!] ?? [];
- dynamic disabledValue = currentFormObject.disabledValue;
- dynamic otherItem = currentFormObject.groupKeys!.first;
- String otherDecrition =
- formValue[currentFormObject.childrenKey!.first] ?? "";
- void selectCheckBoxChange(Option e) {
- if (currentSelected.contains(e.value)) {
- currentSelected.remove(e.value);
- if (e.value == otherItem) {
- otherDecrition = '';
- }
- } else {
- if (disabledValue == e.value) {
- currentSelected = [disabledValue];
- } else {
- if (currentSelected.contains(disabledValue)) {
- // PromptBox.toast('选项冲突');
- } else {
- currentSelected.add(e.value ?? '');
- }
- }
- }
- formValue[currentFormObject.key!] = currentSelected;
- setState(() {});
- }
- void changeExtraDescription(String? extraDescription) {
- otherDecrition = extraDescription ?? '';
- formValue[currentFormObject.childrenKey!.first] = otherDecrition;
- setState(() {});
- }
- return ExamCheckBoxIncludeOther(
- options: options,
- currentSelectedCheckBox: currentSelected,
- currentFormObject: currentFormObject,
- selectCheckBoxChange: selectCheckBoxChange,
- disbaleOthers: currentSelected.contains(disabledValue),
- changeExtraDescription: changeExtraDescription,
- currentExtraDescription: otherDecrition,
- extraDescriptiveItem: otherItem,
- );
- }
- /// 单选框组件
- Widget _buildRadio(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- String currentSelected = formValue[currentFormObject.key!] ?? "";
- void selectRaidoChange(Option e) {
- if (currentSelected == e.value) {
- currentSelected = '';
- } else {
- currentSelected = e.value ?? '';
- }
- formValue[currentFormObject.key!] = currentSelected;
- if (widget.cardKey == "ZQCT") {
- var isAllSelectZQCT = CalculatesWhetherTheSelectAllButtonIsSelected();
- _isAllSelectZQCT = isAllSelectZQCT;
- if (widget.onAllSelectZQCTChange != null) {
- widget.onAllSelectZQCTChange!(isAllSelectZQCT);
- }
- }
- setState(() {});
- }
- return ExamRadio(
- options: options,
- currentFormObject: currentFormObject,
- selectRaidoChange: selectRaidoChange,
- currentSelected: currentSelected,
- );
- }
- Widget _buildRadioScore(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- String currentSelected =
- formValue[currentFormObject.childrenKey!.first] ?? "";
- String currentScore = formValue[currentFormObject.childrenKey!.last] ?? "";
- void selectRaidoChange(Option e) {
- if (formValue[currentFormObject.childrenKey!.first] == e.value) {
- formValue[currentFormObject.childrenKey!.first] = '';
- currentSelected = '';
- } else {
- currentSelected = e.value ?? '';
- formValue[currentFormObject.childrenKey!.first] = currentSelected;
- }
- setState(() {});
- }
- void changeScore(String? score) {
- currentScore = score ?? '';
- formValue[currentFormObject.childrenKey!.last] = currentScore;
- setState(() {});
- }
- return ExamRadioScore(
- options: options,
- currentFormObject: currentFormObject,
- selectRaidoChange: selectRaidoChange,
- currentSelected: currentSelected,
- changeScore: changeScore,
- currentScore: currentScore,
- );
- }
- Widget _buildRadioExtraDescription(FormObject currentFormObject) {
- print(currentFormObject.toJson());
- List<Option> options = currentFormObject.options ?? [];
- String currentValue = formValue[currentFormObject.key!] ?? "";
- String otherDecrition =
- formValue[currentFormObject.childrenKey!.first] ?? "";
- dynamic otherItem = currentFormObject.groupKeys!.first;
- void selectRaidoChange(Option e) {
- currentValue = e.value ?? '';
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- void changeExtraDescription(String? extraDescription) {
- otherDecrition = extraDescription ?? '';
- formValue[currentFormObject.childrenKey!.first] = otherDecrition;
- setState(() {});
- }
- return ExamRadioExtraDescription(
- options: options,
- currentFormObject: currentFormObject,
- selectRaidoChange: selectRaidoChange,
- currentSelected: currentValue,
- changeExtraDescription: changeExtraDescription,
- currentExtraDescription: otherDecrition,
- extraDescriptiveItem: otherItem,
- );
- }
- /// 体温组件
- Widget _buildBodyTemperature(FormObject currentFormObject) {
- String currentInputValue = formValue[currentFormObject.key!] ?? '';
- void bodyTemperatureInput(String value) {
- formValue[currentFormObject.key!] = value;
- currentInputValue = formValue[currentFormObject.key!];
- setState(() {});
- }
- return ExamBodyTemperature(
- currentInputValue: currentInputValue,
- bodyTemperatureInput: bodyTemperatureInput,
- currentFormObject: currentFormObject,
- );
- }
- Widget _buildToxicSubstance(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- String currentValue = formValue[currentFormObject.childrenKey!.first] ?? "";
- Map? currentSelectedToxicSubstance =
- formValue[currentFormObject.childrenKey!.last];
- void selectRaidoChange(Map e) {
- // TODO 处理一下取消选择的问题
- currentSelectedToxicSubstance = e;
- formValue[currentFormObject.childrenKey!.last] =
- currentSelectedToxicSubstance;
- setState(() {});
- }
- void selectValueChange(String e) {
- currentValue = e;
- formValue[currentFormObject.childrenKey!.first] = currentValue;
- setState(() {});
- }
- return ExamToxicSubstance(
- currentFormObject: currentFormObject,
- currentSelectedToxicSubstance: currentSelectedToxicSubstance,
- currentValue: currentValue,
- options: options,
- selectRadioChange: selectRaidoChange,
- selectValueChange: selectValueChange,
- );
- }
- /// 血氧
- Widget _buildBloodOxygen(FormObject currentFormObject) {
- Map<String, dynamic> currentValue = formValue;
- void bloodOxygenInput(Map<String, dynamic> bloodOxygen) {
- formValue['Pulse_Frequency'] = bloodOxygen['Pulse_Frequency'];
- formValue['Spo2'] = bloodOxygen['Spo2'];
- currentValue = bloodOxygen;
- setState(() {});
- }
- return ExamBloodOxygen(
- currentValue: currentValue,
- bloodOxygenInput: bloodOxygenInput,
- );
- }
- /// 住院史
- Widget _buildMedicalHistory(FormObject currentFormObject) {
- List<dynamic> currentValue = formValue[currentFormObject.key!] ?? [];
- int currentId = currentValue.length + 1;
- void resultChange(Map result) {
- currentValue.add(result);
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- void editResult(EditTableValue result) {
- currentValue[result.id! - 1] = result.value;
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- Future<void> addTableData() async {
- Get.dialog(
- HospitalizationHistoryForm(
- fromResult: (result) => resultChange(result),
- currentId: currentId,
- ),
- );
- }
- Future<void> editTableData(EditTableValue editTableValue) async {
- Get.dialog(
- HospitalizationHistoryForm(
- fromResult: (result) => editResult(result),
- currentId: editTableValue.id!,
- admissionJson: editTableValue.value,
- ),
- );
- }
- return FittedBox(
- child: ExamTable(
- tableThList: const ['序号', '入院日期', '出院日期', '原因', '医疗机构名称', '病案号', '操作'],
- currentFormObject: currentFormObject,
- currentValue: currentValue,
- addTableData: addTableData,
- editTableData: (value) => editTableData(value),
- removeTableData: (id) {
- List values = formValue[currentFormObject.key!];
- values.removeWhere((element) => element["id"] == id.toString());
- setState(() {});
- },
- ),
- );
- }
- /// 家庭病床史
- Widget _buildHomecareBedHistory(FormObject currentFormObject) {
- List<dynamic> currentValue = formValue[currentFormObject.key!] ?? [];
- int currentId = currentValue.length + 1;
- void resultChange(Map result) {
- int length = 0;
- for (var i in result.keys) {
- if (result[i] == "") {
- length++;
- continue;
- }
- }
- if (length == result.keys.length - 1) {
- return;
- }
- currentValue.add(result);
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- void editResult(EditTableValue result) {
- currentValue[result.id! - 1] = result.value;
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- Future<void> addTableData() async {
- Get.dialog(
- HomecareBedHistoryFrom(
- fromResult: (result) => resultChange(result),
- currentId: currentId,
- ),
- );
- }
- Future<void> editTableData(EditTableValue editTableValue) async {
- Get.dialog(
- HomecareBedHistoryFrom(
- fromResult: (result) => editResult(result),
- currentId: editTableValue.id!,
- admissionJson: editTableValue.value,
- ),
- );
- }
- return FittedBox(
- child: ExamTable(
- tableThList: const ['序号', '建床日期', '撤床日期', '原因', '医疗机构名称', '病案号', '操作'],
- currentFormObject: currentFormObject,
- currentValue: currentValue,
- addTableData: addTableData,
- editTableData: (value) => editTableData(value),
- removeTableData: (id) {
- List values = formValue[currentFormObject.key!];
- values.removeWhere((element) => element["id"] == id.toString());
- setState(() {});
- },
- ),
- );
- }
- Widget _buildMainMedicationHistory(FormObject currentFormObject) {
- List<dynamic> currentValue = formValue[currentFormObject.key!] ?? [];
- int currentId = currentValue.length + 1;
- void resultChange(Map result) {
- currentValue.add(result);
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- void editResult(EditTableValue result) {
- currentValue[result.id! - 1] = result.value;
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- Future<void> addTableData() async {
- Get.dialog(
- MainMedicationStatusFrom(
- fromResult: (result) => resultChange(result),
- currentId: currentId,
- ),
- );
- }
- Future<void> editTableData(EditTableValue editTableValue) async {
- Get.dialog(
- MainMedicationStatusFrom(
- fromResult: (result) => editResult(result),
- currentId: editTableValue.id!,
- admissionJson: editTableValue.value,
- ),
- );
- }
- return FittedBox(
- child: ExamTable(
- tableThList: const [
- '序号',
- '药物名称',
- '用法',
- '用量',
- '用药时间',
- '服药依从性(1规律 2间断 3不服药)',
- '操作'
- ],
- currentFormObject: currentFormObject,
- currentValue: currentValue,
- addTableData: addTableData,
- editTableData: (value) => editTableData(value),
- removeTableData: (id) {
- List values = formValue[currentFormObject.key!];
- values.removeWhere((element) => element["id"] == id.toString());
- setState(() {});
- },
- ),
- );
- }
- Widget _buildInoculateHistory(FormObject currentFormObject) {
- List<dynamic> currentValue = formValue[currentFormObject.key!] ?? [];
- int currentId = currentValue.length + 1;
- void resultChange(Map result) {
- currentValue.add(result);
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- void editResult(EditTableValue result) {
- currentValue[result.id! - 1] = result.value;
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- Future<void> addTableData() async {
- Get.dialog(
- InoculateHistoryFrom(
- fromResult: (result) => resultChange(result),
- currentId: currentId,
- ),
- );
- }
- Future<void> editTableData(EditTableValue editTableValue) async {
- Get.dialog(
- InoculateHistoryFrom(
- fromResult: (result) => editResult(result),
- currentId: editTableValue.id!,
- admissionJson: editTableValue.value,
- ),
- );
- }
- return ExamTable(
- tableThList: const ['序号', '疫苗名称', '接种日期', '接种机构', '操作'],
- currentFormObject: currentFormObject,
- currentValue: currentValue,
- addTableData: addTableData,
- editTableData: (value) => editTableData(value),
- removeTableData: (id) {
- List values = formValue[currentFormObject.key!];
- values.removeWhere((element) => element["id"] == id.toString());
- setState(() {});
- },
- );
- }
- /// 体重
- Widget _buildBodyWeight(FormObject currentFormObject) {
- String currentInputValue = formValue[currentFormObject.key!] ?? '';
- void bodyWeightInput(String value) {
- formValue[currentFormObject.key!] = value;
- currentInputValue = formValue[currentFormObject.key!];
- setState(() {});
- }
- return ExamBodyWeight(
- currentInputValue: currentInputValue,
- bodyWeightInput: bodyWeightInput,
- currentFormObject: currentFormObject,
- );
- }
- /// 血糖
- Widget _buildBodySugar(FormObject currentFormObject) {
- String currentInputValue = formValue[currentFormObject.key!] ?? '';
- void bloodSugarInput(String value) {
- formValue[currentFormObject.key!] = value;
- currentInputValue = formValue[currentFormObject.key!];
- setState(() {});
- }
- return ExamBloodSugar(
- currentInputValue: currentInputValue,
- bloodSugarInput: bloodSugarInput,
- currentFormObject: currentFormObject,
- );
- }
- Widget _buildAbnormal(FormObject currentFormObject) {
- List<dynamic> currentValue = [];
- var value = formValue[currentFormObject.key!];
- if (value is String) {
- currentValue.add(value);
- } else {
- currentValue = value ?? [];
- }
- Future<void> addAbnormalData() async {
- String? result = await VDialogInput(
- title: currentFormObject.label,
- ).show();
- if (result.isNotNullOrEmpty) {
- currentValue.add(result);
- formValue[currentFormObject.key!] = null;
- formValue[currentFormObject.key!] = currentValue;
- }
- setState(() {});
- }
- Future<void> deleteAbnormalData(int index) async {
- currentValue.removeAt(index);
- formValue[currentFormObject.key!] = null;
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- return ExamAbnormal(
- currentFormObject: currentFormObject,
- currentValue: currentValue,
- addAbnormal: addAbnormalData,
- deleteAbnormal: deleteAbnormalData,
- );
- }
- }
|