Browse Source

增加药品处方限制天数维护

WANGJIALIANG 3 years ago
parent
commit
a831236648

+ 2 - 0
src/main/java/cn/hnthyy/thmz/entity/his/yp/YpBaseYf.java

@@ -44,4 +44,6 @@ public class YpBaseYf {
     private String visibleFlagStop;
     private Double maxStockAmount;
     private Double miniStockAmount;
+    //处方限制天数
+    private Integer prescriptionLimitDays;
 }

+ 22 - 1
src/main/java/cn/hnthyy/thmz/mapper/his/yp/YpBaseYfMapper.java

@@ -71,6 +71,9 @@ public interface YpBaseYfMapper {
             "<when test='stockAmountVirtual2!=null'>",
             ",stock_amount_virtual2 =#{stockAmountVirtual2,jdbcType=FLOAT}",
             "</when>",
+            "<when test='prescriptionLimitDays!=null'>",
+            ",prescription_limit_days =#{prescriptionLimitDays,jdbcType=INTEGER}",
+            "</when>",
             "</trim>",
             "</script>"})
     int updateYpBaseYf(YpBaseYf ypBaseYf);
@@ -82,7 +85,8 @@ public interface YpBaseYfMapper {
      * @param groupNo
      * @return
      */
-    @Select("select charge_code,serial,stock_amount,stock_value,group_no,location " +
+    @Select("select charge_code,serial,stock_amount,stock_value,group_no,location,visible_flag_mz,visible_flag_zy," +
+            "       visible_flag_stop,stock_amount_virtual2,open_virtual2,prescription_limit_days " +
             "from yp_base_yf WITH(NOLOCK) where charge_code=#{chargeCode} and serial=#{serial} and group_no=#{groupNo}")
     YpBaseYf selectYpBaseYf(@Param("chargeCode") String chargeCode, @Param("serial") String serial,@Param("groupNo") String groupNo);
 
@@ -194,4 +198,21 @@ public interface YpBaseYfMapper {
             "    isnull(a.infusion_flag,'0') like '${infusionFlag}%')ab " +
             " where visible_flag like '${visibleFlag}%' order by location" )
     List<YpBaseYfVo> selectYpInventoryData(@Param("groupNo") String groupNo,@Param("infusionFlag") String infusionFlag,@Param("visibleFlag") String visibleFlag);
+
+    /**
+     * 查询药房药品库存合计(大规格)
+     * @param chargeCode
+     * @param groupNo
+     * @return
+     */
+    @Select("select sum(case when x.serial < z.serial then x.stock_amount/z.pack_size else x.stock_amount end) " +
+            "from  (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) z," +
+            "       yp_base_yf x " +
+            "where z.code=x.charge_code and" +
+            "       x.charge_code=#{chargeCode} and" +
+            "       x.group_no =#{groupNo}")
+    Double selectLargeStockAmount(@Param("chargeCode") String chargeCode,@Param("groupNo") String groupNo);
 }

+ 20 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/yp/YpMzFytjMapper.java

@@ -329,4 +329,24 @@ public interface YpMzFytjMapper {
      */
     @Update("update yp_mz_fytj set real_no=-real_no,serial_no=-serial_no where patient_id = #{patientId} and times = #{times}")
     int repealRefund(YpMzFytj ypMzFytj);
+
+    /**
+     * 查询最近发药量
+     * @param chargeCode
+     * @param serial
+     * @param packSize
+     * @param groupNo
+     * @return
+     */
+    @Select("select" +
+            "      a.name," +
+            "      a.charge_item_code," +
+            "      a.serial," +
+            "      a.confirm_time" +
+            "    from yp_mz_fytj a WITH(NOLOCK)" +
+            "     where a.charge_item_code=#{chargeCode} and" +
+            "           datediff(day,confirm_time,getdate()) < 31 and" +
+            "         a.group_no=#{groupNo}" +
+            "     group by a.name,a.charge_item_code,a.serial,a.confirm_time")
+    List<Map<String, Object>> selectLatelyYpMzFytj(@Param("chargeCode") String chargeCode, @Param("serial") String serial, @Param("packSize") Double packSize, @Param("groupNo") String groupNo);
 }

+ 21 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/zy/YpZyPatientMapper.java

@@ -77,4 +77,25 @@ public interface YpZyPatientMapper {
     @Update("update yp_zy_patient set page_no=#{pageNo},keeper=#{keeper},confirm_time=#{confirmTime},doctor_name=#{doctorName}" +
             ",page_type=#{pageType},jy_flag=#{jyFlag} where act_order_no = #{actOrderNo} and charge_code = #{chargeCode} and inpatient_no=#{inpatientNo}  and confirm_time is null")
     int updateYpZyPatient(YpZyPatient ypZyPatient);
+
+    /**
+     * 查询最近发药量
+     * @param chargeCode
+     * @param serial
+     * @param packSize
+     * @param groupNo
+     * @return
+     */
+    @Select("select" +
+            "      a.name," +
+            "      a.charge_code," +
+            "      a.serial," +
+            "      round(sum(case when a.serial  < ${serial} then amount/${packSize} else amount end),2) quantity," +
+            "      a.confirm_time" +
+            "    from yp_zy_patient a WITH(NOLOCK)" +
+            "     where a.charge_code=#{chargeCode} and" +
+            "           datediff(day,confirm_time,getdate()) < 31 and" +
+            "         a.group_no=#{groupNo}" +
+            "     group by a.name,a.charge_code,a.serial,a.confirm_time")
+    List<Map<String, Object>> selectLatelyYpZyPatient(@Param("chargeCode") String chargeCode, @Param("serial") String serial, @Param("packSize") Double packSize, @Param("groupNo") String groupNo);
 }

+ 86 - 1
src/main/java/cn/hnthyy/thmz/service/impl/his/yf/YfSpecialMarkServiceImpl.java

@@ -1,12 +1,24 @@
 package cn.hnthyy.thmz.service.impl.his.yf;
 
+import cn.hnthyy.thmz.Utils.DateUtil;
+import cn.hnthyy.thmz.entity.his.yp.YpBaseYf;
+import cn.hnthyy.thmz.entity.his.yp.YpZdDict;
 import cn.hnthyy.thmz.mapper.his.yf.YfSpecialMarkMapper;
+import cn.hnthyy.thmz.mapper.his.yp.YpBaseYfMapper;
+import cn.hnthyy.thmz.mapper.his.yp.YpMzFytjMapper;
+import cn.hnthyy.thmz.mapper.his.yp.YpZdDictMapper;
+import cn.hnthyy.thmz.mapper.his.yp.YpZdManufactoryMapper;
+import cn.hnthyy.thmz.mapper.his.zy.YpZyPatientMapper;
 import cn.hnthyy.thmz.service.his.yf.YfSpecialMarkService;
 import cn.hnthyy.thmz.vo.YpZdBaseYfSpecialVo;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @description:药房特殊标志维护
@@ -18,9 +30,82 @@ public class YfSpecialMarkServiceImpl implements YfSpecialMarkService {
     @SuppressWarnings("all")
     @Autowired
     YfSpecialMarkMapper yfSpecialMarkMapper;
+    @SuppressWarnings("all")
+    @Autowired
+    YpZdDictMapper ypZdDictMapper;
+    @SuppressWarnings("all")
+    @Autowired
+    YpBaseYfMapper ypBaseYfMapper;
+    @SuppressWarnings("all")
+    @Autowired
+    YpZdManufactoryMapper ypZdManufactoryMapper;
+    @SuppressWarnings("all")
+    @Autowired
+    YpZyPatientMapper ypZyPatientMapper;
+    @SuppressWarnings("all")
+    @Autowired
+    YpMzFytjMapper ypMzFytjMapper;
 
     @Override
     public List<YpZdBaseYfSpecialVo> queryYpSpecialMark(String groupNo, String searchText) {
-        return yfSpecialMarkMapper.selectYpSpecialMark(groupNo, searchText);
+        List<YpZdBaseYfSpecialVo> ypZdBaseYfSpecialVos = new ArrayList<>();
+        List<YpZdDict> ypZdDicts = ypZdDictMapper.selectYpBySearchText(searchText);
+        ypZdDicts.forEach(ypZdDict -> {
+            YpZdBaseYfSpecialVo ypZdBaseYfSpecialVo = new YpZdBaseYfSpecialVo();
+            YpBaseYf ypBaseYf = ypBaseYfMapper.selectYpBaseYf(ypZdDict.getCode(), ypZdDict.getSerial(), groupNo);
+            if(ypBaseYf != null){
+                ypZdBaseYfSpecialVo.setGroupNo(groupNo);
+                ypZdBaseYfSpecialVo.setChargeCode(ypBaseYf.getChargeCode());
+                ypZdBaseYfSpecialVo.setSerial(ypBaseYf.getSerial());
+                ypZdBaseYfSpecialVo.setName(ypZdDict.getName());
+                ypZdBaseYfSpecialVo.setClassCode(ypZdDict.getClassCode());
+                ypZdBaseYfSpecialVo.setSpecification(ypZdDict.getSpecification());
+                ypZdBaseYfSpecialVo.setVisibleFlagMz(ypBaseYf.getVisibleFlagMz());
+                ypZdBaseYfSpecialVo.setVisibleFlagZy(ypBaseYf.getVisibleFlagZy());
+                ypZdBaseYfSpecialVo.setStockAmount(ypBaseYf.getStockAmount());
+                ypZdBaseYfSpecialVo.setVisibleFlagStop(ypBaseYf.getVisibleFlagStop());
+                ypZdBaseYfSpecialVo.setStockAmountVirtual2(ypBaseYf.getStockAmountVirtual2());
+                ypZdBaseYfSpecialVo.setOpenVirtual2(ypBaseYf.getOpenVirtual2());
+                ypZdBaseYfSpecialVo.setPrescriptionLimitDays(ypBaseYf.getPrescriptionLimitDays());
+                String manufactoryName = ypZdManufactoryMapper.selectYpZdManufactoryByCode(ypZdDict.getManuCode());
+                if(StringUtils.isNotBlank(manufactoryName)){
+                    ypZdBaseYfSpecialVo.setManufactoryName(manufactoryName);
+                }
+                Double largeStockAmount = ypBaseYfMapper.selectLargeStockAmount(ypZdDict.getCode(), groupNo);
+                ypZdBaseYfSpecialVo.setStockAmountLarge(largeStockAmount);
+                List<Map<String, Object>> zyList = ypZyPatientMapper.selectLatelyYpZyPatient(ypZdDict.getCode(), ypZdDict.getSerial(), ypZdDict.getPackSize().doubleValue(), groupNo);
+                List<Map<String, Object>> ypMzFytjs = ypMzFytjMapper.selectLatelyYpMzFytj(ypZdDict.getCode(), ypZdDict.getSerial(), ypZdDict.getPackSize().doubleValue(), groupNo);
+                zyList.addAll(ypMzFytjs);
+                int threeDayDosage = 0;
+                int sevenDayDosage = 0;
+                int fourteenDayDosage = 0;
+                int thirtyDayDosage = 0;
+                for (int i = 0; i < zyList.size(); i++) {
+                    Map<String, Object> map = zyList.get(i);
+                    if(DateUtil.differentDaysByMillisecond(DateUtil.pase(map.get("confirm_time").toString(),"yyyy-MM-dd HH:mm:ss"),new Date())
+                            <=3){
+                        threeDayDosage+=Double.parseDouble(map.get("quantity").toString());
+                    }
+                    if(DateUtil.differentDaysByMillisecond(DateUtil.pase(map.get("confirm_time").toString(),"yyyy-MM-dd HH:mm:ss"),new Date())
+                            <=7){
+                        sevenDayDosage+=Double.parseDouble(map.get("quantity").toString());
+                    }
+                    if(DateUtil.differentDaysByMillisecond(DateUtil.pase(map.get("confirm_time").toString(),"yyyy-MM-dd HH:mm:ss"),new Date())
+                            <=14){
+                        fourteenDayDosage+=Double.parseDouble(map.get("quantity").toString());
+                    }
+                    if(DateUtil.differentDaysByMillisecond(DateUtil.pase(map.get("confirm_time").toString(),"yyyy-MM-dd HH:mm:ss"),new Date())
+                            <=30){
+                        thirtyDayDosage+=Double.parseDouble(map.get("quantity").toString());
+                    }
+                }
+                ypZdBaseYfSpecialVo.setThreeDayDosage(threeDayDosage);
+                ypZdBaseYfSpecialVo.setSevenDayDosage(sevenDayDosage);
+                ypZdBaseYfSpecialVo.setFourteenDayDosage(fourteenDayDosage);
+                ypZdBaseYfSpecialVo.setThirtyDayDosage(thirtyDayDosage);
+                ypZdBaseYfSpecialVos.add(ypZdBaseYfSpecialVo);
+            }
+        });
+        return ypZdBaseYfSpecialVos;
     }
 }

+ 2 - 0
src/main/java/cn/hnthyy/thmz/vo/YpZdBaseYfSpecialVo.java

@@ -53,4 +53,6 @@ public class YpZdBaseYfSpecialVo {
     private Integer fourteenDayDosage;
     //30天用量
     private Integer thirtyDayDosage;
+    //处方限制天数
+    private Integer prescriptionLimitDays;
 }

+ 8 - 5
src/main/resources/static/js/yf/yf_special_mark.js

@@ -48,11 +48,14 @@ function initTable() {
         cellEdit: true,
         cellsubmit: "remote",
         cellurl: '/thmz/modifYpSpecialMark',
-        colNames: ['门诊停用','住院停用','库存为零','编码','序号', '药品名', '库存量', '大规格(汇总)', '规格', '虚存2','启用虚存2', '3天用量', '7天用量', '14天用量','30天用量','厂家','药性分类'],
+        colNames: ['门诊停用','住院停用','库存为零','处方限制天数','编码','序号', '药品名', '库存量', '大规格(汇总)', '规格', '虚存2','启用虚存2', '3天用量', '7天用量', '14天用量','30天用量','厂家','药性分类'],
         colModel: [
             {name: 'visibleFlagMz', index: 'visibleFlagMz',align:'center',width:100,formatter : "checkbox",editable : true,edittype:'checkbox', editoptions:{value:"1:0"}},
             {name: 'visibleFlagZy', index: 'visibleFlagZy',align:'center',width:100,formatter : "checkbox",editable : true,edittype:'checkbox', editoptions:{value:"1:0"}},
             {name: 'visibleFlagStop', index: 'visibleFlagStop',align:'center',width:100,formatter : "checkbox",editable : true,edittype:'checkbox', editoptions:{value:"1:0"}},
+            {name: 'prescriptionLimitDays', index: 'prescriptionLimitDays',width:100,align:'center',editable : true,edittype:'text'
+                ,editrules: {edithidden:false,number:true,minValue:0}
+            },
             {name: 'chargeCode', index: 'chargeCode',align:'center',width:100},
             {name: 'serial', index: 'serial',align:'center',width:100,hidden:true},
             {name: 'name', index: 'name',width:180},
@@ -63,10 +66,10 @@ function initTable() {
                 ,editrules: {edithidden:true,number:true,minValue:0}
                },
             {name: 'openVirtual2', index: 'openVirtual2',width:100,align:'center',formatter : "checkbox",editable : true,edittype:'checkbox', editoptions:{value:"1:0"}},
-            {name: 'threeDayDosage', index: 'threeDayDosage', formatter: 'number',align:'center',width:100},
-            {name: 'sevenDayDosage', index: 'sevenDayDosage', formatter: 'number',align:'center',width:100},
-            {name: 'fourteenDayDosage', index: 'fourteenDayDosage', formatter: 'number',align:'center',width:100},
-            {name: 'thirtyDayDosage', index: 'thirtyDayDosage', formatter: 'number',align:'center',width:100},
+            {name: 'threeDayDosage', index: 'threeDayDosage', formatter: 'number',formatoptions:{decimalPlaces:0},align:'center',width:100},
+            {name: 'sevenDayDosage', index: 'sevenDayDosage', formatter: 'number',formatoptions:{decimalPlaces:0},align:'center',width:100},
+            {name: 'fourteenDayDosage', index: 'fourteenDayDosage', formatter: 'number',formatoptions:{decimalPlaces:0},align:'center',width:100},
+            {name: 'thirtyDayDosage', index: 'thirtyDayDosage', formatter: 'number',formatoptions:{decimalPlaces:0},align:'center',width:100},
             {name: 'manufactoryName', index: 'manufactoryName',width:180},
             {name: 'className', index: 'className',width:100,align:'center'}
         ],