Sfoglia il codice sorgente

优化患者住院信息查询

lighter 2 anni fa
parent
commit
47e45b76de

+ 11 - 8
src/main/java/thyyxxk/wxservice_server/dao/InpatientDao.java

@@ -15,24 +15,27 @@ import java.util.List;
 @Mapper
 public interface InpatientDao {
     @Select("select rtrim(a.inpatient_no) inpatientNo, " +
-            "rtrim(b.name) name, " +
+            "rtrim(a.name) as name, " +
             "a.admiss_times, " +
             "convert(varchar(10), admiss_date, 21) admissDate, " +
             "rtrim(d.name) deptName, " +
-            "doctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=isnull(a.refer_physician,a.admiss_physician)), " +
+            "doctorName=(select rtrim(name) from a_employee_mi with(nolock) " +
+            "where code=isnull(a.refer_physician,a.admiss_physician)), " +
             "rtrim(c.total_charge) totalCharge, " +
             "rtrim(c.charge_yb) fundPay, " +
             "lastBalance=RTRIM(c.balance+c.charge_yb) " +
-            "from zy_actpatient a with(nolock), a_patient_mi b with(nolock), " +
-            "zy_ledger_file c with(nolock), zd_unit_code d with(nolock) " +
-            "where a.inpatient_no=b.inpatient_no and " +
+            "from zy_actpatient a with(nolock), zy_ledger_file c with(nolock), zd_unit_code d with(nolock) " +
+            "where a.inpatient_no=#{inpatientNo} and " +
             "a.inpatient_no=c.inpatient_no and " +
             "a.admiss_times=c.admiss_times and " +
             "c.ledger_sn=(select max(ledger_sn) from zy_ledger_file with(nolock) where " +
             "inpatient_no=a.inpatient_no and admiss_times=a.admiss_times) and " +
-            "d.code=a.small_dept and " +
-            "b.mz_no=#{patientId} ")
-    InpatientInfo getInpatientInfo(@Param("patientId") String patientId);
+            "d.code=a.small_dept")
+    InpatientInfo getInpatientInfo(@Param("inpatientNo") String inpatientNo);
+
+    @Select("select rtrim(inpatient_no) from a_patient_mi where social_no=" +
+            "(select social_no from mz_patient_mi where patient_id=#{patientId})")
+    String selectInpatientNoByPatientId(@Param("patientId") String patientId);
 
     @Update("execute zy_receive_drug #{inpatientNo} , #{admissTimes} , 1 , '0'")
     void receiveMedicineFees(@Param("inpatientNo") String inpatientNo,

+ 18 - 12
src/main/java/thyyxxk/wxservice_server/service/InpatientService.java

@@ -12,6 +12,7 @@ import thyyxxk.wxservice_server.entity.inpatient.InpatientInfo;
 import thyyxxk.wxservice_server.entity.inpatient.ZyFee;
 import thyyxxk.wxservice_server.utils.DecimalTool;
 import thyyxxk.wxservice_server.utils.ResultVoUtil;
+import thyyxxk.wxservice_server.utils.StringUtil;
 
 import java.util.*;
 
@@ -29,12 +30,15 @@ public class InpatientService {
     }
 
     public ResultVo<InpatientInfo> getInpatientInfo(String patientId) {
-        InpatientInfo info = dao.getInpatientInfo(patientId.trim());
-        if (null != info && null != info.getInpatientNo()) {
-            return ResultVoUtil.success(info);
-        } else {
+        String inpatientNo = dao.selectInpatientNoByPatientId(patientId);
+        if (StringUtil.isBlank(inpatientNo)) {
+            return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有找到此卡号对应的住院号。");
+        }
+        InpatientInfo info = dao.getInpatientInfo(inpatientNo);
+        if (null == info) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有找到此卡号的在院信息。");
         }
+        return ResultVoUtil.success(info);
     }
 
     public ResultVo<Map<String, Object>> getZyFees(GetZyFeeParam param) {
@@ -51,17 +55,19 @@ public class InpatientService {
         return ResultVoUtil.success(map);
     }
 
-
     public ResultVo<Map<String, Object>> getPrepaidHistory(String patientId) {
-        InpatientInfo info = dao.getInpatientInfo(patientId.trim());
-        if (null != info && null != info.getInpatientNo()) {
-            Map<String, Object> map = new HashMap<>(Constants.Capacity.TWO);
-            map.put("baseInfo", info);
-            map.put("prepaid", dao.selectPrepaidHistory(info.getInpatientNo(), info.getAdmissTimes()));
-            return ResultVoUtil.success(map);
-        } else {
+        String inpatientNo = dao.selectInpatientNoByPatientId(patientId);
+        if (StringUtil.isBlank(inpatientNo)) {
+            return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有找到此卡号对应的住院号。");
+        }
+        InpatientInfo info = dao.getInpatientInfo(inpatientNo);
+        if (null == info) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有找到此卡号的在院信息。");
         }
+        Map<String, Object> map = new HashMap<>(Constants.Capacity.TWO);
+        map.put("baseInfo", info);
+        map.put("prepaid", dao.selectPrepaidHistory(info.getInpatientNo(), info.getAdmissTimes()));
+        return ResultVoUtil.success(map);
     }
 
 }