Selaa lähdekoodia

1. 환자리스트 페이징 제외 완료
2. 환자 등록 수정중

junekeunsong 4 vuotta sitten
vanhempi
commit
105ad1b092

+ 26 - 4
src/main/java/com/lemon/lifecenter/controller/PatientController.java

@@ -8,6 +8,7 @@ import org.slf4j.LoggerFactory;
 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.LifeCenterController;
@@ -24,12 +25,33 @@ public class PatientController extends LifeCenterController {
     private PatientService patientService;
 
     @RequestMapping("/list")
-    public ModelAndView patientList() {
+//    @ModelAttribute("dto") final ASiboDTO dto,
+//    @RequestParam( value="k", required=true ) String k
+//    @RequestParam( value="type", required=false, defaultValue="" ) String type
+    public ModelAndView patientList(
+            @RequestParam(value="inputState", required=false, defaultValue="ALL") String inputState,
+            @RequestParam(value="patientName", required=false, defaultValue="") String patientName,
+            @RequestParam(value="startDate", required=false, defaultValue="") String startDate,
+            @RequestParam(value="endDate", required=false, defaultValue="") String endDate) {
+        
         PatientDTO dto = new PatientDTO();
-        List<PatientDTO> result = patientService.selectPatietList(dto);
-        logger.debug("result -- > " + result);
+        dto.setPatientName(patientName);
+        dto.setStat(inputState);
+        dto.setStartDate(startDate);
+        dto.setEndDate(endDate);
+        
+        int total = patientService.selectPatientCount(dto);
+        List<PatientDTO> result = new ArrayList<PatientDTO>();
+
+        if (total > 0) {
+            result = patientService.selectPatietList(dto);
+        }
+        
         ModelAndView mv = setMV("patient/list");
-        mv.addObject("jksong", result);
+        mv.addObject("inputState", inputState);
+        mv.addObject("patientName", patientName);
+        mv.addObject("total", total);
+        mv.addObject("item", result);
         return mv;
     }
 

+ 79 - 4
src/main/java/com/lemon/lifecenter/dto/PatientDTO.java

@@ -4,14 +4,89 @@ import org.springframework.stereotype.Repository;
 
 @Repository
 public class PatientDTO {
-    public String patientName;
-
+    private String num;
+    private String patientName;
+    private String gender;
+    private String age;
+    private String wardNumber;
+    private String roomNumber;
+    private String finamClinicDate;
+    private String hospitalizationDate;
+    private String disisolationDate;
+    private String stat;
+    private String startDate;
+    private String endDate;
+    
+    public String getNum() {
+        return num;
+    }
+    public void setNum(String num) {
+        this.num = num;
+    }
     public String getPatientName() {
         return patientName;
     }
-
     public void setPatientName(String patientName) {
         this.patientName = patientName;
     }
-
+    public String getGender() {
+        return gender;
+    }
+    public void setGender(String gender) {
+        this.gender = gender;
+    }
+    public String getAge() {
+        return age;
+    }
+    public void setAge(String age) {
+        this.age = age;
+    }
+    public String getWardNumber() {
+        return wardNumber;
+    }
+    public void setWardNumber(String wardNumber) {
+        this.wardNumber = wardNumber;
+    }
+    public String getRoomNumber() {
+        return roomNumber;
+    }
+    public void setRoomNumber(String roomNumber) {
+        this.roomNumber = roomNumber;
+    }
+    public String getFinamClinicDate() {
+        return finamClinicDate;
+    }
+    public void setFinamClinicDate(String finamClinicDate) {
+        this.finamClinicDate = finamClinicDate;
+    }
+    public String getHospitalizationDate() {
+        return hospitalizationDate;
+    }
+    public void setHospitalizationDate(String hospitalizationDate) {
+        this.hospitalizationDate = hospitalizationDate;
+    }
+    public String getDisisolationDate() {
+        return disisolationDate;
+    }
+    public void setDisisolationDate(String disisolationDate) {
+        this.disisolationDate = disisolationDate;
+    }
+    public String getStat() {
+        return stat;
+    }
+    public void setStat(String stat) {
+        this.stat = stat;
+    }
+    public String getStartDate() {
+        return startDate;
+    }
+    public void setStartDate(String startDate) {
+        this.startDate = startDate;
+    }
+    public String getEndDate() {
+        return endDate;
+    }
+    public void setEndDate(String endDate) {
+        this.endDate = endDate;
+    }
 }

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

@@ -10,5 +10,6 @@ import com.lemon.lifecenter.dto.PatientDTO;
 @Repository
 @Mapper
 public interface PatientMapper {
+    public int selectPatientCount(PatientDTO dto);
     public List<PatientDTO> selectPatientList(PatientDTO dto);
 }

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

@@ -14,6 +14,10 @@ public class PatientService {
     @Autowired
     private PatientMapper mapper;
 
+    public int selectPatientCount(PatientDTO dto) {
+        return mapper.selectPatientCount(dto);
+    }
+    
     public List<PatientDTO> selectPatietList(PatientDTO dto) {
         return mapper.selectPatientList(dto);
     }

+ 54 - 6
src/main/resources/mybatis/mapper/patient/patient.xml

@@ -2,14 +2,62 @@
 <!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="selectPatientCount" parameterType="PatientDTO" resultType="int">
+      <![CDATA[
+        SELECT count(*) AS total
+          FROM PATIENT_CARE
+         WHERE 1 = 1
+    ]]>
+    <if test='stat != "ALL"'>
+        <![CDATA[
+            AND STATE = #{stat}
+        ]]>
+    </if>
+    <if test='patientName != null and patientName != ""'>
+        <![CDATA[
+            AND PATIENT_NAME = #{patientName}
+        ]]>
+    </if>
+    <if test='startDate != null and startDate != "" and endDate != null and endDate != ""'>
+        <![CDATA[
+            AND DATE_FORMAT(FINAL_CLINIC_DATE, '%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
+        ]]>
+    </if>
+  </select>
   <select id="selectPatientList" parameterType="PatientDTO" resultType="PatientDTO">
     <![CDATA[
-		SELECT PATIENT_NAME                                                       AS patientName
-		  FROM PATIENT_CARE
-		 WHERE 1 = 1
-		   AND STATE = 'Y'
-		 ORDER BY HOSPITALIZATION_DATE DESC
-		 LIMIT 0, 10
+        SELECT ROWNUM                                                             AS num,
+               PATIENT_NAME                                                       AS patientName,
+               GENDER                                                             AS gender,
+               (SELECT TRUNC((SYSDATE-TO_DATE(19 || JUMIN, 'YYYYMMDD'))/365) + 1) AS age,
+               ward_number                                                        AS wardNumber,
+               room_number                                                        AS roomNumber,
+               DATE_FORMAT(FINAL_CLINIC_DATE, '%Y-%m-%d %H:%i')                   AS finamClinicDate,
+               DATE_FORMAT(HOSPITALIZATION_DATE, '%Y-%m-%d %H:%i')                AS hospitalizationDate,
+               DATE_FORMAT(DISISOLATION_DATE, '%Y-%m-%d %H:%i')                   AS disisolationDate,
+               STATE                                                              AS state
+          FROM PATIENT_CARE
+         WHERE 1 = 1
+    ]]>
+    <if test='stat != "ALL"'>
+        <![CDATA[
+            AND STATE = #{stat}
+        ]]>
+    </if>
+    <if test='patientName != null and patientName != ""'>
+        <![CDATA[
+            AND PATIENT_NAME = #{patientName}
+        ]]>
+    </if>
+    <if test='startDate != null and startDate != "" and endDate != null and endDate != ""'>
+        <![CDATA[
+            AND DATE_FORMAT(FINAL_CLINIC_DATE, '%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
+        ]]>
+    </if>
+    <![CDATA[
+         ORDER BY HOSPITALIZATION_DATE DESC
+         LIMIT 0, 10
     ]]>
   </select>
 </mapper>

+ 104 - 83
src/main/webapp/WEB-INF/jsp/patient/list.jsp

@@ -1,4 +1,5 @@
 <%@ 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"%>
@@ -25,9 +26,21 @@
                 format : "M/DD hh:mm A"
             }
         });
-        $("input[name=\"datesingle\"]").daterangepicker({
+        $("input[name=\"startDate\"]").daterangepicker({
             singleDatePicker : true,
-            showDropdowns : true
+            showDropdowns : true,
+            locale : {
+                //format : "M/DD hh:mm A"
+                format : "YYYY-MM-DD"
+            }
+        });
+        $("input[name=\"endDate\"]").daterangepicker({
+            singleDatePicker : true,
+            showDropdowns : true,
+            locale : {
+                //format : "M/DD hh:mm A"
+                format : "YYYY-MM-DD"
+            }
         });
         // Datetimepicker
         $('#datetimepicker-minimum').datetimepicker();
@@ -150,68 +163,63 @@
                     <div class="row">
                         <div class="col-12">
                             <div class="card">
-                                <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"
-                                                id="inputState"
-                                                name="inputState">
-                                                    <option
-                                                        value="success"
-                                                        selected="">전체</option>
-                                                    <option value="info">입소</option>
-                                                    <option
-                                                        value="warning">퇴소</option>
-                                            </select></td>
-                                            <th>환자명</th>
-                                            <td><input type="text"
-                                                class="form-control"
-                                                id="inputPassword4"
-                                                placeholder="환자명">
-                                            </td>
-                                        </tr>
-                                        <tr>
-                                            <th>진료일</th>
-                                            <td>
-                                                <div class="row">
-                                                    <div class="col-5">
-                                                        <div
-                                                            class="form-group mb-xl-0">
-                                                            <input
-                                                                class="form-control"
-                                                                type="text"
-                                                                name="datesingle">
+                                <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" id="inputState" name="inputState">
+                                                        <option value="ALL">전체</option>
+                                                        <option value="Y" <c:if test="${inputState eq 'Y'}"> selected="selected"</c:if>>입소</option>
+                                                        <option value="N" <c:if test="${inputState eq 'N'}"> selected="selected"</c:if>>퇴소</option>
+                                                    </select></td>
+                                                <th>환자명</th>
+                                                <td>
+                                                    <input type="text" class="form-control" id="inputPassword4" name="patientName" placeholder="환자명" value="<c:out value="${patientName}" />">
+                                                </td>
+                                            </tr>
+                                            <tr>
+                                                <th>진료일</th>
+                                                <td>
+                                                    <div class="row">
+                                                        <div class="col-5">
+                                                            <div
+                                                                class="form-group mb-xl-0">
+                                                                <input
+                                                                    class="form-control"
+                                                                    type="text"
+                                                                    name="startDate">
+                                                            </div>
                                                         </div>
-                                                    </div>
-                                                    <div
-                                                        class="col-2 text-center">
-                                                        ~</div>
-                                                    <div class="col-5">
                                                         <div
-                                                            class="form-group mb-xl-0">
-                                                            <input
-                                                                class="form-control"
-                                                                type="text"
-                                                                name="datesingle">
+                                                            class="col-2 text-center">
+                                                            ~</div>
+                                                        <div class="col-5">
+                                                            <div
+                                                                class="form-group mb-xl-0">
+                                                                <input
+                                                                    class="form-control"
+                                                                    type="text"
+                                                                    name="endDate">
+                                                            </div>
                                                         </div>
                                                     </div>
-                                                </div>
-                                            </td>
-                                            <td colspan="2">
-                                                <button
-                                                    class="btn btn-primary">검색</button>
-                                            </td>
-                                        </tr>
-                                    </table>
-                                </div>
+                                                </td>
+                                                <td colspan="2">
+                                                    <button
+                                                        class="btn btn-primary">검색</button>
+                                                </td>
+                                            </tr>
+                                        </table>
+                                    </div>
+                                </form>
                             </div>
                         </div>
                     </div>
@@ -221,7 +229,8 @@
                                 <div class="card-body">
                                     <div class="row">
                                         <div class="col-6">전체 :
-                                            645</div>
+                                            <fmt:formatNumber value="${total}" pattern="#,###" />
+                                        </div>
                                         <div class="col-6 text-right">
                                             <button
                                                 class="btn btn-primary"
@@ -265,32 +274,44 @@
                                                 </tr>
                                             </thead>
                                             <tbody>
-                                                <c:forEach var="i"
-                                                    items="${jksong}">
-                                                    <tr>
-                                                        <td>10</td>
-                                                        <td><a
-                                                            href="./edit">김레몬</a>
-                                                        </td>
-                                                        <td>남 <c:out
-                                                                value="${i.patientName}" /></td>
-                                                        <td>55</td>
-                                                        <td>1501</td>
-                                                        <td>2020-10-13
-                                                            15:23</td>
-                                                        <td>2020-10-15
-                                                            10:15</td>
-                                                        <td>-</td>
-                                                        <td>입소</td>
-                                                    </tr>
-                                                </c:forEach>
+                                                <c:choose>
+                                                    <c:when test="${total > 0}">
+                                                        <c:forEach var="l" items="${item}">
+                                                            <tr>
+                                                                <td><c:out value="${l.num}" /></td>
+                                                                <td><a
+                                                                    href="./edit"><c:out value="${l.patientName}" /></a>
+                                                                </td>
+                                                                <td><c:out value="${l.gender}" /></td>
+                                                                <td><c:out value="${l.age}" /></td>
+                                                                <td><c:out value="${l.wardNumber}${l.roomNumber}" /></td>
+                                                                <td><c:out value="${l.finamClinicDate}" /></td>
+                                                                <td><c:out value="${l.hospitalizationDate}" /></td>
+                                                                <td>
+                                                                    <c:if test="${l.disisolationDate eq null or l.disisolationDate eq ''}">
+                                                                        -
+                                                                    </c:if>
+                                                                    <c:if test="${l.disisolationDate ne ''}">
+                                                                        <c:out value="${l.disisolationDate}" />
+                                                                    </c:if>
+                                                                </td>
+                                                                <td><c:out value="${l.stat}" /></td>
+                                                            </tr>
+                                                        </c:forEach>
+                                                    </c:when>
+                                                    <c:otherwise>
+                                                        <tr>
+                                                            <td colspan="9">등록된 환자가 없습니다.</td>
+                                                        </tr>
+                                                    </c:otherwise>
+                                                </c:choose>
                                             </tbody>
                                         </table>
                                     </div>
                                     <div class="row mt-5">
-                                        <div
+                                         <div
                                             class="col-12 col-lg-6 mb-2">
-                                            <select
+                                            <!-- <select
                                                 class="custom-select form-control col-md-2"
                                                 id="inputState"
                                                 name="inputState">
@@ -298,7 +319,7 @@
                                                     selected="">전체</option>
                                                 <option value="info">입소</option>
                                                 <option value="warning">퇴소</option>
-                                            </select>
+                                            </select> -->
                                         </div>
                                         <div
                                             class="col-12 col-lg-6 mb-2">

+ 40 - 24
src/main/webapp/WEB-INF/jsp/patient/new.jsp

@@ -27,7 +27,19 @@
         });
         $("input[name=\"datesingle\"]").daterangepicker({
             singleDatePicker : true,
-            showDropdowns : true
+            showDropdowns : true,
+            locale : {
+                //format : "M/DD hh:mm A"
+                format : "YYYY-MM-DD"
+            }
+        });
+        $("input[name=\"hospitalizationDate\"]").daterangepicker({
+            singleDatePicker : true,
+            showDropdowns : true,
+            locale : {
+                //format : "M/DD hh:mm A"
+                format : "YYYY-MM-DD"
+            }
         });
         // Datetimepicker
         $('#datetimepicker-minimum').datetimepicker();
@@ -167,16 +179,11 @@
                                             <td colspan="2">
                                                 <div class="form-row">
                                                     <div class="col-6">
-                                                        <input
-                                                            class="form-control"
-                                                            type="text"
-                                                            name="datesingle">
+                                                        <input class="form-control" type="text" name="hospitalizationDate">
                                                     </div>
                                                     <div class="col-3">
-                                                        <select
-                                                            class="custom-select">
-                                                            <option
-                                                                selected="">시간</option>
+                                                        <select name="hour" class="custom-select">
+                                                            <option selected="">시간</option>
                                                             <option>1</option>
                                                             <option>2</option>
                                                             <option>3</option>
@@ -187,33 +194,42 @@
                                                         </select>
                                                     </div>
                                                     <div class="col-3">
-                                                        <select
-                                                            class="custom-select">
-                                                            <option
-                                                                selected="">분</option>
-                                                            <option>1</option>
+                                                        <select class="custom-select" name="min">
+                                                            <option selected="">분</option>
+                                                            <c:forEach var="i" begin="1" end="59" step="1">
+                                                                <option value="${i}">${i} 분</option>
+                                                            </c:forEach>
+                                                            <!-- <option>1</option>
                                                             <option>2</option>
                                                             <option>3</option>
                                                             <option>4</option>
                                                             <option>5</option>
                                                             <option>6</option>
-                                                            <option>7</option>
+                                                            <option>7</option> -->
                                                         </select>
                                                     </div>
                                                 </div>
                                             </td>
                                         </tr>
                                         <tr>
-                                            <th><span class="fix">*</span>병동
-                                                번호</th>
-                                            <td><input type="text"
-                                                class="form-control"
-                                                placeholder="병동 번호를 입력해주세요">
+                                            <th>
+                                                <span class="fix">*</span>병동  번호
+                                            </th>
+                                            <td>
+                                                <div class="form-row">
+                                                    <div class="col-5 form-check-inline">
+                                                        <input type="text" class="form-control" placeholder="병동 번호"> 동
+                                                    </div>
+                                                    <div class="col-5 form-check-inline">
+                                                        <input type="text" class="form-control" placeholder="병동 호실 "> 호
+                                                    </div>
+                                                </div>
                                             </td>
-                                            <th><span class="fix">*</span>이름</th>
-                                            <td><input type="text"
-                                                class="form-control"
-                                                placeholder="이름을 입력해주세요">
+                                            <th>
+                                                <span class="fix">*</span>이름
+                                            </th>
+                                            <td>
+                                                <input type="text" class="form-control" placeholder="이름을 입력해주세요">
                                             </td>
                                         </tr>
                                         <tr>