MedicalManagementService.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. package thyyxxk.webserver.service.medicaladvice.medicamanage;
  2. import cn.hutool.core.collection.CollUtil;
  3. import cn.hutool.core.convert.Convert;
  4. import cn.hutool.core.date.DateUtil;
  5. import cn.hutool.core.map.MapUtil;
  6. import cn.hutool.core.util.StrUtil;
  7. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  8. import lombok.RequiredArgsConstructor;
  9. import lombok.extern.slf4j.Slf4j;
  10. import org.jetbrains.annotations.NotNull;
  11. import org.springframework.stereotype.Service;
  12. import thyyxxk.webserver.config.exception.BizException;
  13. import thyyxxk.webserver.config.exception.ExceptionEnum;
  14. import thyyxxk.webserver.dao.his.medicaladvice.medicamanage.MedicalManagementDao;
  15. import thyyxxk.webserver.dao.his.medicaladvice.medicamanage.YzPrintRecDao;
  16. import thyyxxk.webserver.dao.his.zhuyuanyisheng.YiZhuLuRuDao;
  17. import thyyxxk.webserver.entity.ResultVo;
  18. import thyyxxk.webserver.entity.datamodify.YzActOrder;
  19. import thyyxxk.webserver.entity.executeItem.NumberEnum;
  20. import thyyxxk.webserver.entity.inpatient.patient.Patient;
  21. import thyyxxk.webserver.entity.inpatient.patient.YzQueryBase;
  22. import thyyxxk.webserver.entity.login.UserInfo;
  23. import thyyxxk.webserver.entity.medicaladvice.medicamanage.YzOrderParam;
  24. import thyyxxk.webserver.entity.medicaladvice.medicamanage.YzPrintRec;
  25. import thyyxxk.webserver.entity.medicaladvice.medicamanage.YzPrintVO;
  26. import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.XinZhenYzActOrder;
  27. import thyyxxk.webserver.service.hutoolcache.ExtraCache;
  28. import thyyxxk.webserver.service.hutoolcache.UserCache;
  29. import thyyxxk.webserver.service.inpatient.PatientService;
  30. import thyyxxk.webserver.utils.*;
  31. import java.math.BigDecimal;
  32. import java.util.*;
  33. import java.util.stream.Collectors;
  34. /**
  35. * @Description:
  36. * @Author:lihong
  37. * @Date: 2023/3/13
  38. */
  39. @Slf4j
  40. @Service
  41. @RequiredArgsConstructor
  42. public class MedicalManagementService {
  43. private final MedicalManagementDao dao;
  44. private final PatientService patientService;
  45. private final YiZhuLuRuDao yiZhuLuRuDao;
  46. private final YzPrintRecDao yzPrintRecDao;
  47. private final UserCache userCache;
  48. private final ExtraCache extraCache;
  49. //打印分页数
  50. private static final int PRINT_PAGE_SIZE = 20;
  51. //长期 临时医嘱打印名称
  52. private static final String PRINT_NAME_ORD_LONG = "print_ord_long";
  53. private static final String PRINT_NAME_ORD_ONCE = "print_ord_once";
  54. public ResultVo<Map<String, Object>> cqYzPrint(YzOrderParam param) {
  55. return getPrinInfo(param);
  56. }
  57. public ResultVo<Map<String, Object>> lsYzPrint(YzOrderParam param) {
  58. return getPrinInfo(param);
  59. }
  60. private String getPageCondition(YzOrderParam param, String pageTemplate) {
  61. String pageCondition;
  62. AssertUtil.isnotBlank(param.getPrintType(), "请选择打印类型");
  63. if (param.getPrintType() == 1) {
  64. pageCondition = StrUtil.format(" isnull({},0)=0 ", pageTemplate);
  65. } else {
  66. AssertUtil.isnotBlank(param.getPageNum(), "请选择医嘱页码");
  67. if (param.getPrintType() == 2) {
  68. pageCondition = StrUtil.format("isnull({},0) ={}", pageTemplate, param.getPageNum());
  69. } else {
  70. pageCondition = StrUtil.format("isnull({},0) >={}", pageTemplate, param.getPageNum());
  71. }
  72. }
  73. return pageCondition;
  74. }
  75. private ResultVo<Map<String, Object>> getPrinInfo(YzOrderParam param) {
  76. Map<String, Object> map = new HashMap<>(2);
  77. List<YzPrintVO> yzPrintVOList;
  78. String tableName = NumberEnum.ONE.getCode().equals(param.getInOutStatusFlag()) ? "yz_inact_order" : "yz_act_order";
  79. String otherTableName = NumberEnum.ONE.getCode().equals(param.getInOutStatusFlag()) ? "yz_act_order" : "yz_inact_order";
  80. if (param.getType() == 1) {
  81. //长期医嘱
  82. String pageCondition = getPageCondition(param, "a.print_page");
  83. yzPrintVOList = dao.getcqYzPrint(param.getPatNo(), param.getTimes(), pageCondition,tableName);
  84. // 兼容某些出院病人的医嘱还在在院医嘱表里
  85. if(yzPrintVOList == null || yzPrintVOList.isEmpty()){
  86. yzPrintVOList = dao.getcqYzPrint(param.getPatNo(), param.getTimes(), pageCondition,otherTableName);
  87. }
  88. } else {
  89. String pageCondition = getPageCondition(param, "a.print_page_once");
  90. yzPrintVOList = dao.getlsYzPrint(param.getPatNo(), param.getTimes(), pageCondition,tableName);
  91. // 兼容某些出院病人的医嘱还在在院医嘱表里
  92. if(yzPrintVOList == null || yzPrintVOList.isEmpty()){
  93. yzPrintVOList = dao.getcqYzPrint(param.getPatNo(), param.getTimes(), pageCondition,otherTableName);
  94. }
  95. }
  96. if (CollUtil.isNotEmpty(yzPrintVOList)) {
  97. List<YzPrintVO> childrenList = yzPrintVOList.stream().filter(o -> o.getParentNo() != null).collect(Collectors.toList());
  98. Map<Long, List<YzPrintVO>> groupMap = null;
  99. if (CollUtil.isNotEmpty(childrenList)) {
  100. groupMap = childrenList.stream().collect(Collectors.groupingBy(o -> o.getParentNo()));
  101. }
  102. for (YzPrintVO obj : yzPrintVOList) {
  103. obj.setOrderGroupNo("");
  104. obj.setDate(DateUtil.format(obj.getStartTime(), "MM-dd"));
  105. obj.setTime(DateUtil.format(obj.getStartTime(), "HH:mm"));
  106. obj.setStopDate(DateUtil.format(obj.getEndTime(), "MM-dd"));
  107. obj.setStopTime(DateUtil.format(obj.getEndTime(), "HH:mm"));
  108. obj.setModifierName(getUserName(obj.getModifier()));
  109. obj.setExecId2Name(getUserName(obj.getExecId2()
  110. ));
  111. obj.setExecName(getUserName(obj.getExecId()));
  112. obj.setFrequCode(StrUtil.replace(obj.getFrequCode(), "Always", "").replace("Once", ""));
  113. obj.setDoctorName(getUserName(obj.getDoctorCode()));
  114. obj.setNurseName(getUserName(obj.getNurseCode()));
  115. obj.setNewOrderName(StrUtil.replace(obj.getNewOrderName(), "诊疗项目", ""));
  116. obj.setExecTimeStr(obj.getExecTime() == null ? "" : DateUtil.format(obj.getExecTime(), "MM-dd HH:mm"));
  117. if (MapUtil.isNotEmpty(groupMap)) {
  118. if (obj.getParentNo() == null && groupMap.containsKey(obj.getActOrderNo())) {
  119. obj.setOrderGroupNo("┏");
  120. } else if (obj.getParentNo() != null) {
  121. List<YzPrintVO> yzPrintVOS = groupMap.get(obj.getParentNo());
  122. if (obj.getActOrderNo() == yzPrintVOS.get(yzPrintVOS.size() - 1).getActOrderNo()) {
  123. obj.setOrderGroupNo("┗");
  124. } else {
  125. obj.setOrderGroupNo("┃");
  126. }
  127. }
  128. }
  129. }
  130. }
  131. List<YzPrintVO> result = dealYzPrintVOList(param, yzPrintVOList);
  132. Patient patientInfo = getPatientBaseInfo(param.getPatNo(), param.getTimes(), param.getInOutStatusFlag());
  133. map.put("yzPrintVOList", result);
  134. map.put("patientInfo", patientInfo);
  135. return ResultVoUtil.success(map);
  136. }
  137. private List<YzPrintVO> dealYzPrintVOList(YzOrderParam param, List<YzPrintVO> yzPrintVOList) {
  138. List<YzPrintVO> result = new ArrayList<>();
  139. if (CollUtil.isEmpty(yzPrintVOList)) return result;
  140. if (param.getPrintType() == 1) {
  141. List<List<YzPrintVO>> splitList = CollUtil.split(yzPrintVOList, PRINT_PAGE_SIZE);
  142. if (splitList.get(splitList.size() - 1).size() <= PRINT_PAGE_SIZE) {
  143. addEmptyYzPrintVO(splitList.get(splitList.size() - 1), PRINT_PAGE_SIZE - splitList.get(splitList.size() - 1).size());
  144. }
  145. for (int i = 0; i < splitList.size(); i++) {
  146. result.addAll(splitList.get(i));
  147. YzPrintVO temp = setPageFlag(param, i + 1);
  148. result.add(temp);
  149. }
  150. } else if (param.getPrintType() == 2) {
  151. // 单页查询
  152. addAllPrintData(param, result, Convert.toInt(param.getPageNum()), yzPrintVOList, "当前页数据已超出打印范围,请重置打印页号");
  153. } else {
  154. // 查询某页后
  155. Map<Integer, List<YzPrintVO>> pageNoGroup = yzPrintVOList.stream().collect(Collectors.groupingBy(o -> o.getPageNo()));
  156. List<Integer> sortPageNo = CollUtil.newArrayList(pageNoGroup.keySet()).stream().sorted().collect(Collectors.toList());
  157. sortPageNo.forEach(pageNo -> {
  158. List<YzPrintVO> temp = pageNoGroup.get(pageNo);
  159. addAllPrintData(param, result, pageNo, temp, pageNo + "页数据已超出打印范围,请重置打印页号");
  160. });
  161. }
  162. return result;
  163. }
  164. private void addAllPrintData(YzOrderParam param, List<YzPrintVO> result, Integer pageNo, List<YzPrintVO> temp, String msg) {
  165. if (temp.size() <= PRINT_PAGE_SIZE) {
  166. addEmptyYzPrintVO(temp, PRINT_PAGE_SIZE - temp.size());
  167. result.addAll(temp);
  168. //添加页码
  169. YzPrintVO print = setPageFlag(param, pageNo);
  170. result.add(print);
  171. } else {
  172. throw new BizException(ExceptionEnum.INTERNAL_SERVER_ERROR, msg);
  173. }
  174. }
  175. @NotNull
  176. private YzPrintVO setPageFlag(YzOrderParam param, int pageNum) {
  177. YzPrintVO temp = new YzPrintVO();
  178. temp.setPageFlag("1");
  179. if (param.getType() == 1) {
  180. temp.setPrintPage(pageNum);
  181. } else {
  182. temp.setPrintPageOnce(pageNum);
  183. }
  184. return temp;
  185. }
  186. private void addEmptyYzPrintVO(List<YzPrintVO> list, int size) {
  187. if (size > 0) {
  188. for (int i = 0; i < size; i++) {
  189. YzPrintVO e = new YzPrintVO();
  190. e.setPageFlag("0");
  191. list.add(e);
  192. }
  193. }
  194. }
  195. private String getUserName(String code) {
  196. UserInfo userInfo = userCache.get(code);
  197. return userInfo == null ? "" : userInfo.getName();
  198. }
  199. public List<Patient> queryPatientInfo(String patNo, String ward, String inOutStatusFlag) {
  200. AssertUtil.isnotBlank(ward, "科室不能为空");
  201. QueryWrapper<?> query = new QueryWrapper<>();
  202. query.eq("a.ward", ward);
  203. query.likeRight(StringUtil.notBlank(patNo), "a.inpatient_no", patNo);
  204. String tableName;
  205. if ("1".equals(inOutStatusFlag)) {
  206. tableName = "zy_inactpatient";
  207. } else {
  208. tableName = "zy_actpatient";
  209. }
  210. List<Patient> patient = dao.queryPatientInfo(query, tableName);
  211. return patient;
  212. }
  213. /**
  214. * @description:查询医嘱
  215. * @author: lihong
  216. * @date: 2023/4/20 10:34
  217. * @param: yzQueryBase
  218. * @return: java.lang.Object
  219. **/
  220. public Map<String, Object> queryYz(YzQueryBase yzQueryBase) {
  221. Map<String, Object> result = new HashMap<>(3);
  222. List<XinZhenYzActOrder> yiZhuList = listYzActOrder(yzQueryBase);
  223. if (CollUtil.isNotEmpty(yiZhuList)) {
  224. List<XinZhenYzActOrder> childrenList = yiZhuList.stream().filter(o -> o.getParentNo() != null).collect(Collectors.toList());
  225. Map<Long, List<XinZhenYzActOrder>> groupMap = null;
  226. if (CollUtil.isNotEmpty(childrenList)) {
  227. groupMap = childrenList.stream().collect(Collectors.groupingBy(o -> Long.valueOf(o.getParentNo().longValue())));
  228. }
  229. for (XinZhenYzActOrder item : yiZhuList) {
  230. if ("00".equals(item.getSerial())) {
  231. item.setGroupNoName("项目");
  232. item.setSerialName("项目");
  233. } else {
  234. if ("01".equals(item.getSerial())) {
  235. item.setSerialName("小包装");
  236. } else if ("99".equals(item.getSerial())) {
  237. item.setSerialName("大包装");
  238. }
  239. }
  240. if (MapUtil.isNotEmpty(groupMap)) {
  241. if (item.getParentNo() == null && groupMap.containsKey(item.getActOrderNo().longValue())) {
  242. item.setOrderGroup("┏");
  243. } else if (item.getParentNo() != null) {
  244. List<XinZhenYzActOrder> orderList = groupMap.get(item.getParentNo().longValue());
  245. if (item.getActOrderNo() == orderList.get(orderList.size() - 1).getActOrderNo()) {
  246. item.setOrderGroup("┗");
  247. } else {
  248. item.setOrderGroup("┃");
  249. }
  250. }
  251. }
  252. }
  253. }
  254. Patient patientInfo = getPatientBaseInfo(yzQueryBase.getPatNo(), yzQueryBase.getTimes(), yzQueryBase.getInOutStatusFlag());
  255. result.put("patientInfo", patientInfo);
  256. result.put("yzDataList", yiZhuList);
  257. return result;
  258. }
  259. @NotNull
  260. public QueryWrapper<?> getQueryWrapper(YzQueryBase yzQueryBase) {
  261. QueryWrapper<?> qw = new QueryWrapper<>();
  262. qw.eq("a.inpatient_no", yzQueryBase.getPatNo()).eq("a.admiss_times", yzQueryBase.getTimes());
  263. if ("3".equals(yzQueryBase.getStatusFlag())) {
  264. qw.inSql("a.status_flag", "'3','4'");
  265. } else if (StringUtil.notBlank(yzQueryBase.getStatusFlag()) && !"0".equals(yzQueryBase.getStatusFlag())) {
  266. qw.eq("a.status_flag", yzQueryBase.getStatusFlag());
  267. }
  268. /**显示范围 0 全部 1停止 2当前(查询确认和执行) 3 今天 */
  269. if ("1".equals(yzQueryBase.getQueryRange())) {
  270. qw.eq("a.status_flag", "5");
  271. } else if ("2".equals(yzQueryBase.getQueryRange())) {
  272. qw.inSql("a.status_flag", "'2','3','4'");
  273. } else if ("3".equals(yzQueryBase.getQueryRange())) {
  274. Date now = new Date();
  275. String nowStr = DateUtil.format(now, "yyyy-MM-dd");
  276. qw.ge("a.start_time", nowStr + " 00:00:00");
  277. qw.le("a.start_time", nowStr + " 23:59:59");
  278. }
  279. qw.orderByAsc("a.order_time");
  280. return qw;
  281. }
  282. public Patient getPatientBaseInfo(String patNo, Integer times, String inOutStatusFlag) {
  283. Patient patientInfo = patientService.getPatientBaseInfo(patNo, times, inOutStatusFlag);
  284. YzQueryBase yzQueryBase = new YzQueryBase();
  285. yzQueryBase.setPatNo(patNo);
  286. yzQueryBase.setTimes(times);
  287. yzQueryBase.setQueryRange("0");
  288. yzQueryBase.setStatusFlag("0");
  289. List<XinZhenYzActOrder> orderList = listYzActOrder(yzQueryBase);
  290. Map<String, List<String>> yzZdOrderItemMap = extraCache.getYzZdOrderItemMap();
  291. for (XinZhenYzActOrder item : orderList) {
  292. // 药品编码会重复
  293. if (!"00".equals(item.getSerial())) {
  294. continue;
  295. }
  296. if ("3".equals(item.getStatusFlag()) || "4".equals(item.getStatusFlag())) {
  297. if (item.getOrderName().contains("级护理")) {
  298. patientInfo.setNursingLevel(item.getOrderName());
  299. }
  300. }
  301. if (yzZdOrderItemMap.get("病重").contains(item.getOrderCode())) {
  302. patientInfo.setCriticallyIllStatus("病重");
  303. }
  304. if (yzZdOrderItemMap.get("病危").contains(item.getOrderCode())) {
  305. patientInfo.setCriticallyIllStatus("病危");
  306. }
  307. }
  308. Integer count = dao.existOprt(patNo, times);
  309. if (count != null) {
  310. patientInfo.setOprtStatus("有手术");
  311. } else {
  312. patientInfo.setOprtStatus("无手术");
  313. }
  314. return patientInfo;
  315. }
  316. public List<XinZhenYzActOrder> listYzActOrder(YzQueryBase yzQueryBase) {
  317. QueryWrapper<?> qw = getQueryWrapper(yzQueryBase);
  318. List<XinZhenYzActOrder> yiZhuList = yiZhuLuRuDao.selectOrderNo(qw);
  319. EntityStringTrim.beanAttributeValueTrimList(yiZhuList);
  320. return yiZhuList;
  321. }
  322. public Map getTotalPageNUm(YzOrderParam param) {
  323. Map map = new HashMap(1);
  324. setYzActTableName(param);
  325. YzPrintVO data = dao.selectMaxPagaNo(param);
  326. if (param.getType() == 1) {
  327. map.put("total", data == null ? null : data.getPrintPage());
  328. } else {
  329. map.put("total", data == null ? null : data.getPrintPageOnce());
  330. }
  331. return map;
  332. }
  333. private void setYzActTableName(YzOrderParam param){
  334. String tableName = NumberEnum.ONE.getCode().equals(param.getInOutStatusFlag()) ? "yz_inact_order" : "yz_act_order";
  335. param.setTableName(tableName);
  336. }
  337. public ResultVo<String> recPrint(YzOrderParam param) {
  338. //--打印新增需要插入一条 print_ord_once print_ord_long 一页20条, 请第几页进行续打
  339. //select * from yz_print_rec where inpatient_no ='0418368' and admiss_times =1 and print_name ='print_ord_once'
  340. // --UPDATE yz_act_order SET print_page_once = 3 WHERE act_order_no = 17648285
  341. // --update yz_print_rec set current_page =3 , last_row =14 where inpatient_no ='0418368' and admiss_times =1 and print_name ='print_ord_once'
  342. AssertUtil.isnotBlank(param.getPatNo(), "请选择一条病人");
  343. QueryWrapper query = new QueryWrapper();
  344. query.eq("inpatient_no", param.getPatNo());
  345. query.eq("admiss_times", param.getTimes());
  346. query.eq("print_name", param.getType() == 1 ? PRINT_NAME_ORD_LONG : PRINT_NAME_ORD_ONCE);
  347. YzPrintRec yzPrintRec = yzPrintRecDao.selectOne(query);
  348. String tableName = NumberEnum.ONE.getCode().equals(param.getInOutStatusFlag()) ? "yz_inact_order" : "yz_act_order";
  349. List<YzPrintVO> yzPrintVOS = param.getType() == 1 ? dao.getcqYzPrint(param.getPatNo(), param.getTimes(), " isnull(a.print_page,0)=0 ",tableName) : dao.getlsYzPrint(param.getPatNo(), param.getTimes(), " isnull(a.print_page_once,0)=0 ",tableName);
  350. YzPrintRec rec = new YzPrintRec();
  351. rec.setInpatientNo(param.getPatNo());
  352. rec.setAdmissTimes(param.getTimes());
  353. rec.setPrintName(param.getType() == 1 ? PRINT_NAME_ORD_LONG : PRINT_NAME_ORD_ONCE);
  354. int size;
  355. if (yzPrintRec == null) {
  356. size = yzPrintVOS.size();
  357. } else {
  358. Integer cur = yzPrintRec.getCurrentPage();
  359. Integer lr = yzPrintRec.getLastRow();
  360. int preSize = (cur - 1) * PRINT_PAGE_SIZE + lr;
  361. size = preSize + yzPrintVOS.size();
  362. }
  363. int currentPage = size % PRINT_PAGE_SIZE == 0 ? size / PRINT_PAGE_SIZE : size / PRINT_PAGE_SIZE + 1;
  364. int lastRow = size % PRINT_PAGE_SIZE == 0 ? PRINT_PAGE_SIZE : size % PRINT_PAGE_SIZE;
  365. rec.setCurrentPage(currentPage);
  366. rec.setLastRow(lastRow);
  367. if (yzPrintRec != null) {
  368. yzPrintRecDao.delete(query);
  369. }
  370. yzPrintRecDao.insert(rec);
  371. //print_page,print_page_once
  372. updatePageNo(yzPrintVOS, yzPrintRec, param.getType() == 1 ? " print_page" : " print_page_once");
  373. return ResultVoUtil.success();
  374. }
  375. private void updatePageNo(List<YzPrintVO> yzPrintVOS, YzPrintRec yzPrintRec, String printPageWhere) {
  376. if (yzPrintRec == null) {
  377. int curPage = 1;
  378. List<List<YzPrintVO>> split = CollUtil.split(yzPrintVOS, PRINT_PAGE_SIZE);
  379. for (List<YzPrintVO> item : split) {
  380. for (YzPrintVO temp : item) {
  381. temp.setPageNo(curPage);
  382. }
  383. List<Long> orderNoList = item.stream().map(o -> o.getActOrderNo()).collect(Collectors.toList());
  384. String join = CollUtil.join(orderNoList, ",");
  385. dao.updatePrintPageNo(join, curPage, printPageWhere);
  386. ++curPage;
  387. }
  388. } else {
  389. int curPage = yzPrintRec.getCurrentPage();
  390. int lastRow = yzPrintRec.getLastRow();
  391. for (YzPrintVO item : yzPrintVOS) {
  392. ++lastRow;
  393. if (lastRow > PRINT_PAGE_SIZE) {
  394. lastRow = 1;
  395. ++curPage;
  396. }
  397. item.setPageNo(curPage);
  398. }
  399. Map<Integer, List<YzPrintVO>> pageNoGroup = yzPrintVOS.stream().collect(Collectors.groupingBy(o -> o.getPageNo()));
  400. for (Integer pageNo : pageNoGroup.keySet()) {
  401. List<Long> collect = pageNoGroup.get(pageNo).stream().map(o -> o.getActOrderNo()).collect(Collectors.toList());
  402. String join = CollUtil.join(collect, ",");
  403. dao.updatePrintPageNo(join, pageNo, printPageWhere);
  404. }
  405. }
  406. }
  407. public ResultVo<String> clearPrintPageNo(YzOrderParam param) {
  408. AssertUtil.isnotBlank(param.getPatNo(), "请选择一条病人");
  409. setYzActTableName(param);
  410. // 兼容某些出院病人的医嘱还在在院医嘱表里
  411. dao.updatePrintPage(param, param.getType() == 1 ? "print_page =null" : "print_page_once=null", "yz_act_order");
  412. dao.updatePrintPage(param, param.getType() == 1 ? "print_page =null" : "print_page_once=null", "yz_inact_order");
  413. dao.updatePrintPage(param, param.getType() == 1 ? "print_page =null" : "print_page_once=null", "yz_erase_order");
  414. QueryWrapper query = new QueryWrapper();
  415. query.eq("inpatient_no", param.getPatNo());
  416. query.eq("admiss_times", param.getTimes());
  417. query.eq("print_name", param.getType() == 1 ? PRINT_NAME_ORD_LONG : PRINT_NAME_ORD_ONCE);
  418. yzPrintRecDao.delete(query);
  419. return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE, "成功");
  420. }
  421. public List<YzActOrder> queryYzCheckData(YzQueryBase yzQueryBase) {
  422. if (NumberEnum.ThREE.getCode().equals(yzQueryBase.getQueryRange())) {
  423. Date now = new Date();
  424. yzQueryBase.setStartTime(DateUtil.formatDate(now) + " 00:00:00");
  425. yzQueryBase.setEndTime(DateUtil.formatDate(now) + " 23:59:59");
  426. }
  427. List<YzActOrder> list = dao.listYzCheckData(yzQueryBase);
  428. CommonUtil.BeanTrim(list);
  429. if (CollUtil.isNotEmpty(list)) {
  430. //组号填充
  431. Map<BigDecimal, String> orderGroupMap = new HashMap<>();
  432. Map<BigDecimal, List<YzActOrder>> parentNoMap = list.stream().collect(Collectors.groupingBy(item -> item.getParentNo()));
  433. for (BigDecimal parentNo : parentNoMap.keySet()) {
  434. List<YzActOrder> temp = parentNoMap.get(parentNo);
  435. if (temp.size() > 1) {
  436. for (int i = 0; i < temp.size(); i++) {
  437. if (i == 0) {
  438. orderGroupMap.put(temp.get(i).getActOrderNo(), "┑");
  439. } else if (i == temp.size() - 1) {
  440. orderGroupMap.put(temp.get(i).getActOrderNo(), "┚");
  441. }
  442. }
  443. }
  444. }
  445. for (YzActOrder yzActOrder : list) {
  446. if ("00".equals(yzActOrder.getGroupNo())) {
  447. yzActOrder.setOrderName(yzActOrder.getOrderName() + " " + yzActOrder.getFrequCode());
  448. } else {
  449. yzActOrder.setOrderName(yzActOrder.getOrderName() + " " + yzActOrder.getDose() + yzActOrder.getDoseUnit() + " " + yzActOrder.getFrequCode() + " " + yzActOrder.getSupplyCode());
  450. }
  451. if (orderGroupMap.get(yzActOrder.getActOrderNo()) != null) {
  452. yzActOrder.setOrderGroup(orderGroupMap.get(yzActOrder.getActOrderNo()));
  453. }
  454. }
  455. }
  456. return list;
  457. }
  458. }