feat(doctorstation): 添加取消接诊功能

- 在医生工作站界面添加取消接诊按钮
- 实现取消接诊的前端处理逻辑和确认对话框
- 添加计算属性控制取消接诊按钮的禁用状态
- 完善后端取消接诊服务的安全性检查和异常处理
- 优化取消接诊时的业务数据验证流程
- 添加详细的错误提示和用户反馈机制
This commit is contained in:
2026-03-11 16:21:49 +08:00
parent 4b544dc214
commit 75737cf95c
2 changed files with 95 additions and 23 deletions

View File

@@ -230,27 +230,55 @@ public class DoctorStationMainAppServiceImpl implements IDoctorStationMainAppSer
*/
@Override
public R<?> cancelEncounter(Long encounterId) {
try {
//1.判断是否已经产生业务,如医生已经开有病历、处方、诊断、检验检查或相关项目已收费、执行等,
//如果有则提示:需要医生删除、作废、退费才能【取消接诊】。
//1.1病历
Object emrDetailResult = iDoctorStationEmrAppService.getEmrDetail(encounterId).getData();
Object emrDetailResult = null;
try {
emrDetailResult = iDoctorStationEmrAppService.getEmrDetail(encounterId).getData();
} catch (Exception e) {
log.debug("获取病历信息失败: {}", e.getMessage());
}
//1.2诊断
Object diagnosisResult = iDoctorStationDiagnosisAppService.getEncounterDiagnosis(encounterId).getData();
Object diagnosisResult = null;
try {
diagnosisResult = iDoctorStationDiagnosisAppService.getEncounterDiagnosis(encounterId).getData();
} catch (Exception e) {
log.debug("获取诊断信息失败: {}", e.getMessage());
}
//1.3处方
Object adviceResult = iDoctorStationAdviceAppService.getRequestBaseInfo(encounterId).getData();
Object adviceResult = null;
try {
adviceResult = iDoctorStationAdviceAppService.getRequestBaseInfo(encounterId).getData();
} catch (Exception e) {
log.debug("获取处方信息失败: {}", e.getMessage());
}
//1.4中医诊断、处方
Map<?,?> tcmDiagnosisResult = (Map<?,?>) iDoctorStationChineseMedicalAppService.getTcmEncounterDiagnosis(encounterId).getData();
Object symptom = tcmDiagnosisResult.get("symptom");
Object illness = tcmDiagnosisResult.get("illness");
Object tcmPrescriptionResult = iDoctorStationChineseMedicalAppService.getTcmRequestBaseInfo(encounterId).getData();
Object symptom = null;
Object illness = null;
Object tcmPrescriptionResult = null;
boolean isEmpty = ObjectUtil.isAllEmpty(emrDetailResult, diagnosisResult, adviceResult, symptom,illness, tcmPrescriptionResult);
try {
Map<?,?> tcmDiagnosisResult = (Map<?,?>) iDoctorStationChineseMedicalAppService.getTcmEncounterDiagnosis(encounterId).getData();
if (tcmDiagnosisResult != null) {
symptom = tcmDiagnosisResult.get("symptom");
illness = tcmDiagnosisResult.get("illness");
}
tcmPrescriptionResult = iDoctorStationChineseMedicalAppService.getTcmRequestBaseInfo(encounterId).getData();
} catch (Exception e) {
// 中医模块可能未启用或返回异常,忽略
log.debug("获取中医信息失败,可能未配置中医模块: {}", e.getMessage());
}
boolean isEmpty = ObjectUtil.isAllEmpty(emrDetailResult, diagnosisResult, adviceResult, symptom, illness, tcmPrescriptionResult);
if (!isEmpty) {
return R.fail();
return R.fail("该患者已产生业务数据(病历、诊断、处方等),无法直接取消接诊。请先删除相关数据后再操作。");
}
//2.取消接诊,患者重新回到患者队列待诊中
@@ -258,7 +286,11 @@ public class DoctorStationMainAppServiceImpl implements IDoctorStationMainAppSer
new LambdaUpdateWrapper<Encounter>().eq(Encounter::getId, encounterId)
.set(Encounter::getStatusEnum, EncounterStatus.PLANNED.getValue())
.set(Encounter::getSubjectStatusEnum, EncounterSubjectStatus.TRIAGED.getValue()));
return update > 0 ? R.ok() : R.fail();
return update > 0 ? R.ok("取消接诊成功") : R.fail("取消接诊失败,请刷新后重试");
} catch (Exception e) {
log.error("取消接诊时发生错误encounterId={}", encounterId, e);
return R.fail("取消接诊失败:" + e.getMessage());
}
}
/**

View File

@@ -102,6 +102,7 @@
</el-radio-group>
<el-button type="primary" plain @click.stop="handleFinish(patientInfo.encounterId)" size="small">完诊</el-button>
<el-button type="primary" plain @click.stop="handleLeave(patientInfo.encounterId)" size="small">暂离</el-button>
<el-button type="warning" plain :disabled="isCancelButtonDisabled" @click.stop="handleCancel(patientInfo.encounterId)" size="small">取消接诊</el-button>
<el-button type="primary" plain :disabled="isRefundButtonDisabled" @click.stop="handleRefund(patientInfo.encounterId)" size="small">退费</el-button>
<el-button type="primary" plain class="top-layer-btn" @click.stop="getEnPrescription(patientInfo.encounterId)" size="small">处方单</el-button>
<el-button type="primary" plain class="top-layer-btn" :disabled="isHospitalizationButtonDisabled" @click.stop="handleHospitalizationClick()" size="small">办理住院</el-button>
@@ -193,6 +194,7 @@ import {
getList,
isHospitalization,
leaveEncounter,
cancelEncounter,
} from './components/api.js';
import prescriptionlist from './components/prescription/prescriptionlist.vue';
import RefundListDialog from './components/prescription/refundListDialog.vue';
@@ -282,6 +284,16 @@ const isHospitalizationButtonDisabled = computed(() => {
patientInfo.value.encounterId === undefined;
});
// 计算属性:确定取消接诊按钮是否应被禁用
const isCancelButtonDisabled = computed(() => {
return !patientInfo.value ||
typeof patientInfo.value !== 'object' ||
!patientInfo.value.encounterId ||
patientInfo.value.encounterId === '' ||
patientInfo.value.encounterId === null ||
patientInfo.value.encounterId === undefined;
});
// 计算属性:确定退费按钮是否应被禁用(与住院按钮使用相同的逻辑)
const isRefundButtonDisabled = computed(() => {
return !patientInfo.value ||
@@ -628,6 +640,34 @@ function handleLeave(encounterId) {
});
}
function handleCancel(encounterId) {
if (!encounterId) {
ElMessage.warning('请先选择患者后再进行取消接诊操作');
return;
}
ElMessageBox.confirm('确定要取消接诊该患者吗?取消后患者将回到待诊状态。', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
cancelEncounter(encounterId).then((res) => {
if (res.code == 200) {
proxy.$modal.msgSuccess('取消接诊成功');
patientInfo.value = {};
getPatientList();
getWaitPatient();
} else {
proxy.$modal.msgError(res.msg || '取消接诊失败');
}
}).catch((error) => {
console.error('取消接诊失败:', error);
proxy.$modal.msgError('取消接诊失败');
});
}).catch(() => {
// 用户取消操作,不做处理
});
}
async function handleFinish(encounterId) {
// 完诊前验证诊断信息
try {