Browse Source

完成第 2~5 次产前随访

loki.wu 11 months ago
parent
commit
fa895f3de2

+ 55 - 1
assets/PrenatalFollowupServiceRecord.json

@@ -372,10 +372,64 @@
                 "childrenKey": null
             },
             {
-                "label": "其他",
+                "label": "自我监测",
                 "defaultValue": null,
                 "span": 12,
                 "key": "Guidance_5",
+                "type": "option",
+                "border": null,
+                "disabledValue": null,
+                "options": null,
+                "children": null,
+                "append": "",
+                "placeholder": "",
+                "required": false,
+                "show-limit": false,
+                "parentKey": "Guidance",
+                "buttonName": null,
+                "childrenKey": null
+            },
+            {
+                "label": "分娩准备",
+                "defaultValue": null,
+                "span": 12,
+                "key": "Guidance_Delivery_Preparation",
+                "type": "option",
+                "border": null,
+                "disabledValue": null,
+                "options": null,
+                "children": null,
+                "append": "",
+                "placeholder": "",
+                "required": false,
+                "show-limit": false,
+                "parentKey": "Guidance",
+                "buttonName": null,
+                "childrenKey": null
+            },
+            {
+                "label": "母乳喂养",
+                "defaultValue": null,
+                "span": 12,
+                "key": "Guidance_Breast_Feeding",
+                "type": "option",
+                "border": null,
+                "disabledValue": null,
+                "options": null,
+                "children": null,
+                "append": "",
+                "placeholder": "",
+                "required": false,
+                "show-limit": false,
+                "parentKey": "Guidance",
+                "buttonName": null,
+                "childrenKey": null
+            },
+            {
+                "label": "其他",
+                "defaultValue": null,
+                "span": 12,
+                "key": "Guidance_Other",
                 "type": "input",
                 "border": null,
                 "disabledValue": null,

+ 15 - 12
lib/pages/check/maternal_health_management/antenatal_visit.dart

@@ -2,12 +2,18 @@ import 'package:flutter/material.dart';
 import 'package:flutter/services.dart';
 import 'package:get/get.dart';
 import 'package:vitalapp/components/appbar.dart';
+import 'package:vitalapp/pages/form/form_info.dart';
 import 'package:vitalapp/pages/form/form_view.dart';
 import 'package:vitalapp/pages/form/maternal_health_form.dart';
+import 'package:vitalapp/pages/form/prenatal_followup_form.dart';
 
 import 'maternal_health_management_controller.dart';
 
 class AntenatalVisitForm extends StatefulWidget {
+  final int times;
+
+  AntenatalVisitForm(this.times);
+
   @override
   State<StatefulWidget> createState() {
     return AntenatalVisitFormState();
@@ -19,24 +25,21 @@ class AntenatalVisitFormState extends State<AntenatalVisitForm> {
 
   @override
   void initState() {
-    var _path = "assets/PrenatalFollowupServiceRecord.json";
-    MaternalHealthFormValue.instance.initListener();
-    rootBundle.loadString(_path).then((value) {
+    Get.find<MaternalHealthManagementController>()
+        .getTemplate("PrenatalFollowupServiceRecord")
+        .then((value) {
       setState(() {
         _template = value;
+        PrenatalFollowupForm.instance.initListener(widget.times);
       });
     });
-    // Get.find<MaternalHealthManagementController>()
-    //     .getTemplate("MaternalHealthManagement")
-    //     .then((value) {
-
-    // });
+    FormInfo.instance.formValue["times"] = widget.times;
     super.initState();
   }
 
   @override
   void dispose() {
-    MaternalHealthFormValue.instance.dispose();
+    PrenatalFollowupForm.instance.dispose();
     super.dispose();
   }
 
@@ -45,12 +48,12 @@ class AntenatalVisitFormState extends State<AntenatalVisitForm> {
     return Scaffold(
       backgroundColor: const Color.fromRGBO(238, 238, 238, 1),
       appBar: VAppBar(
-        titleWidget: const Text("第2次产前检查服务记录表"),
+        titleWidget: Text("第${widget.times}次产前检查服务记录表"),
         actions: [
           ElevatedButton(
             onPressed: () async {
-              bool result =
-                  await Get.find<MaternalHealthManagementController>().save();
+              bool result = await Get.find<MaternalHealthManagementController>()
+                  .save("PrenatalFollowupServiceRecord");
               if (result) {
                 Get.back();
               }

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

@@ -49,8 +49,8 @@ class FirstMaternalHealthManagementFormState
         actions: [
           ElevatedButton(
             onPressed: () async {
-              bool result =
-                  await Get.find<MaternalHealthManagementController>().save();
+              bool result = await Get.find<MaternalHealthManagementController>()
+                  .save("MaternalHealthManagement");
               if (result) {
                 Get.back();
               }

+ 24 - 14
lib/pages/check/maternal_health_management/maternal_health_management_controller.dart

@@ -13,13 +13,16 @@ import 'package:vitalapp/managers/interfaces/template.dart';
 import 'package:vitalapp/pages/form/form_info.dart';
 import 'package:vitalapp/store/store.dart';
 
+import 'antenatal_visit.dart';
 import 'first_form.dart';
 import 'state.dart';
 
 class MaternalHealthManagementController extends GetxController {
   MaternalHealthManagementController();
 
-  final String followUpType = "MaternalHealthManagement";
+  final String firstFollowUpkey = "MaternalHealthManagement";
+
+  final String prenatalFollowupKey = "PrenatalFollowupServiceRecord";
 
   final _followUpManager = Get.find<IFollowUpManager>();
   final _templateManager = Get.find<ITemplateManager>();
@@ -45,7 +48,7 @@ class MaternalHealthManagementController extends GetxController {
     _initData();
   }
 
-  Future<bool> save() async {
+  Future<bool> save(String key) async {
     List<String> followUpPhotos = [];
     DateTime followUpTime = DateTime.now();
     String? followUpData;
@@ -67,7 +70,7 @@ class MaternalHealthManagementController extends GetxController {
     if (isEdit) {
       result = await _followUpManager.updateFollowUp(
             UpdateFollowUpRequest(
-              key: "MaternalHealthManagement",
+              key: key,
               followUpData: followUpData,
               followUpTime: followUpTime,
               nextFollowUpTime: nextFollowUpTime,
@@ -80,7 +83,7 @@ class MaternalHealthManagementController extends GetxController {
     } else {
       String createResult = await _followUpManager.createFollowUp(
         CreateFollowUpRequest(
-          key: "MaternalHealthManagement",
+          key: key,
           patientCode: patientCode,
           templateCode: templateCode,
           followUpData: followUpData,
@@ -107,16 +110,10 @@ class MaternalHealthManagementController extends GetxController {
     try {
       var patientCode = Store.user.currentSelectPatientInfo?.code ?? '';
       var result = await _followUpManager.getFollowUpRecordList(
-        [followUpType],
+        [firstFollowUpkey, prenatalFollowupKey],
         patientCode,
       );
       List<FollowUpRecordDTO> followUpDTOList = [];
-      // 如果是web端并且是离线模式,则从本地获取数据
-      if (!kIsWeb && kIsOnline) {
-        List<FollowUpRecordDTO> offlineFollowUpList = await _followUpManager
-            .getPatientNotUploadedRecordList(patientCode, followUpType);
-        followUpDTOList = offlineFollowUpList;
-      }
       followUpDTOList.addAll(result ?? []);
       state.followUpDTOList = followUpDTOList;
     } catch (e) {
@@ -124,9 +121,17 @@ class MaternalHealthManagementController extends GetxController {
     }
   }
 
-  String getFollowUpValueByKey(String key) {
-    if (key == "MaternalHealthManagement") {
+  String getFollowUpValueByKey(FollowUpRecordDataDTO dto) {
+    var key = dto.key;
+    if (key == firstFollowUpkey) {
       return "第 1 次产前检查";
+    } else if (key == prenatalFollowupKey) {
+      Map datas = jsonDecode(dto.followUpData ?? '');
+      if (datas.containsKey("times")) {
+        int times = datas["times"] ?? 2;
+        return "第 ${times} 次产前随访";
+      }
+      return "第 2~5 次产前随访";
     }
     return "";
   }
@@ -139,7 +144,12 @@ class MaternalHealthManagementController extends GetxController {
     var datas = jsonDecode(dataDto.followUpData ?? '');
     if (datas is Map<String, dynamic>) {
       FormInfo.instance.formValue = datas;
-      Get.to(FirstMaternalHealthManagementForm());
+      if (dataDto.key == firstFollowUpkey) {
+        Get.to(FirstMaternalHealthManagementForm());
+      } else if (dataDto.key == prenatalFollowupKey) {
+        int times = FormInfo.instance.formValue["times"] ?? 2;
+        Get.to(AntenatalVisitForm(times));
+      }
     }
   }
 

+ 5 - 5
lib/pages/check/maternal_health_management/view.dart

@@ -48,8 +48,8 @@ class MaternalHealthManagement
                       }
                       if (time == 1) {
                         Get.to(FirstMaternalHealthManagementForm());
-                      } else if (time == 2) {
-                        Get.to(AntenatalVisitForm());
+                      } else if (time >= 2 && time <= 5) {
+                        Get.to(AntenatalVisitForm(time));
                       }
                     },
                   ));
@@ -176,7 +176,7 @@ class MaternalHealthManagement
                       final width = c.maxWidth - 100;
                       return SizedBox(
                         width: width,
-                        child: _buildBaseInfoRow(dataDto.key ?? ""),
+                        child: _buildBaseInfoRow(dataDto),
                       );
                     }),
                     const SizedBox(
@@ -244,11 +244,11 @@ class MaternalHealthManagement
     );
   }
 
-  Widget _buildBaseInfoRow(String key) {
+  Widget _buildBaseInfoRow(FollowUpRecordDataDTO dto) {
     return SizedBox(
       child: RecordCommonItem(
         itemName: '随访病症',
-        itemValue: controller.getFollowUpValueByKey(key),
+        itemValue: controller.getFollowUpValueByKey(dto),
         fontSize: 20,
       ),
     );

+ 10 - 0
lib/pages/check/widgets/exam_configurable/exam_single_option.dart

@@ -27,6 +27,7 @@ class ExamSingleOptionState extends State<ExamSingleOption> {
   FormObject get currentFormObject => widget.currentFormObject;
   bool _isSelected = false;
   bool _isDisabledValue = false;
+  bool _isHidden = false;
 
   @override
   void initState() {
@@ -60,6 +61,9 @@ class ExamSingleOptionState extends State<ExamSingleOption> {
 
   @override
   Widget build(BuildContext context) {
+    if (_isHidden) {
+      return SizedBox();
+    }
     return Container(
       padding: const EdgeInsets.all(7),
       child: InkWell(
@@ -150,6 +154,12 @@ class ExamSingleOptionState extends State<ExamSingleOption> {
     if (e.targetKey != widget.currentFormObject.key) {
       return;
     }
+    if (e.isHidden) {
+      setState(() {
+        _isHidden = true;
+      });
+      return;
+    }
     if (e.isDisabledValue) {
       setState(() {
         _isSelected = false;

+ 48 - 0
lib/pages/form/base_form_value.dart

@@ -27,4 +27,52 @@ abstract class BaseFormValueChange {
       return;
     }
   }
+
+  ///转诊
+  void onReferralChange(UpdateFormArgs e) {
+    UpdateFormType type = e.type;
+    bool isDisabledValue = false;
+    if ((type == UpdateFormType.Add && e.sourceValue == "referral_1")) {
+      ///选中了无,则禁用其他选项
+      isDisabledValue = true;
+    } else if ((type == UpdateFormType.Remove &&
+            e.sourceValue == "referral_1") ||
+        (type == UpdateFormType.Add && e.sourceValue == "referral_2")) {
+      ///取消选中无或选中有,则取消禁用其他选项
+      isDisabledValue = false;
+    }
+    FormInfo.instance.onChangeTargetValue.emit(
+      this,
+      TargetFormArgs(
+        "Reason_For_Referral",
+        isDisabledValue: isDisabledValue,
+      ),
+    );
+    FormInfo.instance.onChangeTargetValue.emit(
+      this,
+      TargetFormArgs(
+        "Institution_And_Department",
+        isDisabledValue: isDisabledValue,
+      ),
+    );
+    if (e.sourceValue == "referral_1") {
+      FormInfo.instance.onChangeTargetValue.emit(
+        this,
+        TargetFormArgs(
+          "referral_2",
+          isDisabledValue: false,
+          targetValue: "cancelSelection",
+        ),
+      );
+    } else if (e.sourceValue == "referral_2") {
+      FormInfo.instance.onChangeTargetValue.emit(
+        this,
+        TargetFormArgs(
+          "referral_1",
+          isDisabledValue: false,
+          targetValue: "cancelSelection",
+        ),
+      );
+    }
+  }
 }

+ 6 - 0
lib/pages/form/form_info.dart

@@ -42,12 +42,18 @@ class UpdateFormArgs {
 class TargetFormArgs {
   final String targetKey;
   final String targetValue;
+
+  ///是否禁用组件
   final bool isDisabledValue;
 
+  ///是否隐藏组件(不显示)
+  final bool isHidden;
+
   TargetFormArgs(
     this.targetKey, {
     this.targetValue = "",
     this.isDisabledValue = false,
+    this.isHidden = false,
   });
 }
 

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

@@ -268,53 +268,6 @@ class MaternalHealthFormValue extends BaseFormValueChange {
     );
   }
 
-  void onReferralChange(UpdateFormArgs e) {
-    UpdateFormType type = e.type;
-    bool isDisabledValue = false;
-    if ((type == UpdateFormType.Add && e.sourceValue == "referral_1")) {
-      ///选中了无,则禁用其他选项
-      isDisabledValue = true;
-    } else if ((type == UpdateFormType.Remove &&
-            e.sourceValue == "referral_1") ||
-        (type == UpdateFormType.Add && e.sourceValue == "referral_2")) {
-      ///取消选中无或选中有,则取消禁用其他选项
-      isDisabledValue = false;
-    }
-    FormInfo.instance.onChangeTargetValue.emit(
-      this,
-      TargetFormArgs(
-        "Reason_For_Referral",
-        isDisabledValue: isDisabledValue,
-      ),
-    );
-    FormInfo.instance.onChangeTargetValue.emit(
-      this,
-      TargetFormArgs(
-        "Institution_And_Department",
-        isDisabledValue: isDisabledValue,
-      ),
-    );
-    if (e.sourceValue == "referral_1") {
-      FormInfo.instance.onChangeTargetValue.emit(
-        this,
-        TargetFormArgs(
-          "referral_2",
-          isDisabledValue: false,
-          targetValue: "cancelSelection",
-        ),
-      );
-    } else if (e.sourceValue == "referral_2") {
-      FormInfo.instance.onChangeTargetValue.emit(
-        this,
-        TargetFormArgs(
-          "referral_1",
-          isDisabledValue: false,
-          targetValue: "cancelSelection",
-        ),
-      );
-    }
-  }
-
   void onValueChange(UpdateFormArgs e, String sourceValue, String targetKey) {
     UpdateFormType type = e.type;
     bool isDisabledValue = false;

+ 59 - 0
lib/pages/form/prenatal_followup_form.dart

@@ -0,0 +1,59 @@
+import 'base_form_value.dart';
+import 'form_info.dart';
+
+class PrenatalFollowupForm extends BaseFormValueChange {
+  static PrenatalFollowupForm? _prenatalFollowupForm;
+
+  PrenatalFollowupForm._internal();
+
+  ///第 1 次产前检查服务记录表的值
+  static PrenatalFollowupForm get instance {
+    _prenatalFollowupForm ??= PrenatalFollowupForm._internal();
+    return _prenatalFollowupForm!;
+  }
+
+  void initListener(int times) {
+    FormInfo.instance.onValueChange.addListener(_onValueChange);
+    Future.delayed(Duration(milliseconds: 300), () {
+      if (times <= 3) {
+        //第2、3次随访,不需要显示分娩准备、
+        FormInfo.instance.onChangeTargetValue.emit(
+          this,
+          TargetFormArgs(
+            "Guidance_Delivery_Preparation",
+            isHidden: true,
+          ),
+        );
+      }
+      if (times == 2) {
+        //第2次随访,不需要显示自我监测\母乳喂养
+        FormInfo.instance.onChangeTargetValue.emit(
+          this,
+          TargetFormArgs(
+            "Guidance_5",
+            isHidden: true,
+          ),
+        );
+        FormInfo.instance.onChangeTargetValue.emit(
+          this,
+          TargetFormArgs(
+            "Guidance_Breast_Feeding",
+            isHidden: true,
+          ),
+        );
+      }
+    });
+  }
+
+  void dispose() {
+    FormInfo.instance.onValueChange.removeListener(_onValueChange);
+  }
+
+  void _onValueChange(Object sender, UpdateFormArgs e) {
+    String sourceKey = e.sourceKey;
+    switch (sourceKey) {
+      case "Referral":
+        onReferralChange(e);
+    }
+  }
+}