|
@@ -1,17 +1,17 @@
|
|
|
package thyyxxk.webserver.service.zhuyuanyisheng;
|
|
|
|
|
|
+import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.sun.org.apache.bcel.internal.generic.NEW;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.ListUtils;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import thyyxxk.webserver.config.exception.BizException;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.constants.Capacity;
|
|
|
import thyyxxk.webserver.constants.sidicts.ChargeStatus;
|
|
@@ -73,6 +73,10 @@ public class YiZhuLuRuServer {
|
|
|
private final String SMALL_PACKAGE = "01";
|
|
|
private final String BIG_PACKAGE = "99";
|
|
|
|
|
|
+ private YiZhuLuRuServer getThis() {
|
|
|
+ return SpringUtil.getBean(this.getClass());
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public YiZhuLuRuServer(YiZhuLuRuDao dao, PublicServer publicServer, RedisLikeService redisLikeService, XiangMuLuRuDao xiangMuLuRuDao, RationalUseServer rationalUseServer, DrgWebServices drgWebServices) {
|
|
|
this.dao = dao;
|
|
@@ -83,6 +87,7 @@ public class YiZhuLuRuServer {
|
|
|
this.drgWebServices = drgWebServices;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public ResultVo<String> getOrderNo() {
|
|
|
return ResultVoUtil.success(BigDecimal.valueOf(publicServer.getActOrderNo()).stripTrailingZeros().toPlainString());
|
|
|
}
|
|
@@ -125,7 +130,6 @@ public class YiZhuLuRuServer {
|
|
|
public ResultVo<List<XinZhenYzActOrder>> huoQuYiZhuShuJu(YiZhuFeiYongChaXunTiaoJian param) {
|
|
|
QueryWrapper<?> qw = new QueryWrapper<>();
|
|
|
qw.eq("a.inpatient_no", param.getPatNo()).eq("a.admiss_times", param.getTimes());
|
|
|
-// qw.orderByDesc("a.act_order_no");
|
|
|
qw.orderByAsc("a.order_time");
|
|
|
List<XinZhenYzActOrder> yiZhuList = dao.huoQuYiZhuShuJu(qw);
|
|
|
// 还有那些没有被匹配的子级医嘱
|
|
@@ -298,8 +302,8 @@ public class YiZhuLuRuServer {
|
|
|
String userCode = TokenUtil.getTokenUserId();
|
|
|
// 获取医生开药品的权限
|
|
|
Integer doctorLevel = dao.huoQuYiShenDengJi(userCode);
|
|
|
- XinZhenYiZhu huanZheXinXi = dao.huoQuHuanZheXinXi(param.getInpatientNo(), param.getAdmissTimes());
|
|
|
- Map<String, XinZhenYzActOrder> drug = getDrugInformation(yaoPingCode, huanZheXinXi.getZkWard());
|
|
|
+ XinZhenYiZhu patInfo = dao.huoQuHuanZheXinXi(param.getInpatientNo(), param.getAdmissTimes());
|
|
|
+ Map<String, XinZhenYzActOrder> drug = getDrugInformation(yaoPingCode, patInfo.getZkWard());
|
|
|
Map<String, List<XinZhenYzActOrder>> project = getProjectInformation(xiangMuCode);
|
|
|
|
|
|
// 是否可以确认
|
|
@@ -323,7 +327,7 @@ public class YiZhuLuRuServer {
|
|
|
}
|
|
|
|
|
|
confirmOrderInformation.add(item.getActOrderNo());
|
|
|
- Map<String, Object> errorMessageMap = checkData(item, drug, project, huanZheXinXi, doctorLevel);
|
|
|
+ Map<String, Object> errorMessageMap = checkData(item, drug, project, patInfo, doctorLevel);
|
|
|
String key = item.getId();
|
|
|
if (rationalUseOfMedicine.containsKey(key)) {
|
|
|
List<String> temp = (List<String>) errorMessageMap.get("error");
|
|
@@ -357,19 +361,30 @@ public class YiZhuLuRuServer {
|
|
|
for (BigDecimal decimal : confirmOrderInformation) {
|
|
|
dao.confirmOrders(decimal, userCode, new Date());
|
|
|
}
|
|
|
+ getThis().drgOrderUpdate(patInfo.getInpatientNo() + "_" + patInfo.getAdmissTimes());
|
|
|
+ log.info("确认的医嘱:{}", JSON.toJSONString(yiZhuList));
|
|
|
+ return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 在开医嘱时 drg 需要调用一下这个接口
|
|
|
+ *
|
|
|
+ * @param patientNo 患者id
|
|
|
+ */
|
|
|
+ @Async
|
|
|
+ public void drgOrderUpdate(String patientNo) {
|
|
|
try {
|
|
|
JSONObject jsonDrg = new JSONObject();
|
|
|
- jsonDrg.put("visit_id", Collections.singletonList(huanZheXinXi.getInpatientNo() + "_" + huanZheXinXi.getAdmissTimes()));
|
|
|
+ jsonDrg.put("visit_id", Collections.singletonList(patientNo));
|
|
|
jsonDrg.put("scene_type", 1);
|
|
|
- drgWebServices.etlClient(jsonDrg);
|
|
|
+ JSONObject js = drgWebServices.etlClient(jsonDrg);
|
|
|
+ log.info("调用drg医嘱确认接口:{}", js);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- log.info("确认的医嘱:{}", JSON.toJSONString(yiZhuList));
|
|
|
- return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 录入单条医嘱 新的 下面的保存医嘱的都无效了
|
|
|
*
|
|
@@ -379,7 +394,6 @@ public class YiZhuLuRuServer {
|
|
|
public ResultVo<Map<String, Object>> enterOrders(XinZhenYiZhu param) {
|
|
|
XinZhenYzActOrder oldOrderNo = dao.getActOrderNoOne(param.getActOrderNo());
|
|
|
String userCode = TokenUtil.getTokenUserId();
|
|
|
-
|
|
|
if (oldOrderNo != null) {
|
|
|
if (!"1".equals(oldOrderNo.getStatusFlag().trim())) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该医嘱不是录入状态无法保存.");
|
|
@@ -391,7 +405,6 @@ public class YiZhuLuRuServer {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医嘱录入人不是您,无法修改。。");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
// 获取医生开药品的权限
|
|
|
Integer doctorLevel = dao.huoQuYiShenDengJi(userCode);
|
|
|
XinZhenYiZhu huanZheXinXi = dao.huoQuHuanZheXinXi(param.getInpatientNo(), param.getAdmissTimes());
|
|
@@ -456,6 +469,7 @@ public class YiZhuLuRuServer {
|
|
|
if (errorMessageMap.containsKey("error")) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.ERROR_MESSAGE, "请修改有错误的医嘱。", map);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "添加成功.");
|
|
|
}
|
|
@@ -471,17 +485,21 @@ public class YiZhuLuRuServer {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.ERROR_MESSAGE, "请先选择患者.");
|
|
|
}
|
|
|
Map<String, XinZhenYzActOrder> fatherAndSonDoctorSAdvice = new HashMap<>(param.getList().size());
|
|
|
-
|
|
|
param.getList().forEach(item -> {
|
|
|
fatherAndSonDoctorSAdvice.put(item.getId(), item);
|
|
|
item.setActOrderNo(BigDecimal.valueOf(publicServer.getActOrderNo()));
|
|
|
});
|
|
|
XinZhenYiZhu huanZheXinXi = dao.huoQuHuanZheXinXi(param.getInpatientNo(), param.getAdmissTimes());
|
|
|
- String userCode = TokenUtil.getTokenUserId();
|
|
|
+ // 把模板的数据插入到医嘱
|
|
|
+ getThis().templateInsertToOrder(param, fatherAndSonDoctorSAdvice, huanZheXinXi);
|
|
|
+ return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "插入模板数据成功。");
|
|
|
+ }
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void templateInsertToOrder(XinZhenYiZhu param, Map<String, XinZhenYzActOrder> fatherAndSonDoctorSAdvice, XinZhenYiZhu huanZheXinXi) {
|
|
|
+ String userCode = TokenUtil.getTokenUserId();
|
|
|
param.getList().forEach(item -> {
|
|
|
String key = item.getParentNo() != null ? item.getParentNo().stripTrailingZeros().toPlainString() : "";
|
|
|
-// item.setGroupNo(param.getGroupNo());
|
|
|
if (StringUtil.notBlank(key)) {
|
|
|
if (fatherAndSonDoctorSAdvice.containsKey(key)) {
|
|
|
item.setParentNo(fatherAndSonDoctorSAdvice.get(key).getActOrderNo());
|
|
@@ -489,8 +507,6 @@ public class YiZhuLuRuServer {
|
|
|
}
|
|
|
dao.insertEntryOrder(huanZheXinXi, item, userCode);
|
|
|
});
|
|
|
-
|
|
|
- return ResultVoUtil.success();
|
|
|
}
|
|
|
|
|
|
/**
|