Selaa lähdekoodia

0018367: 【孕产妇健康管理】第1次产前检查服务记录表,“家族史”项,如果选择“遗传性疾病史”“精神疾病史”时,无输入框填写具体说明

loki.wu 11 kuukautta sitten
vanhempi
commit
ab4c601a33

+ 18 - 2
lib/pages/check/maternal_health_management/forms/first_form.dart

@@ -30,9 +30,7 @@ class FirstMaternalHealthManagementFormState
 
   @override
   void initState() {
-    //var _path = "assets/MaternalHealthManagement.json";
     MaternalHealthFormValue.instance.initListener();
-    // rootBundle.loadString(_path).then((value) {});
     Get.find<MaternalHealthManagementController>()
         .getTemplate("MaternalHealthManagement")
         .then((value) {
@@ -52,6 +50,24 @@ class FirstMaternalHealthManagementFormState
       setState(() {
         _template = value;
       });
+      Future.delayed(Duration(milliseconds: 500), () {
+        if (!FormInfo.instance.formValue.containsKey("Family_History") &&
+            FormInfo.instance.formValue["Family_History"] !=
+                "Family_History_2") {
+          FormInfo.instance.onChangeTargetValue.emit(
+            this,
+            TargetFormArgs("Family_History_2_Detail", isHidden: true),
+          );
+        }
+        if (!FormInfo.instance.formValue.containsKey("Family_History") &&
+            FormInfo.instance.formValue["Family_History"] !=
+                "Family_History_3") {
+          FormInfo.instance.onChangeTargetValue.emit(
+            this,
+            TargetFormArgs("Family_History_3_Detail", isHidden: true),
+          );
+        }
+      });
     });
     super.initState();
   }

+ 2 - 2
lib/pages/check/prescription/prescription_form_keys.dart

@@ -1,6 +1,6 @@
 class PrescriptionFormKeys {
   static Map<String, String> AllFormKeys = {
-    "BloodSugarDisorder": "2型糖尿病患者健康教育处方",
+    "DiabetesPrescription": "2型糖尿病患者健康教育处方",
     "HypertensionPrescription": "高血压患者健康教育处方",
     "PsychiatricPrescription": "严重精神障碍健康教育处方",
     "TuberculosisPrescription": "肺结核患者健康教育处方",
@@ -47,7 +47,7 @@ class PrescriptionFormKeys {
   };
 
   /// 2型糖尿病患者健康教育处方
-  static const String BLOODSUGAR = 'BloodSugarDisorder';
+  static const String BLOODSUGAR = 'DiabetesPrescription';
 
   /// 高血压患者健康教育处方
   static const String HYPERTENSION = 'HypertensionPrescription';

+ 7 - 1
lib/pages/check/widgets/exam_configurable/exam_single_option.dart

@@ -136,7 +136,13 @@ class ExamSingleOptionState extends State<ExamSingleOption> {
       type = UpdateFormType.Add;
     } else if (FormInfo.instance.formValue
         .containsKey(currentFormObject.parentKey!)) {
-      FormInfo.instance.formValue.remove(currentFormObject.parentKey!);
+      var sourceValue =
+          FormInfo.instance.formValue[currentFormObject.parentKey!] as List;
+      if (sourceValue.contains(currentFormObject.key!)) {
+        sourceValue.remove(currentFormObject.parentKey!);
+      }
+      type = UpdateFormType.Remove;
+    } else {
       type = UpdateFormType.Remove;
     }
     FormInfo.instance.onValueChange.emit(

+ 13 - 3
lib/pages/check/widgets/exam_configurable/exam_text_input.dart

@@ -11,11 +11,9 @@ class ExamTextInput extends StatefulWidget {
   const ExamTextInput({
     super.key,
     required this.currentFormObject,
-    required this.currentInputValue,
     this.isNumber = false,
   });
   final FormObject currentFormObject;
-  final String currentInputValue;
   final bool isNumber;
 
   @override
@@ -25,10 +23,10 @@ class ExamTextInput extends StatefulWidget {
 class _ExamInputState extends State<ExamTextInput> {
   String _currentValue = '';
   bool _isDisabledValue = false;
+  bool _isHidden = false;
 
   @override
   void initState() {
-    _currentValue = widget.currentInputValue;
     if (FormInfo.instance.formValue.containsKey(widget.currentFormObject.key)) {
       _currentValue = FormInfo.instance.formValue[widget.currentFormObject.key];
     }
@@ -44,6 +42,9 @@ class _ExamInputState extends State<ExamTextInput> {
 
   @override
   Widget build(BuildContext context) {
+    if (_isHidden) {
+      return SizedBox();
+    }
     return ExamCard(
       title: widget.currentFormObject.label ?? '',
       color: _isDisabledValue ? Colors.grey[300]! : Colors.white,
@@ -117,6 +118,15 @@ class _ExamInputState extends State<ExamTextInput> {
     if (e.targetKey != widget.currentFormObject.key) {
       return;
     }
+    if (e.isHidden) {
+      setState(() {
+        _isHidden = true;
+      });
+    } else {
+      setState(() {
+        _isHidden = false;
+      });
+    }
     if (e.isDisabledValue) {
       setState(() {
         _isDisabledValue = true;

+ 8 - 3
lib/pages/form/form_view.dart

@@ -94,6 +94,14 @@ class FormItemsView extends StatelessWidget {
                   width: constraints.maxWidth / 2,
                   child: ExamDate(currentFormObject: e),
                 );
+              case "longInput":
+                var width = constraints.maxWidth;
+                return Container(
+                  width: width,
+                  child: ExamTextInput(
+                    currentFormObject: e,
+                  ),
+                );
               case "input":
                 var width = constraints.maxWidth / 2;
                 if ((e.label?.length ?? 0) > 15) {
@@ -102,7 +110,6 @@ class FormItemsView extends StatelessWidget {
                 return Container(
                   width: width,
                   child: ExamTextInput(
-                    currentInputValue: "",
                     currentFormObject: e,
                   ),
                 );
@@ -110,7 +117,6 @@ class FormItemsView extends StatelessWidget {
                 return Container(
                   height: 200,
                   child: ExamTextInput(
-                    currentInputValue: "",
                     currentFormObject: e,
                   ),
                 );
@@ -119,7 +125,6 @@ class FormItemsView extends StatelessWidget {
                   width: constraints.maxWidth / 2,
                   child: ExamTextInput(
                     currentFormObject: e,
-                    currentInputValue: '',
                     isNumber: true,
                   ),
                 );

+ 61 - 0
lib/pages/form/maternal_health_form.dart

@@ -188,6 +188,7 @@ class MaternalHealthFormValue extends BaseFormValueChange {
   void changeFamilyHistory(UpdateFormArgs e) {
     UpdateFormType type = e.type;
     bool isDisabledValue = false;
+
     if (type == UpdateFormType.Add && e.sourceValue == "Family_History_1") {
       ///选中了无,则禁用其他选项
       isDisabledValue = true;
@@ -195,9 +196,69 @@ class MaternalHealthFormValue extends BaseFormValueChange {
         e.sourceValue == "Family_History_1") {
       ///取消选中无,则取消禁用其他选项
       isDisabledValue = false;
+    } else if (type == UpdateFormType.Add &&
+        e.sourceValue == "Family_History_2") {
+      //选中了遗传性病史,则显示遗传性病史详情
+      FormInfo.instance.onChangeTargetValue.emit(
+        this,
+        TargetFormArgs(
+          "Family_History_2_Detail",
+          isHidden: false,
+        ),
+      );
+      return;
+    } else if (type == UpdateFormType.Remove &&
+        e.sourceValue == "Family_History_2") {
+      //取消选中了遗传性病史,则隐藏遗传性病史详情
+      FormInfo.instance.onChangeTargetValue.emit(
+        this,
+        TargetFormArgs(
+          "Family_History_2_Detail",
+          isHidden: true,
+        ),
+      );
+      return;
+    } else if (type == UpdateFormType.Add &&
+        e.sourceValue == "Family_History_3") {
+      //选中了精神疾病史,则显示精神疾病史详情
+      FormInfo.instance.onChangeTargetValue.emit(
+        this,
+        TargetFormArgs(
+          "Family_History_3_Detail",
+          isHidden: false,
+        ),
+      );
+      return;
+    } else if (type == UpdateFormType.Remove &&
+        e.sourceValue == "Family_History_3") {
+      //取消选中了精神疾病史
+      FormInfo.instance.onChangeTargetValue.emit(
+        this,
+        TargetFormArgs(
+          "Family_History_3_Detail",
+          isHidden: true,
+        ),
+      );
+      return;
     } else {
       return;
     }
+    if (isDisabledValue) {
+      FormInfo.instance.onChangeTargetValue.emit(
+        this,
+        TargetFormArgs(
+          "Family_History_3_Detail",
+          isHidden: true,
+        ),
+      );
+      FormInfo.instance.onChangeTargetValue.emit(
+        this,
+        TargetFormArgs(
+          "Family_History_2_Detail",
+          isHidden: true,
+        ),
+      );
+    }
     FormInfo.instance.onChangeTargetValue.emit(
       this,
       TargetFormArgs(