|
@@ -1,5 +1,10 @@
|
|
|
package com.lemon.lifecenter.controller;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileNotFoundException;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -7,6 +12,16 @@ import java.util.List;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
+import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
+import org.apache.poi.ss.usermodel.Font;
|
|
|
+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;
|
|
@@ -23,6 +38,7 @@ import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
import com.lemon.lifecenter.common.LifeCenterConfigVO;
|
|
|
import com.lemon.lifecenter.common.LifeCenterController;
|
|
|
+import com.lemon.lifecenter.common.LifeCenterFileDownload;
|
|
|
import com.lemon.lifecenter.common.LifeCenterFunction;
|
|
|
import com.lemon.lifecenter.common.LifeCenterPaging;
|
|
|
import com.lemon.lifecenter.common.LifeCenterSessionController;
|
|
@@ -31,6 +47,7 @@ import com.lemon.lifecenter.dto.PatientDTO;
|
|
|
import com.lemon.lifecenter.service.CenterService;
|
|
|
import com.lemon.lifecenter.service.PatientService;
|
|
|
|
|
|
+
|
|
|
@Controller
|
|
|
@RequestMapping("/patient")
|
|
|
//@DependsOn(value = {"LifeCenterPaging"})
|
|
@@ -49,9 +66,6 @@ public class PatientController extends LifeCenterController {
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
|
|
|
@RequestMapping("/list")
|
|
|
-// @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,
|
|
@@ -90,15 +104,10 @@ public class PatientController extends LifeCenterController {
|
|
|
|
|
|
ModelAndView mv = setMV("patient/list");
|
|
|
|
|
|
- System.out.println( "PatientController config.pageGroupSize : " + config.pageGroupSize );
|
|
|
-
|
|
|
String param = "patientName=" + patientName + "&inputState=" + inputState + "&startDate=" + startDate + "&endDate=" + endDate;
|
|
|
paging = LifeCenterPaging.getInstance();
|
|
|
paging.paging(config, total, page, param);
|
|
|
|
|
|
-// startDate = startDate.equals( "" ) ? LifeCenterFunction.getNow( "yyyy-MM-dd" ) : startDate;
|
|
|
-// endDate = endDate.equals( "" ) ? LifeCenterFunction.getNow( "yyyy-MM-dd" ) : endDate;
|
|
|
-
|
|
|
mv.addObject("inputState", inputState);
|
|
|
mv.addObject("patientName", patientName);
|
|
|
mv.addObject("total", total);
|
|
@@ -415,4 +424,243 @@ public class PatientController extends LifeCenterController {
|
|
|
return object.toString();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping( value="/excel", method=RequestMethod.POST )
|
|
|
+ public void getPatientList(
|
|
|
+ @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,
|
|
|
+ @RequestParam(value="page", required=false, defaultValue="1") int page,
|
|
|
+ HttpServletRequest request,HttpServletResponse response ) {
|
|
|
+
|
|
|
+ String sesCenterCode = LifeCenterSessionController.getSession(request, "sesCenterCode");
|
|
|
+ String sesGroupIdx = LifeCenterSessionController.getSession(request, "sesGroupIdx");
|
|
|
+
|
|
|
+ // 권한이 SYSTEM일경우
|
|
|
+
|
|
|
+ PatientDTO dto = new PatientDTO();
|
|
|
+
|
|
|
+ dto.setCenterCode(Integer.parseInt(sesCenterCode));
|
|
|
+ dto.setGroupIdx(Integer.valueOf(sesGroupIdx));
|
|
|
+ dto.setPatientName(patientName);
|
|
|
+ dto.setState(inputState);
|
|
|
+ dto.setStartDate(startDate);
|
|
|
+ dto.setEndDate(endDate);
|
|
|
+
|
|
|
+ int total = patientService.selectPatientCount(dto);
|
|
|
+ List<PatientDTO> result = new ArrayList<PatientDTO>();
|
|
|
+
|
|
|
+ if (total > 0) {
|
|
|
+ dto.setLimit( 1 );
|
|
|
+ dto.setLimitMax( total );
|
|
|
+
|
|
|
+ result = patientService.selectPatietList(dto);
|
|
|
+
|
|
|
+ for (PatientDTO temp : result) {
|
|
|
+ result.get(result.indexOf(temp)).setSymptomContent(LifeCenterFunction.getSymptom(temp));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ getPatientListExcel(request, response, result );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void getPatientListExcel(HttpServletRequest request, HttpServletResponse response, List<PatientDTO> data ) {
|
|
|
+ Workbook workbook = new XSSFWorkbook();
|
|
|
+ Sheet sheet1 = workbook.createSheet("firstSheet");
|
|
|
+ DecimalFormat df = new DecimalFormat("#,###");
|
|
|
+
|
|
|
+ //1.셀 스타일 및 폰트 설정
|
|
|
+ CellStyle styleOfBoardFillFontBlackBold16 = workbook.createCellStyle();
|
|
|
+ //정렬
|
|
|
+ styleOfBoardFillFontBlackBold16.setAlignment(CellStyle.ALIGN_CENTER); //가운데 정렬
|
|
|
+ styleOfBoardFillFontBlackBold16.setVerticalAlignment(CellStyle.VERTICAL_CENTER); //높이 가운데 정렬
|
|
|
+ //배경색
|
|
|
+ styleOfBoardFillFontBlackBold16.setFillForegroundColor(IndexedColors.LIGHT_YELLOW.getIndex());
|
|
|
+ styleOfBoardFillFontBlackBold16.setFillPattern(CellStyle.SOLID_FOREGROUND);
|
|
|
+ //테두리 선 (우,좌,위,아래)
|
|
|
+ styleOfBoardFillFontBlackBold16.setBorderRight(HSSFCellStyle.BORDER_THIN);
|
|
|
+ styleOfBoardFillFontBlackBold16.setBorderLeft(HSSFCellStyle.BORDER_THIN);
|
|
|
+ styleOfBoardFillFontBlackBold16.setBorderTop(HSSFCellStyle.BORDER_THIN);
|
|
|
+ styleOfBoardFillFontBlackBold16.setBorderBottom(HSSFCellStyle.BORDER_THIN);
|
|
|
+ //폰트 설정
|
|
|
+ Font fontOfGothicBlackBold16 = workbook.createFont();
|
|
|
+// fontOfGothicBlackBold16.setFontName("나눔고딕"); //글씨체
|
|
|
+ fontOfGothicBlackBold16.setFontHeight((short)(10*20)); //사이즈
|
|
|
+ fontOfGothicBlackBold16.setBoldweight(Font.BOLDWEIGHT_BOLD); //볼드 (굵게)
|
|
|
+ styleOfBoardFillFontBlackBold16.setFont(fontOfGothicBlackBold16);
|
|
|
+
|
|
|
+ int i = 1;
|
|
|
+ Row row = sheet1.createRow(0);
|
|
|
+ Cell cell1 = row.createCell(0);
|
|
|
+ Cell cell2 = row.createCell(1);
|
|
|
+ Cell cell3 = row.createCell(2);
|
|
|
+ Cell cell4 = row.createCell(3);
|
|
|
+ Cell cell5 = row.createCell(4);
|
|
|
+ Cell cell6 = row.createCell(5);
|
|
|
+ Cell cell7 = row.createCell(6);
|
|
|
+ Cell cell8 = row.createCell(7);
|
|
|
+ Cell cell9 = row.createCell(8);
|
|
|
+ Cell cell10 = row.createCell(9);
|
|
|
+ Cell cell11 = row.createCell(10);
|
|
|
+ Cell cell12 = row.createCell(11);
|
|
|
+ Cell cell13 = row.createCell(12);
|
|
|
+ Cell cell14 = row.createCell(13);
|
|
|
+
|
|
|
+ cell1.setCellStyle(styleOfBoardFillFontBlackBold16);
|
|
|
+ cell2.setCellStyle(styleOfBoardFillFontBlackBold16);
|
|
|
+ cell3.setCellStyle(styleOfBoardFillFontBlackBold16);
|
|
|
+ cell4.setCellStyle(styleOfBoardFillFontBlackBold16);
|
|
|
+ cell5.setCellStyle(styleOfBoardFillFontBlackBold16);
|
|
|
+ cell6.setCellStyle(styleOfBoardFillFontBlackBold16);
|
|
|
+ cell7.setCellStyle(styleOfBoardFillFontBlackBold16);
|
|
|
+ cell8.setCellStyle(styleOfBoardFillFontBlackBold16);
|
|
|
+ cell9.setCellStyle(styleOfBoardFillFontBlackBold16);
|
|
|
+ cell10.setCellStyle(styleOfBoardFillFontBlackBold16);
|
|
|
+ cell11.setCellStyle(styleOfBoardFillFontBlackBold16);
|
|
|
+ cell12.setCellStyle(styleOfBoardFillFontBlackBold16);
|
|
|
+ cell13.setCellStyle(styleOfBoardFillFontBlackBold16);
|
|
|
+ cell14.setCellStyle(styleOfBoardFillFontBlackBold16);
|
|
|
+
|
|
|
+
|
|
|
+ sheet1.setColumnWidth( 0, 5000); //센터명
|
|
|
+ sheet1.setColumnWidth( 1, 3000); //환자명
|
|
|
+ sheet1.setColumnWidth( 2, 4000); //동호실
|
|
|
+ sheet1.setColumnWidth( 3, 1500); //성별
|
|
|
+ sheet1.setColumnWidth( 4, 1500); //나이
|
|
|
+ sheet1.setColumnWidth( 5, 3500); //입소일자
|
|
|
+ sheet1.setColumnWidth( 6, 3500); //상태변경일
|
|
|
+ sheet1.setColumnWidth( 7, 3800); //상태
|
|
|
+ sheet1.setColumnWidth( 8, 6000); //체온
|
|
|
+ sheet1.setColumnWidth( 9, 10000); //혈압
|
|
|
+ sheet1.setColumnWidth( 10, 6200); //맥박
|
|
|
+ sheet1.setColumnWidth( 11, 6200); //산소포화도
|
|
|
+ sheet1.setColumnWidth( 12, 7000); //혈당
|
|
|
+ sheet1.setColumnWidth( 13, 14000); //임상증상
|
|
|
+
|
|
|
+
|
|
|
+ cell1.setCellValue("생활치료센터명");
|
|
|
+ cell2.setCellValue("환자명");
|
|
|
+ cell3.setCellValue("동,호실");
|
|
|
+ cell4.setCellValue("성별");
|
|
|
+ cell5.setCellValue("나이");
|
|
|
+ cell6.setCellValue("입소일자");
|
|
|
+ cell7.setCellValue("상태 변경일");
|
|
|
+ cell8.setCellValue("상태");
|
|
|
+ cell9.setCellValue("체온");
|
|
|
+ cell10.setCellValue("혈압");
|
|
|
+ cell11.setCellValue("맥박");
|
|
|
+ cell12.setCellValue("산소포화도");
|
|
|
+ cell13.setCellValue("혈당");
|
|
|
+ cell14.setCellValue("임상증상");
|
|
|
+
|
|
|
+ for (PatientDTO dto : data) {
|
|
|
+ row = sheet1.createRow(i);
|
|
|
+ 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);
|
|
|
+ cell9 = row.createCell(8);
|
|
|
+ cell10 = row.createCell(9);
|
|
|
+ cell11 = row.createCell(10);
|
|
|
+ cell12 = row.createCell(11);
|
|
|
+ cell13 = row.createCell(12);
|
|
|
+ cell14 = row.createCell(13);
|
|
|
+
|
|
|
+ String patientName = dto.getPatientName();
|
|
|
+ String roomWard = ( dto.getRoomNumber() == null || dto.getRoomNumber().equals( "" ) ) ? "" : dto.getRoomNumber()+"동 ";
|
|
|
+ roomWard += ( dto.getWardNumber() == null || dto.getWardNumber().equals( "" ) ) ? "" : dto.getWardNumber()+"호";
|
|
|
+
|
|
|
+ String gender = dto.getGender();
|
|
|
+ String age = dto.getAge();
|
|
|
+
|
|
|
+ String hospitalizationDate = dto.getHospitalizationDate();
|
|
|
+ String disisolationDate = dto.getDisisolationDate();
|
|
|
+ String state = dto.getState();
|
|
|
+
|
|
|
+ String temperature = dto.getTemperature();
|
|
|
+ String temperatureCreateDate = dto.getTemperatureCreateDate();
|
|
|
+
|
|
|
+ String systolicBloodPressure = dto.getSystolicBloodPressure();
|
|
|
+ String systolicBloodPressureCreateDate = dto.getSystolicBloodPressureCreateDate();
|
|
|
+
|
|
|
+ String diastolicBloodPressure = dto.getDiastolicBloodPressure();
|
|
|
+ String diastolicBloodPressureCreateDate = dto.getDiastolicBloodPressureCreateDate();
|
|
|
+
|
|
|
+ String pulseRate = dto.getPulseRate();
|
|
|
+ String pulseRateCreateDate = dto.getPulseRateCreateDate();
|
|
|
+
|
|
|
+ String oxygenSaturation = dto.getOxygenSaturation();
|
|
|
+ String oxygenSaturationCreateDate = dto.getOxygenSaturationCreateDate();
|
|
|
+
|
|
|
+ String bloodSugar = dto.getBloodSugar();
|
|
|
+ String bloodSugarCreateDate = dto.getBloodSugarCreateDate();
|
|
|
+
|
|
|
+ String notMeasured = "-";
|
|
|
+ String symptomDate = dto.getCreateDate();
|
|
|
+ String symptomContent = dto.getSymptomContent();
|
|
|
+// String symptom = LifeCenterFunction.getSymptom( dto );
|
|
|
+ String centerName = dto.getCenterName();
|
|
|
+
|
|
|
+ cell1.setCellValue( centerName );
|
|
|
+ cell2.setCellValue( patientName );
|
|
|
+ cell3.setCellValue( roomWard );
|
|
|
+ cell4.setCellValue( gender );
|
|
|
+ cell5.setCellValue( age );
|
|
|
+ cell6.setCellValue( hospitalizationDate );
|
|
|
+ cell7.setCellValue( disisolationDate );
|
|
|
+ cell8.setCellValue( state );
|
|
|
+ cell9.setCellValue( ( temperature == null || temperature.equals("") ) ? notMeasured : temperature + " ˚C (" + temperatureCreateDate + ")" );
|
|
|
+ cell10.setCellValue( ( systolicBloodPressure == null || systolicBloodPressure.equals("") ) ? notMeasured : systolicBloodPressure + " mmHg / " + diastolicBloodPressure + " mmHg (" + systolicBloodPressureCreateDate + ")" );
|
|
|
+ cell11.setCellValue( ( pulseRate == null || pulseRate.equals("") ) ? notMeasured : pulseRate + " bpm (" + pulseRateCreateDate + ")" );
|
|
|
+ cell12.setCellValue( ( oxygenSaturation == null || oxygenSaturation.equals("") ) ? notMeasured : oxygenSaturation + " % (" + oxygenSaturationCreateDate + ")" );
|
|
|
+ cell13.setCellValue( ( bloodSugar == null || bloodSugar.equals("") ) ? notMeasured : bloodSugar + " mg/dL (" + bloodSugarCreateDate + ")" );
|
|
|
+ cell14.setCellValue( ( symptomContent == null || symptomDate == null || symptomContent.equals("") || symptomDate.equals( "" ) ) ? notMeasured : symptomContent + " (" + symptomDate + ")" );
|
|
|
+
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+
|
|
|
+ row = sheet1.createRow(i);
|
|
|
+ cell1 = row.createCell(2);
|
|
|
+ cell2 = row.createCell(3);
|
|
|
+ cell3 = row.createCell(4);
|
|
|
+ cell4 = row.createCell(5);
|
|
|
+ cell5 = row.createCell(6);
|
|
|
+ cell6 = row.createCell(7);
|
|
|
+ cell7 = row.createCell(8);
|
|
|
+ cell8 = row.createCell(9);
|
|
|
+ cell9 = row.createCell(10);
|
|
|
+ cell10 = row.createCell(11);
|
|
|
+ cell11 = row.createCell(12);
|
|
|
+ cell12 = row.createCell(13);
|
|
|
+ cell13 = row.createCell(14);
|
|
|
+ cell14 = row.createCell(15);
|
|
|
+
|
|
|
+ try {
|
|
|
+ File file = new File(".");
|
|
|
+ String rootPath = file.getAbsolutePath();
|
|
|
+ System.out.println("현재 프로젝트의 경로 : "+rootPath );
|
|
|
+
|
|
|
+ String tempPath = "../excel-temp/testExcel.xlsx";
|
|
|
+ String downName = LifeCenterFunction.getNow() + " 환자리스트.xlsx";
|
|
|
+ File xlsFile = new File(tempPath);
|
|
|
+ FileOutputStream fileOut = new FileOutputStream(xlsFile);
|
|
|
+ workbook.write(fileOut);
|
|
|
+
|
|
|
+ LifeCenterFileDownload.download(request, response, tempPath, downName);
|
|
|
+
|
|
|
+ xlsFile.delete();
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|