Parcourir la source

优化医嘱以及通知。

xiaochan il y a 3 ans
Parent
commit
d3fe5b4bfb

+ 8 - 105
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/YiZhuLuRuDao.java

@@ -1,5 +1,7 @@
 package thyyxxk.webserver.dao.his.zhuyuanyisheng;
 
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
 import org.apache.ibatis.annotations.*;
 import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
 import thyyxxk.webserver.entity.datamodify.YzActOrder;
@@ -174,78 +176,22 @@ public interface YiZhuLuRuDao {
             "         select top ${pageSize} * " +
             "         from (select row_number() over (order by act_order_no) rowIndex, * " +
             "               from yz_act_order a with (NOLOCK) " +
-            "               where inpatient_no = #{patNo} " +
-            "                 and admiss_times = #{times} " +
-            "<if test=\"orderName != null and orderName != '' \">" +
-            " and order_name = #{orderName}" +
-            "</if>" +
-            "<if test=\"startTime != null and startTime != '' \"> " +
-            " and order_time &gt;= #{startTime} and order_time &lt;= #{endTime}" +
-            "</if>" +
-            "<if test=\"frequCode != null and frequCode != '' \">" +
-            " and frequ_code = #{frequCode}" +
-            "</if>" +
-            "<if test=\"zhuangTai != 0 and zhuangTai != 3  and zhuangTai != 6 and zhuangTai != 7 \">" +
-            " and status_flag = #{zhuangTai} /*触发*/" +
-            "</if>" +
-            "<if test=\"zhuangTai == 3 \">" +
-            " and status_flag in (3,4) " +
-            "</if>" +
-            "<if test=\"zhuangTai == 6 \">" +
-            " and frequ_code &lt;&gt; 'ONCE' and end_time is null and doctor_flag = '1' and status_flag &lt;&gt; '5' " +
-            "</if>" +
-            "<if test=\"zhuangTai == 7 \">" +
-            " and  doctor_flag = '1' and status_flag &gt;= '2' and start_time &gt;= dateadd(hour , -24, getdate()) " +
-            "</if>" +
+            "               ${ew.customSqlSegment} " +
             "              ) page " +
             "         where rowIndex > (${currentPage} - 1) * ${pageSize} " +
             "     ) temp" +
             "</script>")
     List<YzActOrder> huoQuYiZhuShuJu(@Param("currentPage") long currentPage,
                                      @Param("pageSize") long pageSize,
-                                     @Param("patNo") String patNo,
-                                     @Param("times") Integer times,
-                                     @Param("startTime") String startTime,
-                                     @Param("endTime") String endTime,
-                                     @Param("frequCode") String frequCode,
-                                     @Param("orderName") String orderName,
-                                     @Param("zhuangTai") Integer zhuangTai);
+                                     @Param(Constants.WRAPPER) Wrapper<?> wq);
 
 
     @Select("<script>" +
             "select count(1) " +
             "from yz_act_order a with (NOLOCK) " +
-            "where  inpatient_no = #{patNo} " +
-            "  and admiss_times = #{times} " +
-            "<if test=\"orderName != null and orderName != '' \">" +
-            " and order_name = #{orderName}" +
-            "</if>" +
-            "<if test=\"startTime != null and startTime != '' \"> " +
-            " and order_time &gt;= #{startTime} and order_time &lt;= #{endTime}" +
-            "</if>" +
-            "<if test=\"frequCode != null and frequCode != '' \">" +
-            " and frequ_code = #{frequCode}" +
-            "</if>" +
-            "<if test=\"zhuangTai != 0 and zhuangTai != 3  and zhuangTai != 6 and zhuangTai != 7 \">" +
-            " and status_flag = #{zhuangTai} /*触发*/" +
-            "</if>" +
-            "<if test=\"zhuangTai == 3 \">" +
-            " and status_flag in (3,4) " +
-            "</if>" +
-            "<if test=\"zhuangTai == 6 \">" +
-            " and frequ_code &lt;&gt; 'ONCE' and end_time is null and doctor_flag = '1' and status_flag &lt;&gt; '5' " +
-            "</if>" +
-            "<if test=\"zhuangTai == 7 \">" +
-            " and  doctor_flag = '1' and status_flag &gt;= '2' and start_time &gt;= dateadd(hour , -24, getdate()) " +
-            "</if>" +
+            " ${ew.customSqlSegment} " +
             "</script>")
-    long huoQuYiZhuShuJuTotal(@Param("patNo") String patNo,
-                              @Param("times") Integer times,
-                              @Param("startTime") String startTime,
-                              @Param("endTime") String endTime,
-                              @Param("frequCode") String frequCode,
-                              @Param("orderName") String orderName,
-                              @Param("zhuangTai") Integer zhuangTai);
+    long huoQuYiZhuShuJuTotal(@Param(Constants.WRAPPER) Wrapper<?> wq);
 
 
     @Select("SELECT distinct py_code=a.py_code, " +
@@ -513,55 +459,20 @@ public interface YiZhuLuRuDao {
             "<foreach collection='list' item='item' separator=','>" +
             "(#{item.orderCode}, #{item.orderName}, #{item.frequCode}, #{item.instruction}, #{item.discription}, #{infantFlag}, #{item.orderTime}, " +
             "        #{inputCode}, #{item.startTime}, #{item.drugSpecification}, " +
-            "<if test=\"item.drugQuan != null \">" +
             "#{item.drugQuan}," +
-            "</if>" +
-            "<if test=\"item.drugQuan == null \">" +
-            "null," +
-            "</if>" +
             " #{item.supplyCode}," +
             " #{item.actOrderNo}, #{patNo}, #{times}, " +
-            "<if test=\"item.drugFlag !=null and item.drugFlag != '' \">" +
             "#{item.drugFlag}," +
-            "</if>" +
-            "<if test=\"item.drugFlag == null or item.drugFlag == '' \">" +
-            "'o'," +
-            "</if>" +
             " #{inputCode}, " +
             " getdate(), #{item.miniUnit}, " +
-            "<if test=\"item.drugWeight != null\">" +
             "#{item.drugWeight}, " +
-            "</if>" +
-            "<if test=\"item.drugWeight == null\">" +
-            "null, " +
-            "</if>" +
             "#{item.drugWeightUnit}, '2', #{item.selfBuy}, " +
-            "<if test=\"item.dose != null\">" +
             "cast(#{item.dose,jdbcType=DECIMAL} as decimal(10,2))," +
-            "</if>" +
-            "<if test=\"item.dose == null\">" +
-            "null," +
-            "</if>" +
             " #{item.doseUnit}, " +
-            "<if test=\"item.drugOcc != null \">" +
             "cast(#{item.drugOcc,jdbcType=DECIMAL} as decimal(10,2))," +
-            "</if>" +
-            "<if test=\"item.drugOcc == null \">" +
-            "null," +
-            "</if>" +
-            "<if test=\"item.drugVolume != null\">" +
             "cast(#{item.drugVolume,jdbcType=DECIMAL} as decimal(10,2))," +
-            "</if>" +
-            "<if test=\"item.drugVolume == null\">" +
-            "null," +
-            "</if>" +
             " #{item.drugVolUnit}, 0, #{item.serial}, " +
-            "<if test=\"item.serial == '00' \">" +
-            "'00'," +
-            "</if>" +
-            "<if test=\"item.serial == '01' or item.serial == '09' \">" +
-            "#{groupNo}," +
-            "</if>" +
+            "#{item.groupNo}," +
             "'1', #{item.execUnit}, " +
             "        #{deptCode}, #{wardCode}, '0', #{item.ybSelfFlag},#{item.emergencyFlag}, #{item.kfFlag}," +
             "<if test=\"item.parentNo != null \">" +
@@ -570,21 +481,13 @@ public interface YiZhuLuRuDao {
             "<if test=\"item.parentNo == null \">" +
             "null," +
             "</if>" +
-            " #{referPhysician}, getdate(), #{inputCode}," +
-            "<if test=\"item.endTime != null \">" +
-            "#{item.endTime},#{inputCode} " +
-            "</if>" +
-            "<if test=\"item.endTime == null\">" +
-            "null,null " +
-            "</if>" +
-            ")" +
+            " #{referPhysician}, getdate(), #{inputCode},#{item.endTime},#{item.modifier})" +
             "</foreach>" +
             "</script>")
     void chaRuYiZhu(@Param("patNo") String patNo,
                     @Param("times") Integer times,
                     @Param("inputCode") String inputCode,
                     @Param("infantFlag") Integer infantFlag,
-                    @Param("groupNo") String groupNo,
                     @Param("deptCode") String deptCode,
                     @Param("wardCode") String wardCode,
                     @Param("referPhysician") String referPhysician,

+ 30 - 0
src/main/java/thyyxxk/webserver/entity/yibao/patient/Patient.java

@@ -64,6 +64,36 @@ public class Patient {
     private String responceTypeName;
     private String actIptDays; // 入院时间
     private String revokeRemark;
+    /**
+     * 患者居住地
+     */
+    private String homeStreet;
+    private Integer age;
+
+    /**
+     * 是否有出纳
+     */
+    private Integer timesBilled;
+
+    private String yp;
+    private String jyjc;
+    private String yb;
+    // 余额
+    private String balance;
+
+    public String getSexName() {
+        if (sex == null) {
+            return "";
+        }
+        switch (sex) {
+            case 1:
+                return "男";
+            case 2:
+                return "女";
+            default:
+                return "未知";
+        }
+    }
 
     public Boolean getMidSetl() {
         return null != midSetl && midSetl;

+ 2 - 0
src/main/java/thyyxxk/webserver/entity/zhuyuanyisheng/yizhuluru/XinZhenYzActOrder.java

@@ -236,5 +236,7 @@ public class XinZhenYzActOrder {
     private Integer ypLevel;
     // 删除标志
     private Integer delFlag;
+    // 停止人
+    private String modifier;
 
 }

+ 4 - 3
src/main/java/thyyxxk/webserver/service/PublicServer.java

@@ -540,9 +540,10 @@ public class PublicServer {
         List<String> huShiBianMa = dao.huoQuHuanZheBingFangDeHuShi(huanZheXinXi.getDeptCode());
         JSONObject obj = new JSONObject();
         obj.put("name", "systemNotification");
-        obj.put("type", "error");
         obj.put("message", "您有新的通知请及时查看。");
-        String message = obj.toJSONString();
+        // 消息数量
+        obj.put("count", content.size());
+
         // 发送通知类
         List<SocketMessage> socketMessage1 = new ArrayList<>();
         List<SocketMessage> socketMessage2 = new ArrayList<>();
@@ -571,7 +572,7 @@ public class PublicServer {
         for (List<SocketMessage> item : fenGeJieShouFang) {
             dao.chaRuJieShouShuJu(item);
         }
-        huShiBianMa.forEach(code -> WebSocketServer.sendMessageByUserCode(code, message));
+        huShiBianMa.forEach(code -> WebSocketServer.sendMessageByUserCode(code, obj.toJSONString()));
 
     }
 

+ 36 - 7
src/main/java/thyyxxk/webserver/service/yibao/PatientService.java

@@ -11,14 +11,22 @@ import thyyxxk.webserver.constants.Capacity;
 import thyyxxk.webserver.constants.sidicts.MedType;
 import thyyxxk.webserver.dao.his.yibao.PatientDao;
 import thyyxxk.webserver.dao.his.yibao.Routines;
-import thyyxxk.webserver.entity.*;
+import thyyxxk.webserver.dao.his.zhuyuanyisheng.YiZhuLuRuDao;
+import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.dictionary.CodeName;
 import thyyxxk.webserver.entity.yibao.dismiss.ZyDisYbDiag;
 import thyyxxk.webserver.entity.yibao.patient.*;
-import thyyxxk.webserver.utils.*;
+import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.HuanZheFeiYong;
+import thyyxxk.webserver.utils.DateUtil;
+import thyyxxk.webserver.utils.DecimalUtil;
+import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.TokenUtil;
 
 import java.text.ParseException;
-import java.util.*;
+import java.text.SimpleDateFormat;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @author dj
@@ -26,14 +34,16 @@ import java.util.*;
 @Slf4j
 @Service
 public class PatientService {
+    private static final String ZD_MEDCN = "yp_zd_dict";
     private final PatientDao dao;
     private final Routines routines;
-    private static final String ZD_MEDCN = "yp_zd_dict";
+    private final YiZhuLuRuDao yiZhuLuRuDao;
 
     @Autowired
-    public PatientService(PatientDao dao, Routines routines) {
+    public PatientService(PatientDao dao, Routines routines, YiZhuLuRuDao yiZhuLuRuDao) {
         this.dao = dao;
         this.routines = routines;
+        this.yiZhuLuRuDao = yiZhuLuRuDao;
     }
 
     public ResultVo<List<Overview>> getOverView(String ward) {
@@ -48,7 +58,26 @@ public class PatientService {
         }
         if (null != data.getSocialNo() && data.getSocialNo().trim().length() == 18 && !data.getSocialNo().startsWith("K")) {
             try {
+                HuanZheFeiYong feiYongZhanBi = yiZhuLuRuDao.feiYongXinXi(data.getInpatientNo(), data.getAdmissTimes(), data.getLedgerSn());
+                if (feiYongZhanBi != null) {
+                    // 余额
+                    data.setBalance(feiYongZhanBi.getBalance());
+                    // 总费用
+                    data.setTotalCharge(feiYongZhanBi.getTotalCharge());
+                    // 药品 百分比
+                    data.setYp(DecimalUtil.getPercent(Double.parseDouble(feiYongZhanBi.getYp()), Double.parseDouble(feiYongZhanBi.getTotalCharge())));
+                    // 检验检查 百分比
+                    data.setJyjc(DecimalUtil.getPercent(Double.parseDouble(feiYongZhanBi.getJyjc()), Double.parseDouble(feiYongZhanBi.getTotalCharge())));
+                    // 医保 费用
+                    data.setChargeYb(feiYongZhanBi.getChargeYb());
+                    // 医保百分比
+                    data.setYb(DecimalUtil.getPercent(Double.parseDouble(feiYongZhanBi.getChargeYb()), Double.parseDouble(feiYongZhanBi.getTotalCharge())));
+                }
+                // 是否出纳
+                data.setTimesBilled(yiZhuLuRuDao.huoQuHuanZheXinXi(data.getInpatientNo(), data.getAdmissTimes()).getTimesBilled());
                 data.setBirthDate(getBirthdayFromSocialNo(data.getSocialNo()));
+                // 年龄
+                data.setAge(DateUtil.calculateAge(new SimpleDateFormat("yyyy-MM-dd").parse(data.getBirthDate())));
             } catch (ParseException e) {
                 log.error("获取患者基本信息出错", e);
             }
@@ -87,7 +116,7 @@ public class PatientService {
         iPage = param.getInjuryMode() ? routines.selectInjuryNotUploadedFees(iPage, param.getZdTable(),
                 param.getPatNo(), param.getTimes(), ledgerSn, DateUtil.getTodayEndTime(), serial1, serial2) :
                 routines.selectNotUploadedFees(iPage, param.getZdTable(), param.getPatNo(), param.getTimes(),
-                ledgerSn, DateUtil.getTodayEndTime(), serial1, serial2);
+                        ledgerSn, DateUtil.getTodayEndTime(), serial1, serial2);
         map.put("totalSize", iPage.getTotal());
         map.put("list", iPage.getRecords());
         map.put("sum", routines.selectSumChargeFee(param.getPatNo(), param.getTimes(), ledgerSn,
@@ -115,7 +144,7 @@ public class PatientService {
 
     /**
      * requestType: 1 - 取消医保登记申请  2 - 出院结算申请
-     * */
+     */
     public ResultVo<List<ToYbkRequest>> getCancelRegisterRequests(String inpatientNo, Integer admissTimes, Integer requestType) {
         // settleType: 0-其他,  1-已结算未出纳, 4-已出纳,  3-中间结算
         Integer settleType = dao.getSettleType(inpatientNo, admissTimes);

+ 69 - 6
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/YiZhuLuRuServer.java

@@ -1,6 +1,7 @@
 package thyyxxk.webserver.service.zhuyuanyisheng;
 
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.slf4j.Slf4j;
@@ -48,6 +49,7 @@ public class YiZhuLuRuServer {
         this.publicServer = publicServer;
     }
 
+
     /**
      * 获取患者列表
      *
@@ -128,16 +130,55 @@ public class YiZhuLuRuServer {
      * @return 返回分页数据,同时做了树状图,这样会有一个问题,那就是开了套餐的数据查询不出来
      */
     public ResultVo<IPage<YzActOrder>> huoQuYiZhuShuJu(YiZhuFeiYongChaXunTiaoJian param) {
+        QueryWrapper<?> qw = new QueryWrapper<>();
+        qw.eq("inpatient_no", param.getPatNo())
+                .eq("admiss_times", param.getTimes());
+        if (StringUtil.notBlank(param.getOrderName())) {
+            qw.eq("order_name", param.getOrderName());
+        }
+        if (StringUtil.notBlank(param.getStartTime())) {
+            qw.ge("order_time", param.getStartTime())
+                    .le("order_time", param.getEndTime());
+        }
+
+        if (StringUtil.notBlank(param.getFrequCode())) {
+            qw.eq("frequ_code", param.getFrequCode());
+        }
+        List<Integer> zhaungTai = new ArrayList<Integer>() {
+            private static final long serialVersionUID = 1194053908853933514L;
+
+            {
+                add(1);
+                add(2);
+                add(5);
+            }
+        };
+        if (zhaungTai.contains(param.getZhuangTai())) {
+            qw.eq("status_flag", param.getZhuangTai());
+        } else if (param.getZhuangTai() == 3) {
+            qw.in("status_flag", 3, 4);
+        } else if (param.getZhuangTai() == 6) {
+            qw.ne("frequ_code", "ONCE")
+                    .isNull("end_time")
+                    .eq("doctor_flag", "1")
+                    .ne("status_flag", "5");
+        } else if (param.getZhuangTai() == 7) {
+            qw.eq("doctor_flag", "1")
+                    .ge("status_flag", "2")
+                    .ge("start_time", DateUtil.formatDatetime(DateUtil.addDateMinut(new Date(), -24)));
+        } else if (param.getZhuangTai() == 8) {
+            qw.eq("frequ_code", "ONCE");
+        } else if (param.getZhuangTai() == 9) {
+            qw.ne("frequ_code", "ONCE");
+        }
         IPage<YzActOrder> page = new Page<>();
         if (param.getTotal() == 0) {
-            page.setTotal(dao.huoQuYiZhuShuJuTotal(param.getPatNo(),
-                    param.getTimes(), param.getStartTime(), param.getEndTime(), param.getFrequCode(), param.getOrderName(), param.getZhuangTai()));
+            page.setTotal(dao.huoQuYiZhuShuJuTotal(qw));
         } else {
             page.setTotal(param.getTotal());
         }
-        List<YzActOrder> yiZhuList = dao.huoQuYiZhuShuJu(param.getCurrentPage(), param.getPageSize(), param.getPatNo(),
-                param.getTimes(), param.getStartTime(), param.getEndTime(), param.getFrequCode(), param.getOrderName(), param.getZhuangTai());
 
+        List<YzActOrder> yiZhuList = dao.huoQuYiZhuShuJu(param.getCurrentPage(), param.getPageSize(), qw);
         // 还有那些没有被匹配的子级医嘱
         Map<BigDecimal, YzActOrder> wuFuJiYiZhu = yiZhuList.stream().collect(
                 Collectors.toMap(YzActOrder::getActOrderNo, a -> a, (k1, k2) -> k1));
@@ -180,6 +221,7 @@ public class YiZhuLuRuServer {
         if (!wuFuJiYiZhu.isEmpty()) {
             tree.addAll(wuFuJiYiZhu.values());
         }
+        // 删除前后空格
         EntityStringTrim.beanAttributeValueTrimList(tree);
         page.setRecords(tree);
         return ResultVoUtil.success(page);
@@ -514,9 +556,28 @@ public class YiZhuLuRuServer {
             dao.chaRuKuangJunYaoWuXinXi(huanZheXinXi.getInpatientNo(), huanZheXinXi.getAdmissTimes(), inputCode, kssList);
         }
         List<String> content = new ArrayList<>();
-        dao.chaRuYiZhu(huanZheXinXi.getInpatientNo(), huanZheXinXi.getAdmissTimes(), inputCode, huanZheXinXi.getInfantFlag(), publicServer.getGroupNo(),
-                huanZheXinXi.getDeptCode(), huanZheXinXi.getDeptCode(), huanZheXinXi.getReferPhysician(), param.getList());
+        String groupNo = publicServer.getGroupNo();
         for (XinZhenYzActOrder item : param.getList()) {
+            if (StringUtil.isBlank(item.getDrugFlag())) {
+                item.setDrugFlag("o");
+            }
+            if (item.getDose() == null) {
+                item.setDose(BigDecimal.valueOf(0));
+            }
+            if (item.getDrugOcc() == null) {
+                item.setDrugOcc(BigDecimal.valueOf(0));
+            }
+            if (item.getDrugVolume() == null) {
+                item.setDrugVolume(BigDecimal.valueOf(0));
+            }
+            if (item.getSerial().trim().equals("00")) {
+                item.setGroupNo("00");
+            } else if (item.getSerial().trim().equals("01") || item.getSerial().trim().equals("99")) {
+                item.setGroupNo(groupNo);
+            }
+            if (item.getEndTime() != null) {
+                item.setModifier(inputCode);
+            }
             content.add(String.format("医嘱名:<span style='color:#409eff'>【%s】</span><br>" +
                             "医嘱时间:<span style='color:#409eff'>【%tF %<tT】</span><br>" +
                             "患者姓名:<span style='color:#409eff'>【%s】</span><br>" +
@@ -524,6 +585,8 @@ public class YiZhuLuRuServer {
                             "频次:<span style='color:#409eff'>【%s】</span>",
                     item.getOrderName(), item.getOrderTime(), huanZheXinXi.getName(), huanZheXinXi.getBedNo(), item.getFrequCode()));
         }
+        dao.chaRuYiZhu(huanZheXinXi.getInpatientNo(), huanZheXinXi.getAdmissTimes(), inputCode, huanZheXinXi.getInfantFlag(),
+                huanZheXinXi.getDeptCode(), huanZheXinXi.getDeptCode(), huanZheXinXi.getReferPhysician(), param.getList());
         publicServer.faSongXiaoXi(huanZheXinXi, content, "新增医嘱", inputCode);
         return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "医嘱保存成功。");
     }