Browse Source

计算年龄优化

DESKTOP-0GD05B0\Administrator 2 years ago
parent
commit
8a04424cb3
1 changed files with 34 additions and 24 deletions
  1. 34 24
      src/main/java/thyyxxk/webserver/service/inpatient/PatientService.java

+ 34 - 24
src/main/java/thyyxxk/webserver/service/inpatient/PatientService.java

@@ -82,35 +82,45 @@ public class PatientService {
     private void setExpenseInformation(Patient data) {
         data.setMedTypeName(MedType.getName(data.getMedType()));
         data.setDutyNurseName(redis.getEmployeeName(data.getDutyNurse()));
+
+        HuanZheFeiYong feiYongZhanBi = yiZhuLuRuDao.feiYongXinXi(data.getInpatientNo(), data.getAdmissTimes(), data.getLedgerSn());
+        if (feiYongZhanBi != null) {
+            // 余额
+            data.setBalance(feiYongZhanBi.getBalance());
+            // 总费用
+            data.setTotalCharge(feiYongZhanBi.getTotalCharge());
+            // 药品 百分比
+            data.setYp(DecimalUtil.getPercent(Double.parseDouble(feiYongZhanBi.getYp()), Double.parseDouble(feiYongZhanBi.getTotalCharge())));
+            // 检验检查 百分比
+            data.setJyjc(DecimalUtil.getPercent(Double.parseDouble(feiYongZhanBi.getJyjc()), Double.parseDouble(feiYongZhanBi.getTotalCharge())));
+            // 医保 费用
+            data.setChargeYb(feiYongZhanBi.getChargeYb());
+            // 医保百分比
+            data.setYb(DecimalUtil.getPercent(Double.parseDouble(feiYongZhanBi.getChargeYb()), Double.parseDouble(feiYongZhanBi.getTotalCharge())));
+        }
+        XinZhenYiZhu xinZhenYiZhu = yiZhuLuRuDao.huoQuHuanZheXinXi(data.getInpatientNo(), data.getAdmissTimes());
+        if (xinZhenYiZhu != null) {
+            // 是否出纳
+            data.setTimesBilled(xinZhenYiZhu.getTimesBilled());
+        }
         if (null != data.getSocialNo() && data.getSocialNo().trim().length() == 18 && !data.getSocialNo().startsWith("K")) {
             try {
-                HuanZheFeiYong feiYongZhanBi = yiZhuLuRuDao.feiYongXinXi(data.getInpatientNo(), data.getAdmissTimes(), data.getLedgerSn());
-                if (feiYongZhanBi != null) {
-                    // 余额
-                    data.setBalance(feiYongZhanBi.getBalance());
-                    // 总费用
-                    data.setTotalCharge(feiYongZhanBi.getTotalCharge());
-                    // 药品 百分比
-                    data.setYp(DecimalUtil.getPercent(Double.parseDouble(feiYongZhanBi.getYp()), Double.parseDouble(feiYongZhanBi.getTotalCharge())));
-                    // 检验检查 百分比
-                    data.setJyjc(DecimalUtil.getPercent(Double.parseDouble(feiYongZhanBi.getJyjc()), Double.parseDouble(feiYongZhanBi.getTotalCharge())));
-                    // 医保 费用
-                    data.setChargeYb(feiYongZhanBi.getChargeYb());
-                    // 医保百分比
-                    data.setYb(DecimalUtil.getPercent(Double.parseDouble(feiYongZhanBi.getChargeYb()), Double.parseDouble(feiYongZhanBi.getTotalCharge())));
-                }
-                XinZhenYiZhu xinZhenYiZhu = yiZhuLuRuDao.huoQuHuanZheXinXi(data.getInpatientNo(), data.getAdmissTimes());
-                if (xinZhenYiZhu != null) {
-                    // 是否出纳
-                    data.setTimesBilled(xinZhenYiZhu.getTimesBilled());
-                }
+                // 根据身份证计算出生年龄
                 data.setBirthDate(getBirthdayFromSocialNo(data.getSocialNo()));
-                // 年龄
-                data.setAge(DateUtil.calculateAge(new SimpleDateFormat("yyyy-MM-dd").parse(data.getBirthDate()), data.getAdmissDate()));
-            } catch (ParseException e) {
-                log.error("获取患者基本信息出错", e);
+            } catch (Exception e) {
+                e.printStackTrace();
+                log.error("设置出生日期出错");
             }
         }
+
+        try {
+            // 年龄
+            data.setAge(DateUtil.calculateAge(new SimpleDateFormat("yyyy-MM-dd").parse(data.getBirthDate()), data.getAdmissDate()));
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("计算年龄出错");
+        }
+
     }
 
     private String getBirthdayFromSocialNo(String socialNo) throws ParseException {