Bläddra i källkod

药品相关优化

hsh 3 månader sedan
förälder
incheckning
5fd7e004f0

+ 5 - 0
src/main/java/cn/hnthyy/thmz/controller/mz/MzPharmacyController.java

@@ -1278,6 +1278,11 @@ public class MzPharmacyController {
                 return resultMap;
             }
             List<RadSendRecord> radSendRecordPage = mzPharmacyService.getRadSendRecordPage(radSendRecord);
+            if(radSendRecordPage.isEmpty()){
+                resultMap.put("code", -1);
+                resultMap.put("message", "放射科发药记录为空!");
+                return resultMap;
+            }
             Stream.iterate(0,i -> i+1).limit(radSendRecordPage.size()).forEach(i -> {
                 RadSendRecord rsr = radSendRecordPage.get(i);
                 Date date = rsr.getSendDate();

+ 2 - 2
src/main/java/cn/hnthyy/thmz/controller/yf/YfDrugApplyController.java

@@ -170,7 +170,7 @@ public class YfDrugApplyController {
             }
             Map<String, Object> map = new HashMap<>();
             YpBaseYf ypBaseYf = ypBaseYfService.queryYpBaseYf(code, serial, groupNo);
-            map.put("stockAmount", ypBaseYf.getStockAmount());
+            map.put("stockAmount", null == ypBaseYf ? 0 : ypBaseYf.getStockAmount());
             int sevenDayDosage = ypMzFytjService.queryDrugUsageStatistics(code, serial, groupNo, 7);
             map.put("sevenDayDosage", sevenDayDosage);
             resultMap.put("code", 0);
@@ -247,7 +247,7 @@ public class YfDrugApplyController {
             List<YpInPlanDrugVo> ypInPlanDrugVos = ypInPlanService.queryYpInPlanDrug(ypInPlan);
             ypInPlanDrugVos.forEach(ypInPlanDrugVo -> {
                 YpBaseYf ypBaseYf = ypBaseYfService.queryYpBaseYf(ypInPlanDrugVo.getChargeCode(), ypInPlanDrugVo.getSerial(), ypInPlanDrugVo.getGroupNo());
-                ypInPlanDrugVo.setPharmacyStockAmount(ypBaseYf.getStockAmount());
+                ypInPlanDrugVo.setPharmacyStockAmount(null == ypBaseYf ? 0 : ypBaseYf.getStockAmount());
                 Double s = ypBaseService.queryStockAmount(ypInPlanDrugVo.getChargeCode(), ypInPlanDrugVo.getSerial(), ypInPlanDrugVo.getGroupYk());
                 ypInPlanDrugVo.setStockAmount(s);
                 int sevenDayDosage = ypMzFytjService.queryDrugUsageStatistics(ypInPlanDrugVo.getChargeCode(), ypInPlanDrugVo.getSerial(), ypInPlanDrugVo.getGroupNo(), 7);

+ 4 - 4
src/main/java/cn/hnthyy/thmz/enums/YpTypeNumberEnum.java

@@ -7,10 +7,10 @@ import java.util.List;
  * 药品类别code范围划分
  */
 public enum YpTypeNumberEnum {
-    ONE(1,"29999","00000"),
-    TWO(2,"39999","30000"),
-    THREE(3,"49999","40000"),
-    FOUR(4,"59999","50000");
+    ONE(1,"39999","00000"),
+    TWO(2,"59999","40000"),
+    THREE(3,"79999","60000"),
+    FOUR(4,"99999","80000");
 
     public Integer code;
     public String maxNum;

+ 4 - 4
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzDrugTracCodgMapper.java

@@ -122,7 +122,7 @@ public interface MzDrugTracCodgMapper {
             "         a.self_flag," +
             "         a.drug_win," +
             "         a.warn_dept, " +
-            "         confirm_flag=case when isnull(b.stock_amount,0) <![CDATA[>=]]> round(quantity * drug_win,2) then '1'else '0'end," +
+            "         confirm_flag=case when isnull(b.stock_amount,0) &gt;= round(quantity * drug_win,2) then '1'else '0'end," +
             "         infusion=c.infusion_flag," +
             "         zj_flag=c.zj_flag," +
             "         zs_flag=''," +
@@ -159,7 +159,8 @@ public interface MzDrugTracCodgMapper {
             "         print_flag_yj=isnull(a.print_flag_yj,'')," +
             "         confirm_flag_b=confirm_flag," +
             "         a.manu_no " +
-            "    FROM mz_charge_detail a WITH(NOLOCK), yp_base_yf b WITH(NOLOCK),yp_zd_dict c WITH(NOLOCK),yp_zd_manufactory d WITH(NOLOCK)" +
+            "    FROM mz_charge_detail a WITH(NOLOCK), yp_base_yf b WITH(NOLOCK)," +
+            "         yp_zd_dict c WITH(NOLOCK) left join yp_zd_manufactory d WITH(NOLOCK) on c.manu_code = d.code " +
             " where   a.patient_id=#{patientId} and" +
             "         a.times     =#{times} and" +
             "         a.receipt_no=#{receiptNo} and" +
@@ -168,10 +169,9 @@ public interface MzDrugTracCodgMapper {
             "         a.serial   =b.serial and " +
             "         b.group_no =#{groupNo} and  " +
             "         b.group_no =a.group_no and  " +
-            "         a.bill_item_code <![CDATA[<>]]>'TC' and" +
+            "         a.bill_item_code &lt;&gt; 'TC' and" +
             "         a.charge_item_code=c.code and" +
             "         a.serial=c.serial and" +
-            "         c.manu_code *= d.code and" +
             "         a.real_no = #{realNo} ",
             "</script>"})
     List<MzSendMedicineVo> selectMzChargeDetailByCode(MzDrugTracCodg codg);

+ 34 - 41
src/main/java/cn/hnthyy/thmz/mapper/his/yf/YfDrugApplyMapper.java

@@ -37,62 +37,55 @@ public interface YfDrugApplyMapper {
             "  location=b.location," +
             "  b.max_stock_amount," +
             "  b.mini_stock_amount," +
-            "  three_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 3 then 0 else quantity end),2),0)," +
-            "  seven_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 7 then 0 else quantity end),2),0)," +
-            "  fourteen_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 14 then 0 else quantity end),2),0)," +
-            "  thirty_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 30 then 0 else quantity end),2),0)," +
+            "  three_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) &gt; 3 then 0 else quantity end),2),0)," +
+            "  seven_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) &gt; 7 then 0 else quantity end),2),0)," +
+            "  fourteen_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) &gt; 14 then 0 else quantity end),2),0)," +
+            "  thirty_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) &gt; 30 then 0 else quantity end),2),0)," +
             "  available_day=" +
-            " case when max(isnull(b.stock_amount,0))=0 or isnull(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 3 then 0 else quantity end),0)=0" +
+            " case when max(isnull(b.stock_amount,0))=0 or isnull(sum(case when datediff(day,confirm_time,getdate()) &gt; 3 then 0 else quantity end),0)=0" +
             "      then 0 " +
-            "      else round(max(isnull(b.stock_amount,0))/(isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 3 then 0 else quantity end),2),0)/3),2) end" +
-            " FROM yp_zd_dict a WITH(NOLOCK) ,yp_base_yf b WITH(NOLOCK),yp_base dd WITH(NOLOCK)," +
-            "     (select c.name,a.charge_item_code code,c.serial,a.confirm_time," +
-            "        round(sum(case when a.serial <![CDATA[<]]> c.serial then quantity*cy_fy/pack_size else quantity*cy_fy end),2) quantity" +
+            "      else round(max(isnull(b.stock_amount,0))/(isnull(round(sum(case when datediff(day,confirm_time,getdate()) &gt; 3 then 0 else quantity end),2),0)/3),2) end" +
+            " FROM yp_zd_dict a WITH(NOLOCK) inner join yp_base_yf b WITH(NOLOCK)  " +
+            "      on a.code=b.charge_code and a.serial=b.serial and b.group_no=#{groupNo}  " +
+            "      left join yp_base dd WITH(NOLOCK)  " +
+            "      on a.code =dd.charge_code and a.serial =dd.serial and dd.group_no = case when b.group_no='81' then '22' else '11' end " +
+            "      left join (select c.name,a.charge_item_code code,c.serial,a.confirm_time," +
+            "        round(sum(case when a.serial &lt; c.serial then quantity*cy_fy/pack_size else quantity*cy_fy end),2) quantity" +
             "      from yp_mz_fytj a WITH(NOLOCK)," +
             "           (select a.name,a.code,a.serial,a.specification,a.pack_size" +
             "            from yp_zd_dict a WITH(NOLOCK),(select code,max(serial) serial" +
             "                               from yp_zd_dict WITH(NOLOCK) group by code) b" +
             "            where a.code=b.code and a.serial=b.serial) c" +
-            "      where a.charge_item_code=c.code and datediff(day,confirm_time,getdate()) <![CDATA[<]]> 61 and group_no =#{groupNo}" +
+            "      where a.charge_item_code=c.code and datediff(day,confirm_time,getdate()) &lt; 61 and group_no =#{groupNo}" +
             "      group by c.name,a.charge_item_code,c.serial,a.confirm_time" +
             "      union all" +
             "      select" +
             "        c.name,a.charge_code code,c.serial,a.confirm_time," +
-            "        round(sum(case when a.serial <![CDATA[<]]> c.serial then amount/pack_size else amount end),2) quantity" +
+            "        round(sum(case when a.serial &lt; c.serial then amount/pack_size else amount end),2) quantity" +
             "      from yp_zy_patient a WITH(NOLOCK)," +
             "           (select a.name,a.code,a.serial,a.specification,a.pack_size" +
             "            from yp_zd_dict a WITH(NOLOCK),(select code,max(serial) serial" +
             "                               from yp_zd_dict WITH(NOLOCK) group by code) b" +
             "            where a.code=b.code and a.serial=b.serial) c" +
-            "      where a.charge_code=c.code and datediff(day,confirm_time,getdate()) <![CDATA[<]]> 61 and acct_sign=2 and group_no =#{groupNo}" +
-            "      group by c.name,a.charge_code,c.serial,a.confirm_time) aa," +
-            "     (select c.name,a.charge_code,c.serial," +
+            "      where a.charge_code=c.code and datediff(day,confirm_time,getdate()) &lt; 61 and acct_sign=2 and group_no =#{groupNo}" +
+            "      group by c.name,a.charge_code,c.serial,a.confirm_time) aa " +
+            "      on a.code = aa.code and a.serial = aa.serial  " +
+            "     left join (select c.name,a.charge_code,c.serial," +
             "             case when a.group_no='81' then '22' else '11' end group_no," +
-            "             round(sum(case when a.serial <![CDATA[<]]> c.serial then stock_amount/pack_size else stock_amount end),2) stock_amount" +
+            "             round(sum(case when a.serial &lt; c.serial then stock_amount/pack_size else stock_amount end),2) stock_amount" +
             "      from yp_base_yf a WITH(NOLOCK)," +
             "           (select a.name,a.code,a.serial,a.specification,a.pack_size" +
             "            from yp_zd_dict a WITH(NOLOCK),(select code,max(serial) serial" +
             "                               from yp_zd_dict WITH(NOLOCK) group by code) b" +
             "            where a.code=b.code and a.serial=b.serial) c" +
-            "      where a.charge_code=c.code and a.group_no <![CDATA[<>]]> '91' and a.group_no =#{groupNo}" +
+            "      where a.charge_code=c.code and a.group_no &lt;&gt; '91' and a.group_no =#{groupNo}" +
             "      group by c.name,a.charge_code,c.serial,(case when a.group_no='81' then '22' else'11' end)) bb" +
-            " where   a.code=b.charge_code and" +
-            "        a.serial=b.serial and" +
-            "        b.group_no=#{groupNo} and" +
-            "        a.code*=aa.code and" +
-            "        a.serial*=aa.serial and" +
-            "        a.code*=dd.charge_code and" +
-            "        a.serial*=dd.serial and" +
-            "        dd.group_no = case when b.group_no='81' then '22' else '11' end  and" +
-            "        a.code*=bb.charge_code and" +
-            "        a.serial*=bb.serial and" +
-            "         (a.py_code like '${searchText}%' or" +
-            "         a.d_code like '${searchText}%' or" +
-            "         a.code like '${searchText}%' or" +
-            "         a.name like '${searchText}%') and" +
-            "        isnull(a.visible_flag,'0') <![CDATA[<>]]> '1' and" +
-            "        isnull(a.del_flag,'0') <![CDATA[<>]]> '1'" +
-            "       and (isnull(b.visible_flag_mz,'0') <![CDATA[<>]]> '1' and isnull(b.visible_flag_zy,'0') <![CDATA[<>]]> '1')" +
+            "      on a.code = bb.charge_code and a.serial = bb.serial " +
+            " where (a.py_code like '${searchText}%' or a.d_code like '${searchText}%' " +
+            "        or a.code like '${searchText}%' or a.name like '${searchText}%') " +
+            "        and isnull(a.visible_flag,'0') &lt;&gt; '1' " +
+            "        and isnull(a.del_flag,'0') &lt;&gt; '1' " +
+            "       and (isnull(b.visible_flag_mz,'0') &lt;&gt; '1' and isnull(b.visible_flag_zy,'0') &lt;&gt; '1') " +
             " group by  b.charge_code," +
             "          a.name," +
             "          b.serial," +
@@ -151,7 +144,7 @@ public interface YfDrugApplyMapper {
             "           b.charge_code =#{chargeCode} and " +
             "   </when>" +
             "   <when test='beyondFlag==1'>"+
-            "           b.mini_stock_amount <![CDATA[>]]> b.stock_amount and " +
+            "           b.mini_stock_amount &gt; b.stock_amount and " +
             "   </when>" +
             "      b.group_no=#{groupNo} and" +
             "      isnull(b.visible_flag,'0')=#{visibleFlag} and" +
@@ -178,7 +171,7 @@ public interface YfDrugApplyMapper {
             "           b.charge_code =#{chargeCode} and " +
             "   </when>" +
             "   <when test='beyondFlag==1'>"+
-            "           b.mini_stock_amount <![CDATA[>]]> b.stock_amount and " +
+            "           b.mini_stock_amount &gt; b.stock_amount and " +
             "   </when>" +
             "           b.group_no=#{groupNo} and " +
             "           isnull(b.visible_flag,'0')=#{visibleFlag} and " +
@@ -194,10 +187,10 @@ public interface YfDrugApplyMapper {
      */
     @Select("<script>" +
             "select\n" +
-            "  seven_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 7 then 0 else quantity end),2),0),\n" +
-            "  fourteen_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 14 then 0 else quantity end),2),0),\n" +
-            "  thirty_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 30 then 0 else quantity end),2),0),\n" +
-            "  sixty_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 60 then 0 else quantity end),2),0)\n" +
+            "  seven_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) &gt; 7 then 0 else quantity end),2),0),\n" +
+            "  fourteen_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) &gt; 14 then 0 else quantity end),2),0),\n" +
+            "  thirty_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) &gt; 30 then 0 else quantity end),2),0),\n" +
+            "  sixty_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) &gt; 60 then 0 else quantity end),2),0)\n" +
             "from (\n" +
             "select\n" +
             "     (case\n" +
@@ -213,7 +206,7 @@ public interface YfDrugApplyMapper {
             "       and d.serial='99'\n" +
             "   where\n" +
             "       p.charge_code=#{chargeCode}\n" +
-            "     and datediff(day,confirm_time,getdate()) <![CDATA[<=]]> 60\n" +
+            "     and datediff(day,confirm_time,getdate()) &lt;= 60\n" +
             "   union all\n" +
             "select\n" +
             "     (case\n" +
@@ -229,7 +222,7 @@ public interface YfDrugApplyMapper {
             "       and d.serial='99'\n" +
             "   where\n" +
             "       f.charge_item_code=#{chargeCode}\n" +
-            "     and datediff(day,confirm_time,getdate()) <![CDATA[<=]]> 60)a" +
+            "     and datediff(day,confirm_time,getdate()) &lt;= 60)a" +
             "</script>")
     YpBaseBoundVo selectSumQuantity(@Param("chargeCode") String chargeCode);
 }

+ 2 - 1
src/main/java/cn/hnthyy/thmz/service/impl/his/yp/YpInDetlServiceImpl.java

@@ -11,6 +11,7 @@ import cn.hnthyy.thmz.mapper.his.yp.*;
 import cn.hnthyy.thmz.service.his.yp.YpConfigService;
 import cn.hnthyy.thmz.service.his.yp.YpInDetlService;
 import cn.hnthyy.thmz.vo.YpInDetlVo;
+import cn.hutool.core.convert.Convert;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.json.JSONObject;
@@ -156,7 +157,7 @@ public class YpInDetlServiceImpl implements YpInDetlService {
     public int saveYpInDetl(List<YpInDetlVo> ypInDetlVoList, String userId) {
         if (StringUtils.isBlank(ypInDetlVoList.get(0).getInDocuNo())) {
             YpConfig ypConfig = ypConfigMapper.selectYpConfig();
-            ypConfig.setYkInNo(ypConfig.getYkInNo() + 1);
+            ypConfig.setYkInNo(Convert.toInt(ypConfig.getYkInNo(),0) + 1);
             ypConfigMapper.updateYpConfig(ypConfig);
             SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
             String inDrawNo = sdf.format(new Date()) + ypConfig.getYkInNo();

+ 7 - 1
src/main/java/cn/hnthyy/thmz/service/impl/his/yp/YpZdDictServiceImpl.java

@@ -151,7 +151,13 @@ public class YpZdDictServiceImpl implements YpZdDictService {
             YpTypeNumberEnum ypTypeNumber = YpTypeNumberEnum.getYpTypeNumberByCode(Integer.parseInt(ypType));
             assert ypTypeNumber != null;
             String maxCode = ypZdDictMapper.selectMaxCode(ypTypeNumber.minNum, ypTypeNumber.maxNum);
-            int code = Convert.toInt(maxCode,0) +1;
+            int initNum;
+            if("1".equals(ypType)){
+                initNum = 0;
+            } else {
+                initNum = Convert.toInt(ypTypeNumber.minNum, 0);
+            }
+            int code = Convert.toInt(maxCode,initNum) + 1;
             maxCode = callYpCodeFormat(code);
             // 药品编码与医嘱编码冲突重置编码
             int cs = ypZdDictMapper.selectYzOrderItemByCode(maxCode);

+ 6 - 1
src/main/resources/static/js/yf/drug_apply.js

@@ -36,6 +36,9 @@ $(function () {
                 if (data[i].amount == 0 || data[i].amount == null) {
                     return errorMesageSimaple('含有请领数量为0的药品');
                 }
+                if(data[i].amount > data[i].stockAmount){
+                    return errorMesageSimaple('请领数量不能超过药库实际库存数量');
+                }
             }
             for (let i = 0; i < data.length; i++) {
                 let ypInPlan = {
@@ -341,7 +344,9 @@ function initAddDrugTable(drawNo) {
         pagination = true;
         $('#groupYkDrugSearch').attr("disabled", true);
         $('#searchText').attr("disabled", true);
-        $('#btn_save').hide();
+        if($("#statusFlagSearch").val() !== "1"){
+            $('#btn_save').hide();
+        }
     }
     $('#add_drug_table').bootstrapTable("destroy");
     $addDrugTable = $('#add_drug_table').bootstrapTable({