Browse Source

fixed: 0018706: 【儿童健康管理】先提交一条包含处方的记录,再点击复制新增,不修改处方,新记录中不包含原记录的处方内容

loki.wu 10 months ago
parent
commit
78cc279ed5

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

@@ -284,6 +284,12 @@ class ChildrenFollowUpRecordController extends FControllerBase {
     } else {
       _followUpController.state.followUpPhoto = "";
     }
+    PatientDTO? currentPatient = Store.user.currentSelectPatientInfo;
+    List<PrescriptionDTO>? prescriptionDTOs =
+        await Get.find<IPrescriptionManager>().getPrescriptionPage(
+      patientCode: currentPatient?.code ?? '',
+      followUpCode: recordCode,
+    );
     String followCode = "";
     await Get.to(
       ConfigurableCard(
@@ -306,12 +312,23 @@ class ChildrenFollowUpRecordController extends FControllerBase {
             if (followCode.isNotEmpty) {
               await updateFollowUp(key, followCode, data);
             } else {
-              await createFollowUpFromOldDto(
+              bool result = await createFollowUpFromOldDto(
                 key,
                 dataDTO.code,
                 data,
                 prescriptionKey,
               );
+              if (result) {
+                String recordCode = _followUpController.recordCode;
+                for (PrescriptionDTO p in prescriptionDTOs ?? []) {
+                  Get.find<IPrescriptionManager>().createPrescription(
+                    patientCode: p.patientCode ?? '',
+                    prescriptionKey: p.prescriptionTemplateKey ?? '',
+                    followUpCode: recordCode,
+                    prescriptionData: p.prescriptionData,
+                  );
+                }
+              }
             }
           } else {
             await updateFollowUp(key, dataDTO.code, data);
@@ -322,7 +339,7 @@ class ChildrenFollowUpRecordController extends FControllerBase {
         },
         onClickPrescribe: (key, code, data) async {
           var result = await Get.to(PrescriptionCollection(
-           followCode.isEmpty ? recordCode: followCode,
+            followCode.isEmpty ? recordCode : followCode,
             isCreateFromOldDto: followCode.isEmpty ? isCreateFromOldDto : false,
             createFollowUpOnly: () async {
               var code = await followUpController.createFollowUpOnly(

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

@@ -22,6 +22,7 @@ class FollowUpController extends GetxController {
 
   late String patientCode = "";
   late String patientName = "";
+  String recordCode = '';
 
   _initData() {
     update(["follow_up"]);
@@ -178,6 +179,7 @@ class FollowUpController extends GetxController {
     print(jsonEncode(request.toJson()));
 
     final result = await _followUpManager.createFollowUp(request);
+    recordCode = result;
     if (result.isNotEmpty && prescriptionKey.isNotEmpty) {
       await createPrescription(result, prescriptionKey);
       PromptBox.toast('保存成功');