Browse Source

新增管床日数统计报表

hsh 3 years ago
parent
commit
31969ca9ef

+ 43 - 0
src/main/java/thyyxxk/webserver/controller/ybkf/BedDaysController.java

@@ -0,0 +1,43 @@
+package thyyxxk.webserver.controller.ybkf;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.ybkf.YbkfShareDto;
+import thyyxxk.webserver.service.ybkf.BedDaysService;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @ClassName BedDaysController
+ * @Description 统计管床日数
+ * @Author hsh
+ * @Date 2022/8/24 9:04
+ **/
+@RestController
+@RequestMapping("/bedDays")
+public class BedDaysController {
+
+    private final BedDaysService service;
+
+    @Autowired
+    public BedDaysController(BedDaysService service) {
+        this.service = service;
+    }
+
+    @PostMapping("/selectBedDays")
+    public ResultVo<List<Map>> selectBedDays(@RequestBody @Validated YbkfShareDto dto){
+        return service.selectBedDays(dto);
+    }
+
+    @PostMapping("/selectYsDaysDetails")
+    public ResultVo<List<Map>> selectYsDaysDetails(@RequestBody @Validated YbkfShareDto dto){
+        return service.selectYsDaysDetails(dto);
+    }
+
+}

+ 51 - 0
src/main/java/thyyxxk/webserver/dao/his/ybkf/BedDaysDao.java

@@ -0,0 +1,51 @@
+package thyyxxk.webserver.dao.his.ybkf;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface BedDaysDao {
+
+    @Select(" select t.ryks, t.small_dept as deptId, sum(t.days) days from " +
+            " (select inpatient_no,admiss_times,name,admiss_date,dis_date,small_dept, " +
+            " refer_physician, DATEDIFF(day, #{beginTime},dis_date) days, " +
+            " (select name from zd_unit_code where code=small_dept) ryks, " +
+            " (select name from zd_unit_code where code=zk_ward) cyks " +
+            " from zy_inactpatient where dis_date< #{endTime} and dis_date >= #{beginTime} " +
+            " union all " +
+            " select inpatient_no,admiss_times,name,admiss_date,dis_date,small_dept,refer_physician, " +
+            " DATEDIFF(day, case when admiss_date < #{beginTime} then #{beginTime} else admiss_date end, " +
+            " case when dis_date is null then #{endTime} else dis_date end) days, " +
+            " (select name from zd_unit_code where code=small_dept) ryks, " +
+            " (select name from zd_unit_code where code=zk_ward) cyks " +
+            " from zy_actpatient where admiss_date < #{endTime} and isnull(dis_date,#{beginTime}) >= #{beginTime} " +
+            " ) t " +
+            " group by t.ryks, t.small_dept " +
+            " order by t.ryks ")
+    List<Map>  selectBedDays(@Param("beginTime") String beginTime, @Param("endTime") String endTime);
+
+    @Select(" select t.ryks, t.doctor, sum(t.days) days from " +
+            " (select inpatient_no,admiss_times,name,admiss_date,dis_date,small_dept, " +
+            " refer_physician, DATEDIFF(day, #{beginTime},dis_date) days, " +
+            " (select name from zd_unit_code where code=small_dept) ryks, " +
+            " (select name from zd_unit_code where code=zk_ward) cyks, " +
+            " isnull((select name from a_employee_mi where code=refer_physician), '其他') doctor " +
+            " from zy_inactpatient where dis_date< #{endTime} and dis_date >= #{beginTime} and small_dept = #{deptId} " +
+            " union all " +
+            " select inpatient_no,admiss_times,name,admiss_date,dis_date,small_dept,refer_physician, " +
+            " DATEDIFF(day, case when admiss_date < #{beginTime} then #{beginTime} else admiss_date end, " +
+            " case when dis_date is null then #{endTime} else dis_date end) days, " +
+            " (select name from zd_unit_code where code=small_dept) ryks, " +
+            " (select name from zd_unit_code where code=zk_ward) cyks, " +
+            " isnull((select name from a_employee_mi where code=refer_physician), '其他') doctor " +
+            " from zy_actpatient where admiss_date < #{endTime} and isnull(dis_date,#{beginTime}) >= #{beginTime} and small_dept = #{deptId} " +
+            " ) t " +
+            " group by t.ryks, t.doctor " +
+            " order by t.ryks ")
+    List<Map>  selectYsDaysDetails(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("deptId") String deptId);
+
+}

+ 22 - 0
src/main/java/thyyxxk/webserver/entity/ybkf/YbkfShareDto.java

@@ -0,0 +1,22 @@
+package thyyxxk.webserver.entity.ybkf;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * @ClassName YbkfShareDto
+ * @Description  报表开发共用查询实体
+ * @Author hsh
+ * @Date 2022/8/24 9:17
+ **/
+@Data
+public class YbkfShareDto {
+    @NotBlank(message = "请选择开始时间!")
+    private String startTime;
+    @NotBlank(message = "请选择结束时间!")
+    private String endTime;
+    private String deptId;
+    private String doctorId;
+    private String insurId;
+}

+ 45 - 0
src/main/java/thyyxxk/webserver/service/ybkf/BedDaysService.java

@@ -0,0 +1,45 @@
+package thyyxxk.webserver.service.ybkf;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import thyyxxk.webserver.dao.his.ybkf.BedDaysDao;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.ybkf.YbkfShareDto;
+import thyyxxk.webserver.utils.DateUtil;
+import thyyxxk.webserver.utils.ResultVoUtil;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @ClassName BedDaysService
+ * @Description 管床日数统计
+ * @Author hsh
+ * @Date 2022/8/24 9:11
+ **/
+@Service
+public class BedDaysService {
+
+    private final BedDaysDao dao;
+
+    @Autowired
+    public BedDaysService(BedDaysDao dao) {
+        this.dao = dao;
+    }
+
+    public ResultVo<List<Map>> selectBedDays(YbkfShareDto dto) {
+        String beginTime = dto.getStartTime();
+        String endTime = DateUtil.getMonthEndtime(dto.getEndTime());
+        List<Map> list = dao.selectBedDays(beginTime, endTime);
+        return ResultVoUtil.success(list);
+    }
+
+    public ResultVo<List<Map>> selectYsDaysDetails(YbkfShareDto dto) {
+        String beginTime = dto.getStartTime();
+        String endTime = DateUtil.getMonthEndtime(dto.getEndTime());
+        String deptId = dto.getDeptId();
+        List<Map> list = dao.selectYsDaysDetails(beginTime, endTime, deptId);
+        return ResultVoUtil.success(list);
+    }
+
+}