Compare commits
254 Commits
e2d608ebb8
...
赵云-bug428
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ab046685c | ||
|
|
571f254d0e | ||
|
|
560813d009 | ||
| 31c2acb4ef | |||
|
|
254de01d2e | ||
|
|
e21122edf0 | ||
|
|
e9576ddfa8 | ||
|
|
b435de9e7b | ||
|
|
bc13fd6968 | ||
|
|
d9ad63397b | ||
|
|
bb3e1e300d | ||
|
|
46358ea03d | ||
| b5c308d9cb | |||
|
|
adfeb8f5e5 | ||
|
|
fd9309f125 | ||
|
|
46affb424e | ||
|
|
6dcee26b54 | ||
|
|
a282234bb0 | ||
|
|
52fc64c71d | ||
|
|
0bd1277307 | ||
|
|
e0e4c2bcc6 | ||
|
|
41bea23116 | ||
|
|
12382503f4 | ||
|
|
ae50a7042e | ||
|
|
9b1ac64cd6 | ||
|
|
6367654ada | ||
|
|
360256e589 | ||
|
|
feb033b857 | ||
|
|
79cce458ee | ||
|
|
1140912f3a | ||
| 250f9ce258 | |||
| 0d6f891b47 | |||
|
|
e68be3be79 | ||
|
|
eab0119c19 | ||
|
|
3ad9ff85d4 | ||
|
|
ab2f580d60 | ||
|
|
665d4ae47a | ||
|
|
d43a06c343 | ||
|
|
a7a33eb5f6 | ||
|
|
444397e868 | ||
|
|
d964155fb8 | ||
|
|
b88e011459 | ||
|
|
492a51d282 | ||
|
|
34774411eb | ||
|
|
0f1b29fcea | ||
|
|
d64ca5b8ee | ||
|
|
faa0b1a61f | ||
|
|
33c76c786c | ||
|
|
1a770ca0ee | ||
|
|
ba9c18b6a4 | ||
|
|
ecc5c75418 | ||
|
|
164ac604fb | ||
|
|
d19ceab70f | ||
|
|
753768a1f0 | ||
|
|
49889e9140 | ||
|
|
3c3428e0b1 | ||
|
|
db05a30795 | ||
|
|
e2feb4850c | ||
|
|
02f2a14178 | ||
|
|
1c87c39473 | ||
|
|
7c28a98d02 | ||
|
|
8e042cae93 | ||
|
|
415a76af49 | ||
|
|
6dc9788d8c | ||
|
|
319224cdac | ||
|
|
66d42f415a | ||
|
|
fd0132ba80 | ||
|
|
6907c7dbc8 | ||
|
|
487b05c845 | ||
|
|
71f99da69a | ||
|
|
15a65063a3 | ||
|
|
72fdafb032 | ||
|
|
56b8d0e98d | ||
|
|
f13734a19c | ||
|
|
6081412072 | ||
|
|
4a2f13cb19 | ||
|
|
522bc238aa | ||
|
|
bea2f27b15 | ||
|
|
95da4c2a57 | ||
|
|
53e3e9c4c0 | ||
|
|
55eba1a0b1 | ||
|
|
1525740ab5 | ||
|
|
96102e8b64 | ||
|
|
49df72121f | ||
|
|
65d1716ca9 | ||
|
|
509a0a788f | ||
|
|
6c4a8e3c14 | ||
|
|
7ada54510d | ||
|
|
1602615820 | ||
|
|
af15f2ae06 | ||
|
|
b1d5ae97b1 | ||
|
|
e5cd7bd792 | ||
|
|
294d7a5d11 | ||
|
|
e78a32a5ec | ||
|
|
dc9f47c534 | ||
|
|
5bf1e4151c | ||
|
|
b7365b6b06 | ||
|
|
c5c3bcae34 | ||
|
|
bacddc6d3f | ||
|
|
31cac09126 | ||
|
|
abc3bdd0c0 | ||
|
|
0f85e95d24 | ||
|
|
deb6ade97b | ||
|
|
2d7228ca5d | ||
|
|
a447e55d43 | ||
| 1be0dc2417 | |||
| a4b4d36d93 | |||
|
|
940fad5c7d | ||
|
|
ead3733aac | ||
|
|
28bf385ec2 | ||
|
|
31f7c4f32a | ||
|
|
480663f716 | ||
|
|
cc484d5f10 | ||
|
|
30f8cdbd80 | ||
|
|
f4c6c12ef8 | ||
|
|
8cf98008ae | ||
|
|
062c8d9dee | ||
|
|
ffdfebaacf | ||
|
|
9ed52b7c48 | ||
|
|
fc1ed6c4ce | ||
|
|
818564f5ba | ||
|
|
78adbddfde | ||
|
|
861db6b0f5 | ||
|
|
b7df71fd0b | ||
|
|
5bc8a8e517 | ||
| 0264fa9d58 | |||
| cd12dd7a22 | |||
|
|
bfddf87b2c | ||
|
|
84499d4ec1 | ||
|
|
01c5b62024 | ||
|
|
559821e4d3 | ||
|
|
0dd4c25c12 | ||
|
|
3590a18adc | ||
|
|
b96acc2402 | ||
|
|
e83c35c3f1 | ||
|
|
b5d876be36 | ||
|
|
5539d4cc03 | ||
|
|
982e905990 | ||
|
|
0d46f03e68 | ||
|
|
3cab8306c2 | ||
|
|
0600bbecbc | ||
|
|
ac57ac21e9 | ||
|
|
d38efd15b3 | ||
|
|
c7404e9d3f | ||
|
|
69b28c59f6 | ||
|
|
4e71b861ab | ||
|
|
7c471205a3 | ||
|
|
dc8661c3d0 | ||
|
|
c634551fdb | ||
|
|
c556d51eaf | ||
|
|
9280065c5b | ||
|
|
220982fa34 | ||
|
|
460890e3c2 | ||
|
|
6a0a2ca711 | ||
|
|
fbbe0e9248 | ||
|
|
b6df124e1b | ||
|
|
a0162686f4 | ||
|
|
23561cc9b1 | ||
|
|
cdb676c859 | ||
|
|
1b159cdfab | ||
|
|
01d48c75a5 | ||
|
|
c8fa9b4bf0 | ||
|
|
349c587386 | ||
|
|
656079b27b | ||
| ede6180c97 | |||
|
|
8de1f933e5 | ||
|
|
3f35b4f2bb | ||
| eb3d0ee608 | |||
|
|
dfe300cc1f | ||
|
|
9bd39c06e7 | ||
|
|
bde42d6b14 | ||
|
|
01bf3177c9 | ||
|
|
2a9f8376e6 | ||
|
|
0774d9f877 | ||
|
|
cee38eceae | ||
|
|
bbc740b6ce | ||
|
|
256b986c0e | ||
|
|
eaac16769d | ||
|
|
df6c5f3824 | ||
|
|
08075c90e2 | ||
|
|
c5820fcec2 | ||
|
|
fbe7f4f41f | ||
|
|
f9ab4c5688 | ||
|
|
861129c9d4 | ||
|
|
78a2dfa3fe | ||
|
|
98e5a0b984 | ||
| e5c944069b | |||
| a68ffbfec4 | |||
| 14f8a8b0a3 | |||
| 0f1e57227b | |||
|
|
98a370f3a2 | ||
| b2ce368749 | |||
| c691f82958 | |||
|
|
d2bfde7230 | ||
|
|
62a09a8b94 | ||
|
|
10b2c58a3e | ||
|
|
abc995523b | ||
|
|
c0438c0288 | ||
|
|
13731c2373 | ||
|
|
d63b00fd33 | ||
|
|
c60cd6878e | ||
|
|
cf50f8968a | ||
|
|
94fac8e257 | ||
|
|
f162134156 | ||
|
|
d866d898df | ||
|
|
6725cef643 | ||
|
|
7790a64eab | ||
|
|
49fa1c9b90 | ||
|
|
e0a035204e | ||
|
|
349b0453c8 | ||
|
|
3ddd74d679 | ||
|
|
9829843b3e | ||
|
|
0d95cc1341 | ||
|
|
1dfceeaf46 | ||
|
|
1b79df4f93 | ||
|
|
f62a280dfc | ||
|
|
e5d949a740 | ||
|
|
6451c308c2 | ||
|
|
772ec5537c | ||
|
|
af6494c806 | ||
|
|
2901dafe10 | ||
|
|
ffc2562aea | ||
|
|
5da537f863 | ||
|
|
facbe7cd44 | ||
|
|
283d25642a | ||
|
|
7b17a66214 | ||
|
|
2b64719d46 | ||
|
|
482a945b77 | ||
|
|
38a80cf7d6 | ||
|
|
db7f1a24f1 | ||
|
|
e0b6dda0e9 | ||
|
|
14525d457e | ||
|
|
e7a7bd1eda | ||
|
|
2188a32fc6 | ||
|
|
0f52327b8b | ||
|
|
0e6dc880b3 | ||
|
|
cb7f1e42cd | ||
|
|
f2d36b49b2 | ||
|
|
2c66e3b37a | ||
|
|
a66d83862f | ||
|
|
d3b6030693 | ||
|
|
57cdeef910 | ||
|
|
1c04c5aadd | ||
|
|
bae86d8dc4 | ||
|
|
21636de19c | ||
|
|
1c93227fad | ||
|
|
b48ca4fb4a | ||
|
|
cb33f4dbe9 | ||
|
|
2a8776ade2 | ||
| c67d88520f | |||
| a09dcb9295 | |||
| 2da3e86393 | |||
| e35d3bc23e | |||
| bc4a6cc6af |
@@ -14,6 +14,16 @@
|
||||
"date": 1778200962650,
|
||||
"name": "/root/.openclaw/workspace/his-repo/logs/application-2026-05-08.log",
|
||||
"hash": "cf50ef7b8aa656efb0a209a252219fea97a437ff9020b1b8770788f1ba51303e"
|
||||
},
|
||||
{
|
||||
"date": 1778293398212,
|
||||
"name": "/root/.openclaw/workspace/his-repo/logs/application-2026-05-09.log",
|
||||
"hash": "9ad2a1402927a9f4095f21ef01a6f6a2895a8f920bea4240ecb23492d6ea810f"
|
||||
},
|
||||
{
|
||||
"date": 1778379926939,
|
||||
"name": "/root/.openclaw/workspace/his-repo/logs/application-2026-05-10.log",
|
||||
"hash": "c6843438942d157762ae474e2f8330c7a05d73ad6dee6c84b789258abca304a7"
|
||||
}
|
||||
],
|
||||
"hashType": "sha256"
|
||||
|
||||
@@ -14,6 +14,16 @@
|
||||
"date": 1778200962653,
|
||||
"name": "/root/.openclaw/workspace/his-repo/logs/error-2026-05-08.log",
|
||||
"hash": "83b015957301572a67ea6fb41a65dfe5aa357831ca361155629630c6e9ef68bd"
|
||||
},
|
||||
{
|
||||
"date": 1778293398215,
|
||||
"name": "/root/.openclaw/workspace/his-repo/logs/error-2026-05-09.log",
|
||||
"hash": "d8abb547ad7f3d20b144728ffe4f4bf737c1211d04fd8e21868b169cbd2fb5e4"
|
||||
},
|
||||
{
|
||||
"date": 1778379926941,
|
||||
"name": "/root/.openclaw/workspace/his-repo/logs/error-2026-05-10.log",
|
||||
"hash": "bba83f44d0e39f37fbead445c361f95958f6b329fa37a53f553f8ed008dc0f08"
|
||||
}
|
||||
],
|
||||
"hashType": "sha256"
|
||||
|
||||
@@ -25,7 +25,7 @@ public class SysTenantController extends BaseController {
|
||||
private ISysTenantService sysTenantService;
|
||||
|
||||
/**
|
||||
* 查询租户分页列表
|
||||
* 查询租户分页列表(只读操作,不限制租户管理权限)
|
||||
*
|
||||
* @param tenantId 租户ID查询
|
||||
* @param tenantCode 租户编码模糊查询
|
||||
@@ -35,7 +35,7 @@ public class SysTenantController extends BaseController {
|
||||
* @param pageSize 每页多少条
|
||||
* @return 租户分页列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:tenant:operate')")
|
||||
@PreAuthorize("@ss.hasPermi('system:tenant:list')")
|
||||
@GetMapping("/page")
|
||||
public R<IPage<SysTenant>> getTenantPage(@RequestParam(required = false) Integer tenantId,
|
||||
@RequestParam(required = false) String tenantCode, @RequestParam(required = false) String tenantName,
|
||||
@@ -45,19 +45,19 @@ public class SysTenantController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询租户详情
|
||||
* 查询租户详情(只读操作)
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @return 租户分页列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:tenant:operate')")
|
||||
@PreAuthorize("@ss.hasPermi('system:tenant:list')")
|
||||
@GetMapping("/{tenantId}")
|
||||
public R<SysTenant> getTenantDetail(@PathVariable Integer tenantId) {
|
||||
return R.ok(sysTenantService.getById(tenantId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询租户所属用户分页列表
|
||||
* 查询租户所属用户分页列表(只读操作)
|
||||
*
|
||||
* @param tenantId 租户ID查询
|
||||
* @param userName 用户昵称模糊查询
|
||||
@@ -67,7 +67,7 @@ public class SysTenantController extends BaseController {
|
||||
* @param pageSize 每页多少条
|
||||
* @return 租户所属用户分页列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:tenant:operate')")
|
||||
@PreAuthorize("@ss.hasPermi('system:tenant:list')")
|
||||
@GetMapping("/user/page")
|
||||
public R<IPage<SysUser>> getTenantUserPage(@RequestParam(required = false) Integer tenantId,
|
||||
@RequestParam(required = false) String userName, @RequestParam(required = false) String nickName,
|
||||
@@ -141,14 +141,14 @@ public class SysTenantController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询租户未绑定的用户列表
|
||||
* 查询租户未绑定的用户列表(只读操作)
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @param pageNum 当前页
|
||||
* @param pageSize 每页多少条
|
||||
* @return 结果
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:tenant:operate')")
|
||||
@PreAuthorize("@ss.hasPermi('system:tenant:list')")
|
||||
@GetMapping("/{tenantId}/unbind-users")
|
||||
public R<IPage<SysUser>> getUnbindTenantUserList(@PathVariable Integer tenantId,
|
||||
@RequestParam(required = false) String userName, @RequestParam(required = false) String nickName,
|
||||
@@ -194,4 +194,4 @@ public class SysTenantController extends BaseController {
|
||||
public R<List<SysTenant>> getUserBindTenantList(@PathVariable String username) {
|
||||
return sysTenantService.getUserBindTenantList(username);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,18 +85,13 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService {
|
||||
String trimmedKey = searchKey.trim();
|
||||
return dictDataMapper.selectDictDataByTypeWithSearch(dictType, trimmedKey);
|
||||
}
|
||||
|
||||
// 否则使用原有方法(带缓存)
|
||||
List<SysDictData> dictDatas = DictUtils.getDictCache(dictType);
|
||||
if (StringUtils.isNotEmpty(dictDatas)) {
|
||||
return dictDatas;
|
||||
}
|
||||
dictDatas = dictDataMapper.selectDictDataByType(dictType);
|
||||
|
||||
// 直接查询数据库,避免缓存中为空数据导致前端下拉框显示"无数据"
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType);
|
||||
if (StringUtils.isNotEmpty(dictDatas)) {
|
||||
DictUtils.setDictCache(dictType, dictDatas);
|
||||
return dictDatas;
|
||||
}
|
||||
return null;
|
||||
return dictDatas;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.openhis.clinical.service.ITicketService;
|
||||
import com.openhis.web.appointmentmanage.appservice.ITicketAppService;
|
||||
import com.openhis.web.appointmentmanage.dto.TicketDto;
|
||||
import com.openhis.common.constant.CommonConstants.SlotStatus;
|
||||
import com.openhis.common.constant.CommonConstants.AppointmentOrderStatus;
|
||||
import com.openhis.common.enums.OrderStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -198,10 +198,11 @@ public class TicketAppServiceImpl implements ITicketAppService {
|
||||
if (SlotStatus.CHECKED_IN.equals(slotStatus)) {
|
||||
dto.setStatus("已取号");
|
||||
} else if (SlotStatus.BOOKED.equals(slotStatus)) {
|
||||
if (AppointmentOrderStatus.CHECKED_IN.equals(raw.getOrderStatus())) {
|
||||
dto.setStatus("已取号");
|
||||
} else if (AppointmentOrderStatus.RETURNED.equals(raw.getOrderStatus())) {
|
||||
// order_main.status: 0=患者取消(已退号) 2=系统取消 其余=已预约
|
||||
if (OrderStatus.PATIENT_CANCELLED.getValue().equals(raw.getOrderStatus())) {
|
||||
dto.setStatus("已退号");
|
||||
} else if (OrderStatus.SYSTEM_CANCELLED.getValue().equals(raw.getOrderStatus())) {
|
||||
dto.setStatus("系统取消");
|
||||
} else {
|
||||
dto.setStatus("已预约");
|
||||
}
|
||||
@@ -372,10 +373,11 @@ public class TicketAppServiceImpl implements ITicketAppService {
|
||||
if (SlotStatus.CHECKED_IN.equals(slotStatus)) {
|
||||
dto.setStatus("已取号");
|
||||
} else if (SlotStatus.BOOKED.equals(slotStatus)) {
|
||||
if (AppointmentOrderStatus.CHECKED_IN.equals(raw.getOrderStatus())) {
|
||||
dto.setStatus("已取号");
|
||||
} else if (AppointmentOrderStatus.RETURNED.equals(raw.getOrderStatus())) {
|
||||
// order_main.status: 0=患者取消(已退号) 2=系统取消 其余=已预约
|
||||
if (OrderStatus.PATIENT_CANCELLED.getValue().equals(raw.getOrderStatus())) {
|
||||
dto.setStatus("已退号");
|
||||
} else if (OrderStatus.SYSTEM_CANCELLED.getValue().equals(raw.getOrderStatus())) {
|
||||
dto.setStatus("系统取消");
|
||||
} else {
|
||||
dto.setStatus("已预约");
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.core.common.utils.MessageUtils;
|
||||
import com.openhis.administration.domain.Location;
|
||||
import com.openhis.administration.domain.Organization;
|
||||
import com.openhis.administration.domain.OrganizationLocation;
|
||||
import com.openhis.workflow.domain.ActivityDefinition;
|
||||
import com.openhis.administration.mapper.OrganizationLocationMapper;
|
||||
import com.openhis.administration.service.ILocationService;
|
||||
import com.openhis.administration.service.IOrganizationLocationService;
|
||||
@@ -70,6 +71,7 @@ public class OrganizationLocationAppServiceImpl implements IOrganizationLocation
|
||||
// 获取科室下拉选列表
|
||||
List<Organization> organizationList = organizationService.getList(OrganizationType.DEPARTMENT.getValue(), null);
|
||||
List<OrgLocInitDto.departmentOption> organizationOptions = organizationList.stream()
|
||||
.filter(organization -> organization != null && organization.getName() != null)
|
||||
.map(organization -> new OrgLocInitDto.departmentOption(organization.getId(), organization.getName()))
|
||||
.collect(Collectors.toList());
|
||||
initDto.setLocationFormOptions(chargeItemStatusOptions).setDepartmentOptions(organizationOptions);
|
||||
@@ -131,11 +133,18 @@ public class OrganizationLocationAppServiceImpl implements IOrganizationLocation
|
||||
@Override
|
||||
public R<?> addOrEditOrgLoc(OrgLocQueryDto orgLocQueryDto) {
|
||||
|
||||
// Validate required fields before processing
|
||||
if (orgLocQueryDto.getOrganizationId() == null) {
|
||||
return R.fail("请选择执行科室");
|
||||
}
|
||||
|
||||
OrganizationLocation orgLoc = new OrganizationLocation();
|
||||
BeanUtils.copyProperties(orgLocQueryDto, orgLoc);
|
||||
|
||||
Long activityDefinitionId = orgLoc.getActivityDefinitionId();
|
||||
String activityName = activityDefinitionId != null ? activityDefinitionMapper.selectById(activityDefinitionId).getName() : "";
|
||||
ActivityDefinition activityDef = activityDefinitionId != null
|
||||
? activityDefinitionMapper.selectById(activityDefinitionId) : null;
|
||||
String activityName = activityDef != null ? activityDef.getName() : "";
|
||||
|
||||
List<OrganizationLocation> organizationLocationList =
|
||||
organizationLocationService.getOrgLocListByOrgIdAndActivityDefinitionId(orgLoc.getActivityDefinitionId());
|
||||
@@ -147,8 +156,8 @@ public class OrganizationLocationAppServiceImpl implements IOrganizationLocation
|
||||
for (OrganizationLocation organizationLocation : organizationLocationList)
|
||||
if (DateTimeUtils.isOverlap(organizationLocation.getStartTime(), organizationLocation.getEndTime(),
|
||||
orgLoc.getStartTime(), orgLoc.getEndTime())) {
|
||||
String organizationName =
|
||||
organizationService.getById(organizationLocation.getOrganizationId()).getName();
|
||||
Organization org = organizationService.getById(organizationLocation.getOrganizationId());
|
||||
String organizationName = org != null ? org.getName() : "未知科室";
|
||||
return R.fail("当前诊疗:" + activityName + CommonConstants.Common.DASH + orgLoc.getStartTime()
|
||||
+ CommonConstants.Common.DASH + orgLoc.getEndTime() + "与" + organizationName + "时间冲突");
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.openhis.web.chargemanage.appservice.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.core.common.core.domain.R;
|
||||
@@ -329,16 +330,14 @@ public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistra
|
||||
}
|
||||
}
|
||||
|
||||
// 如果本次门诊挂号来自预约签到,同步把预约订单与号源槽位状态改为已退号
|
||||
// 退费成功后,同步回滚预约订单状态及号源;同时移除分诊队列
|
||||
Long refundOrderMainId = null;
|
||||
if (result != null && result.getCode() == 200) {
|
||||
syncAppointmentReturnStatus(byId, cancelRegPaymentDto.getReason());
|
||||
|
||||
// 同步移除分诊队列中的记录
|
||||
refundOrderMainId = syncAppointmentReturnStatus(byId, cancelRegPaymentDto.getReason());
|
||||
removeTriageQueueItem(byId.getId());
|
||||
}
|
||||
|
||||
// 记录退号日志
|
||||
recordRefundLog(cancelRegPaymentDto, byId, result, paymentRecon);
|
||||
// 退号日志独立事务写入,无论退费成功与否均记录
|
||||
recordRefundLog(cancelRegPaymentDto, byId, result, paymentRecon, refundOrderMainId);
|
||||
|
||||
// 2025/05/05 该处保存费用项后,会通过统一收费处理进行收费
|
||||
return R.ok(paymentRecon, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] {"退号"}));
|
||||
@@ -435,8 +434,6 @@ public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistra
|
||||
// 通过患者、科室、日期查找关联的预约订单
|
||||
LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<Order>()
|
||||
.eq(Order::getPatientId, encounter.getPatientId())
|
||||
.in(Order::getStatus, CommonConstants.AppointmentOrderStatus.BOOKED,
|
||||
CommonConstants.AppointmentOrderStatus.CHECKED_IN)
|
||||
.orderByDesc(Order::getUpdateTime)
|
||||
.orderByDesc(Order::getCreateTime)
|
||||
.last("LIMIT 1");
|
||||
@@ -590,20 +587,25 @@ public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistra
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步预约号源状态为已退号。
|
||||
* 说明:
|
||||
* 1) 门诊退号主流程不依赖该步骤成功与否,因此此方法内部异常仅记录日志,不向上抛出。
|
||||
* 2) 通过患者、科室、日期以及状态筛选最近一条预约订单,尽量避免误匹配。
|
||||
* 诊前退号:回滚预约订单、号源槽位、号源池统计。
|
||||
*
|
||||
* <p>处理四件事:
|
||||
* <ol>
|
||||
* <li>order_main → status=0(患者取消), pay_status=3(已退费), 写入取消时间和原因</li>
|
||||
* <li>adm_schedule_slot → status=0(待约), order_id=NULL(释放号源)</li>
|
||||
* <li>adm_schedule_pool → 重算统计值 + version+1</li>
|
||||
* <li>返回 order_main.id 供 refund_log 关联</li>
|
||||
* </ol>
|
||||
*
|
||||
* <p>异常仅记录日志不向上抛,不影响主流程返回成功。
|
||||
*/
|
||||
private void syncAppointmentReturnStatus(Encounter encounter, String reason) {
|
||||
private Long syncAppointmentReturnStatus(Encounter encounter, String reason) {
|
||||
if (encounter == null || encounter.getPatientId() == null) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<Order>()
|
||||
.eq(Order::getPatientId, encounter.getPatientId())
|
||||
.in(Order::getStatus, CommonConstants.AppointmentOrderStatus.BOOKED,
|
||||
CommonConstants.AppointmentOrderStatus.CHECKED_IN)
|
||||
.orderByDesc(Order::getUpdateTime)
|
||||
.orderByDesc(Order::getCreateTime)
|
||||
.last("LIMIT 1");
|
||||
@@ -625,35 +627,55 @@ public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistra
|
||||
|
||||
Order appointmentOrder = orderService.getOne(queryWrapper, false);
|
||||
if (appointmentOrder == null) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
Date now = new Date();
|
||||
if (!CommonConstants.AppointmentOrderStatus.RETURNED.equals(appointmentOrder.getStatus())) {
|
||||
Order updateOrder = new Order();
|
||||
updateOrder.setId(appointmentOrder.getId());
|
||||
updateOrder.setStatus(CommonConstants.AppointmentOrderStatus.RETURNED);
|
||||
updateOrder.setCancelTime(now);
|
||||
updateOrder.setCancelReason(
|
||||
StringUtils.isNotEmpty(reason) ? reason : "门诊退号");
|
||||
updateOrder.setUpdateTime(now);
|
||||
orderService.updateById(updateOrder);
|
||||
// 只有有效订单(1)才能退号
|
||||
if (!OrderStatus.ACTIVE.getValue().equals(appointmentOrder.getStatus())) {
|
||||
log.warn("退号跳过:订单状态非有效, orderId={}, status={}",
|
||||
appointmentOrder.getId(), appointmentOrder.getStatus());
|
||||
return null;
|
||||
}
|
||||
|
||||
// 乐观锁更新:WHERE version = 旧值,防并发重复退号
|
||||
boolean updated = orderService.update(
|
||||
new LambdaUpdateWrapper<Order>()
|
||||
.set(Order::getStatus, OrderStatus.PATIENT_CANCELLED.getValue())
|
||||
.set(Order::getPayStatus, PaymentStatus.REFUND_ALL.getValue())
|
||||
.set(Order::getCancelTime, new Date())
|
||||
.set(Order::getCancelReason,
|
||||
StringUtils.isNotEmpty(reason) ? reason : "诊前退号")
|
||||
.set(Order::getUpdateTime, new Date())
|
||||
.setSql("version = version + 1")
|
||||
.eq(Order::getId, appointmentOrder.getId())
|
||||
.eq(Order::getVersion, appointmentOrder.getVersion())
|
||||
);
|
||||
if (!updated) {
|
||||
log.warn("退号乐观锁冲突,订单已被其他操作修改, orderId={}", appointmentOrder.getId());
|
||||
return null;
|
||||
}
|
||||
|
||||
Long slotId = appointmentOrder.getSlotId();
|
||||
if (slotId == null) {
|
||||
return;
|
||||
return appointmentOrder.getId();
|
||||
}
|
||||
|
||||
int slotRows = scheduleSlotMapper.updateSlotStatus(slotId, CommonConstants.SlotStatus.RETURNED);
|
||||
int slotRows = scheduleSlotMapper.updateSlotStatus(slotId, CommonConstants.SlotStatus.AVAILABLE);
|
||||
if (slotRows > 0) {
|
||||
Long poolId = scheduleSlotMapper.selectPoolIdBySlotId(slotId);
|
||||
if (poolId != null) {
|
||||
schedulePoolMapper.refreshPoolStats(poolId);
|
||||
schedulePoolMapper.update(null,
|
||||
new LambdaUpdateWrapper<SchedulePool>()
|
||||
.setSql("version = version + 1")
|
||||
.set(SchedulePool::getUpdateTime, new Date())
|
||||
.eq(SchedulePool::getId, poolId));
|
||||
}
|
||||
}
|
||||
return appointmentOrder.getId();
|
||||
} catch (Exception e) {
|
||||
log.warn("同步预约号源已退号状态失败, encounterId={}", encounter.getId(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -672,22 +694,29 @@ public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistra
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录退号日志
|
||||
* 记录退号日志(独立事务)。
|
||||
*
|
||||
* <p>REQUIRES_NEW 确保即使主事务回滚,退号审计日志也不丢失。
|
||||
* orderMainId 优先使用 order_main.id,若退费失败则 fallback 到 encounterId。
|
||||
*
|
||||
* @param cancelRegPaymentDto 退号请求对象
|
||||
* @param encounter 就诊信息
|
||||
* @param result 退号结果
|
||||
* @param paymentRecon 支付对账信息
|
||||
* @param orderMainId 预约订单主键(order_main.id),用于关联业务数据
|
||||
*/
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public void recordRefundLog(CancelRegPaymentDto cancelRegPaymentDto,
|
||||
Encounter encounter,
|
||||
R<?> result,
|
||||
PaymentReconciliation paymentRecon) {
|
||||
PaymentReconciliation paymentRecon,
|
||||
Long orderMainId) {
|
||||
RefundLog refundLog = new RefundLog();
|
||||
try {
|
||||
// 1. 订单ID(唯一)
|
||||
String orderId = String.valueOf(cancelRegPaymentDto.getEncounterId());
|
||||
// 1. 订单ID(关联 order_main.id)
|
||||
String orderId = orderMainId != null
|
||||
? String.valueOf(orderMainId)
|
||||
: String.valueOf(cancelRegPaymentDto.getEncounterId());
|
||||
refundLog.setOrderId(orderId);
|
||||
|
||||
// 已存在则不重复插入(防止唯一约束异常)
|
||||
|
||||
@@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.check.domain.CheckPackage;
|
||||
import com.openhis.check.domain.CheckPackageDetail;
|
||||
import com.openhis.check.domain.CheckPart;
|
||||
import com.openhis.check.service.ICheckPackageDetailService;
|
||||
import com.openhis.check.service.ICheckPackageService;
|
||||
import com.openhis.check.service.ICheckPartService;
|
||||
import com.openhis.web.check.appservice.ICheckPackageAppService;
|
||||
import com.openhis.web.check.dto.CheckPackageDetailDto;
|
||||
import com.openhis.web.check.dto.CheckPackageDto;
|
||||
@@ -34,6 +36,7 @@ public class CheckPackageAppServiceImpl implements ICheckPackageAppService {
|
||||
|
||||
private final ICheckPackageService checkPackageService;
|
||||
private final ICheckPackageDetailService checkPackageDetailService;
|
||||
private final ICheckPartService checkPartService;
|
||||
|
||||
/**
|
||||
* 转换明细 DTO 列表为实体列表
|
||||
@@ -61,6 +64,25 @@ public class CheckPackageAppServiceImpl implements ICheckPackageAppService {
|
||||
return details;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步更新引用此套餐的检查部位价格
|
||||
*/
|
||||
private void syncCheckPartPrice(String packageName, java.math.BigDecimal newPrice) {
|
||||
if (packageName == null || newPrice == null) {
|
||||
return;
|
||||
}
|
||||
List<CheckPart> parts = checkPartService.list(
|
||||
new LambdaQueryWrapper<CheckPart>()
|
||||
.eq(CheckPart::getPackageName, packageName)
|
||||
);
|
||||
if (parts.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
parts.forEach(part -> part.setPrice(newPrice.doubleValue()));
|
||||
checkPartService.updateBatchById(parts);
|
||||
log.info("套餐[{}]价格更新为 {},已同步更新 {} 个检查部位的价格", packageName, newPrice, parts.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> getCheckPackageList() {
|
||||
try {
|
||||
@@ -134,6 +156,9 @@ public class CheckPackageAppServiceImpl implements ICheckPackageAppService {
|
||||
}
|
||||
}
|
||||
|
||||
// 同步更新引用此套餐的检查部位价格
|
||||
syncCheckPartPrice(checkPackage.getPackageName(), checkPackage.getPackagePrice());
|
||||
|
||||
return R.ok(checkPackage.getId(), "保存成功");
|
||||
} catch (Exception e) {
|
||||
log.error("新增检查套餐失败", e);
|
||||
@@ -193,6 +218,9 @@ public class CheckPackageAppServiceImpl implements ICheckPackageAppService {
|
||||
checkPackageDetailService.saveBatch(details);
|
||||
}
|
||||
|
||||
// 同步更新引用此套餐的检查部位价格
|
||||
syncCheckPartPrice(existPackage.getPackageName(), checkPackage.getPackagePrice());
|
||||
|
||||
return R.ok("更新成功");
|
||||
} catch (Exception e) {
|
||||
log.error("更新检查套餐失败", e);
|
||||
|
||||
@@ -366,7 +366,7 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService {
|
||||
serviceRequest.setTherapyEnum(TherapyTimeType.TEMPORARY.getValue());// 治疗类型
|
||||
serviceRequest.setQuantity(BigDecimal.valueOf(1)); // 请求数量
|
||||
serviceRequest.setUnitCode("次"); // 请求单位编码
|
||||
serviceRequest.setCategoryEnum(4); // 请求类型:4-手术
|
||||
serviceRequest.setCategoryEnum(24); // 请求类型:24-手术(新值域,避开 adviceType 碰撞)
|
||||
serviceRequest.setActivityId(surgeryId); // 手术ID作为诊疗定义id
|
||||
serviceRequest.setPatientId(surgeryDto.getPatientId()); // 患者
|
||||
serviceRequest.setRequesterId(practitionerId); // 开方医生
|
||||
@@ -418,7 +418,7 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService {
|
||||
// 清除相关缓存
|
||||
clearSurgeryAppCache(surgery);
|
||||
|
||||
return R.ok(surgeryId, MessageUtils.createMessage(PromptMsgConstant.Common.M00001, new Object[]{"手术信息"}));
|
||||
return R.ok(surgeryId, "手术申请提交成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -497,7 +497,7 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService {
|
||||
// 清除相关缓存
|
||||
clearSurgeryAppCache(surgery);
|
||||
|
||||
return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00002, new Object[]{"手术信息"}));
|
||||
return R.ok(null, "手术申请修改成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.core.common.core.domain.R;
|
||||
import com.core.common.core.domain.model.LoginUser;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.openhis.administration.domain.Patient;
|
||||
import com.openhis.administration.service.IOrganizationService;
|
||||
import com.openhis.administration.service.IPatientService;
|
||||
import com.openhis.clinical.domain.Surgery;
|
||||
import com.openhis.clinical.service.ISurgeryService;
|
||||
@@ -28,7 +27,6 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URLEncoder;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -204,6 +202,8 @@ public class SurgicalScheduleAppServiceImpl implements ISurgicalScheduleAppServi
|
||||
return R.fail("新增手术安排失败");
|
||||
}
|
||||
|
||||
syncSurgeryIncisionLevel(opSchedule.getOperCode(), opCreateScheduleDto.getIncisionLevel());
|
||||
|
||||
// Bug #247 修复:更新手术申请单状态为已排期 (1)
|
||||
if (opCreateScheduleDto.getApplyId() != null) {
|
||||
try {
|
||||
@@ -300,6 +300,8 @@ public class SurgicalScheduleAppServiceImpl implements ISurgicalScheduleAppServi
|
||||
return R.fail("修改手术安排失败");
|
||||
}
|
||||
|
||||
syncSurgeryIncisionLevel(opScheduleDto.getOperCode(), opScheduleDto.getIncisionLevel());
|
||||
|
||||
return R.ok("修改手术安排成功");
|
||||
}
|
||||
|
||||
@@ -433,6 +435,28 @@ public class SurgicalScheduleAppServiceImpl implements ISurgicalScheduleAppServi
|
||||
return scheduleDate.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步手术申请表中的切口类型
|
||||
*/
|
||||
private void syncSurgeryIncisionLevel(String surgeryNo, Integer incisionLevel) {
|
||||
if (surgeryNo == null || surgeryNo.isEmpty() || incisionLevel == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<Surgery> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(Surgery::getSurgeryNo, surgeryNo)
|
||||
.eq(Surgery::getDeleteFlag, "0");
|
||||
Surgery surgery = surgeryService.getOne(queryWrapper);
|
||||
if (surgery == null) {
|
||||
log.warn("未找到需要同步切口类型的手术申请记录 - surgeryNo: {}", surgeryNo);
|
||||
return;
|
||||
}
|
||||
|
||||
surgery.setIncisionLevel(incisionLevel);
|
||||
surgery.setUpdateTime(new Date());
|
||||
surgeryService.updateById(surgery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充手术申请中缺失的名称字段
|
||||
* 在创建手术安排时调用,确保关联的cli_surgery表中的名称字段有值
|
||||
|
||||
@@ -2,9 +2,13 @@ package com.openhis.web.clinicalmanage.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.common.enums.ActivityDefCategory;
|
||||
import com.openhis.web.clinicalmanage.appservice.ISurgicalScheduleAppService;
|
||||
import com.openhis.web.clinicalmanage.dto.OpCreateScheduleDto;
|
||||
import com.openhis.web.clinicalmanage.dto.OpScheduleDto;
|
||||
import com.openhis.web.regdoctorstation.appservice.IRequestFormManageAppService;
|
||||
import com.openhis.web.regdoctorstation.dto.RequestFormDto;
|
||||
import com.openhis.web.regdoctorstation.dto.RequestFormPageDto;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -26,6 +30,7 @@ import java.util.Map;
|
||||
public class SurgicalScheduleController {
|
||||
|
||||
private final ISurgicalScheduleAppService surgicalScheduleAppService;
|
||||
private final IRequestFormManageAppService requestFormManageAppService;
|
||||
|
||||
/**
|
||||
* 分页查询手术安排列表
|
||||
@@ -87,6 +92,27 @@ public class SurgicalScheduleController {
|
||||
return surgicalScheduleAppService.deleteSurgerySchedule(scheduleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询待排期手术申请列表
|
||||
*
|
||||
* @param requestFormDto 查询条件
|
||||
* @return 手术申请列表
|
||||
*/
|
||||
@PostMapping(value = "/apply-list")
|
||||
public R<IPage<RequestFormPageDto>> getSurgeryApplyList(@RequestBody RequestFormDto requestFormDto) {
|
||||
if (requestFormDto.getPageNo() == null) {
|
||||
requestFormDto.setPageNo(1);
|
||||
}
|
||||
if (requestFormDto.getPageSize() == null) {
|
||||
requestFormDto.setPageSize(10);
|
||||
}
|
||||
//虽然很想这么写,但是库里的手术申请单的type_code都是直接写的SURGERY
|
||||
// requestFormDto.setTypeCode(ActivityDefCategory.PROCEDURE.getCode());
|
||||
//只查询手术申请单
|
||||
requestFormDto.setTypeCode("SURGERY");
|
||||
return R.ok(requestFormManageAppService.getRequestFormPage(requestFormDto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出手术安排列表
|
||||
*
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@@ -85,6 +84,11 @@ public class OpCreateScheduleDto {
|
||||
*/
|
||||
private String surgerySite;
|
||||
|
||||
/**
|
||||
* 切口类型
|
||||
*/
|
||||
private Integer incisionLevel;
|
||||
|
||||
/**
|
||||
* 入院时间
|
||||
*/
|
||||
@@ -246,11 +250,26 @@ public class OpCreateScheduleDto {
|
||||
*/
|
||||
private String communicationInfo;
|
||||
|
||||
/**
|
||||
* 是否外请专家 1-是 0-否
|
||||
*/
|
||||
private Integer isExternalExpert;
|
||||
|
||||
/**
|
||||
* 外请专家姓名
|
||||
*/
|
||||
private String externalExpertName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 费用类别
|
||||
*/
|
||||
private String feeType;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.openhis.surgicalschedule.domain.OpSchedule;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDate;
|
||||
@@ -93,6 +94,12 @@ public class OpScheduleDto extends OpSchedule {
|
||||
* 手术类型
|
||||
*/
|
||||
private String surgeryType;
|
||||
|
||||
/**
|
||||
* 切口类型
|
||||
*/
|
||||
private Integer incisionLevel;
|
||||
|
||||
/**
|
||||
* 申请科室
|
||||
*/
|
||||
@@ -106,4 +113,5 @@ public class OpScheduleDto extends OpSchedule {
|
||||
* 创建人名称
|
||||
*/
|
||||
private String createByName;
|
||||
|
||||
}
|
||||
|
||||
@@ -59,6 +59,16 @@ public interface IDoctorStationAdviceAppService {
|
||||
*/
|
||||
R<?> getRequestBaseInfo(Long encounterId);
|
||||
|
||||
/**
|
||||
* 查询医嘱请求数据(支持按生成来源和来源单据号过滤)
|
||||
*
|
||||
* @param encounterId 就诊id
|
||||
* @param generateSourceEnum 生成来源(可选,如手术计费=6)
|
||||
* @param sourceBillNo 来源业务单据号(可选)
|
||||
* @return 医嘱请求数据
|
||||
*/
|
||||
R<?> getRequestBaseInfo(Long encounterId, Integer generateSourceEnum, String sourceBillNo);
|
||||
|
||||
/**
|
||||
* 门诊签退医嘱
|
||||
*
|
||||
|
||||
@@ -35,51 +35,8 @@ import com.openhis.medication.service.IMedicationDispenseService;
|
||||
import com.openhis.medication.service.IMedicationRequestService;
|
||||
import com.openhis.web.chargemanage.mapper.OutpatientRegistrationAppMapper;
|
||||
import com.openhis.web.doctorstation.appservice.IDoctorStationAdviceAppService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAppService {
|
||||
|
||||
@Autowired
|
||||
private IChargeItemService chargeItemService;
|
||||
|
||||
/**
|
||||
* 查询护理级别相关的医嘱项目
|
||||
*/
|
||||
@Override
|
||||
public R<List<ChargeItem>> getNursingLevelItems(String keyword) {
|
||||
try {
|
||||
LambdaQueryWrapper<ChargeItem> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ChargeItem::getDelFlag, DelFlag.NORMAL)
|
||||
.and(wrapper -> wrapper.like(ChargeItem::getItemName, keyword)
|
||||
.or()
|
||||
.like(ChargeItem::getItemCode, keyword))
|
||||
.orderByAsc(ChargeItem::getItemName);
|
||||
|
||||
List<ChargeItem> chargeItems = chargeItemService.list(queryWrapper);
|
||||
|
||||
// 过滤出与护理相关的项目
|
||||
List<ChargeItem> nursingItems = chargeItems.stream()
|
||||
.filter(item -> item.getItemName().contains("护理") ||
|
||||
item.getItemName().toLowerCase().contains("nursing") ||
|
||||
item.getItemCategory() != null &&
|
||||
(item.getItemCategory().contains("护理") ||
|
||||
item.getItemCategory().toLowerCase().contains("nursing")))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return R.ok(nursingItems);
|
||||
} catch (Exception e) {
|
||||
// 记录错误日志但返回空列表避免前端显示错误
|
||||
System.out.println("查询护理级别项目失败: " + e.getMessage());
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
```mport com.openhis.web.doctorstation.dto.*;
|
||||
import com.openhis.web.doctorstation.appservice.IDoctorStationInspectionLabApplyService;
|
||||
import com.openhis.web.doctorstation.dto.*;
|
||||
import com.openhis.web.doctorstation.mapper.DoctorStationAdviceAppMapper;
|
||||
import com.openhis.web.doctorstation.utils.AdviceUtils;
|
||||
import com.openhis.web.doctorstation.utils.DoctorStationSendApplyUtil;
|
||||
@@ -87,21 +44,19 @@ import com.openhis.web.doctorstation.utils.PrescriptionUtils;
|
||||
import com.openhis.web.personalization.dto.ActivityDeviceDto;
|
||||
import com.openhis.workflow.domain.ActivityDefinition;
|
||||
import com.openhis.workflow.domain.DeviceRequest;
|
||||
import com.openhis.workflow.domain.ServiceRequest;
|
||||
import com.openhis.workflow.service.IActivityDefinitionService;
|
||||
import com.openhis.workflow.service.IDeviceDispenseService;
|
||||
import com.openhis.workflow.service.IDeviceRequestService;
|
||||
import com.openhis.workflow.service.IServiceRequestService;
|
||||
import com.openhis.workflow.domain.InventoryItem;
|
||||
import com.openhis.workflow.service.IInventoryItemService;
|
||||
import com.openhis.workflow.domain.ServiceRequest;
|
||||
import com.openhis.workflow.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -111,6 +66,9 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAppService {
|
||||
|
||||
private static final Pattern INSPECTION_APPLY_NO_JSON =
|
||||
Pattern.compile("\"applyNo\"\\s*:\\s*\"([^\"]+)\"");
|
||||
|
||||
@Resource
|
||||
AssignSeqUtil assignSeqUtil;
|
||||
|
||||
@@ -167,6 +125,13 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
@Resource
|
||||
IInventoryItemService inventoryItemService;
|
||||
|
||||
/**
|
||||
* 与检验申请实现存在循环依赖,需延迟注入;删除诊疗医嘱时按 contentJson 级联作废检验申请单。
|
||||
*/
|
||||
@Resource
|
||||
@Lazy
|
||||
private IDoctorStationInspectionLabApplyService iDoctorStationInspectionLabApplyService;
|
||||
|
||||
// 缓存 key 前缀
|
||||
private static final String ADVICE_BASE_INFO_CACHE_PREFIX = "advice:base:info:";
|
||||
// 缓存过期时间(小时)
|
||||
@@ -190,8 +155,8 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
*/
|
||||
@Override
|
||||
public IPage<AdviceBaseDto> getAdviceBaseInfo(AdviceBaseDto adviceBaseDto, String searchKey, Long locationId,
|
||||
List<Long> adviceDefinitionIdParamList, Long organizationId, Integer pageNo, Integer pageSize,
|
||||
Integer pricingFlag, List<Integer> adviceTypes, String orderPricing, String categoryCode) {
|
||||
List<Long> adviceDefinitionIdParamList, Long organizationId, Integer pageNo, Integer pageSize,
|
||||
Integer pricingFlag, List<Integer> adviceTypes, String orderPricing, String categoryCode) {
|
||||
|
||||
// 生成缓存键,处理可能的null值
|
||||
String safeSearchKey = searchKey != null ? searchKey : "";
|
||||
@@ -277,36 +242,58 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
// 医嘱定义ID集合
|
||||
List<Long> adviceDefinitionIdList = adviceBaseDtoList.stream().map(AdviceBaseDto::getAdviceDefinitionId)
|
||||
.collect(Collectors.toList());
|
||||
// 费用定价主表ID集合
|
||||
List<Long> chargeItemDefinitionIdList = adviceBaseDtoList.stream().map(AdviceBaseDto::getChargeItemDefinitionId)
|
||||
// 费用定价主表ID集合(过滤null值,手术项目无定价定义)
|
||||
List<Long> chargeItemDefinitionIdList = adviceBaseDtoList.stream()
|
||||
.map(AdviceBaseDto::getChargeItemDefinitionId)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
// 医嘱库存集合
|
||||
List<AdviceInventoryDto> adviceInventoryList = doctorStationAdviceAppMapper.getAdviceInventory(locationId,
|
||||
adviceDefinitionIdList,
|
||||
CommonConstants.SqlCondition.ABOUT_INVENTORY_TABLE_STR, PublicationStatus.ACTIVE.getValue());
|
||||
// 待发放个数信息
|
||||
List<AdviceInventoryDto> adviceDraftInventoryList = doctorStationAdviceAppMapper.getAdviceDraftInventory(
|
||||
CommonConstants.TableName.MED_MEDICATION_DEFINITION, CommonConstants.TableName.ADM_DEVICE_DEFINITION,
|
||||
DispenseStatus.DRAFT.getValue(), DispenseStatus.PREPARATION.getValue());
|
||||
// 预减库存
|
||||
List<AdviceInventoryDto> adviceInventory = adviceUtils.subtractInventory(adviceInventoryList,
|
||||
adviceDraftInventoryList);
|
||||
// 查询取药科室配置
|
||||
List<AdviceInventoryDto> medLocationConfig = doctorStationAdviceAppMapper.getMedLocationConfig(organizationId);
|
||||
// 将配置转为 {categoryCode -> 允许的locationId集合}
|
||||
Map<String, Set<Long>> allowedLocByCategory = new HashMap<>();
|
||||
if (medLocationConfig != null && !medLocationConfig.isEmpty()) {
|
||||
for (AdviceInventoryDto cfg : medLocationConfig) {
|
||||
if (cfg.getCategoryCode() == null || cfg.getLocationId() == null) {
|
||||
continue;
|
||||
}
|
||||
allowedLocByCategory.computeIfAbsent(String.valueOf(cfg.getCategoryCode()), k -> new HashSet<>())
|
||||
.add(cfg.getLocationId());
|
||||
}
|
||||
|
||||
// 判断是否包含药品或耗材类型(只有这些类型才需要库存相关查询)
|
||||
boolean hasMedOrDevice = adviceTypes != null
|
||||
&& (adviceTypes.contains(1) || adviceTypes.contains(2));
|
||||
|
||||
// 医嘱库存集合 — 仅药品/耗材需要库存查询,手术/诊疗(3,6)无库存概念,跳过以减少数据库开销
|
||||
List<AdviceInventoryDto> adviceInventoryList;
|
||||
List<AdviceInventoryDto> adviceDraftInventoryList;
|
||||
List<AdviceInventoryDto> adviceInventory;
|
||||
if (hasMedOrDevice) {
|
||||
adviceInventoryList = doctorStationAdviceAppMapper.getAdviceInventory(locationId,
|
||||
adviceDefinitionIdList,
|
||||
CommonConstants.SqlCondition.ABOUT_INVENTORY_TABLE_STR, PublicationStatus.ACTIVE.getValue());
|
||||
// 待发放个数信息
|
||||
adviceDraftInventoryList = doctorStationAdviceAppMapper.getAdviceDraftInventory(
|
||||
CommonConstants.TableName.MED_MEDICATION_DEFINITION, CommonConstants.TableName.ADM_DEVICE_DEFINITION,
|
||||
DispenseStatus.DRAFT.getValue(), DispenseStatus.PREPARATION.getValue());
|
||||
// 预减库存
|
||||
adviceInventory = adviceUtils.subtractInventory(adviceInventoryList, adviceDraftInventoryList);
|
||||
} else {
|
||||
adviceInventoryList = Collections.emptyList();
|
||||
adviceDraftInventoryList = Collections.emptyList();
|
||||
adviceInventory = Collections.emptyList();
|
||||
}
|
||||
// 费用定价子表信息 - 使用分批处理避免大量参数问题
|
||||
// 查询取药科室配置 — 仅药品开单场景需要
|
||||
List<AdviceInventoryDto> medLocationConfig;
|
||||
Map<String, Set<Long>> allowedLocByCategory;
|
||||
if (hasMedOrDevice) {
|
||||
medLocationConfig = doctorStationAdviceAppMapper.getMedLocationConfig(organizationId);
|
||||
// 将配置转为 {categoryCode -> 允许的locationId集合}
|
||||
allowedLocByCategory = new HashMap<>();
|
||||
if (medLocationConfig != null && !medLocationConfig.isEmpty()) {
|
||||
for (AdviceInventoryDto cfg : medLocationConfig) {
|
||||
if (cfg.getCategoryCode() == null || cfg.getLocationId() == null) {
|
||||
continue;
|
||||
}
|
||||
allowedLocByCategory.computeIfAbsent(String.valueOf(cfg.getCategoryCode()), k -> new HashSet<>())
|
||||
.add(cfg.getLocationId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
medLocationConfig = Collections.emptyList();
|
||||
allowedLocByCategory = Collections.emptyMap();
|
||||
}
|
||||
// 费用定价子表信息 - 仅药品/耗材需要批次定价查询,手术/诊疗无库存概念不需要
|
||||
List<AdvicePriceDto> childCharge = new ArrayList<>();
|
||||
if (chargeItemDefinitionIdList != null && !chargeItemDefinitionIdList.isEmpty()) {
|
||||
if (hasMedOrDevice && chargeItemDefinitionIdList != null && !chargeItemDefinitionIdList.isEmpty()) {
|
||||
// 分批处理,每批最多1000个ID,增加批次大小以减少查询次数
|
||||
int batchSize = 1000;
|
||||
for (int i = 0; i < chargeItemDefinitionIdList.size(); i += batchSize) {
|
||||
@@ -986,11 +973,16 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
}
|
||||
}
|
||||
for (AdviceSaveDto adviceSaveDto : deleteList) {
|
||||
iMedicationRequestService.removeById(adviceSaveDto.getRequestId());
|
||||
Long requestId = adviceSaveDto.getRequestId();
|
||||
// 🔧 Bug #442: 跳过 requestId 为 null 的记录,避免删除不存在的药品请求
|
||||
if (requestId == null) {
|
||||
log.warn("BugFix#442: handMedication - 跳过 requestId 为 null 的删除请求");
|
||||
continue;
|
||||
}
|
||||
iMedicationRequestService.removeById(requestId);
|
||||
// 删除已经产生的药品发放信息
|
||||
iMedicationDispenseService.deleteMedicationDispense(adviceSaveDto.getRequestId());
|
||||
// 🔧 Bug Fix #219: 删除费用项
|
||||
Long requestId = adviceSaveDto.getRequestId();
|
||||
String serviceTable = CommonConstants.TableName.MED_MEDICATION_REQUEST;
|
||||
// 直接删除费用项
|
||||
iChargeItemService.deleteByServiceTableAndId(serviceTable, requestId);
|
||||
@@ -1446,6 +1438,11 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
log.info("BugFix#219: handDevice - 开始删除循环, deleteList.size={}", deleteList.size());
|
||||
for (AdviceSaveDto adviceSaveDto : deleteList) {
|
||||
Long requestId = adviceSaveDto.getRequestId();
|
||||
// 🔧 Bug #442: 跳过 requestId 为 null 的记录,避免删除不存在的耗材请求
|
||||
if (requestId == null) {
|
||||
log.warn("BugFix#442: handDevice - 跳过 requestId 为 null 的删除请求");
|
||||
continue;
|
||||
}
|
||||
log.info("BugFix#219: handDevice - 删除开始: requestId={}", requestId);
|
||||
|
||||
// 1. 删除耗材请求
|
||||
@@ -1546,21 +1543,44 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
deviceRequest.setBusNo(assignSeqUtil.getSeqByDay(AssignSeqEnum.DEVICE_RES_NO.getPrefix(), 4));
|
||||
}
|
||||
deviceRequest.setGenerateSourceEnum(GenerateSource.DOCTOR_PRESCRIPTION.getValue()); // 生成来源
|
||||
deviceRequest.setPrescriptionNo(adviceSaveDto.getSourceBillNo()); // 来源业务单据号(手术单号)
|
||||
deviceRequest.setQuantity(adviceSaveDto.getQuantity()); // 请求数量
|
||||
deviceRequest.setUnitCode(adviceSaveDto.getUnitCode()); // 请求单位编码
|
||||
deviceRequest.setLotNumber(adviceSaveDto.getLotNumber());// 产品批号
|
||||
|
||||
deviceRequest.setCategoryEnum(adviceSaveDto.getCategoryEnum()); // 请求类型
|
||||
deviceRequest.setDeviceDefId(adviceSaveDto.getAdviceDefinitionId());// 耗材定义id
|
||||
// 🔧 BugFix #498: categoryEnum=22(检查) 走 ServiceRequest,不走 DeviceRequest
|
||||
// 检查申请单的诊疗定义ID存在 activityId,不在 adviceDefinitionId
|
||||
// deviceDefId 对应耗材定义ID,不能用诊疗定义ID填充
|
||||
if (adviceSaveDto.getCategoryEnum() == 22) {
|
||||
log.info("handDevice skip - 检查申请单(categoryEnum=22) 走 ServiceRequest 路径,跳过 DeviceRequest 保存");
|
||||
continue; // 跳过本次循环,不走耗材请求路径
|
||||
} else if (adviceSaveDto.getAdviceDefinitionId() != null) {
|
||||
deviceRequest.setDeviceDefId(adviceSaveDto.getAdviceDefinitionId());// 耗材定义id
|
||||
} else {
|
||||
log.warn("handDevice - deviceDefId 为空,adviceDefinitionId=null, categoryEnum={}", adviceSaveDto.getCategoryEnum());
|
||||
}
|
||||
|
||||
deviceRequest.setPatientId(adviceSaveDto.getPatientId()); // 患者
|
||||
deviceRequest.setRequesterId(adviceSaveDto.getPractitionerId()); // 开方医生
|
||||
deviceRequest.setOrgId(adviceSaveDto.getFounderOrgId());// 开方人科室
|
||||
deviceRequest.setReqAuthoredTime(curDate); // 请求开始时间
|
||||
// 发放耗材房(若前端未传locationId,使用登录用户的科室作为默认值)
|
||||
// 发放耗材房(若前端未传locationId,优先沿用已有DeviceRequest的performLocation,否则使用登录用户科室)
|
||||
Long locId = adviceSaveDto.getLocationId();
|
||||
if (locId == null) {
|
||||
locId = SecurityUtils.getLoginUser().getOrgId();
|
||||
log.info("耗材locationId为空,使用登录用户科室作为默认值: locationId={}", locId);
|
||||
// 尝试从已有DeviceRequest获取原始的performLocation
|
||||
if (adviceSaveDto.getRequestId() != null) {
|
||||
DeviceRequest existingDevice = iDeviceRequestService.getById(adviceSaveDto.getRequestId());
|
||||
if (existingDevice != null && existingDevice.getPerformLocation() != null) {
|
||||
locId = existingDevice.getPerformLocation();
|
||||
log.info("耗材locationId为空,使用已有DeviceRequest的performLocation: locationId={}", locId);
|
||||
}
|
||||
}
|
||||
// 如果已有记录也没有performLocation,则使用登录用户科室作为兜底
|
||||
if (locId == null) {
|
||||
locId = SecurityUtils.getLoginUser().getOrgId();
|
||||
log.info("耗材locationId为空且无已有记录,使用登录用户科室作为默认值: locationId={}", locId);
|
||||
}
|
||||
}
|
||||
deviceRequest.setPerformLocation(locId);
|
||||
deviceRequest.setEncounterId(adviceSaveDto.getEncounterId()); // 就诊id
|
||||
@@ -1701,6 +1721,21 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从诊疗医嘱 contentJson 中解析检验申请单号(检验保存时写入形如 {"applyNo":"..."})。
|
||||
*/
|
||||
private String extractInspectionApplyNoFromContentJson(String contentJson) {
|
||||
if (StringUtils.isBlank(contentJson) || !contentJson.contains("applyNo")) {
|
||||
return null;
|
||||
}
|
||||
Matcher m = INSPECTION_APPLY_NO_JSON.matcher(contentJson);
|
||||
if (!m.find()) {
|
||||
return null;
|
||||
}
|
||||
String applyNo = m.group(1).trim();
|
||||
return StringUtils.isBlank(applyNo) ? null : applyNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理诊疗
|
||||
*/
|
||||
@@ -1749,13 +1784,49 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
}
|
||||
}
|
||||
}
|
||||
// 检验申请单在医嘱 contentJson 中写入 applyNo;从医嘱删除时需先级联作废检验单,避免检验页签仍显示孤儿申请
|
||||
Map<String, List<Long>> labApplyNoToRequestIds = new LinkedHashMap<>();
|
||||
for (AdviceSaveDto adviceSaveDto : deleteList) {
|
||||
iServiceRequestService.removeById(adviceSaveDto.getRequestId());// 删除诊疗
|
||||
Long requestId = adviceSaveDto.getRequestId();
|
||||
// 🔧 Bug #442: 跳过 requestId 为 null 的记录,避免删除不存在的诊疗请求
|
||||
if (requestId == null) {
|
||||
log.warn("BugFix#442: handService - 跳过 requestId 为 null 的删除请求");
|
||||
continue;
|
||||
}
|
||||
iServiceRequestService.removeById(requestId);// 删除诊疗
|
||||
ServiceRequest existing = iServiceRequestService.getById(adviceSaveDto.getRequestId());
|
||||
if (existing == null) {
|
||||
continue;
|
||||
}
|
||||
String applyNo = extractInspectionApplyNoFromContentJson(existing.getContentJson());
|
||||
if (StringUtils.isNotBlank(applyNo)) {
|
||||
labApplyNoToRequestIds.computeIfAbsent(applyNo, k -> new ArrayList<>())
|
||||
.add(adviceSaveDto.getRequestId());
|
||||
}
|
||||
}
|
||||
Set<Long> labCascadeSkippedRequestIds = new HashSet<>();
|
||||
for (Map.Entry<String, List<Long>> e : labApplyNoToRequestIds.entrySet()) {
|
||||
R<?> delLab = iDoctorStationInspectionLabApplyService.deleteInspectionLabApply(e.getKey());
|
||||
if (delLab != null && R.isSuccess(delLab)) {
|
||||
labCascadeSkippedRequestIds.addAll(e.getValue());
|
||||
log.info("handService - 级联作废检验申请单 applyNo={},已跳过重复删除的医嘱 requestIds={}",
|
||||
e.getKey(), e.getValue());
|
||||
} else {
|
||||
String msg = delLab != null && StringUtils.isNotEmpty(delLab.getMsg()) ? delLab.getMsg() : "删除检验申请单失败";
|
||||
log.warn("handService - 级联作废检验申请单未成功 applyNo={} msg={},将回退为仅删除当前医嘱记录",
|
||||
e.getKey(), msg);
|
||||
}
|
||||
}
|
||||
for (AdviceSaveDto adviceSaveDto : deleteList) {
|
||||
if (labCascadeSkippedRequestIds.contains(adviceSaveDto.getRequestId())) {
|
||||
continue;
|
||||
}
|
||||
Long requestId = adviceSaveDto.getRequestId();
|
||||
iServiceRequestService.removeById(requestId);// 删除诊疗
|
||||
iServiceRequestService.remove(
|
||||
new LambdaQueryWrapper<ServiceRequest>().eq(ServiceRequest::getParentId,
|
||||
adviceSaveDto.getRequestId()));// 删除诊疗套餐对应的子项
|
||||
requestId));// 删除诊疗套餐对应的子项
|
||||
// 🔧 Bug Fix #219: 删除费用项
|
||||
Long requestId = adviceSaveDto.getRequestId();
|
||||
String serviceTable = CommonConstants.TableName.WOR_SERVICE_REQUEST;
|
||||
// 直接删除费用项
|
||||
iChargeItemService.deleteByServiceTableAndId(serviceTable, requestId);
|
||||
@@ -1812,8 +1883,9 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
log.info("handService - 自动补全founderOrgId: founderOrgId={}", adviceSaveDto.getFounderOrgId());
|
||||
}
|
||||
|
||||
// 🔧 Bug Fix #238: 诊疗项目执行科室非空校验
|
||||
if (adviceSaveDto.getAdviceType() != null && adviceSaveDto.getAdviceType() == 3) {
|
||||
// 🔧 Bug Fix #238/#454: 诊疗项目执行科室非空校验(删除操作跳过校验)
|
||||
if (adviceSaveDto.getAdviceType() != null && adviceSaveDto.getAdviceType() == 3
|
||||
&& !DbOpType.DELETE.getCode().equals(adviceSaveDto.getDbOpType())) {
|
||||
Long effectiveOrgId = adviceSaveDto.getEffectiveOrgId();
|
||||
if (effectiveOrgId == null) {
|
||||
throw new ServiceException("诊疗项目必须选择执行科室");
|
||||
@@ -1835,6 +1907,7 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
serviceRequest.setBusNo(assignSeqUtil.getSeqByDay(AssignSeqEnum.SERVICE_RES_NO.getPrefix(), 4));
|
||||
}
|
||||
serviceRequest.setGenerateSourceEnum(GenerateSource.DOCTOR_PRESCRIPTION.getValue()); // 生成来源
|
||||
serviceRequest.setPrescriptionNo(adviceSaveDto.getSourceBillNo()); // 来源业务单据号(手术单号)
|
||||
serviceRequest.setQuantity(adviceSaveDto.getQuantity()); // 请求数量
|
||||
serviceRequest.setUnitCode(adviceSaveDto.getUnitCode()); // 请求单位编码
|
||||
|
||||
@@ -2016,13 +2089,25 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
*/
|
||||
@Override
|
||||
public R<?> getRequestBaseInfo(Long encounterId) {
|
||||
return this.getRequestBaseInfo(encounterId, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> getRequestBaseInfo(Long encounterId, Integer generateSourceEnum, String sourceBillNo) {
|
||||
// 当前账号的参与者id
|
||||
Long practitionerId = SecurityUtils.getLoginUser().getPractitionerId();
|
||||
// 未指定generateSourceEnum时,默认只查询医生开立的医嘱
|
||||
int sourceEnum = (generateSourceEnum != null) ? generateSourceEnum : GenerateSource.DOCTOR_PRESCRIPTION.getValue();
|
||||
// 医嘱请求数据
|
||||
List<RequestBaseDto> requestBaseInfo = doctorStationAdviceAppMapper.getRequestBaseInfo(encounterId, null,
|
||||
CommonConstants.TableName.MED_MEDICATION_REQUEST, CommonConstants.TableName.WOR_DEVICE_REQUEST,
|
||||
CommonConstants.TableName.WOR_SERVICE_REQUEST, practitionerId, Whether.NO.getCode(),
|
||||
GenerateSource.DOCTOR_PRESCRIPTION.getValue());
|
||||
sourceEnum, sourceBillNo);
|
||||
// 手术计费场景:sourceBillNo 不为空时,过滤掉药品(1),保留耗材(2)和诊疗(3/6)
|
||||
if (sourceBillNo != null && !sourceBillNo.isEmpty()) {
|
||||
requestBaseInfo.removeIf(dto -> dto.getAdviceType() != null
|
||||
&& dto.getAdviceType() == 1);
|
||||
}
|
||||
for (RequestBaseDto requestBaseDto : requestBaseInfo) {
|
||||
// 请求状态
|
||||
requestBaseDto
|
||||
@@ -2143,7 +2228,7 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
List<RequestBaseDto> requestBaseInfo = doctorStationAdviceAppMapper.getRequestBaseInfo(encounterId, patientId,
|
||||
CommonConstants.TableName.MED_MEDICATION_REQUEST, CommonConstants.TableName.WOR_DEVICE_REQUEST,
|
||||
CommonConstants.TableName.WOR_SERVICE_REQUEST, practitionerId, Whether.YES.getCode(),
|
||||
GenerateSource.DOCTOR_PRESCRIPTION.getValue());
|
||||
GenerateSource.DOCTOR_PRESCRIPTION.getValue(), null);
|
||||
for (RequestBaseDto requestBaseDto : requestBaseInfo) {
|
||||
// 请求状态
|
||||
requestBaseDto
|
||||
|
||||
@@ -36,12 +36,13 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
import java.util.*;
|
||||
|
||||
import static com.openhis.common.constant.CommonConstants.FieldName.DeleteFlag;
|
||||
import static com.openhis.common.enums.ReportCardStatus.SUBMITTED;
|
||||
import static java.time.LocalDateTime.now;
|
||||
|
||||
/**
|
||||
* 医生站-诊断 应用实现类
|
||||
@@ -253,6 +254,9 @@ public class DoctorStationDiagnosisAppServiceImpl implements IDoctorStationDiagn
|
||||
encounterDiagnosis.setMedTypeCode(saveDiagnosisChildParam.getMedTypeCode());// 医疗类型
|
||||
encounterDiagnosis.setDiagnosisDesc(saveDiagnosisChildParam.getDiagnosisDesc()); // 诊断描述
|
||||
encounterDiagnosis.setIptDiseTypeCode(saveDiagnosisChildParam.getIptDiseTypeCode()); // 患者疾病诊断类型代码
|
||||
encounterDiagnosis.setDoctor(saveDiagnosisChildParam.getDiagnosisDoctor());
|
||||
encounterDiagnosis.setDiagnosisTime(saveDiagnosisChildParam.getDiagnosisTime());
|
||||
encounterDiagnosis.setOnsetDate(saveDiagnosisChildParam.getOnsetDate());
|
||||
// 设置租户ID,避免数据库约束错误
|
||||
encounterDiagnosis.setTenantId(SecurityUtils.getLoginUser().getTenantId());
|
||||
// 设置创建人,避免数据库约束错误
|
||||
@@ -260,8 +264,10 @@ public class DoctorStationDiagnosisAppServiceImpl implements IDoctorStationDiagn
|
||||
// 设置创建时间,避免数据库约束错误
|
||||
encounterDiagnosis.setCreateTime(new Date());
|
||||
iEncounterDiagnosisService.saveOrUpdate(encounterDiagnosis);
|
||||
// 回写就诊诊断ID,供前端后续更新使用
|
||||
saveDiagnosisChildParam.setEncounterDiagnosisId(encounterDiagnosis.getId());
|
||||
}
|
||||
return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00002, new Object[] {"诊断"}));
|
||||
return R.ok(saveDiagnosisParam, MessageUtils.createMessage(PromptMsgConstant.Common.M00002, new Object[] {"诊断"}));
|
||||
}
|
||||
|
||||
|
||||
@@ -579,7 +585,11 @@ public class DoctorStationDiagnosisAppServiceImpl implements IDoctorStationDiagn
|
||||
@Override
|
||||
public R<?> saveInfectiousDiseaseReport(InfectiousDiseaseReportDto infectiousDiseaseReportDto) {
|
||||
// 检查卡片编号唯一性(新增时检查,编辑时排除当前记录)
|
||||
String cardNo = infectiousDiseaseReportDto.getCardNo().trim();
|
||||
String cardNo = infectiousDiseaseReportDto.getCardNo();
|
||||
if (cardNo == null || cardNo.trim().isEmpty()) {
|
||||
return R.fail("卡片编号不能为空");
|
||||
}
|
||||
cardNo = cardNo.trim();
|
||||
LambdaQueryWrapper<InfectiousDiseaseReport> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(InfectiousDiseaseReport::getCardNo, cardNo);
|
||||
long count = iInfectiousDiseaseReportService.count(queryWrapper);
|
||||
@@ -591,6 +601,25 @@ public class DoctorStationDiagnosisAppServiceImpl implements IDoctorStationDiagn
|
||||
InfectiousDiseaseReport infectiousDiseaseReport = new InfectiousDiseaseReport();
|
||||
BeanUtils.copyProperties(infectiousDiseaseReportDto, infectiousDiseaseReport);
|
||||
|
||||
// BeanUtils.copyProperties 不支持 LocalDate/LocalDateTime 到 java.util.Date 的类型转换,需手动处理
|
||||
if (infectiousDiseaseReportDto.getOnsetDate() != null) {
|
||||
infectiousDiseaseReport.setOnsetDate(
|
||||
Date.from(infectiousDiseaseReportDto.getOnsetDate().atStartOfDay(ZoneId.systemDefault()).toInstant()));
|
||||
}
|
||||
if (infectiousDiseaseReportDto.getDiagDate() != null) {
|
||||
infectiousDiseaseReport.setDiagDate(
|
||||
Date.from(infectiousDiseaseReportDto.getDiagDate().atZone(ZoneId.systemDefault()).toInstant()));
|
||||
}
|
||||
// deathDate / reportDate 同理
|
||||
if (infectiousDiseaseReportDto.getDeathDate() != null) {
|
||||
infectiousDiseaseReport.setDeathDate(
|
||||
Date.from(infectiousDiseaseReportDto.getDeathDate().atStartOfDay(ZoneId.systemDefault()).toInstant()));
|
||||
}
|
||||
if (infectiousDiseaseReportDto.getReportDate() != null) {
|
||||
infectiousDiseaseReport.setReportDate(
|
||||
Date.from(infectiousDiseaseReportDto.getReportDate().atStartOfDay(ZoneId.systemDefault()).toInstant()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置创建人、删除状态、租户ID
|
||||
*/
|
||||
|
||||
@@ -274,27 +274,8 @@ public class DoctorStationMainAppServiceImpl implements IDoctorStationMainAppSer
|
||||
return R.fail("非就诊中患者不能完诊");
|
||||
}
|
||||
|
||||
// 2. 获取 pool_id 和 slot_id:从 encounter → order_main → adm_schedule_slot 链路获取
|
||||
// 确保 div_log 中的值与排班主表一致,不依赖 triage_queue_item(队列项可能不存在或值错误)
|
||||
// 2. 查找队列项(限定当天,避免复诊患者匹配到历史队列记录)
|
||||
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||
Long divPoolId = null;
|
||||
Long divSlotId = null;
|
||||
if (encounter.getOrderId() != null) {
|
||||
try {
|
||||
Order order = iOrderService.getById(encounter.getOrderId());
|
||||
if (order != null && order.getSlotId() != null) {
|
||||
divSlotId = order.getSlotId();
|
||||
ScheduleSlot slot = scheduleSlotMapper.selectById(divSlotId);
|
||||
if (slot != null) {
|
||||
divPoolId = slot.getPoolId();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("获取完诊div_log的pool_id/slot_id失败,encounterId={}", encounterId, e);
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 查找队列项(限定当天,避免复诊患者匹配到历史队列记录)
|
||||
TriageQueueItem queueItem = triageQueueItemService.getOne(
|
||||
new LambdaQueryWrapper<TriageQueueItem>()
|
||||
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||
@@ -303,30 +284,84 @@ public class DoctorStationMainAppServiceImpl implements IDoctorStationMainAppSer
|
||||
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||
);
|
||||
|
||||
// 当天未找到时回退:不限日期查最近一条(防止跨日就诊队列项遗漏更新)
|
||||
if (queueItem == null) {
|
||||
queueItem = triageQueueItemService.getOne(
|
||||
new LambdaQueryWrapper<TriageQueueItem>()
|
||||
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||
.eq(TriageQueueItem::getEncounterId, encounterId)
|
||||
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||
.orderByDesc(TriageQueueItem::getQueueDate)
|
||||
.last("LIMIT 1")
|
||||
);
|
||||
if (queueItem != null) {
|
||||
log.warn("完诊:当天队列项未找到,回退使用最近队列记录 queueDate={}, id={}",
|
||||
queueItem.getQueueDate(), queueItem.getId());
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 获取 pool_id 和 slot_id:优先使用 triage_queue_item(挂号时录入的号源信息,为权威来源)
|
||||
// 队列项不存在或值缺失时,回退使用 encounter → order_main → adm_schedule_slot 链路
|
||||
Long divPoolId = null;
|
||||
Long divSlotId = null;
|
||||
if (queueItem != null && queueItem.getPoolId() != null && queueItem.getSlotId() != null) {
|
||||
divPoolId = queueItem.getPoolId();
|
||||
divSlotId = queueItem.getSlotId();
|
||||
}
|
||||
// 队列项 poolId/slotId 缺失时,通过 encounter.orderId → order_main.slot_id → adm_schedule_slot.pool_id 回退获取
|
||||
if ((divPoolId == null || divSlotId == null) && encounter.getOrderId() != null) {
|
||||
try {
|
||||
Order order = iOrderService.getById(encounter.getOrderId());
|
||||
if (order != null && order.getSlotId() != null) {
|
||||
ScheduleSlot slot = scheduleSlotMapper.selectById(order.getSlotId());
|
||||
if (slot != null) {
|
||||
divSlotId = slot.getId();
|
||||
divPoolId = slot.getPoolId();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("回退获取完诊div_log的pool_id/slot_id失败,encounterId={}", encounterId, e);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果队列项存在且未完成,更新队列状态为已完成
|
||||
// 使用排除法而非白名单:只要不是"已完成"就可以完诊,覆盖跳过、等待等非标准流转状态
|
||||
// Bug #401:在更新前记录队列原始完成状态,用于判断是否需要写入 div_log
|
||||
boolean queueWasAlreadyCompleted = queueItem != null
|
||||
&& TriageQueueStatus.COMPLETED.getValue().equals(queueItem.getStatus());
|
||||
if (queueItem != null &&
|
||||
!TriageQueueStatus.COMPLETED.getValue().equals(queueItem.getStatus())) {
|
||||
java.time.LocalDateTime nowLocal = java.time.LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS);
|
||||
queueItem.setStatus(TriageQueueStatus.COMPLETED.getValue());
|
||||
queueItem.setUpdateTime(nowLocal);
|
||||
triageQueueItemService.updateById(queueItem);
|
||||
// 使用 LambdaUpdateWrapper 直接更新,确保 status 字段必定写入数据库
|
||||
boolean queueUpdate = triageQueueItemService.update(new LambdaUpdateWrapper<TriageQueueItem>()
|
||||
.eq(TriageQueueItem::getId, queueItem.getId())
|
||||
.set(TriageQueueItem::getStatus, TriageQueueStatus.COMPLETED.getValue())
|
||||
.set(TriageQueueItem::getUpdateTime, nowLocal));
|
||||
if (!queueUpdate) {
|
||||
log.error("完诊:triage_queue_item 状态更新失败,queueItemId={}", queueItem.getId());
|
||||
}
|
||||
} else if (queueItem == null) {
|
||||
log.error("完诊:未找到任何 triage_queue_item 记录,encounterId={}, tenantId={}",
|
||||
encounterId, tenantId);
|
||||
}
|
||||
|
||||
// 写入 div_log 审计日志(独立于队列项,确保每次完诊都生成记录)
|
||||
try {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
DivLog divLog = new DivLog()
|
||||
.setPoolId(divPoolId)
|
||||
.setSlotId(divSlotId)
|
||||
.setOpUserId(loginUser != null ? loginUser.getUserId() : null)
|
||||
.setAction("COMPLETE")
|
||||
.setCreateTime(LocalDateTime.now())
|
||||
.setUpdateAt(LocalDateTime.now())
|
||||
.setCreatedAt(LocalDateTime.now());
|
||||
divLogService.save(divLog);
|
||||
} catch (Exception e) {
|
||||
log.error("写入div_log审计日志失败", e);
|
||||
// Bug #401:使用更新前记录的原始状态判断,避免自身更新后将状态改为 COMPLETED 导致误判为"已完成"
|
||||
if (!queueWasAlreadyCompleted) {
|
||||
try {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
DivLog divLog = new DivLog()
|
||||
.setPoolId(divPoolId)
|
||||
.setSlotId(divSlotId)
|
||||
.setOpUserId(loginUser != null ? loginUser.getUserId() : null)
|
||||
.setAction("COMPLETE")
|
||||
.setCreateTime(LocalDateTime.now())
|
||||
.setUpdateAt(LocalDateTime.now())
|
||||
.setCreatedAt(LocalDateTime.now());
|
||||
divLogService.save(divLog);
|
||||
} catch (Exception e) {
|
||||
log.error("写入div_log审计日志失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 更新状态、完成时间以及初复诊标识
|
||||
|
||||
@@ -112,11 +112,16 @@ public class DoctorStationAdviceController {
|
||||
* 查询医嘱请求数据
|
||||
*
|
||||
* @param encounterId 就诊id
|
||||
* @param generateSourceEnum 生成来源(可选,用于按来源过滤,如手术计费=6)
|
||||
* @param sourceBillNo 来源业务单据号(可选,用于按来源单据过滤)
|
||||
* @return 医嘱请求数据
|
||||
*/
|
||||
@GetMapping(value = "/request-base-info")
|
||||
public R<?> getRequestBaseInfo(@RequestParam(required = false) Long encounterId) {
|
||||
return iDoctorStationAdviceAppService.getRequestBaseInfo(encounterId);
|
||||
public R<?> getRequestBaseInfo(
|
||||
@RequestParam(required = false) Long encounterId,
|
||||
@RequestParam(required = false) Integer generateSourceEnum,
|
||||
@RequestParam(required = false) String sourceBillNo) {
|
||||
return iDoctorStationAdviceAppService.getRequestBaseInfo(encounterId, generateSourceEnum, sourceBillNo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -91,4 +91,14 @@ public class DiagnosisQueryDto {
|
||||
*/
|
||||
private Date diagnosisTime;
|
||||
|
||||
/**
|
||||
* 诊断医生
|
||||
*/
|
||||
private String diagnosisDoctor;
|
||||
|
||||
/**
|
||||
* 是否已有传染病报卡(0-无,1-有)
|
||||
*/
|
||||
private Integer hasInfectiousReport;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.openhis.web.doctorstation.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
@@ -55,6 +56,7 @@ public class InfectiousDiseaseReportDto {
|
||||
private String sex;
|
||||
|
||||
/** 出生日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date birthday;
|
||||
|
||||
/** 实足年龄 */
|
||||
|
||||
@@ -122,7 +122,8 @@ public interface DoctorStationAdviceAppMapper {
|
||||
@Param("MED_MEDICATION_REQUEST") String MED_MEDICATION_REQUEST,
|
||||
@Param("WOR_DEVICE_REQUEST") String WOR_DEVICE_REQUEST,
|
||||
@Param("WOR_SERVICE_REQUEST") String WOR_SERVICE_REQUEST, @Param("practitionerId") Long practitionerId,
|
||||
@Param("historyFlag") String historyFlag, @Param("generateSourceEnum") Integer generateSourceEnum);
|
||||
@Param("historyFlag") String historyFlag, @Param("generateSourceEnum") Integer generateSourceEnum,
|
||||
@Param("sourceBillNo") String sourceBillNo);
|
||||
|
||||
/**
|
||||
* 查询就诊费用性质
|
||||
|
||||
@@ -83,9 +83,14 @@ public class AdviceUtils {
|
||||
* @return 提示信息
|
||||
*/
|
||||
public String checkInventory(List<AdviceSaveDto> adviceSaveList) {
|
||||
// 医嘱定义ID集合
|
||||
// 医嘱定义ID集合(过滤null值,避免SQL查询异常)
|
||||
List<Long> adviceDefinitionIdList
|
||||
= adviceSaveList.stream().map(AdviceSaveDto::getAdviceDefinitionId).collect(Collectors.toList());
|
||||
= adviceSaveList.stream().map(AdviceSaveDto::getAdviceDefinitionId)
|
||||
.filter(id -> id != null).collect(Collectors.toList());
|
||||
// 🔧 Bug #504 修复:如果所有adviceDefinitionId都为null,跳过库存校验
|
||||
if (adviceDefinitionIdList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
// 医嘱库存集合
|
||||
List<AdviceInventoryDto> adviceInventoryList
|
||||
= doctorStationAdviceAppMapper.getAdviceInventory(null, adviceDefinitionIdList,
|
||||
@@ -99,6 +104,10 @@ public class AdviceUtils {
|
||||
= this.subtractInventory(adviceInventoryList, adviceDraftInventoryList);
|
||||
// 检查库存
|
||||
for (AdviceSaveDto saveDto : adviceSaveList) {
|
||||
// 🔧 Bug #504 修复:退回医嘱可能adviceDefinitionId为空,跳过校验
|
||||
if (saveDto.getAdviceDefinitionId() == null) {
|
||||
continue;
|
||||
}
|
||||
boolean matched = false;
|
||||
for (AdviceInventoryDto inventoryDto : adviceInventory) {
|
||||
// 匹配条件:adviceDefinitionId, adviceTableName, locationId, lotNumber 同时相等
|
||||
@@ -108,10 +117,12 @@ public class AdviceUtils {
|
||||
|| saveDto.getLotNumber().equals(inventoryDto.getLotNumber());
|
||||
boolean tableNameMatch = StringUtils.isEmpty(saveDto.getAdviceTableName())
|
||||
|| inventoryDto.getItemTable().equals(saveDto.getAdviceTableName());
|
||||
// if (saveDto.)
|
||||
// 🔧 Bug #504 修复:退回医嘱可能locationId为空,跳过location匹配
|
||||
boolean locationMatch = saveDto.getLocationId() == null
|
||||
|| inventoryDto.getLocationId().equals(saveDto.getLocationId());
|
||||
if (inventoryDto.getItemId().equals(saveDto.getAdviceDefinitionId())
|
||||
&& tableNameMatch
|
||||
&& inventoryDto.getLocationId().equals(saveDto.getLocationId()) && lotNumberMatch) {
|
||||
&& locationMatch && lotNumberMatch) {
|
||||
matched = true;
|
||||
// 检查库存是否充足
|
||||
BigDecimal minUnitQuantity = saveDto.getMinUnitQuantity();
|
||||
@@ -167,22 +178,37 @@ public class AdviceUtils {
|
||||
// 生命提示信息集合
|
||||
List<String> tipsList = new ArrayList<>();
|
||||
for (MedicationRequestUseExe medicationRequestUseExe : medUseExeList) {
|
||||
Optional<AdviceInventoryDto> matchedInventory = adviceInventory.stream()
|
||||
// 第一步:按 performLocation 匹配指定药房的库存
|
||||
List<AdviceInventoryDto> matchedInventories = adviceInventory.stream()
|
||||
.filter(inventoryDto -> medicationRequestUseExe.getMedicationId().equals(inventoryDto.getItemId())
|
||||
&& CommonConstants.TableName.MED_MEDICATION_DEFINITION.equals(inventoryDto.getItemTable())
|
||||
&& medicationRequestUseExe.getPerformLocation().equals(inventoryDto.getLocationId())
|
||||
&& (medicationRequestUseExe.getPerformLocation() == null
|
||||
|| medicationRequestUseExe.getPerformLocation().equals(inventoryDto.getLocationId()))
|
||||
// 如果选择了具体的批次号,校验库存时需要加上批次号的匹配条件
|
||||
&& (StringUtils.isEmpty(medicationRequestUseExe.getLotNumber())
|
||||
|| medicationRequestUseExe.getLotNumber().equals(inventoryDto.getLotNumber())))
|
||||
.findFirst();
|
||||
.collect(Collectors.toList());
|
||||
// 第二步:如果指定药房没有匹配到库存,则放宽条件查询所有药房的库存
|
||||
if (matchedInventories.isEmpty()) {
|
||||
matchedInventories = adviceInventory.stream()
|
||||
.filter(inventoryDto -> medicationRequestUseExe.getMedicationId().equals(inventoryDto.getItemId())
|
||||
&& CommonConstants.TableName.MED_MEDICATION_DEFINITION.equals(inventoryDto.getItemTable())
|
||||
// 如果选择了具体的批次号,校验库存时需要加上批次号的匹配条件
|
||||
&& (StringUtils.isEmpty(medicationRequestUseExe.getLotNumber())
|
||||
|| medicationRequestUseExe.getLotNumber().equals(inventoryDto.getLotNumber())))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
// 匹配到库存信息
|
||||
if (matchedInventory.isPresent()) {
|
||||
AdviceInventoryDto inventoryDto = matchedInventory.get();
|
||||
if ((medicationRequestUseExe.getExecuteTimesNum()
|
||||
.multiply(medicationRequestUseExe.getMinUnitQuantity()))
|
||||
.compareTo(inventoryDto.getQuantity()) > 0) {
|
||||
if (!matchedInventories.isEmpty()) {
|
||||
// 聚合所有批次的可用库存
|
||||
BigDecimal totalQuantity = matchedInventories.stream()
|
||||
.map(dto -> dto.getQuantity() != null ? dto.getQuantity() : BigDecimal.ZERO)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal requestQuantity = medicationRequestUseExe.getExecuteTimesNum()
|
||||
.multiply(medicationRequestUseExe.getMinUnitQuantity());
|
||||
if (requestQuantity.compareTo(totalQuantity) > 0) {
|
||||
tipsList
|
||||
.add("【" + medicationRequestUseExe.getBusNo() + "】在" + inventoryDto.getLocationName() + "库存不足");
|
||||
.add("【" + medicationRequestUseExe.getBusNo() + "】在" + matchedInventories.get(0).getLocationName() + "库存不足");
|
||||
}
|
||||
} else {
|
||||
tipsList.add("【" + medicationRequestUseExe.getBusNo() + "】未匹配到库存信息");
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.core.common.enums.TenantOptionDict;
|
||||
import com.core.common.exception.ServiceException;
|
||||
@@ -177,6 +178,8 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
inpatientAdviceParam.setEncounterIds(null);
|
||||
Integer exeStatus = inpatientAdviceParam.getExeStatus();
|
||||
inpatientAdviceParam.setExeStatus(null);
|
||||
// requestStatus由前端tab控制,后端SQL已通过CASE条件处理校对状态过滤,无需再作为SQL条件
|
||||
inpatientAdviceParam.setRequestStatus(null);
|
||||
// 构建查询条件
|
||||
QueryWrapper<InpatientAdviceParam> queryWrapper
|
||||
= HisQueryUtils.buildQueryWrapper(inpatientAdviceParam, null, null, null);
|
||||
@@ -205,6 +208,8 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
e.setTherapyEnum_enumText(EnumUtils.getInfoByValue(TherapyTimeType.class, e.getTherapyEnum()));
|
||||
// 请求状态
|
||||
e.setRequestStatus_enumText(EnumUtils.getInfoByValue(RequestStatus.class, e.getRequestStatus()));
|
||||
// 发药状态
|
||||
e.setDispenseStatus_enumText(EnumUtils.getInfoByValue(DispenseStatus.class, e.getDispenseStatus()));
|
||||
// 性别枚举
|
||||
e.setGenderEnum_enumText(EnumUtils.getInfoByValue(AdministrativeGender.class, e.getGenderEnum()));
|
||||
// 计算年龄
|
||||
@@ -355,6 +360,17 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
medRequestList.add(item);
|
||||
}
|
||||
}
|
||||
// 校验药品医嘱是否已发药,已发药的医嘱不允许退回
|
||||
if (!medRequestList.isEmpty()) {
|
||||
List<Long> medReqIds = medRequestList.stream().map(PerformInfoDto::getRequestId).toList();
|
||||
List<MedicationDispense> dispenseList = medicationDispenseService.list(
|
||||
new LambdaQueryWrapper<MedicationDispense>()
|
||||
.in(MedicationDispense::getMedReqId, medReqIds)
|
||||
.eq(MedicationDispense::getStatusEnum, DispenseStatus.COMPLETED.getValue()));
|
||||
if (!dispenseList.isEmpty()) {
|
||||
return R.fail("该医嘱已发药,无法退回");
|
||||
}
|
||||
}
|
||||
Long practitionerId = SecurityUtils.getLoginUser().getPractitionerId();
|
||||
Date checkDate = new Date();
|
||||
if (!serviceRequestList.isEmpty()) {
|
||||
@@ -377,6 +393,7 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
* @return 操作结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> adviceExecute(AdviceExecuteParam adviceExecuteParam) {
|
||||
// 实际执行时间
|
||||
Date exeDate = adviceExecuteParam.getExeDate();
|
||||
@@ -804,12 +821,6 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
chargeItemService.saveOrUpdate(chargeItem);
|
||||
} else {
|
||||
// 批次售卖情况
|
||||
// 需要的药品数量(小单位)
|
||||
BigDecimal minUnitQuantity = medicationRequestUseExe.getMinUnitQuantity();
|
||||
if (minUnitQuantity == null || minUnitQuantity.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
throw new RuntimeException("药品执行数量异常,medicationId: "
|
||||
+ finalLongMedicationRequest.getMedicationId());
|
||||
}
|
||||
// 库存集合
|
||||
List<AdviceInventoryDto> inventoryList = advice.getInventoryList();
|
||||
if (inventoryList == null || inventoryList.isEmpty()) {
|
||||
@@ -822,9 +833,23 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
throw new RuntimeException("未找到药品匹配的定价信息: "
|
||||
+ finalLongMedicationRequest.getMedicationId());
|
||||
}
|
||||
// 需要的药品数量(小单位)
|
||||
BigDecimal minUnitQuantity = medicationRequestUseExe.getMinUnitQuantity();
|
||||
if (minUnitQuantity == null || minUnitQuantity.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
throw new RuntimeException("药品执行数量异常,medicationId: "
|
||||
+ finalLongMedicationRequest.getMedicationId());
|
||||
}
|
||||
// 【修复】预先计算总可用库存,确保在写入任何数据前进行校验
|
||||
BigDecimal totalAvailableQuantity = inventoryList.stream()
|
||||
.map(AdviceInventoryDto::getQuantity)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
if (totalAvailableQuantity.compareTo(minUnitQuantity) < 0) {
|
||||
throw new RuntimeException("药品库存不足,medicationId: "
|
||||
+ finalLongMedicationRequest.getMedicationId());
|
||||
}
|
||||
// 剩余需要分配的数量
|
||||
BigDecimal remainingQuantity = minUnitQuantity;
|
||||
|
||||
|
||||
// 按批次循环分配数量
|
||||
for (AdviceInventoryDto inventory : inventoryList) {
|
||||
if (remainingQuantity.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
@@ -927,11 +952,6 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
chargeItem.setTotalPrice(totalPrice); // 总价
|
||||
|
||||
chargeItemService.saveOrUpdate(chargeItem);
|
||||
|
||||
}
|
||||
if (remainingQuantity.compareTo(BigDecimal.ZERO) > 0) {
|
||||
throw new RuntimeException("药品库存不足,medicationId: "
|
||||
+ finalLongMedicationRequest.getMedicationId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,4 +255,8 @@ public class InpatientAdviceDto {
|
||||
|
||||
/** 总价 */
|
||||
private BigDecimal totalPrice;
|
||||
|
||||
/** 发药状态 */
|
||||
private Integer dispenseStatus;
|
||||
private String dispenseStatus_enumText;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ public class NursingRecordController {
|
||||
* 获取住院患者信息 分页显示
|
||||
*
|
||||
* @param nursingSearchParam 查询参数
|
||||
*
|
||||
* @param searchKey 模糊查询
|
||||
* @param pageNo 当前页码
|
||||
* @param pageSize 查询条数
|
||||
|
||||
@@ -17,6 +17,9 @@ import com.openhis.common.constant.PromptMsgConstant;
|
||||
import com.openhis.common.enums.*;
|
||||
import com.openhis.common.utils.EnumUtils;
|
||||
import com.openhis.common.utils.HisQueryUtils;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.openhis.workflow.domain.InventoryItem;
|
||||
import com.openhis.workflow.service.IInventoryItemService;
|
||||
import com.openhis.web.basedatamanage.dto.LocationDto;
|
||||
import com.openhis.web.common.dto.UnitDto;
|
||||
import com.openhis.web.inventorymanage.appservice.IProductTransferAppService;
|
||||
@@ -57,6 +60,9 @@ public class ProductTransferAppServiceImpl implements IProductTransferAppService
|
||||
@Autowired
|
||||
private IPractitionerService practitionerService;
|
||||
|
||||
@Autowired
|
||||
private IInventoryItemService inventoryItemService;
|
||||
|
||||
/**
|
||||
* 商品调拨页面初始化
|
||||
*
|
||||
@@ -196,6 +202,23 @@ public class ProductTransferAppServiceImpl implements IProductTransferAppService
|
||||
@Override
|
||||
public R<?> addOrEditBatchTransferReceipt(List<ProductTransferDto> productTransferDtoList, Boolean flag) {
|
||||
|
||||
// 校验调拨数量:必须 > 0 且不超过源库存数量(从数据库查实时库存)
|
||||
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||
for (ProductTransferDto dto : productTransferDtoList) {
|
||||
if (dto.getItemQuantity() == null || dto.getItemQuantity().compareTo(java.math.BigDecimal.ZERO) <= 0) {
|
||||
return R.fail("调拨数量必须大于0");
|
||||
}
|
||||
// 查询该药品在源仓库的实时库存总量
|
||||
List<InventoryItem> inventoryList = inventoryItemService.selectInventoryByItemId(
|
||||
dto.getItemId(), dto.getLotNumber(), dto.getSourceLocationId(), tenantId);
|
||||
java.math.BigDecimal actualStock = inventoryList.stream()
|
||||
.map(InventoryItem::getQuantity)
|
||||
.reduce(java.math.BigDecimal.ZERO, java.math.BigDecimal::add);
|
||||
if (dto.getItemQuantity().compareTo(actualStock) > 0) {
|
||||
return R.fail("调拨数量不可超出源库存数量(当前库存:" + actualStock + ")");
|
||||
}
|
||||
}
|
||||
|
||||
List<String> idList = new ArrayList<>();
|
||||
if (flag) {
|
||||
// 批量保存按钮
|
||||
@@ -309,6 +332,22 @@ public class ProductTransferAppServiceImpl implements IProductTransferAppService
|
||||
@Override
|
||||
public R<?> addOrEditTransferReceipt(List<ProductTransferDto> productTransferDtoList) {
|
||||
|
||||
// 校验调拨数量:必须 > 0 且不超过源库存数量(从数据库查实时库存)
|
||||
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||
for (ProductTransferDto dto : productTransferDtoList) {
|
||||
if (dto.getItemQuantity() == null || dto.getItemQuantity().compareTo(java.math.BigDecimal.ZERO) <= 0) {
|
||||
return R.fail("调拨数量必须大于0");
|
||||
}
|
||||
List<InventoryItem> inventoryList = inventoryItemService.selectInventoryByItemId(
|
||||
dto.getItemId(), dto.getLotNumber(), dto.getSourceLocationId(), tenantId);
|
||||
java.math.BigDecimal actualStock = inventoryList.stream()
|
||||
.map(InventoryItem::getQuantity)
|
||||
.reduce(java.math.BigDecimal.ZERO, java.math.BigDecimal::add);
|
||||
if (dto.getItemQuantity().compareTo(actualStock) > 0) {
|
||||
return R.fail("调拨数量不可超出源库存数量(当前库存:" + actualStock + ")");
|
||||
}
|
||||
}
|
||||
|
||||
List<String> idList = new ArrayList<>();
|
||||
|
||||
// 单据号取得
|
||||
@@ -380,6 +419,25 @@ public class ProductTransferAppServiceImpl implements IProductTransferAppService
|
||||
*/
|
||||
@Override
|
||||
public R<?> submitApproval(String busNo) {
|
||||
// 提交前再次校验调拨数量(从数据库查实时库存)
|
||||
List<SupplyRequest> requestList = supplyRequestService.getSupplyByBusNo(busNo);
|
||||
if (requestList != null && !requestList.isEmpty()) {
|
||||
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||
for (SupplyRequest request : requestList) {
|
||||
if (request.getItemQuantity() == null || request.getItemQuantity().compareTo(java.math.BigDecimal.ZERO) <= 0) {
|
||||
return R.fail("调拨数量必须大于0,请检查后重新保存");
|
||||
}
|
||||
// 查询该药品在源仓库的实时库存总量
|
||||
List<InventoryItem> inventoryList = inventoryItemService.selectInventoryByItemId(
|
||||
request.getItemId(), request.getLotNumber(), request.getSourceLocationId(), tenantId);
|
||||
java.math.BigDecimal actualStock = inventoryList.stream()
|
||||
.map(InventoryItem::getQuantity)
|
||||
.reduce(java.math.BigDecimal.ZERO, java.math.BigDecimal::add);
|
||||
if (request.getItemQuantity().compareTo(actualStock) > 0) {
|
||||
return R.fail("调拨数量不可超出源库存数量(当前库存:" + actualStock + "),请检查后重新保存");
|
||||
}
|
||||
}
|
||||
}
|
||||
// 单据提交审核
|
||||
boolean result = supplyRequestService.submitApproval(busNo);
|
||||
return result ? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, null))
|
||||
|
||||
@@ -3,29 +3,38 @@
|
||||
*/
|
||||
package com.openhis.web.inventorymanage.appservice.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.core.common.exception.ServiceException;
|
||||
import com.core.common.utils.*;
|
||||
import com.core.common.utils.bean.BeanUtils;
|
||||
import com.openhis.administration.domain.DeviceDefinition;
|
||||
import com.openhis.administration.domain.Practitioner;
|
||||
import com.openhis.administration.service.IDeviceDefinitionService;
|
||||
import com.openhis.administration.service.IPractitionerService;
|
||||
import com.openhis.common.constant.CommonConstants;
|
||||
import com.openhis.common.constant.PromptMsgConstant;
|
||||
import com.openhis.common.enums.*;
|
||||
import com.openhis.common.utils.EnumUtils;
|
||||
import com.openhis.common.utils.HisQueryUtils;
|
||||
import com.openhis.medication.domain.MedicationDefinition;
|
||||
import com.openhis.medication.service.IMedicationDefinitionService;
|
||||
import com.openhis.web.common.dto.UnitDto;
|
||||
import com.openhis.web.inventorymanage.appservice.IRequisitionIssueAppService;
|
||||
import com.openhis.web.inventorymanage.dto.*;
|
||||
import com.openhis.web.inventorymanage.mapper.RequisitionIssueMapper;
|
||||
import com.openhis.workflow.domain.InventoryItem;
|
||||
import com.openhis.workflow.domain.SupplyRequest;
|
||||
import com.openhis.workflow.service.IInventoryItemService;
|
||||
import com.openhis.workflow.service.ISupplyRequestService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@@ -48,6 +57,15 @@ public class RequisitionIssueAppServiceImpl implements IRequisitionIssueAppServi
|
||||
@Autowired
|
||||
private IPractitionerService practitionerService;
|
||||
|
||||
@Autowired
|
||||
private IInventoryItemService inventoryItemService;
|
||||
|
||||
@Autowired
|
||||
private IMedicationDefinitionService medicationDefinitionService;
|
||||
|
||||
@Autowired
|
||||
private IDeviceDefinitionService deviceDefinitionService;
|
||||
|
||||
@Autowired
|
||||
private AssignSeqUtil assignSeqUtil;
|
||||
|
||||
@@ -167,6 +185,10 @@ public class RequisitionIssueAppServiceImpl implements IRequisitionIssueAppServi
|
||||
|
||||
// 单据号取得
|
||||
List<String> busNoList = requisitionIssueDtoList.stream().map(IssueDto::getBusNo).collect(Collectors.toList());
|
||||
|
||||
// 库存校验:领用数量不能超过源仓库实际库存
|
||||
this.validateRequisitionStock(requisitionIssueDtoList);
|
||||
|
||||
// 请求数据取得
|
||||
List<SupplyRequest> requestList = supplyRequestService.getSupplyByBusNo(busNoList.get(0));
|
||||
if (!requestList.isEmpty()) {
|
||||
@@ -328,4 +350,73 @@ public class RequisitionIssueAppServiceImpl implements IRequisitionIssueAppServi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验领用数量是否超过源仓库实际库存
|
||||
*
|
||||
* @param requisitionIssueDtoList 领用出库单据列表
|
||||
*/
|
||||
private void validateRequisitionStock(List<IssueDto> requisitionIssueDtoList) {
|
||||
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||
for (IssueDto issueDto : requisitionIssueDtoList) {
|
||||
Long itemId = issueDto.getItemId();
|
||||
String lotNumber = issueDto.getLotNumber();
|
||||
Long sourceLocationId = issueDto.getSourceLocationId();
|
||||
BigDecimal reqQuantity = issueDto.getItemQuantity();
|
||||
String itemUnit = issueDto.getUnitCode();
|
||||
String itemTable = issueDto.getItemTable();
|
||||
|
||||
// 根据物品类型查询定义信息(拆零比、常规单位、最小单位)
|
||||
BigDecimal partPercent = BigDecimal.ONE;
|
||||
String unitCode = itemUnit;
|
||||
String minUnitCode = itemUnit;
|
||||
|
||||
if (CommonConstants.TableName.MED_MEDICATION_DEFINITION.equals(itemTable)) {
|
||||
MedicationDefinition medDef = medicationDefinitionService.getById(itemId);
|
||||
if (medDef != null) {
|
||||
unitCode = medDef.getUnitCode();
|
||||
minUnitCode = medDef.getMinUnitCode();
|
||||
if (medDef.getPartPercent() != null) {
|
||||
partPercent = medDef.getPartPercent();
|
||||
}
|
||||
}
|
||||
} else if (CommonConstants.TableName.ADM_DEVICE_DEFINITION.equals(itemTable)) {
|
||||
DeviceDefinition devDef = deviceDefinitionService.getById(itemId);
|
||||
if (devDef != null) {
|
||||
unitCode = devDef.getUnitCode();
|
||||
minUnitCode = devDef.getMinUnitCode();
|
||||
if (devDef.getPartPercent() != null) {
|
||||
partPercent = devDef.getPartPercent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 计算领用数量折合最小单位的值
|
||||
BigDecimal reqQuantityInMinUnit;
|
||||
if (itemUnit.equals(unitCode)) {
|
||||
// 领用单位 = 包装单位,需乘以拆零比
|
||||
reqQuantityInMinUnit = reqQuantity.multiply(partPercent);
|
||||
} else {
|
||||
// 领用单位 = 最小单位,无需换算
|
||||
reqQuantityInMinUnit = reqQuantity;
|
||||
}
|
||||
|
||||
// 查询源仓库实际库存(按物品编号、批号、仓库匹配)
|
||||
List<InventoryItem> inventoryItemList = inventoryItemService.selectInventoryByItemId(
|
||||
itemId, lotNumber, sourceLocationId, tenantId);
|
||||
|
||||
// 累加匹配批号的总库存(库存表quantity字段为最小单位)
|
||||
BigDecimal totalStock = BigDecimal.ZERO;
|
||||
for (InventoryItem inventoryItem : inventoryItemList) {
|
||||
if (inventoryItem.getLocationId().equals(sourceLocationId)) {
|
||||
totalStock = totalStock.add(inventoryItem.getQuantity());
|
||||
}
|
||||
}
|
||||
|
||||
// 比较领用数量与库存
|
||||
if (reqQuantityInMinUnit.compareTo(totalStock) > 0) {
|
||||
throw new ServiceException("操作失败,库存数量不足");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1991,7 +1991,7 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
|
||||
Order appointmentOrder = iOrderService.getOne(
|
||||
new LambdaQueryWrapper<Order>()
|
||||
.eq(Order::getPatientId, encounterFormData.getPatientId())
|
||||
.eq(Order::getStatus, CommonConstants.AppointmentOrderStatus.CHECKED_IN)
|
||||
.eq(Order::getStatus, OrderStatus.ACTIVE.getValue()) // 有效订单(1)
|
||||
.eq(Order::getDeleteFlag, "0")
|
||||
.orderByDesc(Order::getCreateTime)
|
||||
.last("LIMIT 1")
|
||||
@@ -2114,11 +2114,11 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
|
||||
Long queuePoolId = null;
|
||||
Long queueSlotId = null;
|
||||
try {
|
||||
// 查询患者当天的待签到预约订单(status = 1 或 2 表示已预约或已取号)
|
||||
// 查询患者当天有效订单(1);已取消(0/2)和已完成(3)的不参与排队
|
||||
Order order = iOrderService.getOne(
|
||||
new LambdaQueryWrapper<Order>()
|
||||
.eq(Order::getPatientId, encounter.getPatientId())
|
||||
.in(Order::getStatus, 1, 2) // 1=BOOKED 已预约, 2=CHECKED_IN 已取号
|
||||
.eq(Order::getStatus, OrderStatus.ACTIVE.getValue()) // 有效(1)
|
||||
.eq(Order::getDeleteFlag, "0")
|
||||
.orderByDesc(Order::getCreateTime)
|
||||
.last("LIMIT 1")
|
||||
|
||||
@@ -39,10 +39,22 @@ public interface IRequestFormManageAppService {
|
||||
* @param typeCode 申请单类型
|
||||
* @param startDate 开始日期(可选,格式:yyyy-MM-dd)
|
||||
* @param endDate 结束日期(可选,格式:yyyy-MM-dd)
|
||||
* @param status 单据状态(可选)
|
||||
* @return 申请单列表
|
||||
*/
|
||||
List<RequestFormQueryDto> getRequestForm(Long encounterId, String typeCode, String startDate, String endDate, String status);
|
||||
List<RequestFormQueryDto> getRequestForm(Long encounterId, String typeCode, String startDate, String endDate);
|
||||
|
||||
/**
|
||||
* 查询申请单(支持筛选+状态+关键字)
|
||||
*
|
||||
* @param encounterId 就诊id
|
||||
* @param typeCode 申请单类型
|
||||
* @param startDate 开始日期(可选,格式:yyyy-MM-dd)
|
||||
* @param endDate 结束日期(可选,格式:yyyy-MM-dd)
|
||||
* @param status 单据状态(可选)
|
||||
* @param keyword 关键字(可选,申请单号/项目名称模糊匹配)
|
||||
* @return 申请单列表
|
||||
*/
|
||||
List<RequestFormQueryDto> getRequestForm(Long encounterId, String typeCode, String startDate, String endDate, String status, String keyword);
|
||||
|
||||
/**
|
||||
* 分页查询申请单
|
||||
@@ -51,4 +63,20 @@ public interface IRequestFormManageAppService {
|
||||
* @return 申请单
|
||||
*/
|
||||
IPage<RequestFormPageDto> getRequestFormPage(RequestFormDto requestFormDto);
|
||||
|
||||
/**
|
||||
* 删除申请单(仅待签发状态可删除)
|
||||
*
|
||||
* @param requestFormId 申请单ID
|
||||
* @return 结果
|
||||
*/
|
||||
R<?> deleteRequestForm(Long requestFormId);
|
||||
|
||||
/**
|
||||
* 撤回申请单(已签发状态撤回至待签发)
|
||||
*
|
||||
* @param requestFormId 申请单ID
|
||||
* @return 结果
|
||||
*/
|
||||
R<?> withdrawRequestForm(Long requestFormId);
|
||||
}
|
||||
|
||||
@@ -341,6 +341,28 @@ public class AdviceManageAppServiceImpl implements IAdviceManageAppService {
|
||||
&& (DbOpType.INSERT.getCode().equals(e.getDbOpType()) || DbOpType.UPDATE.getCode().equals(e.getDbOpType())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 防重复保存:对所有医嘱进行去重(包括 INSERT 和 UPDATE 混合场景),避免签发单条医嘱时产生重复记录
|
||||
Set<String> longUniqueKeySet = new HashSet<>();
|
||||
List<RegAdviceSaveDto> longUniqueList = new ArrayList<>();
|
||||
for (RegAdviceSaveDto adviceSaveDto : longInsertOrUpdateList) {
|
||||
String uniqueKey = adviceSaveDto.getPatientId() + "_"
|
||||
+ adviceSaveDto.getEncounterId() + "_"
|
||||
+ adviceSaveDto.getAdviceDefinitionId() + "_"
|
||||
+ adviceSaveDto.getDose() + "_"
|
||||
+ adviceSaveDto.getMethodCode() + "_"
|
||||
+ adviceSaveDto.getRateCode();
|
||||
if (longUniqueKeySet.contains(uniqueKey)) {
|
||||
log.warn("防重复保存:检测到重复长期医嘱(跨操作类型),跳过 - patientId={}, encounterId={}, adviceDefinitionId={}, dbOpType={}",
|
||||
adviceSaveDto.getPatientId(), adviceSaveDto.getEncounterId(),
|
||||
adviceSaveDto.getAdviceDefinitionId(), adviceSaveDto.getDbOpType());
|
||||
continue;
|
||||
}
|
||||
longUniqueKeySet.add(uniqueKey);
|
||||
longUniqueList.add(adviceSaveDto);
|
||||
}
|
||||
log.info("防重复保存(长期):去重前{}条,去重后{}条", longInsertOrUpdateList.size(), longUniqueList.size());
|
||||
longInsertOrUpdateList = longUniqueList;
|
||||
|
||||
for (RegAdviceSaveDto regAdviceSaveDto : longInsertOrUpdateList) {
|
||||
boolean firstTimeSave = false;// 第一次保存
|
||||
longMedicationRequest = new MedicationRequest();
|
||||
@@ -406,6 +428,29 @@ public class AdviceManageAppServiceImpl implements IAdviceManageAppService {
|
||||
.getValue().equals(e.getTherapyEnum())
|
||||
&& (DbOpType.INSERT.getCode().equals(e.getDbOpType()) || DbOpType.UPDATE.getCode().equals(e.getDbOpType())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 防重复保存:对所有医嘱进行去重(包括 INSERT 和 UPDATE 混合场景),避免签发时产生重复记录
|
||||
Set<String> tempUniqueKeySet = new HashSet<>();
|
||||
List<RegAdviceSaveDto> tempUniqueList = new ArrayList<>();
|
||||
for (RegAdviceSaveDto adviceSaveDto : tempInsertOrUpdateList) {
|
||||
String uniqueKey = adviceSaveDto.getPatientId() + "_"
|
||||
+ adviceSaveDto.getEncounterId() + "_"
|
||||
+ adviceSaveDto.getAdviceDefinitionId() + "_"
|
||||
+ adviceSaveDto.getDose() + "_"
|
||||
+ adviceSaveDto.getMethodCode() + "_"
|
||||
+ adviceSaveDto.getRateCode();
|
||||
if (tempUniqueKeySet.contains(uniqueKey)) {
|
||||
log.warn("防重复保存:检测到重复临时医嘱(跨操作类型),跳过 - patientId={}, encounterId={}, adviceDefinitionId={}, dbOpType={}",
|
||||
adviceSaveDto.getPatientId(), adviceSaveDto.getEncounterId(),
|
||||
adviceSaveDto.getAdviceDefinitionId(), adviceSaveDto.getDbOpType());
|
||||
continue;
|
||||
}
|
||||
tempUniqueKeySet.add(uniqueKey);
|
||||
tempUniqueList.add(adviceSaveDto);
|
||||
}
|
||||
log.info("防重复保存(临时):去重前{}条,去重后{}条", tempInsertOrUpdateList.size(), tempUniqueList.size());
|
||||
tempInsertOrUpdateList = tempUniqueList;
|
||||
|
||||
for (RegAdviceSaveDto regAdviceSaveDto : tempInsertOrUpdateList) {
|
||||
boolean firstTimeSave = false;// 第一次保存
|
||||
tempMedicationRequest = new MedicationRequest();
|
||||
@@ -511,6 +556,9 @@ public class AdviceManageAppServiceImpl implements IAdviceManageAppService {
|
||||
// 签发操作
|
||||
boolean is_sign = AdviceOpType.SIGN_ADVICE.getCode().equals(adviceOpType);
|
||||
|
||||
// 收集已处理的requestId,用于批量更新状态
|
||||
List<Long> processedRequestIds = new ArrayList<>();
|
||||
|
||||
// 声明长期医嘱诊疗请求
|
||||
ServiceRequest longServiceRequest;
|
||||
// 新增 + 修改 (长期医嘱)
|
||||
@@ -555,6 +603,9 @@ public class AdviceManageAppServiceImpl implements IAdviceManageAppService {
|
||||
}
|
||||
}
|
||||
iServiceRequestService.saveOrUpdate(longServiceRequest);
|
||||
if (longServiceRequest.getId() != null) {
|
||||
processedRequestIds.add(longServiceRequest.getId());
|
||||
}
|
||||
}
|
||||
|
||||
// 声明临时医嘱诊疗请求
|
||||
@@ -603,6 +654,9 @@ public class AdviceManageAppServiceImpl implements IAdviceManageAppService {
|
||||
}
|
||||
}
|
||||
iServiceRequestService.saveOrUpdate(tempServiceRequest);
|
||||
if (tempServiceRequest.getId() != null) {
|
||||
processedRequestIds.add(tempServiceRequest.getId());
|
||||
}
|
||||
|
||||
// 保存时,保存诊疗费用项
|
||||
if (is_save) {
|
||||
@@ -654,6 +708,24 @@ public class AdviceManageAppServiceImpl implements IAdviceManageAppService {
|
||||
}
|
||||
}
|
||||
|
||||
// 批量更新诊疗医嘱状态(使用 update 确保状态字段必定更新)
|
||||
if (!processedRequestIds.isEmpty()) {
|
||||
// 🔧 Bug #487 修复:签发时额外设置 authoredTime,确保签发时间被记录
|
||||
if (is_sign) {
|
||||
iServiceRequestService.update(null,
|
||||
new LambdaUpdateWrapper<ServiceRequest>()
|
||||
.set(ServiceRequest::getStatusEnum, RequestStatus.ACTIVE.getValue())
|
||||
.set(ServiceRequest::getAuthoredTime, authoredTime)
|
||||
.set(ServiceRequest::getSignCode, signCode)
|
||||
.in(ServiceRequest::getId, processedRequestIds));
|
||||
log.info("签发诊疗医嘱成功,requestIds: {}, signCode: {}", processedRequestIds, signCode);
|
||||
} else {
|
||||
iServiceRequestService.update(null,
|
||||
new LambdaUpdateWrapper<ServiceRequest>()
|
||||
.set(ServiceRequest::getStatusEnum, RequestStatus.DRAFT.getValue())
|
||||
.in(ServiceRequest::getId, processedRequestIds));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -689,6 +761,8 @@ public class AdviceManageAppServiceImpl implements IAdviceManageAppService {
|
||||
if (is_sign) {
|
||||
deviceRequest.setReqAuthoredTime(authoredTime); // 医嘱签发时间
|
||||
}
|
||||
// 保存或签发时都需要设置耗材定义ID(防止 sign 分支 deviceDefId 为空触发 NOT NULL 约束)
|
||||
deviceRequest.setDeviceDefId(regAdviceSaveDto.getAdviceDefinitionId());
|
||||
// 保存时处理的字段属性
|
||||
if (is_save) {
|
||||
deviceRequest.setBusNo(assignSeqUtil.getSeqByDay(AssignSeqEnum.DEVICE_RES_NO.getPrefix(), 4));
|
||||
@@ -726,6 +800,8 @@ public class AdviceManageAppServiceImpl implements IAdviceManageAppService {
|
||||
if (is_sign) {
|
||||
deviceRequest.setReqAuthoredTime(authoredTime); // 医嘱签发时间
|
||||
}
|
||||
// 保存或签发时都需要设置耗材定义ID(防止 sign 分支 deviceDefId 为空触发 NOT NULL 约束)
|
||||
deviceRequest.setDeviceDefId(regAdviceSaveDto.getAdviceDefinitionId());
|
||||
// 保存时处理的字段属性
|
||||
if (is_save) {
|
||||
deviceRequest.setBusNo(assignSeqUtil.getSeqByDay(AssignSeqEnum.DEVICE_RES_NO.getPrefix(), 4));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.openhis.web.regdoctorstation.appservice.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.core.common.core.domain.R;
|
||||
@@ -31,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -75,12 +77,46 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> saveRequestForm(RequestFormSaveDto requestFormSaveDto, String typeCode) {
|
||||
// 申请单ID(前端空字符串可能反序列化为0L,需同时判0)
|
||||
Long requestFormId = requestFormSaveDto.getRequestFormId();
|
||||
boolean isEdit = requestFormId != null && requestFormId != 0L;
|
||||
|
||||
// 诊疗执行科室配置校验(必须在任何数据库操作之前)
|
||||
List<ActivityOrganizationConfigDto> activityOrganizationConfig =
|
||||
requestFormManageAppMapper.getActivityOrganizationConfig(typeCode);
|
||||
if (activityOrganizationConfig.isEmpty()) {
|
||||
throw new ServiceException("请先配置当前时间段的执行科室");
|
||||
}
|
||||
|
||||
// 逐个校验activityList中的项目是否都配置了执行科室,并收集positionId供后续使用
|
||||
// 必须在任何数据库操作之前完成全部校验,避免部分保存后异常导致脏数据
|
||||
// 🔧 Bug #516: 优先使用前端传入的positionId(用户手动选择的发往科室),仅在未选择时使用配置的执行科室
|
||||
List<ActivitySaveDto> activityList = requestFormSaveDto.getActivityList();
|
||||
// 缓存校验结果,避免主循环中重复查询和可能出现的数据不一致
|
||||
java.util.Map<Long, Long> activityIdToPositionIdMap = new java.util.HashMap<>();
|
||||
if (activityList != null && !activityList.isEmpty()) {
|
||||
for (ActivitySaveDto activitySaveDto : activityList) {
|
||||
// 优先使用前端传入的positionId(用户手动选择的科室)
|
||||
Long frontendPositionId = activitySaveDto.getPositionId();
|
||||
if (frontendPositionId != null) {
|
||||
activityIdToPositionIdMap.put(activitySaveDto.getAdviceDefinitionId(), frontendPositionId);
|
||||
continue;
|
||||
}
|
||||
// 前端未传入时,使用配置的执行科室
|
||||
Long configPositionId = activityOrganizationConfig.stream()
|
||||
.filter(dto -> activitySaveDto.getAdviceDefinitionId().equals(dto.getActivityDefinitionId()))
|
||||
.map(ActivityOrganizationConfigDto::getOrganizationId).findFirst().orElse(null);
|
||||
if (configPositionId == null) {
|
||||
throw new ServiceException(activitySaveDto.getAdviceDefinitionName() + "未配置当前时间段的执行科室");
|
||||
}
|
||||
activityIdToPositionIdMap.put(activitySaveDto.getAdviceDefinitionId(), configPositionId);
|
||||
}
|
||||
}
|
||||
|
||||
// 诊疗处方号
|
||||
String prescriptionNo;
|
||||
// 申请单ID
|
||||
Long requestFormId = requestFormSaveDto.getRequestFormId();
|
||||
// 编辑场景
|
||||
if (requestFormId != null) {
|
||||
if (isEdit) {
|
||||
RequestForm requestFormInfo = iRequestFormService.getById(requestFormId);
|
||||
prescriptionNo = requestFormInfo.getPrescriptionNo();
|
||||
// 该申请单存在的待发送医嘱个数
|
||||
@@ -91,8 +127,10 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
||||
return R.fail("无待签发的医嘱,该申请单不可编辑");
|
||||
}
|
||||
} else {
|
||||
// 诊疗处方号
|
||||
prescriptionNo = assignSeqUtil.getSeq(AssignSeqEnum.ACTIVITY_PSYCHOTROPIC_NO.getPrefix(), 8);
|
||||
// 检查申请单号:JC(检查)+ Z(住院标识)+ yyMMdd(日期)+ 5位顺序号
|
||||
String dateStr = new java.text.SimpleDateFormat("yyMMdd").format(new Date());
|
||||
int seq = assignSeqUtil.getSeqNoByDay(AssignSeqEnum.CHECK_APPLY_NO.getPrefix());
|
||||
prescriptionNo = "JCZ" + dateStr + String.format("%05d", seq);
|
||||
}
|
||||
|
||||
// 当前时间
|
||||
@@ -122,7 +160,7 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
||||
iRequestFormService.saveOrUpdate(requestForm);
|
||||
|
||||
// 编辑场景时,先删除掉原有诊疗项目及账单再新增
|
||||
if (requestFormId != null) {
|
||||
if (isEdit) {
|
||||
List<Long> serviceRequestIds = iServiceRequestService
|
||||
.list(new LambdaQueryWrapper<ServiceRequest>().eq(ServiceRequest::getPrescriptionNo, prescriptionNo))
|
||||
.stream().map(ServiceRequest::getId).collect(Collectors.toList());
|
||||
@@ -136,15 +174,7 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
||||
|
||||
ServiceRequest serviceRequest;
|
||||
ChargeItem chargeItem;
|
||||
// 诊疗集合
|
||||
List<ActivitySaveDto> activityList = requestFormSaveDto.getActivityList();
|
||||
log.info("保存申请单,typeCode={}, activityListSize={}, encounterId={}", typeCode, activityList != null ? activityList.size() : 0, encounterId);
|
||||
// 诊疗执行科室配置
|
||||
List<ActivityOrganizationConfigDto> activityOrganizationConfig =
|
||||
requestFormManageAppMapper.getActivityOrganizationConfig(typeCode);
|
||||
if (activityOrganizationConfig.isEmpty()) {
|
||||
throw new ServiceException("请先配置当前时间段的执行科室");
|
||||
}
|
||||
|
||||
for (ActivitySaveDto activitySaveDto : activityList) {
|
||||
serviceRequest = new ServiceRequest();
|
||||
@@ -162,9 +192,7 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
||||
serviceRequest.setEncounterId(encounterId); // 就诊id
|
||||
serviceRequest.setAuthoredTime(curDate); // 请求签发时间
|
||||
|
||||
Long positionId = activityOrganizationConfig.stream()
|
||||
.filter(dto -> activitySaveDto.getAdviceDefinitionId().equals(dto.getActivityDefinitionId()))
|
||||
.map(ActivityOrganizationConfigDto::getOrganizationId).findFirst().orElse(null);
|
||||
Long positionId = activityIdToPositionIdMap.get(activitySaveDto.getAdviceDefinitionId());
|
||||
if (positionId == null) {
|
||||
throw new ServiceException(activitySaveDto.getAdviceDefinitionName() + "未配置当前时间段的执行科室");
|
||||
}
|
||||
@@ -275,7 +303,7 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
||||
surgeryServiceRequest.setTherapyEnum(TherapyTimeType.TEMPORARY.getValue());
|
||||
surgeryServiceRequest.setQuantity(BigDecimal.valueOf(1));
|
||||
surgeryServiceRequest.setUnitCode("次");
|
||||
surgeryServiceRequest.setCategoryEnum(4); // 4-手术
|
||||
surgeryServiceRequest.setCategoryEnum(24); // 24-手术(新值域,避开 adviceType 碰撞)
|
||||
// 优先从 activityList 获取手术 ID
|
||||
if (activityList != null && !activityList.isEmpty()) {
|
||||
Long activityId = activityList.get(0).getAdviceDefinitionId();
|
||||
@@ -414,7 +442,7 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
||||
@Override
|
||||
public List<RequestFormQueryDto> getRequestForm(Long encounterId, String typeCode) {
|
||||
// 调用重载方法,不传筛选参数
|
||||
return getRequestForm(encounterId, typeCode, null, null, null);
|
||||
return getRequestForm(encounterId, typeCode, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -424,17 +452,32 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
||||
* @param typeCode 申请单类型
|
||||
* @param startDate 开始日期(可选,格式:yyyy-MM-dd)
|
||||
* @param endDate 结束日期(可选,格式:yyyy-MM-dd)
|
||||
* @param status 单据状态(可选)
|
||||
* @return 申请单列表
|
||||
*/
|
||||
@Override
|
||||
public List<RequestFormQueryDto> getRequestForm(Long encounterId, String typeCode, String startDate, String endDate, String status) {
|
||||
public List<RequestFormQueryDto> getRequestForm(Long encounterId, String typeCode, String startDate, String endDate) {
|
||||
return getRequestForm(encounterId, typeCode, startDate, endDate, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询申请单(支持筛选+状态+关键字)
|
||||
*
|
||||
* @param encounterId 就诊id
|
||||
* @param typeCode 申请单类型
|
||||
* @param startDate 开始日期(可选,格式:yyyy-MM-dd)
|
||||
* @param endDate 结束日期(可选,格式:yyyy-MM-dd)
|
||||
* @param status 单据状态(可选)
|
||||
* @param keyword 关键字(可选,申请单号/项目名称模糊匹配)
|
||||
* @return 申请单列表
|
||||
*/
|
||||
@Override
|
||||
public List<RequestFormQueryDto> getRequestForm(Long encounterId, String typeCode, String startDate, String endDate, String status, String keyword) {
|
||||
// 检查参数
|
||||
if (encounterId == null) {
|
||||
return new java.util.ArrayList<>(); // 返回空列表而不是查询数据库
|
||||
return new java.util.ArrayList<>();
|
||||
}
|
||||
|
||||
List<RequestFormQueryDto> requestFormList = requestFormManageAppMapper.getRequestForm(encounterId, typeCode, startDate, endDate, status);
|
||||
List<RequestFormQueryDto> requestFormList = requestFormManageAppMapper.getRequestForm(encounterId, typeCode, startDate, endDate, status, keyword);
|
||||
for (RequestFormQueryDto requestFormQueryDto : requestFormList) {
|
||||
// 查询处方详情
|
||||
List<RequestFormDetailQueryDto> requestFormDetail =
|
||||
@@ -456,4 +499,90 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
||||
return requestFormManageAppMapper.getRequestFormPage(requestFormDto, page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> deleteRequestForm(Long requestFormId) {
|
||||
if (requestFormId == null) {
|
||||
return R.fail("申请单ID不能为空");
|
||||
}
|
||||
RequestForm requestForm = iRequestFormService.getById(requestFormId);
|
||||
if (requestForm == null) {
|
||||
return R.fail("申请单不存在");
|
||||
}
|
||||
String prescriptionNo = requestForm.getPrescriptionNo();
|
||||
|
||||
// 查询该申请单下所有 ServiceRequest(含子项)
|
||||
List<ServiceRequest> serviceRequests = iServiceRequestService.list(
|
||||
new LambdaQueryWrapper<ServiceRequest>()
|
||||
.eq(ServiceRequest::getPrescriptionNo, prescriptionNo));
|
||||
if (serviceRequests == null || serviceRequests.isEmpty()) {
|
||||
return R.fail("未找到关联的诊疗医嘱");
|
||||
}
|
||||
|
||||
// 校验:只有待签发(status=0)的申请单可删除
|
||||
boolean allDraft = serviceRequests.stream()
|
||||
.allMatch(sr -> RequestStatus.DRAFT.getValue().equals(sr.getStatusEnum()));
|
||||
if (!allDraft) {
|
||||
return R.fail("只有待签发状态的申请单可删除");
|
||||
}
|
||||
|
||||
List<Long> serviceRequestIds = serviceRequests.stream()
|
||||
.map(ServiceRequest::getId).collect(Collectors.toList());
|
||||
|
||||
// 1. 删除关联的费用项
|
||||
for (Long srId : serviceRequestIds) {
|
||||
iChargeItemService.deleteByServiceTableAndId(
|
||||
CommonConstants.TableName.WOR_SERVICE_REQUEST, srId);
|
||||
}
|
||||
// 2. 删除子项 ServiceRequest(parentId 非空)
|
||||
iServiceRequestService.remove(
|
||||
new LambdaQueryWrapper<ServiceRequest>()
|
||||
.in(ServiceRequest::getId, serviceRequestIds)
|
||||
.isNotNull(ServiceRequest::getParentId));
|
||||
// 3. 删除主项 ServiceRequest
|
||||
iServiceRequestService.removeByIds(serviceRequestIds);
|
||||
// 4. 删除申请单
|
||||
iRequestFormService.removeById(requestFormId);
|
||||
|
||||
log.info("检查申请单删除成功,requestFormId={}, prescriptionNo={}", requestFormId, prescriptionNo);
|
||||
return R.ok("删除成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> withdrawRequestForm(Long requestFormId) {
|
||||
if (requestFormId == null) {
|
||||
return R.fail("申请单ID不能为空");
|
||||
}
|
||||
RequestForm requestForm = iRequestFormService.getById(requestFormId);
|
||||
if (requestForm == null) {
|
||||
return R.fail("申请单不存在");
|
||||
}
|
||||
String prescriptionNo = requestForm.getPrescriptionNo();
|
||||
|
||||
// 查询该申请单下所有 ServiceRequest
|
||||
List<ServiceRequest> serviceRequests = iServiceRequestService.list(
|
||||
new LambdaQueryWrapper<ServiceRequest>()
|
||||
.eq(ServiceRequest::getPrescriptionNo, prescriptionNo));
|
||||
if (serviceRequests == null || serviceRequests.isEmpty()) {
|
||||
return R.fail("未找到关联的诊疗医嘱");
|
||||
}
|
||||
|
||||
// 校验:只有已签发(status=2)的申请单可撤回
|
||||
boolean allActive = serviceRequests.stream()
|
||||
.allMatch(sr -> RequestStatus.ACTIVE.getValue().equals(sr.getStatusEnum()));
|
||||
if (!allActive) {
|
||||
return R.fail("只有已签发状态的申请单可撤回");
|
||||
}
|
||||
|
||||
// 将所有 ServiceRequest 状态改回待签发(DRAFT=0)
|
||||
List<Long> serviceRequestIds = serviceRequests.stream()
|
||||
.map(ServiceRequest::getId).collect(Collectors.toList());
|
||||
iServiceRequestService.update(
|
||||
new ServiceRequest().setStatusEnum(RequestStatus.DRAFT.getValue()),
|
||||
new LambdaUpdateWrapper<ServiceRequest>()
|
||||
.in(ServiceRequest::getId, serviceRequestIds));
|
||||
|
||||
log.info("检查申请单撤回成功,requestFormId={}, prescriptionNo={}", requestFormId, prescriptionNo);
|
||||
return R.ok("撤回成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 申请单管理 controller
|
||||
@@ -81,14 +83,23 @@ public class RequestFormManageController {
|
||||
* 查询检查申请单
|
||||
*
|
||||
* @param encounterId 就诊id
|
||||
* @param startDate 开始日期(可选,格式:yyyy-MM-dd)
|
||||
* @param endDate 结束日期(可选,格式:yyyy-MM-dd)
|
||||
* @param status 单据状态(可选)
|
||||
* @param keyword 关键字(可选,申请单号/检查项目名称模糊匹配)
|
||||
* @return 检查申请单
|
||||
*/
|
||||
@GetMapping(value = "/get-check")
|
||||
public R<?> getCheckRequestForm(@RequestParam(required = false) Long encounterId) {
|
||||
public R<?> getCheckRequestForm(
|
||||
@RequestParam(required = false) Long encounterId,
|
||||
@RequestParam(required = false) String startDate,
|
||||
@RequestParam(required = false) String endDate,
|
||||
@RequestParam(required = false) String status,
|
||||
@RequestParam(required = false) String keyword) {
|
||||
if (encounterId == null) {
|
||||
return R.fail("就诊ID不能为空");
|
||||
}
|
||||
return R.ok(iRequestFormManageAppService.getRequestForm(encounterId, ActivityDefCategory.TEST.getCode()));
|
||||
return R.ok(iRequestFormManageAppService.getRequestForm(encounterId, ActivityDefCategory.TEST.getCode(), startDate, endDate, status, keyword));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,6 +109,7 @@ public class RequestFormManageController {
|
||||
* @param startDate 开始日期(可选,格式:yyyy-MM-dd)
|
||||
* @param endDate 结束日期(可选,格式:yyyy-MM-dd)
|
||||
* @param status 单据状态(可选)
|
||||
* @param keyword 关键字(可选,申请单号/检验项目模糊匹配)
|
||||
* @return 检验申请单
|
||||
*/
|
||||
@GetMapping(value = "/get-inspection")
|
||||
@@ -105,11 +117,12 @@ public class RequestFormManageController {
|
||||
@RequestParam(required = false) Long encounterId,
|
||||
@RequestParam(required = false) String startDate,
|
||||
@RequestParam(required = false) String endDate,
|
||||
@RequestParam(required = false) String status) {
|
||||
@RequestParam(required = false) String status,
|
||||
@RequestParam(required = false) String keyword) {
|
||||
if (encounterId == null) {
|
||||
return R.fail("就诊ID不能为空");
|
||||
}
|
||||
return R.ok(iRequestFormManageAppService.getRequestForm(encounterId, ActivityDefCategory.PROOF.getCode(), startDate, endDate, status));
|
||||
return R.ok(iRequestFormManageAppService.getRequestForm(encounterId, ActivityDefCategory.PROOF.getCode(), startDate, endDate, status, keyword));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,6 +153,32 @@ public class RequestFormManageController {
|
||||
return R.ok(iRequestFormManageAppService.getRequestForm(encounterId, ActivityDefCategory.PROCEDURE.getCode()));
|
||||
}
|
||||
/**
|
||||
* 分页查询手术申请单(全局,不需要encounterId,用于门诊手术安排查找弹窗)
|
||||
*
|
||||
* @param surgeryNo 手术单号(模糊查询,可选)
|
||||
* @param applyTimeStart 申请时间起始(可选)
|
||||
* @param applyTimeEnd 申请时间截止(可选)
|
||||
* @param mainDoctorId 主刀医生ID(可选)
|
||||
* @param applyDeptId 申请科室ID(可选)
|
||||
* @param pageNo 页码,默认1
|
||||
* @param pageSize 每页数量,默认10
|
||||
* @return 分页手术申请单列表
|
||||
*/
|
||||
@GetMapping(value = "/get-surgery-page")
|
||||
public R<IPage<RequestFormPageDto>> getSurgeryRequestFormPage(
|
||||
@RequestParam(required = false) String surgeryNo,
|
||||
@RequestParam(required = false) LocalDate applyTimeStart,
|
||||
@RequestParam(required = false) LocalDate applyTimeEnd,
|
||||
@RequestParam(required = false) Long mainDoctorId,
|
||||
@RequestParam(required = false) Long applyDeptId,
|
||||
@RequestParam(defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
RequestFormDto dto = new RequestFormDto(surgeryNo, ActivityDefCategory.PROCEDURE.getCode(), applyTimeStart, applyTimeEnd,
|
||||
mainDoctorId, applyDeptId, pageNo, pageSize);
|
||||
return R.ok(iRequestFormManageAppService.getRequestFormPage(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询申请单
|
||||
* @return 申请单
|
||||
*/
|
||||
@@ -147,4 +186,26 @@ public class RequestFormManageController {
|
||||
public R<IPage<RequestFormPageDto>> getRequestFormPage(@RequestBody RequestFormDto requestFormDto) {
|
||||
return R.ok(iRequestFormManageAppService.getRequestFormPage(requestFormDto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除申请单(仅待签发状态可删除)
|
||||
*
|
||||
* @param data 包含 requestFormId 的请求体
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping(value = "/delete")
|
||||
public R<?> deleteRequestForm(@RequestBody Map<String, Long> data) {
|
||||
return iRequestFormManageAppService.deleteRequestForm(data.get("requestFormId"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤回申请单(已签发状态撤回至待签发)
|
||||
*
|
||||
* @param data 包含 requestFormId 的请求体
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping(value = "/withdraw")
|
||||
public R<?> withdrawRequestForm(@RequestBody Map<String, Long> data) {
|
||||
return iRequestFormManageAppService.withdrawRequestForm(data.get("requestFormId"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@ public class RequestFormDto {
|
||||
* 手术单号
|
||||
*/
|
||||
private String surgeryNo;
|
||||
/**
|
||||
* 申请单类型编码
|
||||
*/
|
||||
private String typeCode;
|
||||
/**
|
||||
* 申请时间开始
|
||||
*/
|
||||
|
||||
@@ -61,6 +61,11 @@ public class RequestFormQueryDto {
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 单据状态 0=待签发 1=已签发 2=已校对 3=待接收 4=已接收 5=已检查 6=已出报告 7=已作废
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 申请单详情
|
||||
*/
|
||||
|
||||
@@ -37,13 +37,15 @@ public interface RequestFormManageAppMapper {
|
||||
* @param startDate 开始日期(可选,格式:yyyy-MM-dd)
|
||||
* @param endDate 结束日期(可选,格式:yyyy-MM-dd)
|
||||
* @param status 单据状态(可选)
|
||||
* @param keyword 关键字(可选,申请单号/检查项目名称模糊匹配)
|
||||
* @return 申请单列表
|
||||
*/
|
||||
List<RequestFormQueryDto> getRequestForm(@Param("encounterId") Long encounterId,
|
||||
@Param("typeCode") String typeCode,
|
||||
@Param("startDate") String startDate,
|
||||
@Param("endDate") String endDate,
|
||||
@Param("status") String status);
|
||||
@Param("status") String status,
|
||||
@Param("keyword") String keyword);
|
||||
|
||||
/**
|
||||
* 查询申请单详情
|
||||
|
||||
@@ -138,4 +138,12 @@ public class CurrentDayEncounterTencentDto {
|
||||
*/
|
||||
private String englishName;
|
||||
|
||||
/** 号源池ID(用于分诊队列 div_log 审计日志) */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long poolId;
|
||||
|
||||
/** 号源槽位ID(用于分诊队列 div_log 审计日志) */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long slotId;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ spring:
|
||||
druid:
|
||||
# 主库数据源
|
||||
master:
|
||||
url: jdbc:postgresql://192.168.110.252:15432/postgresql?currentSchema=histest&characterEncoding=UTF-8&client_encoding=UTF-8
|
||||
url: jdbc:postgresql://192.168.110.252:15432/postgresql?currentSchema=histest1&characterEncoding=UTF-8&client_encoding=UTF-8
|
||||
username: postgresql
|
||||
password: Jchl1528
|
||||
# 从库数据源
|
||||
|
||||
@@ -96,13 +96,25 @@
|
||||
T8.contract_name,
|
||||
CASE
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN T9.surgery_name
|
||||
WHEN T1.context_enum = 6 AND T1.product_table = 'cli_surgery' THEN T9.surgery_name
|
||||
WHEN T1.context_enum = 6 AND T1.service_table = 'wor_service_request' THEN COALESCE(
|
||||
wsr.content_json::json->>'surgeryName',
|
||||
wsr.content_json::json->>'adviceName',
|
||||
T9sr.surgery_name)
|
||||
WHEN T1.context_enum = 6 AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN COALESCE(wsr.content_json::json->>'adviceName', T2."name")
|
||||
WHEN T1.context_enum = 6 THEN T2."name"
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN COALESCE(wsr.content_json::json->>'adviceName', T2."name")
|
||||
WHEN T1.context_enum = #{activity} THEN T2."name"
|
||||
WHEN T1.context_enum = #{activity} AND T1.service_table = 'wor_service_request' THEN COALESCE(T9.surgery_name, wsr.content_json::json->>'surgeryName', wsr.content_json::json->>'adviceName', T2."name")
|
||||
WHEN T1.context_enum = #{activity} THEN COALESCE(wsr.content_json::json->>'surgeryName', wsr.content_json::json->>'adviceName', T2."name")
|
||||
WHEN T1.context_enum = #{medication} THEN T3."name"
|
||||
WHEN T1.context_enum = #{device} THEN T4."name"
|
||||
END AS item_name,
|
||||
CASE
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN NULL
|
||||
WHEN T1.context_enum = 6 AND T1.product_table = 'cli_surgery' THEN NULL
|
||||
WHEN T1.context_enum = 6 AND T1.service_table = 'wor_service_request' THEN NULL
|
||||
WHEN T1.context_enum = 6 AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN NULL
|
||||
WHEN T1.context_enum = 6 THEN T2.yb_no
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN NULL
|
||||
WHEN T1.context_enum = #{activity} THEN T2.yb_no
|
||||
WHEN T1.context_enum = #{medication} THEN T3.yb_no
|
||||
@@ -110,6 +122,10 @@
|
||||
END AS yb_no,
|
||||
CASE
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN T9.id
|
||||
WHEN T1.context_enum = 6 AND T1.product_table = 'cli_surgery' THEN T9.id
|
||||
WHEN T1.context_enum = 6 AND T1.service_table = 'wor_service_request' THEN COALESCE(T9sr.id, wsr.activity_id)
|
||||
WHEN T1.context_enum = 6 AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN 0
|
||||
WHEN T1.context_enum = 6 THEN T2.id
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN 0
|
||||
WHEN T1.context_enum = #{activity} THEN T2.id
|
||||
WHEN T1.context_enum = #{medication} THEN T3.id
|
||||
@@ -149,6 +165,11 @@
|
||||
LEFT JOIN med_medication_request AS mmr ON mmr.id = T1.service_id AND mmr.delete_flag = '0'
|
||||
LEFT JOIN wor_device_request AS wdr ON wdr.id = T1.service_id AND wdr.delete_flag = '0'
|
||||
LEFT JOIN wor_service_request AS wsr ON wsr.id = T1.service_id AND wsr.delete_flag = '0'
|
||||
LEFT JOIN cli_surgery AS T9sr ON T1.context_enum = 6
|
||||
AND T1.service_table = 'wor_service_request'
|
||||
AND wsr.activity_id IS NOT NULL
|
||||
AND wsr.activity_id = T9sr.id
|
||||
AND T9sr.delete_flag = '0'
|
||||
LEFT JOIN wor_service_request AS wsrp ON wsrp.id = wsr.parent_id AND wsrp.delete_flag = '0'
|
||||
WHERE T1.encounter_id = #{encounterId}
|
||||
AND T1.status_enum IN (0
|
||||
@@ -212,13 +233,25 @@
|
||||
T8.contract_name,
|
||||
CASE
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN T9.surgery_name
|
||||
WHEN T1.context_enum = 6 AND T1.product_table = 'cli_surgery' THEN T9.surgery_name
|
||||
WHEN T1.context_enum = 6 AND T1.service_table = 'wor_service_request' THEN COALESCE(
|
||||
wsr.content_json::json->>'surgeryName',
|
||||
wsr.content_json::json->>'adviceName',
|
||||
T9sr.surgery_name)
|
||||
WHEN T1.context_enum = 6 AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN COALESCE(wsr.content_json::json->>'adviceName', T2."name")
|
||||
WHEN T1.context_enum = 6 THEN T2."name"
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN COALESCE(wsr.content_json::json->>'adviceName', T2."name")
|
||||
WHEN T1.context_enum = #{activity} THEN T2."name"
|
||||
WHEN T1.context_enum = #{activity} AND T1.service_table = 'wor_service_request' THEN COALESCE(T9.surgery_name, wsr.content_json::json->>'surgeryName', wsr.content_json::json->>'adviceName', T2."name")
|
||||
WHEN T1.context_enum = #{activity} THEN COALESCE(wsr.content_json::json->>'surgeryName', wsr.content_json::json->>'adviceName', T2."name")
|
||||
WHEN T1.context_enum = #{medication} THEN T3."name"
|
||||
WHEN T1.context_enum = #{device} THEN T4."name"
|
||||
END AS item_name,
|
||||
CASE
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN NULL
|
||||
WHEN T1.context_enum = 6 AND T1.product_table = 'cli_surgery' THEN NULL
|
||||
WHEN T1.context_enum = 6 AND T1.service_table = 'wor_service_request' THEN NULL
|
||||
WHEN T1.context_enum = 6 AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN NULL
|
||||
WHEN T1.context_enum = 6 THEN T2.yb_no
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN NULL
|
||||
WHEN T1.context_enum = #{activity} THEN T2.yb_no
|
||||
WHEN T1.context_enum = #{medication} THEN T3.yb_no
|
||||
@@ -226,6 +259,10 @@
|
||||
END AS yb_no,
|
||||
CASE
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN T9.id
|
||||
WHEN T1.context_enum = 6 AND T1.product_table = 'cli_surgery' THEN T9.id
|
||||
WHEN T1.context_enum = 6 AND T1.service_table = 'wor_service_request' THEN COALESCE(T9sr.id, wsr.activity_id)
|
||||
WHEN T1.context_enum = 6 AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN 0
|
||||
WHEN T1.context_enum = 6 THEN T2.id
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN 0
|
||||
WHEN T1.context_enum = #{activity} THEN T2.id
|
||||
WHEN T1.context_enum = #{medication} THEN T3.id
|
||||
@@ -266,6 +303,11 @@
|
||||
LEFT JOIN med_medication_request AS mmr ON mmr.id = T1.service_id AND mmr.delete_flag = '0'
|
||||
LEFT JOIN wor_device_request AS wdr ON wdr.id = T1.service_id AND wdr.delete_flag = '0'
|
||||
LEFT JOIN wor_service_request AS wsr ON wsr.id = T1.service_id AND wsr.delete_flag = '0'
|
||||
LEFT JOIN cli_surgery AS T9sr ON T1.context_enum = 6
|
||||
AND T1.service_table = 'wor_service_request'
|
||||
AND wsr.activity_id IS NOT NULL
|
||||
AND wsr.activity_id = T9sr.id
|
||||
AND T9sr.delete_flag = '0'
|
||||
WHERE T1.encounter_id = #{encounterId}
|
||||
AND T1.status_enum IN (0
|
||||
, #{planned}
|
||||
|
||||
@@ -331,12 +331,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
) t
|
||||
WHERE rn = 1
|
||||
) pi ON s.patient_id = pi.patient_id
|
||||
<!-- 排除已生成医嘱的手术 -->
|
||||
<!-- 关联服务请求表(仅用于数据关联,不再过滤) -->
|
||||
LEFT JOIN wor_service_request sr ON sr.activity_id = s.id AND sr.delete_flag = '0' AND sr.category_enum = 4
|
||||
<where>
|
||||
s.delete_flag = '0'
|
||||
<!-- 只显示未生成医嘱的手术 -->
|
||||
AND sr.id IS NULL
|
||||
<if test="ew.sqlSegment != null and ew.sqlSegment != ''">
|
||||
<!-- 补充 encounter_id 替换,修复多表关联时字段歧义。注释不能放进 OGNL 表达式内部。 -->
|
||||
<![CDATA[
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
</if>
|
||||
AND os.delete_flag = '0'
|
||||
</where>
|
||||
ORDER BY os.create_time DESC
|
||||
ORDER BY os.create_time DESC, os.schedule_id DESC
|
||||
</select>
|
||||
<!-- 根据ID查询手术安排详情-->
|
||||
<select id="getSurgeryScheduleDetail" resultType="com.openhis.web.clinicalmanage.dto.OpScheduleDto">
|
||||
@@ -89,6 +89,9 @@
|
||||
cs.apply_doctor_name AS apply_doctor_name,
|
||||
drf.create_time AS apply_time,
|
||||
os.surgery_nature AS surgeryType,
|
||||
cs.incision_level AS incisionLevel,
|
||||
fc.contract_name AS feeType,
|
||||
os.fee_type AS feeType,
|
||||
COALESCE(pi.identifier_no, ap.bus_no, '') AS identifierNo
|
||||
FROM op_schedule os
|
||||
LEFT JOIN adm_patient ap ON os.patient_id = ap.id
|
||||
@@ -182,7 +185,7 @@
|
||||
<if test="dto.applyDeptId != null and dto.applyDeptId != ''"> AND cs.apply_dept_id = #{dto.applyDeptId}</if>
|
||||
<if test="dto.patientName != null and dto.patientName != ''"> AND ap.name LIKE CONCAT('%', #{dto.patientName}, '%')</if>
|
||||
</where>
|
||||
ORDER BY os.create_time DESC
|
||||
ORDER BY os.create_time DESC, os.schedule_id DESC
|
||||
</select>
|
||||
<!-- 查询时间段内该手术室是否被占用-->
|
||||
<select id="isScheduleConflict" resultType="java.lang.Boolean">
|
||||
|
||||
@@ -98,9 +98,6 @@
|
||||
INNER JOIN adm_organization_location AS T6 ON T6.distribution_category_code = t1.category_code AND T6.delete_flag = '0' AND T6.item_code = '1' AND T6.organization_id = #{organizationId} AND (CURRENT_TIME :: time (6) BETWEEN T6.start_time AND T6.end_time)
|
||||
WHERE t1.delete_flag = '0'
|
||||
AND T2.status_enum = #{statusEnum}
|
||||
<if test="pricingFlag == 1">
|
||||
AND 1 = 2
|
||||
</if>
|
||||
<if test="categoryCode != null and categoryCode != ''">
|
||||
<!-- 🔧 BugFix: 支持两种匹配方式 -->
|
||||
<!-- 1. 直接匹配:distribution_category_code = category_code(都是数字代码) -->
|
||||
@@ -242,7 +239,7 @@
|
||||
NULL AS activity_type_dictText,
|
||||
-- 前端"包装单位"列:显示使用单位(permitted_unit_code)
|
||||
T1.permitted_unit_code AS unit_code,
|
||||
'' AS min_unit_code,
|
||||
T1.permitted_unit_code AS min_unit_code,
|
||||
'' AS volume,
|
||||
'' AS method_code,
|
||||
'' AS rate_code,
|
||||
@@ -530,6 +527,9 @@
|
||||
LEFT JOIN cli_condition AS cc ON cc.id = T1.condition_id AND cc.delete_flag = '0'
|
||||
LEFT JOIN cli_condition_definition AS ccd ON ccd.id = cc.definition_id
|
||||
WHERE T1.delete_flag = '0' AND T1.tcm_flag = 0
|
||||
<if test="generateSourceEnum != null">
|
||||
AND T1.generate_source_enum = #{generateSourceEnum}
|
||||
</if>
|
||||
<if test="historyFlag == '0'.toString()">
|
||||
AND T1.encounter_id = #{encounterId}
|
||||
</if>
|
||||
@@ -539,14 +539,15 @@
|
||||
AND T1.refund_medicine_id IS NULL
|
||||
ORDER BY T1.status_enum,T1.sort_number)
|
||||
UNION ALL
|
||||
-- 🔧 新增:查询门诊术中计费生成的耗材数据(这些数据存在于 adm_charge_item 和 wor_device_request)
|
||||
-- 🔧 查询仅存在于 adm_charge_item 的"孤儿"耗材数据(DeviceRequest 缺失或 generate_source_enum 未设置)
|
||||
-- 正常 DeviceRequest(generate_source_enum 已赋值)由下方 Part 3 统一负责,此处不做重复覆盖避免 UNION ALL 重复行
|
||||
(SELECT 2 AS advice_type,
|
||||
CI.service_id AS request_id,
|
||||
CI.service_id || '-ci-dev' AS unique_key,
|
||||
'' AS prescription_no,
|
||||
CI.enterer_id AS requester_id,
|
||||
COALESCE(DR.requester_id, CI.enterer_id) AS requester_id,
|
||||
CI.entered_date AS request_time,
|
||||
CASE WHEN CI.enterer_id = #{practitionerId} THEN '1' ELSE '0' END AS biz_request_flag,
|
||||
CASE WHEN COALESCE(DR.requester_id, CI.enterer_id) = #{practitionerId} THEN '1' ELSE '0' END AS biz_request_flag,
|
||||
DR.content_json AS content_json,
|
||||
NULL AS skin_test_flag,
|
||||
NULL AS inject_flag,
|
||||
@@ -583,6 +584,9 @@
|
||||
LEFT JOIN adm_location AS AL ON AL.id = DR.perform_location AND AL.delete_flag = '0'
|
||||
WHERE CI.delete_flag = '0'
|
||||
AND CI.service_table = 'wor_device_request'
|
||||
<if test="generateSourceEnum != null">
|
||||
AND DR.generate_source_enum IS NULL <!-- 仅匹配孤儿记录,normal DeviceRequest 由 Part 3 负责,避免 UNION ALL 重复 -->
|
||||
</if>
|
||||
<if test="historyFlag == '0'.toString()">
|
||||
AND CI.encounter_id = #{encounterId}
|
||||
</if>
|
||||
@@ -647,7 +651,7 @@
|
||||
AND T1.refund_device_id IS NULL
|
||||
ORDER BY T1.status_enum)
|
||||
UNION ALL
|
||||
(SELECT CASE WHEN T1.category_enum = 4 THEN 6 ELSE COALESCE(T1.category_enum, 3) END AS advice_type,
|
||||
(SELECT CASE WHEN T1.category_enum = 4 THEN 6 ELSE 3 END AS advice_type,
|
||||
T1.id AS request_id,
|
||||
T1.id || '-3' AS unique_key,
|
||||
'' AS prescription_no,
|
||||
@@ -698,6 +702,9 @@
|
||||
-- based_on_table='med_medication_request' → 输液/皮试执行记录,应排除
|
||||
-- based_on_table='exam_apply'/'lab_apply' → 申请单原始医嘱,应保留
|
||||
AND (T1.based_on_id IS NULL OR T1.based_on_table IS NULL OR T1.based_on_table NOT IN ('med_medication_request', 'med_medication_dispense'))
|
||||
<if test="sourceBillNo != null and sourceBillNo != ''">
|
||||
AND T1.prescription_no = #{sourceBillNo}
|
||||
</if>
|
||||
<if test="historyFlag == '0'.toString()">
|
||||
AND T1.encounter_id = #{encounterId}
|
||||
</if>
|
||||
|
||||
@@ -133,7 +133,12 @@
|
||||
T2.verification_status_enum,
|
||||
T2.yb_no,
|
||||
T1.onset_date AS onsetDate,
|
||||
T1.diagnosis_time AS diagnosisTime
|
||||
T1.diagnosis_time AS diagnosisTime,
|
||||
T1.doctor AS diagnosisDoctor,
|
||||
CASE WHEN EXISTS (
|
||||
SELECT 1 FROM infectious_card T4
|
||||
WHERE T4.diag_id = T2.id AND T4.delete_flag = '0' AND T4.status >= 1
|
||||
) THEN 1 ELSE 0 END AS hasInfectiousReport
|
||||
FROM adm_encounter_diagnosis AS T1
|
||||
LEFT JOIN cli_condition AS T2 ON T2.ID = T1.condition_id
|
||||
AND T2.delete_flag = '0' AND T2.tcm_flag = 0
|
||||
|
||||
@@ -231,7 +231,7 @@
|
||||
ae.priority_enum,
|
||||
ae.organization_id,
|
||||
ae.start_time AS in_hos_time,
|
||||
bed.start_time,
|
||||
COALESCE(bed.start_time, ae.start_time) AS start_time,
|
||||
bed.location_id AS bed_id,
|
||||
bed.location_name AS bed_name,
|
||||
house.location_id AS house_id,
|
||||
@@ -264,7 +264,6 @@
|
||||
WHERE ael.status_enum = #{active}
|
||||
AND ael.delete_flag = '0'
|
||||
AND ael.form_enum = #{bed}
|
||||
LIMIT 1
|
||||
) AS bed ON bed.encounter_id = ae.id
|
||||
LEFT JOIN (
|
||||
SELECT ael.encounter_id,
|
||||
@@ -275,7 +274,6 @@
|
||||
WHERE ael.status_enum = #{active}
|
||||
AND ael.delete_flag = '0'
|
||||
AND ael.form_enum = #{house}
|
||||
LIMIT 1
|
||||
) AS house ON house.encounter_id = ae.id
|
||||
LEFT JOIN (
|
||||
SELECT ael.encounter_id,
|
||||
@@ -286,7 +284,6 @@
|
||||
WHERE ael.status_enum = #{active}
|
||||
AND ael.delete_flag = '0'
|
||||
AND ael.form_enum = #{ward}
|
||||
LIMIT 1
|
||||
) AS ward ON ward.encounter_id = ae.id
|
||||
LEFT JOIN (
|
||||
SELECT aep.encounter_id,
|
||||
|
||||
@@ -153,8 +153,9 @@
|
||||
ii.balance_amount AS balance_amount,
|
||||
ii.account_id AS account_id,
|
||||
ii.performer_check_id,
|
||||
ii.category_code
|
||||
FROM (( SELECT T1.encounter_id,
|
||||
ii.category_code,
|
||||
ii.dispense_status
|
||||
FROM (( SELECT DISTINCT T1.encounter_id,
|
||||
T1.tenant_id,
|
||||
#{medMedicationRequest} AS advice_table,
|
||||
T1.id AS request_id,
|
||||
@@ -197,7 +198,8 @@
|
||||
pra."name" AS admitting_doctor_name,
|
||||
personal_account.balance_amount,
|
||||
personal_account.id AS account_id,
|
||||
T2.category_code
|
||||
T2.category_code,
|
||||
mmd.status_enum AS dispense_status
|
||||
FROM med_medication_request AS T1
|
||||
LEFT JOIN med_medication_definition AS T2
|
||||
ON T2.id = T1.medication_id
|
||||
@@ -278,6 +280,13 @@
|
||||
aa.balance_amount
|
||||
) AS personal_account
|
||||
ON personal_account.encounter_id = ae.id
|
||||
LEFT JOIN LATERAL (
|
||||
SELECT status_enum
|
||||
FROM med_medication_dispense
|
||||
WHERE med_req_id = T1.id AND delete_flag = '0'
|
||||
ORDER BY create_time DESC
|
||||
LIMIT 1
|
||||
) mmd ON true
|
||||
WHERE T1.delete_flag = '0'
|
||||
AND T1.refund_medicine_id IS NULL
|
||||
AND T1.generate_source_enum = #{doctorPrescription}
|
||||
@@ -288,7 +297,7 @@
|
||||
T1.sort_number,
|
||||
T1.group_id )
|
||||
UNION
|
||||
( SELECT T1.encounter_id,
|
||||
( SELECT DISTINCT T1.encounter_id,
|
||||
T1.tenant_id,
|
||||
#{worServiceRequest} AS advice_table,
|
||||
T1.id AS request_id,
|
||||
@@ -331,7 +340,8 @@
|
||||
pra."name" AS admitting_doctor_name,
|
||||
personal_account.balance_amount,
|
||||
personal_account.id AS account_id,
|
||||
T2.category_code
|
||||
T2.category_code,
|
||||
NULL AS dispense_status
|
||||
FROM wor_service_request AS T1
|
||||
LEFT JOIN wor_activity_definition AS T2
|
||||
ON T2.id = T1.activity_id
|
||||
|
||||
@@ -105,6 +105,8 @@
|
||||
<if test="statusEnum == 4">
|
||||
T4.status_enum = #{completed}
|
||||
</if>
|
||||
AND T4.summary_no IS NOT NULL
|
||||
AND T4.summary_no != ''
|
||||
) AS ii
|
||||
${ew.customSqlSegment}
|
||||
GROUP BY ii.encounter_id,
|
||||
@@ -263,6 +265,8 @@
|
||||
AND T15.delete_flag = '0'
|
||||
WHERE T1.delete_flag = '0'
|
||||
-- 因发药配药合并,前台只能看到待发药,已发药状态,但是后台配药发药状态都查
|
||||
AND T1.summary_no IS NOT NULL
|
||||
AND T1.summary_no != ''
|
||||
AND
|
||||
<if test="dispenseStatus == null">
|
||||
T1.status_enum IN (#{inProgress},#{completed},#{preparation},#{prepared})
|
||||
|
||||
@@ -216,7 +216,8 @@
|
||||
ccd.name AS condition_definition_name,
|
||||
T1.therapy_enum AS therapyEnum,
|
||||
T1.sort_number AS sort_number,
|
||||
T1.based_on_id AS based_on_id
|
||||
T1.based_on_id AS based_on_id,
|
||||
T1.medication_id AS advice_definition_id
|
||||
FROM med_medication_request AS T1
|
||||
LEFT JOIN med_medication_definition AS T2 ON T2.ID = T1.medication_id
|
||||
AND T2.delete_flag = '0'
|
||||
@@ -268,7 +269,8 @@
|
||||
'' AS condition_definition_name,
|
||||
2 AS therapyEnum,
|
||||
99 AS sort_number,
|
||||
T1.based_on_id AS based_on_id
|
||||
T1.based_on_id AS based_on_id,
|
||||
T1.device_def_id AS advice_definition_id
|
||||
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'
|
||||
@@ -286,7 +288,7 @@
|
||||
AND T1.refund_device_id IS NULL
|
||||
ORDER BY T1.status_enum)
|
||||
UNION ALL
|
||||
(SELECT CASE WHEN T1.category_enum = 4 THEN 6 ELSE COALESCE(T1.category_enum, 3) END AS advice_type,
|
||||
(SELECT CASE WHEN T1.category_enum IN (4, 24) THEN 6 ELSE 3 END AS advice_type,
|
||||
T1.id AS request_id,
|
||||
T1.id || '-3' AS unique_key,
|
||||
T1.requester_id AS requester_id,
|
||||
@@ -317,7 +319,8 @@
|
||||
'' AS condition_definition_name,
|
||||
COALESCE(T1.therapy_enum, 2) AS therapyEnum,
|
||||
99 AS sort_number,
|
||||
T1.based_on_id AS based_on_id
|
||||
T1.based_on_id AS based_on_id,
|
||||
T1.activity_id AS advice_definition_id
|
||||
FROM wor_service_request AS T1
|
||||
LEFT JOIN wor_activity_definition AS T2
|
||||
ON T2.ID = T1.activity_id
|
||||
@@ -370,4 +373,4 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
@@ -8,16 +8,34 @@
|
||||
SELECT drf.id AS request_form_id,
|
||||
drf.encounter_id,
|
||||
drf.prescription_no,
|
||||
drf.NAME,
|
||||
COALESCE(
|
||||
(SELECT STRING_AGG(DISTINCT wad.name, '、')
|
||||
FROM wor_service_request wsr2
|
||||
LEFT JOIN wor_activity_definition wad ON wad.id = wsr2.activity_id AND wad.delete_flag = '0'
|
||||
WHERE wsr2.prescription_no = drf.prescription_no AND wsr2.delete_flag = '0'),
|
||||
drf.name
|
||||
) AS name,
|
||||
drf.desc_json,
|
||||
drf.requester_id,
|
||||
drf.create_time,
|
||||
ap.NAME AS patient_name
|
||||
ap.NAME AS patient_name,
|
||||
CASE
|
||||
WHEN MIN(wsr.status_enum) = 1 THEN 0
|
||||
WHEN MIN(wsr.status_enum) = 2 THEN 1
|
||||
WHEN MIN(wsr.status_enum) = 3 AND MAX(CASE WHEN wsr.performer_check_id IS NOT NULL THEN 1 ELSE 0 END) = 1 THEN 2
|
||||
WHEN MIN(wsr.status_enum) = 3 THEN 4
|
||||
WHEN MIN(wsr.status_enum) = 4 THEN 3
|
||||
WHEN MIN(wsr.status_enum) = 5 OR MIN(wsr.status_enum) = 6 OR MIN(wsr.status_enum) = 7 THEN 7
|
||||
WHEN MIN(wsr.status_enum) = 8 THEN 6
|
||||
ELSE NULL
|
||||
END AS status
|
||||
FROM doc_request_form AS drf
|
||||
LEFT JOIN adm_encounter AS ae ON ae.ID = drf.encounter_id
|
||||
AND ae.delete_flag = '0'
|
||||
LEFT JOIN adm_patient AS ap ON ap.ID = ae.patient_id
|
||||
AND ap.delete_flag = '0'
|
||||
LEFT JOIN wor_service_request AS wsr ON wsr.prescription_no = drf.prescription_no
|
||||
AND wsr.delete_flag = '0'
|
||||
WHERE drf.delete_flag = '0'
|
||||
AND drf.encounter_id = #{encounterId}
|
||||
AND drf.type_code = #{typeCode}
|
||||
@@ -28,8 +46,32 @@
|
||||
AND drf.create_time <= (#{endDate}::date + INTERVAL '1 day' - INTERVAL '1 second')
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND drf.status = #{status}::integer
|
||||
AND CASE
|
||||
WHEN MIN(wsr.status_enum) = 1 THEN 0
|
||||
WHEN MIN(wsr.status_enum) = 2 THEN 1
|
||||
WHEN MIN(wsr.status_enum) = 3 AND MAX(CASE WHEN wsr.performer_check_id IS NOT NULL THEN 1 ELSE 0 END) = 1 THEN 2
|
||||
WHEN MIN(wsr.status_enum) = 3 THEN 4
|
||||
WHEN MIN(wsr.status_enum) = 4 THEN 3
|
||||
WHEN MIN(wsr.status_enum) = 5 OR MIN(wsr.status_enum) = 6 OR MIN(wsr.status_enum) = 7 THEN 7
|
||||
WHEN MIN(wsr.status_enum) = 8 THEN 6
|
||||
ELSE NULL
|
||||
END = #{status}::integer
|
||||
</if>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (drf.prescription_no ILIKE '%' || #{keyword} || '%'
|
||||
OR EXISTS (
|
||||
SELECT 1 FROM wor_service_request wsr2
|
||||
WHERE wsr2.prescription_no = drf.prescription_no
|
||||
AND wsr2.delete_flag = '0'
|
||||
AND wsr2.activity_id IN (
|
||||
SELECT id FROM wor_activity_definition wad
|
||||
WHERE wad.delete_flag = '0'
|
||||
AND wad.name ILIKE '%' || #{keyword} || '%'
|
||||
)
|
||||
))
|
||||
</if>
|
||||
GROUP BY drf.id, drf.encounter_id, drf.prescription_no, drf.name, drf.desc_json,
|
||||
drf.requester_id, drf.create_time, ap.name
|
||||
</select>
|
||||
|
||||
<select id="getRequestFormDetail" resultType="com.openhis.web.regdoctorstation.dto.RequestFormDetailQueryDto">
|
||||
@@ -125,6 +167,9 @@
|
||||
<if test="requestFormDto.surgeryNo != null and requestFormDto.surgeryNo != ''">
|
||||
AND drf.prescription_no LIKE CONCAT('%', #{requestFormDto.surgeryNo}, '%')
|
||||
</if>
|
||||
<if test="requestFormDto.typeCode != null and requestFormDto.typeCode != ''">
|
||||
AND drf.type_code IN (#{requestFormDto.typeCode}, 'SURGERY')
|
||||
</if>
|
||||
<if test="requestFormDto.applyTimeStart != null">
|
||||
AND drf.create_time >= #{requestFormDto.applyTimeStart}
|
||||
</if>
|
||||
|
||||
@@ -27,7 +27,9 @@
|
||||
T9.payment_id,
|
||||
T9.picture_url,
|
||||
T9.birth_date,
|
||||
t9.english_name
|
||||
t9.english_name,
|
||||
t9.slot_id,
|
||||
t9.pool_id
|
||||
from (
|
||||
SELECT T1.tenant_id AS tenant_id,
|
||||
T1.id AS encounter_id,
|
||||
@@ -51,7 +53,9 @@
|
||||
T13.id AS payment_id,
|
||||
ai.picture_url AS picture_url,
|
||||
T8.birth_date AS birth_date,
|
||||
tx.staff_english_name AS english_name
|
||||
tx.staff_english_name AS english_name,
|
||||
om_slot.slot_id AS slot_id,
|
||||
om_slot.pool_id AS pool_id
|
||||
FROM adm_encounter AS T1
|
||||
LEFT JOIN adm_organization AS T2 ON T1.organization_id = T2.ID AND T2.delete_flag = '0'
|
||||
LEFT JOIN adm_healthcare_service AS T3 ON T1.service_type_id = T3.ID AND T3.delete_flag = '0'
|
||||
@@ -91,6 +95,8 @@
|
||||
AND T13.status_enum = ${paymentStatus}
|
||||
LEFT JOIN adm_invoice AS ai
|
||||
ON ai.reconciliation_id = T13.id AND ai.delete_flag = '0'
|
||||
LEFT JOIN order_main AS om ON T1.order_id = om.id AND om.delete_flag = '0'
|
||||
LEFT JOIN adm_schedule_slot AS om_slot ON om.slot_id = om_slot.id
|
||||
WHERE T1.delete_flag = '0'
|
||||
AND T1.class_enum = #{classEnum}
|
||||
AND T10.context_enum = #{register}
|
||||
|
||||
@@ -270,6 +270,10 @@ public enum AssignSeqEnum {
|
||||
* 诊疗处方号
|
||||
*/
|
||||
ACTIVITY_PSYCHOTROPIC_NO("62", "诊疗处方号", "PAR"),
|
||||
/**
|
||||
* 检查申请单号(住院)
|
||||
*/
|
||||
CHECK_APPLY_NO("72", "检查申请单号", "JCZ"),
|
||||
/**
|
||||
* b 病历文书
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright ©2023 CJB-CNIT Team. All rights reserved
|
||||
*/
|
||||
package com.openhis.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 订单状态 (order_main.status)
|
||||
*
|
||||
* <pre>
|
||||
* 状态流转:
|
||||
* 创建订单 → ACTIVE(1)
|
||||
* 签到 → ACTIVE(1) 不变
|
||||
* 患者退号 → PATIENT_CANCELLED(0)
|
||||
* 系统取消 → SYSTEM_CANCELLED(2)
|
||||
* 就诊完成 → COMPLETED(3)
|
||||
* </pre>
|
||||
*
|
||||
* @author wangjian963
|
||||
* @date 2026-05-09
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum OrderStatus implements HisEnumInterface {
|
||||
|
||||
/**
|
||||
* 患者取消
|
||||
*/
|
||||
PATIENT_CANCELLED(0, "0", "患者取消"),
|
||||
|
||||
/**
|
||||
* 有效
|
||||
*/
|
||||
ACTIVE(1, "1", "有效"),
|
||||
|
||||
/**
|
||||
* 系统取消
|
||||
*/
|
||||
SYSTEM_CANCELLED(2, "2", "系统取消"),
|
||||
|
||||
/**
|
||||
* 已完成
|
||||
*/
|
||||
COMPLETED(3, "3", "已完成");
|
||||
|
||||
private Integer value;
|
||||
private String code;
|
||||
private String info;
|
||||
|
||||
public static OrderStatus getByValue(Integer value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
for (OrderStatus val : values()) {
|
||||
if (val.getValue().equals(value)) {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,11 @@ public enum RequestStatus implements HisEnumInterface {
|
||||
*/
|
||||
ENDED(7, "ended", "不执行"),
|
||||
|
||||
/**
|
||||
* 已出报告
|
||||
*/
|
||||
COMPLETED_REPORT(8, "completed_report", "已出报告"),
|
||||
|
||||
/**
|
||||
* 未知
|
||||
*/
|
||||
|
||||
@@ -6,8 +6,8 @@ import com.core.common.utils.AssignSeqUtil;
|
||||
import com.openhis.clinical.domain.Order;
|
||||
import com.openhis.clinical.mapper.OrderMapper;
|
||||
import com.openhis.clinical.service.IOrderService;
|
||||
import com.openhis.common.constant.CommonConstants.AppointmentOrderStatus;
|
||||
import com.openhis.common.enums.AssignSeqEnum;
|
||||
import com.openhis.common.enums.OrderStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -124,7 +124,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
: new Date(); // 兜底:正常业务不应走到这里
|
||||
order.setAppointmentDate(appointmentDateTime);
|
||||
order.setAppointmentTime(appointmentDateTime);
|
||||
order.setStatus(AppointmentOrderStatus.BOOKED);
|
||||
// 订单状态: 0=患者取消 1=有效 2=系统取消 3=已完成
|
||||
order.setStatus(OrderStatus.ACTIVE.getValue());
|
||||
order.setPayStatus(0);
|
||||
order.setVersion(0);
|
||||
|
||||
@@ -169,10 +170,13 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
if (order == null) {
|
||||
throw new RuntimeException("订单不存在");
|
||||
}
|
||||
if (AppointmentOrderStatus.CANCELLED.equals(order.getStatus())) {
|
||||
// 已取消(患者取消0 或 系统取消2)不可再次取消
|
||||
if (OrderStatus.PATIENT_CANCELLED.getValue().equals(order.getStatus())
|
||||
|| OrderStatus.SYSTEM_CANCELLED.getValue().equals(order.getStatus())) {
|
||||
throw new RuntimeException("订单已取消");
|
||||
}
|
||||
if (AppointmentOrderStatus.CHECKED_IN.equals(order.getStatus())) {
|
||||
// 已完成(3)的订单不可取消
|
||||
if (OrderStatus.COMPLETED.getValue().equals(order.getStatus())) {
|
||||
throw new RuntimeException("订单已完成,无法取消");
|
||||
}
|
||||
|
||||
@@ -189,6 +193,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
.eq(Order::getPatientId, patientId)
|
||||
.eq(Order::getTenantId, tenantId)
|
||||
.ge(Order::getCancelTime, startTime)
|
||||
.eq(Order::getStatus, AppointmentOrderStatus.CANCELLED));
|
||||
// 只统计患者主动取消(0),不含系统取消(2)
|
||||
.eq(Order::getStatus, OrderStatus.PATIENT_CANCELLED.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ import com.openhis.clinical.domain.Ticket;
|
||||
import com.openhis.clinical.mapper.TicketMapper;
|
||||
import com.openhis.clinical.service.IOrderService;
|
||||
import com.openhis.clinical.service.ITicketService;
|
||||
import com.openhis.common.constant.CommonConstants.AppointmentOrderStatus;
|
||||
import com.openhis.common.constant.CommonConstants.SlotStatus;
|
||||
import com.openhis.common.enums.OrderStatus;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -195,8 +195,8 @@ public class TicketServiceImpl extends ServiceImpl<TicketMapper, Ticket> impleme
|
||||
Date startTime = Date.from(periodStart.atZone(ZoneId.systemDefault()).toInstant());
|
||||
Date endTime = Date.from(periodEnd.atZone(ZoneId.systemDefault()).toInstant());
|
||||
|
||||
// 预约去重以订单为准(order_main),因为预约成功会先落订单;clinical_ticket 不一定在此链路写入
|
||||
List<Integer> effectiveOrderStatuses = Arrays.asList(AppointmentOrderStatus.BOOKED, AppointmentOrderStatus.CHECKED_IN);
|
||||
// 预约去重以订单为准(order_main),有效订单(1)才参与去重
|
||||
List<Integer> effectiveOrderStatuses = Arrays.asList(OrderStatus.ACTIVE.getValue());
|
||||
int exists = orderMapper.countPatientDeptOrdersInPeriod(dto.getPatientId(), slot.getDepartmentId(), slot.getDepartmentName(),
|
||||
startTime, endTime, effectiveOrderStatuses);
|
||||
if (exists > 0) {
|
||||
@@ -314,9 +314,8 @@ public class TicketServiceImpl extends ServiceImpl<TicketMapper, Ticket> impleme
|
||||
}
|
||||
Order latestOrder = orders.get(0);
|
||||
|
||||
// 1. 更新订单状态为已取号,并更新支付状态和支付时间
|
||||
orderService.updateOrderStatusById(latestOrder.getId(), AppointmentOrderStatus.CHECKED_IN);
|
||||
// 更新支付状态为已支付,记录支付时间
|
||||
// 1. 签到不改变订单状态(仍为有效1),更新支付状态为已支付并记录支付时间
|
||||
orderService.updateOrderStatusById(latestOrder.getId(), OrderStatus.ACTIVE.getValue());
|
||||
orderMapper.updatePayStatus(latestOrder.getId(), 1, new Date());
|
||||
|
||||
// 2. 查询号源槽位信息
|
||||
|
||||
@@ -187,6 +187,15 @@ public class OpSchedule extends HisBaseEntity {
|
||||
/** 沟通信息 */
|
||||
private String communicationInfo;
|
||||
|
||||
/** 是否外请专家 1-是 0-否 */
|
||||
private Integer isExternalExpert;
|
||||
|
||||
/** 外请专家姓名 */
|
||||
private String externalExpertName;
|
||||
|
||||
/** 费用类别 */
|
||||
private String feeType;
|
||||
|
||||
/** 备注信息 */
|
||||
private String remark;
|
||||
|
||||
|
||||
@@ -160,11 +160,12 @@
|
||||
AND delete_flag = '0'
|
||||
</update>
|
||||
|
||||
<!-- status=0(待约)时清空order_id,释放号源,使退号后号源可再被预约 -->
|
||||
<update id="updateSlotStatus">
|
||||
UPDATE adm_schedule_slot
|
||||
SET
|
||||
status = #{status},
|
||||
<if test="status != null and '0'.equals(status.toString())">
|
||||
<if test="status != null and status == 0">
|
||||
order_id = NULL,
|
||||
</if>
|
||||
update_time = now()
|
||||
|
||||
@@ -117,12 +117,14 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- status=1: 只查有效订单(0=患者取消 1=有效 2=系统取消 3=已完成) -->
|
||||
<select id="selectOrderById" resultMap="OrderResult">
|
||||
select * from order_main where id = #{id}
|
||||
and status = 1
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<!-- status=1: 只查有效订单 -->
|
||||
<select id="selectOrderBySlotId" resultMap="OrderResult">
|
||||
select * from order_main where slot_id = #{slotId} and status = 1
|
||||
</select>
|
||||
@@ -248,8 +250,9 @@
|
||||
update order_main set status = #{status} where id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- status=0: 患者取消 (OrderStatus.PATIENT_CANCELLED) -->
|
||||
<update id="updateOrderCancelInfoById">
|
||||
update order_main set status = 3, cancel_time = #{cancelTime}, cancel_reason = #{cancelReason} where id = #{id}
|
||||
update order_main set status = 0, cancel_time = #{cancelTime}, cancel_reason = #{cancelReason} where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updatePayStatus">
|
||||
|
||||
@@ -13,7 +13,7 @@ CREATE TABLE IF NOT EXISTS triage_queue_item (
|
||||
patient_name VARCHAR(255),
|
||||
healthcare_name VARCHAR(255),
|
||||
practitioner_name VARCHAR(255),
|
||||
status VARCHAR(50) NOT NULL, -- WAITING/CALLING/SKIPPED/COMPLETED
|
||||
status INTEGER NOT NULL DEFAULT 0, -- 分诊队列状态: 0=WAITING(等待), 10=CALLING(叫号中), 20=IN_CLINIC(诊中), 30=COMPLETED(已完成), 40=SKIPPED(已跳过)
|
||||
queue_order INTEGER NOT NULL,
|
||||
create_time TIMESTAMP,
|
||||
update_time TIMESTAMP,
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
-- Bug #400 修复:triage_queue_item.status 字段类型修正
|
||||
-- 原 DDL 将 status 定义为 VARCHAR(50),但 Java 实体 TriageQueueItem.status 为 Integer 类型,
|
||||
-- 应用层使用 TriageQueueStatus 枚举值(0/10/20/30/40)写入,类型不匹配导致 MyBatis-Plus
|
||||
-- 无法正确映射 status 字段,完诊时 status 更新为 30 失败。
|
||||
--
|
||||
-- 注意:必须在后端实际连接的 schema 中执行(dev=hisdev, test=histest, prd=hisprd)
|
||||
-- 执行前请先确认:SET search_path TO hisdev; (或对应的 schema)
|
||||
|
||||
-- 1. 先将已有的字符串值转换为对应的整数值
|
||||
-- 如果之前写入的是枚举 code(如 'waiting'、'completed'),需要先转换
|
||||
UPDATE triage_queue_item
|
||||
SET status = CASE
|
||||
WHEN status IN ('0', 'waiting', 'WAITING') THEN 0
|
||||
WHEN status IN ('10', 'calling', 'CALLING') THEN 10
|
||||
WHEN status IN ('20', 'in-clinic', 'IN_CLINIC', 'in-clinic') THEN 20
|
||||
WHEN status IN ('30', 'completed', 'COMPLETED') THEN 30
|
||||
WHEN status IN ('40', 'skipped', 'SKIPPED') THEN 40
|
||||
WHEN status IN ('50', 'refunded', 'REFUNDED') THEN 50
|
||||
WHEN status IN ('60', 'follow', 'FOLLOW') THEN 60
|
||||
ELSE 0
|
||||
END
|
||||
WHERE status IS NOT NULL AND status !~ '^[0-9]+$';
|
||||
|
||||
-- 2. 修改字段类型为 INTEGER
|
||||
ALTER TABLE triage_queue_item
|
||||
ALTER COLUMN status TYPE INTEGER USING status::INTEGER;
|
||||
|
||||
-- 3. 设置默认值
|
||||
ALTER TABLE triage_queue_item
|
||||
ALTER COLUMN status SET DEFAULT 0;
|
||||
@@ -38,7 +38,6 @@ export function listAdviceTypes(query) {
|
||||
params: query
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
/**
|
||||
* 查询手术室详细
|
||||
|
||||
@@ -163,7 +163,7 @@ export function updateCheckPart(data) {
|
||||
// 查询检查套餐列表
|
||||
export function listCheckPackage(query) {
|
||||
return request({
|
||||
url: '/system/check-package/list',
|
||||
url: '/system/package/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import useDictStore from '@/store/modules/dict';
|
||||
|
||||
// 日期格式化
|
||||
export function parseTime(time, pattern) {
|
||||
if (arguments.length === 0 || !time) {
|
||||
@@ -275,30 +277,13 @@ export function blobValidate(data) {
|
||||
|
||||
// 按照频次天数计算总数量
|
||||
export function calculateQuantityByDays(frequency, days) {
|
||||
// const dict = useDict('rate_code').rate_code.value
|
||||
// const rate = dict.find(item => item.value === frequency).remark
|
||||
// if(rate){
|
||||
// return Math.floor(Number(rate) * days)
|
||||
// } else {
|
||||
// return undefined
|
||||
// }
|
||||
const frequencyMap = {
|
||||
ST: 1,
|
||||
QD: 1, // 每日一次
|
||||
BID: 2, // 每日两次
|
||||
TID: 3, // 每日三次
|
||||
QID: 4, // 每日四次
|
||||
QN: 1, // 每晚一次
|
||||
QOD: 1 / 2, // 每隔一日一次
|
||||
QW: 1 / 7, // 每周一次
|
||||
BIW: 2 / 7, // 每周两次
|
||||
TIW: 3 / 7, // 每周三次
|
||||
QOW: 1 / 14, // 隔周一次
|
||||
};
|
||||
if (!frequencyMap[frequency]) {
|
||||
return;
|
||||
}
|
||||
const quantity = frequencyMap[frequency] * days;
|
||||
const dicts = useDictStore().getDict('rate_code');
|
||||
if (!dicts) return;
|
||||
const dict = dicts.find(item => item.value === frequency);
|
||||
if (!dict?.remark) return;
|
||||
const rate = Number(dict.remark);
|
||||
if (isNaN(rate) || !rate) return;
|
||||
const quantity = rate * days;
|
||||
return quantity < 1 ? 1 : Math.ceil(quantity);
|
||||
}
|
||||
|
||||
|
||||
@@ -178,22 +178,25 @@ service.interceptors.request.use(config => {
|
||||
}
|
||||
return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
|
||||
} else if (code === 500) {
|
||||
// 检查是否需要跳过错误提示
|
||||
if (!res.config?.skipErrorMsg) {
|
||||
ElMessage({ message: msg, type: 'error' })
|
||||
// 检查是否需要跳过错误提示(静默请求:返回响应让.then()处理)
|
||||
if (res.config?.skipErrorMsg) {
|
||||
return Promise.resolve(res.data)
|
||||
}
|
||||
ElMessage({ message: msg, type: 'error' })
|
||||
return Promise.reject(new Error(msg))
|
||||
} else if (code === 601) {
|
||||
// 检查是否需要跳过错误提示
|
||||
if (!res.config?.skipErrorMsg) {
|
||||
ElMessage({ message: msg, type: 'warning' })
|
||||
// 检查是否需要跳过错误提示(静默请求:返回响应让.then()处理)
|
||||
if (res.config?.skipErrorMsg) {
|
||||
return Promise.resolve(res.data)
|
||||
}
|
||||
ElMessage({ message: msg, type: 'warning' })
|
||||
return Promise.reject(new Error(msg))
|
||||
} else if (code !== 200) {
|
||||
// 检查是否需要跳过错误提示
|
||||
if (!res.config?.skipErrorMsg) {
|
||||
ElNotification.error({ title: msg })
|
||||
// 检查是否需要跳过错误提示(静默请求:返回响应让.then()处理)
|
||||
if (res.config?.skipErrorMsg) {
|
||||
return Promise.resolve(res.data)
|
||||
}
|
||||
ElNotification.error({ title: msg })
|
||||
return Promise.reject('error')
|
||||
} else {
|
||||
return Promise.resolve(res.data)
|
||||
|
||||
@@ -226,8 +226,14 @@ function getList() {
|
||||
getDiagnosisTreatmentList(queryParams.value).then((res) => {
|
||||
loading.value = false;
|
||||
catagoryList.value = res.data.records.map(record => {
|
||||
// 为每一行初始化 filteredOptions,确保显示框能正确显示项目名称
|
||||
const filteredOptions = allImplementDepartmentList.value.slice(0, 100);
|
||||
// 确保后端返回的项目名称选项存在于 filteredOptions 中,避免 el-select 因找不到选项而回显为 ID
|
||||
if (record.activityDefinitionId && !filteredOptions.some(o => o.value === record.activityDefinitionId)) {
|
||||
filteredOptions.push({
|
||||
value: record.activityDefinitionId,
|
||||
label: record.activityDefinitionId_dictText || record.activityDefinitionId
|
||||
});
|
||||
}
|
||||
return {
|
||||
...record,
|
||||
loading: false,
|
||||
|
||||
@@ -372,11 +372,10 @@ import {
|
||||
} from './diagnosistreatment';
|
||||
import PopoverList from '@/components/OpenHis/popoverList/index.vue';
|
||||
import medicineList from './medicineList.vue';
|
||||
import MedicineList from '../components/medicineList.vue';
|
||||
import {getCurrentInstance, nextTick, watch} from 'vue';
|
||||
|
||||
const { proxy } = getCurrentInstance();
|
||||
const { unit_code, med_chrgitm_type, fin_type_code, activity_category_code, chrgitm_lv } =
|
||||
const { specimen_code, unit_code, med_chrgitm_type, fin_type_code, activity_category_code, chrgitm_lv } =
|
||||
proxy.useDict(
|
||||
'specimen_code',
|
||||
'unit_code',
|
||||
@@ -467,13 +466,22 @@ function calculateTotalPrice() {
|
||||
try {
|
||||
let sum = 0;
|
||||
treatmentItems.value.forEach((item) => {
|
||||
if (item.adviceDefinitionId && item.retailPrice && item.childrenRequestNum) {
|
||||
const price = parseFloat(item.retailPrice) || 0;
|
||||
const count = parseInt(item.childrenRequestNum) || 0;
|
||||
if (item.adviceDefinitionId && item.adviceDefinitionId !== '') {
|
||||
const price = Number(item.retailPrice) || 0;
|
||||
const count = Number(item.childrenRequestNum) || 0;
|
||||
sum += price * count;
|
||||
}
|
||||
});
|
||||
totalPrice.value = sum.toFixed(2);
|
||||
// Bug #464: 零售价与诊疗子项合计总价实时同步,直接赋值不使用nextTick避免多调用方竞争
|
||||
const hasValidItem = treatmentItems.value.some(
|
||||
(item) => item.adviceDefinitionId && item.adviceDefinitionId !== ''
|
||||
);
|
||||
if (hasValidItem) {
|
||||
form.value.retailPrice = parseFloat(totalPrice.value) || 0;
|
||||
} else {
|
||||
form.value.retailPrice = undefined;
|
||||
}
|
||||
} catch (error) {
|
||||
totalPrice.value = '0.00';
|
||||
proxy.$modal.msgWarning('价格计算过程中遇到错误,请检查输入数据');
|
||||
@@ -482,7 +490,7 @@ function calculateTotalPrice() {
|
||||
|
||||
// 添加表单项
|
||||
function addItem() {
|
||||
treatmentItems.value.push({ adviceDefinitionId: '', childrenRequestNum: 1, retailPrice: 0 });
|
||||
treatmentItems.value.push({ adviceDefinitionId: '', childrenRequestNum: 1, name: '', retailPrice: 0 });
|
||||
// 使用nextTick确保DOM更新后再计算
|
||||
nextTick(() => {
|
||||
calculateTotalPrice();
|
||||
@@ -556,15 +564,16 @@ function edit() {
|
||||
form.value.pricingFlag = 1;
|
||||
}
|
||||
|
||||
// 处理子项数据,确保包含retailPrice字段
|
||||
// 处理子项数据,确保包含retailPrice和name字段
|
||||
if (props.item.childrenJson) {
|
||||
const parsedItems = JSON.parse(props.item.childrenJson);
|
||||
treatmentItems.value = parsedItems.map((item) => ({
|
||||
...item,
|
||||
name: item.name || '',
|
||||
retailPrice: item.retailPrice || 0,
|
||||
}));
|
||||
} else {
|
||||
treatmentItems.value = [{ adviceDefinitionId: '', childrenRequestNum: 1, retailPrice: 0 }];
|
||||
treatmentItems.value = [{ adviceDefinitionId: '', childrenRequestNum: 1, name: '', retailPrice: 0 }];
|
||||
}
|
||||
form.value.permittedUnitCode = form.value.permittedUnitCode
|
||||
? form.value.permittedUnitCode.toString()
|
||||
@@ -609,7 +618,7 @@ function reset() {
|
||||
chrgitmLv: undefined, //医保等级
|
||||
pricingFlag: 1, // 划价标记,默认允许划价
|
||||
};
|
||||
treatmentItems.value = [{ adviceDefinitionId: '', childrenRequestNum: 1, retailPrice: 0 }];
|
||||
treatmentItems.value = [{ adviceDefinitionId: '', childrenRequestNum: 1, name: '', retailPrice: 0 }];
|
||||
totalPrice.value = '0.00';
|
||||
proxy.resetForm('diagnosisTreatmentRef');
|
||||
}
|
||||
@@ -643,12 +652,15 @@ async function submitForm() {
|
||||
form.value.ybMatchFlag ? (form.value.ybMatchFlag = 1) : (form.value.ybMatchFlag = 0);
|
||||
form.value.ruleId ? (form.value.ruleId = 1) : (form.value.ruleId = 0);
|
||||
form.value.childrenJson =
|
||||
treatmentItems.value.length > 0 && treatmentItems.value[0].adviceDefinitionId != ''
|
||||
treatmentItems.value.some((item) => item.adviceDefinitionId != '' && item.adviceDefinitionId)
|
||||
? JSON.stringify(treatmentItems.value)
|
||||
: undefined;
|
||||
// Bug #464 修复:零售价自动与诊疗子项合计总价同步
|
||||
// 当有子项时,零售价自动设置为子项合计总价
|
||||
if (treatmentItems.value.length > 0 && treatmentItems.value[0].adviceDefinitionId != '') {
|
||||
const hasValidItem = treatmentItems.value.some(
|
||||
(item) => item.adviceDefinitionId && item.adviceDefinitionId !== ''
|
||||
);
|
||||
if (hasValidItem) {
|
||||
form.value.retailPrice = parseFloat(totalPrice.value) || 0;
|
||||
}
|
||||
proxy.$refs['diagnosisTreatmentRef'].validate(async (valid) => {
|
||||
|
||||
@@ -36,6 +36,7 @@ const emit = defineEmits(['selectRow']);
|
||||
const diagnosisTreatmentList = ref([]); // 原始数据列表
|
||||
const filteredList = ref([]); // 过滤后的数据列表
|
||||
const hasLoaded = ref(false); // 标记是否已加载数据
|
||||
const isLoading = ref(false); // 标记是否正在加载
|
||||
|
||||
// 获取诊疗项目列表
|
||||
function getList() {
|
||||
@@ -53,7 +54,7 @@ function getList() {
|
||||
getDiagnosisTreatmentList({ statusEnum: 2, pageSize: 1000, pageNo: 1 })
|
||||
.then((res) => {
|
||||
diagnosisTreatmentList.value =
|
||||
res.data?.records?.filter((item) => item.childrenJson == null) || [];
|
||||
res.data?.records?.filter((item) => item.childrenJson == null || item.childrenJson === '') || [];
|
||||
filterList(); // 初始化过滤
|
||||
hasLoaded.value = true; // 标记为已加载
|
||||
})
|
||||
@@ -62,6 +63,47 @@ function getList() {
|
||||
});
|
||||
}
|
||||
|
||||
// 服务端搜索(当用户输入搜索关键词时)
|
||||
function searchList(searchKey) {
|
||||
if (!searchKey || searchKey.trim() === '') return;
|
||||
isLoading.value = true;
|
||||
// 使用较大的pageSize确保搜索结果尽可能多
|
||||
getDiagnosisTreatmentList({ statusEnum: 2, searchKey: searchKey.trim(), pageSize: 5000, pageNo: 1 })
|
||||
.then((res) => {
|
||||
diagnosisTreatmentList.value =
|
||||
res.data?.records?.filter((item) => item.childrenJson == null || item.childrenJson === '') || [];
|
||||
filterList();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('搜索诊疗项目数据失败:', err);
|
||||
})
|
||||
.finally(() => {
|
||||
isLoading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
// 获取预加载数据(不带搜索关键词时使用)
|
||||
function loadPreloadedData() {
|
||||
if (props.preloadedData && props.preloadedData.length > 0) {
|
||||
diagnosisTreatmentList.value = props.preloadedData;
|
||||
filterList();
|
||||
hasLoaded.value = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasLoaded.value) return;
|
||||
getDiagnosisTreatmentList({ statusEnum: 2, pageSize: 1000, pageNo: 1 })
|
||||
.then((res) => {
|
||||
diagnosisTreatmentList.value =
|
||||
res.data?.records?.filter((item) => item.childrenJson == null || item.childrenJson === '') || [];
|
||||
filterList();
|
||||
hasLoaded.value = true;
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('获取诊疗项目数据失败:', err);
|
||||
});
|
||||
}
|
||||
|
||||
// 监听shouldLoadData属性变化,仅在首次为true时加载数据
|
||||
watch(
|
||||
() => props.shouldLoadData,
|
||||
@@ -86,11 +128,17 @@ watch(
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
// 监听搜索关键词变化,实时过滤数据
|
||||
// 监听搜索关键词变化,有搜索词时走服务端搜索,否则走本地过滤
|
||||
watch(
|
||||
() => props.searchKey,
|
||||
() => {
|
||||
filterList();
|
||||
(newVal) => {
|
||||
if (newVal && newVal.trim() !== '') {
|
||||
// 有搜索关键词,走服务端搜索
|
||||
searchList(newVal);
|
||||
} else {
|
||||
// 搜索词为空,使用预加载数据
|
||||
loadPreloadedData();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -69,13 +69,14 @@ const throttledGetList = throttle(
|
||||
watch(
|
||||
() => props.adviceQueryParams,
|
||||
(newValue) => {
|
||||
// 只有在弹窗打开时才响应 adviceQueryParams 的变化,避免选择项目后弹窗关闭时触发不必要的请求
|
||||
if (!props.popoverVisible) {
|
||||
return;
|
||||
}
|
||||
// 始终同步参数到 queryParams,避免弹窗打开时使用旧参数
|
||||
queryParams.value.searchKey = newValue?.searchKey;
|
||||
queryParams.value.adviceType = newValue?.adviceType;
|
||||
queryParams.value.categoryCode = newValue?.categoryCode;
|
||||
// 只有在弹窗打开时才触发 API 请求
|
||||
if (!props.popoverVisible) {
|
||||
return;
|
||||
}
|
||||
throttledGetList();
|
||||
},
|
||||
{ deep: true }
|
||||
@@ -114,22 +115,44 @@ function getList() {
|
||||
console.log('[adviceBaseList] getList() 跳过:未选择患者');
|
||||
return; // 不执行API调用
|
||||
}
|
||||
|
||||
|
||||
// 只有在弹窗打开时才执行查询
|
||||
if (!props.popoverVisible) {
|
||||
console.log('[adviceBaseList] getList() 跳过:弹窗未打开');
|
||||
return;
|
||||
}
|
||||
|
||||
queryParams.value.organizationId = props.patientInfo.orgId;
|
||||
console.log('[adviceBaseList] getList() 请求参数:', JSON.stringify(queryParams.value));
|
||||
|
||||
getAdviceBaseInfo(queryParams.value).then((res) => {
|
||||
|
||||
// 🔧 Bug #448 修复:显式构建请求参数,确保 adviceType 正确传递
|
||||
// 不直接使用 queryParams.value,避免 undefined 值被发送到后端导致过滤失效
|
||||
const requestParams = {
|
||||
pageSize: queryParams.value.pageSize,
|
||||
pageNum: queryParams.value.pageNum,
|
||||
organizationId: props.patientInfo.orgId,
|
||||
};
|
||||
|
||||
// 只在 adviceType 有值时添加(0 是无效值,undefined/null 会导致后端查询所有类型)
|
||||
if (queryParams.value.adviceType != null && queryParams.value.adviceType !== 0) {
|
||||
requestParams.adviceType = queryParams.value.adviceType;
|
||||
}
|
||||
|
||||
// 只在 categoryCode 有值时添加
|
||||
if (queryParams.value.categoryCode) {
|
||||
requestParams.categoryCode = queryParams.value.categoryCode;
|
||||
}
|
||||
|
||||
// 只在 searchKey 有值时添加
|
||||
if (queryParams.value.searchKey) {
|
||||
requestParams.searchKey = queryParams.value.searchKey;
|
||||
}
|
||||
|
||||
console.log('[adviceBaseList] getList() 请求参数:', JSON.stringify(requestParams));
|
||||
|
||||
getAdviceBaseInfo(requestParams).then((res) => {
|
||||
console.log('[adviceBaseList] getList() 响应数据:', {
|
||||
total: res.data?.total,
|
||||
recordsCount: res.data?.records?.length || 0,
|
||||
firstRecord: res.data?.records?.[0]?.adviceName || '无数据',
|
||||
adviceType: queryParams.value.adviceType
|
||||
adviceType: requestParams.adviceType
|
||||
});
|
||||
adviceBaseList.value = res.data.records || [];
|
||||
total.value = res.data.total || 0;
|
||||
|
||||
@@ -58,10 +58,17 @@ export function singOut(data) {
|
||||
/**
|
||||
* 获取患者本次就诊处方
|
||||
*/
|
||||
export function getPrescriptionList(encounterId) {
|
||||
// Add timestamp to bypass browser caching and ensure fresh data is loaded
|
||||
export function getPrescriptionList(encounterId, generateSourceEnum, sourceBillNo) {
|
||||
let url = '/doctor-station/advice/request-base-info?encounterId=' + encounterId
|
||||
if (generateSourceEnum != null) {
|
||||
url += '&generateSourceEnum=' + generateSourceEnum
|
||||
}
|
||||
if (sourceBillNo != null) {
|
||||
url += '&sourceBillNo=' + encodeURIComponent(sourceBillNo)
|
||||
}
|
||||
url += '&t=' + Date.now()
|
||||
return request({
|
||||
url: '/doctor-station/advice/request-base-info?encounterId=' + encounterId + '&t=' + Date.now(),
|
||||
url: url,
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
@@ -381,6 +381,14 @@ const props = defineProps({
|
||||
activeTab: {
|
||||
type: String,
|
||||
},
|
||||
generateSourceEnum: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
sourceBillNo: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
const isAdding = ref(false);
|
||||
const isSaving = ref(false); // #437 防重复提交锁
|
||||
@@ -453,7 +461,7 @@ watch(
|
||||
console.log(prescriptionList.value,"prescriptionList.value")
|
||||
if(newValue&&newValue.length>0){
|
||||
let saveList = prescriptionList.value.filter((item) => {
|
||||
return item.statusEnum == 1&&(Number(item.bizRequestFlag)==1||!item.bizRequestFlag)
|
||||
return item.check && item.statusEnum == 1&&(Number(item.bizRequestFlag)==1||!item.bizRequestFlag)
|
||||
})
|
||||
console.log(saveList,"prescriptionList.value")
|
||||
if (saveList.length == 0) {
|
||||
@@ -468,7 +476,11 @@ watch(
|
||||
|
||||
function getListInfo(addNewRow) {
|
||||
isAdding.value = false;
|
||||
getPrescriptionList(props.patientInfo.encounterId).then((res) => {
|
||||
getPrescriptionList(
|
||||
props.patientInfo.encounterId,
|
||||
props.generateSourceEnum ?? undefined,
|
||||
props.sourceBillNo ?? undefined,
|
||||
).then((res) => {
|
||||
// 为每行数据添加 adviceTypeValue 字段,用于类型下拉框显示
|
||||
prescriptionList.value = (res.data || []).map(item => {
|
||||
// 根据 adviceType 和 categoryCode 找到对应的 adviceTypeValue
|
||||
@@ -868,19 +880,27 @@ function handleDelete() {
|
||||
proxy.$modal.msgWarning('请选择要删除的项目');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
let deleteList = groupIndexList.value.map((index) => {
|
||||
const item = prescriptionList.value[index];
|
||||
// 只删除待签发且未收费的项目
|
||||
if (item.statusEnum != 1 || item.chargeStatus == 5) {
|
||||
return null;
|
||||
}
|
||||
// 🔧 Bug #442: 非本人创建的医嘱不允许删除(与签发/签退逻辑保持一致)
|
||||
if (Number(item.bizRequestFlag) !== 1 && item.bizRequestFlag) {
|
||||
return null;
|
||||
}
|
||||
// 🔧 Bug #442: 已保存的行必须有有效的 requestId,否则跳过(避免后端删除不存在的记录)
|
||||
if (item.requestId == null || item.requestId === undefined || item.requestId === '') {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
requestId: item.requestId,
|
||||
dbOpType: '3',
|
||||
adviceType: item.adviceType,
|
||||
};
|
||||
}).filter(item => item !== null); // 过滤掉已签发或已收费的项目
|
||||
}).filter(item => item !== null); // 过滤掉已签发、已收费、非本人创建或无 requestId 的项目
|
||||
|
||||
if (deleteList.length == 0) {
|
||||
proxy.$modal.msgWarning('只能删除待签发且未收费的项目');
|
||||
@@ -995,7 +1015,7 @@ function handleSave() {
|
||||
return;
|
||||
}
|
||||
let saveList = prescriptionList.value.filter((item) => {
|
||||
return item.statusEnum == 1&&(Number(item.bizRequestFlag)==1||!item.bizRequestFlag)
|
||||
return item.check && item.statusEnum == 1&&(Number(item.bizRequestFlag)==1||!item.bizRequestFlag)
|
||||
});
|
||||
// let saveList = prescriptionList.value
|
||||
// .filter((item) => {
|
||||
@@ -1016,6 +1036,14 @@ function handleSave() {
|
||||
requestId: item.requestId,
|
||||
dbOpType: '1',
|
||||
groupId: item.groupId,
|
||||
// 🔧 Bug #443: 补充顶层关键字段(这些不在 contentJson 中,需从 API 响应顶层提取)
|
||||
encounterId: item.encounterId,
|
||||
patientId: item.patientId,
|
||||
locationId: item.positionId,
|
||||
adviceType: item.adviceType,
|
||||
adviceTableName: item.adviceTableName,
|
||||
adviceDefinitionId: item.adviceDefinitionId,
|
||||
chargeItemId: item.chargeItemId,
|
||||
};
|
||||
});
|
||||
savePrescriptionSign({
|
||||
@@ -1031,7 +1059,12 @@ function handleSave() {
|
||||
groupIndexList.value = []
|
||||
groupList.value = []
|
||||
nextId.value = 1;
|
||||
} else {
|
||||
proxy.$modal.msgError(res?.msg || '签发失败,请重试');
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error('签发失败:', error);
|
||||
proxy.$modal.msgError(error?.response?.data?.msg || error?.message || '签发失败,请重试');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1047,42 +1080,44 @@ function handleSaveSign(row, index) {
|
||||
proxy.$modal.msgWarning('诊疗项目必须选择执行科室');
|
||||
return;
|
||||
}
|
||||
isSaving.value = true; // #437 立即加锁,消除 TOCTOU 竞态
|
||||
proxy.$refs['formRef' + index].validate((valid) => {
|
||||
if (valid) {
|
||||
isSaving.value = true; // #437 加锁
|
||||
row.isEdit = false;
|
||||
isAdding.value = false;
|
||||
expandOrder.value = [];
|
||||
row.patientId = props.patientInfo.patientId;
|
||||
row.encounterId = props.patientInfo.encounterId;
|
||||
row.accountId = props.patientInfo.accountId;
|
||||
const cleanRow = JSON.parse(JSON.stringify(row));
|
||||
cleanRow.contentJson = JSON.stringify(cleanRow);
|
||||
cleanRow.dbOpType = cleanRow.requestId ? '2' : '1';
|
||||
cleanRow.minUnitQuantity = cleanRow.quantity * cleanRow.partPercent;
|
||||
cleanRow.categoryEnum = cleanRow.adviceType
|
||||
// 如果是手术计费,设置生成来源和来源业务单据号
|
||||
if (props.patientInfo.sourceBillNo) {
|
||||
cleanRow.generateSourceEnum = 6; // 手术计费
|
||||
cleanRow.sourceBillNo = props.patientInfo.sourceBillNo;
|
||||
}
|
||||
console.log('cleanRow', cleanRow)
|
||||
savePrescription({ adviceSaveList: [cleanRow] }).then((res) => {
|
||||
if (res.code === 200) {
|
||||
proxy.$modal.msgSuccess('保存成功');
|
||||
getListInfo(false);
|
||||
nextId.value = 1;
|
||||
// 🔧 Bug Fix #238: 如果诊疗项目缺少执行科室,标记为需要修复的脏数据
|
||||
if (row.adviceType === 3 && !row.orgId) {
|
||||
console.warn('Bug #238: 检测到诊疗项目保存时缺少执行科室,请手动编辑修正:', cleanRow);
|
||||
proxy.$modal.msgWarning('诊疗项目执行科室信息不完整,请编辑后重新保存');
|
||||
}
|
||||
}
|
||||
}).finally(() => {
|
||||
isSaving.value = false; // #437 释放锁
|
||||
});
|
||||
if (!valid) {
|
||||
isSaving.value = false; // 验证失败释放锁
|
||||
return;
|
||||
}
|
||||
});
|
||||
row.isEdit = false;
|
||||
isAdding.value = false;
|
||||
expandOrder.value = [];
|
||||
row.patientId = props.patientInfo.patientId;
|
||||
row.encounterId = props.patientInfo.encounterId;
|
||||
row.accountId = props.patientInfo.accountId;
|
||||
const cleanRow = JSON.parse(JSON.stringify(row));
|
||||
cleanRow.contentJson = JSON.stringify(cleanRow);
|
||||
cleanRow.dbOpType = cleanRow.requestId ? '2' : '1';
|
||||
cleanRow.minUnitQuantity = cleanRow.quantity * cleanRow.partPercent;
|
||||
cleanRow.categoryEnum = cleanRow.adviceType
|
||||
// 如果是手术计费,设置生成来源和来源业务单据号
|
||||
if (props.patientInfo.sourceBillNo) {
|
||||
cleanRow.generateSourceEnum = 6; // 手术计费
|
||||
cleanRow.sourceBillNo = props.patientInfo.sourceBillNo;
|
||||
}
|
||||
console.log('cleanRow', cleanRow)
|
||||
savePrescription({ adviceSaveList: [cleanRow] }, '1').then((res) => {
|
||||
if (res.code === 200) {
|
||||
proxy.$modal.msgSuccess('保存成功');
|
||||
getListInfo(false);
|
||||
nextId.value = 1;
|
||||
// 🔧 Bug Fix #238: 如果诊疗项目缺少执行科室,标记为需要修复的脏数据
|
||||
if (row.adviceType === 3 && !row.orgId) {
|
||||
console.warn('Bug #238: 检测到诊疗项目保存时缺少执行科室,请手动编辑修正:', cleanRow);
|
||||
proxy.$modal.msgWarning('诊疗项目执行科室信息不完整,请编辑后重新保存');
|
||||
}
|
||||
}
|
||||
}).finally(() => {
|
||||
isSaving.value = false; // #437 释放锁
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
// 签退
|
||||
@@ -1146,7 +1181,13 @@ function calculateTotalPrice(row, index) {
|
||||
});
|
||||
}
|
||||
|
||||
defineExpose({ getListInfo });
|
||||
function closeAllPopovers() {
|
||||
prescriptionList.value.forEach(row => {
|
||||
row.showPopover = false;
|
||||
});
|
||||
}
|
||||
|
||||
defineExpose({ getListInfo, closeAllPopovers });
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -519,9 +519,10 @@
|
||||
>
|
||||
<template #append>
|
||||
<!-- 审核记录:查看/审核都展示,保证留痕可追溯 -->
|
||||
<!-- 修复:查看模式始终显示区块;审核模式始终显示区块(header + 空状态 或 timeline) -->
|
||||
<div
|
||||
class="audit-records-section"
|
||||
v-if="drawerMode === 'view' || (drawerMode === 'audit' && auditRecords.length > 0)"
|
||||
v-if="drawerMode === 'view' || drawerMode === 'audit'"
|
||||
>
|
||||
<h3 class="section-title">审核记录</h3>
|
||||
<el-timeline v-if="auditRecords.length > 0">
|
||||
|
||||
@@ -127,6 +127,7 @@ const queryParams = ref({
|
||||
pageSize: 100,
|
||||
pageNo: 1,
|
||||
adviceTypes: '1,2,3',
|
||||
categoryCode: '',
|
||||
});
|
||||
|
||||
// 节流函数 - 与V1.3一致:300ms,首次立即响应
|
||||
@@ -148,6 +149,7 @@ watch(
|
||||
} else {
|
||||
queryParams.value.adviceTypes = '1,2,3';
|
||||
}
|
||||
queryParams.value.categoryCode = newValue.categoryCode || '';
|
||||
throttledGetList();
|
||||
},
|
||||
{ deep: true }
|
||||
@@ -175,6 +177,12 @@ function getList() {
|
||||
const types = adviceTypes.split(',').map(t => parseInt(t));
|
||||
filteredData = filteredData.filter(item => types.includes(item.adviceType));
|
||||
}
|
||||
|
||||
// 根据 categoryCode 过滤(如西药='2',中成药='1')
|
||||
const categoryCode = queryParams.value.categoryCode;
|
||||
if (categoryCode) {
|
||||
filteredData = filteredData.filter(item => String(item.categoryCode) === String(categoryCode));
|
||||
}
|
||||
|
||||
// 根据搜索关键词过滤
|
||||
if (searchKey && searchKey.length >= 1) {
|
||||
|
||||
@@ -375,7 +375,7 @@ const finishCallPatient = async () => {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await completeEncounter(currentCallPatient.value.encounterId);
|
||||
await completeEncounter({ encounterId: currentCallPatient.value.encounterId, firstEnum: currentCallPatient.value.firstEnum || 1 });
|
||||
emit('finish');
|
||||
emit('update:dialogVisible', false);
|
||||
ElMessage.success('患者已完诊');
|
||||
|
||||
@@ -349,11 +349,17 @@ async function getList() {
|
||||
if (res.code == 200) {
|
||||
// 过滤掉中医诊断,只保留西医诊断
|
||||
form.value.diagnosisList = res.data.filter(item => item.typeName !== '中医诊断');
|
||||
// 为旧数据添加默认分类
|
||||
// 为旧数据添加默认分类和selectedDiseases
|
||||
form.value.diagnosisList.forEach(item => {
|
||||
if (!item.classification) {
|
||||
item.classification = '西医';
|
||||
}
|
||||
// 如果ybNo(诊断编码)符合传染病编码格式,添加到selectedDiseases
|
||||
if (item.ybNo && /^(01|02|03)/.test(item.ybNo)) {
|
||||
item.selectedDiseases = [item.ybNo];
|
||||
} else {
|
||||
item.selectedDiseases = item.selectedDiseases || [];
|
||||
}
|
||||
});
|
||||
emits('diagnosisSave', false);
|
||||
}
|
||||
@@ -685,23 +691,80 @@ async function handleFoodDiseasesCheck() {
|
||||
|
||||
/**
|
||||
* 传染病报告卡处理
|
||||
* 通过诊断目录维护的'报卡类型'字段自动识别是否有需要填写的传染病报告卡
|
||||
* 如果有则弹出诊断对应需登记的报告卡界面
|
||||
* 通过诊断名称自动识别并勾选传染病报告卡中的疾病
|
||||
* 修复 Bug #519:跳过已有已提交报卡的诊断
|
||||
*/
|
||||
function handleInfectiousDiseaseReport() {
|
||||
// 查找所有有报卡类型的诊断(reportTypeCode不为空)
|
||||
const diagnosesWithReportType = form.value.diagnosisList.filter(d => d.reportTypeCode);
|
||||
// 疾病名称到报卡编码的映射(根据传染病报告卡弹窗中的疾病列表)
|
||||
const diseaseNameToCode = {
|
||||
// 甲类
|
||||
'鼠疫': '0101',
|
||||
'霍乱': '0102',
|
||||
// 乙类
|
||||
'传染性非典型肺炎': '0201',
|
||||
'艾滋病': '0202',
|
||||
'病毒性肝炎': '0203',
|
||||
'脊髓灰质炎': '0204',
|
||||
'人感染高致病性禽流感': '0205',
|
||||
'麻疹': '0206',
|
||||
'流行性出血热': '0207',
|
||||
'狂犬病': '0208',
|
||||
'流行性乙型脑炎': '0209',
|
||||
'登革热': '0210',
|
||||
'炭疽': '0211',
|
||||
'细菌性和阿米巴性痢疾': '0212',
|
||||
'肺结核': '0213',
|
||||
'伤寒和副伤寒': '0214',
|
||||
'流行性脑脊髓膜炎': '0215',
|
||||
'百日咳': '0216',
|
||||
'白喉': '0217',
|
||||
'新生儿破伤风': '0218',
|
||||
'猩红热': '0219',
|
||||
'布鲁氏菌病': '0220',
|
||||
'淋病': '0221',
|
||||
'梅毒': '0222',
|
||||
'钩端螺旋体病': '0223',
|
||||
'血吸虫病': '0224',
|
||||
'疟疾': '0225',
|
||||
'新型冠状病毒肺炎': '0226',
|
||||
'甲型H1N1流感': '0227',
|
||||
'人感染H7N9禽流感': '0228',
|
||||
// 丙类
|
||||
'流行性感冒': '0301',
|
||||
'流行性腮腺炎': '0302',
|
||||
'风疹': '0303',
|
||||
'急性出血性结膜炎': '0304',
|
||||
'麻风病': '0305',
|
||||
'流行性和地方性斑疹伤寒': '0306',
|
||||
'黑热病': '0307',
|
||||
'包虫病': '0308',
|
||||
'丝虫病': '0309',
|
||||
'除霍乱/菌痢/伤寒副伤寒以外的感染性腹泻病': '0310',
|
||||
'其它感染性腹泻病': '0310',
|
||||
'手足口病': '0311',
|
||||
};
|
||||
|
||||
if (diagnosesWithReportType.length === 0) {
|
||||
// 获取所有诊断名称对应的报卡编码,但跳过已有已提交报卡的诊断
|
||||
const allSelectedDiseases = form.value.diagnosisList
|
||||
.filter(d => d.name && d.hasInfectiousReport !== 1)
|
||||
.map(d => diseaseNameToCode[d.name] || null)
|
||||
.filter(code => code);
|
||||
|
||||
if (allSelectedDiseases.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 优先使用主诊断,如果没有主诊断有报卡类型则使用第一个有报卡类型的诊断
|
||||
const mainDiagnosisWithReport = diagnosesWithReportType.find(d => d.maindiseFlag === 1);
|
||||
const targetDiagnosis = mainDiagnosisWithReport || diagnosesWithReportType[0];
|
||||
// 优先使用主诊断(同样跳过已有报卡的)
|
||||
const mainDiagnosis = form.value.diagnosisList.find(d => d.maindiseFlag === 1 && d.hasInfectiousReport !== 1);
|
||||
const firstDiagnosis = form.value.diagnosisList.find(d => d.hasInfectiousReport !== 1) || form.value.diagnosisList[0];
|
||||
|
||||
const diagnosisToShow = {
|
||||
...(mainDiagnosis || firstDiagnosis),
|
||||
selectedDiseases: allSelectedDiseases
|
||||
};
|
||||
|
||||
// 弹出传染病报告卡弹窗
|
||||
proxy.$refs.infectiousDiseaseReportRef?.show(targetDiagnosis);
|
||||
proxy.$refs.infectiousDiseaseReportRef?.show(diagnosisToShow);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -814,7 +877,8 @@ form.value.diagnosisList.push({
|
||||
classification: '西医', // 默认为西医
|
||||
onsetDate: getCurrentDate(),
|
||||
diagnosisDoctor: props.patientInfo.practitionerName || props.patientInfo.doctorName || props.patientInfo.physicianName || userStore.name,
|
||||
diagnosisTime: getCurrentDate()
|
||||
diagnosisTime: getCurrentDate(),
|
||||
selectedDiseases: data.ybNo ? [data.ybNo] : [], // 用于传染病报告卡自动勾选
|
||||
});
|
||||
|
||||
// 添加后按排序号排序
|
||||
|
||||
@@ -16,15 +16,15 @@
|
||||
v-model="form.cardNo"
|
||||
class="card-number-input"
|
||||
placeholder="单位自编,与网络直报一致"
|
||||
maxlength="12"
|
||||
:disabled="readOnly"
|
||||
maxlength="20"
|
||||
:disabled="readOnly || dialogReadOnly"
|
||||
/>
|
||||
</el-space>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<el-card class="report-form" shadow="never">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-position="top" :disabled="readOnly">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-position="top" :disabled="readOnly || dialogReadOnly">
|
||||
<!-- 患者姓名、家长姓名、身份证号 -->
|
||||
<el-row :gutter="16" class="form-row">
|
||||
<el-col :span="8" class="form-item">
|
||||
@@ -41,31 +41,39 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 性别、出生日期、实足年龄 -->
|
||||
<el-row :gutter="16" class="form-row align-bottom">
|
||||
<el-col :span="6" class="form-item">
|
||||
<!-- 工作单位(学校) -->
|
||||
<el-row :gutter="16" class="form-row">
|
||||
<el-col :span="12" class="form-item">
|
||||
<span class="form-label">工作单位(学校)</span>
|
||||
<el-input v-model="form.workplace" class="underline-input" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 性别、出生日期、或实足年龄 -->
|
||||
<el-row :gutter="16" class="form-row">
|
||||
<el-col :span="7" class="form-item">
|
||||
<span class="form-label required">性别</span>
|
||||
<el-radio-group v-model="form.sex">
|
||||
<el-radio label="男">男</el-radio>
|
||||
<el-radio label="女">女</el-radio>
|
||||
<el-radio label="未知">未知</el-radio>
|
||||
<el-radio-group v-model="form.sex" class="gender-radio-group">
|
||||
<el-radio value="男">男</el-radio>
|
||||
<el-radio value="女">女</el-radio>
|
||||
<el-radio value="未知">未知</el-radio>
|
||||
</el-radio-group>
|
||||
</el-col>
|
||||
<el-col :span="10" class="form-item birth-date">
|
||||
<el-col :span="10" class="form-item">
|
||||
<span class="form-label required">出生日期</span>
|
||||
<div class="date-inputs">
|
||||
<el-input v-model="form.birthYear" class="underline-input small" maxlength="4" @change="calculateAge" />
|
||||
<span>年</span>
|
||||
<el-input v-model="form.birthMonth" class="underline-input small" maxlength="2" @change="calculateAge" />
|
||||
<span>月</span>
|
||||
<el-input v-model="form.birthDay" class="underline-input small" maxlength="2" @change="calculateAge" />
|
||||
<span>日</span>
|
||||
<div class="birth-input-group">
|
||||
<el-input v-model="form.birthYear" class="birth-input year" placeholder="年" maxlength="4" />
|
||||
<span class="birth-separator">年</span>
|
||||
<el-input v-model="form.birthMonth" class="birth-input month" placeholder="月" maxlength="2" />
|
||||
<span class="birth-separator">月</span>
|
||||
<el-input v-model="form.birthDay" class="birth-input day" placeholder="日" maxlength="2" />
|
||||
<span class="birth-separator">日</span>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="8" class="form-item age-item">
|
||||
<el-col :span="7" class="form-item">
|
||||
<span class="form-label">或 实足年龄</span>
|
||||
<div class="age-inputs">
|
||||
<el-input v-model="form.age" class="underline-input small"/>
|
||||
<div class="age-input-group">
|
||||
<el-input v-model="form.age" class="age-input" placeholder="年龄" />
|
||||
<el-select v-model="form.ageUnit" class="age-unit-select">
|
||||
<el-option label="岁" value="岁" />
|
||||
<el-option label="月" value="月" />
|
||||
@@ -75,14 +83,6 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 工作单位 -->
|
||||
<el-row :gutter="16" class="form-row">
|
||||
<el-col :span="24" class="form-item full-width">
|
||||
<span class="form-label">工作单位(学校)</span>
|
||||
<el-input v-model="form.workplace" class="underline-input" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 联系电话、紧急联系人电话 -->
|
||||
<el-row :gutter="16" class="form-row">
|
||||
<el-col :span="12" class="form-item">
|
||||
@@ -510,9 +510,9 @@
|
||||
<template #footer>
|
||||
<slot name="footer" :close="handleClose" :submit-loading="submitLoading">
|
||||
<el-space :size="16" justify="center" class="dialog-footer-space" style="display: flex; justify-content: center; width: 100%;">
|
||||
<el-button v-if="!readOnly" type="primary" @click="handleSubmit" :loading="submitLoading" class="blue-button">保 存</el-button>
|
||||
<el-button v-if="!(readOnly || dialogReadOnly)" type="primary" @click="handleSubmit" :loading="submitLoading" class="blue-button">保 存</el-button>
|
||||
<el-button type="info" @click="handleClose">关 闭</el-button>
|
||||
<el-button v-if="!readOnly" type="danger" @click="handleReset">重 置</el-button>
|
||||
<el-button v-if="!(readOnly || dialogReadOnly)" type="danger" @click="handleReset">重 置</el-button>
|
||||
</el-space>
|
||||
</slot>
|
||||
</template>
|
||||
@@ -522,7 +522,7 @@
|
||||
<script setup>
|
||||
import { ref, computed, getCurrentInstance, watch } from 'vue';
|
||||
import pcas from 'china-division/dist/pcas-code.json';
|
||||
import { saveInfectiousDiseaseReport } from '../api';
|
||||
import { saveInfectiousDiseaseReport, getNextCardNo } from '../api';
|
||||
import useUserStore from '@/store/modules/user';
|
||||
import { useDict } from '@/utils/dict';
|
||||
|
||||
@@ -544,6 +544,7 @@ const DISEASE_NAMES = {
|
||||
};
|
||||
|
||||
const dialogVisible = ref(false);
|
||||
const dialogReadOnly = ref(false);
|
||||
const formRef = ref(null);
|
||||
// 保存按钮加载状态,防止重复提交
|
||||
const submitLoading = ref(false);
|
||||
@@ -1033,6 +1034,17 @@ function normalizeSex(value) {
|
||||
return '未知';
|
||||
}
|
||||
|
||||
function normalizeSexFromPatientInfo(patientInfo) {
|
||||
// 优先使用文本字段
|
||||
if (patientInfo.genderEnum_enumText) return patientInfo.genderEnum_enumText;
|
||||
if (patientInfo.genderName) return patientInfo.genderName;
|
||||
if (patientInfo.sex) return normalizeSex(patientInfo.sex);
|
||||
// 使用数字枚举字段
|
||||
if (patientInfo.genderEnum === 1) return '男';
|
||||
if (patientInfo.genderEnum === 2) return '女';
|
||||
return '未知';
|
||||
}
|
||||
|
||||
function normalizeAgeUnit(value) {
|
||||
const ageUnitMap = {
|
||||
1: '岁',
|
||||
@@ -1071,8 +1083,9 @@ function resetAddressSelector() {
|
||||
* 以只读详情方式打开报卡弹窗,供报卡管理等页面复用医生站报卡样式。
|
||||
* @param {Object} reportData - 报卡详情数据
|
||||
*/
|
||||
function showReport(reportData = {}) {
|
||||
function showReport(reportData = {}, readOnly = true) {
|
||||
dialogVisible.value = true;
|
||||
dialogReadOnly.value = readOnly;
|
||||
|
||||
resetAddressSelector();
|
||||
initProvinceOptions();
|
||||
@@ -1103,7 +1116,7 @@ function showReport(reportData = {}) {
|
||||
addressHouse: reportData.addressHouse || '',
|
||||
patientBelong: reportData.patientBelong || 1,
|
||||
occupation: reportData.occupation || '',
|
||||
caseClass: reportData.caseClass != null ? String(reportData.caseClass) : '',
|
||||
caseClass: reportData.diseaseType != null ? String(reportData.diseaseType) : '',
|
||||
onsetDate: normalizeDate(reportData.onsetDate),
|
||||
diagDate: normalizeDate(reportData.diagDate),
|
||||
deathDate: normalizeDate(reportData.deathDate),
|
||||
@@ -1112,13 +1125,13 @@ function showReport(reportData = {}) {
|
||||
selectedClassB: diseaseSelection.selectedClassB,
|
||||
selectedClassC: diseaseSelection.selectedClassC,
|
||||
otherDisease: reportData.otherDisease || (diseaseCode === 'OTHER' ? reportData.diseaseName || '' : ''),
|
||||
diseaseType: reportData.diseaseType || '',
|
||||
diseaseType: reportData.diseaseSubtype || '',
|
||||
reportOrg: reportData.reportOrg || '',
|
||||
reportOrgPhone: reportData.reportOrgPhone || '',
|
||||
reportDoc: reportData.reportDoc || '',
|
||||
reportDate: normalizeDate(reportData.reportDate || reportData.createdAt),
|
||||
correctName: reportData.correctName || '',
|
||||
withdrawReason: reportData.withdrawReason || '',
|
||||
correctName: reportData.revisedDiseaseName || '',
|
||||
withdrawReason: reportData.returnReason || '',
|
||||
remark: reportData.remark || '',
|
||||
encounterId: reportData.encounterId || reportData.visitId || '',
|
||||
patientId: reportData.patientId || reportData.patId || '',
|
||||
@@ -1237,8 +1250,9 @@ function calculateAge() {
|
||||
* 显示对话框并初始化表单数据
|
||||
* @param {Object} diagnosisData - 诊断数据,包含已选疾病和地址信息
|
||||
*/
|
||||
function show(diagnosisData) {
|
||||
async function show(diagnosisData) {
|
||||
dialogVisible.value = true;
|
||||
dialogReadOnly.value = false;
|
||||
|
||||
// 重置地址选择器状态
|
||||
resetAddressSelector();
|
||||
@@ -1267,18 +1281,32 @@ function show(diagnosisData) {
|
||||
});
|
||||
}
|
||||
|
||||
// 生成默认卡片编号:医疗机构编码+当前年月日+4位流水
|
||||
// 生成默认卡片编号:调用后端接口获取
|
||||
const orgCode = userStore.fixmedinsCode || '0000';
|
||||
let cardNo = '';
|
||||
try {
|
||||
const res = await getNextCardNo(orgCode);
|
||||
if (res.code === 200 && res.data && res.data.length >= 12) {
|
||||
cardNo = res.data;
|
||||
} else {
|
||||
// API返回失败或不合规时,生成临时卡号避免保存时 cardNo 为空导致后端校验失败
|
||||
cardNo = 'TEMP_' + Date.now();
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取卡片编号失败:', err);
|
||||
// API调用异常时,生成临时卡号
|
||||
cardNo = 'TEMP_' + Date.now();
|
||||
}
|
||||
|
||||
form.value = {
|
||||
// 卡片编号:单位自编,与网络直报一致
|
||||
cardNo: '',
|
||||
cardNo: cardNo,
|
||||
|
||||
// 患者基本信息
|
||||
patName: patientInfo.patientName || patientInfo.name || '', // 患者姓名
|
||||
parentName: '', // 家长姓名(14岁以下患者必填)
|
||||
idNo: patientInfo.idCard, // 身份证号
|
||||
sex: patientInfo.sex || patientInfo.genderName || '男', // 性别
|
||||
sex: normalizeSexFromPatientInfo(patientInfo), // 性别
|
||||
|
||||
// 出生日期信息
|
||||
birthYear: birthInfo.year, // 出生年份
|
||||
@@ -1338,7 +1366,11 @@ function show(diagnosisData) {
|
||||
// 系统关联信息
|
||||
encounterId: patientInfo.encounterId || '', // 就诊ID
|
||||
patientId: patientInfo.patientId || '', // 患者ID
|
||||
diagnosisId: diagnosisData?.conditionId || diagnosisData?.definitionId || '', // 诊断ID
|
||||
diagnosisId: (diagnosisData?.conditionId != null && diagnosisData?.conditionId !== '')
|
||||
? diagnosisData.conditionId
|
||||
: (diagnosisData?.definitionId != null && diagnosisData?.definitionId !== '')
|
||||
? diagnosisData.definitionId
|
||||
: '', // 诊断ID
|
||||
};
|
||||
|
||||
// 更新selectedDiseases数组
|
||||
@@ -1379,6 +1411,9 @@ async function buildSubmitData() {
|
||||
} else if (formData.otherDisease) {
|
||||
// 其他传染病使用自定义编码
|
||||
diseaseCode = 'OTHER';
|
||||
} else if (formData.selectedDiseases && formData.selectedDiseases.length > 0) {
|
||||
// 兜底:如果 ClassA/B/C 都为空但 selectedDiseases 有值,取第一个作为 diseaseCode
|
||||
diseaseCode = formData.selectedDiseases[0];
|
||||
}
|
||||
|
||||
// 转换年龄单位:岁=1, 月=2, 天=3
|
||||
@@ -1393,7 +1428,7 @@ async function buildSubmitData() {
|
||||
const submitData = {
|
||||
cardNo: formData.cardNo,
|
||||
visitId: props.patientInfo?.encounterId || formData.encounterId || null,
|
||||
diagId: formData.diagnosisId || null,
|
||||
diagId: formData.diagnosisId ? Number(formData.diagnosisId) : null,
|
||||
patId: formData.patientId || null,
|
||||
idType: 1, // 默认身份证
|
||||
idNo: formData.idNo,
|
||||
@@ -1446,9 +1481,9 @@ async function buildSubmitData() {
|
||||
function validateFormManually() {
|
||||
const errors = [];
|
||||
|
||||
// 卡片编号验证(可选,但如果填写了必须是12位)
|
||||
if (form.value.cardNo && form.value.cardNo.length !== 12) {
|
||||
errors.push('卡片编号必须为12位');
|
||||
// 卡片编号验证(至少12位,后端自动生成16位编号;临时卡号 TEMP_ 开头允许通过)
|
||||
if (form.value.cardNo && !form.value.cardNo.startsWith('TEMP_') && form.value.cardNo.length < 12) {
|
||||
errors.push('卡片编号至少12位');
|
||||
}
|
||||
|
||||
// 身份证号验证
|
||||
@@ -1559,6 +1594,12 @@ async function handleSubmit() {
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查诊断ID是否有效(后端 @NotNull 校验要求)
|
||||
if (!form.value.diagnosisId) {
|
||||
proxy.$modal.msgError('诊断信息不完整,请重新选择诊断后重试');
|
||||
return;
|
||||
}
|
||||
|
||||
// 开始加载状态,防止重复提交
|
||||
submitLoading.value = true;
|
||||
|
||||
@@ -1782,6 +1823,33 @@ defineExpose({ show, showReport, close: handleClose });
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 输入框下划线样式(与 underline-select 保持一致) */
|
||||
.underline-input :deep(.el-input__wrapper) {
|
||||
border: none;
|
||||
border-bottom: 1px solid #dcdfe6;
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.underline-input :deep(.el-input__wrapper:hover) {
|
||||
border-bottom-color: #c0c4cc;
|
||||
}
|
||||
|
||||
.underline-input :deep(.el-input__wrapper.is-focus) {
|
||||
border-bottom-color: #409eff;
|
||||
}
|
||||
|
||||
.underline-input :deep(.el-input__inner) {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.underline-input :deep(.el-input__inner::placeholder) {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 街道下拉框下划线样式 */
|
||||
.underline-select {
|
||||
width: 100%;
|
||||
@@ -1969,4 +2037,53 @@ defineExpose({ show, showReport, close: handleClose });
|
||||
display: flex !important;
|
||||
justify-content: center !important;
|
||||
}
|
||||
|
||||
/* 性别单选按钮组 */
|
||||
.gender-radio-group {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
/* 出生日期输入组 */
|
||||
.birth-input-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.birth-input {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.birth-input.year {
|
||||
width: 70px;
|
||||
}
|
||||
|
||||
.birth-input.month,
|
||||
.birth-input.day {
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
.birth-separator {
|
||||
color: #606266;
|
||||
font-size: 13px;
|
||||
margin: 0 2px;
|
||||
}
|
||||
|
||||
/* 年龄输入组 */
|
||||
.age-input-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.age-input {
|
||||
width: 70px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.age-unit-select {
|
||||
width: 65px;
|
||||
}
|
||||
</style>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -56,6 +56,13 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="申请单号" prop="applyNo" min-width="160" align="center" header-align="center" />
|
||||
<el-table-column label="单据状态" prop="applyStatus" width="100" align="center" header-align="center">
|
||||
<template #default="scope">
|
||||
<el-tag :type="getStatusType(scope.row.applyStatus)" size="small">
|
||||
{{ getStatusLabel(scope.row.applyStatus, scope.row) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="检验项目" prop="itemName" min-width="170px" align="center" header-align="center">
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.itemName }}</span>
|
||||
@@ -1445,6 +1452,26 @@ const formatAmount = (amount) => {
|
||||
return num.toFixed(2)
|
||||
}
|
||||
|
||||
// 单据状态标签文字
|
||||
const getStatusLabel = (applyStatus, row) => {
|
||||
// applyStatus: 0=待开立, 1=已开立(已签发)
|
||||
// 结合收费/执行标记推导更丰富的状态
|
||||
if (applyStatus === 1) {
|
||||
// 已收费后根据执行标记判断
|
||||
if (row.needExecute === true) {
|
||||
return '已执行'
|
||||
}
|
||||
return '已开立'
|
||||
}
|
||||
return '待开立'
|
||||
}
|
||||
|
||||
// 单据状态标签颜色
|
||||
const getStatusType = (applyStatus) => {
|
||||
if (applyStatus === 1) return 'success'
|
||||
return 'info'
|
||||
}
|
||||
|
||||
// 格式化日期时间为字符串 YYYY-MM-DD HH:mm:ss
|
||||
const formatDateTime = (date) => {
|
||||
if (!date) return ''
|
||||
|
||||
@@ -109,6 +109,7 @@ const props = defineProps({
|
||||
});
|
||||
const { proxy } = getCurrentInstance();
|
||||
const encounterId = ref();
|
||||
const firstEnum = ref(1); // 初复诊标识:1=初诊,2=复诊
|
||||
onMounted(() => {
|
||||
getPatientList();
|
||||
});
|
||||
@@ -127,6 +128,7 @@ function getPatientList() {
|
||||
|
||||
function clickRow(row) {
|
||||
encounterId.value = row.encounterId;
|
||||
firstEnum.value = row.firstEnum ?? row.first_enum ?? 1;
|
||||
emits('cellClick', row);
|
||||
}
|
||||
|
||||
@@ -182,7 +184,7 @@ function handleComplete() {
|
||||
}
|
||||
proxy.$modal.confirm('是否完成该患者问诊?').then(() => {
|
||||
proxy.$modal.loading();
|
||||
completeEncounter(encounterId.value).then(() => {
|
||||
completeEncounter({ encounterId: encounterId.value, firstEnum: firstEnum.value }).then(() => {
|
||||
proxy.$modal.closeLoading();
|
||||
proxy.$modal.msgSuccess('完成问诊成功');
|
||||
getPatientList();
|
||||
|
||||
@@ -589,36 +589,46 @@ function handleUseOrderGroup(row) {
|
||||
minUnitPrice: orderDetail.minUnitPrice,
|
||||
inventoryList: orderDetail.inventoryList || [],
|
||||
priceList: orderDetail.priceList || [],
|
||||
partPercent: orderDetail.partPercent || 1,
|
||||
partPercent: orderDetail.partPercent ?? 1,
|
||||
partAttributeEnum: orderDetail.partAttributeEnum,
|
||||
unitConversionRatio: orderDetail.unitConversionRatio,
|
||||
// 🔧 Bug #218 修复:positionId 可能存储在 item 本身,优先使用 item.positionId
|
||||
positionId: item.positionId || orderDetail.positionId,
|
||||
positionId: item.positionId ?? orderDetail.positionId,
|
||||
defaultLotNumber: orderDetail.defaultLotNumber,
|
||||
|
||||
// 单位信息
|
||||
unitCode: item.unitCode || orderDetail.unitCode,
|
||||
unitCode: item.unitCode ?? orderDetail.unitCode,
|
||||
categoryCode: item.categoryCode ?? orderDetail.categoryCode,
|
||||
unitCodeName: item.unitCodeName || orderDetail.unitCode_dictText,
|
||||
minUnitCode: orderDetail.minUnitCode,
|
||||
doseUnitCode: orderDetail.doseUnitCode,
|
||||
|
||||
// 合并后的完整对象(用于 setValue)
|
||||
// 先展开 orderDetail 获取所有药品基础字段(categoryCode、minUnitCode、doseUnitCode、
|
||||
// partPercent、partAttributeEnum、unitConversionRatio、defaultLotNumber 等),
|
||||
// 再用组套用户覆盖值覆盖,确保单次剂量/频次/用法/用药天数/总量等不被丢失
|
||||
mergedDetail: {
|
||||
...orderDetail,
|
||||
adviceName: orderDetail.adviceName || item.orderDefinitionName || '未知项目',
|
||||
adviceType: orderDetail.adviceType,
|
||||
quantity: item.quantity,
|
||||
unitCode: item.unitCode || orderDetail.unitCode,
|
||||
unitCode: item.unitCode ?? orderDetail.unitCode,
|
||||
categoryCode: item.categoryCode ?? orderDetail.categoryCode,
|
||||
unitCodeName: item.unitCodeName,
|
||||
dose: item.dose || orderDetail.dose,
|
||||
rateCode: item.rateCode || orderDetail.rateCode,
|
||||
methodCode: item.methodCode || orderDetail.methodCode,
|
||||
dispensePerDuration: item.dispensePerDuration || orderDetail.dispensePerDuration,
|
||||
doseQuantity: item.doseQuantity,
|
||||
inventoryList: orderDetail.inventoryList || [],
|
||||
priceList: orderDetail.priceList || [],
|
||||
partPercent: orderDetail.partPercent || 1,
|
||||
// 🔧 Bug #218 修复:positionId 可能存储在 item 本身,优先使用 item.positionId
|
||||
positionId: item.positionId || orderDetail.positionId,
|
||||
defaultLotNumber: orderDetail.defaultLotNumber,
|
||||
dose: item.dose ?? orderDetail.dose,
|
||||
rateCode: item.rateCode ?? orderDetail.rateCode,
|
||||
methodCode: item.methodCode ?? orderDetail.methodCode,
|
||||
dispensePerDuration: item.dispensePerDuration ?? orderDetail.dispensePerDuration,
|
||||
doseQuantity: item.doseQuantity ?? orderDetail.doseQuantity,
|
||||
// 🔧 Bug #218 / #403 修复:positionId 可能存储在 item 本身,优先使用 item.positionId
|
||||
positionId: item.positionId ?? orderDetail.positionId,
|
||||
// 执行科室:优先使用组套明细中保存的 orgId
|
||||
orgId: item.orgId ?? orderDetail.orgId,
|
||||
orgName: item.orgName ?? orderDetail.orgName,
|
||||
// 组号(保留组套中的分组信息)
|
||||
groupId: item.groupId,
|
||||
groupOrder: item.groupOrder,
|
||||
therapyEnum: item.therapyEnum ?? orderDetail.therapyEnum ?? '1',
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -246,7 +246,8 @@
|
||||
<el-input-number :min="0" v-model="scope.row.doseQuantity" controls-position="right"
|
||||
:controls="false" style="width: 70px; margin-right: 20px"
|
||||
:ref="(el) => (inputRefs.doseQuantity = el)" @input="convertValues(scope.row, scope.$index)"
|
||||
@keyup.enter.prevent="handleEnter('doseQuantity', scope.row, scope.$index)" />
|
||||
@keyup.enter.prevent="handleEnter('doseQuantity', scope.row, scope.$index)"
|
||||
@change="calculateTotalAmount(scope.row, scope.$index)"/>
|
||||
</el-form-item>
|
||||
<!-- 剂量单位 -->
|
||||
<el-select v-model="scope.row.minUnitCode" style="width: 70px; margin-right: 20px" placeholder=" ">
|
||||
@@ -294,7 +295,8 @@
|
||||
}
|
||||
// inputRefs.rateCode.blur();
|
||||
}
|
||||
" :ref="(el) => (inputRefs.rateCode = el)">
|
||||
" :ref="(el) => (inputRefs.rateCode = el)"
|
||||
@change="calculateTotalAmount(scope.row, scope.$index)">
|
||||
<el-option v-for="dict in rate_code" @click="() => (scope.row.rateCode_dictText = dict.label)"
|
||||
:key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
@@ -313,6 +315,8 @@
|
||||
data-prop="dispensePerDuration">
|
||||
<el-input-number v-model="scope.row.dispensePerDuration" style="width: 80px" :min="1"
|
||||
controls-position="right" :controls="false" :ref="(el) => (inputRefs.dispensePerDuration = el)"
|
||||
@input="calculateTotalAmount(scope.row, scope.$index)"
|
||||
@change="calculateTotalAmount(scope.row, scope.$index)"
|
||||
@keyup.enter.prevent="
|
||||
handleEnter('dispensePerDuration', scope.row, scope.$index)
|
||||
">
|
||||
@@ -871,7 +875,7 @@ import { ArrowDown, Search, Memo, Minus, Plus, Edit, Delete } from '@element-plu
|
||||
import printUtils, { getPrinterList, PRINT_TEMPLATE, savePrinterToCache, } from '@/utils/printUtils';
|
||||
import Template from "@/views/inpatientDoctor/home/emr/components/template.vue";
|
||||
|
||||
const emit = defineEmits(['selectDiagnosis']);
|
||||
const emit = defineEmits(['selectDiagnosis', 'inspectionListRefresh']);
|
||||
const total = ref(0);
|
||||
const queryParams = ref({});
|
||||
const prescriptionList = ref([]);
|
||||
@@ -1010,15 +1014,29 @@ const mapAdviceTypeLabel = (type, adviceTableName) => {
|
||||
if (type === 2 && adviceTableName === 'adm_device_definition') {
|
||||
return '耗材';
|
||||
}
|
||||
|
||||
|
||||
// 🔧 Bug Fix: 处理检查类型(adviceType=23)
|
||||
// 检查类型属于诊疗类,应该显示为"检查"
|
||||
if (type === 23) {
|
||||
return '检查';
|
||||
}
|
||||
|
||||
|
||||
const found = adviceTypeList.value.find((item) => item.value === type);
|
||||
return found ? found.label : '';
|
||||
if (found) {
|
||||
return found.label;
|
||||
}
|
||||
|
||||
// 🔧 Bug #458 Fix: 诊疗/手术类型字典缺失时的兜底,避免保存后"医嘱类型"列显示为空
|
||||
if (adviceTableName === 'wor_activity_definition' || adviceTableName === 'wor_service_request') {
|
||||
if (type === 6) return '手术';
|
||||
if (type === 4) return '手术';
|
||||
if (type === 1) return '检验';
|
||||
if (type === 2) return '检查';
|
||||
if (type === 5) return '其他';
|
||||
return '诊疗';
|
||||
}
|
||||
|
||||
return '';
|
||||
};
|
||||
|
||||
// 西药处方管理相关变量
|
||||
@@ -2066,6 +2084,21 @@ function getOrgList() {
|
||||
});
|
||||
}
|
||||
|
||||
/** 诊疗医嘱关联检验申请时 contentJson 含 applyNo */
|
||||
function getInspectionApplyNoFromAdviceRow(row) {
|
||||
if (!row || row.adviceType !== 3) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
const raw = row.contentJson;
|
||||
const j = raw ? (typeof raw === 'string' ? JSON.parse(raw) : raw) : {};
|
||||
const no = j && j.applyNo != null ? String(j.applyNo).trim() : '';
|
||||
return no || null;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function handleDelete() {
|
||||
let selectRows = prescriptionRef.value.getSelectionRows();
|
||||
console.log('BugFix#219: handleDelete called, selectRows=', selectRows);
|
||||
@@ -2245,12 +2278,31 @@ function handleDelete() {
|
||||
}
|
||||
|
||||
if (deleteList.length > 0) {
|
||||
savePrescription({ adviceSaveList: deleteList }).then((res) => {
|
||||
if (res.code == 200) {
|
||||
proxy.$modal.msgSuccess('删除成功');
|
||||
getListInfo(false);
|
||||
}
|
||||
const hasLabLinked = deleteList.some((d) => {
|
||||
const row = normalRows.find((r) => r.requestId === d.requestId);
|
||||
return row && getInspectionApplyNoFromAdviceRow(row);
|
||||
});
|
||||
const runApiDelete = () => {
|
||||
savePrescription({ adviceSaveList: deleteList }).then((res) => {
|
||||
if (res.code == 200) {
|
||||
proxy.$modal.msgSuccess('删除成功');
|
||||
getListInfo(false);
|
||||
emit('inspectionListRefresh');
|
||||
}
|
||||
});
|
||||
};
|
||||
if (hasLabLinked) {
|
||||
proxy.$modal
|
||||
.confirm(
|
||||
'删除此医嘱将同时作废关联的检验申请单(检验页签中的同单申请及同单下相关医嘱)。是否继续?',
|
||||
'删除确认',
|
||||
{ type: 'warning' }
|
||||
)
|
||||
.then(runApiDelete)
|
||||
.catch(() => {});
|
||||
} else {
|
||||
runApiDelete();
|
||||
}
|
||||
} else if (consultationRows.length == 0) {
|
||||
proxy.$modal.msgWarning('所选医嘱不可删除,请先撤回后再删除');
|
||||
return;
|
||||
@@ -2492,11 +2544,13 @@ function handleSave(prescriptionId) {
|
||||
|
||||
// 🔧 BugFix#318: 从 parsedContent 提取标准医嘱字段,排除手术特有字段
|
||||
const standardFields = [
|
||||
'accountId', 'chargeItemId', 'conditionDefinitionId', 'conditionId',
|
||||
'contentJson', 'definitionDetailId', 'definitionId', 'diagnosisName',
|
||||
'dosageInstruction', 'effectiveOrgId', 'encounterDiagnosisId',
|
||||
'encounterId', 'lotNumber', 'patientId', 'practitionerId',
|
||||
'prescriptionNo', 'skinTestFlag', 'unitPrice', 'volume', 'ybClassEnum'
|
||||
'accountId', 'chargeItemId', 'conditionDefinitionId', 'conditionId',
|
||||
'contentJson', 'definitionDetailId', 'definitionId', 'diagnosisName',
|
||||
'dosageInstruction', 'effectiveOrgId', 'encounterDiagnosisId',
|
||||
'encounterId', 'lotNumber', 'patientId', 'practitionerId',
|
||||
'prescriptionNo', 'skinTestFlag', 'unitPrice', 'volume', 'ybClassEnum',
|
||||
// 🔧 Bug Fix: 添加 therapyEnum 字段(医嘱类型:1=长期, 2=临时)
|
||||
'therapyEnum'
|
||||
];
|
||||
let filteredContent = {};
|
||||
standardFields.forEach(field => {
|
||||
@@ -3140,7 +3194,9 @@ function handleSaveBatch(prescriptionId) {
|
||||
// 🔧 Bug Fix: 添加 definitionId 和 definitionDetailId 字段
|
||||
'definitionId', 'definitionDetailId',
|
||||
// 🔧 Bug Fix: 添加 categoryEnum 字段(耗材必填)
|
||||
'categoryEnum'
|
||||
'categoryEnum',
|
||||
// 🔧 Bug Fix: 添加 therapyEnum 字段(医嘱类型:1=长期, 2=临时)
|
||||
'therapyEnum'
|
||||
];
|
||||
let filteredItem = {};
|
||||
standardItemFields.forEach(field => {
|
||||
@@ -3305,9 +3361,13 @@ function syncGroupFields(row) {
|
||||
}
|
||||
|
||||
// 同步执行科室
|
||||
// 🔧 Bug #455: 诊疗类医嘱(adviceType=3)不使用项目配置的执行科室,
|
||||
// 避免配置ID不在机构树中导致显示原始ID,保持患者就诊科室即可
|
||||
if (row.orgId || row.positionId) {
|
||||
// 🔧 修复:优先使用项目所属科室(orgId),其次positionId
|
||||
prescriptionList.value[rowIndex.value].orgId = row.orgId || row.positionId;
|
||||
if (Number(row.adviceType) != 3) {
|
||||
// 🔧 修复:优先使用项目所属科室(orgId),其次positionId
|
||||
prescriptionList.value[rowIndex.value].orgId = row.orgId || row.positionId;
|
||||
}
|
||||
}
|
||||
|
||||
// 同步皮试标记
|
||||
@@ -3339,7 +3399,7 @@ function syncGroupFields(row) {
|
||||
}
|
||||
}
|
||||
|
||||
function setValue(row) {
|
||||
async function setValue(row) {
|
||||
unitCodeList.value = [];
|
||||
unitCodeList.value.push({ value: row.unitCode, label: row.unitCode_dictText, type: 'unit' });
|
||||
|
||||
@@ -3391,8 +3451,16 @@ function setValue(row) {
|
||||
showPopover: false, // 确保查询框关闭
|
||||
};
|
||||
console.log('[BugFix] setValue - prescriptionList[rowIndex].adviceType_dictText:', prescriptionList.value[rowIndex.value].adviceType_dictText);
|
||||
// 🔧 修复执行科室逻辑:优先使用项目维护的所属科室(row.orgId),其次使用positionId,最后回退到患者科室
|
||||
prescriptionList.value[rowIndex.value].orgId = row.orgId || row.positionId || props.patientInfo?.orgId;
|
||||
// 🔧 Bug #455: 诊疗医嘱(adviceType=3)的执行科室默认使用患者就诊科室,
|
||||
// 不使用positionId(诊疗目录配置的执行科室),避免配置ID不在机构树中导致显示原始ID
|
||||
if (Number(row.adviceType) == 3) {
|
||||
// 覆盖 catalog 传来的 positionId/orgId,使用患者就诊科室
|
||||
prescriptionList.value[rowIndex.value].orgId = props.patientInfo?.orgId;
|
||||
prescriptionList.value[rowIndex.value].positionId = props.patientInfo?.orgId;
|
||||
prescriptionList.value[rowIndex.value].positionName = findOrgNameById(props.patientInfo?.orgId) || props.patientInfo?.orgName || '';
|
||||
} else {
|
||||
prescriptionList.value[rowIndex.value].orgId = row.positionId || props.patientInfo?.orgId;
|
||||
}
|
||||
prescriptionList.value[rowIndex.value].dose = row.dose || row.doseQuantity;
|
||||
prescriptionList.value[rowIndex.value].quantity = row.quantity || 1;
|
||||
prescriptionList.value[rowIndex.value].unitCodeList = unitCodeList.value;
|
||||
@@ -3407,7 +3475,11 @@ function setValue(row) {
|
||||
prescriptionList.value[rowIndex.value].unitCode =
|
||||
row.partAttributeEnum == 1 ? row.minUnitCode : row.unitCode;
|
||||
}
|
||||
prescriptionList.value[rowIndex.value].categoryEnum = row.categoryCode;
|
||||
// 🔧 Bug Fix #456: 诊疗类医嘱(adviceType=3)不应将categoryCode赋值给categoryEnum,
|
||||
// 否则保存后SQL查询会根据category_enum=2(检查目录)将类型误判为"检查"
|
||||
if (row.adviceType != 3) {
|
||||
prescriptionList.value[rowIndex.value].categoryEnum = row.activityType;
|
||||
}
|
||||
prescriptionList.value[rowIndex.value].skinTestFlag = row.skinTestFlag;
|
||||
prescriptionList.value[rowIndex.value].definitionId = row.chargeItemDefinitionId;
|
||||
prescriptionList.value[rowIndex.value].executeNum = 1;
|
||||
@@ -3478,7 +3550,7 @@ function setValue(row) {
|
||||
// 🔧 Bug Fix: 设置耗材的minUnitQuantity,避免保存时null错误
|
||||
prescriptionList.value[rowIndex.value].minUnitQuantity = row.quantity || 1;
|
||||
// 🔧 Bug Fix: 设置耗材的categoryEnum,避免数据库约束错误
|
||||
prescriptionList.value[rowIndex.value].categoryEnum = row.categoryCode || 3; // 默认为3
|
||||
prescriptionList.value[rowIndex.value].categoryEnum = row.activityType || 3; // 默认为3
|
||||
prescriptionList.value[rowIndex.value].positionName = row.positionName || '';
|
||||
// 🔧 Bug Fix: 使用 positionId,如果为空则使用患者信息中的 orgId
|
||||
console.log('设置耗材locationId:', {
|
||||
@@ -3500,14 +3572,14 @@ function setValue(row) {
|
||||
// 🔧 Bug Fix: 设置耗材的minUnitQuantity,避免保存时null错误
|
||||
prescriptionList.value[rowIndex.value].minUnitQuantity = row.quantity || 1;
|
||||
// 🔧 Bug Fix: 设置耗材的categoryEnum,避免数据库约束错误
|
||||
prescriptionList.value[rowIndex.value].categoryEnum = row.categoryCode || 3; // 默认为3
|
||||
prescriptionList.value[rowIndex.value].categoryEnum = row.activityType || 3; // 默认为3
|
||||
prescriptionList.value[rowIndex.value].positionName = row.positionName || '';
|
||||
const finalLocationId = row.positionId || props.patientInfo.orgId;
|
||||
prescriptionList.value[rowIndex.value].locationId = finalLocationId;
|
||||
prescriptionList.value[rowIndex.value].positionId = finalLocationId;
|
||||
}
|
||||
} else {
|
||||
getOrgList();
|
||||
await getOrgList();
|
||||
// 会诊类型(adviceType == 5)和诊疗类型(adviceType == 3)的处理
|
||||
if (row.adviceType == 5) {
|
||||
// 会诊类型:设置默认值
|
||||
@@ -3519,13 +3591,10 @@ function setValue(row) {
|
||||
prescriptionList.value[rowIndex.value].categoryEnum = 31; // 会诊的category_enum设置为31
|
||||
} else {
|
||||
// 诊疗类型(adviceType == 3)
|
||||
// 🔧 Bug Fix #238: 诊疗项目默认使用患者就诊科室
|
||||
if (!prescriptionList.value[rowIndex.value].orgId) {
|
||||
prescriptionList.value[rowIndex.value].orgId = props.patientInfo.orgId;
|
||||
}
|
||||
if (!prescriptionList.value[rowIndex.value].positionName) {
|
||||
prescriptionList.value[rowIndex.value].positionName = findOrgNameById(prescriptionList.value[rowIndex.value].orgId) || props.patientInfo.orgName || '';
|
||||
}
|
||||
// 🔧 Bug #455: 诊疗项目执行科室强制使用患者就诊科室,
|
||||
// 不使用目录配置的执行科室(可能是错误ID或占位符,导致显示原始ID)
|
||||
prescriptionList.value[rowIndex.value].orgId = props.patientInfo.orgId;
|
||||
prescriptionList.value[rowIndex.value].positionName = findOrgNameById(props.patientInfo.orgId) || props.patientInfo.orgName || '';
|
||||
// 🔧 Bug #218 修复:使用组套中维护的quantity,如果没有则默认1
|
||||
prescriptionList.value[rowIndex.value].quantity = row.quantity || 1;
|
||||
// 🔧 Bug #144 修复:安全访问 priceList,防止 orderDetailInfos 为空时出错
|
||||
@@ -3620,7 +3689,10 @@ function handleSaveGroup(orderGroupList) {
|
||||
unitCode_dictText: item.unitCodeName || '',
|
||||
statusEnum: 1,
|
||||
// 🔧 修复执行科室逻辑:优先使用 orgId(所属科室),其次 positionId
|
||||
orgId: item.orderDetailInfos?.orgId || mergedDetail.orgId || item.positionId || item.orderDetailInfos?.positionId || mergedDetail.positionId,
|
||||
// 🔧 Bug #455: 诊疗类(adviceType=3)使用患者就诊科室,不使用目录配置的ID
|
||||
orgId: item.adviceType === 3
|
||||
? props.patientInfo?.orgId
|
||||
: (item.orderDetailInfos?.orgId || mergedDetail.orgId || item.positionId || item.orderDetailInfos?.positionId || mergedDetail.positionId),
|
||||
dbOpType: prescriptionList.value[rowIndex.value].requestId ? '2' : '1',
|
||||
conditionId: conditionId.value,
|
||||
conditionDefinitionId: conditionDefinitionId.value,
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
|
||||
|
||||
<!-- 手术单号 -->
|
||||
<el-table-column label="手术单号" align="center" width="150">
|
||||
<template #default="scope">
|
||||
@@ -33,30 +33,31 @@
|
||||
</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
|
||||
<!-- 申请日期 -->
|
||||
<el-table-column label="申请日期" align="center" prop="createTime" width="180">
|
||||
<template #default="scope">
|
||||
{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
|
||||
<!-- 患者姓名 -->
|
||||
<el-table-column label="患者姓名" align="center" prop="patientName" width="100" />
|
||||
|
||||
|
||||
<!-- 申请医生 -->
|
||||
<el-table-column label="申请医生" align="center" prop="applyDoctorName" width="100" />
|
||||
|
||||
|
||||
<!-- 申请科室 -->
|
||||
<el-table-column label="申请科室" align="center" prop="applyDeptName" width="120" show-overflow-tooltip />
|
||||
|
||||
|
||||
<!-- 手术名称 -->
|
||||
<el-table-column label="手术名称" align="center" prop="surgeryName" min-width="150" show-overflow-tooltip />
|
||||
|
||||
|
||||
<!-- 手术等级 -->
|
||||
<el-table-column label="手术等级" align="center" prop="surgeryLevel_dictText" width="100" />
|
||||
|
||||
|
||||
<!-- 手术室确认时间 -->
|
||||
|
||||
<el-table-column label="手术室确认时间" align="center" prop="operatingRoomConfirmTime" width="180">
|
||||
<template #default="scope">
|
||||
{{ scope.row.operatingRoomConfirmTime ? parseTime(scope.row.operatingRoomConfirmTime, '{y}-{m}-{d} {h}:{i}:{s}') : '-' }}
|
||||
@@ -74,16 +75,16 @@
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
|
||||
<!-- 操作 -->
|
||||
<el-table-column label="操作" align="center" width="200" fixed="right">
|
||||
<template #default="scope">
|
||||
<!-- 查看:显示手术申请详情(只读模式) -->
|
||||
<el-button link type="primary" icon="View" @click="handleView(scope.row)">查看</el-button>
|
||||
|
||||
|
||||
<!-- 编辑:修改手术申请信息(只有状态为新开的能修改) -->
|
||||
<el-button link type="primary" icon="Edit" @click="handleEdit(scope.row)" v-if="scope.row.statusEnum === 0">编辑</el-button>
|
||||
|
||||
|
||||
<!-- 删除:取消手术申请(作废) -->
|
||||
<el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)" v-if="scope.row.statusEnum === 0 || scope.row.statusEnum === 1">删除</el-button>
|
||||
</template>
|
||||
@@ -166,14 +167,11 @@
|
||||
<el-select
|
||||
v-model="form.surgeryName"
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
placeholder="请输入关键词搜索手术"
|
||||
:remote-method="remoteSearchSurgery"
|
||||
:loading="surgeryLoading"
|
||||
:filter-method="filterSurgery"
|
||||
style="width: 100%"
|
||||
@change="handleSurgeryChange"
|
||||
@focus="() => remoteSearchSurgery('')"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in surgeryNameList"
|
||||
@@ -219,14 +217,11 @@
|
||||
<el-select
|
||||
v-model="scope.row.surgeryName"
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
placeholder="搜索次要手术"
|
||||
:remote-method="remoteSearchSurgery"
|
||||
:loading="surgeryLoading"
|
||||
:filter-method="filterSurgery"
|
||||
style="width: 100%"
|
||||
@change="(val) => handleSecondarySurgeryChange(val, scope.row)"
|
||||
@focus="() => remoteSearchSurgery('')"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in surgeryNameList"
|
||||
@@ -264,14 +259,11 @@
|
||||
<el-select
|
||||
v-model="scope.row.anesthesiaName"
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
placeholder="搜索麻醉"
|
||||
:remote-method="remoteSearchAnesthesia"
|
||||
:loading="anesthesiaLoading"
|
||||
:filter-method="filterAnesthesia"
|
||||
style="width: 100%"
|
||||
@change="(val) => handleSecondaryAnesthesiaChange(val, scope.row)"
|
||||
@focus="() => remoteSearchAnesthesia('')"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in anesthesiaNameList"
|
||||
@@ -519,6 +511,10 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
const loading = ref(true)
|
||||
const surgeryLoading = ref(false)
|
||||
const anesthesiaLoading = ref(false)
|
||||
let surgerySearchTimer = null
|
||||
let anesthesiaSearchTimer = null
|
||||
const surgeryList = ref([])
|
||||
const open = ref(false)
|
||||
const viewOpen = ref(false)
|
||||
@@ -560,12 +556,8 @@ const title = ref('')
|
||||
const doctorList = ref([])
|
||||
const surgeryNameList = ref([])
|
||||
const anesthesiaNameList = ref([])
|
||||
const surgeryLoading = ref(false)
|
||||
const anesthesiaLoading = ref(false)
|
||||
|
||||
// 防抖定时器
|
||||
let surgerySearchTimer = null
|
||||
let anesthesiaSearchTimer = null
|
||||
const allSurgeryItems = ref([])
|
||||
const allAnesthesiaItems = ref([])
|
||||
|
||||
// 计算总费用
|
||||
const totalCalculatedFee = computed(() => {
|
||||
@@ -624,6 +616,7 @@ watch(() => props.patientInfo, (newVal) => {
|
||||
// 挂载时加载医生列表
|
||||
onMounted(() => {
|
||||
loadDoctorList()
|
||||
loadSurgeryAndAnesthesiaOptions()
|
||||
})
|
||||
|
||||
// 获取手术申请列表
|
||||
@@ -633,14 +626,19 @@ function getList() {
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
loading.value = true
|
||||
getSurgeryPage({
|
||||
pageNo: 1,
|
||||
pageSize: 100,
|
||||
encounterId: props.patientInfo.encounterId
|
||||
}).then((res) => {
|
||||
surgeryList.value = res.data.records || []
|
||||
if (res.code === 200) {
|
||||
surgeryList.value = res.data?.records || []
|
||||
} else {
|
||||
proxy.$modal.msgError(res.msg || '数据加载失败,请稍后重试')
|
||||
surgeryList.value = []
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('获取手术列表失败:', error)
|
||||
proxy.$modal.msgError('数据加载失败,请稍后重试')
|
||||
@@ -967,6 +965,60 @@ function doSearchAnesthesia(query) {
|
||||
})
|
||||
}
|
||||
|
||||
// 本地过滤手术项目
|
||||
function filterSurgery(query) {
|
||||
if (!query) {
|
||||
surgeryNameList.value = allSurgeryItems.value
|
||||
} else {
|
||||
surgeryNameList.value = allSurgeryItems.value.filter(item =>
|
||||
(item.name && item.name.toLowerCase().includes(query.toLowerCase())) ||
|
||||
(item.busNo && item.busNo.toLowerCase().includes(query.toLowerCase()))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// 本地过滤麻醉项目
|
||||
function filterAnesthesia(query) {
|
||||
if (!query) {
|
||||
anesthesiaNameList.value = allAnesthesiaItems.value
|
||||
} else {
|
||||
anesthesiaNameList.value = allAnesthesiaItems.value.filter(item =>
|
||||
(item.name && item.name.toLowerCase().includes(query.toLowerCase())) ||
|
||||
(item.busNo && item.busNo.toLowerCase().includes(query.toLowerCase()))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// 加载手术和麻醉全量数据供本地过滤
|
||||
function loadSurgeryAndAnesthesiaOptions() {
|
||||
getDiagnosisTreatmentList({
|
||||
searchKey: '',
|
||||
pageNo: 1,
|
||||
pageSize: 1000
|
||||
}).then(res => {
|
||||
let data = []
|
||||
if (res.data && res.data.records) {
|
||||
data = res.data.records
|
||||
} else if (res.data && Array.isArray(res.data)) {
|
||||
data = res.data
|
||||
} else if (res.records && Array.isArray(res.records)) {
|
||||
data = res.records
|
||||
}
|
||||
allSurgeryItems.value = data.filter(item =>
|
||||
(item.categoryCode === '24' || item.categoryCode_dictText === '手术') &&
|
||||
(item.statusEnum === 2 || item.statusEnum_enumText === '启用' || !item.statusEnum)
|
||||
)
|
||||
allAnesthesiaItems.value = data.filter(item =>
|
||||
(item.categoryCode === '25' || item.categoryCode_dictText === '麻醉') &&
|
||||
(item.statusEnum === 2 || item.statusEnum_enumText === '启用' || !item.statusEnum)
|
||||
)
|
||||
surgeryNameList.value = allSurgeryItems.value
|
||||
anesthesiaNameList.value = allAnesthesiaItems.value
|
||||
}).catch(error => {
|
||||
console.error('加载手术/麻醉选项失败:', error)
|
||||
})
|
||||
}
|
||||
|
||||
// 手术项目选择变更
|
||||
function handleSurgeryChange(val) {
|
||||
// 🔧 BugFix#318: 确保 surgeryName 被正确设置
|
||||
@@ -1086,12 +1138,12 @@ function submitForm() {
|
||||
// 新增手术
|
||||
addSurgery(form.value).then((res) => {
|
||||
if (res.code === 200) {
|
||||
proxy.$modal.msgSuccess(res.msg || '新增成功')
|
||||
proxy.$modal.msgSuccess('手术申请提交成功!')
|
||||
// 保存麻醉方式
|
||||
sessionStorage.setItem('anesthesiaType', form.value.anesthesiaTypeEnum)
|
||||
open.value = false
|
||||
getList()
|
||||
emit('saved') // 🔧 触发保存事件,通知父组件刷新医嘱列表
|
||||
getList() // 提交成功后直接刷新列表
|
||||
emit('saved') // 通知父组件刷新医嘱列表
|
||||
} else {
|
||||
proxy.$modal.msgError(res.msg || '新增手术失败,请检查表单信息')
|
||||
}
|
||||
@@ -1103,12 +1155,12 @@ function submitForm() {
|
||||
// 修改手术
|
||||
updateSurgery(form.value).then((res) => {
|
||||
if (res.code === 200) {
|
||||
proxy.$modal.msgSuccess(res.msg || '修改成功')
|
||||
proxy.$modal.msgSuccess('手术申请修改成功!')
|
||||
// 保存麻醉方式
|
||||
sessionStorage.setItem('anesthesiaType', form.value.anesthesiaTypeEnum)
|
||||
open.value = false
|
||||
getList()
|
||||
emit('saved') // 🔧 触发保存事件,通知父组件刷新医嘱列表
|
||||
getList() // 修改成功后直接刷新列表
|
||||
emit('saved') // 通知父组件刷新医嘱列表
|
||||
} else {
|
||||
proxy.$modal.msgError(res.msg || '更新手术失败,请检查表单信息')
|
||||
}
|
||||
|
||||
@@ -138,7 +138,8 @@
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="医嘱" name="prescription">
|
||||
<prescriptionlist :patientInfo="patientInfo" ref="prescriptionRef" :activeTab="activeTab"
|
||||
:outpatientEmrSaved="outpatientEmrSaved" />
|
||||
:outpatientEmrSaved="outpatientEmrSaved"
|
||||
@inspectionListRefresh="refreshInspectionListFromAdvice" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="中医" name="tcm">
|
||||
<tcmAdvice :patientInfo="patientInfo" ref="tcmRef" />
|
||||
@@ -151,8 +152,8 @@
|
||||
@saved="() => prescriptionRef?.getListInfo()" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="手术申请" name="surgery">
|
||||
<surgeryApplication :patientInfo="patientInfo" :activeTab="activeTab" ref="surgeryRef"
|
||||
@saved="() => prescriptionRef?.getListInfo()" />
|
||||
<surgeryApplication :patientInfo="patientInfo" :activeTab="activeTab" ref="surgeryRef"
|
||||
@saved="() => { prescriptionRef?.getListInfo(); surgeryRef?.getList() }" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="电子处方" name="eprescription">
|
||||
<eprescriptionlist :patientInfo="patientInfo" ref="eprescriptionRef" />
|
||||
@@ -312,6 +313,9 @@ const patientDrawerRef = ref();
|
||||
const prescriptionRef = ref();
|
||||
const tcmRef = ref();
|
||||
const inspectionRef = ref();
|
||||
function refreshInspectionListFromAdvice() {
|
||||
inspectionRef.value?.getList?.();
|
||||
}
|
||||
const examinationRef = ref();
|
||||
const surgeryRef = ref();
|
||||
const emrRef = ref();
|
||||
|
||||
@@ -151,23 +151,12 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-dialog
|
||||
v-model="detailVisible"
|
||||
:title="detailMode === 'view' ? '报卡详情 - 中华人民共和国传染病报告卡' : '编辑报卡 - 中华人民共和国传染病报告卡'"
|
||||
width="1100px"
|
||||
destroy-on-close
|
||||
class="card-detail-dialog"
|
||||
>
|
||||
<InfectiousReport
|
||||
:mode=" detailMode"
|
||||
:card-data="currentCard"
|
||||
@submit-edit="handleSaveEdit"
|
||||
style="max-height: 75vh; overflow-y: auto;"
|
||||
/>
|
||||
<template #footer>
|
||||
<el-button @click="detailVisible = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<InfectiousDiseaseReportDialog
|
||||
ref="infectiousDiseaseReportRef"
|
||||
:read-only="detailMode === 'view'"
|
||||
@success="detailVisible = false"
|
||||
@close="detailVisible = false"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -175,7 +164,7 @@
|
||||
import { ref, reactive, onMounted, onActivated, onBeforeUnmount, nextTick, computed } from 'vue';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { DataAnalysis, Warning, CircleCheck, Check, RefreshRight } from '@element-plus/icons-vue';
|
||||
import InfectiousReport from '../components/infectiousReport/index.vue';
|
||||
import InfectiousDiseaseReportDialog from '../components/diagnosis/infectiousDiseaseReportDialog.vue';
|
||||
import {
|
||||
getDoctorCardStatistics,
|
||||
getDoctorCardList,
|
||||
@@ -185,7 +174,6 @@ import {
|
||||
batchDeleteCards,
|
||||
exportCardToWord,
|
||||
getCardDetail,
|
||||
updateDoctorCard,
|
||||
} from './api';
|
||||
|
||||
const loading = ref(false);
|
||||
@@ -211,7 +199,7 @@ const queryParams = reactive({
|
||||
|
||||
const detailVisible = ref(false);
|
||||
const detailMode = ref('view');
|
||||
const currentCard = ref({});
|
||||
const infectiousDiseaseReportRef = ref(null);
|
||||
|
||||
// 计算表格高度:根据视口高度动态调整
|
||||
const tableHeight = computed(() => {
|
||||
@@ -327,9 +315,11 @@ async function handleView(row) {
|
||||
try {
|
||||
const res = await getCardDetail(row.cardNo);
|
||||
if (res.code === 200) {
|
||||
currentCard.value = res.data || {};
|
||||
detailMode.value = 'view';
|
||||
detailVisible.value = true;
|
||||
nextTick(() => {
|
||||
infectiousDiseaseReportRef.value?.showReport(res.data || {});
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
ElMessage.error('获取详情失败');
|
||||
@@ -340,57 +330,17 @@ async function handleEdit(row) {
|
||||
try {
|
||||
const res = await getCardDetail(row.cardNo);
|
||||
if (res.code === 200) {
|
||||
currentCard.value = res.data || {};
|
||||
detailMode.value = 'edit';
|
||||
detailVisible.value = true;
|
||||
nextTick(() => {
|
||||
infectiousDiseaseReportRef.value?.showReport(res.data || {}, false);
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
ElMessage.error('获取详情失败');
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSaveEdit(submitData) {
|
||||
// submitData 来自 InfectiousReport 组件的 submit-edit 事件
|
||||
try {
|
||||
const updateData = {
|
||||
cardNo: submitData.cardNo,
|
||||
phone: submitData.phone,
|
||||
contactPhone: submitData.contactPhone,
|
||||
onsetDate: submitData.onsetDate,
|
||||
diagDate: submitData.diagDate,
|
||||
diseaseCode: submitData.diseaseCode,
|
||||
diseaseType: submitData.diseaseType,
|
||||
otherDisease: submitData.otherDisease,
|
||||
caseClass: submitData.caseClass,
|
||||
occupation: submitData.occupation,
|
||||
patientBelong: submitData.patientBelong,
|
||||
addressProv: submitData.addressProv,
|
||||
addressCity: submitData.addressCity,
|
||||
addressCounty: submitData.addressCounty,
|
||||
addressTown: submitData.addressTown,
|
||||
addressVillage: submitData.addressVillage,
|
||||
addressHouse: submitData.addressHouse,
|
||||
workplace: submitData.workplace,
|
||||
parentName: submitData.parentName,
|
||||
deathDate: submitData.deathDate,
|
||||
correctName: submitData.correctName,
|
||||
withdrawReason: submitData.withdrawReason,
|
||||
remark: submitData.remark,
|
||||
};
|
||||
|
||||
const res = await updateDoctorCard(updateData);
|
||||
if (res.code === 200) {
|
||||
ElMessage.success('保存成功');
|
||||
detailVisible.value = false;
|
||||
getList();
|
||||
} else {
|
||||
ElMessage.error(res.msg || '保存失败');
|
||||
}
|
||||
} catch (error) {
|
||||
ElMessage.error('保存失败:' + (error.message || '网络错误'));
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit(row) {
|
||||
try {
|
||||
await ElMessageBox.confirm('确认提交该报卡?', '提示', {
|
||||
@@ -800,17 +750,4 @@ function handleResize() {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* 报卡详情弹窗 */
|
||||
:deep(.card-detail-dialog .el-dialog__body) {
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:deep(.card-detail-dialog .infectious-report-container) {
|
||||
padding: 16px;
|
||||
height: auto;
|
||||
max-height: 70vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
@@ -51,7 +51,7 @@ const currentSelectRow = ref<any>({});
|
||||
const queryParams = ref({
|
||||
pageSize: 100,
|
||||
pageNo: 1,
|
||||
adviceTypes: '1,2,3,6',
|
||||
adviceTypes: [1, 2, 3, 6],
|
||||
searchKey: '',
|
||||
organizationId: '',
|
||||
categoryCode: '',
|
||||
@@ -88,10 +88,10 @@ const tableColumns = computed<TableColumn[]>(() => [
|
||||
function refresh(adviceType: any, categoryCode: string, searchKey: string) {
|
||||
// 有搜索词时跨类型搜索,避免用户输入"级护理"但因当前adviceType为药品而搜不到诊疗类护理项目
|
||||
if (searchKey) {
|
||||
queryParams.value.adviceTypes = '1,2,3,6';
|
||||
queryParams.value.adviceTypes = [1, 2, 3, 6];
|
||||
} else {
|
||||
queryParams.value.adviceTypes =
|
||||
adviceType !== undefined && adviceType !== '' ? String(adviceType) : '1,2,3,6';
|
||||
adviceType !== undefined && adviceType !== '' ? [parseInt(adviceType)] : [1, 2, 3, 6];
|
||||
}
|
||||
queryParams.value.categoryCode = categoryCode || '';
|
||||
queryParams.value.searchKey = searchKey || '';
|
||||
@@ -131,7 +131,8 @@ function getList() {
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
.catch((err) => {
|
||||
console.warn('医嘱基础信息加载失败:', err);
|
||||
adviceBaseList.value = [];
|
||||
})
|
||||
.finally(() => {
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
import request from '@/utils/request';
|
||||
|
||||
|
||||
// 申请单相关接口
|
||||
|
||||
|
||||
/**
|
||||
* 查询检查申请单
|
||||
*/
|
||||
export function getCheck(queryParams) {
|
||||
return request({
|
||||
url: '/reg-doctorstation/request-form/get-check',
|
||||
method: 'get',
|
||||
params: queryParams,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 查询检验申请单
|
||||
*/
|
||||
export function getInspection(queryParams) {
|
||||
return request({
|
||||
url: '/reg-doctorstation/request-form/get-inspection',
|
||||
method: 'get',
|
||||
params: queryParams,
|
||||
});
|
||||
@@ -28,6 +44,17 @@ export function getSurgery(queryParams) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询手术申请单(全局,不需要encounterId,用于门诊手术安排查找弹窗)
|
||||
*/
|
||||
export function getSurgeryPage(queryParams) {
|
||||
return request({
|
||||
url: '/reg-doctorstation/request-form/get-surgery-page',
|
||||
method: 'get',
|
||||
params: queryParams,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询护理医嘱信息
|
||||
*/
|
||||
@@ -105,3 +132,25 @@ export function getTestResultPage(queryParams) {
|
||||
data: queryParams,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除申请单(仅待签发状态可删除)
|
||||
*/
|
||||
export function deleteRequestForm(data) {
|
||||
return request({
|
||||
url: '/reg-doctorstation/request-form/delete',
|
||||
method: 'post',
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤回申请单(已签发状态撤回至待签发)
|
||||
*/
|
||||
export function withdrawRequestForm(data) {
|
||||
return request({
|
||||
url: '/reg-doctorstation/request-form/withdraw',
|
||||
method: 'post',
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -175,10 +175,9 @@ const hasMatchedFields = computed(() => {
|
||||
});
|
||||
|
||||
/** 查询科室 */
|
||||
const getLocationInfo = () => {
|
||||
getOrgList().then((res) => {
|
||||
orgOptions.value = res.data.records;
|
||||
});
|
||||
const getLocationInfo = async () => {
|
||||
const res = await getOrgList();
|
||||
orgOptions.value = res.data.records;
|
||||
};
|
||||
|
||||
const recursionFun = (targetDepartment) => {
|
||||
@@ -199,7 +198,12 @@ const recursionFun = (targetDepartment) => {
|
||||
return name;
|
||||
};
|
||||
|
||||
const handleViewDetail = (row) => {
|
||||
const handleViewDetail = async (row) => {
|
||||
// 确保科室数据已加载,以便将 ID 解析为名称
|
||||
if (!orgOptions.value || orgOptions.value.length === 0) {
|
||||
await getLocationInfo();
|
||||
}
|
||||
|
||||
currentDetail.value = row;
|
||||
// 解析 descJson
|
||||
if (row.descJson) {
|
||||
@@ -220,10 +224,9 @@ const handleViewDetail = (row) => {
|
||||
|
||||
watch(
|
||||
() => patientInfo.value?.encounterId,
|
||||
(val) => {
|
||||
async (val) => {
|
||||
if (val) {
|
||||
fetchData();
|
||||
getLocationInfo();
|
||||
await Promise.all([fetchData(), getLocationInfo()]);
|
||||
} else {
|
||||
tableData.value = [];
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,20 @@
|
||||
<!--
|
||||
* 住院医生站 — 汇总发药申请:复用药房「发药汇总单」能力
|
||||
-->
|
||||
<template>
|
||||
<div class="summary-drug-application">
|
||||
<MedicationSummary />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import MedicationSummary from '@/views/drug/inpatientMedicationDispensing/components/MedicationSummary.vue';
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.summary-drug-application {
|
||||
height: 100%;
|
||||
min-height: 400px;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
@@ -181,10 +181,9 @@ const hasMatchedFields = computed(() => {
|
||||
});
|
||||
|
||||
/** 查询科室 */
|
||||
const getLocationInfo = () => {
|
||||
getOrgList().then((res) => {
|
||||
orgOptions.value = res.data.records;
|
||||
});
|
||||
const getLocationInfo = async () => {
|
||||
const res = await getOrgList();
|
||||
orgOptions.value = res.data.records;
|
||||
};
|
||||
|
||||
const recursionFun = (targetDepartment) => {
|
||||
@@ -205,7 +204,12 @@ const recursionFun = (targetDepartment) => {
|
||||
return name;
|
||||
};
|
||||
|
||||
const handleViewDetail = (row) => {
|
||||
const handleViewDetail = async (row) => {
|
||||
// 确保科室数据已加载,以便将 ID 解析为名称
|
||||
if (!orgOptions.value || orgOptions.value.length === 0) {
|
||||
await getLocationInfo();
|
||||
}
|
||||
|
||||
currentDetail.value = row;
|
||||
// 解析 descJson
|
||||
if (row.descJson) {
|
||||
@@ -226,10 +230,9 @@ const handleViewDetail = (row) => {
|
||||
|
||||
watch(
|
||||
() => patientInfo.value?.encounterId,
|
||||
(val) => {
|
||||
async (val) => {
|
||||
if (val) {
|
||||
fetchData();
|
||||
getLocationInfo();
|
||||
await Promise.all([fetchData(), getLocationInfo()]);
|
||||
} else {
|
||||
tableData.value = [];
|
||||
}
|
||||
|
||||
@@ -41,12 +41,19 @@
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="待签发" value="0" />
|
||||
<el-option label="已签发" value="1" />
|
||||
<el-option label="已采集" value="2" />
|
||||
<el-option label="已收样" value="3" />
|
||||
<el-option label="报告已出" value="4" />
|
||||
<el-option label="已作废" value="5" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="关键字">
|
||||
<el-input
|
||||
v-model="filterForm.keyword"
|
||||
placeholder="申请单号/检验项目"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
@keyup.enter="handleSearch"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleSearch" :loading="loading">
|
||||
<el-icon><Search /></el-icon>
|
||||
@@ -75,7 +82,11 @@
|
||||
</template>
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<el-table-column prop="patientName" label="患者姓名" width="120" />
|
||||
<el-table-column prop="name" label="申请单名称" width="140" />
|
||||
<el-table-column label="申请单名称" width="140">
|
||||
<template #default="scope">
|
||||
<span>{{ buildApplicationName(scope.row) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" label="创建时间" width="160" />
|
||||
<el-table-column prop="prescriptionNo" label="申请单号" width="140" />
|
||||
<el-table-column label="单据状态" width="100" align="center">
|
||||
@@ -94,8 +105,15 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="requesterId_dictText" label="申请者" width="120" />
|
||||
<el-table-column label="操作" align="center" fixed="right">
|
||||
<el-table-column label="操作" align="center" fixed="right" width="160">
|
||||
<template #default="scope">
|
||||
<template v-if="scope.row.status == 0">
|
||||
<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="scope.row.status == 1">
|
||||
<el-button link type="warning" @click="handleWithdraw(scope.row)">撤回</el-button>
|
||||
</template>
|
||||
<el-button link type="primary" @click="handleViewDetail(scope.row)">详情</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -123,7 +141,7 @@
|
||||
<el-descriptions-item label="创建时间">{{
|
||||
currentDetail.createTime || '-'
|
||||
}}</el-descriptions-item>
|
||||
<el-descriptions-item label="处方号">{{
|
||||
<el-descriptions-item label="申请单号">{{
|
||||
currentDetail.prescriptionNo || '-'
|
||||
}}</el-descriptions-item>
|
||||
<el-descriptions-item label="申请者">{{
|
||||
@@ -165,6 +183,26 @@
|
||||
<el-button @click="detailDialogVisible = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 编辑检验申请单弹窗 -->
|
||||
<el-dialog
|
||||
v-model="editDialogVisible"
|
||||
title="编辑检验申请单"
|
||||
width="1200px"
|
||||
destroy-on-close
|
||||
top="5vh"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<LaboratoryTests
|
||||
ref="editFormRef"
|
||||
@submitOk="handleEditSubmitOk"
|
||||
:editData="editRowData"
|
||||
/>
|
||||
<template #footer>
|
||||
<el-button @click="editDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="submitEditForm">确认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -172,14 +210,19 @@
|
||||
import {computed, getCurrentInstance, ref, watch} from 'vue';
|
||||
import {Refresh, Search} from '@element-plus/icons-vue';
|
||||
import {patientInfo} from '../../store/patient.js';
|
||||
import {getInspection} from './api';
|
||||
import {getOrgList} from '@/views/doctorstation/components/api.js';
|
||||
import {getInspection, deleteRequestForm, withdrawRequestForm} from './api';
|
||||
import {getDepartmentList} from '@/api/public.js';
|
||||
import LaboratoryTests from '../order/applicationForm/laboratoryTests.vue';
|
||||
import {saveInspection} from '../order/applicationForm/api.js';
|
||||
|
||||
const { proxy } = getCurrentInstance();
|
||||
|
||||
const tableData = ref([]);
|
||||
const loading = ref(false);
|
||||
const detailDialogVisible = ref(false);
|
||||
const editDialogVisible = ref(false);
|
||||
const editRowData = ref(null);
|
||||
const editFormRef = ref(null);
|
||||
const currentDetail = ref(null);
|
||||
const descJsonData = ref(null);
|
||||
const orgOptions = ref([]);
|
||||
@@ -188,6 +231,7 @@ const orgOptions = ref([]);
|
||||
const filterForm = ref({
|
||||
dateRange: [], // [startDate, endDate]
|
||||
status: '', // 单据状态
|
||||
keyword: '', // 关键字搜索
|
||||
});
|
||||
|
||||
const fetchData = async () => {
|
||||
@@ -211,7 +255,12 @@ const fetchData = async () => {
|
||||
if (filterForm.value.status !== '' && filterForm.value.status !== undefined) {
|
||||
params.status = filterForm.value.status;
|
||||
}
|
||||
|
||||
|
||||
// 添加关键字搜索
|
||||
if (filterForm.value.keyword && filterForm.value.keyword.trim()) {
|
||||
params.keyword = filterForm.value.keyword.trim();
|
||||
}
|
||||
|
||||
const res = await getInspection(params);
|
||||
if (res.code === 200 && res.data) {
|
||||
const raw = res.data?.records || res.data;
|
||||
@@ -251,6 +300,7 @@ const handleReset = () => {
|
||||
// 重置筛选条件为默认值
|
||||
filterForm.value.dateRange = [];
|
||||
filterForm.value.status = '';
|
||||
filterForm.value.keyword = '';
|
||||
// 重新加载数据
|
||||
fetchData();
|
||||
};
|
||||
@@ -264,6 +314,9 @@ const labelMap = {
|
||||
otherDiagnosis: '其他诊断',
|
||||
relatedResult: '相关结果',
|
||||
attention: '注意事项',
|
||||
applicationType: '申请类型',
|
||||
specimenName: '标本类型',
|
||||
executeTime: '执行时间',
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -275,8 +328,6 @@ const parseBillStatus = (status) => {
|
||||
const statusMap = {
|
||||
'0': '待签发',
|
||||
'1': '已签发',
|
||||
'2': '已采集',
|
||||
'3': '已收样',
|
||||
'4': '报告已出',
|
||||
'5': '已作废',
|
||||
};
|
||||
@@ -292,8 +343,8 @@ const parsePriorityCode = (descJson) => {
|
||||
if (!descJson) return '-';
|
||||
try {
|
||||
const obj = JSON.parse(descJson);
|
||||
// priorityCode: 0-普通, 1-急
|
||||
return obj.priorityCode === 1 ? '急' : '普通';
|
||||
// applicationType: 0-普通, 1-急诊
|
||||
return obj.applicationType === 1 ? '急' : '普通';
|
||||
} catch (e) {
|
||||
console.error('解析 descJson 失败:', e);
|
||||
return '-';
|
||||
@@ -317,6 +368,24 @@ const parseSpecimenType = (descJson) => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据申请单详情构建申请单名称
|
||||
* 单一项目:显示项目名称+数量
|
||||
* 多个项目:显示首个项目名称+数量+"等X项"
|
||||
*/
|
||||
const buildApplicationName = (row) => {
|
||||
const details = row.requestFormDetailList;
|
||||
if (!details || details.length === 0) {
|
||||
return row.name || '-';
|
||||
}
|
||||
if (details.length === 1) {
|
||||
const item = details[0];
|
||||
return `${item.adviceName}${item.quantity || ''}`;
|
||||
}
|
||||
const first = details[0];
|
||||
return `${first.adviceName}${first.quantity || ''}等${details.length}项`;
|
||||
};
|
||||
|
||||
const isFieldMatched = (key) => {
|
||||
return key in labelMap;
|
||||
};
|
||||
@@ -331,39 +400,51 @@ const hasMatchedFields = computed(() => {
|
||||
});
|
||||
|
||||
/** 查询科室 */
|
||||
const getLocationInfo = () => {
|
||||
getOrgList().then((res) => {
|
||||
orgOptions.value = res.data.records;
|
||||
});
|
||||
const getLocationInfo = async () => {
|
||||
const res = await getDepartmentList();
|
||||
orgOptions.value = res.data || [];
|
||||
};
|
||||
|
||||
const recursionFun = (targetDepartment) => {
|
||||
if (!targetDepartment) return '';
|
||||
let name = '';
|
||||
for (let index = 0; index < orgOptions.value.length; index++) {
|
||||
const obj = orgOptions.value[index];
|
||||
if (obj.id == targetDepartment) {
|
||||
name = obj.name;
|
||||
break;
|
||||
}
|
||||
const subObjArray = obj['children'];
|
||||
for (let index = 0; index < subObjArray.length; index++) {
|
||||
const item = subObjArray[index];
|
||||
if (item.id == targetDepartment) {
|
||||
name = item.name;
|
||||
if (subObjArray && subObjArray.length > 0) {
|
||||
for (let i = 0; i < subObjArray.length; i++) {
|
||||
const item = subObjArray[i];
|
||||
if (item.id == targetDepartment) {
|
||||
name = item.name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (name) break;
|
||||
}
|
||||
return name;
|
||||
};
|
||||
|
||||
const handleViewDetail = (row) => {
|
||||
const handleViewDetail = async (row) => {
|
||||
// 确保科室数据已加载,以便将 ID 解析为名称
|
||||
if (!orgOptions.value || orgOptions.value.length === 0) {
|
||||
await getLocationInfo();
|
||||
}
|
||||
|
||||
currentDetail.value = row;
|
||||
// 解析 descJson
|
||||
if (row.descJson) {
|
||||
try {
|
||||
const obj = JSON.parse(row.descJson);
|
||||
obj.targetDepartment = recursionFun(obj.targetDepartment);
|
||||
// 转换申请类型编码为可读文本
|
||||
if (obj.applicationType === 0) obj.applicationType = '普通';
|
||||
else if (obj.applicationType === 1) obj.applicationType = '急诊';
|
||||
descJsonData.value = obj;
|
||||
// descJsonData.value = JSON.parse(row.descJson);
|
||||
} catch (e) {
|
||||
console.error('解析 descJson 失败:', e);
|
||||
descJsonData.value = null;
|
||||
@@ -374,15 +455,92 @@ const handleViewDetail = (row) => {
|
||||
detailDialogVisible.value = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 修改检验申请单(待签发状态)
|
||||
*/
|
||||
const handleEdit = async (row) => {
|
||||
// 确保科室数据已加载
|
||||
if (!orgOptions.value || orgOptions.value.length === 0) {
|
||||
await getLocationInfo();
|
||||
}
|
||||
editRowData.value = row;
|
||||
editDialogVisible.value = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 编辑弹窗提交成功回调
|
||||
*/
|
||||
const handleEditSubmitOk = async () => {
|
||||
editDialogVisible.value = false;
|
||||
editRowData.value = null;
|
||||
proxy.$modal?.msgSuccess?.('修改成功');
|
||||
await fetchData();
|
||||
};
|
||||
|
||||
/**
|
||||
* 编辑弹窗提交按钮
|
||||
*/
|
||||
const submitEditForm = () => {
|
||||
if (editFormRef.value?.submit) {
|
||||
editFormRef.value.submit();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除检验申请单(仅待签发状态可删除)
|
||||
*/
|
||||
const handleDelete = async (row) => {
|
||||
try {
|
||||
await proxy.$modal?.confirm?.(`确定要删除申请单 "${row.prescriptionNo}" 吗?此操作不可恢复。`);
|
||||
} catch {
|
||||
return; // 用户取消
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await deleteRequestForm({ requestFormId: row.requestFormId });
|
||||
if (res?.code === 200) {
|
||||
proxy.$modal?.msgSuccess?.('删除成功');
|
||||
await fetchData();
|
||||
} else {
|
||||
proxy.$modal?.msgError?.(res?.msg || '删除失败');
|
||||
}
|
||||
} catch (e) {
|
||||
proxy.$modal?.msgError?.(e.message || '删除异常');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 撤回检验申请单(已签发状态撤回至待签发)
|
||||
*/
|
||||
const handleWithdraw = async (row) => {
|
||||
try {
|
||||
await proxy.$modal?.confirm?.(`确定要撤回申请单 "${row.prescriptionNo}" 吗?撤回后将恢复为待签发状态。`);
|
||||
} catch {
|
||||
return; // 用户取消
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await withdrawRequestForm({ requestFormId: row.requestFormId });
|
||||
if (res?.code === 200) {
|
||||
proxy.$modal?.msgSuccess?.('撤回成功');
|
||||
await fetchData();
|
||||
} else {
|
||||
proxy.$modal?.msgError?.(res?.msg || '撤回失败');
|
||||
}
|
||||
} catch (e) {
|
||||
proxy.$modal?.msgError?.(e.message || '撤回异常');
|
||||
}
|
||||
};
|
||||
|
||||
watch(
|
||||
() => patientInfo.value?.encounterId,
|
||||
(val) => {
|
||||
async (val) => {
|
||||
if (val) {
|
||||
// 设置默认日期范围为近7天
|
||||
const today = new Date();
|
||||
const sevenDaysAgo = new Date(today);
|
||||
sevenDaysAgo.setDate(today.getDate() - 6); // 包含今天共7天
|
||||
|
||||
|
||||
// 格式化为 YYYY-MM-DD
|
||||
const formatDate = (date) => {
|
||||
const year = date.getFullYear();
|
||||
@@ -390,19 +548,19 @@ watch(
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
return `${year}-${month}-${day}`;
|
||||
};
|
||||
|
||||
|
||||
filterForm.value.dateRange = [
|
||||
formatDate(sevenDaysAgo),
|
||||
formatDate(today)
|
||||
];
|
||||
|
||||
fetchData();
|
||||
getLocationInfo();
|
||||
|
||||
await Promise.all([fetchData(), getLocationInfo()]);
|
||||
} else {
|
||||
tableData.value = [];
|
||||
// 重置筛选条件
|
||||
filterForm.value.dateRange = [];
|
||||
filterForm.value.status = '';
|
||||
filterForm.value.keyword = '';
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
|
||||
@@ -568,6 +568,11 @@ function handleMaindise(value, index) {
|
||||
* 保存诊断
|
||||
*/
|
||||
function handleSaveDiagnosis() {
|
||||
// 防止重复点击保存
|
||||
if (isSaving.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let index = 0; index < (form.value.diagnosisList || []).length; index++) {
|
||||
const item = form.value.diagnosisList[index];
|
||||
if (!item.diagSrtNo) {
|
||||
@@ -600,7 +605,7 @@ function handleSaveDiagnosis() {
|
||||
|
||||
// 步骤2:重新分配连续的序号(从1开始)
|
||||
sortedList.forEach((item, index) => {
|
||||
item.diagSrtNo = index + 1; // 这里是关键!把“诊断排序”改成新顺序
|
||||
item.diagSrtNo = index + 1; // 这里是关键!把”诊断排序”改成新顺序
|
||||
});
|
||||
|
||||
// 步骤3:提交排序后的数据
|
||||
@@ -610,12 +615,12 @@ function handleSaveDiagnosis() {
|
||||
diagnosisChildList: sortedList,
|
||||
}).then((res) => {
|
||||
if (res.code === 200) {
|
||||
// 步骤4:更新本地数据,使用全新对象防止响应式问题
|
||||
form.value.diagnosisList = sortedList.map(item => ({ ...item }));
|
||||
|
||||
emits('diagnosisSave', false);
|
||||
proxy.$modal.msgSuccess('诊断已保存');
|
||||
|
||||
// 保存成功后从服务器重新加载数据,确保前后端数据一致
|
||||
getList();
|
||||
|
||||
// 食源性疾病逻辑
|
||||
isFoodDiseasesNew({ encounterId: props.patientInfo.encounterId }).then((res2) => {
|
||||
if (res2.code === 20 && res2.data) {
|
||||
|
||||
@@ -112,6 +112,8 @@ const showApplicationFormDialog = (name) => {
|
||||
setTimeout(() => {
|
||||
applicationFormName.value = components.value[name];
|
||||
applicationFormDialogVisible.value = true;
|
||||
// 列表(项目列表)
|
||||
applicationFormNameRef?.value.getList?.();
|
||||
// 科室列表
|
||||
applicationFormNameRef?.value.getLocationInfo();
|
||||
// 诊断目录列表
|
||||
@@ -121,6 +123,8 @@ const showApplicationFormDialog = (name) => {
|
||||
applicationFormName.value = components.value[name];
|
||||
applicationFormDialogVisible.value = true;
|
||||
nextTick(() => {
|
||||
// 列表(项目列表)
|
||||
applicationFormNameRef?.value.getList?.();
|
||||
// 科室列表
|
||||
applicationFormNameRef?.value.getLocationInfo();
|
||||
// 诊断目录列表
|
||||
|
||||
@@ -249,7 +249,7 @@ const submit = () => {
|
||||
requestFormId: '', // 申请单ID
|
||||
name: '输血申请单',
|
||||
descJson: JSON.stringify(form),
|
||||
categoryEnum: '3', // 1 检验 2 检查 3 输血 4 手术
|
||||
categoryEnum: '23', // 21 检验 22 检查 23 输血 24 手术(避开 adviceType 1-6 碰撞)
|
||||
}).then((res) => {
|
||||
if (res.code === 200) {
|
||||
proxy.$message.success(res.msg);
|
||||
|
||||
@@ -6,9 +6,26 @@
|
||||
<template>
|
||||
<div class="LaboratoryTests-container">
|
||||
<div v-loading="loading" class="transfer-wrapper">
|
||||
<!-- 远程搜索框 -->
|
||||
<div class="search-bar">
|
||||
<el-input
|
||||
v-model="searchKey"
|
||||
placeholder="输入项目代码/名称搜索"
|
||||
clearable
|
||||
@keyup.enter="handleSearch"
|
||||
@clear="handleSearch"
|
||||
style="width: 300px; margin-bottom: 10px"
|
||||
>
|
||||
<template #append>
|
||||
<el-button @click="handleSearch">搜索</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
<span v-if="!searchKey" class="total-count">共 {{ totalCount }} 项</span>
|
||||
<span v-else class="total-count">搜索到 {{ filteredCount }} 项 / 共 {{ totalCount }} 项</span>
|
||||
</div>
|
||||
<el-transfer
|
||||
v-model="transferValue"
|
||||
:data="applicationList"
|
||||
:data="transferData"
|
||||
filter-placeholder="项目代码/名称"
|
||||
filterable
|
||||
:titles="['未选择', '已选择']"
|
||||
@@ -72,16 +89,55 @@
|
||||
<el-input v-model="form.attention" autocomplete="off" type="textarea" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 申请类型 -->
|
||||
<el-col :span="12">
|
||||
<el-form-item label="申请类型" prop="applicationType" style="width: 100%">
|
||||
<el-radio-group v-model="form.applicationType">
|
||||
<el-radio :value="0">普通</el-radio>
|
||||
<el-radio :value="1">急诊</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 标本类型 -->
|
||||
<el-col :span="12">
|
||||
<el-form-item label="标本类型" prop="specimenName" style="width: 100%">
|
||||
<el-select v-model="form.specimenName" placeholder="请选择标本类型" style="width: 100%">
|
||||
<el-option label="血液" value="血液" />
|
||||
<el-option label="尿液" value="尿液" />
|
||||
<el-option label="粪便" value="粪便" />
|
||||
<el-option label="痰液" value="痰液" />
|
||||
<el-option label="咽拭子" value="咽拭子" />
|
||||
<el-option label="脑脊液" value="脑脊液" />
|
||||
<el-option label="胸腹水" value="胸腹水" />
|
||||
<el-option label="关节液" value="关节液" />
|
||||
<el-option label="分泌物" value="分泌物" />
|
||||
<el-option label="其他" value="其他" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 执行时间 -->
|
||||
<el-col :span="12">
|
||||
<el-form-item label="执行时间" prop="executeTime" style="width: 100%">
|
||||
<el-date-picker
|
||||
v-model="form.executeTime"
|
||||
type="datetime"
|
||||
placeholder="选择执行时间"
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup name="LaboratoryTests">
|
||||
import {getCurrentInstance, onBeforeMount, onMounted, reactive, watch} from 'vue';
|
||||
import {getCurrentInstance, onMounted, reactive, ref, watch, computed} from 'vue';
|
||||
import {patientInfo} from '../../../store/patient.js';
|
||||
import {getApplicationList, saveInspection} from './api';
|
||||
import {getDepartmentList} from '@/api/public.js';
|
||||
import {getOrgList} from '@/views/doctorstation/components/api.js';
|
||||
import {getEncounterDiagnosis} from '../../api.js';
|
||||
import {ElMessage} from 'element-plus';
|
||||
|
||||
@@ -99,48 +155,92 @@ const findTreeItem = (list, id) => {
|
||||
return null;
|
||||
};
|
||||
const emits = defineEmits(['submitOk']);
|
||||
const props = defineProps({});
|
||||
const props = defineProps({
|
||||
editData: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
const isEditMode = computed(() => !!props.editData?.requestFormId);
|
||||
const state = reactive({});
|
||||
const applicationListAll = ref();
|
||||
const applicationList = ref();
|
||||
const applicationListAll = ref([]);
|
||||
const loading = ref(false);
|
||||
const orgOptions = ref([]); // 科室选项
|
||||
const getList = () => {
|
||||
const orgOptions = ref([]);
|
||||
const searchKey = ref('');
|
||||
const totalCount = ref(0);
|
||||
|
||||
// 将已加载的全部数据转为 transfer 组件所需的格式
|
||||
const buildTransferData = (records) => {
|
||||
return records.map((item) => {
|
||||
const priceInfo = item.priceList?.[0] || {};
|
||||
const price = priceInfo.price != null ? Number(priceInfo.price).toFixed(2) : '0.00';
|
||||
const unit = item.unitCode_dictText || item.unitCode || '';
|
||||
return {
|
||||
adviceDefinitionId: item.adviceDefinitionId,
|
||||
orgId: item.orgId,
|
||||
label: item.adviceName + ' (¥' + price + '/' + unit + ')',
|
||||
key: item.adviceDefinitionId,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
// 加载全部数据(不分页,一次性拉取)
|
||||
const loadAllData = async () => {
|
||||
if (!patientInfo.value?.inHospitalOrgId) {
|
||||
applicationList.value = [];
|
||||
applicationListAll.value = [];
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
getApplicationList({
|
||||
pageSize: 500,
|
||||
pageNum: 1,
|
||||
categoryCode: '22',
|
||||
organizationId: patientInfo.value.inHospitalOrgId,
|
||||
adviceTypes: [3], //1 药品 2耗材 3诊疗
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.code === 200) {
|
||||
applicationListAll.value = res.data.records;
|
||||
applicationList.value = res.data.records.map((item) => {
|
||||
const priceInfo = item.priceList?.[0] || {};
|
||||
const price = priceInfo.price != null ? Number(priceInfo.price).toFixed(2) : '0.00';
|
||||
const unit = item.unitCode_dictText || item.unitCode || '';
|
||||
return {
|
||||
adviceDefinitionId: item.adviceDefinitionId,
|
||||
orgId: item.orgId,
|
||||
label: item.adviceName + ' (¥' + price + '/' + unit + ')',
|
||||
key: item.adviceDefinitionId,
|
||||
};
|
||||
});
|
||||
console.log('applicationList========>', JSON.stringify(res.data.records));
|
||||
} else {
|
||||
proxy.$message.error(res.message);
|
||||
applicationList.value = [];
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
try {
|
||||
// 使用大 pageSize 一次性拉取所有启用状态的检验类诊疗项目
|
||||
const res = await getApplicationList({
|
||||
pageSize: 9999,
|
||||
pageNo: 1,
|
||||
categoryCode: '22',
|
||||
organizationId: patientInfo.value.inHospitalOrgId,
|
||||
adviceTypes: [3], // 1 药品 2 耗材 3 诊疗
|
||||
});
|
||||
if (res.code !== 200) {
|
||||
proxy.$message.error(res.message);
|
||||
applicationListAll.value = [];
|
||||
return;
|
||||
}
|
||||
applicationListAll.value = res.data?.records || [];
|
||||
totalCount.value = res.data?.total || 0;
|
||||
} catch (e) {
|
||||
proxy.$message.error('获取检验项目列表失败');
|
||||
applicationListAll.value = [];
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 根据搜索关键词过滤数据
|
||||
const filterData = (key) => {
|
||||
if (!key || key.trim() === '') {
|
||||
return applicationListAll.value;
|
||||
}
|
||||
const lowerKey = key.toLowerCase().trim();
|
||||
return applicationListAll.value.filter((item) => {
|
||||
return (
|
||||
item.adviceName?.toLowerCase().includes(lowerKey) ||
|
||||
item.pyStr?.toLowerCase().includes(lowerKey) ||
|
||||
item.adviceBusNo?.toLowerCase().includes(lowerKey)
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
// transfer 组件实际显示的数据(受搜索词影响)
|
||||
const transferData = computed(() => buildTransferData(filterData(searchKey.value)));
|
||||
// 当前显示的条数
|
||||
const filteredCount = computed(() => filterData(searchKey.value).length);
|
||||
|
||||
const getList = async () => {
|
||||
await loadAllData();
|
||||
};
|
||||
|
||||
const handleSearch = () => {
|
||||
// 搜索时保持已选中的项目不受影响
|
||||
};
|
||||
const transferValue = ref([]);
|
||||
const form = reactive({
|
||||
@@ -152,11 +252,13 @@ const form = reactive({
|
||||
otherDiagnosis: '', // 其他诊断
|
||||
relatedResult: '', // 相关结果
|
||||
attention: '', // 注意事项
|
||||
applicationType: 0, // 申请类型 0-普通 1-急诊
|
||||
specimenName: '血液', // 标本类型
|
||||
executeTime: null, // 执行时间
|
||||
primaryDiagnosisList: [], //主诊断目录
|
||||
otherDiagnosisList: [], //其他断目录
|
||||
});
|
||||
const rules = reactive({});
|
||||
onBeforeMount(() => {});
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
@@ -169,13 +271,25 @@ const projectWithDepartment = (selectProjectIds, type) => {
|
||||
let isRelease = true;
|
||||
// 选中项目的数组
|
||||
const arr = [];
|
||||
// 根据选中的项目id查找对应的项目
|
||||
// 根据选中的项目id查找对应的项目(从全部原始数据中查找)
|
||||
selectProjectIds.forEach((element) => {
|
||||
const searchData = applicationList.value.find((item) => {
|
||||
const searchData = applicationListAll.value.find((item) => {
|
||||
return element == item.adviceDefinitionId;
|
||||
});
|
||||
arr.push(searchData);
|
||||
if (searchData) {
|
||||
const priceInfo = searchData.priceList?.[0] || {};
|
||||
const price = priceInfo.price != null ? Number(priceInfo.price).toFixed(2) : '0.00';
|
||||
const unit = searchData.unitCode_dictText || searchData.unitCode || '';
|
||||
arr.push({
|
||||
adviceDefinitionId: searchData.adviceDefinitionId,
|
||||
orgId: searchData.orgId,
|
||||
label: searchData.adviceName + ' (¥' + price + '/' + unit + ')',
|
||||
key: searchData.adviceDefinitionId,
|
||||
});
|
||||
}
|
||||
});
|
||||
// 保存用户手动选择的发往科室(提交时需要保留)
|
||||
const manualDept = type === 2 ? form.targetDepartment : '';
|
||||
// 清空科室
|
||||
form.targetDepartment = '';
|
||||
if (arr.length > 0) {
|
||||
@@ -194,14 +308,27 @@ const projectWithDepartment = (selectProjectIds, type) => {
|
||||
// 选中项目中的执行科室id与全部科室数据做匹配
|
||||
const findItem = findTreeItem(orgOptions.value, obj.orgId);
|
||||
if (!findItem) {
|
||||
isRelease = false;
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: '未找到项目执行的科室',
|
||||
});
|
||||
// type=2(提交)时,若用户已手动选择发往科室,则允许提交
|
||||
if (type === 2 && manualDept) {
|
||||
form.targetDepartment = manualDept;
|
||||
isRelease = true;
|
||||
} else if (type === 2 && !manualDept) {
|
||||
// 提交时用户未手动选择科室,才提示错误
|
||||
isRelease = false;
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: '未找到项目执行的科室',
|
||||
});
|
||||
} else {
|
||||
// type=1(选择项目变化)时,不弹窗,仅清空科室让用户自行选择
|
||||
isRelease = false;
|
||||
}
|
||||
}
|
||||
if (type == 1) {
|
||||
if (isRelease) {
|
||||
if (findItem && isRelease) {
|
||||
// 提交时若用户已选「发往科室」,不得用项目默认执行科室覆盖
|
||||
if (type === 2 && manualDept) {
|
||||
form.targetDepartment = manualDept;
|
||||
} else {
|
||||
form.targetDepartment = findItem.id;
|
||||
}
|
||||
}
|
||||
@@ -215,6 +342,44 @@ watch(
|
||||
projectWithDepartment(newValue, 1);
|
||||
}
|
||||
);
|
||||
|
||||
// 编辑模式下,回显已有数据
|
||||
watch(
|
||||
() => props.editData,
|
||||
(newData) => {
|
||||
if (!newData || !newData.requestFormId) return;
|
||||
|
||||
// 解析 descJson 回填表单
|
||||
if (newData.descJson) {
|
||||
try {
|
||||
const obj = JSON.parse(newData.descJson);
|
||||
Object.keys(form).forEach((key) => {
|
||||
if (obj[key] !== undefined) {
|
||||
form[key] = obj[key];
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('解析 descJson 失败:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// 回填已选项目
|
||||
if (newData.requestFormDetailList && newData.requestFormDetailList.length > 0) {
|
||||
// 从全部数据中匹配已选项目
|
||||
const selectedIds = [];
|
||||
newData.requestFormDetailList.forEach((detail) => {
|
||||
const matched = applicationListAll.value.find(
|
||||
(item) => item.adviceName === detail.adviceName
|
||||
);
|
||||
if (matched) {
|
||||
selectedIds.push(matched.adviceDefinitionId);
|
||||
}
|
||||
});
|
||||
transferValue.value = selectedIds;
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
const submit = () => {
|
||||
if (transferValue.value.length == 0) {
|
||||
return proxy.$message.error('请选择申请单');
|
||||
@@ -232,7 +397,7 @@ const submit = () => {
|
||||
unitCode: item.priceList[0].unitCode /** 请求单位编码 */,
|
||||
unitPrice: item.priceList[0].price /** 单价 */,
|
||||
totalPrice: item.priceList[0].price /** 总价 */,
|
||||
positionId: item.positionId, //执行科室id
|
||||
positionId: form.targetDepartment || item.positionId, // 用户指定发往科室优先于项目默认执行科室
|
||||
ybClassEnum: item.ybClassEnum, //类别医保编码
|
||||
conditionId: item.conditionId, //诊断ID
|
||||
encounterDiagnosisId: item.encounterDiagnosisId, //就诊诊断id
|
||||
@@ -247,15 +412,15 @@ const submit = () => {
|
||||
patientId: patientInfo.value.patientId, //患者ID
|
||||
encounterId: patientInfo.value.encounterId, // 就诊ID
|
||||
organizationId: patientInfo.value.inHospitalOrgId, // 医疗机构ID
|
||||
requestFormId: '', // 申请单ID
|
||||
requestFormId: isEditMode.value ? props.editData.requestFormId : '', // 申请单ID(编辑模式传入,新增为空)
|
||||
name: '检验申请单',
|
||||
descJson: JSON.stringify(form),
|
||||
categoryEnum: '1', // 1 检验 2 检查 3 输血 4 手术
|
||||
categoryEnum: '21', // 21 检验 22 检查 23 输血 24 手术(避开 adviceType 1-6 碰撞)
|
||||
};
|
||||
saveInspection(params).then((res) => {
|
||||
if (res.code === 200) {
|
||||
proxy.$message.success(res.msg);
|
||||
applicationList.value = [];
|
||||
proxy.$message.success(isEditMode.value ? '修改成功' : res.msg);
|
||||
transferValue.value = [];
|
||||
emits('submitOk');
|
||||
} else {
|
||||
proxy.$message.error(res.message);
|
||||
@@ -264,8 +429,8 @@ const submit = () => {
|
||||
};
|
||||
/** 查询科室 */
|
||||
const getLocationInfo = () => {
|
||||
getDepartmentList().then((res) => {
|
||||
orgOptions.value = res.data || [];
|
||||
getOrgList().then((res) => {
|
||||
orgOptions.value = res.data.records;
|
||||
console.log('科室========>', JSON.stringify(orgOptions.value));
|
||||
});
|
||||
};
|
||||
@@ -302,7 +467,7 @@ function getDiagnosisList() {
|
||||
}
|
||||
});
|
||||
}
|
||||
defineExpose({ state, submit, getLocationInfo, getDiagnosisList });
|
||||
defineExpose({ state, submit, getLocationInfo, getDiagnosisList, getList });
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.LaboratoryTests-container {
|
||||
@@ -312,6 +477,19 @@ defineExpose({ state, submit, getLocationInfo, getDiagnosisList });
|
||||
.transfer-wrapper {
|
||||
position: relative;
|
||||
min-height: 300px;
|
||||
|
||||
.search-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 8px;
|
||||
|
||||
.total-count {
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.el-transfer {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
||||
-->
|
||||
<template>
|
||||
<div class="surgery-container">
|
||||
<div v-loading="loading" class="transfer-wrapper">
|
||||
<div v-loading="loading" class="transfer-wrapper" style="min-height: 300px;">
|
||||
<el-transfer
|
||||
v-model="transferValue"
|
||||
:data="applicationList"
|
||||
@@ -86,6 +86,9 @@ import {getApplicationList, saveSurgery} from './api';
|
||||
import {ElMessage} from 'element-plus';
|
||||
|
||||
const { proxy } = getCurrentInstance();
|
||||
// 模块级缓存:避免每次打开弹窗都重新请求手术项目列表
|
||||
let surgeryRecordsCache = null; // 原始 API 记录
|
||||
let surgeryMappedCache = null; // 映射后的 el-transfer 数据
|
||||
// 递归查找树形科室节点
|
||||
const findTreeItem = (list, id) => {
|
||||
if (!list || list.length === 0) return null;
|
||||
@@ -103,13 +106,19 @@ const props = defineProps({});
|
||||
const state = reactive({});
|
||||
const applicationListAll = ref();
|
||||
const applicationList = ref();
|
||||
const loading = ref(false);
|
||||
const orgOptions = ref([]); // 科室选项
|
||||
const loading = ref(false); // 加载状态
|
||||
const getList = () => {
|
||||
if (!patientInfo.value?.inHospitalOrgId) {
|
||||
applicationList.value = [];
|
||||
return;
|
||||
}
|
||||
// 命中缓存时直接使用,避免重复请求导致加载缓慢
|
||||
if (surgeryMappedCache && surgeryMappedCache.length > 0) {
|
||||
applicationList.value = surgeryMappedCache;
|
||||
applicationListAll.value = surgeryRecordsCache;
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
getApplicationList({
|
||||
pageSize: 500,
|
||||
@@ -132,11 +141,18 @@ const getList = () => {
|
||||
key: item.adviceDefinitionId,
|
||||
};
|
||||
});
|
||||
// 写入模块缓存,后续打开弹窗直接复用
|
||||
surgeryRecordsCache = res.data.records;
|
||||
surgeryMappedCache = applicationList.value;
|
||||
} else {
|
||||
proxy.$message.error(res.message);
|
||||
console.warn('获取手术项目列表失败:', res.message);
|
||||
applicationList.value = [];
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.warn('手术项目列表加载失败(可能无权限):', e?.message || e);
|
||||
applicationList.value = [];
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
@@ -251,7 +267,7 @@ const submit = () => {
|
||||
requestFormId: '', // 申请单ID
|
||||
name: '手术申请单',
|
||||
descJson: JSON.stringify(form),
|
||||
categoryEnum: '4', // 1 检验 2 检查 3 输血 4 手术
|
||||
categoryEnum: '24', // 21 检验 22 检查 23 输血 24 手术(避开 adviceType 1-6 碰撞)
|
||||
}).then((res) => {
|
||||
if (res.code === 200) {
|
||||
proxy.$message.success(res.msg);
|
||||
@@ -302,7 +318,7 @@ function getDiagnosisList() {
|
||||
}
|
||||
});
|
||||
}
|
||||
defineExpose({ state, submit, getLocationInfo, getDiagnosisList });
|
||||
defineExpose({ state, submit, getLocationInfo, getDiagnosisList, getList });
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.surgery-container {
|
||||
|
||||
@@ -122,7 +122,6 @@
|
||||
|
||||
<el-table-column label="类型" align="center" prop="" width="120">
|
||||
<template #default="scope">
|
||||
{{ console.log(scope.row, 1111) }}
|
||||
<el-radio-group
|
||||
v-model="scope.row.therapyEnum"
|
||||
size="small"
|
||||
@@ -270,7 +269,6 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="频次/用法" align="center" prop="" width="180">
|
||||
<template #default="scope">
|
||||
{{ console.log(scope.row) }}
|
||||
<span v-if="!scope.row.isEdit && scope.row.adviceType == 1" style="text-align: right">
|
||||
{{
|
||||
[
|
||||
@@ -382,7 +380,7 @@ const form = ref({
|
||||
prescriptionList: prescriptionList.value,
|
||||
});
|
||||
const adviceQueryParams = ref({
|
||||
adviceType: 1,
|
||||
adviceType: '',
|
||||
categoryCode: '', // 初始为空,等待加载配置后动态设置
|
||||
searchKey: '',
|
||||
});
|
||||
@@ -535,6 +533,7 @@ const statusOption = [
|
||||
let loadingInstance = undefined;
|
||||
onMounted(() => {
|
||||
document.addEventListener('keydown', escKeyListener);
|
||||
getList();
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
@@ -575,7 +574,6 @@ function handleTotalAmount() {
|
||||
}
|
||||
}, new Decimal(0));
|
||||
}
|
||||
getList();
|
||||
function getList() {
|
||||
getDiagnosisDefinitionList(queryParams.value).then((res) => {
|
||||
// prescriptionList.value = res.data.records;
|
||||
@@ -587,6 +585,11 @@ function refresh() {
|
||||
}
|
||||
// 获取列表信息
|
||||
function getListInfo(addNewRow) {
|
||||
// 守护:未选择患者时不发起 API 请求,避免页面加载时循环报错
|
||||
if (!patientInfo.value || !patientInfo.value.encounterId) {
|
||||
console.warn('⚠️ getListInfo 跳过:未选择患者');
|
||||
return;
|
||||
}
|
||||
loadingInstance = ElLoading.service({ fullscreen: true });
|
||||
setTimeout(() => {
|
||||
loadingInstance.close();
|
||||
@@ -610,6 +613,8 @@ function getListInfo(addNewRow) {
|
||||
return {
|
||||
...parsedContent,
|
||||
...item,
|
||||
isEdit: false,
|
||||
showPopover: false,
|
||||
doseQuantity: parsedContent?.doseQuantity,
|
||||
doseUnitCode_dictText: parsedContent?.doseUnitCode_dictText,
|
||||
// 确保 therapyEnum 被正确设置,优先使用 contentJson 中的值
|
||||
@@ -686,7 +691,7 @@ function loadConfiguredCategories() {
|
||||
nextTick(() => {
|
||||
// 创建新对象触发响应式更新
|
||||
adviceQueryParams.value = {
|
||||
adviceType: 1,
|
||||
adviceType: '',
|
||||
categoryCode: defaultCategoryCode,
|
||||
searchKey: '',
|
||||
};
|
||||
@@ -710,9 +715,17 @@ function loadConfiguredCategories() {
|
||||
// 数据过滤
|
||||
const filterPrescriptionList = computed(() => {
|
||||
const pList = prescriptionList.value.filter((item) => {
|
||||
// 修复 Bug #488:orderClassCode 可能是复合值 '1-2',需提取 adviceType 部分进行比较
|
||||
let matchAdviceType = true;
|
||||
if (orderClassCode.value) {
|
||||
const filterAdviceType = String(orderClassCode.value).includes('-')
|
||||
? parseInt(String(orderClassCode.value).split('-')[0])
|
||||
: orderClassCode.value;
|
||||
matchAdviceType = filterAdviceType == item.adviceType;
|
||||
}
|
||||
return (
|
||||
(!therapyEnum.value || therapyEnum.value == item.therapyEnum) &&
|
||||
(!orderClassCode.value || orderClassCode.value == item.adviceType) &&
|
||||
matchAdviceType &&
|
||||
(!orderStatus.value || (orderStatus.value == item.statusEnum && item.requestId))
|
||||
);
|
||||
});
|
||||
@@ -740,12 +753,28 @@ function getRowDisabled(row) {
|
||||
/**
|
||||
* 将行的 adviceType + categoryCode 映射为 el-select 的选中值
|
||||
* 药品子分类使用复合值如 '1-2'(adviceType-categoryCode),诊疗/手术/全部使用原始值
|
||||
* 修复 Bug #488:当行的 adviceType 在当前配置中找不到匹配选项时,返回最接近的可用值,避免回显为纯数字
|
||||
*/
|
||||
function getRowSelectValue(row) {
|
||||
if (row.adviceType == 1 && row.categoryCode) {
|
||||
return '1-' + row.categoryCode;
|
||||
const compositeValue = '1-' + row.categoryCode;
|
||||
// 检查复合值是否在选项列表中
|
||||
if (adviceTypeList.value.some(item => item.value === compositeValue)) {
|
||||
return compositeValue;
|
||||
}
|
||||
// 配置的 categoryCode 已变更,回退到第一个药品选项
|
||||
const firstPharmacy = adviceTypeList.value.find(item => String(item.value).startsWith('1-'));
|
||||
if (firstPharmacy) {
|
||||
return firstPharmacy.value;
|
||||
}
|
||||
return row.adviceType;
|
||||
}
|
||||
return row.adviceType;
|
||||
// 诊疗/手术等非药品类型,检查其值是否在选项列表中
|
||||
if (adviceTypeList.value.some(item => item.value === row.adviceType)) {
|
||||
return row.adviceType;
|
||||
}
|
||||
// 不在选项中的值(如已废弃的 adviceType),返回 undefined 让 el-select 显示为空
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// 新增医嘱
|
||||
@@ -802,6 +831,7 @@ function clickRowDb(row, column, event) {
|
||||
return;
|
||||
}
|
||||
row.showPopover = false;
|
||||
// 仅”待签发(statusEnum==1)”允许编辑;”已签发(statusEnum==2)”及之后状态不允许编辑
|
||||
if (row.statusEnum == 1) {
|
||||
// 确保治疗类型为字符串,方便与单选框 label 对齐,默认为长期医嘱('1')
|
||||
row.therapyEnum = String(row.therapyEnum ?? '1');
|
||||
@@ -876,14 +906,13 @@ function handleDiagnosisChange(item) {
|
||||
function handleFocus(row, index) {
|
||||
rowIndex.value = index;
|
||||
row.showPopover = true;
|
||||
// el-popover 懒渲染,需要等两帧组件才会挂载
|
||||
const adviceType = row.adviceType !== undefined ? row.adviceType : adviceQueryParams.value.adviceType;
|
||||
// 用 adviceType + categoryCode 组合查找匹配的选项
|
||||
const selectValue = (adviceType == 1 && row.categoryCode) ? '1-' + row.categoryCode : adviceType;
|
||||
const selectedItem = adviceTypeList.value.find(item => item.value === selectValue) || adviceTypeList.value.find(item => item.adviceType === adviceType);
|
||||
// 诊疗(3)和手术(6)没有categoryCode,传空字符串给refresh,由子组件转为undefined不发送
|
||||
// 药品(1)才有categoryCode(如'1'=中成药,'2'=西药,'4'=中草药)
|
||||
const categoryCode = selectedItem ? selectedItem.categoryCode : (adviceQueryParams.value.categoryCode || '');
|
||||
// 修复Bug #486:当行没有显式选择医嘱类型时(row.adviceType为undefined),
|
||||
// 不传categoryCode,让搜索在全药库中进行;只有行已选择类型时才用对应categoryCode过滤
|
||||
const categoryCode = row.adviceType !== undefined ? (selectedItem ? selectedItem.categoryCode : '') : '';
|
||||
const searchKey = row.adviceName || '';
|
||||
|
||||
nextTick(() => {
|
||||
@@ -920,9 +949,12 @@ function handleChange(value) {
|
||||
// 用 adviceType + categoryCode 组合查找匹配的选项
|
||||
const selectValue = (adviceType == 1 && row?.categoryCode) ? '1-' + row.categoryCode : adviceType;
|
||||
const selectedItem = adviceTypeList.value.find(item => item.value === selectValue) || adviceTypeList.value.find(item => item.adviceType === adviceType);
|
||||
// 诊疗/手术的categoryCode为空字符串,由子组件转为undefined不发送
|
||||
const categoryCode = selectedItem ? selectedItem.categoryCode : (adviceQueryParams.value.categoryCode || '');
|
||||
tableRef.refresh(adviceType, categoryCode, value);
|
||||
// 修复Bug #486:当行没有显式选择医嘱类型时(row?.adviceType为undefined),
|
||||
// 不传categoryCode,让搜索在全药库中进行;只有行已选择类型时才用对应categoryCode过滤
|
||||
const categoryCode = row?.adviceType !== undefined ? (selectedItem ? selectedItem.categoryCode : '') : '';
|
||||
// 修复Bug #453:当adviceType为空字符串或NaN时,不传具体类型,让refresh函数根据searchKey决定搜索范围
|
||||
const effectiveAdviceType = (adviceType && !isNaN(Number(adviceType))) ? adviceType : '';
|
||||
tableRef.refresh(effectiveAdviceType, categoryCode, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1181,19 +1213,27 @@ function handleSave() {
|
||||
});
|
||||
// 此处签发处方和单行保存处方传参相同,后台已经将传参存为JSON字符串,此处直接转换为JSON即可
|
||||
loading.value = true;
|
||||
let list = saveList.map((item) => {
|
||||
const parsedContent = JSON.parse(item.contentJson);
|
||||
return {
|
||||
...parsedContent,
|
||||
adviceType: item.adviceType,
|
||||
requestId: item.requestId,
|
||||
dbOpType: '1',
|
||||
groupId: item.groupId,
|
||||
uniqueKey: undefined,
|
||||
// 确保 therapyEnum 被正确传递
|
||||
therapyEnum: parsedContent.therapyEnum || item.therapyEnum || '1',
|
||||
};
|
||||
});
|
||||
let list = [];
|
||||
try {
|
||||
list = saveList.map((item) => {
|
||||
const parsedContent = item.contentJson ? JSON.parse(item.contentJson) || {} : {};
|
||||
return {
|
||||
...parsedContent,
|
||||
adviceType: item.adviceType,
|
||||
requestId: item.requestId,
|
||||
dbOpType: '1',
|
||||
groupId: item.groupId,
|
||||
uniqueKey: undefined,
|
||||
// 确保 therapyEnum 被正确传递
|
||||
therapyEnum: parsedContent?.therapyEnum || item.therapyEnum || '1',
|
||||
};
|
||||
});
|
||||
} catch (error) {
|
||||
loading.value = false;
|
||||
isSaving.value = false;
|
||||
proxy.$modal.msgError('医嘱内容解析失败,请检查待签发医嘱');
|
||||
return;
|
||||
}
|
||||
// 保存签发按钮
|
||||
isSaving.value = true;
|
||||
console.log('签发处方参数:', {
|
||||
@@ -1208,15 +1248,18 @@ function handleSave() {
|
||||
if (res.code === 200) {
|
||||
proxy.$modal.msgSuccess('签发成功');
|
||||
isSaving.value = false;
|
||||
// 乐观更新:立即将已签发医嘱的状态设为"已签发",确保列表实时刷新
|
||||
saveList.forEach((item) => {
|
||||
const row = prescriptionList.value.find((r) => r.requestId && r.requestId === item.requestId);
|
||||
if (row) {
|
||||
row.statusEnum = 2;
|
||||
}
|
||||
});
|
||||
getListInfo(false);
|
||||
bindMethod.value = {};
|
||||
nextId.value == 1;
|
||||
|
||||
// 处方保存成功后,自动将医嘱信息同步至患者处置记录
|
||||
// handleEmrTreatment();
|
||||
nextId.value = 1;
|
||||
} else {
|
||||
proxy.$modal.msgError(res.message);
|
||||
conso;
|
||||
isSaving.value = false;
|
||||
}
|
||||
})
|
||||
@@ -1315,23 +1358,28 @@ function handleCancelEdit(row, index) {
|
||||
|
||||
function handleSaveSign(row, index) {
|
||||
if (row.adviceType != 2) {
|
||||
// 修复 Bug #488:严格校验 itemNo,确保非空且为有效字符串才发起请求
|
||||
let itemNo = row.adviceType == 1 ? row.methodCode : row.adviceDefinitionId;
|
||||
getBindDevice({ typeCode: row.adviceType, itemNo: itemNo }).then((res) => {
|
||||
if (res.data.length == 0) {
|
||||
return;
|
||||
}
|
||||
let openBindDialog = localStorage.getItem('doctor' + userStore.id);
|
||||
if (!JSON.parse(openBindDialog)) {
|
||||
proxy.$refs['orderBindInfoRef'].open(res.data);
|
||||
} else {
|
||||
// 如果弹窗不提示带出的项目,自动带出
|
||||
// 如果有未签发的项目,并且当前的项目没有带出过绑定项目,则自动带出
|
||||
if (!bindMethod.value[itemNo]) {
|
||||
handleOrderBindInfo(res.data);
|
||||
bindMethod.value[itemNo] = true;
|
||||
if (!itemNo || String(itemNo).trim() === '') {
|
||||
console.warn('绑定设备检查跳过:itemNo为空(adviceType=' + row.adviceType + ', adviceName=' + row.adviceName + ')');
|
||||
} else {
|
||||
getBindDevice({ typeCode: row.adviceType, itemNo: String(itemNo) }).then((res) => {
|
||||
if (res.data.length == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
let openBindDialog = localStorage.getItem('doctor' + userStore.id);
|
||||
if (!JSON.parse(openBindDialog)) {
|
||||
proxy.$refs['orderBindInfoRef'].open(res.data);
|
||||
} else {
|
||||
// 如果弹窗不提示带出的项目,自动带出
|
||||
// 如果有未签发的项目,并且当前的项目没有带出过绑定项目,则自动带出
|
||||
if (!bindMethod.value[itemNo]) {
|
||||
handleOrderBindInfo(res.data);
|
||||
bindMethod.value[itemNo] = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 更新UI状态
|
||||
@@ -1376,13 +1424,21 @@ function handleSaveSign(row, index) {
|
||||
savePrescription({ regAdviceSaveList: [row] }).then((res) => {
|
||||
if (res.code === 200) {
|
||||
proxy.$modal.msgSuccess('保存成功');
|
||||
nextId.value == 1;
|
||||
nextId.value = 1;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (prescriptionList.value[0].adviceName) {
|
||||
handleAddPrescription();
|
||||
}
|
||||
// 新增行:调用保存接口将数据持久化到后端
|
||||
row.dbOpType = '1';
|
||||
savePrescription({ regAdviceSaveList: [row] }).then((res) => {
|
||||
if (res.code === 200) {
|
||||
proxy.$modal.msgSuccess('保存成功');
|
||||
nextId.value = 1;
|
||||
// 保存成功后刷新列表,确保后端返回的数据带 requestId
|
||||
getListInfo(false);
|
||||
}
|
||||
});
|
||||
// 不需要再添加空行,保存成功后由 getListInfo 处理
|
||||
}
|
||||
adviceQueryParams.value.adviceType = undefined;
|
||||
}
|
||||
@@ -1423,32 +1479,40 @@ function handleSaveBatch() {
|
||||
.then((res) => {
|
||||
if (res.code === 200) {
|
||||
proxy.$modal.msgSuccess('保存成功');
|
||||
// 修复【#405】:保存成功后重置所有待保存行的 isEdit 为 false,锁定医嘱不再编辑
|
||||
// 修复 Bug #405:保存成功后锁定所有待保存行,避免医嘱条目仍处于可编辑状态
|
||||
// saveList 中的 item 与 prescriptionList 是同一对象引用,直接修改即可
|
||||
saveList.forEach(item => {
|
||||
const row = prescriptionList.value.find(r => r.uniqueKey === item.uniqueKey);
|
||||
if (row) row.isEdit = false;
|
||||
item.isEdit = false;
|
||||
});
|
||||
// 兜底:锁定所有 statusEnum == 1 的行,确保没有遗漏
|
||||
prescriptionList.value.forEach(row => {
|
||||
if (row.statusEnum == 1) {
|
||||
row.isEdit = false;
|
||||
}
|
||||
});
|
||||
expandOrder.value = [];
|
||||
getListInfo(false);
|
||||
nextId.value == 1;
|
||||
nextId.value = 1;
|
||||
isSaving.value = false;
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
isSaving.value = false;
|
||||
proxy.$modal.msgError(error?.msg || '保存失败,请重试');
|
||||
});
|
||||
}
|
||||
|
||||
function setValue(row) {
|
||||
// 构造单位列表
|
||||
// 构造单位列表,确保 value 始终为 String 类型,避免 el-select 值类型不匹配
|
||||
unitCodeList.value = [
|
||||
{ value: row.unitCode, label: row.unitCode_dictText, type: 'unit' },
|
||||
{ value: String(row.unitCode ?? ''), label: row.unitCode_dictText, type: 'unit' },
|
||||
{
|
||||
value: row.doseUnitCode,
|
||||
value: String(row.doseUnitCode ?? ''),
|
||||
label: row.doseUnitCode_dictText,
|
||||
type: 'dose',
|
||||
},
|
||||
{
|
||||
value: row.minUnitCode,
|
||||
value: String(row.minUnitCode ?? ''),
|
||||
label: row.minUnitCode_dictText,
|
||||
type: 'minUnit',
|
||||
},
|
||||
@@ -1513,9 +1577,9 @@ function setValue(row) {
|
||||
orgName: row.adviceType != 3 ? undefined : (findOrgName(row.orgId || row.positionId || patientInfo.value?.inHospitalOrgId) || row.orgName || patientInfo.value?.inHospitalOrgName || ''),
|
||||
// dose: undefined, Removed to preserve dose value from group package
|
||||
unitCodeList: unitCodeList.value,
|
||||
doseUnitCode: row.doseUnitCode,
|
||||
minUnitCode: row.minUnitCode,
|
||||
unitCode: row.partAttributeEnum == 1 ? row.minUnitCode : row.unitCode,
|
||||
doseUnitCode: String(row.doseUnitCode ?? ''),
|
||||
minUnitCode: String(row.minUnitCode ?? ''),
|
||||
unitCode: row.partAttributeEnum == 1 ? String(row.minUnitCode ?? '') : String(row.unitCode ?? ''),
|
||||
categoryEnum: row.categoryCode,
|
||||
definitionId: row.chargeItemDefinitionId,
|
||||
executeNum: 1,
|
||||
@@ -1531,6 +1595,10 @@ function setValue(row) {
|
||||
? new Decimal(selectedStock.price).div(row.partPercent).toFixed(6)
|
||||
: prevRow.minUnitPrice,
|
||||
positionName: selectedStock?.locationName,
|
||||
// 🔧 Bug #523 修复:初始化 totalPrice 为 0,避免总金额列显示为横杠
|
||||
totalPrice: row.quantity
|
||||
? new Decimal(row.quantity).mul(selectedStock?.price ?? 0).toFixed(6)
|
||||
: '0',
|
||||
}
|
||||
: {
|
||||
quantity: 1,
|
||||
@@ -1562,17 +1630,21 @@ function handleSaveGroup(orderGroupList) {
|
||||
// 🔥 新版组件已经预处理了数据,优先使用 mergedDetail
|
||||
const mergedDetail = item.mergedDetail || {
|
||||
...(item.orderDetailInfos || {}),
|
||||
adviceName: item.orderDetailInfos?.adviceName || item.orderDefinitionName || '未知项目',
|
||||
adviceName: item.orderDefinitionName || item.orderDetailInfos?.adviceName || '未知项目',
|
||||
adviceType: item.orderDetailInfos?.adviceType,
|
||||
adviceDefinitionId: item.orderDefinitionId || item.orderDetailInfos?.adviceDefinitionId,
|
||||
quantity: item.quantity,
|
||||
unitCode: item.unitCode || item.orderDetailInfos?.unitCode,
|
||||
unitCodeName: item.unitCodeName,
|
||||
dose: item.dose || item.orderDetailInfos?.dose,
|
||||
// 🔧 Bug #403 修复:dose/doseQuantity/dispensePerDuration 需用 null 检查,
|
||||
// 避免组套中值为 null 时回退到医嘱库的 orderDetailInfos
|
||||
dose: item.dose !== undefined && item.dose !== null ? item.dose : item.orderDetailInfos?.dose,
|
||||
rateCode: item.rateCode || item.orderDetailInfos?.rateCode,
|
||||
methodCode: item.methodCode || item.orderDetailInfos?.methodCode,
|
||||
dispensePerDuration: item.dispensePerDuration || item.orderDetailInfos?.dispensePerDuration,
|
||||
doseQuantity: item.doseQuantity,
|
||||
dispensePerDuration: item.dispensePerDuration !== undefined && item.dispensePerDuration !== null
|
||||
? item.dispensePerDuration : item.orderDetailInfos?.dispensePerDuration,
|
||||
doseQuantity: item.doseQuantity !== undefined && item.doseQuantity !== null
|
||||
? item.doseQuantity : item.orderDetailInfos?.doseQuantity,
|
||||
inventoryList: item.orderDetailInfos?.inventoryList || [],
|
||||
priceList: item.orderDetailInfos?.priceList || [],
|
||||
partPercent: item.orderDetailInfos?.partPercent || 1,
|
||||
@@ -1591,20 +1663,15 @@ function handleSaveGroup(orderGroupList) {
|
||||
setValue(mergedDetail);
|
||||
|
||||
// 创建新的处方项目
|
||||
// 🔧 Bug #403 修复:关键字段使用 null-safe 回退到 mergedDetail(已由 setValue 填充完整数据)
|
||||
// 先取 setValue 填充的行数据作为基础
|
||||
const baseRow = prescriptionList.value[rowIndex.value];
|
||||
const newRow = {
|
||||
...prescriptionList.value[rowIndex.value],
|
||||
...baseRow,
|
||||
patientId: patientInfo.value.patientId,
|
||||
encounterId: patientInfo.value.encounterId,
|
||||
accountId: accountId.value,
|
||||
quantity: item.quantity,
|
||||
methodCode: item.methodCode,
|
||||
rateCode: item.rateCode,
|
||||
dispensePerDuration: item.dispensePerDuration,
|
||||
dose: item.dose,
|
||||
doseQuantity: item.doseQuantity,
|
||||
executeNum: 1,
|
||||
unitCode: item.unitCode,
|
||||
unitCode_dictText: item.unitCodeName || '',
|
||||
statusEnum: 1,
|
||||
orgId: resolveOrgId(item.orderDetailInfos?.orgId || mergedDetail.orgId || patientInfo.value?.inHospitalOrgId) || '',
|
||||
// 🔧 修复:同时保存 orgName,确保树匹配不到时仍有中文名称可显示
|
||||
@@ -1613,19 +1680,33 @@ function handleSaveGroup(orderGroupList) {
|
||||
conditionId: conditionId.value,
|
||||
conditionDefinitionId: conditionDefinitionId.value,
|
||||
encounterDiagnosisId: encounterDiagnosisId.value,
|
||||
therapyEnum: prescriptionList.value[rowIndex.value]?.therapyEnum || '1',
|
||||
therapyEnum: baseRow?.therapyEnum || '1',
|
||||
};
|
||||
// 覆盖关键字段:优先使用 item 的值,其次 mergedDetail(已由 setValue 填充),最后 baseRow
|
||||
newRow.quantity = item.quantity ?? mergedDetail.quantity ?? baseRow.quantity;
|
||||
newRow.methodCode = item.methodCode ?? mergedDetail.methodCode ?? baseRow.methodCode;
|
||||
newRow.rateCode = item.rateCode ?? mergedDetail.rateCode ?? baseRow.rateCode;
|
||||
newRow.dispensePerDuration = item.dispensePerDuration ?? mergedDetail.dispensePerDuration ?? baseRow.dispensePerDuration;
|
||||
newRow.dose = item.dose ?? mergedDetail.dose ?? baseRow.dose;
|
||||
newRow.doseQuantity = item.doseQuantity ?? mergedDetail.doseQuantity ?? baseRow.doseQuantity;
|
||||
newRow.unitCode = item.unitCode ?? mergedDetail.unitCode ?? baseRow.unitCode;
|
||||
newRow.unitCode_dictText = item.unitCodeName || mergedDetail.unitCodeName || baseRow.unitCode_dictText || '';
|
||||
|
||||
// 计算价格和总量
|
||||
const unitInfo = unitCodeList.value.find((k) => k.value == item.unitCode);
|
||||
// 🔧 Bug #403 修复:使用 newRow.unitCode(已由 setValue 填充)而非 item.unitCode
|
||||
// 使用 ?? 替代 || 计算 partPercent,确保值为 0 时不会被错误替换
|
||||
const finalUnitCode = newRow.unitCode;
|
||||
const unitInfo = unitCodeList.value.find((k) => k.value == finalUnitCode);
|
||||
const finalQuantity = newRow.quantity;
|
||||
const partPercent = item.orderDetailInfos?.partPercent ?? mergedDetail.partPercent ?? baseRow.partPercent ?? 1;
|
||||
if (unitInfo && unitInfo.type == 'minUnit') {
|
||||
newRow.price = newRow.minUnitPrice;
|
||||
newRow.totalPrice = (item.quantity * newRow.minUnitPrice).toFixed(6);
|
||||
newRow.minUnitQuantity = item.quantity;
|
||||
newRow.totalPrice = ((finalQuantity || 0) * newRow.minUnitPrice).toFixed(6);
|
||||
newRow.minUnitQuantity = finalQuantity || 0;
|
||||
} else {
|
||||
newRow.price = newRow.unitPrice;
|
||||
newRow.totalPrice = (item.quantity * newRow.unitPrice).toFixed(6);
|
||||
newRow.minUnitQuantity = item.quantity * (item.orderDetailInfos?.partPercent || mergedDetail.partPercent || 1);
|
||||
newRow.totalPrice = ((finalQuantity || 0) * newRow.unitPrice).toFixed(6);
|
||||
newRow.minUnitQuantity = (finalQuantity || 0) * partPercent;
|
||||
}
|
||||
|
||||
newRow.contentJson = JSON.stringify(newRow);
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
<el-tab-pane label="检验申请" name="test">
|
||||
<TestApplication ref="testApplicationRef" :show-status-column="true" />
|
||||
</el-tab-pane>
|
||||
```vue
|
||||
|
||||
```
|
||||
<el-tab-pane label="检查申请" name="examine">
|
||||
<ExamineApplication ref="examineApplicationRef" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="汇总发药申请" name="summaryDrug">
|
||||
<SummaryDrugApplication ref="summaryDrugApplicationRef" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="手术申请" name="surgery">
|
||||
<SurgeryApplication ref="surgeryApplicationRef" />
|
||||
</el-tab-pane>
|
||||
@@ -47,6 +47,7 @@
|
||||
import {computed, onBeforeMount, onMounted, provide, reactive, ref, watch,} from 'vue';
|
||||
|
||||
import Emr from './emr/index.vue';
|
||||
import SummaryDrugApplication from './components/applicationShow/summaryDrugApplication.vue';
|
||||
import inPatientBarDoctorFold from '@/components/patientBar/inPatientBarDoctorFold.vue';
|
||||
import PatientList from '@/components/PatientList/patient-list.vue';
|
||||
import {localPatientInfo, updateLocalPatientInfo} from './store/localPatient';
|
||||
@@ -82,6 +83,7 @@ const currentPatientInfo = ref({});
|
||||
const testApplicationRef = ref();
|
||||
const examineApplicationRef = ref();
|
||||
const surgeryApplicationRef = ref();
|
||||
const summaryDrugApplicationRef = ref();
|
||||
const bloodTtransfusionAapplicationRef = ref();
|
||||
|
||||
// 患者列表相关逻辑
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
</template>
|
||||
</el-input>
|
||||
</div>
|
||||
<el-button type="primary">划价组套</el-button>
|
||||
<el-button type="primary" @click="openGroupSetDialog">划价组套</el-button>
|
||||
</div>
|
||||
<!-- 弹窗内容 - 左右布局 -->
|
||||
<div style="display: flex; gap: 20px; height: 70vh">
|
||||
@@ -147,6 +147,7 @@
|
||||
<el-select
|
||||
v-model="scope.row.selectUnitCode"
|
||||
placeholder="单位"
|
||||
filterable
|
||||
style="width: 100px"
|
||||
@change="unitCodeChange(scope.row)"
|
||||
>
|
||||
@@ -171,30 +172,32 @@
|
||||
v-if="scope.row.adviceType == 3"
|
||||
clearable
|
||||
filterable
|
||||
:filter-method="(val) => filterOptions(val, scope.row, 'departmentOptions')"
|
||||
v-model="scope.row.positionId"
|
||||
placeholder="选择科室"
|
||||
style="width: 220px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dept in departmentOptions"
|
||||
v-for="dept in getFilteredOptions(scope.row, 'departmentOptions')"
|
||||
:key="dept.id"
|
||||
:label="dept.name"
|
||||
:value="dept.id"
|
||||
:value="String(dept.id)"
|
||||
/>
|
||||
</el-select>
|
||||
<el-select
|
||||
v-if="scope.row.adviceType == 2"
|
||||
clearable
|
||||
filterable
|
||||
:filter-method="(val) => filterOptions(val, scope.row, 'locationOptions')"
|
||||
v-model="scope.row.positionId"
|
||||
placeholder="选择药房/耗材房"
|
||||
style="width: 220px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dept in locationOptions"
|
||||
v-for="dept in getFilteredOptions(scope.row, 'locationOptions')"
|
||||
:key="dept.value"
|
||||
:label="dept.label"
|
||||
:value="dept.value"
|
||||
:value="String(dept.value)"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
@@ -247,6 +250,58 @@
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 划价组套选择对话框 -->
|
||||
<el-dialog v-model="groupSetDialogVisible" title="划价组套选择" width="600px" :close-on-click-modal="false" append-to-body :z-index="3000">
|
||||
<div style="margin-bottom: 15px; display: flex; align-items: center; gap: 10px">
|
||||
<el-input
|
||||
v-model="groupSetSearchText"
|
||||
placeholder="请输入组套名称搜索"
|
||||
clearable
|
||||
style="width: 250px"
|
||||
@keyup.enter="loadGroupSets"
|
||||
>
|
||||
<template #append>
|
||||
<el-button icon="Search" @click="loadGroupSets" />
|
||||
</template>
|
||||
</el-input>
|
||||
<el-radio-group v-model="groupSetRange" @change="loadGroupSets">
|
||||
<el-radio-button :label="1">个人</el-radio-button>
|
||||
<el-radio-button :label="2">科室</el-radio-button>
|
||||
<el-radio-button :label="3">全院</el-radio-button>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
<el-table
|
||||
:data="groupSetList"
|
||||
v-loading="groupSetLoading"
|
||||
highlight-current-row
|
||||
border
|
||||
stripe
|
||||
@current-change="handleGroupSetSelect"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<el-table-column label="组套名称" min-width="180" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
{{ scope.row.name || scope.row.Name || '' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="使用范围" width="100" align="center">
|
||||
<template #default="scope">
|
||||
{{ getRangeText(scope.row) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="明细数量" width="100" align="center">
|
||||
<template #default="scope">
|
||||
{{ scope.row.detailList?.length || 0 }} 项
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-empty v-if="!groupSetLoading && groupSetList.length === 0" description="暂无划价组套数据" :image-size="80" />
|
||||
<div style="margin-top: 15px; text-align: right">
|
||||
<el-button @click="groupSetDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="applyGroupSet" :disabled="!selectedGroupSet">应用</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -254,6 +309,7 @@ import {computed, getCurrentInstance, onMounted, reactive, ref, watch} from 'vue
|
||||
import {ElMessage} from 'element-plus';
|
||||
import {formatDateStr} from '@/utils/index';
|
||||
import {getAdviceBaseInfo, getDiseaseTreatmentInitLoc, getOrgList} from './api.js';
|
||||
import {getOrderGroup} from '@/views/doctorstation/components/api.js';
|
||||
import useUserStore from '@/store/modules/user';
|
||||
|
||||
const { proxy } = getCurrentInstance();
|
||||
@@ -312,6 +368,8 @@ const locationOptions = ref([]);
|
||||
const searchText = ref('');
|
||||
const userId = ref('');
|
||||
const orgId = ref('');
|
||||
// 下拉框模糊搜索关键字(按行存储)
|
||||
const filterKeywords = ref({});
|
||||
const queryParams = ref({
|
||||
pageSize: 100,
|
||||
pageNum: 1,
|
||||
@@ -389,6 +447,14 @@ const submitData = reactive({
|
||||
});
|
||||
const adviceLoading = ref(false);
|
||||
|
||||
// 划价组套相关
|
||||
const groupSetDialogVisible = ref(false);
|
||||
const groupSetList = ref([]);
|
||||
const groupSetLoading = ref(false);
|
||||
const groupSetSearchText = ref('');
|
||||
const groupSetRange = ref(2);
|
||||
const selectedGroupSet = ref(null);
|
||||
|
||||
// 【优化核心】计算总金额 - 使用计算属性实现实时更新
|
||||
const totalAmount = computed(() => {
|
||||
return feeItemsList.value.reduce((sum, item) => {
|
||||
@@ -416,19 +482,73 @@ watch(
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
executeTime.value = formatDateStr(new Date(), 'YYYY-MM-DD HH:mm:ss');
|
||||
// 弹窗打开时重新加载科室和位置选项,确保数据最新
|
||||
loadDepartmentOptions();
|
||||
getDiseaseInitLoc(16);
|
||||
} else {
|
||||
resetData();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// 加载科室选项
|
||||
// 监听科室选项加载完成,为已添加的诊疗项目设置默认执行科室
|
||||
watch(
|
||||
() => departmentOptions.value,
|
||||
(depts) => {
|
||||
if (!depts || depts.length === 0) return;
|
||||
feeItemsList.value.forEach(item => {
|
||||
if (item.adviceType === 3 && !item.positionId) {
|
||||
const patientOrgId = props.patientInfo.organizationId;
|
||||
const matched = depts.find(d => String(d.id) === String(patientOrgId));
|
||||
item.positionId = matched ? String(matched.id) : String(depts[0].id);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// 监听位置选项加载完成,为已添加的耗材项目设置默认位置
|
||||
watch(
|
||||
() => locationOptions.value,
|
||||
(locs) => {
|
||||
if (!locs || locs.length === 0) return;
|
||||
feeItemsList.value.forEach(item => {
|
||||
if (item.adviceType === 2 && !item.positionId) {
|
||||
item.positionId = String(locs[0].value);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// 加载科室选项(支持树形/扁平两种数据结构)
|
||||
function loadDepartmentOptions() {
|
||||
getOrgList().then((res) => {
|
||||
if (res.data && res.data.records && res.data.records.length > 0) {
|
||||
departmentOptions.value = res.data.records[0].children || [];
|
||||
}
|
||||
});
|
||||
getOrgList()
|
||||
.then((res) => {
|
||||
if (res.data) {
|
||||
// 尝试从树形结构中取:records[0].children
|
||||
if (res.data.records && res.data.records.length > 0) {
|
||||
if (res.data.records[0].children && res.data.records[0].children.length > 0) {
|
||||
departmentOptions.value = res.data.records[0].children;
|
||||
return;
|
||||
}
|
||||
// 如果 records[0] 有 id 和 name(非树根节点),直接用所有 records
|
||||
if (res.data.records[0].id) {
|
||||
departmentOptions.value = res.data.records;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 兜底:如果 records 不存在或为空,尝试直接使用 data 本身
|
||||
if (Array.isArray(res.data)) {
|
||||
departmentOptions.value = res.data;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 所有方式都失败,置空
|
||||
departmentOptions.value = [];
|
||||
})
|
||||
.catch(() => {
|
||||
console.warn('科室列表加载失败(可能无权限)');
|
||||
departmentOptions.value = [];
|
||||
});
|
||||
}
|
||||
|
||||
// 加载收费组套数据
|
||||
@@ -447,9 +567,37 @@ function getAdviceBaseInfos() {
|
||||
});
|
||||
}
|
||||
function getDiseaseInitLoc() {
|
||||
getDiseaseTreatmentInitLoc(16).then((response) => {
|
||||
console.log('Disease Treatment Init Loc:', response);
|
||||
locationOptions.value = response.data.locationOptions;
|
||||
getDiseaseTreatmentInitLoc(16)
|
||||
.then((response) => {
|
||||
console.log('Disease Treatment Init Loc:', response);
|
||||
locationOptions.value = response.data.locationOptions;
|
||||
})
|
||||
.catch(() => {
|
||||
console.warn('位置列表加载失败(可能无权限)');
|
||||
locationOptions.value = [];
|
||||
});
|
||||
}
|
||||
// 下拉框模糊搜索过滤(自定义filter-method,配合element-plus filterable使用)
|
||||
function filterOptions(val, row, optionsKey) {
|
||||
const key = row.adviceDefinitionId + '_' + optionsKey;
|
||||
if (!val || val.trim() === '') {
|
||||
delete filterKeywords.value[key];
|
||||
} else {
|
||||
filterKeywords.value[key] = val.toLowerCase();
|
||||
}
|
||||
}
|
||||
function getFilteredOptions(row, optionsKey) {
|
||||
const key = row.adviceDefinitionId + '_' + optionsKey;
|
||||
const keyword = filterKeywords.value[key];
|
||||
const options = optionsKey === 'departmentOptions' ? departmentOptions.value : locationOptions.value;
|
||||
if (!keyword) {
|
||||
return options;
|
||||
}
|
||||
return options.filter(item => {
|
||||
const name = (item.name || item.label || '').toLowerCase();
|
||||
const id = String(item.id || item.value || '').toLowerCase();
|
||||
const py = (item.pyStr || '').toLowerCase();
|
||||
return name.includes(keyword) || id.includes(keyword) || py.includes(keyword);
|
||||
});
|
||||
}
|
||||
// 获取组套类型文本
|
||||
@@ -458,19 +606,26 @@ function getItemType_Text(type) {
|
||||
return map[type] || '其他';
|
||||
}
|
||||
function getUnitCodeOptions(row) {
|
||||
const unitCodes = [
|
||||
{ code: row.unitCode, codeText: row.unitCode_dictText },
|
||||
{ code: row.minUnitCode, codeText: row.minUnitCode_dictText },
|
||||
];
|
||||
// 使用 Set 来跟踪已经存在的 code
|
||||
const unitCodes = [];
|
||||
// 大单位:优先用 code,code 缺失时用字典文本兜底
|
||||
if (row.unitCode != null && String(row.unitCode) !== '') {
|
||||
unitCodes.push({ code: String(row.unitCode), codeText: row.unitCode_dictText });
|
||||
} else if (row.unitCode_dictText) {
|
||||
unitCodes.push({ code: row.unitCode_dictText, codeText: row.unitCode_dictText });
|
||||
}
|
||||
// 小单位:同上
|
||||
if (row.minUnitCode != null && String(row.minUnitCode) !== '') {
|
||||
unitCodes.push({ code: String(row.minUnitCode), codeText: row.minUnitCode_dictText });
|
||||
} else if (row.minUnitCode_dictText) {
|
||||
unitCodes.push({ code: row.minUnitCode_dictText, codeText: row.minUnitCode_dictText });
|
||||
}
|
||||
// 去重
|
||||
const seenCodes = new Set();
|
||||
const uniqueUnitCodes = unitCodes.filter((item) => {
|
||||
// 如果 Set 中没有这个 code,就保留它,并把它加入 Set
|
||||
if (!seenCodes.has(item.code)) {
|
||||
seenCodes.add(item.code);
|
||||
return true;
|
||||
}
|
||||
// 如果已经存在,就过滤掉
|
||||
return false;
|
||||
});
|
||||
return uniqueUnitCodes;
|
||||
@@ -481,11 +636,11 @@ function unitCodeChange(row) {
|
||||
// 获取价格
|
||||
const price = row.priceList?.[0]?.price || 0;
|
||||
|
||||
// 根据选择的单位调整单价
|
||||
if (row.selectUnitCode === row.unitCode) {
|
||||
// 根据选择的单位调整单价(统一用字符串比较)
|
||||
if (String(row.selectUnitCode) === String(row.unitCode)) {
|
||||
// 如果选择的是大单位 (如 "盒")
|
||||
row.unitPrice = price.toFixed(6); // 单价就是原价
|
||||
} else if (row.selectUnitCode === row.minUnitCode) {
|
||||
} else if (String(row.selectUnitCode) === String(row.minUnitCode)) {
|
||||
// 如果选择的是小单位 (如 "个")
|
||||
row.unitPrice = (price / (row.partPercent || 1)).toFixed(6); // 单价 = 原价 / 拆零比
|
||||
}
|
||||
@@ -527,14 +682,54 @@ function selectChange(row) {
|
||||
const price = row.priceList?.[0]?.price || 0;
|
||||
//获取大小单位
|
||||
const uniqueUnitCodes = getUnitCodeOptions(row);
|
||||
// 设置默认单位:优先使用 minUnitCode(小单位),回退到 unitCode(大单位)
|
||||
let defaultUnitCode = '';
|
||||
if (row.minUnitCode) {
|
||||
defaultUnitCode = String(row.minUnitCode);
|
||||
} else if (row.unitCode) {
|
||||
defaultUnitCode = String(row.unitCode);
|
||||
} else if (row.minUnitCode_dictText) {
|
||||
// 兜底:如果 minUnitCode 为空但字典文本存在,使用文本作为选项值
|
||||
defaultUnitCode = row.minUnitCode_dictText;
|
||||
} else if (row.unitCode_dictText) {
|
||||
defaultUnitCode = row.unitCode_dictText;
|
||||
}
|
||||
// 如果默认单位不在 uniqueUnitCodes 中,添加兜底选项
|
||||
if (defaultUnitCode && !uniqueUnitCodes.some(u => u.code === defaultUnitCode)) {
|
||||
uniqueUnitCodes.push({ code: defaultUnitCode, codeText: defaultUnitCode });
|
||||
}
|
||||
// 设置默认执行科室/位置(统一转为字符串,避免 el-select 类型不匹配)
|
||||
let defaultPositionId = undefined;
|
||||
if (row.adviceType === 3 && departmentOptions.value.length > 0) {
|
||||
// 诊疗:
|
||||
// 1. 优先使用诊疗目录项目的"所属科室"(row.orgId)
|
||||
// 2. 其次使用患者当前病房科室(patientInfo.organizationId)
|
||||
// 3. 最后取第一个科室
|
||||
const orgIdPriority = [row.orgId, props.patientInfo.organizationId];
|
||||
for (const id of orgIdPriority) {
|
||||
if (id) {
|
||||
const matched = departmentOptions.value.find(d => String(d.id) === String(id));
|
||||
if (matched) {
|
||||
defaultPositionId = String(matched.id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!defaultPositionId) {
|
||||
defaultPositionId = String(departmentOptions.value[0].id);
|
||||
}
|
||||
} else if (row.adviceType === 2 && locationOptions.value.length > 0) {
|
||||
// 耗材:默认取第一个药房/耗材房
|
||||
defaultPositionId = String(locationOptions.value[0].value);
|
||||
}
|
||||
//插入费用列表
|
||||
feeItemsList.value.push({
|
||||
...row,
|
||||
uniqueUnitCodes: uniqueUnitCodes,
|
||||
unitPrice: (price / (row.partPercent || 1)).toFixed(6), // 根据拆零比计算单价
|
||||
quantity: 1,
|
||||
// positionId: row.positionId === null || row.positionId === undefined ? orgId : row.positionId, // 默认执行科室
|
||||
selectUnitCode: row.minUnitCode, // 默认选择小单位
|
||||
positionId: defaultPositionId, // 默认执行科室/位置(字符串类型)
|
||||
selectUnitCode: defaultUnitCode, // 默认选择小单位
|
||||
});
|
||||
}
|
||||
|
||||
@@ -648,6 +843,120 @@ function resetData() {
|
||||
searchText.value = '';
|
||||
executeTime.value = '';
|
||||
}
|
||||
|
||||
// 划价组套相关功能
|
||||
function openGroupSetDialog() {
|
||||
console.log('openGroupSetDialog called');
|
||||
groupSetDialogVisible.value = true;
|
||||
groupSetSearchText.value = '';
|
||||
selectedGroupSet.value = null;
|
||||
loadGroupSets();
|
||||
}
|
||||
|
||||
function loadGroupSets() {
|
||||
groupSetLoading.value = true;
|
||||
const params = { organizationId: orgId.value };
|
||||
// 传递搜索关键字,后端 /group-package-for-order 虽不直接支持 searchKey,
|
||||
// 但保持参数传递以便后续扩展
|
||||
if (groupSetSearchText.value && groupSetSearchText.value.trim()) {
|
||||
params.searchKey = groupSetSearchText.value.trim();
|
||||
}
|
||||
getOrderGroup(params)
|
||||
.then((res) => {
|
||||
const data = res?.data || {};
|
||||
let rawList = [];
|
||||
if (groupSetRange.value === 1) {
|
||||
rawList = data.personalList || [];
|
||||
} else if (groupSetRange.value === 2) {
|
||||
rawList = data.organizationList || [];
|
||||
} else {
|
||||
rawList = data.hospitalList || [];
|
||||
}
|
||||
// 客户端过滤:根据搜索关键字过滤组套名称
|
||||
const keyword = groupSetSearchText.value?.trim()?.toLowerCase();
|
||||
if (keyword) {
|
||||
groupSetList.value = rawList.filter(item => {
|
||||
const name = (item.name || item.Name || '').toLowerCase();
|
||||
return name.includes(keyword);
|
||||
});
|
||||
} else {
|
||||
groupSetList.value = rawList;
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.warn('组套列表加载失败(可能无权限):', err);
|
||||
ElMessage.warning('组套列表加载失败,当前暂无可用组套');
|
||||
groupSetList.value = [];
|
||||
})
|
||||
.finally(() => {
|
||||
groupSetLoading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
function getRangeText(row) {
|
||||
// 后端未返回rangeCode,根据当前选中的范围标签显示
|
||||
const rangeMap = { 1: '个人', 2: '科室', 3: '全院' };
|
||||
if (row.rangeCode_dictText) return row.rangeCode_dictText;
|
||||
return rangeMap[groupSetRange.value] || '';
|
||||
}
|
||||
|
||||
function handleGroupSetSelect(row) {
|
||||
selectedGroupSet.value = row;
|
||||
}
|
||||
|
||||
function applyGroupSet() {
|
||||
if (!selectedGroupSet.value) {
|
||||
ElMessage.warning('请先选择一个组套');
|
||||
return;
|
||||
}
|
||||
const detailList = selectedGroupSet.value.detailList;
|
||||
if (!detailList || detailList.length === 0) {
|
||||
ElMessage.warning('该组套没有明细项');
|
||||
return;
|
||||
}
|
||||
let successCount = 0;
|
||||
detailList.forEach((item) => {
|
||||
const orderDetail = item.orderDetailInfos || {};
|
||||
const feeItem = {
|
||||
adviceDefinitionId: item.orderDefinitionId || orderDetail.adviceDefinitionId,
|
||||
adviceName: orderDetail.adviceName || item.orderDefinitionName || '未知项目',
|
||||
adviceType: orderDetail.adviceType,
|
||||
unitPrice: orderDetail.unitPrice,
|
||||
minUnitPrice: orderDetail.minUnitPrice,
|
||||
inventoryList: orderDetail.inventoryList || [],
|
||||
priceList: orderDetail.priceList || [],
|
||||
partPercent: orderDetail.partPercent || 1,
|
||||
positionId: item.positionId || orderDetail.positionId,
|
||||
defaultLotNumber: orderDetail.defaultLotNumber,
|
||||
unitCode: item.unitCode || orderDetail.unitCode,
|
||||
unitCode_dictText: item.unitCodeName || orderDetail.unitCode_dictText,
|
||||
minUnitCode: orderDetail.minUnitCode,
|
||||
doseUnitCode: orderDetail.doseUnitCode,
|
||||
categoryCode: orderDetail.categoryCode,
|
||||
pharmacologyCategoryCode: orderDetail.pharmacologyCategoryCode,
|
||||
partAttributeEnum: orderDetail.partAttributeEnum,
|
||||
chargeItemDefinitionId: orderDetail.chargeItemDefinitionId,
|
||||
adviceTableName: orderDetail.adviceTableName,
|
||||
methodCode: item.methodCode || orderDetail.methodCode,
|
||||
rateCode: item.rateCode || orderDetail.rateCode,
|
||||
dose: item.dose || orderDetail.dose,
|
||||
doseQuantity: item.doseQuantity,
|
||||
dispensePerDuration: item.dispensePerDuration || orderDetail.dispensePerDuration,
|
||||
dosageInstruction: orderDetail.dosageInstruction,
|
||||
skinTestFlag: orderDetail.skinTestFlag,
|
||||
injectFlag: orderDetail.injectFlag,
|
||||
quantity: item.quantity || 1,
|
||||
chrgitmLv_dictText: orderDetail.chrgitmLv_dictText,
|
||||
volume: orderDetail.volume,
|
||||
};
|
||||
selectChange(feeItem);
|
||||
successCount++;
|
||||
});
|
||||
if (successCount > 0) {
|
||||
ElMessage.success(`已添加 ${successCount} 项组套费用`);
|
||||
}
|
||||
groupSetDialogVisible.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -28,6 +28,7 @@ export function getOrgList() {
|
||||
return request({
|
||||
url: '/base-data-manage/organization/organization',
|
||||
method: 'get',
|
||||
params: { pageSize: 100, pageNum: 1 },
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -463,20 +463,45 @@ function watchPatientSelection() {
|
||||
}, 300);
|
||||
}
|
||||
|
||||
/** 查询科室 */
|
||||
/** 查询科室(支持树形/扁平多种响应结构) */
|
||||
const getLocationInfo = () => {
|
||||
getOrgList().then((res) => {
|
||||
orgOptions.value = res.data?.records[0]?.children;
|
||||
if (!res.data) {
|
||||
orgOptions.value = [];
|
||||
return;
|
||||
}
|
||||
// 尝试从树形结构取:records[0].children
|
||||
if (res.data.records && res.data.records.length > 0) {
|
||||
if (res.data.records[0].children && res.data.records[0].children.length > 0) {
|
||||
orgOptions.value = res.data.records[0].children;
|
||||
return;
|
||||
}
|
||||
// 如果 records[0] 有 id 和 name(非树根节点),直接用所有 records
|
||||
if (res.data.records[0].id) {
|
||||
orgOptions.value = res.data.records;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 兜底:如果 data 本身是数组
|
||||
if (Array.isArray(res.data)) {
|
||||
orgOptions.value = res.data;
|
||||
return;
|
||||
}
|
||||
orgOptions.value = [];
|
||||
}).catch(() => {
|
||||
console.warn('科室列表加载失败(可能无权限)');
|
||||
orgOptions.value = [];
|
||||
});
|
||||
};
|
||||
getLocationInfo();
|
||||
|
||||
// 映射
|
||||
// 映射(查找失败时返回 '-' 而非显示内码)
|
||||
const selectOrg = (itemid) => {
|
||||
if (!itemid) return '-';
|
||||
const item = orgOptions.value.find((item) => {
|
||||
return item.id == itemid;
|
||||
});
|
||||
return item?.name;
|
||||
return item?.name || '-';
|
||||
};
|
||||
// 重置
|
||||
const onReset = () => {
|
||||
|
||||
@@ -273,8 +273,9 @@ function handleSearch() {
|
||||
// 清除缓存(搜索时需要重新加载)
|
||||
patientDataCache.value.clear();
|
||||
|
||||
// 重新加载所有已展开病区的患者列表
|
||||
reloadAllPatients();
|
||||
// 通过递增 key 强制重新渲染树组件,触发重新加载所有病区患者列表
|
||||
// 此时 searchKey 已有值,loadPatientList 会将 searchKey 传给后端进行过滤
|
||||
treeKey.value += 1;
|
||||
}
|
||||
|
||||
// 暴露方法供外部调用
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user