Explorar el Código

1、fixed:0018447: 【儿童健康管理】儿童健康管理下的提交的随访记录右侧的>样式,应和其他糖尿病、高血压下提交随访记录一样显示为+,方便修改随访和保存后新增随访记录

guanxinyi hace 11 meses
padre
commit
562ccd3b3d

+ 158 - 0
lib/components/dialog_gxy_medication.dart

@@ -0,0 +1,158 @@
+import 'package:flutter/material.dart';
+import 'package:get/get.dart';
+import 'package:vitalapp/components/cell.dart';
+import 'package:vitalapp/components/dialog_input.dart';
+import 'package:vitalapp/components/dialog_number.dart';
+import 'package:vitalapp/pages/check/models/form.dart';
+
+import 'alert_dialog.dart';
+
+class VDialogGxyMedication extends StatefulWidget {
+  final String? title;
+  final String? description;
+  final String? placeholder;
+
+  final int? maxLines;
+  final double? inputHeight;
+  final bool Function(String)? onConfirmVerification;
+  final bool showCancel;
+  final MedicationModel? medicationModel;
+
+  const VDialogGxyMedication({
+    Key? key,
+    this.title,
+    this.description,
+    this.placeholder,
+    this.maxLines = 1,
+    this.inputHeight = 56,
+    this.onConfirmVerification,
+    this.showCancel = false,
+    this.medicationModel,
+  }) : super(key: key);
+  Future<MedicationModel?> show<MedicationModel>() =>
+      VAlertDialog.showDialog<MedicationModel>(this);
+  @override
+  _VDialogGxyMedicationState createState() => _VDialogGxyMedicationState();
+}
+
+class _VDialogGxyMedicationState extends State<VDialogGxyMedication> {
+  MedicationModel medicationModel = MedicationModel();
+
+  @override
+  void initState() {
+    super.initState();
+    if (widget.medicationModel != null) {
+      medicationModel = widget.medicationModel!;
+    }
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    return VAlertDialog(
+      title: "主要用药情况填写",
+      width: 600,
+      content: Container(
+        height: 280,
+        padding: const EdgeInsets.symmetric(horizontal: 24),
+        alignment: Alignment.center,
+        child: VListFormCellGroup(
+          children: [
+            _buildFormCell(
+              label: '药物名称',
+              content: medicationModel.name,
+              onTap: () async {
+                final result = await _showInputDialog(
+                  title: '药物名称',
+                  initialValue: medicationModel.name ?? '',
+                );
+                setState(() {
+                  medicationModel.name = result;
+                });
+              },
+            ),
+            _buildFormCell(
+              label: '用法(每日次数)',
+              content: medicationModel.usage,
+              onTap: () async {
+                final result = await _showNumberDialog(
+                  title: '用法(每日次数)',
+                  initialValue: medicationModel.usage ?? '',
+                );
+                setState(() {
+                  medicationModel.usage = result;
+                });
+              },
+            ),
+            //  _buildFormCell(
+            //   label: '频率:每日(月)',
+            //   content: medicationModel.monthOrDay,
+            //   onTap: () async {
+            //     String? result = await VDialogSelect<String, String>(
+            //       source: [
+            //         "每月",
+            //         "每日",
+            //       ],
+            //       labelGetter: (data) => data,
+            //       valueGetter: (data) => data,
+            //     ).show();
+            //     setState(() {
+            //       medicationModel.monthOrDay = result;
+            //     });
+            //   },
+            // ),
+            _buildFormCell(
+              label: '每次',
+              content: medicationModel.dosages,
+              onTap: () async {
+                final result = await _showInputDialog(
+                  title: '每次',
+                  initialValue: medicationModel.dosages ?? '',
+                );
+                setState(() {
+                  medicationModel.dosages = result;
+                });
+              },
+            ),
+          ],
+        ),
+      ),
+      onConfirm: () {
+        Get.back(result: medicationModel);
+      },
+    );
+  }
+
+  Future<String?> _showInputDialog({
+    required String title,
+    required String initialValue,
+  }) async {
+    final result = await VDialogInput(
+      title: title,
+      initialValue: initialValue,
+    ).show();
+    return result;
+  }
+
+  Future<String?> _showNumberDialog({
+    required String title,
+    required String initialValue,
+  }) async {
+    final result = await VDialogNumber(
+      title: title,
+      initialValue: initialValue,
+    ).show();
+    return result;
+  }
+
+  Widget _buildFormCell({
+    required String label,
+    String? content,
+    required VoidCallback onTap,
+  }) {
+    return VListFormCell(
+      label: label,
+      content: content ?? '',
+      onTap: onTap,
+    );
+  }
+}

+ 29 - 2
lib/pages/check/children_follow_up_record/controller.dart

@@ -256,7 +256,24 @@ class ChildrenFollowUpRecordController extends FControllerBase {
     return prescriptionList;
   }
 
-  toCheckPage(FollowUpRecordDataDTO dataDTO) async {
+  Future<bool> createFollowUpFromOldDto(
+    String key,
+    String? code,
+    data,
+    prescriptionKey,
+  ) async {
+    return await _followUpController.createFollowUp(
+      key,
+      code,
+      data,
+      prescriptionKey,
+    );
+  }
+
+  toCheckPage(
+    FollowUpRecordDataDTO dataDTO, {
+    bool isCreateFromOldDto = false,
+  }) async {
     await Get.put(MedicalController());
     recordCode = dataDTO.code!;
     _followUpController.state.followUpTime = dataDTO.followUpTime;
@@ -284,7 +301,17 @@ class ChildrenFollowUpRecordController extends FControllerBase {
             PromptBox.toast('本次随访时间不能晚于下次随访时间');
             return false;
           }
-          await updateFollowUp(key, dataDTO.code, data);
+          if (isCreateFromOldDto) {
+            await createFollowUpFromOldDto(
+              key,
+              dataDTO.code,
+              data,
+              prescriptionKey,
+            );
+          } else {
+            await updateFollowUp(key, dataDTO.code, data);
+          }
+
           await getFollowUpRecordListByChildrenKey(key);
           return true;
         },

+ 5 - 2
lib/pages/check/children_follow_up_record/view.dart

@@ -326,8 +326,11 @@ class _followUpRecordCard extends StatelessWidget {
                 ),
               ),
             ),
-            Expanded(
-              child: Icon(
+            IconButton(
+              onPressed: () {
+                controller.toCheckPage(dataDto, isCreateFromOldDto: true);
+              },
+              icon: Icon(
                 Icons.add,
                 size: 54,
                 color: Colors.grey.shade400,

+ 57 - 0
lib/pages/check/widgets/configurable_card.dart

@@ -11,6 +11,7 @@ import 'package:vitalapp/architecture/utils/compute_children_level.dart';
 import 'package:vitalapp/architecture/utils/prompt_box.dart';
 import 'package:vitalapp/components/button.dart';
 import 'package:vitalapp/components/dialog_date.dart';
+import 'package:vitalapp/components/dialog_gxy_medication.dart';
 import 'package:vitalapp/components/dialog_input.dart';
 import 'package:vitalapp/components/dialog_medication.dart';
 import 'package:vitalapp/components/dialog_number.dart';
@@ -47,6 +48,7 @@ import 'package:vitalapp/pages/check/widgets/follow_up_configurable/follow_up_ch
 import 'package:vitalapp/pages/check/widgets/follow_up_configurable/follow_up_child_height_and_weight.dart';
 import 'package:vitalapp/pages/check/widgets/follow_up_configurable/follow_up_child_radio_input.dart';
 import 'package:vitalapp/pages/check/widgets/follow_up_configurable/follow_up_child_referral.dart';
+import 'package:vitalapp/pages/check/widgets/follow_up_configurable/follow_up_medication.dart';
 import 'package:vitalapp/pages/check/widgets/follow_up_configurable/follow_up_resident_detail.dart';
 import 'package:vitalapp/pages/check/widgets/title_clip_path.dart';
 import 'package:flutter/services.dart' show rootBundle;
@@ -465,6 +467,7 @@ class _ConfigurableFormState extends State<ConfigurableCard> {
       'radioHospitalization': _buildRadioHospitalization,
       'radioReferral': _buildRadioReferral,
       'medication': _buildMedication,
+      'gxyAndTnbMedication': _buildGxyAndTnbMedication,
       'radioExtraDescription': _buildRadioExtraDescription,
       'checkBoxIncludeOther': _buildCheckBoxIncludeOther,
       'inputAndRadio': _buildChildHeightAndWeight,
@@ -1228,6 +1231,60 @@ class _ConfigurableFormState extends State<ConfigurableCard> {
     );
   }
 
+  /// 高血压和糖尿病用药情况与指导
+  Widget _buildGxyAndTnbMedication(FormObject currentFormObject) {
+    List<dynamic> currentValue = [];
+    var value = formValue[currentFormObject.key!];
+    if (value is String) {
+      return Container();
+    } else {
+      if (value != null) currentValue = value;
+    }
+
+    Future<void> addVeterinaryDrug() async {
+      MedicationModel? result = await VDialogGxyMedication(
+        title: currentFormObject.label,
+      ).show();
+      if (result != null) {
+        currentValue.add(result.toJson());
+        formValue[currentFormObject.key!] = null;
+        formValue[currentFormObject.key!] = currentValue;
+        setState(() {});
+      }
+    }
+
+    Future<void> deleteVeterinaryDrug(int index) async {
+      currentValue.removeAt(index);
+      formValue[currentFormObject.key!] = null;
+      formValue[currentFormObject.key!] = currentValue;
+      setState(() {});
+    }
+
+    Future<void> editVeterinaryDrug(int index) async {
+      MedicationModel medicationModel =
+          MedicationModel.fromJson(currentValue[index]);
+
+      MedicationModel? result = await VDialogGxyMedication(
+        title: currentFormObject.label,
+        medicationModel: medicationModel,
+      ).show();
+      if (result != null) {
+        currentValue[index] = result.toJson();
+        formValue[currentFormObject.key!] = null;
+        formValue[currentFormObject.key!] = currentValue;
+        setState(() {});
+      }
+    }
+
+    return FollowUpGxyAndTnbMedication(
+      currentFormObject: currentFormObject,
+      currentValues: currentValue,
+      addVeterinaryDrug: addVeterinaryDrug,
+      deleteVeterinaryDrug: deleteVeterinaryDrug,
+      editVeterinaryDrug: editVeterinaryDrug,
+    );
+  }
+
   ///转诊
   Widget _buildRadioReferral(FormObject currentFormObject) {
     List<Option> options = currentFormObject.options ?? [];

+ 99 - 0
lib/pages/check/widgets/follow_up_configurable/follow_up_medication.dart

@@ -0,0 +1,99 @@
+import 'package:flutter/material.dart';
+import 'package:vitalapp/components/button.dart';
+import 'package:vitalapp/pages/check/models/form.dart';
+import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_radio_and_select.dart';
+
+class FollowUpGxyAndTnbMedication extends StatelessWidget {
+  final List<dynamic>? currentValues;
+  final Function? addVeterinaryDrug;
+  final FormObject currentFormObject;
+  final Function? deleteVeterinaryDrug;
+  final Function? editVeterinaryDrug;
+
+  const FollowUpGxyAndTnbMedication({
+    super.key,
+    this.currentValues,
+    this.addVeterinaryDrug,
+    required this.currentFormObject,
+    this.deleteVeterinaryDrug,
+    this.editVeterinaryDrug,
+  });
+
+  @override
+  Widget build(BuildContext context) {
+    return Stack(
+      children: [
+        ExamCardRadioSelect(
+          title: currentFormObject.label ?? "",
+          clickCard: null,
+          content: Container(
+            alignment: Alignment.centerLeft,
+            padding: const EdgeInsets.only(
+              right: 20,
+              left: 20,
+              bottom: 10,
+            ),
+            child: Column(children: [
+              ...currentValues!.asMap().entries.map((entry) {
+                var medicationModel = MedicationModel.fromJson(entry.value);
+                return Row(
+                  crossAxisAlignment: CrossAxisAlignment.start,
+                  mainAxisAlignment: MainAxisAlignment.start,
+                  children: [
+                    Expanded(
+                      child: Text(
+                        "药物${entry.key + 1}:${medicationModel.name}     用法:${medicationModel.usage}次   每次${medicationModel.dosages}",
+                        style: TextStyle(fontSize: 18, color: Colors.black54),
+                        textAlign: TextAlign.left,
+                      ),
+                    ),
+                    IconButton(
+                      onPressed: () {
+                        editVeterinaryDrug!(entry.key);
+                      },
+                      icon: Icon(Icons.edit),
+                    ),
+                    IconButton(
+                      onPressed: () {
+                        deleteVeterinaryDrug!(entry.key);
+                      },
+                      icon: Icon(Icons.delete),
+                    ),
+                  ],
+                );
+              }).toList()
+            ]),
+          ),
+        ),
+        Positioned(
+          right: 16,
+          top: 8,
+          child: SizedBox(
+            width: 130,
+            height: 54,
+            child: VButton(
+              child: Row(
+                mainAxisAlignment: MainAxisAlignment.center,
+                children: const [
+                  Icon(Icons.add, size: 24),
+                  SizedBox(
+                    width: 8,
+                  ),
+                  Text(
+                    "新增",
+                    style: TextStyle(
+                      fontSize: 20,
+                    ),
+                  )
+                ],
+              ),
+              onTap: () {
+                addVeterinaryDrug!();
+              },
+            ),
+          ),
+        ),
+      ],
+    );
+  }
+}