ソースを参照

添加开医嘱的限制

xiaochan 3 年 前
コミット
9ccd257ac3

+ 18 - 9
src/main/java/thyyxxk/webserver/dao/his/PublicDao.java

@@ -82,7 +82,7 @@ public interface PublicDao {
     @Select("select yj_template_no from ysh_config")
     Integer tempNo();
 
-    @Update("update ysh_config\n" +
+    @Update("update ysh_config " +
             "set yj_template_no = #{tempNo}")
     void updateTempNo(Integer tempNo);
 
@@ -252,18 +252,18 @@ public interface PublicDao {
     List<String> bingFangSuoSuKeShi(String deptCode);
 
     // 重置 流水号
-    @Select("select row_number() over (order by charge_date ) row_index,\n" +
-            "       ledger_sn,\n" +
-            "       detail_sn\n" +
-            "from zy_detail_charge\n" +
-            "where inpatient_no = '${patNo}'\n" +
+    @Select("select row_number() over (order by charge_date ) row_index, " +
+            "       ledger_sn, " +
+            "       detail_sn " +
+            "from zy_detail_charge " +
+            "where inpatient_no = '${patNo}' " +
             "  and admiss_times = ${times} ")
     List<ZyDetailCharge> huoQuZhongYeFeiYong(@Param("patNo") String patNo,
                                              @Param("times") Integer times);
 
-    @Select("select count(1)\n" +
-            "from zy_detail_charge\n" +
-            "where inpatient_no = '${patNo}'\n" +
+    @Select("select count(1) " +
+            "from zy_detail_charge " +
+            "where inpatient_no = '${patNo}' " +
             "  and admiss_times = ${times}")
     int maxDetailSn(@Param("patNo") String patNo,
                     @Param("times") Integer times);
@@ -307,4 +307,13 @@ public interface PublicDao {
 
     @Update("update yz_sequence set page_no = #{index}")
     void genXingCaoYaoDanHao(Integer index);
+
+    @Select("select top (1) cast(settle_type as int) as settle_type " +
+            "from zy_ledger_file " +
+            "where inpatient_no = #{patNo} " +
+            "  and admiss_times = #{times} " +
+            "order by ledger_sn desc")
+    Integer jieSuanXinXi(@Param("patNo") String patNo,
+                         @Param("times") Integer times);
+
 }

+ 13 - 13
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiQueryDao.java

@@ -280,7 +280,7 @@ public interface SiQueryDao {
                           @Param("insutype") String insutype);
 
     @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
-            "psn_cash_pay,setl_time, " +
+            "psn_cash_pay,setl_time,med_type, " +
             "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
             "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
             "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
@@ -293,7 +293,7 @@ public interface SiQueryDao {
                                                                      @Param("setlType") String setlType);
 
     @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
-            "psn_cash_pay,setl_time, " +
+            "psn_cash_pay,setl_time,med_type, " +
             "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
             "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
             "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
@@ -306,7 +306,7 @@ public interface SiQueryDao {
                                                                     @Param("setlType") String setlType);
 
     @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
-            "psn_cash_pay,setl_time, " +
+            "psn_cash_pay,setl_time,med_type, " +
             "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
             "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
             "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
@@ -314,12 +314,12 @@ public interface SiQueryDao {
             "from t_si_setlinfo a where revoked=0 and setl_type=#{setlType} and insutype like #{insutype} and setl_time>=#{begntime} " +
             "and setl_time<=#{endtime} and insuplc_admdvs='430121' ")
     List<BaseSetlStatistics> selectBaseSetlStatisticsInChangshaCounty(@Param("begntime") String begntime,
-                                                                    @Param("endtime") String endtime,
-                                                                    @Param("insutype") String insutype,
-                                                                    @Param("setlType") String setlType);
+                                                                      @Param("endtime") String endtime,
+                                                                      @Param("insutype") String insutype,
+                                                                      @Param("setlType") String setlType);
 
     @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
-            "psn_cash_pay,setl_time, " +
+            "psn_cash_pay,setl_time,med_type, " +
             "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
             "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
             "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
@@ -327,12 +327,12 @@ public interface SiQueryDao {
             "from t_si_setlinfo a where revoked=0 and setl_type=#{setlType} and insutype like #{insutype} and setl_time>=#{begntime} " +
             "and setl_time<=#{endtime} and insuplc_admdvs='430181' ")
     List<BaseSetlStatistics> selectBaseSetlStatisticsInLiuYangCity(@Param("begntime") String begntime,
-                                                                      @Param("endtime") String endtime,
-                                                                      @Param("insutype") String insutype,
-                                                                      @Param("setlType") String setlType);
+                                                                   @Param("endtime") String endtime,
+                                                                   @Param("insutype") String insutype,
+                                                                   @Param("setlType") String setlType);
 
     @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
-            "psn_cash_pay,setl_time, " +
+            "psn_cash_pay,setl_time,med_type,med_type, " +
             "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
             "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
             "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
@@ -345,7 +345,7 @@ public interface SiQueryDao {
                                                                            @Param("setlType") String setlType);
 
     @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
-            "psn_cash_pay,setl_time, " +
+            "psn_cash_pay,setl_time,med_type, " +
             "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
             "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
             "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
@@ -358,7 +358,7 @@ public interface SiQueryDao {
                                                                  @Param("setlType") String setlType);
 
     @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
-            "psn_cash_pay,setl_time, " +
+            "psn_cash_pay,setl_time,med_type, " +
             "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
             "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
             "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +

+ 7 - 6
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/YiZhuLuRuDao.java

@@ -101,7 +101,8 @@ public interface YiZhuLuRuDao {
             "       act_order_no, " +
             "       order_code, " +
             "       order_name, " +
-            "       rtrim(frequ_code) frequ_code, " +
+            "       rtrim(frequ_code) frequ_code," +
+            "       frequ_code_name  = (select rtrim(comm) from yz_order_frequency where code = frequ_code), " +
             "       instruction, " +
             "       discription, " +
             "       infant_flag, " +
@@ -287,9 +288,10 @@ public interface YiZhuLuRuDao {
             "FROM view_yp_zd_dict_base_yf a with (NOLOCK) " +
             "WHERE isnull(a.visible_flag_zy, '') <> '1' " +
             "  and (a.py_code like #{code} or a.name like #{code} or code like #{code}) " +
-            "  and group_no in ('73','11','81') " +
+            "  and group_no = #{groupNo} " +
             "  and isnull(national_code, '') <> '' ")
-    List<YiZhuMingChen> yiZhuMingChen1(@Param("code") String code);
+    List<YiZhuMingChen> yiZhuYaoPing(@Param("code") String code,
+                                     @Param("groupNo") String groupNo);
 
 
     @Select("SELECT a.py_code, " +
@@ -322,7 +324,7 @@ public interface YiZhuLuRuDao {
             "  and (py_code like #{code} or order_name like #{code} or order_code like #{code}) " +
             "  and order_code not in (select zy_order_code from jc_zd_item) " +
             "  and isnull(exec_dept, '') <> '2010000' ")
-    List<YiZhuMingChen> yiZhuMingChen2(String code);
+    List<YiZhuMingChen> yiZhuXiangMu(String code);
 
 
     @Select("SELECT cast(rtrim(isnull(nullif(del_flag, ''), 0)) as int) del_flag, " +
@@ -372,7 +374,7 @@ public interface YiZhuLuRuDao {
             "   frequency as frequCode," +
             "   supply_type as supply_code " +
             "from yp_zd_dict with (NOLOCK) " +
-            "where  rtrim(code) + rtrim(serial) = #{code} " +
+            "where  rtrim(code) + rtrim(serial) = #{code}  " +
             "  and cast(isnull(NULLIF(del_flag, ''), 0) as int) = 0 ")
     YaoPinXinXi huoQuYaoPin(@Param("code") String code);
 
@@ -975,5 +977,4 @@ public interface YiZhuLuRuDao {
                                      @Param("endTime") String endTime);
 
 
-
 }

+ 22 - 0
src/main/java/thyyxxk/webserver/service/PublicServer.java

@@ -17,6 +17,7 @@ import thyyxxk.webserver.entity.yibao.ZyActpatient;
 import thyyxxk.webserver.utils.*;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -422,5 +423,26 @@ public class PublicServer {
         return index;
     }
 
+    public String getGroupNo() {
+        String groupNo = "71";
+        if (DateUtil.timeIsInRound(DateUtil.formatDatetime(new Date(), "HH:mm:ss"), "08:00:00", "19:59:59")) {
+            groupNo = "73";
+        }
+        return groupNo;
+    }
+
+    public void huanZheJieSuan(String patNo, Integer times) {
+        if (StringUtil.isBlank(patNo) || times == null) {
+            throw new BizException(ExceptionEnum.LOGICAL_ERROR, "住院号不能为空。");
+        }
+        Integer settleType = dao.jieSuanXinXi(patNo, times);
+        if (settleType == null) {
+            throw new BizException(ExceptionEnum.LOGICAL_ERROR, "没有查询到患者的信息。");
+        }
+        if (settleType == 1) {
+            throw new BizException(ExceptionEnum.LOGICAL_ERROR, "患者已经结算无法进行操作了。");
+        }
+    }
+
 }
 

+ 6 - 2
src/main/java/thyyxxk/webserver/service/casefrontsheet/HuiZhenShenQingService.java

@@ -8,6 +8,7 @@ import thyyxxk.webserver.dao.his.casefrontsheet.HuiZhenShenQingDao;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.casefrontsheet.YshHzRecord;
 import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
+import thyyxxk.webserver.service.PublicServer;
 import thyyxxk.webserver.utils.ListUtil;
 import thyyxxk.webserver.utils.ResultVoUtil;
 import thyyxxk.webserver.utils.StringUtil;
@@ -29,9 +30,11 @@ import java.util.List;
 @Slf4j
 public class HuiZhenShenQingService {
     private final HuiZhenShenQingDao dao;
+    private final PublicServer publicServer;
 
-    public HuiZhenShenQingService(HuiZhenShenQingDao dao) {
+    public HuiZhenShenQingService(HuiZhenShenQingDao dao, PublicServer publicServer) {
         this.dao = dao;
+        this.publicServer = publicServer;
     }
 
     /**
@@ -59,6 +62,7 @@ public class HuiZhenShenQingService {
      */
     public ResultVo<String> submitHuiZhenShenQing(YshHzRecord param) {
         log.info("会诊申请====>申请人:{},数据:{}", TokenUtil.getTokenUserId(), JSON.toJSONString(param));
+        publicServer.huanZheJieSuan(param.getInpatientNo(), param.getAdmissTimes());
         /*
          * 获取一个新的医嘱号
          * 需要一套指令 先把表锁住 在查询出医嘱号 在加一更新加一就完事了
@@ -72,7 +76,7 @@ public class HuiZhenShenQingService {
         param.setActOrderNo((int) actOrderNo);
         param.setInputId(TokenUtil.getTokenUserId());
         param.setReqDate(param.getInputDate());
-        param.setOrderCode(getOrderCode(param.getHzType()));
+        param.setOrderCode(getOrderCode("00" + param.getHzType()));
         param.setOrderName(String.format("请%s进行院内会诊", param.getReqDeptName()));
         //插入会诊申请
         dao.chaRuHuiZhenShenQing(param);

+ 1 - 0
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/CaoYaoYiZhuServer.java

@@ -134,6 +134,7 @@ public class CaoYaoYiZhuServer {
         if (ListUtil.isBlank(param.getList())) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请先选择需要上传的数据。");
         }
+        publicServer.huanZheJieSuan(param.getInpatientNo(), param.getAdmissTimes());
         BigDecimal sum = new BigDecimal(0);
         param.setInputId(TokenUtil.getTokenUserId());
         for (YzActOrderCyDetail item : param.getList()) {

+ 1 - 1
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/JianYanJianChaShenQingServer.java

@@ -357,7 +357,7 @@ public class JianYanJianChaShenQingServer {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请先悬着要上传的数据。");
         }
         XinZhenYiZhu huanZheXinXi = yiZhuLuRuDao.huoQuHuanZheXinXi(param.getInpatientNo(), param.getAdmissTimes());
-
+        publicServer.huanZheJieSuan(param.getInpatientNo(), param.getAdmissTimes());
         int index = 1;
         StringBuilder cuoWuXinXi = new StringBuilder();
         for (YshYjReq item : param.getList()) {

+ 1 - 0
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/ShouShuShenQingServer.java

@@ -109,6 +109,7 @@ public class ShouShuShenQingServer {
         if (ListUtil.isBlank(param.getList())) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请先选择需要上传的数据。");
         }
+        publicServer.huanZheJieSuan(param.getInpatientNo(), param.getAdmissTimes());
         String userCode = TokenUtil.getTokenUserId();
         Integer shenQingCiShu = dao.shouShuShenQingCiShu(param.getInpatientNo(), param.getAdmissTimes());
         List<OpRecord> shenChengYiZhu = new ArrayList<>();

+ 8 - 10
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/YiZhuLuRuServer.java

@@ -190,8 +190,8 @@ public class YiZhuLuRuServer {
      */
     public ResultVo<List<YiZhuMingChen>> huoQuXiangMu(String code) {
         code = StringUtil.isContainChinese(code);
-        List<YiZhuMingChen> list = dao.yiZhuMingChen1(code);
-        list.addAll(dao.yiZhuMingChen2(code));
+        List<YiZhuMingChen> list = dao.yiZhuYaoPing(code, publicServer.getGroupNo());
+        list.addAll(dao.yiZhuXiangMu(code));
         EntityStringTrim.beanAttributeValueTrimList(list);
         return ResultVoUtil.success(list);
     }
@@ -506,23 +506,18 @@ public class YiZhuLuRuServer {
         if (StringUtil.isBlank(param.getInpatientNo()) || param.getAdmissTimes() == null) {
             throw new BizException(ExceptionEnum.LOGICAL_ERROR, "请先选择患者信息");
         }
-        String groupNo = "71";
+
         XinZhenYiZhu huanZheXinXi = dao.huoQuHuanZheXinXi(param.getInpatientNo(), param.getAdmissTimes());
         if (huanZheXinXi == null) {
             throw new BizException(ExceptionEnum.LOGICAL_ERROR, "没有查询到患者的在院信息。");
         }
         huanZheXinXi.setInfantFlag(publicServer.getInfantFlag(huanZheXinXi.getInpatientNo()));
-        if (DateUtil.timeIsInRound(DateUtil.formatDatetime(new Date(), "HH:mm:ss"), "08:00:00", "19:59:59")) {
-            groupNo = "73";
-        }
-        if (huanZheXinXi.getTimesBilled() != null && huanZheXinXi.getTimesBilled().equals(1)) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该患者已经有出纳信息了,无法添加医嘱。");
-        }
+        publicServer.huanZheJieSuan(param.getInpatientNo(), param.getAdmissTimes());
         if (ListUtil.notBlank(kssList)) {
             dao.shanChuYuanKuangJunYaoWu(kssList);
             dao.chaRuKuangJunYaoWuXinXi(huanZheXinXi.getInpatientNo(), huanZheXinXi.getAdmissTimes(), inputCode, kssList);
         }
-        dao.chaRuYiZhu(huanZheXinXi.getInpatientNo(), huanZheXinXi.getAdmissTimes(), inputCode, huanZheXinXi.getInfantFlag(), groupNo,
+        dao.chaRuYiZhu(huanZheXinXi.getInpatientNo(), huanZheXinXi.getAdmissTimes(), inputCode, huanZheXinXi.getInfantFlag(), publicServer.getGroupNo(),
                 huanZheXinXi.getWardCode(), huanZheXinXi.getWardCode(), huanZheXinXi.getReferPhysician(), param.getList());
         return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "医嘱保存成功。");
     }
@@ -742,6 +737,9 @@ public class YiZhuLuRuServer {
                 return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "已经超过24个小时了,无法撤销,医务部有权限可以撤销。");
             }
         }
+        if (!yz.getStatusFlag().trim().equals("2")) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该医嘱已经无法被撤销了。");
+        }
         dao.chaRuCheXiaoYuanYin(yz.getActOrderNo(), yz.getInpatientNo(), yz.getAdmissTimes(), content, yz.getOrderCode());
         dao.cheXiaoYiZhu(yz.getActOrderNo());
         dao.chaRuShanChuBiao(yz.getActOrderNo());