Pārlūkot izejas kodu

환자 입퇴소 현황 개발

huiwon.seo 4 gadi atpakaļ
vecāks
revīzija
585f10a589

+ 83 - 0
src/main/java/com/lemon/lifecenter/controller/PatientStatistics.java

@@ -0,0 +1,83 @@
+package com.lemon.lifecenter.controller;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.lemon.lifecenter.common.LifeCenterConfigVO;
+import com.lemon.lifecenter.common.LifeCenterController;
+import com.lemon.lifecenter.common.LifeCenterFunction;
+import com.lemon.lifecenter.common.LifeCenterPaging;
+import com.lemon.lifecenter.dto.LocationDTO;
+import com.lemon.lifecenter.dto.PatientDTO;
+import com.lemon.lifecenter.service.CenterService;
+import com.lemon.lifecenter.service.PatientService;
+
+@Controller
+@RequestMapping( "/statistics/patient" )
+public class PatientStatistics extends LifeCenterController {
+    @Autowired
+    private CenterService centerService;
+    @Autowired
+    private LifeCenterConfigVO config;
+    @Autowired
+    private PatientService patientService;
+    private LifeCenterPaging paging;
+    
+    @RequestMapping( "/list" )
+    public ModelAndView list( 
+            @RequestParam(value="page", required=false, defaultValue="1") int page,
+            @RequestParam(value="q", required=false, defaultValue="") String q,
+            @RequestParam(value="locationCode", required=false, defaultValue="") String locationCode,
+            @RequestParam(value="startDate", required=false, defaultValue="") String startDate,
+            @RequestParam(value="endDate", required=false, defaultValue="") String endDate) {
+        PatientDTO dto = new PatientDTO();
+        
+        if( endDate.equals( "" ) ) {
+            endDate = LifeCenterFunction.getNow( "yyyy-MM-dd" );
+        }
+        
+        if( startDate.equals( "" ) ) {
+            //기록상 최초 환자 입소일 이후부터 계산
+            startDate = "2020-11-23"; 
+        }
+        
+        dto.setLimit( ( Integer.valueOf( page ) - 1 ) * config.pageDataSize );
+        dto.setLimitMax( config.pageDataSize );
+        dto.setQ(q);
+        dto.setLocationCode(locationCode);
+        dto.setStartDate(startDate);
+        dto.setEndDate(endDate);
+        
+        List<LocationDTO> locationList = centerService.selectLocation();
+        
+        int total = patientService.selectStatisticsPatientCount(dto);
+        List<PatientDTO> statisticsList = patientService.selectStatisticsPatientList(dto);
+        PatientDTO statisticsSum = patientService.selectStatisticsPatientSum(dto);
+        
+        String param = "q=" + q + "&locationCode=" + locationCode + "&startDate=" + startDate + "&endDate=" + endDate;
+        paging = LifeCenterPaging.getInstance();
+        paging.paging(config, total, page, param);
+        
+        ModelAndView mv = setMV("statistics/list");
+        
+        
+        mv.addObject( "q" , q );
+        mv.addObject( "statisticsList" , statisticsList );
+        mv.addObject( "statisticsSum" , statisticsSum );
+        mv.addObject( "locationList", locationList );
+        mv.addObject( "locationCode", locationCode );
+        mv.addObject( "startDate", startDate);
+        mv.addObject( "endDate", endDate);
+        mv.addObject( "total", total);
+        mv.addObject( "paging", paging );
+        mv.addObject( "page", page );
+        mv.addObject( "pageSize", dto.getLimitMax() );
+        
+        return mv;
+    }
+}

+ 51 - 0
src/main/java/com/lemon/lifecenter/dto/PatientDTO.java

@@ -134,6 +134,57 @@ public class PatientDTO {
     private int limitMax;
     
     
+    //환자 입.퇴소자수 통계
+    private String inDate;
+    private int hTotal; //입소자수
+    private int dTotal; //퇴소자수
+    private int tTotal; //지정병원이송자 수
+    private int eTotal; //기타수
+    private String locationCode;
+    private String q;
+    
+    public String getInDate() {
+        return inDate;
+    }
+    public void setInDate(String inDate) {
+        this.inDate = inDate;
+    }
+    public int gethTotal() {
+        return hTotal;
+    }
+    public void sethTotal(int hTotal) {
+        this.hTotal = hTotal;
+    }
+    public int getdTotal() {
+        return dTotal;
+    }
+    public void setdTotal(int dTotal) {
+        this.dTotal = dTotal;
+    }
+    public int gettTotal() {
+        return tTotal;
+    }
+    public void settTotal(int tTotal) {
+        this.tTotal = tTotal;
+    }
+    public int geteTotal() {
+        return eTotal;
+    }
+    public void seteTotal(int eTotal) {
+        this.eTotal = eTotal;
+    }
+    public String getLocationCode() {
+        return locationCode;
+    }
+    public void setLocationCode(String locationCode) {
+        this.locationCode = locationCode;
+    }
+    public String getQ() {
+        return q;
+    }
+    public void setQ(String q) {
+        this.q = q;
+    }
     public int getNewCenterCode() {
         return newCenterCode;
     }

+ 4 - 0
src/main/java/com/lemon/lifecenter/mapper/PatientMapper.java

@@ -32,4 +32,8 @@ public interface PatientMapper {
     public int selectMunJinCount(PatientDTO dto);
     public void updatePatientCenterInfo( PatientDTO dto );
     public void insertCenterChangeLog( PatientDTO dto );
+    
+    public int selectStatisticsPatientCount( PatientDTO dto );
+    public List<PatientDTO> selectStatisticsPatientList( PatientDTO dto );
+    public PatientDTO selectStatisticsPatientSum( PatientDTO dto );
 }

+ 10 - 0
src/main/java/com/lemon/lifecenter/service/PatientService.java

@@ -79,4 +79,14 @@ public class PatientService {
     public void insertCenterChangeLog( PatientDTO dto ) {
         mapper.insertCenterChangeLog(dto);
     }
+    
+    public int selectStatisticsPatientCount( PatientDTO dto ) {
+        return mapper.selectStatisticsPatientCount(dto);
+    }
+    public List<PatientDTO> selectStatisticsPatientList( PatientDTO dto ){
+        return mapper.selectStatisticsPatientList(dto);
+    }
+    public PatientDTO selectStatisticsPatientSum( PatientDTO dto ) {
+        return mapper.selectStatisticsPatientSum(dto);
+    }
 }

+ 140 - 0
src/main/resources/mybatis/mapper/patient/patientStatistics.xml

@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.lemon.lifecenter.mapper.PatientMapper">
+    <select id="selectStatisticsPatientCount" parameterType="PatientDTO" resultType="int">
+        <![CDATA[
+            SELECT COUNT(*)
+              FROM DB_ROOT
+           CONNECT BY LEVEL <= ( TO_DATE( '2021-02-04' ) - TO_DATE( '2020-11-23' ) + 1)
+        ]]>
+    </select>
+    <select id="selectStatisticsPatientList" parameterType="PatientDTO" resultType="PatientDTO">
+        <![CDATA[
+            SELECT inDate,
+                   NVL( hTotal, 0 ) hTotal,
+                   NVL( dTotal, 0 ) dTotal,
+                   NVL( tTotal, 0 ) tTotal,
+                   NVL( eTotal, 0 ) eTotal
+             FROM ( SELECT TO_CHAR(TO_DATE( #{startDate} ) + LEVEL - 1, 'YYYY-MM-DD') AS inDate
+                      FROM DB_ROOT
+                   CONNECT BY LEVEL <= ( TO_DATE( #{endDate} ) - TO_DATE( #{startDate} ) + 1)
+                     ORDER BY inDate DESC
+                     LIMIT #{limit}, #{limitMax}
+                  ) DL
+             LEFT JOIN ( SELECT DATE_FORMAT( disisolation_date ,'%Y-%m-%d' ) AS dDate,
+                                COUNT( CASE WHEN state='D' THEN 1 END ) dTotal,
+                                COUNT( CASE WHEN state='T' THEN 1 END ) tTotal,
+                                COUNT( CASE WHEN state='E' THEN 1 END ) eTotal
+                           FROM patient_care
+                          WHERE center_code != 1
+                            AND center_code IN ( SELECT center_code AS center_code  
+                                                   FROM center_info 
+                                                  WHERE 1 = 1 
+                                                  ]]>
+                                                   <if test='q != null and q != ""'>
+                                                    <![CDATA[ 
+                                                    AND center_name LIKE CONCAT('%', #{q}, '%')
+                                                   ]]>
+                                                   </if>
+                                                   
+                                                   <if test='locationCode != null and locationCode != ""'>
+                                                   <![CDATA[ 
+                                                    AND location_code = #{locationCode}
+                                                    ]]>
+                                                   </if>
+                                                    <![CDATA[ 
+                                               )
+                          GROUP BY DATE_FORMAT( disisolation_date ,'%Y-%m-%d' )
+                       ) A
+               ON DL.inDate = A.dDate
+             LEFT JOIN ( SELECT DATE_FORMAT( hospitalization_date ,'%Y-%m-%d' ) AS hDate,
+                                COUNT(*) hTotal
+                           FROM patient_care
+                          WHERE center_code != 1 
+                            AND center_code IN ( SELECT center_code AS center_code  
+                                                   FROM center_info 
+                                                  WHERE 1 = 1 
+                                                  ]]>
+                                                   <if test='q != null and q != ""'>
+                                                    <![CDATA[ 
+                                                    AND center_name LIKE CONCAT('%', #{q}, '%')
+                                                   ]]>
+                                                   </if>
+                                                   
+                                                   <if test='locationCode != null and locationCode != ""'>
+                                                   <![CDATA[ 
+                                                    AND location_code = #{locationCode}
+                                                    ]]>
+                                                   </if>
+                                                    <![CDATA[ 
+                                               )
+                          GROUP BY DATE_FORMAT( hospitalization_date ,'%Y-%m-%d' )
+                       ) B
+               ON DL.inDate = B.hDate
+        ]]>
+    </select>
+    
+    <select id="selectStatisticsPatientSum" parameterType="PatientDTO" resultType="PatientDTO">
+        <![CDATA[
+            SELECT SUM ( NVL( hTotal, 0 ) ) hTotal,
+                   SUM ( NVL( dTotal, 0 ) ) dTotal,
+                   SUM ( NVL( tTotal, 0 ) ) tTotal,
+                   SUM ( NVL( eTotal, 0 ) ) eTotal
+             FROM ( SELECT TO_CHAR(TO_DATE( #{startDate} ) + LEVEL - 1, 'YYYY-MM-DD') AS inDate
+                      FROM DB_ROOT
+                   CONNECT BY LEVEL <= ( TO_DATE( #{endDate} ) - TO_DATE( #{startDate} ) + 1)
+                  ) DL
+             LEFT JOIN ( SELECT DATE_FORMAT( disisolation_date ,'%Y-%m-%d' ) AS dDate,
+                                COUNT( CASE WHEN state='D' THEN 1 END ) dTotal,
+                                COUNT( CASE WHEN state='T' THEN 1 END ) tTotal,
+                                COUNT( CASE WHEN state='E' THEN 1 END ) eTotal
+                           FROM patient_care
+                          WHERE center_code != 1
+                            AND center_code IN ( SELECT center_code AS center_code  
+                                                   FROM center_info 
+                                                  WHERE 1 = 1 
+                                                  ]]>
+                                                   <if test='q != null and q != ""'>
+                                                    <![CDATA[ 
+                                                    AND center_name LIKE CONCAT('%', #{q}, '%')
+                                                   ]]>
+                                                   </if>
+                                                   
+                                                   <if test='locationCode != null and locationCode != ""'>
+                                                   <![CDATA[ 
+                                                    AND location_code = #{locationCode}
+                                                    ]]>
+                                                   </if>
+                                                    <![CDATA[ 
+                                               )
+                          GROUP BY DATE_FORMAT( disisolation_date ,'%Y-%m-%d' )
+                       ) A
+               ON DL.inDate = A.dDate
+             LEFT JOIN ( SELECT DATE_FORMAT( hospitalization_date ,'%Y-%m-%d' ) AS hDate,
+                                COUNT(*) hTotal
+                           FROM patient_care
+                          WHERE center_code != 1 
+                            AND center_code IN ( SELECT center_code AS center_code  
+                                                   FROM center_info 
+                                                  WHERE 1 = 1 
+                                                  ]]>
+                                                   <if test='q != null and q != ""'>
+                                                    <![CDATA[ 
+                                                    AND center_name LIKE CONCAT('%', #{q}, '%')
+                                                   ]]>
+                                                   </if>
+                                                   
+                                                   <if test='locationCode != null and locationCode != ""'>
+                                                   <![CDATA[ 
+                                                    AND location_code = #{locationCode}
+                                                    ]]>
+                                                   </if>
+                                                    <![CDATA[ 
+                                               )
+                          GROUP BY DATE_FORMAT( hospitalization_date ,'%Y-%m-%d' )
+                       ) B
+               ON DL.inDate = B.hDate
+        ]]>
+    </select>
+</mapper>

+ 207 - 0
src/main/webapp/WEB-INF/jsp/statistics/list.jsp

@@ -0,0 +1,207 @@
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+    pageEncoding="UTF-8"%>
+<jsp:include page="${data._INCLUDE}/header.jsp"></jsp:include>
+<script>
+</script>
+</head>
+<body>
+    <div class="wrapper">
+        <jsp:include page="${data._INCLUDE}/sidebar.jsp"></jsp:include>
+        
+        <div class="main">
+            <jsp:include page="${data._INCLUDE}/top.jsp"></jsp:include>
+
+            <main class="content">
+                <div class="container-fluid p-0">
+                    <!-- 환지관리 START -->
+                    <div class="row">
+                        <div class="col-12 col-lg-6">
+                            <h1 class="h3 mb-3">환자 입/퇴소 현황</h1>
+                        </div>
+                        <div class="col-12 col-lg-6  text-right">
+                            <nav aria-label="breadcrumb">
+                                <ol class="breadcrumb">
+                                    <li class="breadcrumb-item"><a href="javscript:;">Home</a></li>
+                                    <li class="breadcrumb-item">환자 입/퇴소 현황</li>
+                                    <li class="breadcrumb-item active">입/퇴소 리스트</li>
+                                </ol>
+                            </nav>
+                        </div>
+                    </div>
+                    <div class="row">
+                        <div class="col-12">
+                            <div class="card">
+                                <form action="?" method="get">
+                                    <div class="card-body">
+                                        <table class="table mobile-table">
+                                            <colgroup>
+                                                <col style="width:10%">
+                                                <col style="width:40%">
+                                                <col style="width:10%">
+                                                <col style="width:40%">
+                                            </colgroup>
+                                            <tr>
+                                                <th>지역</th>
+                                                <td>
+                                                    <select class="custom-select form-control" name="locationCode">
+                                                        <option value="">전체</option>
+                                                        <c:forEach var="i" items="${locationList}">
+                                                            <option value="${i.locationCode}" <c:if test="${i.locationCode eq locationCode}"> selected="selected"</c:if>><c:out value="${i.locationName}"/></option>
+                                                        </c:forEach>
+                                                    </select>
+                                                </td>
+                                                <th>생활치료센터명</th>
+                                                <td>
+                                                    <div class="form-row">
+                                                        <div class="col-12">
+                                                            <input type="text" class="form-control" name="q" value="${q}" placeholder="">
+                                                        </div>
+                                                    </div>
+                                                </td>
+                                            </tr>
+                                            
+                                            <tr>
+                                                <th>검색 일자</th>
+                                                <td>
+                                                    <div class="row">
+                                                        <div class="col-lg-5 col-sm-5">
+                                                            <div class="form-group calendar-bar mb-xl-0">
+                                                                <input class="form-control" type="text" name="startDate" value="<c:out value="${startDate}"/>" placeholder="검색 시작일자" autocomplete="off">
+                                                                <i class="align-middle mr-2 fas fa-fw fa-calendar-alt"></i>
+                                                            </div>
+                                                        </div>
+                                                        <div class="col-lg-2 col-sm-2 text-center">
+                                                            ~
+                                                        </div>
+                                                        <div class="col-lg-5 col-sm-5">
+                                                            <div class="form-group calendar-bar mb-xl-0">
+                                                                <input class="form-control" type="text" name="endDate" value="<c:out value="${endDate}"/>" placeholder="검색 종료일자" autocomplete="off">
+                                                                <i class="align-middle mr-2 fas fa-fw fa-calendar-alt"></i>
+                                                            </div>
+                                                        </div>
+<!--                                                         <div class="col-sm-12 col-lg-2"> -->
+<!--                                                             <button class="btn btn-primary">검색</button> -->
+<!--                                                         </div> -->
+                                                    </div>
+                                                </td>
+                                                <td colspan="2">
+                                                    <div class="row">
+                                                        <div class="col-sm-12">
+                                                            <button class="btn btn-primary">검색</button>
+                                                        </div>
+                                                    </div>
+                                                </td>
+                                            </tr>
+                                        </table>
+                                    </div>
+                                </form>
+                            </div>
+                        </div>
+                    </div>
+                    <div class="row">
+                        <div class="col-12">
+                            <div class="card">
+                                <div class="card-body">
+                                    <div class="row mb-3">
+                                        <div class="col-6">전체 :
+                                            <fmt:formatNumber value="${total}" pattern="#,###" />
+                                        </div>
+                                        <div class="col-6 text-right">
+                                            <button class="btn btn-primary" onclick="location.href='./new';">Excel 다운로드</button>
+                                        </div>
+                                    </div>
+                                    <div class="table-responsive">
+                                        <table class="table table-striped text-center">
+                                            <colgroup>
+                                                <col width="7%">
+                                                <col width="15%">
+                                                <col width="15%">
+                                                <col width="15%">
+                                                <col width="15%">
+                                                <col width="15%">
+                                                <col width="15%">
+                                            </colgroup>
+                                            <thead>
+                                                <tr>
+                                                    <th rowspan="2">번호</th>
+                                                    <th rowspan="2">날짜</th>
+                                                    <th rowspan="2">환자 인원</th>
+                                                    <th rowspan="2">입소</th>
+                                                    <th rowspan="2">퇴실 소계</th>
+                                                    <th colspan="2">퇴실</th>
+                                                </tr>
+                                                
+                                                <tr>
+                                                    <th>퇴소</th>
+                                                    <th>지정병원이송</th>
+                                                </tr>
+                                            </thead>
+                                            <tbody>
+                                                <c:choose>
+                                                    <c:when test="${total > 0}">
+                                                        <tr style="background:#fbfd93;font-weight:600;">
+                                                            <td colspan="2">누적</td>
+                                                            <td><fmt:formatNumber value='${statisticsSum.hTotal + statisticsSum.dTotal + statisticsSum.tTotal}' pattern="#,###" /></td>
+                                                            <td><fmt:formatNumber value='${statisticsSum.hTotal}' pattern="#,###" /></td>
+                                                            <td><fmt:formatNumber value='${statisticsSum.dTotal + statisticsSum.tTotal}' pattern="#,###" /></td>
+                                                            <td><fmt:formatNumber value='${statisticsSum.dTotal}' pattern="#,###" /></td>
+                                                            <td><fmt:formatNumber value='${statisticsSum.tTotal}' pattern="#,###" /></td>
+                                                        </tr>
+                                                            
+                                                        <c:forEach var="sl" items="${statisticsList}" varStatus="lStatus">
+                                                            <c:set var="pageNum" value="${ ( total - lStatus.index ) - ( (page - 1) * pageSize ) }" />
+                                                            
+                                                            <tr>
+                                                                <td><fmt:formatNumber value="${pageNum}" pattern="#,###" /></td>
+                                                                <td><c:out value="${sl.inDate}" /></td>
+                                                                <td><fmt:formatNumber value='${sl.hTotal + sl.dTotal + sl.tTotal}' pattern="#,###" /></td>
+                                                                <td><fmt:formatNumber value='${sl.hTotal}' pattern="#,###" /></td>
+                                                                <td><fmt:formatNumber value='${sl.dTotal + sl.tTotal}' pattern="#,###" /></td>
+                                                                <td><fmt:formatNumber value='${sl.dTotal}' pattern="#,###" /></td>
+                                                                <td><fmt:formatNumber value='${sl.tTotal}' pattern="#,###" /></td>
+                                                            </tr>
+                                                        </c:forEach>
+                                                    </c:when>
+                                                    <c:otherwise>
+                                                        <tr>
+                                                            <td colspan="7">이력이 없습니다.</td>
+                                                        </tr>
+                                                    </c:otherwise>
+                                                </c:choose>
+                                            </tbody>
+                                        </table>
+                                    </div>
+                                    <div class="row mt-5">
+                                        <div class="col-12 col-lg-6 mb-2">
+                                        </div>
+                                        <div class="col-12 col-lg-6 mb-2">
+                                            <jsp:include page="${data._INCLUDE}/paging.jsp" flush="true">
+                                                <jsp:param name="firstPageNo" value="${paging.firstPageNo}" />
+                                                <jsp:param name="prevPageNo"  value="${paging.prevPageNo}" />
+                                                <jsp:param name="startPageNo" value="${paging.startPageNo}" />
+                                                <jsp:param name="pageNo"      value="${paging.pageNo}" />
+                                                <jsp:param name="endPageNo"   value="${paging.endPageNo}" />
+                                                <jsp:param name="nextPageNo"  value="${paging.nextPageNo}" />
+                                                <jsp:param name="finalPageNo" value="${paging.finalPageNo}" />
+                                                <jsp:param name="preFix"      value="${paging.preFix}" />
+                                                <jsp:param name="url"         value="${paging.url}" />
+                                                <jsp:param name="total"       value="${paging.totalCount}" />
+                                            </jsp:include>
+                                        </div>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                    <!-- 환자관리 END -->
+                </div>
+            </main>
+
+            <jsp:include page="${data._INCLUDE}/footer.jsp"></jsp:include>
+        </div>
+    </div>
+</body>
+</html>