123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 |
- package thyyxxk.webserver.service.zhuyuanyisheng;
- import cn.hutool.extra.spring.SpringUtil;
- import com.alibaba.fastjson.JSON;
- import com.baomidou.dynamic.datasource.annotation.DS;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.core.metadata.OrderItem;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import lombok.extern.slf4j.Slf4j;
- 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.dao.his.zhuyuanyisheng.JianYanJianChaDao;
- import thyyxxk.webserver.dao.his.zhuyuanyisheng.YiZhuLuRuDao;
- import thyyxxk.webserver.entity.ResultVo;
- import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
- import thyyxxk.webserver.entity.login.UserInfo;
- import thyyxxk.webserver.entity.zhuyuanyisheng.jianyanjiancha.*;
- import thyyxxk.webserver.entity.zhuyuanyisheng.query.ChaXunJianChaHeJianYan;
- import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.PatientTemp;
- import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.XinZhenYiZhu;
- import thyyxxk.webserver.service.PublicServer;
- import thyyxxk.webserver.service.redislike.RedisLikeService;
- import thyyxxk.webserver.utils.*;
- import java.lang.reflect.Field;
- import java.nio.channels.NonWritableChannelException;
- import java.util.*;
- import java.util.stream.Collectors;
- /**
- * <p>
- * 描述: 住院医生,检查申请
- * </p>
- *
- * @author xc
- * @date 2022-02-10 15:37
- */
- @Service
- @Slf4j
- public class JianYanJianChaShenQingService {
- private final JianYanJianChaDao dao;
- private final PublicServer publicServer;
- private final YiZhuLuRuDao yiZhuLuRuDao;
- private final RedisLikeService realtimeService;
- private JianYanJianChaShenQingService getThis() {
- return SpringUtil.getBean(this.getClass());
- }
- public JianYanJianChaShenQingService(JianYanJianChaDao dao, PublicServer publicServer, YiZhuLuRuDao yiZhuLuRuDao, RedisLikeService realtimeService) {
- this.dao = dao;
- this.publicServer = publicServer;
- this.yiZhuLuRuDao = yiZhuLuRuDao;
- this.realtimeService = realtimeService;
- }
- /*-------------------------------------------------------------- 下面是检查的逻辑 -----------------------------------------------------------------------------------------------------*/
- /**
- * 获取检验检查的名字
- *
- * @param name 姓名
- * @param patNo 住院号
- * @param times 住院次数
- * @param bedNo 床位
- * @param reqType 2-检验 3-检查
- * @return 返回数据
- */
- public ResultVo<List<Map<String, String>>> huoQuJianYanJianChaMing(String name, String patNo, Integer times, String bedNo, String reqType) {
- return ResultVoUtil.success(dao.huoQuJianJianChaMing(patNo, times, bedNo, StringUtil.isContainChinese(name), reqType));
- }
- /**
- * 获取检查申请
- *
- * @param param 检查申请
- * @return 返回数据
- */
- public ResultVo<List<YshYjReq>> huoQuJianChaShenQing(ChaXunJianChaHeJianYan param) {
- QueryWrapper<?> qw = new QueryWrapper<>();
- qw.eq("inpatient_no", param.getPatNo());
- qw.eq("admiss_times", param.getTimes());
- qw.eq("req_type", "3");
- if (StringUtil.notBlank(param.getOrderName())) {
- qw.like("order_name", param.getOrderName());
- }
- if (StringUtil.notBlank(param.getStartTime())) {
- qw.ge("start_time", param.getStartTime())
- .le("start_time", param.getEndTime());
- }
- qw.orderByDesc("req_date");
- List<YshYjReq> list = dao.huoQuJianChaShenQingV2(qw);
- return ResultVoUtil.success(list);
- }
- public ResultVo<Map<String, Object>> huoQuShengQingXiangQing(Integer reqNo) {
- YshYjReq req = dao.huoQuShengQingXiangQing(reqNo);
- if (req == null) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_HTML_ERROR, "没有查询到有效信息,可能已经被删除了。");
- }
- Map<String, Object> map = new HashMap<>();
- StringBuilder zhuYiShiXiang = new StringBuilder();
- JcZdClass jc = dao.daYingXiangQing(req.getOrderType());
- if (req.getReqType().trim().equals("2") && req.getClasses() != null && req.getClasses().equals("038")) {
- jc = new JcZdClass();
- jc.setComm("病理检验申请单");
- } else if (req.getReqType().trim().equals("2")) {
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "非病理无序打印");
- }
- // 获取患者的住址和性别
- PatientTemp patient = dao.huoQuHuanZheXinXi(req.getInpatientNo());
- req.setSex(patient.getSex());
- // 地址
- req.setHomeStreet(patient.getHomeStreet());
- //联系电话
- req.setHomeTel(patient.getHomeTel());
- // 医保身份
- req.setResponceTypeName(dao.huoQuHuanZheShenFen(req.getInpatientNo()));
- map.put("title", jc.getComm());
- Field[] fields = jc.getClass().getDeclaredFields();
- for (Field field : fields) {
- field.setAccessible(true);
- // 输出属性名和属性值
- try {
- String key = field.getName();
- Object value = EntityStringTrim.getFieldValue(jc, key);
- if (key.startsWith("comment") && StringUtil.notBlank((String) value)) {
- zhuYiShiXiang.append(((String) value).trim()).append("\n");
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- map.put("mattersNeedingAttention", zhuYiShiXiang.toString());
- map.put("data", req);
- return ResultVoUtil.success(map);
- }
- /**
- * 获取检查
- *
- * @return
- */
- public ResultVo<List<JcZdClass>> getCheckNewApplication() {
- return ResultVoUtil.success(dao.getCheckNewApplication());
- }
- /**
- * @param itemType 3-检查 2-检验
- * @param templateType 2 个人 3 科室模板
- * @return
- */
- public ResultVo<List<JcZdClass>> getTemplate(Integer itemType, Integer templateType) {
- QueryWrapper<?> qw = new QueryWrapper<>();
- qw.eq("c.req_type", itemType);
- if (templateType == 2) {
- qw.eq("c.op_id", TokenUtil.getTokenUserId());
- } else {
- UserInfo info = realtimeService.getUserInfoByToken();
- qw.eq("c.tc_exec", info.getDeptCode());
- }
- List<JcZdClass> parentNode = dao.getTemplate(qw);
- Map<String, JcZdClass> map = parentNode
- .stream()
- .collect(Collectors.toMap(JcZdClass::getCode, a -> a, (k1, k2) -> k1));
- List<Map<String, String>> tempContent = dao.selectTemplateContent(qw);
- tempContent.forEach(item -> {
- JcZdClass jcZdClass = map.get(item.get("tc_no"));
- if (jcZdClass != null) {
- if (jcZdClass.getList() == null) {
- jcZdClass.setList(new ArrayList<>());
- }
- jcZdClass.getList().add(item);
- }
- });
- return ResultVoUtil.success(parentNode);
- }
- /**
- * 查询检查检验分类
- *
- * @param total 总条数
- * @param currentPage 当前页
- * @param leiXing 类型 1-新申请 2-个人 3-科室
- * @param jianCha true 检查 false 检验
- * @return 返回分页数据
- */
- @Deprecated
- public ResultVo<IPage<JcZdClass>> jianChaJianYanFenLei(long total, long currentPage, Integer leiXing, Boolean jianCha) {
- IPage<JcZdClass> page = new Page<>();
- if (leiXing == 1) {
- if (jianCha) {
- if (total == 0) {
- page.setTotal(dao.jianChaMingTiaoShu());
- }
- page.setRecords(dao.jianChaMing(currentPage));
- } else {
- page = new Page<>(currentPage, 20, total == 0);
- page = dao.jianYanFenLei(page);
- return ResultVoUtil.success(page);
- }
- } else {
- page = new Page<>(currentPage, 20, total == 0);
- page = dao.jianChaJianYanMuBan(page, leiXing, TokenUtil.getTokenUserId(), jianCha ? "3" : "2");
- }
- return ResultVoUtil.success(page);
- }
- /**
- * 删除检查或检验模板
- *
- * @param code 要删除的模板 code
- * @param deptCode 当前患者的科室编码
- * @return 返回提示
- */
- public ResultVo<String> shanShuJianChaMuBan(String code, String deptCode) {
- ZyTcYj yj = dao.jianChaLuRuRen(code);
- if (yj == null) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找对应的记录可能已经被删除了。");
- }
- if (jianChaMuBanPanDuan(yj.getOpId(), yj.getTcExec(), deptCode)) {
- dao.shanChuJianChaMuBan(code);
- return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您没有权限执行这个操作。");
- }
- /**
- * 检查模板的判断
- *
- * @param opId 录入人
- * @param tcExec 模板的科室
- * @param deptCode 当前用户的科室
- * @return boolean
- */
- public boolean jianChaMuBanPanDuan(String opId, String tcExec, String deptCode) {
- List<Integer> userRole = publicServer.getRoleCode().getData();
- // 医务部
- if (userRole.contains(38)) {
- return true;
- }
- // 科主任 可以删除自己科室任意模板
- if (userRole.contains(11) && tcExec.trim().equals(deptCode)) {
- return true;
- }
- // 普通的只能删除自己的
- return opId.trim().equals(TokenUtil.getTokenUserId());
- }
- /**
- * 获取说明,模板的一下信息
- *
- * @param name 根据说明模板来 搜索
- * @param fenLei 分类
- * @param total 总数
- * @param currentPage 当前页
- * @return 返回提示
- */
- public ResultVo<IPage<YshZdYjTemplate>> huoMuShuoMingMuBan(String name, Integer fenLei, long total, long currentPage) {
- Page<YshZdYjTemplate> page = new Page<>(currentPage, 20, total == 0);
- page = dao.huoQuShuoMingMuBan(page, StringUtil.isContainChinese(name), fenLei, TokenUtil.getTokenUserId());
- return ResultVoUtil.success(page);
- }
- /**
- * 对于说明模板的操作
- *
- * @param param 说明模板的内容
- * @return 返回提示
- */
- @Transactional(rollbackFor = Exception.class)
- public ResultVo<String> shouMingMuBanChaoZuo(YshZdYjTemplate param) {
- switch (param.getLeiXing()) {
- case "修改":
- return xiuGaiMuBan(param, dao.muBanShuJu(param.getCode()));
- case "删除":
- return shanChuMuBan(dao.muBanShuJu(param.getCode()));
- case "新增":
- return xinZengShouMingMuBan(param);
- default:
- return ResultVoUtil.success();
- }
- }
- /**
- * 修改说明模板
- *
- * @param param 修改的数据
- * @param mb 原来的数据
- * @return 返回提示
- */
- private ResultVo<String> xiuGaiMuBan(YshZdYjTemplate param, YshZdYjTemplate mb) {
- if (publicServer.noNeedRule(38)) {
- if (!TokenUtil.getTokenUserId().equals(mb.getOpId().trim())) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该模板创建人不是你,无法操作。");
- }
- }
- dao.genXingShouMingMuBan(param.getJcText(), param.getName(),
- PingYinUtils.pyShouZiMuDaXie(param.getName()),
- PingYinUtils.getWBCode(param.getName()), param.getCode());
- return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
- }
- /**
- * 删除说明模板
- *
- * @param mb 通过数据库查找 原来的模板
- * @return 返回提示
- */
- private ResultVo<String> shanChuMuBan(YshZdYjTemplate mb) {
- List<Integer> userRole = publicServer.getRoleCode().getData();
- if (publicServer.noNeedRule(userRole, 38)) {
- if (TokenUtil.getTokenUserId().equals(mb.getOpId().trim()) || (userRole.contains(11) && mb.getDeptCode().trim().equals(mb.getUserDeptCode().trim()))) {
- dao.shanChuShouMingMuBan(mb.getCode());
- return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
- } else {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您没有权限修改。");
- }
- }
- dao.shanChuShouMingMuBan(mb.getCode());
- return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
- }
- /**
- * 新增说明模板
- *
- * @param param 新增的数据
- * @return 返回提示
- */
- private ResultVo<String> xinZengShouMingMuBan(YshZdYjTemplate param) {
- if (param.getWhFlag().trim().equals("3") && publicServer.noNeedRule(38)) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您没有权限创建全院模板。");
- }
- param.setCode(publicServer.getYjTemplateNo().toString());
- param.setPyCode(PingYinUtils.pyShouZiMuDaXie(param.getName(), 8));
- param.setDCode(PingYinUtils.getWBCode(param.getName(), 8));
- param.setOpId(TokenUtil.getTokenUserId());
- dao.xinZengShouMingMuBan(param);
- return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
- }
- /**
- * 搜索临床诊断
- *
- * @param name 搜索的名字
- * @return 返回搜索的数据
- */
- @DS("his")
- public ResultVo<List<GetDropdownBox>> diagnosisInOurHospital(String name) {
- return ResultVoUtil.success(dao.diagnosisInOurHospital(StringUtil.isContainChinese(name)));
- }
- /**
- * 判断检查模板是否有重复的
- *
- * @param name 名称
- * @return 返回有没有
- */
- public ResultVo<Boolean> jianChaJianYanMuBanMing(String name, String reqType) {
- return ResultVoUtil.success(dao.huoQuJianChaJianYanChongFuMuBanMing(name, TokenUtil.getTokenUserId(), reqType).size() > 0);
- }
- /**
- * 保存检查或检验模板
- *
- * @param param 数据
- * @return 返回提示
- */
- @Transactional(rollbackFor = Exception.class)
- public ResultVo<String> baoCunJianChaJianYanMuBan(ZyTcYj param) {
- param.setOpId(TokenUtil.getTokenUserId());
- param.setTcNo(publicServer.huoQuJianYanJianChaXuHao().toString());
- param.setPyCode(PingYinUtils.pyShouZiMuDaXie(param.getTcName(), 8));
- param.setDCode(PingYinUtils.getWBCode(param.getTcName(), 8));
- List<String> yuanShuJu = dao.huoQuJianChaJianYanChongFuMuBanMing(param.getTcName(), param.getOpId(), param.getReqType());
- if (ListUtil.notBlank(yuanShuJu)) {
- for (String s : yuanShuJu) {
- dao.shanChuJianChaMuBan(s);
- }
- }
- dao.chaRuJCJYMuBan(param);
- dao.chaRuJCJYMuBanNeiRong(param.getList(), param.getTcNo(), param.getReqType().trim());
- log.info("模板数据:{}", JSON.toJSONString(param.getList()));
- return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
- }
- public ResultVo<String> baoCunJianYanJianCha(TianJiaJianChaJianYan param) {
- if (ListUtil.isBlank(param.getList())) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请选择需要保存的数据。");
- }
- XinZhenYiZhu huanZheXinXi = yiZhuLuRuDao.queryPatientInfo(param.getInpatientNo(), param.getAdmissTimes());
- publicServer.huanZheJieSuan(param.getInpatientNo(), param.getAdmissTimes());
- List<String> xm = new ArrayList<>();
- int index = 1;
- List<String> content = new ArrayList<>();
- StringBuilder cuoWuXinXi = new StringBuilder();
- for (YshYjReq item : param.getList()) {
- if (StringUtil.notBlank(item.getJzFlag()) && "0".equals(item.getJzFlag())) {
- item.setJzFlag(null);
- }
- if (StringUtil.notBlank(item.getYbSelfFlag()) && "0".equals(item.getYbSelfFlag())) {
- item.setYbSelfFlag(null);
- }
- if (StringUtil.isBlank(item.getOrderCode())) {
- cuoWuXinXi.append(baoCunCuoWuXinXi(index, "项目编码不能为空"));
- }
- if (StringUtil.isBlank(item.getOrderName())) {
- cuoWuXinXi.append(baoCunCuoWuXinXi(index, "项目名称不能为空"));
- }
- if (item.getStartTime() == null) {
- cuoWuXinXi.append(baoCunCuoWuXinXi(index, "检查时间不能为空"));
- } else if (DateUtil.shiJianDaXiao(huanZheXinXi.getAdmissDate(), item.getStartTime(), ">")) {
- cuoWuXinXi.append(baoCunCuoWuXinXi(index, "医嘱时间不能小于入院时间"));
- }
- if (StringUtil.isBlank(item.getExecDept())) {
- cuoWuXinXi.append(baoCunCuoWuXinXi(index, "执行科室不能为空。"));
- }
- if ("3".equals(param.getReqType())) {
- if (StringUtil.isBlank(item.getReqComment())) {
- cuoWuXinXi.append(baoCunCuoWuXinXi(index, "病室摘要不能为空。"));
- }
- if (StringUtil.isBlank(item.getReqTzComment())) {
- cuoWuXinXi.append(baoCunCuoWuXinXi(index, "体征信息不能为空。"));
- }
- if (StringUtil.isBlank(item.getReqOtherResult())) {
- cuoWuXinXi.append(baoCunCuoWuXinXi(index, "相关辅检结果不能为空。"));
- }
- if (StringUtil.isBlank(item.getDiagCode())) {
- cuoWuXinXi.append(baoCunCuoWuXinXi(index, "临床诊断不能为空。"));
- }
- } else {
- if (StringUtil.isBlank(item.getInspectStuff())) {
- cuoWuXinXi.append(baoCunCuoWuXinXi(index, "标本不能为空。"));
- }
- }
- if (cuoWuXinXi.length() > 0) {
- cuoWuXinXi.append("<br>");
- }
- xm.add(item.getOrderCode().trim());
- content.add(String.format("%s:<span style='color:#409eff'>【%s】</span><br>" +
- "患者姓名:<span style='color:#409eff'>【%s】</span><br>" +
- "床位:<span style='color:#409eff'>【%s】</span>", "2".equals(param.getReqType()) ? "检查名" : "检验名",
- item.getOrderName(), huanZheXinXi.getName(), huanZheXinXi.getBedNo()));
- index++;
- }
- // 先判断是不是停用了
- String tingYong = publicServer.xiangMuXianZhi(xm, true);
- if (StringUtil.notBlank(tingYong)) {
- throw new BizException(ExceptionEnum.LOGICAL_HTML_ERROR, tingYong);
- }
- if (StringUtil.notBlank(cuoWuXinXi.toString())) {
- throw new BizException(ExceptionEnum.LOGICAL_HTML_ERROR, String.valueOf(cuoWuXinXi));
- }
- // 生成 医嘱号和申请号
- for (YshYjReq item : param.getList()) {
- item.setActOrderNo(publicServer.getActOrderNo());
- item.setReqNo(publicServer.getReqPageNo());
- }
- String userCode = TokenUtil.getTokenUserId();
- getThis().insertData(param, huanZheXinXi, userCode);
- try {
- publicServer.faSongXiaoXi(huanZheXinXi, content, "2".equals(param.getReqType()) ? "新增检查" : "新增检验", TokenUtil.getTokenUserId());
- } catch (Exception e) {
- e.printStackTrace();
- }
- log.info("数据:{}", JSON.toJSONString(param.getList()));
- return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
- }
- @Transactional(rollbackFor = Exception.class)
- public void insertData(TianJiaJianChaJianYan param, XinZhenYiZhu huanZheXinXi, String userCode) {
- Date reqDate = new Date();
- dao.chaRuShenQing(param.getList(), param.getInpatientNo(), param.getName(), param.getAge() + "岁", param.getAdmissTimes(),
- param.getBedNo(), userCode, huanZheXinXi.getDeptCode(), huanZheXinXi.getDeptCode(), param.getReqType(),
- "3".equals(param.getReqType()) ? "jc_zd_item" : "jy_zd_item", reqDate);
- dao.chaRuShenQingYiZhu(param.getList(), param.getInpatientNo(), param.getAdmissTimes(), userCode, huanZheXinXi.getDeptCode(), huanZheXinXi.getDeptCode(),
- PublicServer.getInfantFlag(param.getInpatientNo()), reqDate);
- }
- public String baoCunCuoWuXinXi(int index, String xinXi) {
- return String.format("第【%d】个%s<br>", index, xinXi);
- }
- /*-------------------------------------------------------------- 下面是检验的逻辑 -----------------------------------------------------------------------------------------------------*/
- public ResultVo<List<YshYjReq>> huoQuJianYan(ChaXunJianChaHeJianYan param) {
- QueryWrapper<?> qw = new QueryWrapper<>();
- qw.eq("inpatient_no", param.getPatNo());
- qw.eq("admiss_times", param.getTimes());
- qw.eq("req_type", "2");
- if (StringUtil.notBlank(param.getStartTime())) {
- qw.ge("start_time", param.getStartTime())
- .le("start_time", param.getEndTime());
- }
- if (StringUtil.notBlank(param.getOrderName())) {
- qw.like("order_name", param.getOrderName());
- }
- qw.orderByDesc("act_order_no");
- List<YshYjReq> list = dao.huoQuJianYanV2(qw);
- return ResultVoUtil.success(list);
- }
- public ResultVo<IPage<JcZdClass>> huoQuJianYanMing(long total, long currentPage, Integer leiXing) {
- IPage<JcZdClass> page = new Page<>(currentPage, 20, total == 0);
- if (leiXing == 1) {
- page = dao.jianYanFenLei(page);
- return ResultVoUtil.success(page);
- }
- return ResultVoUtil.success();
- }
- public ResultVo<List<GetDropdownBox>> biaoBenShuJu(String name) {
- return ResultVoUtil.success(dao.biaoBenLeiXing(StringUtil.isContainChinese(name)));
- }
- @DS("his")
- public ResultVo<List<JianYanFeiYongXiangQing>> viewInspectionItemDetails(String orderCode) {
- return ResultVoUtil.success(dao.viewInspectionItemDetails(orderCode));
- }
- public ResultVo<String> shanChuJianChaJianYan(Integer reqNo, String patNo, Integer times) {
- if (StringUtil.isBlank(patNo)) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "住院号不能为空。");
- }
- YshYjReq yj = dao.huoQuJianYanJianCha(reqNo, patNo, times);
- if (yj == null) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有查询到该数据的具体信息,已经被删除了。");
- }
- int feeCount = dao.selectedFeeCount(yj);
- if (feeCount > 0) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "费用已上账无法删除。");
- }
- int feePatientFee = dao.selecePatientFee(yj);
- if (feePatientFee > 0) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医技已确费无法删除。");
- }
- dao.shanChuJianYanJianCha(reqNo, patNo, times);
- dao.shanChuYiZhu(yj.getActOrderNo());
- dao.cancellationOfConfirmedFees(yj, TokenUtil.getTokenUserId());
- log.info("删除医技申请==》操作人:{},医技数据:{}", TokenUtil.getTokenUserId(), JSON.toJSONString(yj));
- return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
- }
- public ResultVo<Map<String, Object>> queryCheckTextResults(String patNo, String reqNo) {
- String jcId = dao.getJcIdByPatNo(patNo);
- if (StringUtil.isBlank(jcId)) {
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有获取到患者的检查id");
- }
- YjJcRecord yjJcRecord = dao.getJcRecord(reqNo, jcId);
- if (yjJcRecord == null) {
- return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有查询到检查结果。");
- }
- Map<String, String> textJc = dao.selectTextJc(yjJcRecord.getReportNo());
- if (textJc != null) {
- yjJcRecord.setDiagnosticOpinion(textJc.get("text_zd"));
- yjJcRecord.setCheckWhatYouSee(textJc.get("text_jc"));
- }
- Map<String, Object> map = new HashMap<>(Capacity.TWO);
- map.put("record", yjJcRecord);
- return ResultVoUtil.success(map);
- }
- /**
- * 检验检查 树状图
- *
- * @return 返回树
- */
- @DS("his")
- public ResultVo<Map<String, List<JyJcItem>>> getJyJcZdTree() {
- Map<String, List<JyJcItem>> map = new HashMap<>(Capacity.TWO);
- // 把 检验 项目大类做map的key
- Map<String, JyJcItem> jyMap = dao.queryInspectionClassification().stream().collect(
- Collectors.toMap(JyJcItem::getCode, a -> a, (k1, k2) -> k1)
- );
- // 获取检验的详细项目
- List<JyJcItem> jyDetailedItems = dao.getJyDetailedItems();
- grouping(jyMap, jyDetailedItems);
- // 把 检查 项目大类做map的key
- Map<String, JyJcItem> jcMap = dao.queryCheckClassification().stream().collect(
- Collectors.toMap(JyJcItem::getCode, a -> a, (k1, k2) -> k1)
- );
- // 获取检查的详细项目
- List<JyJcItem> jcDetailedItems = dao.selectJcDetailItems();
- grouping(jcMap, jcDetailedItems);
- // 检查项目还需要根据部位细分
- List<JyJcItem> jcTree = new ArrayList<>();
- for (Map.Entry<String, JyJcItem> item : jcMap.entrySet()) {
- // 没有节点就不要添加
- if (item.getValue().getChildren() != null) {
- JyJcItem temp = new JyJcItem();
- temp.setName(item.getValue().getName());
- temp.setChildren(new ArrayList<>());
- // 通过部位进行详细的区分
- Map<String, List<JyJcItem>> tempMap = item.getValue().getChildren().stream().collect(
- Collectors.groupingBy(JyJcItem::getBw)
- );
- for (Map.Entry<String, List<JyJcItem>> entry : tempMap.entrySet()) {
- // 如果部位是空的就直接添加到父节点
- if (StringUtil.isBlank(entry.getKey())) {
- temp.setChildren(entry.getValue());
- } else {
- // 添加到指定的部位
- JyJcItem temp1 = new JyJcItem();
- temp1.setName(entry.getKey());
- temp1.setChildren(entry.getValue());
- temp.getChildren().add(temp1);
- }
- }
- jcTree.add(temp);
- }
- }
- map.put("jy", new ArrayList<>(jyMap.values()));
- map.put("jc", jcTree);
- return ResultVoUtil.success(map);
- }
- private void grouping(Map<String, JyJcItem> jyMap, List<JyJcItem> jyDetailedItems) {
- for (JyJcItem item : jyDetailedItems) {
- if (jyMap.containsKey(item.getClasses())) {
- JyJcItem tempMap = jyMap.get(item.getClasses());
- if (tempMap.getChildren() == null) {
- tempMap.setChildren(new ArrayList<>());
- }
- tempMap.getChildren().add(item);
- }
- }
- }
- @DS("his")
- public ResultVo<List<JyJcItem>> getJcItem(String code) {
- return ResultVoUtil.success(dao.getJcItem(StringUtil.isContainChinese(code)));
- }
- @DS("his")
- public ResultVo<List<JyJcItem>> getJyItem(String code) {
- return ResultVoUtil.success(dao.getJyItem(StringUtil.isContainChinese(code)));
- }
- }
|