bug469
This commit is contained in:
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.core.common.core.domain.R;
|
import com.core.common.core.domain.R;
|
||||||
|
import com.core.common.enums.DelFlag;
|
||||||
import com.core.common.exception.ServiceException;
|
import com.core.common.exception.ServiceException;
|
||||||
import com.core.common.utils.AssignSeqUtil;
|
import com.core.common.utils.AssignSeqUtil;
|
||||||
import com.core.common.utils.MessageUtils;
|
import com.core.common.utils.MessageUtils;
|
||||||
@@ -17,6 +18,8 @@ import com.openhis.common.constant.PromptMsgConstant;
|
|||||||
import com.openhis.common.enums.*;
|
import com.openhis.common.enums.*;
|
||||||
import com.openhis.document.domain.RequestForm;
|
import com.openhis.document.domain.RequestForm;
|
||||||
import com.openhis.document.service.IRequestFormService;
|
import com.openhis.document.service.IRequestFormService;
|
||||||
|
import com.openhis.lab.domain.Specimen;
|
||||||
|
import com.openhis.lab.service.ISpecimenService;
|
||||||
import com.openhis.web.doctorstation.dto.ActivityChildrenJsonParams;
|
import com.openhis.web.doctorstation.dto.ActivityChildrenJsonParams;
|
||||||
import com.openhis.web.doctorstation.utils.AdviceUtils;
|
import com.openhis.web.doctorstation.utils.AdviceUtils;
|
||||||
import com.openhis.web.regdoctorstation.appservice.IRequestFormManageAppService;
|
import com.openhis.web.regdoctorstation.appservice.IRequestFormManageAppService;
|
||||||
@@ -67,6 +70,39 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
|||||||
@Resource
|
@Resource
|
||||||
IActivityDefinitionService iActivityDefinitionService;
|
IActivityDefinitionService iActivityDefinitionService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ISpecimenService iSpecimenService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验当前用户是否有权操作该申请单(申请者本人或管理员)
|
||||||
|
*/
|
||||||
|
private R<?> validateRequestFormPermission(RequestForm requestForm) {
|
||||||
|
if (SecurityUtils.isAdmin(SecurityUtils.getUserId())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Long currentPractitionerId = SecurityUtils.getLoginUser().getPractitionerId();
|
||||||
|
Long requesterId = requestForm.getRequesterId();
|
||||||
|
if (currentPractitionerId == null || requesterId == null
|
||||||
|
|| !currentPractitionerId.equals(requesterId)) {
|
||||||
|
return R.fail("无操作权限,仅申请开立者或管理员可操作");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验关联医嘱是否已采证(存在已采集/已接收标本则不可撤回)
|
||||||
|
*/
|
||||||
|
private boolean hasCollectedSpecimen(List<Long> serviceRequestIds) {
|
||||||
|
if (serviceRequestIds == null || serviceRequestIds.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
long count = iSpecimenService.count(
|
||||||
|
new LambdaQueryWrapper<Specimen>()
|
||||||
|
.in(Specimen::getServiceId, serviceRequestIds)
|
||||||
|
.ge(Specimen::getCollectionStatusEnum, SpecCollectStatus.COLLECTED.getValue()));
|
||||||
|
return count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存申请单
|
* 保存申请单
|
||||||
*
|
*
|
||||||
@@ -528,12 +564,17 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
|||||||
if (requestForm == null) {
|
if (requestForm == null) {
|
||||||
return R.fail("申请单不存在");
|
return R.fail("申请单不存在");
|
||||||
}
|
}
|
||||||
|
R<?> permissionResult = validateRequestFormPermission(requestForm);
|
||||||
|
if (permissionResult != null) {
|
||||||
|
return permissionResult;
|
||||||
|
}
|
||||||
String prescriptionNo = requestForm.getPrescriptionNo();
|
String prescriptionNo = requestForm.getPrescriptionNo();
|
||||||
|
|
||||||
// 查询该申请单下所有 ServiceRequest(含子项)
|
// 查询该申请单下所有 ServiceRequest(含子项)
|
||||||
List<ServiceRequest> serviceRequests = iServiceRequestService.list(
|
List<ServiceRequest> serviceRequests = iServiceRequestService.list(
|
||||||
new LambdaQueryWrapper<ServiceRequest>()
|
new LambdaQueryWrapper<ServiceRequest>()
|
||||||
.eq(ServiceRequest::getPrescriptionNo, prescriptionNo));
|
.eq(ServiceRequest::getPrescriptionNo, prescriptionNo)
|
||||||
|
.eq(ServiceRequest::getDeleteFlag, DelFlag.NO.getCode()));
|
||||||
if (serviceRequests == null || serviceRequests.isEmpty()) {
|
if (serviceRequests == null || serviceRequests.isEmpty()) {
|
||||||
return R.fail("未找到关联的诊疗医嘱");
|
return R.fail("未找到关联的诊疗医嘱");
|
||||||
}
|
}
|
||||||
@@ -563,7 +604,7 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
|||||||
// 4. 删除申请单
|
// 4. 删除申请单
|
||||||
iRequestFormService.removeById(requestFormId);
|
iRequestFormService.removeById(requestFormId);
|
||||||
|
|
||||||
log.info("检查申请单删除成功,requestFormId={}, prescriptionNo={}", requestFormId, prescriptionNo);
|
log.info("检验申请单删除成功,requestFormId={}, prescriptionNo={}", requestFormId, prescriptionNo);
|
||||||
return R.ok("删除成功");
|
return R.ok("删除成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -576,32 +617,43 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
|||||||
if (requestForm == null) {
|
if (requestForm == null) {
|
||||||
return R.fail("申请单不存在");
|
return R.fail("申请单不存在");
|
||||||
}
|
}
|
||||||
|
R<?> permissionResult = validateRequestFormPermission(requestForm);
|
||||||
|
if (permissionResult != null) {
|
||||||
|
return permissionResult;
|
||||||
|
}
|
||||||
String prescriptionNo = requestForm.getPrescriptionNo();
|
String prescriptionNo = requestForm.getPrescriptionNo();
|
||||||
|
|
||||||
// 查询该申请单下所有 ServiceRequest
|
// 查询该申请单下所有 ServiceRequest
|
||||||
List<ServiceRequest> serviceRequests = iServiceRequestService.list(
|
List<ServiceRequest> serviceRequests = iServiceRequestService.list(
|
||||||
new LambdaQueryWrapper<ServiceRequest>()
|
new LambdaQueryWrapper<ServiceRequest>()
|
||||||
.eq(ServiceRequest::getPrescriptionNo, prescriptionNo));
|
.eq(ServiceRequest::getPrescriptionNo, prescriptionNo)
|
||||||
|
.eq(ServiceRequest::getDeleteFlag, DelFlag.NO.getCode()));
|
||||||
if (serviceRequests == null || serviceRequests.isEmpty()) {
|
if (serviceRequests == null || serviceRequests.isEmpty()) {
|
||||||
return R.fail("未找到关联的诊疗医嘱");
|
return R.fail("未找到关联的诊疗医嘱");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Long> serviceRequestIds = serviceRequests.stream()
|
||||||
|
.map(ServiceRequest::getId).collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 校验:标本已采集则不可撤回
|
||||||
|
if (hasCollectedSpecimen(serviceRequestIds)) {
|
||||||
|
return R.fail("标本已采集,无法撤回");
|
||||||
|
}
|
||||||
|
|
||||||
// 校验:只有已签发(status=2)的申请单可撤回
|
// 校验:只有已签发(status=2)的申请单可撤回
|
||||||
boolean allActive = serviceRequests.stream()
|
boolean allActive = serviceRequests.stream()
|
||||||
.allMatch(sr -> RequestStatus.ACTIVE.getValue().equals(sr.getStatusEnum()));
|
.allMatch(sr -> RequestStatus.ACTIVE.getValue().equals(sr.getStatusEnum()));
|
||||||
if (!allActive) {
|
if (!allActive) {
|
||||||
return R.fail("只有已签发状态的申请单可撤回");
|
return R.fail("只有已签发且未采证的申请单可撤回");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 将所有 ServiceRequest 状态改回待签发(DRAFT=0)
|
// 将所有 ServiceRequest 状态改回待签发,与申请单展示状态同步
|
||||||
List<Long> serviceRequestIds = serviceRequests.stream()
|
|
||||||
.map(ServiceRequest::getId).collect(Collectors.toList());
|
|
||||||
iServiceRequestService.update(
|
iServiceRequestService.update(
|
||||||
new ServiceRequest().setStatusEnum(RequestStatus.DRAFT.getValue()),
|
new ServiceRequest().setStatusEnum(RequestStatus.DRAFT.getValue()),
|
||||||
new LambdaUpdateWrapper<ServiceRequest>()
|
new LambdaUpdateWrapper<ServiceRequest>()
|
||||||
.in(ServiceRequest::getId, serviceRequestIds));
|
.in(ServiceRequest::getId, serviceRequestIds));
|
||||||
|
|
||||||
log.info("检查申请单撤回成功,requestFormId={}, prescriptionNo={}", requestFormId, prescriptionNo);
|
log.info("检验申请单撤回成功,requestFormId={}, prescriptionNo={}", requestFormId, prescriptionNo);
|
||||||
return R.ok("撤回成功");
|
return R.ok("撤回成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,21 +35,27 @@
|
|||||||
WHERE ws.prescription_no = drf.prescription_no AND ws.delete_flag = '0'
|
WHERE ws.prescription_no = drf.prescription_no AND ws.delete_flag = '0'
|
||||||
AND ws.status_enum = 8
|
AND ws.status_enum = 8
|
||||||
) THEN 6
|
) THEN 6
|
||||||
|
WHEN EXISTS (
|
||||||
|
SELECT 1 FROM wor_service_request ws
|
||||||
|
WHERE ws.prescription_no = drf.prescription_no AND ws.delete_flag = '0'
|
||||||
|
AND ws.status_enum = 5
|
||||||
|
) THEN 7
|
||||||
WHEN EXISTS (
|
WHEN EXISTS (
|
||||||
SELECT 1 FROM wor_service_request ws
|
SELECT 1 FROM wor_service_request ws
|
||||||
WHERE ws.prescription_no = drf.prescription_no AND ws.delete_flag = '0'
|
WHERE ws.prescription_no = drf.prescription_no AND ws.delete_flag = '0'
|
||||||
AND ws.status_enum = 3
|
AND ws.status_enum = 3
|
||||||
) THEN 5
|
) THEN 5
|
||||||
|
WHEN EXISTS (
|
||||||
|
SELECT 1 FROM wor_service_request ws
|
||||||
|
INNER JOIN lab_specimen ls ON ls.service_id = ws.id
|
||||||
|
WHERE ws.prescription_no = drf.prescription_no AND ws.delete_flag = '0'
|
||||||
|
AND ls.collection_status_enum >= 1
|
||||||
|
) THEN 4
|
||||||
WHEN EXISTS (
|
WHEN EXISTS (
|
||||||
SELECT 1 FROM wor_service_request ws
|
SELECT 1 FROM wor_service_request ws
|
||||||
WHERE ws.prescription_no = drf.prescription_no AND ws.delete_flag = '0'
|
WHERE ws.prescription_no = drf.prescription_no AND ws.delete_flag = '0'
|
||||||
AND ws.status_enum = 2
|
AND ws.status_enum = 2
|
||||||
) THEN 1
|
) THEN 1
|
||||||
WHEN EXISTS (
|
|
||||||
SELECT 1 FROM wor_service_request ws
|
|
||||||
WHERE ws.prescription_no = drf.prescription_no AND ws.delete_flag = '0'
|
|
||||||
AND ws.status_enum = 5
|
|
||||||
) THEN 7
|
|
||||||
ELSE 0
|
ELSE 0
|
||||||
END AS computed_status
|
END AS computed_status
|
||||||
FROM doc_request_form AS drf
|
FROM doc_request_form AS drf
|
||||||
|
|||||||
@@ -115,20 +115,20 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="requesterId_dictText" label="申请者" width="120" />
|
<el-table-column prop="requesterId_dictText" label="申请者" width="120" />
|
||||||
<el-table-column label="操作" align="center" fixed="right" width="220">
|
<el-table-column label="操作" align="center" fixed="right" width="280">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<!-- 待签发:可修改、删除 -->
|
<el-button link type="primary" @click="handleViewDetail(scope.row)">详情</el-button>
|
||||||
<template v-if="isPendingStatus(scope.row)">
|
<template v-if="canManageRow(scope.row)">
|
||||||
<el-button link type="primary" @click="handleEdit(scope.row)">修改</el-button>
|
<template v-if="isPendingStatus(scope.row)">
|
||||||
<el-button link type="danger" @click="handleDelete(scope.row)">删除</el-button>
|
<el-button link type="primary" @click="handleEdit(scope.row)">修改</el-button>
|
||||||
|
<el-button link type="danger" @click="handleDelete(scope.row)">删除</el-button>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="isWithdrawableStatus(scope.row)">
|
||||||
|
<el-button link type="warning" @click="handleWithdraw(scope.row)">撤回</el-button>
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
<!-- 已签发:可撤回 -->
|
<template v-if="isReportStatus(scope.row)">
|
||||||
<template v-else-if="isIssuedStatus(scope.row)">
|
<el-button link type="success" @click="handleViewReport(scope.row)">查看报告</el-button>
|
||||||
<el-button link type="warning" @click="handleWithdraw(scope.row)">撤回</el-button>
|
|
||||||
</template>
|
|
||||||
<!-- 已采证、已送检、报告已出、已作废:仅查看详情 -->
|
|
||||||
<template v-else>
|
|
||||||
<el-button link type="primary" @click="handleViewDetail(scope.row)">详情</el-button>
|
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -228,7 +228,10 @@ import {patientInfo} from '../../store/patient.js';
|
|||||||
import {getInspection, deleteRequestForm, withdrawRequestForm, getProofResult} from './api';
|
import {getInspection, deleteRequestForm, withdrawRequestForm, getProofResult} from './api';
|
||||||
import {getDepartmentList} from '@/api/public.js';
|
import {getDepartmentList} from '@/api/public.js';
|
||||||
import LaboratoryTests from '../order/applicationForm/laboratoryTests.vue';
|
import LaboratoryTests from '../order/applicationForm/laboratoryTests.vue';
|
||||||
import {saveInspection} from '../order/applicationForm/api.js';
|
import useUserStore from '@/store/modules/user';
|
||||||
|
import auth from '@/plugins/auth';
|
||||||
|
|
||||||
|
const userStore = useUserStore();
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance();
|
const { proxy } = getCurrentInstance();
|
||||||
|
|
||||||
@@ -378,10 +381,25 @@ const isPendingStatus = (row) => {
|
|||||||
return status === undefined || status === null || status === '' || String(status) === '0';
|
return status === undefined || status === null || status === '' || String(status) === '0';
|
||||||
};
|
};
|
||||||
|
|
||||||
const isIssuedStatus = (row) => String(getBillStatus(row)) === '1';
|
const isWithdrawableStatus = (row) => String(getBillStatus(row)) === '1';
|
||||||
|
|
||||||
const isReportStatus = (row) => ['6', '8'].includes(String(getBillStatus(row)));
|
const isReportStatus = (row) => ['6', '8'].includes(String(getBillStatus(row)));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否可管理该申请单:申请者本人或管理员
|
||||||
|
*/
|
||||||
|
const canManageRow = (row) => {
|
||||||
|
if (auth.hasRole('admin')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
const currentPractitionerId = userStore.practitionerId;
|
||||||
|
const requesterId = row?.requesterId;
|
||||||
|
if (!currentPractitionerId || !requesterId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return String(currentPractitionerId) === String(requesterId);
|
||||||
|
};
|
||||||
|
|
||||||
const sortByCreateTimeDesc = (a, b) => {
|
const sortByCreateTimeDesc = (a, b) => {
|
||||||
const aTime = a?.createTime ? new Date(a.createTime).getTime() : 0;
|
const aTime = a?.createTime ? new Date(a.createTime).getTime() : 0;
|
||||||
const bTime = b?.createTime ? new Date(b.createTime).getTime() : 0;
|
const bTime = b?.createTime ? new Date(b.createTime).getTime() : 0;
|
||||||
@@ -586,9 +604,9 @@ const submitEditForm = () => {
|
|||||||
*/
|
*/
|
||||||
const handleDelete = async (row) => {
|
const handleDelete = async (row) => {
|
||||||
try {
|
try {
|
||||||
await proxy.$modal?.confirm?.(`确定要删除申请单 "${row.prescriptionNo}" 吗?此操作不可恢复。`);
|
await proxy.$modal?.confirm?.('确认作废该申请单吗?作废后不可撤销');
|
||||||
} catch {
|
} catch {
|
||||||
return; // 用户取消
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -605,13 +623,15 @@ const handleDelete = async (row) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 撤回检验申请单(已签发状态撤回至待签发)
|
* 撤回检验申请单(已签发且未采证状态可撤回)
|
||||||
*/
|
*/
|
||||||
const handleWithdraw = async (row) => {
|
const handleWithdraw = async (row) => {
|
||||||
try {
|
try {
|
||||||
await proxy.$modal?.confirm?.(`确定要撤回申请单 "${row.prescriptionNo}" 吗?撤回后将恢复为待签发状态。`);
|
await proxy.$modal?.confirm?.(
|
||||||
|
'确认撤回该申请单吗?撤回后申请单及关联医嘱将恢复为待签发状态,护士站将同步更新。'
|
||||||
|
);
|
||||||
} catch {
|
} catch {
|
||||||
return; // 用户取消
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -740,6 +760,10 @@ defineExpose({
|
|||||||
|
|
||||||
.report-status-tag {
|
.report-status-tag {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
background-color: #f0f9eb !important;
|
||||||
|
border-color: #67c23a !important;
|
||||||
|
color: #529b2e !important;
|
||||||
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes rotating {
|
@keyframes rotating {
|
||||||
|
|||||||
Reference in New Issue
Block a user