diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java index e09f2c29b..225d47c8c 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java @@ -48,6 +48,9 @@ import com.openhis.web.personalization.dto.ActivityDeviceDto; import com.openhis.workflow.domain.ActivityDefinition; import com.openhis.workflow.domain.DeviceRequest; import com.openhis.workflow.domain.InventoryItem; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.openhis.workflow.domain.ServiceRequest; import com.openhis.workflow.service.*; import lombok.extern.slf4j.Slf4j; @@ -946,6 +949,27 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp /** * 处理药品 */ + + /** + * 将 remark 合并到 contentJson 中,确保 Mapper 能从 content_json 提取 remark + */ + private String injectRemarkIntoContentJson(String contentJson, String remark) { + if (remark == null || remark.isEmpty() || contentJson == null || contentJson.isEmpty()) { + return contentJson; + } + try { + ObjectMapper mapper = new ObjectMapper(); + JsonNode node = mapper.readTree(contentJson); + if (node instanceof ObjectNode) { + ((ObjectNode) node).put("remark", remark); + return mapper.writeValueAsString(node); + } + } catch (Exception e) { + log.warn("Failed to inject remark into contentJson: {}", e.getMessage()); + } + return contentJson; + } + private List handMedication(List medicineList, Date curDate, String adviceOpType, Long organizationId, String signCode) { // 当前登录账号的科室id @@ -1162,6 +1186,10 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp if (medicationRequest.getId() == null) { firstTimeSave = true; } + // 确保 contentJson 包含 remark + if (adviceSaveDto.getRemark() != null && !adviceSaveDto.getRemark().isEmpty()) { + medicationRequest.setContentJson(injectRemarkIntoContentJson(medicationRequest.getContentJson(), adviceSaveDto.getRemark())); + } iMedicationRequestService.saveOrUpdate(medicationRequest); if (firstTimeSave) { medRequestIdList.add(medicationRequest.getId().toString()); @@ -1622,6 +1650,10 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp deviceRequest.setConditionId(adviceSaveDto.getConditionId()); // 诊断id deviceRequest.setEncounterDiagnosisId(adviceSaveDto.getEncounterDiagnosisId()); // 就诊诊断id + // 确保 contentJson 包含 remark + if (adviceSaveDto.getRemark() != null && !adviceSaveDto.getRemark().isEmpty()) { + deviceRequest.setContentJson(injectRemarkIntoContentJson(deviceRequest.getContentJson(), adviceSaveDto.getRemark())); + } iDeviceRequestService.saveOrUpdate(deviceRequest); if (is_save) { // 处理耗材发放 diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/AdviceManageAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/AdviceManageAppServiceImpl.java index 1412ebd71..362f12331 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/AdviceManageAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/AdviceManageAppServiceImpl.java @@ -30,6 +30,9 @@ import com.openhis.web.regdoctorstation.dto.*; import com.openhis.web.regdoctorstation.mapper.AdviceManageAppMapper; import com.openhis.web.regdoctorstation.utils.RegPrescriptionUtils; import com.openhis.workflow.domain.DeviceRequest; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.openhis.workflow.domain.ServiceRequest; import com.openhis.workflow.service.IActivityDefinitionService; import com.openhis.workflow.domain.ActivityDefinition; @@ -351,6 +354,27 @@ public class AdviceManageAppServiceImpl implements IAdviceManageAppService { /** * 处理药品 */ + + /** + * 将 remark 合并到 contentJson 中,确保 Mapper 能从 content_json 提取 remark + */ + private String injectRemarkIntoContentJson(String contentJson, String remark) { + if (remark == null || remark.isEmpty() || contentJson == null || contentJson.isEmpty()) { + return contentJson; + } + try { + ObjectMapper mapper = new ObjectMapper(); + JsonNode node = mapper.readTree(contentJson); + if (node instanceof ObjectNode) { + ((ObjectNode) node).put("remark", remark); + return mapper.writeValueAsString(node); + } + } catch (Exception e) { + log.warn("Failed to inject remark into contentJson: {}", e.getMessage()); + } + return contentJson; + } + private List handMedication(List medicineList, Date startTime, Date authoredTime, Date curDate, String adviceOpType, Long organizationId, String signCode) { // 当前登录账号的科室id @@ -449,6 +473,10 @@ public class AdviceManageAppServiceImpl implements IAdviceManageAppService { if (longMedicationRequest.getId() == null) { firstTimeSave = true; } + // 确保 contentJson 包含 remark + if (regAdviceSaveDto.getRemark() != null && !regAdviceSaveDto.getRemark().isEmpty()) { + longMedicationRequest.setContentJson(injectRemarkIntoContentJson(longMedicationRequest.getContentJson(), regAdviceSaveDto.getRemark())); + } iMedicationRequestService.saveOrUpdate(longMedicationRequest); if (firstTimeSave) { medRequestIdList.add(longMedicationRequest.getId().toString()); @@ -536,6 +564,10 @@ public class AdviceManageAppServiceImpl implements IAdviceManageAppService { if (tempMedicationRequest.getId() == null) { firstTimeSave = true; } + // 确保 contentJson 包含 remark + if (regAdviceSaveDto.getRemark() != null && !regAdviceSaveDto.getRemark().isEmpty()) { + tempMedicationRequest.setContentJson(injectRemarkIntoContentJson(tempMedicationRequest.getContentJson(), regAdviceSaveDto.getRemark())); + } iMedicationRequestService.saveOrUpdate(tempMedicationRequest); if (firstTimeSave) { medRequestIdList.add(tempMedicationRequest.getId().toString()); @@ -823,6 +855,10 @@ public class AdviceManageAppServiceImpl implements IAdviceManageAppService { deviceRequest.setConditionId(regAdviceSaveDto.getConditionId()); // 诊断id deviceRequest.setEncounterDiagnosisId(regAdviceSaveDto.getEncounterDiagnosisId()); // 就诊诊断id } + // 确保 contentJson 包含 remark + if (regAdviceSaveDto.getRemark() != null && !regAdviceSaveDto.getRemark().isEmpty()) { + deviceRequest.setContentJson(injectRemarkIntoContentJson(deviceRequest.getContentJson(), regAdviceSaveDto.getRemark())); + } iDeviceRequestService.saveOrUpdate(deviceRequest); } @@ -862,6 +898,10 @@ public class AdviceManageAppServiceImpl implements IAdviceManageAppService { deviceRequest.setConditionId(regAdviceSaveDto.getConditionId()); // 诊断id deviceRequest.setEncounterDiagnosisId(regAdviceSaveDto.getEncounterDiagnosisId()); // 就诊诊断id } + // 确保 contentJson 包含 remark + if (regAdviceSaveDto.getRemark() != null && !regAdviceSaveDto.getRemark().isEmpty()) { + deviceRequest.setContentJson(injectRemarkIntoContentJson(deviceRequest.getContentJson(), regAdviceSaveDto.getRemark())); + } iDeviceRequestService.saveOrUpdate(deviceRequest); // 保存时,保存耗材费用项 diff --git a/openhis-server-new/openhis-application/src/main/resources/mapper/doctorstation/DoctorStationAdviceAppMapper.xml b/openhis-server-new/openhis-application/src/main/resources/mapper/doctorstation/DoctorStationAdviceAppMapper.xml index e95852482..12f135132 100755 --- a/openhis-server-new/openhis-application/src/main/resources/mapper/doctorstation/DoctorStationAdviceAppMapper.xml +++ b/openhis-server-new/openhis-application/src/main/resources/mapper/doctorstation/DoctorStationAdviceAppMapper.xml @@ -516,7 +516,7 @@ T1.patient_id AS patient_id, 'med_medication_definition' AS advice_table_name, T1.medication_id AS advice_definition_id - , (SELECT remark FROM wor_service_request WHERE based_on_id = T1.id AND based_on_table = #{MED_MEDICATION_REQUEST} AND delete_flag = '0' LIMIT 1) AS remark + , T1.content_json::jsonb ->> 'remark' AS remark FROM med_medication_request AS T1 LEFT JOIN med_medication_definition AS T2 ON T2.ID = T1.medication_id AND T2.delete_flag = '0' @@ -578,7 +578,7 @@ T1.patient_id AS patient_id, 'med_medication_definition' AS advice_table_name, T3.ID AS advice_definition_id - , (SELECT remark FROM wor_service_request WHERE based_on_id = T2.id AND based_on_table = #{MED_MEDICATION_REQUEST} AND delete_flag = '0' LIMIT 1) AS remark + , T1.content_json::jsonb ->> 'remark' AS remark FROM adm_charge_item AS T1 INNER JOIN med_medication_request AS T2 ON T2.ID = T1.service_id AND T2.delete_flag = '0' LEFT JOIN med_medication_definition AS T3 ON T3.ID = T2.medication_id AND T3.delete_flag = '0' @@ -694,7 +694,7 @@ T1.patient_id AS patient_id, 'adm_device_definition' AS advice_table_name, T1.device_def_id AS advice_definition_id - , (SELECT remark FROM wor_service_request WHERE based_on_id = T1.id AND based_on_table = #{WOR_DEVICE_REQUEST} AND delete_flag = '0' LIMIT 1) AS remark + , T1.content_json::jsonb ->> 'remark' AS remark FROM wor_device_request AS T1 LEFT JOIN adm_device_definition AS T2 ON T2.ID = T1.device_def_id AND T2.delete_flag = '0' diff --git a/openhis-server-new/openhis-application/src/main/resources/mapper/regdoctorstation/AdviceManageAppMapper.xml b/openhis-server-new/openhis-application/src/main/resources/mapper/regdoctorstation/AdviceManageAppMapper.xml index 4a8bf8e28..aa1c15631 100755 --- a/openhis-server-new/openhis-application/src/main/resources/mapper/regdoctorstation/AdviceManageAppMapper.xml +++ b/openhis-server-new/openhis-application/src/main/resources/mapper/regdoctorstation/AdviceManageAppMapper.xml @@ -218,7 +218,7 @@ T1.sort_number AS sort_number, T1.based_on_id AS based_on_id, T1.medication_id AS advice_definition_id, - (SELECT remark FROM wor_service_request WHERE based_on_id = T1.id AND based_on_table = #{MED_MEDICATION_REQUEST} AND delete_flag = '0' LIMIT 1) AS remark + T1.content_json::jsonb ->> 'remark' AS remark FROM med_medication_request AS T1 LEFT JOIN med_medication_definition AS T2 ON T2.ID = T1.medication_id AND T2.delete_flag = '0' @@ -272,7 +272,7 @@ 99 AS sort_number, T1.based_on_id AS based_on_id, T1.device_def_id AS advice_definition_id, - (SELECT remark FROM wor_service_request WHERE based_on_id = T1.id AND based_on_table = #{WOR_DEVICE_REQUEST} AND delete_flag = '0' LIMIT 1) AS remark + T1.content_json::jsonb ->> 'remark' AS remark FROM wor_device_request AS T1 LEFT JOIN adm_device_definition AS T2 ON T2.ID = T1.device_def_id AND T2.delete_flag = '0'