Bläddra i källkod

单人单管/混采增加时间和总数限制

hurugang 2 år sedan
förälder
incheckning
3d99ecf9f9

+ 14 - 0
src/main/java/cn/hnthyy/thmz/Utils/DateUtil.java

@@ -151,6 +151,20 @@ public class DateUtil {
         return calendar.getTime();
     }
 
+    /**
+     * 获取当前日期的23点59分59秒
+     *
+     * @return
+     */
+    public static Date getLastSecond() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.HOUR_OF_DAY, 23);
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+        calendar.set(Calendar.MILLISECOND, 0);
+        return calendar.getTime();
+    }
+
     /**
      * 获取给定日期的0点0分0秒
      *

+ 11 - 1
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzChargeDetailMapper.java

@@ -1150,7 +1150,6 @@ public interface MzChargeDetailMapper {
     @Select("select patient_id from mz_charge_detail  WITH(NOLOCK) where tc_no ='003585' and pay_mark = '0' and cash_id <> '99997' and price_time> '2022-10-09 15:00:00'  ")
     List<String> selectDrdgPatientId();
 
-
     /**
      * 根据收费编码查询当天是否有已经缴费的记录
      *
@@ -1161,6 +1160,17 @@ public interface MzChargeDetailMapper {
     @Select("select count(1) from  mz_charge_detail where patient_id=#{patientId} and charge_item_code =#{chargeItemCode} and pay_mark = 0 and confirm_flag<>4 and DateDiff(dd,charge_date,getDate()) =0 ")
     int select24HourReqByCode(@Param("patientId") String patientId, @Param("chargeItemCode") String chargeItemCode);
 
+    /**
+     * 根据收费编码查询当天的总混检申请数
+     *
+     * @param chargeItemCode
+     * @param beninTime
+     * @param endTime
+     * @return
+     */
+    @Select("select count(1) from  mz_charge_detail where charge_item_code =#{chargeItemCode} and pay_mark = 0 and confirm_flag<>4 and charge_date>=#{beninTime} and  charge_date<=#{endTime}")
+    int selectTotalReqByCode(@Param("chargeItemCode") String chargeItemCode, @Param("beninTime") Date beninTime, @Param("endTime") Date endTime);
+
     /**
      * 根据病人id和次数及缴费次数查询退费记录
      *

+ 10 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzYjReqMapper.java

@@ -391,4 +391,14 @@ public interface MzYjReqMapper {
      */
     @Select("select count(1) from  mz_yj_req where patient_id=#{patientId} and order_code =#{orderCode} and pay_mark = 0 and DateDiff(dd,req_date,getDate()) =0 ")
     int select24HourReqByCode(@Param("patientId") String patientId,@Param("orderCode") String orderCode);
+
+
+    /**
+     * 根据医嘱编码查询当天的总单检申请数
+     * @param beninTime
+     * @param endTime
+     * @return
+     */
+    @Select("select count(1) from  mz_yj_req where order_code in('003585','004764') and pay_mark = 0 and req_date>=#{beninTime} and  req_date<=#{endTime} ")
+    int selectTotalReqByCode(@Param("beninTime") Date beninTime, @Param("endTime") Date endTime);
 }

+ 49 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzChargeDetailServiceImpl.java

@@ -23,6 +23,7 @@ import cn.hnthyy.thmz.mapper.his.yp.YpMzFytjMapper;
 import cn.hnthyy.thmz.mapper.his.zd.JcZdItemMapper;
 import cn.hnthyy.thmz.mapper.his.zd.MzZdYpYshMapper;
 import cn.hnthyy.thmz.mapper.thmz.ClinicMapper;
+import cn.hnthyy.thmz.mapper.thmz.ConfigMapper;
 import cn.hnthyy.thmz.mapper.thmz.WindowsMapper;
 import cn.hnthyy.thmz.pageDto.MzChargeDetailPageDto;
 import cn.hnthyy.thmz.service.his.ResponceTypeService;
@@ -121,6 +122,9 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
     private WindowsMapper windowsMapper;
     @SuppressWarnings("all")
     @Autowired
+    private ConfigMapper configMapper;
+    @SuppressWarnings("all")
+    @Autowired
     private MzYpFydlMapper mzYpFydlMapper;
     @SuppressWarnings("all")
     @Autowired
@@ -2378,6 +2382,12 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
         if (num > 0) {
             throw new MzException("您在今天已经采过样了,请不要重复申请!");
         }
+
+        String title="核酸单人单管申请";
+        String hybirdNumberKey="single_hybird_number";
+        String hybirdTimeKey="single_hybird_time";
+        int totalNum=mzYjReqMapper.selectTotalReqByCode(DateUtil.getFirstSecond(),DateUtil.getLastSecond());
+        checkHybrid(title, hybirdNumberKey, hybirdTimeKey, totalNum);
         //自助开核酸的时候更新病人年龄
         if (mzPatientMi.getBirthDay() != null) {
             int age = DateUtil.getAge(mzPatientMi.getBirthDay());
@@ -2423,6 +2433,9 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
 
     @Override
     public Clinic hybridTestApplication(String patientId, String opId) throws MzException {
+        //单人单管最大人数
+        int personNumber = 20;
+        //int personNumber = 2;
         MzPatientMi mzPatientMi = mzPatientMiMapper.selectByPatientId(patientId);
         if (mzPatientMi == null) {
             throw new MzException("当前挂号的病人信息不存在,请先保存病人信息!");
@@ -2431,6 +2444,11 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
         if (num > 0) {
             throw new MzException("您在今天已经采过样了,请不要重复申请!");
         }
+        String title="混采";
+        String hybirdNumberKey="hybird_number";
+        String hybirdTimeKey="hybird_time";
+        int totalNum=mzChargeDetailMapper.selectTotalReqByCode(Constants.HYBRID_TEST_CHARGE_CODE,DateUtil.getFirstSecond(),DateUtil.getLastSecond());
+        checkHybrid(title, hybirdNumberKey, hybirdTimeKey, totalNum/personNumber);
         //自助开核酸的时候更新病人年龄
         if (mzPatientMi.getBirthDay() != null) {
             int age = DateUtil.getAge(mzPatientMi.getBirthDay());
@@ -2489,6 +2507,37 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
         return savePrescription(mzPrescriptionVo, null);
     }
 
+    /**
+     * 校验核酸申请是否已经达到最大值
+     * @param title
+     * @param hybirdNumberKey
+     * @param hybirdTimeKey
+     * @param totalNum
+     * @throws MzException
+     */
+    private void checkHybrid(String title, String hybirdNumberKey, String hybirdTimeKey, int totalNum) throws MzException {
+        Config config=configMapper.selectUserByKey(hybirdNumberKey);
+        if(config==null || StringUtils.isBlank(config.getConfigValue())){
+            throw new MzException(title+"最大数参数为空!");
+        }
+        Integer hybirdNumber =Integer.valueOf(config.getConfigValue());
+        if(totalNum>=hybirdNumber){
+            throw new MzException("抱歉,"+title+"人数以达到最大数值,无法继续采样!");
+        }
+        config=configMapper.selectUserByKey(hybirdTimeKey);
+        if(config==null || StringUtils.isBlank(config.getConfigValue())){
+            throw new MzException(title+"时间参数为空!");
+        }
+        String [] arr =config.getConfigValue().replaceAll(":","").split("-");
+        if(arr==null || arr.length!=2){
+            throw new MzException(title+"时间参数错误!");
+        }
+        Integer currentTimes = Integer.valueOf(DateUtil.fomart(new Date(),"HH:mm").replace(":",""));
+        if(currentTimes<Integer.valueOf(arr[0]) || currentTimes> Integer.valueOf(arr[1])){
+            throw new MzException("当前时间段无法进行"+title+",请选择其他核酸检验或者改日进行!");
+        }
+    }
+
     @Override
     public Clinic nucleicOnlyYellowAcidApplication(String patientId, String opId) throws MzException {
         return getNucleicAcidApplication(patientId, opId, Constants.NUCLEIC_ORDER_ONLY_YELLOW_CODE);

+ 37 - 1
src/main/resources/static/js/mz/hybrid_test.js

@@ -884,6 +884,23 @@ function hybirdTimeModal() {
             }
         }
     });
+    $.ajax({
+        type: "GET",
+        url: '/thmz/getConfigByKey?key=hybird_number',
+        contentType: "application/json;charset=UTF-8",
+        dataType: "json",
+        headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
+        success: function (res) {
+            if (res == '401' || res == 401) {
+                window.location.href = '/thmz/login/view'
+                return;
+            }
+            if (res.code == 0) {
+                var hybirdNumber=res.data.configValue;
+                $("#hybirdNumber").val(hybirdNumber);
+            }
+        }
+    });
 }
 
 
@@ -909,7 +926,26 @@ function updateHyBirdTime() {
                 return;
             }
             if (res.code == 0) {
-                successMesage(res);
+                var hybirdNumber=$('#hybirdNumber').val();
+                $.ajax({
+                    type: "POST",
+                    contentType: "application/json;charset=UTF-8",
+                    url: '/thmz/setConfig',
+                    dataType: "json",
+                    data: JSON.stringify({"configKey": "hybird_number","configValue": hybirdNumber}),
+                    headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
+                    success: function (res) {
+                        if (res == '401' || res == 401) {
+                            window.location.href = '/thmz/login/view'
+                            return;
+                        }
+                        if (res.code == 0) {
+                            successMesage(res);
+                        } else {
+                            errorMesage(res);
+                        }
+                    }
+                });
             } else {
                 errorMesage(res);
             }

+ 1 - 1
src/main/resources/templates/mz/hs_jc.html

@@ -247,7 +247,7 @@
                         </div>
                     </div>
                     <div class="col-md-8 col-sm-8 col-xs-12 item form-group">
-                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="hybirdEndTimeMinute">最大采样数
+                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="singleHybirdNumber">最大采样数
                             <span
                                     class="required">*</span>
                         </label>

+ 10 - 1
src/main/resources/templates/mz/hybrid_test.html

@@ -56,7 +56,7 @@
                 </div>
                 <div class="col-md-9 col-sm-9 col-xs-12">
                     <div class="clearRegistrationDiv">
-                        <a id="hybirdTimeManager" onclick="hybirdTimeModal()"><i class="fa fa-clock-o">&nbsp;混检设置</i></a>
+                        <a id="hybirdTimeManager" onclick="hybirdTimeModal()"><i class="fa fa-cog">&nbsp;混检管数/时间设置</i></a>
                         <a id="creatHybird" onclick="hybirdTypeModal()"><i class="fa fa-eyedropper">&nbsp;创建混检主体</i></a>
                         <a onclick="addToList()" hidden id="editUser"><i class="fa fa-plus">&nbsp;添加至列表</i></a>
                         <a id="clearRegistration"><i class="fa fa-trash">&nbsp;清空</i></a>
@@ -605,6 +605,15 @@
                             </select>
                         </div>
                     </div>
+                    <div class="col-md-8 col-sm-8 col-xs-12 item form-group">
+                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="hybirdNumber">最大采样数
+                            <span
+                                    class="required">*</span>
+                        </label>
+                        <div class="col-md-8 col-sm-8 col-xs-12">
+                            <input id="hybirdNumber" class="form-control col-md-7 col-xs-12" title="请录入混采最大采样数" type="number" min="0" />
+                        </div>
+                    </div>
                 </form>
             </div>
             <div class="modal-footer">