Browse Source

门诊收费挂号费加收50%

hurugang 4 years ago
parent
commit
81f982642d

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

@@ -355,6 +355,37 @@ public class DateUtil {
         System.out.println(DateUtil.IsAfternoon(java.util.Calendar.getInstance().getTime().getHours()));
     }
 
+    /**
+     * 获取年龄
+     * @param birthDay
+     * @return
+     * @throws Exception
+     */
+    public static int getAge(Date birthDay) {
+        Calendar cal = Calendar.getInstance();
+        if (cal.before(birthDay)) { //出生日期晚于当前时间,无法计算
+//            throw new IllegalArgumentException(
+//                    "The birthDay is before Now.It's unbelievable!");
+            return 0;
+        }
+        int yearNow = cal.get(Calendar.YEAR);  //当前年份
+        int monthNow = cal.get(Calendar.MONTH);  //当前月份
+        int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH); //当前日期
+        cal.setTime(birthDay);
+        int yearBirth = cal.get(Calendar.YEAR);
+        int monthBirth = cal.get(Calendar.MONTH);
+        int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);
+        int age = yearNow - yearBirth;   //计算整岁数
+        if (monthNow <= monthBirth) {
+            if (monthNow == monthBirth) {
+                if (dayOfMonthNow < dayOfMonthBirth) age--;//当前日期在生日之前,年龄减一
+            } else {
+                age--;//当前月份在生日之前,年龄减一
+            }
+        }
+        return age;
+    }
+
 
 }
 

+ 35 - 0
src/main/java/cn/hnthyy/thmz/controller/MzyRequestController.java

@@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -470,4 +471,38 @@ public class MzyRequestController {
         }
     }
 
+
+    /**
+     * 根据排班主键和生日查询挂号费用
+     *
+     * @return
+     */
+    @UserLoginToken
+    @RequestMapping(value = "/getMzChargeTypeByMzyRequestId", method = {RequestMethod.GET})
+    public Map<String, Object> getMzChargeTypeByMzyRequestId(@RequestParam("mzyRequestId") Long mzyRequestId,@RequestParam("birthDay") String birthDay) {
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
+            if (mzyRequestId==null) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "排班主键不能为空");
+                return resultMap;
+            }
+            Date birthDayD =null;
+            if (StringUtils.isNotBlank(birthDay)) {
+                birthDayD= DateUtil.pase(birthDay,"yyyy-MM-dd");
+            }
+            MzyZdChargeType mzyZdChargeType=mzyRequestService.calculateAddition(mzyRequestId,birthDayD);
+            resultMap.put("code", 0);
+            resultMap.put("message", "根据号别编号查询号别成功");
+            resultMap.put("data", mzyZdChargeType);
+            return resultMap;
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("根据排班主键和生日查询挂号费用失败,错误信息{}", e.getMessage());
+            resultMap.put("code", -1);
+            resultMap.put("message", "根据排班主键和生日查询挂号费用失败");
+            return resultMap;
+        }
+    }
+
 }

+ 9 - 0
src/main/java/cn/hnthyy/thmz/service/his/MzyRequestService.java

@@ -154,4 +154,13 @@ public interface MzyRequestService {
      */
     int  removeMzyRequestById(Long id);
 
+
+    /**
+     * 根据排版主键和生日计算挂号费用 是否要加收附加费用7岁以内的孩子的
+     * @param mzyRequestId
+     * @param birthDay
+     * @return
+     */
+    MzyZdChargeType calculateAddition(Long mzyRequestId, Date birthDay) throws MzException;
+
 }

+ 9 - 3
src/main/java/cn/hnthyy/thmz/service/impl/his/MzyReqrecServiceImpl.java

@@ -113,7 +113,7 @@ public class MzyReqrecServiceImpl implements MzyReqrecService {
         if (windows == null) {
             throw new MzException("当前操作人未设置窗口号,请先设置!");
         }
-        MzyZdChargeType mzyZdChargeType = mzyZdChargeTypeMapper.selectByCode(mzyReqrec.getChargeType());
+        MzyZdChargeType mzyZdChargeType = mzyRequestService.calculateAddition(mzyReqrecPageDto.getMzyRequestId(),mzPatientMi.getBirthDay());
         if (mzyZdChargeType == null) {
             throw new MzException("当前号别不存在,请先设置!");
         }
@@ -324,10 +324,16 @@ public class MzyReqrecServiceImpl implements MzyReqrecService {
             mzyReqrec.setClinicFee(BigDecimal.ZERO);
             mzyReqrec.setReqFee(BigDecimal.ZERO);
         } else {
-            mzyReqrec.setOthFee(mzyRequest.getCheckFee());
+            BigDecimal checkFee=BigDecimal.ZERO;
+            if(mzyRequest.getCheckFee()!=null){
+                checkFee=mzyRequest.getCheckFee();
+            }
+            if(mzyZdChargeType.getOthFee()!=null){
+                checkFee=checkFee.add(mzyZdChargeType.getOthFee());
+            }
+            mzyReqrec.setOthFee(checkFee);
             mzyReqrec.setClinicFee(mzyZdChargeType.getClinicFee());
             mzyReqrec.setReqFee(mzyZdChargeType.getReqFee());
-
         }
         mzyReqrec.setBrochureFee(BigDecimal.ZERO);
 

+ 36 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/MzyRequestServiceImpl.java

@@ -1,5 +1,6 @@
 package cn.hnthyy.thmz.service.impl.his;
 
+import cn.hnthyy.thmz.Utils.DateUtil;
 import cn.hnthyy.thmz.entity.MzException;
 import cn.hnthyy.thmz.entity.his.Employee;
 import cn.hnthyy.thmz.entity.his.MzyRequest;
@@ -210,4 +211,39 @@ public class MzyRequestServiceImpl implements MzyRequestService {
     public int removeMzyRequestById(Long id) {
         return mzyRequestMapper.deleteMzyRequestById(id);
     }
+
+    @Override
+    public MzyZdChargeType calculateAddition(Long mzyRequestId, Date birthDay) throws MzException {
+        if (mzyRequestId==null) {
+            throw new MzException("排班主键不能为空");
+        }
+        MzyRequest mzyRequest=mzyRequestMapper.selectMzyRequestById(mzyRequestId);
+        if(mzyRequest==null){
+            throw new MzException("排班信息不存在");
+        }
+        MzyZdChargeType mzyZdChargeType=mzyZdChargeTypeMapper.selectByCode(mzyRequest.getChargeType());
+        if(mzyZdChargeType==null){
+            throw new MzException("根据号别编号查询号别失败,没有对应的号别信息");
+        }
+        if (birthDay!=null) {
+            int age=DateUtil.getAge(birthDay);
+            //小于7岁的挂号费上调50%
+            if(age<7){
+                BigDecimal checkFee=mzyRequest.getCheckFee();
+                checkFee=checkFee==null?BigDecimal.ZERO:checkFee;
+                if(mzyZdChargeType.getReqFee()!=null){
+                    checkFee=checkFee.add(mzyZdChargeType.getReqFee());
+                }
+                if(mzyZdChargeType.getClinicFee()!=null){
+                    checkFee=checkFee.add(mzyZdChargeType.getClinicFee());
+                }
+                if(mzyZdChargeType.getOthFee()!=null){
+                    checkFee=checkFee.add(mzyZdChargeType.getOthFee());
+                }
+                BigDecimal tempFee = checkFee.multiply(BigDecimal.valueOf(0.5));
+                mzyZdChargeType.setOthFee(mzyZdChargeType.getOthFee().add(tempFee));
+            }
+        }
+        return mzyZdChargeType;
+    }
 }

+ 42 - 31
src/main/resources/static/js/registration.js

@@ -260,33 +260,7 @@ $(function () {
     // });
 
     $("#birthDay").change(function (e) {
-        var birthDay = $("#birthDay").val();
-        if (birthDay.length == 8 && birthDay.indexOf("-") <= 0) {
-            birthDay = birthDay.substring(0, 4) + "-" + birthDay.substring(4, 6) + "-" + birthDay.substring(6);
-            $("#birthDay").val(birthDay);
-        }
-        var dateFormat = /^(\d{4})-(\d{2})-(\d{2})$/;
-        if (!dateFormat.test(birthDay)) {
-            new PNotify({
-                title: '错误提示',
-                text: '生日日期错误',
-                type: 'error',
-                hide: true,
-                styling: 'bootstrap3'
-            });
-        }
-        var arr = birthDay.split("-");
-        if (!checkDate(arr[0], arr[1], arr[2])) {
-            new PNotify({
-                title: '错误提示',
-                text: '生日日期错误',
-                type: 'error',
-                hide: true,
-                styling: 'bootstrap3'
-            });
-        }
-        var returnAge = jsGetAge(birthDay);
-        $("#age").val(returnAge);
+        setAge();
         $("#age").blur();
     });
 
@@ -586,7 +560,7 @@ function initChargeType() {
  * 设置挂号费等费用
  */
 function fitFee() {
-    var chargeType = $('#doctor').find("option:selected").attr('data-chargeType');
+    var mzyRequestId = $('#doctor').find("option:selected").attr('data-mzyRequestId');
     var checkFee = $('#doctor').find("option:selected").attr('data-checkFee');
     $("#checkFee").val(checkFee);
     $("#amountMoney").text(checkFee);
@@ -596,7 +570,7 @@ function fitFee() {
     $("#changeAmount").val(0);
     $.ajax({
         type: "GET",
-        url: '/thmz/getMzChargeTypeByCode?code=' + chargeType,
+        url: '/thmz/getMzChargeTypeByMzyRequestId?mzyRequestId=' + mzyRequestId+"&birthDay="+ $("#birthDay").val(),
         dataType: "json",
         headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
         success: function (res) {
@@ -606,7 +580,8 @@ function fitFee() {
             }
             $("#registrationFee").val(res.data.reqFee);
             $("#hospitalFee").val(res.data.clinicFee);
-            checkFee = parseFloat(checkFee) + parseFloat(res.data.reqFee) + parseFloat(res.data.clinicFee);
+            $("#othFee").val(res.data.othFee);
+            checkFee = parseFloat(checkFee) + parseFloat(res.data.reqFee) + parseFloat(res.data.clinicFee)+ parseFloat(res.data.othFee);
             $("#amountMoney").text(checkFee);
             $("#amountMoneyConfirm").text(checkFee);
             $("#realMoney").val(checkFee);
@@ -823,6 +798,7 @@ function queryUserInfoByCardNo() {
                         $("#address").val(res.data.address);
                         $("#address").blur();
                         $("#patientId").val(res.data.patientId);
+                        setAge();
                         if (res.data.name != null && res.data.name != "") {
                             $("#editUser").show();
                             $("#clearIcCardNo").show();
@@ -1095,6 +1071,7 @@ function fillPatinet(patientId) {
                     $("#address").val(res.data.address);
                     $("#address").blur();
                     $("#patientId").val(res.data.patientId);
+                    setAge();
                     if (res.data.name != null && res.data.name != "") {
                         $("#editUser").show();
                     }
@@ -1482,7 +1459,7 @@ function saveMzyReqrec() {
                 "ampm": $("#ampm").val(),
                 "unitCode": $("#deptNo").val(),
                 "chargeType": $("#chargeType").val(),
-                "paymode": $("#payType").val()
+                "paymode": $("#payType").val(),
             }, "responceType": $("#patientsNature").val(), "mzyRequestId": mzyRequestId
         }),
         headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
@@ -1839,3 +1816,37 @@ function queryUserInfoByName() {
     }
 
 }
+
+
+/**
+ * 设置年龄
+ */
+function setAge() {
+    var birthDay = $("#birthDay").val();
+    if (birthDay.length == 8 && birthDay.indexOf("-") <= 0) {
+        birthDay = birthDay.substring(0, 4) + "-" + birthDay.substring(4, 6) + "-" + birthDay.substring(6);
+        $("#birthDay").val(birthDay);
+    }
+    var dateFormat = /^(\d{4})-(\d{2})-(\d{2})$/;
+    if (!dateFormat.test(birthDay)) {
+        new PNotify({
+            title: '错误提示',
+            text: '生日日期错误',
+            type: 'error',
+            hide: true,
+            styling: 'bootstrap3'
+        });
+    }
+    var arr = birthDay.split("-");
+    if (!checkDate(arr[0], arr[1], arr[2])) {
+        new PNotify({
+            title: '错误提示',
+            text: '生日日期错误',
+            type: 'error',
+            hide: true,
+            styling: 'bootstrap3'
+        });
+    }
+    var returnAge = jsGetAge(birthDay);
+    $("#age").val(returnAge);
+}

+ 7 - 0
src/main/resources/templates/registration.html

@@ -284,6 +284,13 @@
                         <input id="checkFee" class="form-control col-md-7 col-xs-12" readonly>
                     </div>
                 </div>
+                <div class="col-md-3 col-sm-3 col-xs-12">
+                    <label class="control-label col-md-4 col-sm-4 col-xs-12" for="othFee">其他费
+                    </label>
+                    <div class="col-md-8 col-sm-8 col-xs-12">
+                        <input id="othFee" class="form-control col-md-7 col-xs-12" readonly>
+                    </div>
+                </div>
             </div>
             <!--<div class="item form-group">-->
                 <!---->