fix(#597): remark字段保存后丢失修复——药品/耗材医嘱的备注写入contentJson
根因: - MedicationRequest/DeviceRequest 实体无 remark 字段/列 - handMedication()/handDevice() 未保存 remark - 查询 Mapper 通过子查 wor_service_request 取 remark,但药品/耗材无对应记录 修复: - Mapper:药品/耗材的 remark 来源改为从 content_json::jsonb ->> 'remark' 提取 - Service:在 handMedication()/handDevice() 中将 remark 合并到 contentJson - 覆盖住院(AdviceManageAppServiceImpl)和门诊(DoctorStationAdviceAppServiceImpl) - 不新增数据库列,不改实体结构
This commit is contained in:
@@ -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<String> handMedication(List<AdviceSaveDto> 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) {
|
||||
// 处理耗材发放
|
||||
|
||||
@@ -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<String> handMedication(List<RegAdviceSaveDto> 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);
|
||||
|
||||
// 保存时,保存耗材费用项
|
||||
|
||||
Reference in New Issue
Block a user