|
|
@@ -3,11 +3,13 @@ package thyyxxk.webserver.service.medicaladvice.patientinfo;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
+import thyyxxk.webserver.config.envionment.YzConfig;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.dao.his.inpatient.PatientDao;
|
|
|
import thyyxxk.webserver.dao.his.medicaladvice.patientinfo.AdjustBedDao;
|
|
|
@@ -19,6 +21,7 @@ import thyyxxk.webserver.entity.medicaladvice.medicamanage.patientinfo.ZkBedVo;
|
|
|
import thyyxxk.webserver.entity.medicaladvice.medicamanage.patientinfo.ZyBedMi;
|
|
|
import thyyxxk.webserver.entity.zhuyuanyisheng.ZyOrderZk;
|
|
|
import thyyxxk.webserver.service.hutoolcache.DeptCache;
|
|
|
+import thyyxxk.webserver.service.zhuyuanyisheng.YiZhuLuRuServer;
|
|
|
import thyyxxk.webserver.utils.AssertUtil;
|
|
|
import thyyxxk.webserver.utils.CommonUtil;
|
|
|
import thyyxxk.webserver.utils.ResultVoUtil;
|
|
|
@@ -37,34 +40,25 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
+@RequiredArgsConstructor
|
|
|
public class ZkManageService {
|
|
|
private final ZkManageDao dao;
|
|
|
private final PatientDao patientDao;
|
|
|
private final AdjustBedDao adjustBedDao;
|
|
|
private final DeptCache deptCache;
|
|
|
private final RestTemplate template;
|
|
|
- //手术病室编码
|
|
|
- private static final String SJ_DEPT_CODE = "8000130";
|
|
|
-
|
|
|
- @Autowired
|
|
|
- public ZkManageService(ZkManageDao dao, PatientDao patientDao, AdjustBedDao adjustBedDao, DeptCache deptCache, RestTemplate template) {
|
|
|
- this.dao = dao;
|
|
|
- this.patientDao = patientDao;
|
|
|
- this.adjustBedDao = adjustBedDao;
|
|
|
- this.deptCache = deptCache;
|
|
|
- this.template = template;
|
|
|
- }
|
|
|
-
|
|
|
+ private final YzConfig yzConfig;
|
|
|
+ private final YiZhuLuRuServer yiZhuLuRuServer;
|
|
|
|
|
|
public List<ZyActpatient> queryZkPatient(Map<String, String> query) {
|
|
|
- AssertUtil.isnotBlank(query.get("wardCode"),"病室编码不能为空");
|
|
|
+ AssertUtil.isnotBlank(query.get("wardCode"), "病室编码不能为空");
|
|
|
List<ZyActpatient> list = dao.selectZkPatient(query.get("keyWard"), query.get("wardCode"));
|
|
|
CommonUtil.BeanTrim(list);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
public List<ZkBedVo> queryZkBedVo(Map<String, String> query) {
|
|
|
- AssertUtil.isnotBlank(query.get("wardCode"),"病室编码不能为空");
|
|
|
+ AssertUtil.isnotBlank(query.get("wardCode"), "病室编码不能为空");
|
|
|
List<ZkBedVo> list = dao.selectZkBedVo(query.get("wardCode"));
|
|
|
CommonUtil.BeanTrim(list);
|
|
|
return list;
|
|
|
@@ -76,19 +70,19 @@ public class ZkManageService {
|
|
|
AssertUtil.isnotBlank(param.getWardCode(), "病室不能为空");
|
|
|
AssertUtil.isnotBlank(param.getDeptCode(), "转科病室不能为空");
|
|
|
AssertUtil.isnotBlank(param.getZkDept(), "小科室不能为空");
|
|
|
- if(!passZk(param)){
|
|
|
+ if (!passZk(param)) {
|
|
|
Map<String, Object> map = dao.selectZkYz(param);
|
|
|
if (CollUtil.isEmpty(map) || Convert.toInt(map.get("zk_count"), 0) == 0) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, StrUtil.format("{}病人没有转科医嘱,不可做转科处理!", param.getInpatientNo()));
|
|
|
}
|
|
|
ZyOrderZk zyOrderZk = dao.selectZkOrder(Convert.toBigDecimal(map.get("act_order_no")));
|
|
|
- if(zyOrderZk == null){
|
|
|
+ if (zyOrderZk == null) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, StrUtil.format("{}病人没有转科医嘱详情,请确认!", param.getInpatientNo()));
|
|
|
}
|
|
|
|
|
|
- if(!param.getDeptCode().equals(zyOrderZk.getNewWard()) || !param.getZkDept().equals(zyOrderZk.getNewDept())){
|
|
|
+ if (!param.getDeptCode().equals(zyOrderZk.getNewWard()) || !param.getZkDept().equals(zyOrderZk.getNewDept())) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, StrUtil.format("{}病人选择的转科病区或小科室不对,正确的转科医嘱为病区:[{}],小科室:[{}]!",
|
|
|
- param.getInpatientNo(),deptCache.getDeptName(zyOrderZk.getNewWard()),deptCache.getDeptName(zyOrderZk.getNewDept())));
|
|
|
+ param.getInpatientNo(), deptCache.getDeptName(zyOrderZk.getNewWard()), deptCache.getDeptName(zyOrderZk.getNewDept())));
|
|
|
}
|
|
|
Integer countZk = dao.selectZyZkList(param.getInpatientNo(), param.getAdmissTimes(), Convert.toBigDecimal(map.get("act_order_no")));
|
|
|
if (countZk > 0) {
|
|
|
@@ -112,11 +106,13 @@ public class ZkManageService {
|
|
|
patientDao.zyReceiveDrug(param.getInpatientNo(), param.getAdmissTimes(), infant);
|
|
|
//接收医嘱
|
|
|
patientDao.zyReceiveOne(param.getInpatientNo(), param.getAdmissTimes(), infant);
|
|
|
- return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE,"药品和医嘱接收成功!");
|
|
|
+ return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE, "药品和医嘱接收成功!");
|
|
|
}
|
|
|
|
|
|
- private boolean passZk(ZkBedVo param){
|
|
|
- if(SJ_DEPT_CODE.equals(param.getDeptCode()) || SJ_DEPT_CODE.equals(param.getWardCode())){
|
|
|
+ private boolean passZk(ZkBedVo param) {
|
|
|
+ String SJ_DEPT_CODE = yzConfig.getShoushubingqu();
|
|
|
+
|
|
|
+ if (SJ_DEPT_CODE.equals(param.getDeptCode()) || SJ_DEPT_CODE.equals(param.getWardCode())) {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
@@ -127,18 +123,18 @@ public class ZkManageService {
|
|
|
List<ZkBedVo> data = param.stream().filter(item -> StrUtil.isNotBlank(item.getInpatientNo())).collect(Collectors.toList());
|
|
|
AssertUtil.isnotBlank(data, "保存数据不能为空");
|
|
|
String userId = TokenUtil.getInstance().getTokenUserId();
|
|
|
- for(ZkBedVo item : data){
|
|
|
- AssertUtil.isnotBlank(item.getZkDept(),StrUtil.format("{}病人转科科室不能为空!",item.getInpatientNo()));
|
|
|
+ for (ZkBedVo item : data) {
|
|
|
+ AssertUtil.isnotBlank(item.getZkDept(), StrUtil.format("{}病人转科科室不能为空!", item.getInpatientNo()));
|
|
|
int count = 0;
|
|
|
- if(!item.getInpatientNo().contains("$")){
|
|
|
+ if (!item.getInpatientNo().contains("$")) {
|
|
|
count = dao.countBaby(item.getInpatientNo() + "$%");
|
|
|
}
|
|
|
- if(count > 0){
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, StrUtil.format("{}病人有婴儿信息,不可做转科处理!",item.getInpatientNo()));
|
|
|
+ if (count > 0) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, StrUtil.format("{}病人有婴儿信息,不可做转科处理!", item.getInpatientNo()));
|
|
|
}
|
|
|
Integer hasBedNo = adjustBedDao.isIdleBedNo(item.getBedNo(), item.getWardCode());
|
|
|
- if(hasBedNo == null){
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, StrUtil.format("{}病人转科的床位已经有病人了,请刷新重新分配床位!",item.getInpatientNo()));
|
|
|
+ if (hasBedNo == null) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, StrUtil.format("{}病人转科的床位已经有病人了,请刷新重新分配床位!", item.getInpatientNo()));
|
|
|
}
|
|
|
//清空原床位
|
|
|
ZyBedMi zyBedMi = new ZyBedMi();
|
|
|
@@ -162,23 +158,25 @@ public class ZkManageService {
|
|
|
dao.updateZkZyActpatien(item);
|
|
|
dao.insertZyAdt(item);
|
|
|
item.setOpId(userId);
|
|
|
- if(SJ_DEPT_CODE.equals(item.getOrigDept()) || SJ_DEPT_CODE.equals(item.getWardCode())){
|
|
|
+ String SJ_DEPT_CODE = yzConfig.getShoushubingqu();
|
|
|
+ if (SJ_DEPT_CODE.equals(item.getOrigDept()) || SJ_DEPT_CODE.equals(item.getWardCode())) {
|
|
|
dao.insertZyZkListNoActOrderNo(item);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
dao.insertZyZkList(item);
|
|
|
}
|
|
|
+ yiZhuLuRuServer.updateChargeByWardCode(item.getInpatientNo(), item.getAdmissTimes());
|
|
|
}
|
|
|
- return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE,"保存成功");
|
|
|
+ return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE, "保存成功");
|
|
|
}
|
|
|
|
|
|
public ResultVo<String> createPatientDoor(List<ZkBedVo> param) {
|
|
|
- for(ZkBedVo zkBedVo : param){
|
|
|
+ for (ZkBedVo zkBedVo : param) {
|
|
|
try {
|
|
|
Map<String, Object> paramMap = new HashMap<>();
|
|
|
paramMap.put("patNo", StrUtil.trim(zkBedVo.getInpatientNo()));
|
|
|
template.postForObject("http://172.16.32.167:20923/thyy/api/haikang/door/createPatient", paramMap, ResultVo.class);
|
|
|
- }catch (Exception e){
|
|
|
- log.error("住院号="+zkBedVo.getInpatientNo()+"创建门禁报错,{}",e);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("住院号=" + zkBedVo.getInpatientNo() + "创建门禁报错,{}", e);
|
|
|
}
|
|
|
}
|
|
|
return ResultVoUtil.success();
|