Quellcode durchsuchen

1、移除处方功能

guanxinyi vor 11 Monaten
Ursprung
Commit
1213eeec3a

+ 4 - 0
lib/managers/interfaces/prescription.dart

@@ -28,4 +28,8 @@ abstract class IPrescriptionManager {
     String? followUpCode,
     String? prescriptionData,
   });
+
+  Future<bool?> removePrescription({
+    required String prescriptionCode,
+  });
 }

+ 18 - 0
lib/managers/prescription.dart

@@ -108,4 +108,22 @@ class PrescriptionManager implements IPrescriptionManager {
       return null;
     }
   }
+
+  @override
+  Future<bool?> removePrescription({
+    required String prescriptionCode,
+  }) async {
+    try {
+      RemovePrescriptionRequest request = RemovePrescriptionRequest(
+        code: prescriptionCode,
+        token: Store.user.token,
+      );
+      bool result =
+          await rpc.vitalPrescription.removePrescriptionAsync(request);
+      return result;
+    } catch (e) {
+      logger.e("removePrescription error.", e);
+      return null;
+    }
+  }
 }

+ 114 - 48
lib/pages/check/widgets/exam_configurable/exam_check_guidance.dart

@@ -1,7 +1,10 @@
 import 'package:flutter/material.dart';
 import 'package:get/get.dart';
 import 'package:vitalapp/architecture/types/index.dart';
+import 'package:vitalapp/architecture/utils/prompt_box.dart';
+import 'package:vitalapp/components/alert_dialog.dart';
 import 'package:vitalapp/components/button.dart';
+import 'package:vitalapp/managers/interfaces/prescription.dart';
 import 'package:vitalapp/pages/check/models/form.dart';
 import 'package:vitalapp/pages/check/prescription/examination_prescription.dart';
 import 'package:vitalapp/pages/check/prescription/prescription_form_keys.dart';
@@ -20,6 +23,7 @@ class ExamCheckBoxGuidance extends StatelessWidget {
     required this.physicalExamNumber,
     required this.patientCode,
     required this.createPrescription,
+    required this.removePrescription,
     required this.prescriptionList,
     this.disbaleOthers = false,
   });
@@ -30,10 +34,12 @@ class ExamCheckBoxGuidance extends StatelessWidget {
   final String? physicalExamNumber;
   final String? patientCode;
   final ValueCallback<Map> createPrescription;
+  final ValueCallback<Map> removePrescription;
   final List prescriptionList;
 
   /// 禁用其他选项(除已选)
   final bool disbaleOthers;
+  final _prescriptionManager = Get.find<IPrescriptionManager>();
 
   @override
   Widget build(BuildContext context) {
@@ -80,58 +86,118 @@ class ExamCheckBoxGuidance extends StatelessWidget {
               ),
             ),
             if (prescriptionList.isNotEmpty)
-              Wrap(
-                children: [
-                  SizedBox(width: 30),
-                  Container(
-                    margin: EdgeInsets.only(bottom: 8, top: 8),
-                    child: Text(
-                      '处方列表',
-                      style: TextStyle(
-                        fontSize: 26,
-                        fontWeight: FontWeight.bold,
+              Container(
+                alignment: Alignment.centerLeft,
+                padding: EdgeInsets.only(left: 30),
+                child: Column(
+                  crossAxisAlignment: CrossAxisAlignment.start,
+                  children: [
+                    SizedBox(width: 30),
+                    Container(
+                      margin: EdgeInsets.only(bottom: 8, top: 8),
+                      child: Text(
+                        '处方列表',
+                        style: TextStyle(
+                          fontSize: 26,
+                          fontWeight: FontWeight.bold,
+                        ),
                       ),
                     ),
-                  ),
-                  SizedBox(width: 16),
-                  ...prescriptionList.map(
-                    (e) => InkWell(
-                      radius: 8,
-                      onTap: () async {
-                        var prescription = await Get.dialog(
-                          ExaminationPrescription(
-                            physicalExamNumber: physicalExamNumber,
-                            patientCode: patientCode,
-                            prescription: e['prescription'],
-                            prescriptionTitle:
-                                '${PrescriptionFormKeys.AllFormKeys[e['prescription']]}',
-                            isEdit: true,
-                          ),
-                        );
-                        if (prescription != null) {
-                          createPrescription.call(prescription);
-                        }
-                      },
-                      child: Container(
-                        decoration: BoxDecoration(
-                          border: Border.all(
-                            color: Colors.black26,
-                          ),
-                          borderRadius: _borderRadius,
-                        ),
-                        margin: EdgeInsets.all(8),
-                        padding: const EdgeInsets.all(8),
-                        child: Text(
-                          '${PrescriptionFormKeys.AllFormKeys[e['prescription']]}',
-                          style: TextStyle(
-                            fontSize: 20,
-                            fontWeight: FontWeight.bold,
+                    SizedBox(width: 16),
+                    Wrap(
+                      children: [
+                        ...prescriptionList.map(
+                          (e) => InkWell(
+                            radius: 8,
+                            onTap: () async {
+                              var prescription = await Get.dialog(
+                                ExaminationPrescription(
+                                  physicalExamNumber: physicalExamNumber,
+                                  patientCode: patientCode,
+                                  prescription: e['prescription'],
+                                  prescriptionTitle:
+                                      '${PrescriptionFormKeys.AllFormKeys[e['prescription']]}',
+                                  isEdit: true,
+                                ),
+                              );
+                              if (prescription != null) {
+                                createPrescription.call(prescription);
+                              }
+                            },
+                            child: Container(
+                              decoration: BoxDecoration(
+                                border: Border.all(
+                                  color: Colors.black26,
+                                ),
+                                borderRadius: _borderRadius,
+                              ),
+                              margin: EdgeInsets.all(8),
+                              padding:
+                                  const EdgeInsets.all(8).copyWith(left: 30),
+                              child: Container(
+                                width: 380,
+                                child: Row(
+                                  children: [
+                                    Expanded(
+                                      child: Text(
+                                        '${PrescriptionFormKeys.AllFormKeys[e['prescription']]}',
+                                        style: TextStyle(
+                                          fontSize: 24,
+                                          fontWeight: FontWeight.bold,
+                                        ),
+                                        overflow: TextOverflow.ellipsis,
+                                      ),
+                                    ),
+                                    Container(
+                                      width: 40,
+                                      padding: EdgeInsets.only(right: 8),
+                                      child: IconButton(
+                                        onPressed: () {
+                                          Get.dialog(
+                                            VAlertDialog(
+                                              title: "提示",
+                                              onConfirm: () async {
+                                                bool? result =
+                                                    await _prescriptionManager
+                                                        .removePrescription(
+                                                  prescriptionCode:
+                                                      e['prescriptionCode'],
+                                                );
+                                                if (result ?? false) {
+                                                  removePrescription.call(e);
+                                                } else {
+                                                  PromptBox.toast("删除失败");
+                                                }
+                                              },
+                                              content: Container(
+                                                alignment: Alignment.center,
+                                                height: 60,
+                                                child: Text(
+                                                  "确认是否删除当前 ${PrescriptionFormKeys.AllFormKeys[e['prescription']]}",
+                                                  style: TextStyle(
+                                                    fontSize: 24,
+                                                  ),
+                                                ),
+                                              ),
+                                            ),
+                                          );
+                                        },
+                                        icon: Icon(
+                                          Icons.close,
+                                          size: 36,
+                                        ),
+                                      ),
+                                    )
+                                  ],
+                                ),
+                              ),
+                            ),
                           ),
                         ),
-                      ),
-                    ),
-                  ),
-                ],
+                      ],
+                    )
+                  ],
+                ),
               ),
           ],
         ),

+ 7 - 0
lib/pages/check/widgets/new_configurable_card.dart

@@ -595,6 +595,12 @@ class NewConfigurableFormState extends State<NewConfigurableCard> {
       setState(() {});
     }
 
+    removePrescription(Map prescription) {
+      prescriptionList.remove(prescription);
+      formValue["PrescriptionList"] = prescriptionList;
+      setState(() {});
+    }
+
     // void deletePrescription(int index) {
     //   prescriptionList.removeAt(index);
     //   formValue["PrescriptionList"] = prescriptionList;
@@ -610,6 +616,7 @@ class NewConfigurableFormState extends State<NewConfigurableCard> {
       physicalExamNumber: widget.physicalExamNumber,
       patientCode: widget.patientCode!,
       createPrescription: createPrescription,
+      removePrescription: removePrescription,
       prescriptionList: prescriptionList,
     );
   }