|
@@ -5,6 +5,7 @@ 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;
|
|
@@ -210,10 +211,54 @@ public class YiZhuLuRuServer {
|
|
|
* @param times 次数
|
|
|
* @return
|
|
|
*/
|
|
|
- public ResultVo<List<XinZhenYzActOrder>> getParentOrders(String patNo, String times) {
|
|
|
+ public ResultVo<List<XinZhenYzActOrder>> getParentOrders(String patNo, Integer times) {
|
|
|
return ResultVoUtil.success(dao.getParentOrders(patNo, times));
|
|
|
}
|
|
|
|
|
|
+ public ResultVo<String> correctSubOrders(String patNo, Integer times) {
|
|
|
+ QueryWrapper<?> qw = new QueryWrapper<>();
|
|
|
+ qw.eq("a.inpatient_no", patNo)
|
|
|
+ .eq("a.admiss_times", times)
|
|
|
+ .eq("a.status_flag", "1")
|
|
|
+ .eq("a.enter_oper", TokenUtil.getTokenUserId());
|
|
|
+ List<XinZhenYzActOrder> list = dao.huoQuYiZhuShuJu(qw);
|
|
|
+ if (ListUtil.isBlank(list)) {
|
|
|
+ return ResultVoUtil.success();
|
|
|
+ }
|
|
|
+ // 父医嘱
|
|
|
+ Map<BigDecimal, XinZhenYzActOrder> parentOrder = new HashMap<>(list.size());
|
|
|
+ list.forEach(item -> parentOrder.put(item.getActOrderNo(), item));
|
|
|
+ list.forEach(item -> {
|
|
|
+ if (item.getParentNo() != null && parentOrder.containsKey(item.getParentNo())) {
|
|
|
+ XinZhenYzActOrder order = parentOrder.get(item.getParentNo());
|
|
|
+ // 判断是否需要更新
|
|
|
+ if (updateSubOrders(order, item)) {
|
|
|
+ dao.updateSubOrderStatus(item.getActOrderNo(), order);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return ResultVoUtil.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean updateSubOrders(XinZhenYzActOrder parent, XinZhenYzActOrder children) {
|
|
|
+ if (!parent.getOrderTime().equals(children.getOrderTime())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (!parent.getStartTime().equals(children.getStartTime())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (parent.getEndTime() != null && !parent.getEndTime().equals(children.getEndTime())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (!parent.getSupplyCode().equals(children.getSupplyCode())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (!parent.getFrequCode().equals(children.getFrequCode())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 确认医嘱 , 这个是最新的正确的
|
|
@@ -347,14 +392,9 @@ public class YiZhuLuRuServer {
|
|
|
Integer doctorLevel = dao.huoQuYiShenDengJi(userCode);
|
|
|
XinZhenYiZhu huanZheXinXi = dao.huoQuHuanZheXinXi(param.getInpatientNo(), param.getAdmissTimes());
|
|
|
XinZhenYzActOrder data = param.getData();
|
|
|
- // 设置 药房
|
|
|
- data.setGroupNo(param.getGroupNo());
|
|
|
if (ITEM.equals(data.getSerial().trim())) {
|
|
|
data.setGroupNo("00");
|
|
|
}
|
|
|
- if (data.getParentNo() != null) {
|
|
|
- data.setSupplyCode("044");
|
|
|
- }
|
|
|
// 药品的 code
|
|
|
Set<String> yaoPingCode = new HashSet<>();
|
|
|
// 项目的 code
|
|
@@ -437,7 +477,7 @@ public class YiZhuLuRuServer {
|
|
|
|
|
|
param.getList().forEach(item -> {
|
|
|
String key = item.getParentNo() != null ? item.getParentNo().stripTrailingZeros().toPlainString() : "";
|
|
|
- item.setGroupNo(param.getGroupNo());
|
|
|
+// item.setGroupNo(param.getGroupNo());
|
|
|
if (StringUtil.notBlank(key)) {
|
|
|
if (fatherAndSonDoctorSAdvice.containsKey(key)) {
|
|
|
item.setParentNo(fatherAndSonDoctorSAdvice.get(key).getActOrderNo());
|
|
@@ -738,12 +778,17 @@ public class YiZhuLuRuServer {
|
|
|
return ResultVoUtil.success(dao.huoQuZhiXinKeShi(StringUtil.isContainChinese(code)));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 这里是校验模板的数据
|
|
|
+ *
|
|
|
+ * @param param 模板数据
|
|
|
+ * @return 返回提示信息
|
|
|
+ */
|
|
|
public ResultVo<Map<String, Object>> singleDataCheck(XinZhenYiZhu param) {
|
|
|
// 获取医生开药品的权限
|
|
|
Integer doctorLevel = dao.huoQuYiShenDengJi(TokenUtil.getTokenUserId());
|
|
|
Set<String> yaoPingCode = new HashSet<>();
|
|
|
Set<String> xiangMuCode = new HashSet<>();
|
|
|
-
|
|
|
for (XinZhenYzActOrder item : param.getList()) {
|
|
|
if (ITEM.equals(item.getSerial().trim())) {
|
|
|
xiangMuCode.add(item.getOrderCode().trim());
|
|
@@ -751,115 +796,12 @@ public class YiZhuLuRuServer {
|
|
|
yaoPingCode.add(item.getOrderCode().trim() + item.getSerial().trim() + item.getGroupNo().trim());
|
|
|
}
|
|
|
}
|
|
|
- XinZhenYiZhu huanZheXinXi = dao.huoQuHuanZheXinXi(param.getInpatientNo(), param.getAdmissTimes());
|
|
|
- Map<String, Object> errorMessage = checkData(param.getList().get(0), getDrugInformation(yaoPingCode, huanZheXinXi == null ? null : huanZheXinXi.getZkWard()), getProjectInformation(xiangMuCode), huanZheXinXi, doctorLevel);
|
|
|
+ Map<String, Object> errorMessage = checkData(param.getList().get(0), getDrugInformation(yaoPingCode, null), getProjectInformation(xiangMuCode), null, doctorLevel);
|
|
|
errorMessage.put("data", param.getList().get(0));
|
|
|
return ResultVoUtil.success(errorMessage);
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 保存医嘱
|
|
|
- *
|
|
|
- * @param param 医嘱数据
|
|
|
- * @return 返回错误提示或者别的
|
|
|
- */
|
|
|
- @Deprecated
|
|
|
- public ResultVo<Map<String, Object>> saveTheDoctorSOrder(XinZhenYiZhu param) {
|
|
|
- log.info("上传数据:{}", JSON.toJSONStringWithDateFormat(param, DateUtil.DEFAULT_PATTERN));
|
|
|
- // 获取医生开药品的权限
|
|
|
- Integer doctorLevel = dao.huoQuYiShenDengJi(TokenUtil.getTokenUserId());
|
|
|
- // 药品的 code
|
|
|
- Set<String> yaoPingCode = new HashSet<>();
|
|
|
- // 项目的 code
|
|
|
- Set<String> xiangMuCode = new HashSet<>();
|
|
|
- // id 做 map
|
|
|
- Map<String, XinZhenYzActOrder> doctorSOrderMap = new HashMap<>(param.getList().size());
|
|
|
-
|
|
|
- for (XinZhenYzActOrder item : param.getList()) {
|
|
|
- if (ITEM.equals(item.getSerial().trim())) {
|
|
|
- xiangMuCode.add(item.getOrderCode().trim());
|
|
|
- } else {
|
|
|
- yaoPingCode.add(item.getOrderCode().trim() + item.getSerial().trim() + item.getGroupNo().trim());
|
|
|
- }
|
|
|
- doctorSOrderMap.put(item.getId(), item);
|
|
|
- }
|
|
|
- // 医嘱 map {医嘱号: { 具体数据 }}
|
|
|
- // 获取患者信息
|
|
|
- XinZhenYiZhu huanZheXinXi = dao.huoQuHuanZheXinXi(param.getInpatientNo(), param.getAdmissTimes());
|
|
|
- if (huanZheXinXi == null) {
|
|
|
- throw new BizException(ExceptionEnum.LOGICAL_ERROR, "没有查询到患者的在院信息。");
|
|
|
- }
|
|
|
- // 设置婴儿标志
|
|
|
- huanZheXinXi.setInfantFlag(PublicServer.getInfantFlag(huanZheXinXi.getInpatientNo()));
|
|
|
-
|
|
|
- boolean isThereAnyErrorMessage = false;
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- Map<String, XinZhenYzActOrder> drug = getDrugInformation(yaoPingCode, huanZheXinXi.getZkWard());
|
|
|
- Map<String, List<XinZhenYzActOrder>> project = getProjectInformation(xiangMuCode);
|
|
|
-
|
|
|
- int index = 0;
|
|
|
- for (XinZhenYzActOrder item : param.getList()) {
|
|
|
- Map<String, Object> errorMessageMap = checkData(item, drug, project, huanZheXinXi, doctorLevel);
|
|
|
- if (!errorMessageMap.isEmpty()) {
|
|
|
- if (!isThereAnyErrorMessage && errorMessageMap.containsKey("error")) {
|
|
|
- isThereAnyErrorMessage = true;
|
|
|
- }
|
|
|
- map.put(item.getId(), errorMessageMap);
|
|
|
- }
|
|
|
- errorMessageMap.put("data", item);
|
|
|
- errorMessageMap.put("index", index++);
|
|
|
- }
|
|
|
-
|
|
|
- if (isThereAnyErrorMessage) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.ERROR_MESSAGE, "请修改错误的医嘱", map);
|
|
|
- }
|
|
|
- /* 在这里上传医嘱,一点错误信息都没了的话 */
|
|
|
- // 这个是 抗菌药物的信息
|
|
|
- List<YzActRecordKss> kssList = new ArrayList<>();
|
|
|
- // 这个是 转科医嘱的
|
|
|
- ZyOrderZk transferData = null;
|
|
|
- for (XinZhenYzActOrder item : param.getList()) {
|
|
|
- // 生成医嘱号
|
|
|
- item.setActOrderNo(BigDecimal.valueOf(publicServer.getActOrderNo()));
|
|
|
-
|
|
|
- if (item.getParentNo() != null && doctorSOrderMap.containsKey(item.getParentNo().stripTrailingZeros().toPlainString())) {
|
|
|
- item.setParentNo(doctorSOrderMap.get(item.getParentNo().stripTrailingZeros().toPlainString()).getActOrderNo());
|
|
|
- }
|
|
|
-
|
|
|
- if (item.getKjywFlag() != null && item.getKjywFlag() == 1) {
|
|
|
- YzActRecordKss kss = new YzActRecordKss();
|
|
|
- kss.setActOrderNo(item.getActOrderNo());
|
|
|
- kss.setChargeCode(item.getOrderCode());
|
|
|
- kss.setYyfs(item.getYyfs());
|
|
|
- kss.setSsqk(item.getSsqk());
|
|
|
- kss.setYysj(item.getYysj());
|
|
|
- kssList.add(kss);
|
|
|
- }
|
|
|
- if (ZK_CODE.equals(item.getOrderCode())) {
|
|
|
- transferData = new ZyOrderZk();
|
|
|
- transferData.setActOrderNo(item.getActOrderNo().stripTrailingZeros().toPlainString()).setNewDept(item.getZkDeptCode()).setNewWard(item.getZkWardCode());
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- // 执行人
|
|
|
- String inputCode = TokenUtil.getTokenUserId();
|
|
|
- // 判断患者是否结算了
|
|
|
- publicServer.huanZheJieSuan(param.getInpatientNo(), param.getAdmissTimes());
|
|
|
- if (ListUtil.notBlank(kssList)) {
|
|
|
- dao.shanChuYuanKuangJunYaoWu(kssList);
|
|
|
- dao.chaRuKuangJunYaoWuXinXi(huanZheXinXi.getInpatientNo(), huanZheXinXi.getAdmissTimes(), inputCode, kssList);
|
|
|
- }
|
|
|
- if (transferData != null) {
|
|
|
- transferData.setOldWard(huanZheXinXi.getDeptCode()).setOldDept(huanZheXinXi.getSmallDept());
|
|
|
- dao.insertDoctorSOrder(transferData);
|
|
|
- }
|
|
|
- String groupNo = publicServer.getGroupNo();
|
|
|
- sendAMessageToTheNurse(param, inputCode, huanZheXinXi, groupNo);
|
|
|
-// dao.chaRuYiZhu(huanZheXinXi.getInpatientNo(), huanZheXinXi.getAdmissTimes(), inputCode, huanZheXinXi.getInfantFlag(), huanZheXinXi.getDeptCode(), huanZheXinXi.getDeptCode(), huanZheXinXi.getReferPhysician(), param.getList());
|
|
|
- return ResultVoUtil.success(map);
|
|
|
- }
|
|
|
-
|
|
|
public ResultVo<String> doesTheTemplateExist(String name) {
|
|
|
if (dao.duplicateTemplateName(name, TokenUtil.getTokenUserId()) == 0) {
|
|
|
return ResultVoUtil.success();
|
|
@@ -867,6 +809,12 @@ public class YiZhuLuRuServer {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "模板名称重复");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存模板数据
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public ResultVo<String> saveTemplate(YzOrderPattern param) {
|
|
|
// 如果名字重复了,那么就修改原来的模板
|
|
|
YzOrderPattern yzOrderPattern = dao.yuanLaiDeMuBanBianMa(param.getPatternName(), TokenUtil.getTokenUserId());
|
|
@@ -892,9 +840,9 @@ public class YiZhuLuRuServer {
|
|
|
|
|
|
param.setPyCode(py.length() > 9 ? py.substring(0, 9) : py);
|
|
|
param.setDCode(wb.length() > 9 ? wb.substring(0, 9) : wb);
|
|
|
+
|
|
|
param.setInputId(TokenUtil.getTokenUserId());
|
|
|
param.setDeptCode(userInfo.getDeptCode());
|
|
|
-
|
|
|
dao.chaRuMuBan(param);
|
|
|
|
|
|
Map<String, XinZhenYzActOrder> map = param.getList().stream().collect(Collectors.toMap(XinZhenYzActOrder::getId, a -> a, (k1, k2) -> k1));
|