瀏覽代碼

건강정보 엑셀 정신건강 상세추가, 환자용앱 정신건강 blank페이지 오류 수정

huiwonseo 4 年之前
父節點
當前提交
f61692fae1

+ 78 - 1
src/main/java/com/lemon/lifecenter/controller/ClinicController.java

@@ -14,6 +14,7 @@ import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Set;
 
 import javax.servlet.http.HttpServletRequest;
@@ -51,11 +52,13 @@ import org.apache.poi.ss.usermodel.IndexedColors;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.MessageSource;
 import org.springframework.stereotype.Controller;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.ModelAttribute;
@@ -63,6 +66,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+import org.springframework.web.servlet.LocaleResolver;
 import org.springframework.web.servlet.ModelAndView;
 
 @Controller
@@ -83,6 +89,11 @@ public class ClinicController extends LifeCenterController {
   
   @Autowired
   private MentalService mentalService;
+
+  @Autowired
+  LocaleResolver localeResolver;
+  @Autowired
+  MessageSource messageSource;
 	
 	private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
@@ -1197,7 +1208,7 @@ public class ClinicController extends LifeCenterController {
       List<MentalDTO> data = new ArrayList<MentalDTO>();
       int mentalTotal = mentalService.selectMentalHealthTotalCount(mDTO);
       if (mentalTotal > 0) {
-        data = mentalService.selectMentalHealthTotalList(mDTO);
+        data = mentalService.selectMentalHealthExcelDownList(mDTO);
       }
 
       Sheet sheet1 = workbook.createSheet("정신건강");
@@ -1266,6 +1277,72 @@ public class ClinicController extends LifeCenterController {
         cs.setVerticalAlignment(CellStyle.VERTICAL_CENTER); // 높이 가운데 정렬
         cell5.setCellStyle(cs);
 
+        i++;
+
+        
+        row = sheet1.createRow(i);
+        row.setHeightInPoints((float) 100.0);
+        cell1 = row.createCell(0);
+        cell2 = row.createCell(1);
+        cell3 = row.createCell(2);
+        cell4 = row.createCell(3);
+        cell5 = row.createCell(4);
+        cell6 = row.createCell(5);
+        cell7 = row.createCell(6);
+        cell8 = row.createCell(7);
+
+        cell1.setCellValue("   자가진단 상세");
+        String[] stressTotalDetialArray = dto.getDetail().split(",");
+        String stressTotalDetial="";
+        
+        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder .getRequestAttributes()).getRequest();
+        Locale locale = localeResolver.resolveLocale(request);
+
+
+
+
+        for( String detail : stressTotalDetialArray ) {
+          String[] ds = detail.split("=");
+          String title = "";
+          String score="";
+
+          if (ds[0].contains("health.mental.question.stress")) {
+            score = ds[1].equals("0") ? "아니오(0점)" : "예(1점)";
+          } else if (ds[0].contains("health.mental.question.depressed")
+              && !ds[0].equals("health.mental.question.depressedChk")) {
+            score = ds[1].equals("0") ? "전혀 방해받지 않았다(0점)"
+                : ds[1].equals("1") ? "며칠 동안 방해 받았다(1점)" : ds[1].equals("2") ? "7일 이상 방해 받았다(2점)" : "거의 매일 방해 받았다(3점)";
+          } else if ( ds[0].equals("health.mental.question.depressedChk") ) {
+            score = ds[1].equals("0") ? "전혀 어렵지 않았다(0점)"
+                : ds[1].equals("1") ? "약간어려웠다(1점)" : ds[1].equals("2") ? "많이어려웠다(2점)" : "매우 많이어려웠다(3점)";
+          }
+
+
+          if( ds[0].equals( "health.mental.question.stress1" ) ) {
+            title = "[외상후 스트레스 증상]\r\n";
+
+          } else if( ds[0].equals( "health.mental.question.depressed1" ) ) {
+            title = "\r\n[우울 (9문항)]\r\n";
+
+          } else if( ds[0].equals( "health.mental.question.vas1" ) ) {
+            title = "\r\n[주관적 심리적 고통정도(VAS, 1문항)] \r\n";
+            
+            score = ds[1] + "점";
+          }
+
+
+          stressTotalDetial += title + messageSource.getMessage(ds[0], null, locale) + " - " + score + "\r\n";
+        }
+
+
+        cell2.setCellValue(stressTotalDetial);
+        sheet1.addMergedRegion(new CellRangeAddress(i, i, 1, 7));
+
+        cs.setWrapText(true);
+        cs.setVerticalAlignment(CellStyle.VERTICAL_CENTER); // 높이 가운데 정렬
+        cell5.setCellStyle(cs);
+
+
         i++;
       }
     }

+ 9 - 0
src/main/java/com/lemon/lifecenter/dto/MentalDTO.java

@@ -35,6 +35,15 @@ public class MentalDTO {
     private String recordId;
     private int recordPatientIdx;
     private String deletedById;
+    private String detail;
+
+    public String getDetail() {
+      return this.detail;
+    }
+
+    public void setDetail(String detail) {
+      this.detail = detail;
+    }
 
     public String getDeletedById() {
       return this.deletedById;

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

@@ -16,6 +16,7 @@ public interface MentalMapper {
     public MentalDTO selectMentalHealthTotalAmPm(MentalDTO dto);
     public int selectMentalHealthTotalCount(MentalDTO dto);
     public List<MentalDTO> selectMentalHealthTotalList(MentalDTO dto);
+    public List<MentalDTO> selectMentalHealthExcelDownList(MentalDTO dto);
     public List<MentalDTO> selectMentalHealthRecord(MentalDTO dto);
     public void insertMentalHealthTotalTemp(MentalDTO dto);
     public void insertMentalHealthRecordTemp(MentalDTO dto);

+ 3 - 0
src/main/java/com/lemon/lifecenter/service/MentalService.java

@@ -32,6 +32,9 @@ public class MentalService {
     public List<MentalDTO> selectMentalHealthTotalList(MentalDTO dto) {
         return mapper.selectMentalHealthTotalList(dto);
     }
+    public List<MentalDTO> selectMentalHealthExcelDownList(MentalDTO dto) {
+        return mapper.selectMentalHealthExcelDownList(dto);
+    }
     public List<MentalDTO> selectMentalHealthRecord(MentalDTO dto) {
         return mapper.selectMentalHealthRecord(dto);
     }

+ 39 - 0
src/main/resources/mybatis/mapper/mental/mental.xml

@@ -129,6 +129,45 @@
              ORDER BY idx desc
         ]]>
     </select>
+    <select id="selectMentalHealthExcelDownList" parameterType="MentalDTO" resultType="MentalDTO">
+        <![CDATA[
+            SELECT mh.idx             AS idx,
+                   mh.patient_idx     AS patientIdx,
+                   mh.stress_total    AS stressTotal,
+                   mh.depressed_total AS depressedTotal,
+                   mh.depressed_nine  AS depressedNine,
+                   mh.vas_total       AS vasTotal,
+                   DATE_FORMAT( mh.create_date, '%Y-%m-%d %H:%i')  AS createDate,
+                   DATE_FORMAT( mh.recorded_date, '%Y-%m-%d %H:%i')  AS recordedDate,
+                   mh.created_by      AS createdBy,
+                   mh.agree_yn        AS agreeYn,
+                   detail
+              FROM mental_health_total mh
+              LEFT JOIN( SELECT total_idx,
+                                GROUP_CONCAT( CONCAT( question_key, '=',item_score) ) AS detail
+								           FROM ( SELECT mr.total_idx,
+											                   mr.patient_idx,
+											                   mr.item_code,
+                                         mr.item_score,
+                                         mr.create_date,
+                                         mr.created_by,
+                                         mc.parent_code,
+                                         mc.question_key,
+                                         mc.category_key,
+                                         mc.etc_code
+                                    FROM mental_health_record mr
+                                    LEFT JOIN mental_health_check mc
+                                      ON mc.item_code = mr.item_code
+                                   WHERE mr.patient_idx = #{patientIdx}
+                                   ORDER BY mr.total_idx asc, mc.item_code asc
+								                ) A
+						              GROUP BY A.total_idx
+                       ) B
+                ON B.total_idx = mh.idx
+             WHERE patient_idx = #{patientIdx}
+             ORDER BY idx desc
+        ]]>
+    </select>
 
     <select id="selectMentalHealthRecord" parameterType="MentalDTO" resultType="MentalDTO">
         <![CDATA[

+ 14 - 2
src/main/webapp/WEB-INF/jsp/common/blank.jsp

@@ -1,5 +1,8 @@
-<%@ page session="false" %>
-<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
+<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
+<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
 <!doctype html>
 <html lang="ko">
 <head>
@@ -12,6 +15,15 @@
 <script src="/resources/js/mobile/jquery-3.3.1.min.js"></script>
 <script src="/resources/js/mobile/common.js"></script>
 <script src="/resources/js/mobile/jquery.modal.min.js"></script>
+<script>
+  var setLocale='<c:out value="${data._LOCALE_CODE}"/>' == 'ko_KR' ? 'ko' : '<c:out value="${data._LOCALE_CODE}"/>';
+  var alertText = {
+    title : '<spring:message code="common.alert.box.title" />',
+    btnOk : '<spring:message code="common.alert.box.ok" />',
+    btnYes : '<spring:message code="common.alert.box.yes" />',
+    btnCancel : '<spring:message code="common.alert.box.cancel" />',
+  }
+</script>
 </head>
 <body>
 </body>

+ 25 - 18
src/main/webapp/resources/js/mobile/common.js

@@ -253,8 +253,15 @@ $(document).ready(function(){
 });
 
 function alertBox( obj ) {
-    var type  = "alert";
-    var title = alertText.title;
+    var title = "";
+
+    if (typeof alertText == "undefined" ) {
+      title = obj.title;
+    } else {
+      title = alertText.title;
+    }
+
+    var type = "alert";
     var txt   = "";
     var callBack = function(){};
     
@@ -279,22 +286,22 @@ function alertBox( obj ) {
     }
     
     modal({
-        type: type,
-        title: title,
-        text: txt,
-        callback: function(result){
-            if( type == "confirm" ) {
-                if( result ) {
-                    callBack( result );
-                }
-            } else {
-                callBack();
-            }
-        },
-        buttonText: {
-            ok: alertText.btnOk,
-            yes: alertText.btnYes,
-            cancel: alertText.btnCancel
+      type: type,
+      title: title,
+      text: txt,
+      callback: function (result) {
+        if (type == "confirm") {
+          if (result) {
+            callBack(result);
+          }
+        } else {
+          callBack();
         }
+      },
+      buttonText: {
+        ok: typeof alertText == "undefined" ? "확인" : alertText.btnOk,
+        yes: typeof alertText == "undefined" ? "확인" : alertText.btnYes,
+        cancel: typeof alertText == "undefined" ? "취소" : alertText.btnCancel,
+      },
     });
 }