Jelajahi Sumber

查询药品

xiaochan 3 tahun lalu
induk
melakukan
b4d79804ad

+ 7 - 7
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiQueryDao.java

@@ -328,7 +328,7 @@ public interface SiQueryDao {
             "FROM t_si_setlinfo a " +
             "LEFT JOIN zy_dis_diag_yb dis " +
             " ON (a.pat_no = dis.inpatient_no " +
-            "  AND a.times = dis.admiss_times) " +
+            "  AND a.times = dis.admiss_times and dis_diag_no = 1) " +
             "LEFT JOIN zy_inactpatient zy " +
             " ON (zy.inpatient_no = a.pat_no " +
             "  AND zy.admiss_times = a.times) " +
@@ -356,7 +356,7 @@ public interface SiQueryDao {
             "       dis_diag_comment = dis.dis_diag_comment, " +
             "       dis_diag = dis.dis_diag " +
             "from t_si_setlinfo a " +
-            "         left join zy_dis_diag_yb dis on (a.pat_no = dis.inpatient_no and a.times = dis.admiss_times) " +
+            "         left join zy_dis_diag_yb dis on (a.pat_no = dis.inpatient_no and a.times = dis.admiss_times and dis_diag_no = 1) " +
             "         left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no " +
             "    and zy.admiss_times = a.times) " +
             "where revoked=0 and setl_type=#{setlType} and insutype like #{insutype} and setl_time>=#{begntime} " +
@@ -379,7 +379,7 @@ public interface SiQueryDao {
             "       dis_diag_comment = dis.dis_diag_comment, " +
             "       dis_diag = dis.dis_diag " +
             "from t_si_setlinfo a " +
-            "         left join zy_dis_diag_yb dis on (a.pat_no = dis.inpatient_no and a.times = dis.admiss_times) " +
+            "         left join zy_dis_diag_yb dis on (a.pat_no = dis.inpatient_no and a.times = dis.admiss_times and dis_diag_no = 1) " +
             "         left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no " +
             "    and zy.admiss_times = a.times) " +
             "where revoked=0 and setl_type=#{setlType} and insutype like #{insutype} and setl_time>=#{begntime} " +
@@ -402,7 +402,7 @@ public interface SiQueryDao {
             "       dis_diag_comment = dis.dis_diag_comment, " +
             "       dis_diag = dis.dis_diag " +
             "from t_si_setlinfo a " +
-            "         left join zy_dis_diag_yb dis on (a.pat_no = dis.inpatient_no and a.times = dis.admiss_times) " +
+            "         left join zy_dis_diag_yb dis on (a.pat_no = dis.inpatient_no and a.times = dis.admiss_times and dis_diag_no = 1) " +
             "         left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no " +
             "    and zy.admiss_times = a.times) " +
             "where revoked=0 and setl_type=#{setlType} and insutype like #{insutype} and setl_time>=#{begntime} " +
@@ -425,7 +425,7 @@ public interface SiQueryDao {
             "       dis_diag_comment = dis.dis_diag_comment, " +
             "       dis_diag = dis.dis_diag " +
             "from t_si_setlinfo a " +
-            "         left join zy_dis_diag_yb dis on (a.pat_no = dis.inpatient_no and a.times = dis.admiss_times) " +
+            "         left join zy_dis_diag_yb dis on (a.pat_no = dis.inpatient_no and a.times = dis.admiss_times and dis_diag_no = 1) " +
             "         left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no " +
             "    and zy.admiss_times = a.times) " +
             "where revoked=0 and setl_type=#{setlType} and insutype like #{insutype} and setl_time>=#{begntime} " +
@@ -448,7 +448,7 @@ public interface SiQueryDao {
             "       dis_diag_comment = dis.dis_diag_comment, " +
             "       dis_diag = dis.dis_diag " +
             "from t_si_setlinfo a " +
-            "         left join zy_dis_diag_yb dis on (a.pat_no = dis.inpatient_no and a.times = dis.admiss_times) " +
+            "         left join zy_dis_diag_yb dis on (a.pat_no = dis.inpatient_no and a.times = dis.admiss_times and dis_diag_no = 1) " +
             "         left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no " +
             "    and zy.admiss_times = a.times) " +
             "where revoked=0 and setl_type=#{setlType} and insutype like #{insutype} and setl_time>=#{begntime} " +
@@ -471,7 +471,7 @@ public interface SiQueryDao {
             "       dis_diag_comment = dis.dis_diag_comment, " +
             "       dis_diag = dis.dis_diag " +
             "from t_si_setlinfo a " +
-            "         left join zy_dis_diag_yb dis on (a.pat_no = dis.inpatient_no and a.times = dis.admiss_times) " +
+            "         left join zy_dis_diag_yb dis on (a.pat_no = dis.inpatient_no and a.times = dis.admiss_times and dis_diag_no = 1) " +
             "         left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no " +
             "    and zy.admiss_times = a.times) " +
             "where revoked=0 and setl_type=#{setlType} and insutype like #{insutype} and setl_time>=#{begntime} " +

+ 47 - 0
src/main/java/thyyxxk/webserver/dao/his/reports/QueryDrugsAndProjectsDao.java

@@ -83,6 +83,53 @@ public interface QueryDrugsAndProjectsDao {
     List<QueryDrugsAndProjects> queryProjects(QueryDrugsAndProjects param);
 
 
+    @Select("<script>" +
+            "select a.charge_code_mx     as chargeCode, " +
+            "       rtrim(name)          as name, " +
+            "       sum(a.charge_amount) as number, " +
+            "       sum(charge_fee)      as amount_of_money, " +
+            "       '药品费'             as classCode, " +
+            "       N'住院'                as source " +
+            "from zy_detail_charge a, " +
+            "     yp_zd_dict b " +
+            "where a.charge_code_mx = b.code " +
+            "  and b.serial = '01' " +
+            "<if test=\"startTime!=null and startTime!=''\">" +
+            "and charge_date&gt;=#{startTime} and charge_date&lt;#{endTime} " +
+            "</if>" +
+            "<if test=\"ward!=null and ward!=''\">" +
+            "and a.exec_unit=#{ward} " +
+            "</if>" +
+            "<if test=\"chargeCode!=null and chargeCode!=''\">" +
+            "and charge_code_mx=#{chargeCode} " +
+            "</if>" +
+            "group by a.charge_code_mx, name " +
+            "union all " +
+            "select a.charge_item_code                      as chargeCode, " +
+            "       b.name                                  as name, " +
+            "       sum(a.quantity * drug_win)              as amount_of_money, " +
+            "       sum(a.quantity * drug_win * unit_price) as amountOfMoney, " +
+            "       '药品费'                                as classCode, " +
+            "       N'门诊'                                   as source " +
+            "from mz_charge_detail a, " +
+            "     yp_zd_dict b " +
+            "where a.charge_item_code = b.code " +
+            "  and b.serial = '01' " +
+            "<if test=\"startTime!=null and startTime!=''\">" +
+            "and a.charge_date&gt;=#{startTime} and a.charge_date&lt;#{endTime} " +
+            "</if>" +
+            "<if test=\"ward!=null and ward!=''\">" +
+            "and a.exec_dept=#{ward} " +
+            "</if>" +
+            "<if test=\"chargeCode!=null and chargeCode!=''\">" +
+            "and a.charge_item_code=#{chargeCode} " +
+            "</if>" +
+            "  and a.pay_mark='0' " +
+            "group by a.charge_item_code, b.name " +
+            "</script>")
+    List<QueryDrugsAndProjects> inquireAboutMedicines(QueryDrugsAndProjects param);
+
+
     /**
      * @param startTime  开始时间
      * @param endTime    结束时间

+ 9 - 2
src/main/java/thyyxxk/webserver/service/reports/QueryDrugsAndProjectsService.java

@@ -35,7 +35,7 @@ import java.util.Map;
 public class QueryDrugsAndProjectsService {
 
     private final QueryDrugsAndProjectsDao dao;
-
+    private final String TYPE_OF_MEDICINE = "K";
 
     @Autowired
     public QueryDrugsAndProjectsService(QueryDrugsAndProjectsDao dao) {
@@ -60,7 +60,14 @@ public class QueryDrugsAndProjectsService {
      * @param param 查询条件 时间 收费编码 费用类型 科室
      */
     public ResultVo<List<QueryDrugsAndProjects>> queryProjects(QueryDrugsAndProjects param) {
-        List<QueryDrugsAndProjects> list = dao.queryProjects(param);
+        List<QueryDrugsAndProjects> list = new ArrayList<>();
+        if (StringUtil.isBlank(param.getClassCode())) {
+            list = dao.queryProjects(param);
+            list.addAll(dao.inquireAboutMedicines(param));
+        }
+        if (TYPE_OF_MEDICINE.equals(param.getClassCode())) {
+            list.addAll(dao.inquireAboutMedicines(param));
+        }
         if (list.isEmpty()) {
             return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
         }