Browse Source

1、人群随访表单提交

guanxinyi 1 year ago
parent
commit
3ff8da11d4

+ 6 - 0
lib/pages/check/follow_up/controller.dart

@@ -1,9 +1,12 @@
 import 'package:fis_jsonrpc/rpc.dart';
 import 'package:get/get.dart';
 import 'package:vnoteapp/managers/interfaces/follow_up.dart';
+import 'package:vnoteapp/pages/check/follow_up/state.dart';
 import 'package:vnoteapp/pages/check/widgets/configurable_form.dart';
 
 class FollowUpController extends GetxController {
+  final state = FollowUpState();
+
   FollowUpController();
   final _followUpManager = Get.find<IFollowUpManager>();
   late String patientCode;
@@ -48,6 +51,9 @@ class FollowUpController extends GetxController {
         patientCode: patientCode,
         templateCode: templateCode,
         followUpData: data,
+        followUpTime: state.followUpTime,
+        nextFollowUpTime: state.nextFollowUpTime,
+        followUpMode: state.followUpMode ?? FollowUpModeEnum.Outpatient,
       ),
     );
   }

+ 17 - 0
lib/pages/check/follow_up/state.dart

@@ -0,0 +1,17 @@
+import 'package:fis_jsonrpc/rpc.dart';
+import 'package:get/get_rx/src/rx_types/rx_types.dart';
+
+class FollowUpState {
+  final Rx<DateTime?> _followUpTime = Rx(null);
+  final Rx<DateTime?> _nextFollowUpTime = Rx(null);
+  final Rx<FollowUpModeEnum?> _followUpMode = Rx(null);
+
+  DateTime? get followUpTime => _followUpTime.value;
+  set followUpTime(DateTime? val) => _followUpTime.value = val;
+
+  DateTime? get nextFollowUpTime => _nextFollowUpTime.value;
+  set nextFollowUpTime(DateTime? val) => _nextFollowUpTime.value = val;
+
+  FollowUpModeEnum? get followUpMode => _followUpMode.value;
+  set followUpMode(FollowUpModeEnum? val) => _followUpMode.value = val;
+}

+ 104 - 0
lib/pages/check/follow_up/view.dart

@@ -1,8 +1,13 @@
 import 'package:flutter/material.dart';
 import 'package:get/get.dart';
+import 'package:intl/intl.dart';
 import 'package:vnoteapp/components/appbar.dart';
+import 'package:vnoteapp/components/dialog_date.dart';
+import 'package:vnoteapp/components/input.dart';
 import 'package:vnoteapp/pages/check/widgets/check_category_widget.dart';
 import 'package:vnoteapp/pages/check/widgets/configurable_card.dart';
+import 'package:vnoteapp/pages/check/widgets/form_cell.dart';
+import 'package:vnoteapp/store/store.dart';
 
 import 'index.dart';
 
@@ -55,6 +60,104 @@ class FollowUpPage extends GetView<FollowUpController> {
     );
   }
 
+  Widget _buildFollowUp() {
+    return Card(
+      elevation: 6,
+      shape: RoundedRectangleBorder(
+        borderRadius: BorderRadius.circular(16),
+      ),
+      margin: const EdgeInsets.all(16),
+      child: Material(
+        color: Colors.white,
+        borderRadius: const BorderRadius.all(
+          Radius.circular(16),
+        ),
+        child: Container(
+            padding: const EdgeInsets.symmetric(horizontal: 16),
+            child: Obx(
+              () => Column(
+                // mainAxisAlignment: MainAxisAlignment.center,
+                children: [
+                  FormCell(
+                    title: '病人姓名:',
+                    content: Text(
+                      Store.user.displayName,
+                      style: const TextStyle(fontSize: 20),
+                    ),
+                  ),
+                  FormCell(
+                    title: '随访医生:',
+                    content: Text(
+                      Store.user.principalName,
+                      style: const TextStyle(fontSize: 20),
+                    ),
+                  ),
+                  FormCell(
+                    title: '本次随访日期:',
+                    content: VInput(
+                      readOnly: true,
+                      controller: TextEditingController(
+                        text: getFollowUpTime(controller.state.followUpTime),
+                      ),
+                      radius: 4,
+                      onTap: () async {
+                        final result = await VDialogDate(
+                          title: '本次随访日期',
+                          initialValue: controller.state.followUpTime,
+                        ).show();
+                        controller.state.followUpTime = result;
+                      },
+                    ),
+                  ),
+                  FormCell(
+                    title: '下次随访日期:',
+                    content: VInput(
+                      readOnly: true,
+                      controller: TextEditingController(
+                        text:
+                            getFollowUpTime(controller.state.nextFollowUpTime),
+                      ),
+                      radius: 4,
+                      onTap: () async {
+                        final result = await VDialogDate(
+                          title: '下次随访日期',
+                          initialValue: controller.state.nextFollowUpTime,
+                        ).show();
+                        controller.state.nextFollowUpTime = result;
+                      },
+                    ),
+                  ),
+                  // FormCell(
+                  //   title: '随访方式:',
+                  //   content: VInput(
+                  //     readOnly: true,
+                  //     controller: TextEditingController(
+                  //       text: DateFormat('yyyy-MM-dd').format(DateTime.now()),
+                  //     ),
+                  //     radius: 4,
+                  //     onTap: () async {
+                  //       final result = await VDialogDate(
+                  //         title: '随访方式',
+                  //         initialValue: DateTime.now(),
+                  //       ).show();
+                  //       // controller.state.startTime.value = result;
+                  //     },
+                  //   ),
+                  // ),
+                ],
+              ),
+            )),
+      ),
+    );
+  }
+
+  String getFollowUpTime(DateTime? time) {
+    if (time != null) {
+      return DateFormat('yyyy-MM-dd').format(time);
+    }
+    return '';
+  }
+
   void changePage(String key) {
     Get.to(
       ConfigurableCard(
@@ -63,6 +166,7 @@ class FollowUpPage extends GetView<FollowUpController> {
           await controller.createFollowUp(key, templateCode, data);
           Get.back();
         },
+        followUpWidget: _buildFollowUp(),
       ),
     );
   }

+ 9 - 89
lib/pages/check/widgets/configurable_card.dart

@@ -3,13 +3,10 @@ import 'dart:convert';
 import 'package:fis_jsonrpc/rpc.dart';
 import 'package:flutter/material.dart';
 import 'package:get/get.dart';
-import 'package:intl/intl.dart' as intl;
 import 'package:vnoteapp/components/button.dart';
-import 'package:vnoteapp/components/dialog_date.dart';
 import 'package:vnoteapp/components/dialog_input.dart';
 import 'package:vnoteapp/components/dialog_number.dart';
 import 'package:vnoteapp/components/dynamic_drawer.dart';
-import 'package:vnoteapp/components/input.dart';
 import 'package:vnoteapp/managers/interfaces/template.dart';
 import 'package:vnoteapp/pages/check/models/form.dart';
 import 'package:vnoteapp/pages/check/widgets/exam_configurable/exam_blood_pressure.dart';
@@ -29,10 +26,12 @@ String tw = '00.0';
 class ConfigurableCard extends StatefulWidget {
   final String cardKey;
   final Function(String, String, dynamic) callBack;
+  final Widget? followUpWidget;
   const ConfigurableCard({
     super.key,
     required this.cardKey,
     required this.callBack,
+    this.followUpWidget,
   });
 
   @override
@@ -309,17 +308,17 @@ class _ConfigurableFormState extends State<ConfigurableCard> {
       flex: 1,
       child: Stack(
         children: [
-          Container(
-            alignment: Alignment.topCenter,
-            margin: const EdgeInsets.all(16).copyWith(top: 0),
-            child: widget.cardKey == 'TNB'
-                ? _buildFollowUp()
-                : Image.asset(
+          widget.cardKey == 'TNB'
+              ? widget.followUpWidget!
+              : Container(
+                  alignment: Alignment.topCenter,
+                  margin: const EdgeInsets.all(16).copyWith(top: 0),
+                  child: Image.asset(
                     'assets/images/exam/normalMeasurementChart.png',
                     height: double.infinity,
                     fit: BoxFit.fitWidth, // 设置图像的适应方式
                   ),
-          ),
+                ),
           _buildPositionedButton(
             currentTitleIndex == 0 ? "返回" : "上一步",
             () async {
@@ -337,85 +336,6 @@ class _ConfigurableFormState extends State<ConfigurableCard> {
     );
   }
 
-  Widget _buildFollowUp() {
-    return Column(
-      children: [
-        Row(
-          children: [
-            const Text(
-              '本次随访日期:',
-              style: TextStyle(fontSize: 16),
-            ),
-            Expanded(
-              child: VInput(
-                readOnly: true,
-                controller: TextEditingController(
-                  text: intl.DateFormat('yyyy-MM-dd').format(DateTime.now()),
-                ),
-                radius: 4,
-                onTap: () async {
-                  final result = await VDialogDate(
-                    title: '结束时间',
-                    initialValue: DateTime.now(),
-                  ).show();
-                  // controller.state.startTime.value = result;
-                },
-              ),
-            ),
-          ],
-        ),
-        Row(
-          children: [
-            const Text(
-              '下次随访日期:',
-              style: TextStyle(fontSize: 16),
-            ),
-            Expanded(
-              child: VInput(
-                readOnly: true,
-                controller: TextEditingController(
-                  text: intl.DateFormat('yyyy-MM-dd').format(DateTime.now()),
-                ),
-                radius: 4,
-                onTap: () async {
-                  final result = await VDialogDate(
-                    title: '结束时间',
-                    initialValue: DateTime.now(),
-                  ).show();
-                  // controller.state.startTime.value = result;
-                },
-              ),
-            ),
-          ],
-        ),
-        Row(
-          children: [
-            const Text(
-              '随访方式:',
-              style: TextStyle(fontSize: 16),
-            ),
-            Expanded(
-              child: VInput(
-                readOnly: true,
-                controller: TextEditingController(
-                  text: intl.DateFormat('yyyy-MM-dd').format(DateTime.now()),
-                ),
-                radius: 4,
-                onTap: () async {
-                  final result = await VDialogDate(
-                    title: '结束时间',
-                    initialValue: DateTime.now(),
-                  ).show();
-                  // controller.state.startTime.value = result;
-                },
-              ),
-            ),
-          ],
-        ),
-      ],
-    );
-  }
-
   /// 按钮
   Widget _buildPositionedButton(String title, Function onTap,
       {double? right, double? left}) {

+ 6 - 2
lib/pages/check/widgets/form_cell.dart

@@ -11,8 +11,12 @@ class FormCell extends StatelessWidget {
       margin: const EdgeInsets.symmetric(vertical: 16),
       child: Row(
         children: [
-          Container(
-            child: Text(title),
+          SizedBox(
+            width: 150,
+            child: Text(
+              title,
+              style: const TextStyle(fontSize: 20),
+            ),
           ),
           Expanded(
             child: content,