fix(prescription): 解决处方列表患者信息不完整导致保存失败的问题 BUG#220
- 在前端处方组件中添加患者信息完整性校验 - 当患者信息缺失时显示错误提示并阻止保存操作 - 确保处方项目正确携带patientId和encounterId信息 - 在后端服务中验证并自动补全缺失的patientId信息 - 当encounterId为空时返回相应错误提示 - 添加详细的日志记录以便问题追踪
This commit is contained in:
@@ -16,9 +16,11 @@ import com.core.common.utils.SecurityUtils;
|
|||||||
import com.core.common.utils.StringUtils;
|
import com.core.common.utils.StringUtils;
|
||||||
import com.core.web.util.TenantOptionUtil;
|
import com.core.web.util.TenantOptionUtil;
|
||||||
import com.openhis.administration.domain.Account;
|
import com.openhis.administration.domain.Account;
|
||||||
import com.openhis.administration.service.IAccountService;
|
|
||||||
import com.openhis.administration.domain.ChargeItem;
|
import com.openhis.administration.domain.ChargeItem;
|
||||||
|
import com.openhis.administration.domain.Encounter;
|
||||||
|
import com.openhis.administration.service.IAccountService;
|
||||||
import com.openhis.administration.service.IChargeItemService;
|
import com.openhis.administration.service.IChargeItemService;
|
||||||
|
import com.openhis.administration.service.IEncounterService;
|
||||||
import com.openhis.common.constant.CommonConstants;
|
import com.openhis.common.constant.CommonConstants;
|
||||||
import com.openhis.common.constant.PromptMsgConstant;
|
import com.openhis.common.constant.PromptMsgConstant;
|
||||||
import com.openhis.common.enums.*;
|
import com.openhis.common.enums.*;
|
||||||
@@ -106,6 +108,9 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
|||||||
@Resource
|
@Resource
|
||||||
RedisCache redisCache;
|
RedisCache redisCache;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
IEncounterService iEncounterService;
|
||||||
|
|
||||||
// 缓存 key 前缀
|
// 缓存 key 前缀
|
||||||
private static final String ADVICE_BASE_INFO_CACHE_PREFIX = "advice:base:info:";
|
private static final String ADVICE_BASE_INFO_CACHE_PREFIX = "advice:base:info:";
|
||||||
// 缓存过期时间(小时)
|
// 缓存过期时间(小时)
|
||||||
@@ -480,6 +485,30 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
|||||||
Long organizationId = adviceSaveParam.getOrganizationId();
|
Long organizationId = adviceSaveParam.getOrganizationId();
|
||||||
// 医嘱分类信息
|
// 医嘱分类信息
|
||||||
List<AdviceSaveDto> adviceSaveList = adviceSaveParam.getAdviceSaveList();
|
List<AdviceSaveDto> adviceSaveList = adviceSaveParam.getAdviceSaveList();
|
||||||
|
|
||||||
|
// 🔧 Bug Fix: 校验并补全patientId(如果为null,从encounter查询获取)
|
||||||
|
for (AdviceSaveDto adviceSaveDto : adviceSaveList) {
|
||||||
|
// 首先检查encounterId是否为null
|
||||||
|
if (adviceSaveDto.getEncounterId() == null) {
|
||||||
|
log.error("encounterId为null,无法保存医嘱");
|
||||||
|
return R.fail(null, "就诊信息不完整,请重新选择患者后再试");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果patientId为null,尝试从encounter获取
|
||||||
|
if (adviceSaveDto.getPatientId() == null) {
|
||||||
|
// 从就诊记录中获取patientId
|
||||||
|
Encounter encounter = iEncounterService.getById(adviceSaveDto.getEncounterId());
|
||||||
|
if (encounter != null && encounter.getPatientId() != null) {
|
||||||
|
adviceSaveDto.setPatientId(encounter.getPatientId());
|
||||||
|
log.info("自动补全patientId: encounterId={}, patientId={}",
|
||||||
|
adviceSaveDto.getEncounterId(), encounter.getPatientId());
|
||||||
|
} else {
|
||||||
|
log.error("无法获取patientId: encounterId={}", adviceSaveDto.getEncounterId());
|
||||||
|
return R.fail(null, "无法获取患者信息,请重新选择患者");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 药品
|
// 药品
|
||||||
List<AdviceSaveDto> medicineList = adviceSaveList.stream()
|
List<AdviceSaveDto> medicineList = adviceSaveList.stream()
|
||||||
.filter(e -> ItemType.MEDICINE.getValue().equals(e.getAdviceType())).collect(Collectors.toList());
|
.filter(e -> ItemType.MEDICINE.getValue().equals(e.getAdviceType())).collect(Collectors.toList());
|
||||||
|
|||||||
@@ -674,6 +674,7 @@
|
|||||||
:controls="false"
|
:controls="false"
|
||||||
style="width: 60px"
|
style="width: 60px"
|
||||||
size="small"
|
size="small"
|
||||||
|
@change="calculateTotalPrice(scope.row, scope.$index)"
|
||||||
/>
|
/>
|
||||||
<span style="margin-left: 4px">{{ scope.row.unitCode_dictText }}</span>
|
<span style="margin-left: 4px">{{ scope.row.unitCode_dictText }}</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -2154,6 +2155,13 @@ function handleSave(prescriptionId) {
|
|||||||
finalAccountId = null;
|
finalAccountId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 🔧 Bug Fix: 校验患者信息完整性
|
||||||
|
if (!props.patientInfo || !props.patientInfo.patientId || !props.patientInfo.encounterId) {
|
||||||
|
console.error('患者信息不完整:', props.patientInfo);
|
||||||
|
proxy.$modal.msgError('患者信息不完整,请重新选择患者后再试');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
saveList.forEach((item) => {
|
saveList.forEach((item) => {
|
||||||
item.patientId = props.patientInfo.patientId;
|
item.patientId = props.patientInfo.patientId;
|
||||||
item.encounterId = props.patientInfo.encounterId;
|
item.encounterId = props.patientInfo.encounterId;
|
||||||
@@ -2686,6 +2694,13 @@ function handleSaveBatch(prescriptionId) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 🔧 Bug Fix: 校验患者信息完整性
|
||||||
|
if (!props.patientInfo || !props.patientInfo.patientId || !props.patientInfo.encounterId) {
|
||||||
|
console.error('患者信息不完整:', props.patientInfo);
|
||||||
|
proxy.$modal.msgError('患者信息不完整,请重新选择患者后再试');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// --- 【修改开始:优先使用选中行】 ---
|
// --- 【修改开始:优先使用选中行】 ---
|
||||||
|
|
||||||
// 1. 获取表格当前选中的行
|
// 1. 获取表格当前选中的行
|
||||||
@@ -2785,6 +2800,8 @@ function handleSaveBatch(prescriptionId) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
|
patientId: props.patientInfo.patientId,
|
||||||
|
encounterId: props.patientInfo.encounterId,
|
||||||
adviceType: saveAdviceType,
|
adviceType: saveAdviceType,
|
||||||
dbOpType: item.requestId ? '2' : '1',
|
dbOpType: item.requestId ? '2' : '1',
|
||||||
isSaved: true,
|
isSaved: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user