PatientController.java 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355
  1. package com.lemon.lifecenter.controller;
  2. import java.io.ByteArrayInputStream;
  3. import java.io.ByteArrayOutputStream;
  4. import java.io.File;
  5. import java.io.FileNotFoundException;
  6. import java.io.FileOutputStream;
  7. import java.io.IOException;
  8. import java.io.InputStream;
  9. import java.io.UnsupportedEncodingException;
  10. import java.lang.reflect.Field;
  11. import java.net.URLEncoder;
  12. import java.nio.charset.StandardCharsets;
  13. import java.security.GeneralSecurityException;
  14. import java.text.DecimalFormat;
  15. import java.util.ArrayList;
  16. import java.util.Base64;
  17. import java.util.HashMap;
  18. import java.util.List;
  19. import javax.servlet.http.HttpServletRequest;
  20. import javax.servlet.http.HttpServletResponse;
  21. import com.lemon.lifecenter.common.LifeCenterConfigVO;
  22. import com.lemon.lifecenter.common.LifeCenterController;
  23. import com.lemon.lifecenter.common.LifeCenterFileDownload;
  24. import com.lemon.lifecenter.common.LifeCenterFunction;
  25. import com.lemon.lifecenter.common.LifeCenterPaging;
  26. import com.lemon.lifecenter.common.LifeCenterSessionController;
  27. import com.lemon.lifecenter.dto.CenterInfoDTO;
  28. import com.lemon.lifecenter.dto.FileDownloadDTO;
  29. import com.lemon.lifecenter.dto.PatientDTO;
  30. import com.lemon.lifecenter.dto.PrivateLogDTO;
  31. import com.lemon.lifecenter.dto.PushDTO;
  32. import com.lemon.lifecenter.dto.StaffDTO;
  33. import com.lemon.lifecenter.service.CenterService;
  34. import com.lemon.lifecenter.service.FileDownloadService;
  35. import com.lemon.lifecenter.service.PatientService;
  36. import com.lemon.lifecenter.service.PrivateLogService;
  37. import com.lemon.lifecenter.service.PushService;
  38. import com.lemon.lifecenter.service.StaffService;
  39. import org.apache.poi.hssf.usermodel.HSSFCellStyle;
  40. import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
  41. import org.apache.poi.openxml4j.opc.OPCPackage;
  42. import org.apache.poi.poifs.crypt.EncryptionInfo;
  43. import org.apache.poi.poifs.crypt.EncryptionMode;
  44. import org.apache.poi.poifs.crypt.Encryptor;
  45. import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  46. import org.apache.poi.ss.usermodel.Cell;
  47. import org.apache.poi.ss.usermodel.CellStyle;
  48. import org.apache.poi.ss.usermodel.Font;
  49. import org.apache.poi.ss.usermodel.IndexedColors;
  50. import org.apache.poi.ss.usermodel.Row;
  51. import org.apache.poi.ss.usermodel.Sheet;
  52. import org.apache.poi.ss.usermodel.Workbook;
  53. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  54. import org.json.JSONObject;
  55. import org.slf4j.Logger;
  56. import org.slf4j.LoggerFactory;
  57. import org.springframework.beans.factory.annotation.Autowired;
  58. import org.springframework.stereotype.Controller;
  59. import org.springframework.transaction.annotation.Propagation;
  60. import org.springframework.transaction.annotation.Transactional;
  61. import org.springframework.web.bind.annotation.ModelAttribute;
  62. import org.springframework.web.bind.annotation.RequestMapping;
  63. import org.springframework.web.bind.annotation.RequestMethod;
  64. import org.springframework.web.bind.annotation.RequestParam;
  65. import org.springframework.web.bind.annotation.ResponseBody;
  66. import org.springframework.web.servlet.ModelAndView;
  67. @Controller
  68. @RequestMapping("/patient")
  69. //@DependsOn(value = {"LifeCenterPaging"})
  70. public class PatientController extends LifeCenterController {
  71. @Autowired
  72. private PatientService patientService;
  73. @Autowired
  74. private CenterService centerService;
  75. @Autowired
  76. private StaffService staffService;
  77. @Autowired
  78. private FileDownloadService fileDownloadService;
  79. @Autowired
  80. private PushService pushService;
  81. @Autowired
  82. private LifeCenterConfigVO config;
  83. @Autowired
  84. private PrivateLogService privateLogService;
  85. private LifeCenterPaging paging;
  86. private final Logger logger = LoggerFactory.getLogger(this.getClass());
  87. @RequestMapping("/list")
  88. public ModelAndView patientList(
  89. @RequestParam(value="inputState", required=false, defaultValue="ALL") String inputState,
  90. @RequestParam(value="patientName", required=false, defaultValue="") String patientName,
  91. @RequestParam(value="startDate", required=false, defaultValue="") String startDate,
  92. @RequestParam(value="endDate", required=false, defaultValue="") String endDate,
  93. @RequestParam(value="page", required=false, defaultValue="1") int page,
  94. @RequestParam(value="sortType", required=false, defaultValue="patient_name") String sortType,
  95. @RequestParam(value="sort", required=false, defaultValue="desc") String sort,
  96. @RequestParam(value="cla", required=false, defaultValue="") String cla,
  97. @RequestParam(value="dateType", required=false, defaultValue="") String dateType,
  98. HttpServletRequest request,HttpServletResponse response) {
  99. String sesId = LifeCenterSessionController.getSession( request, "sesId" );
  100. String sesCenterCode = LifeCenterSessionController.getSession( request, "sesCenterCode" );
  101. String sesGroupIdx = LifeCenterSessionController.getSession( request, "sesGroupIdx" );
  102. String sesName = LifeCenterSessionController.getSession( request, "sesName" );
  103. String sesCenterName = LifeCenterSessionController.getSession( request, "sesCenterName" );
  104. String logCenterName = !sesCenterName.equals( "" )? "["+sesCenterName+"] " : "";
  105. String processingContents = "환자리스트 조회";
  106. PrivateLogDTO logDTO = new PrivateLogDTO();
  107. logDTO.setId( sesId );
  108. logDTO.setAccessorDetail( logCenterName + sesName + " (" + sesId + ")" );
  109. logDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) );
  110. logDTO.setFullUrl( LifeCenterFunction.getFullURL( request ) );
  111. logDTO.setProcessingTarget( "" );
  112. logDTO.setProcessingContents( processingContents );
  113. // privateLogService.insertPrivateAccessLog( logDTO );
  114. PatientDTO dto = new PatientDTO();
  115. dto.setCenterCode(Integer.parseInt(sesCenterCode));
  116. dto.setGroupIdx( Integer.valueOf( sesGroupIdx ) );
  117. dto.setPatientName(patientName);
  118. dto.setState(inputState);
  119. dto.setStartDate(startDate);
  120. dto.setEndDate(endDate);
  121. dto.setSortType(sortType);
  122. dto.setSort(sort);
  123. dto.setLimit( ( Integer.valueOf( page ) - 1 ) * config.pageDataSize );
  124. dto.setLimitMax( config.pageDataSize );
  125. dto.setCla(cla);
  126. dto.setDateType(dateType);
  127. int total = patientService.selectPatientCount(dto);
  128. List<PatientDTO> result = new ArrayList<PatientDTO>();
  129. if (total > 0) {
  130. result = patientService.selectPatientList(dto);
  131. for( PatientDTO temp : result ) {
  132. // logger.error("temp -- > " + result.get( result.indexOf( temp ) ).getJumin());
  133. // String age = result.get( result.indexOf( temp ) ).getJumin();
  134. // try {
  135. // age = String.valueOf(LifeCenterFunction.getAgeFromBirthday(age));
  136. // } catch (ParseException e) {
  137. // // TODO Auto-generated catch block
  138. // e.printStackTrace();
  139. // }
  140. // result.get( result.indexOf( temp ) ).setAge(age);
  141. result.get( result.indexOf( temp ) ).setSymptomContent( LifeCenterFunction.getSymptom( temp ) );
  142. }
  143. }
  144. ModelAndView mv = setMV("patient/list");
  145. String param = "";
  146. try {
  147. param = "patientName=" + URLEncoder.encode(patientName, "UTF-8") + "&inputState=" + inputState + "&startDate=" + startDate + "&endDate=" + endDate + "&sortType=" + sortType + "&sort=" + sort + "&cla=" + cla + "&dateType=" + dateType;
  148. } catch (UnsupportedEncodingException e) {
  149. // TODO Auto-generated catch block
  150. e.printStackTrace();
  151. }
  152. paging = LifeCenterPaging.getInstance();
  153. paging.paging(config, total, page, param);
  154. CenterInfoDTO cDTO = new CenterInfoDTO();
  155. List<CenterInfoDTO> centerListAll = new ArrayList<CenterInfoDTO>();
  156. centerListAll = centerService.selectCenterListAllYn(cDTO);
  157. mv.addObject("inputState", inputState);
  158. mv.addObject("patientName", patientName);
  159. mv.addObject("total", total);
  160. mv.addObject("item", result);
  161. mv.addObject("paging", paging);
  162. mv.addObject( "startDate", startDate );
  163. mv.addObject( "endDate", endDate );
  164. mv.addObject( "page", page );
  165. mv.addObject( "pageSize", dto.getLimitMax() );
  166. mv.addObject( "sesGroupIdx" , sesGroupIdx );
  167. mv.addObject("sort", sort);
  168. mv.addObject("sortType", sortType);
  169. mv.addObject("centerListAll", centerListAll);
  170. mv.addObject("selectCode", cla);
  171. mv.addObject("dateType", dateType);
  172. return mv;
  173. }
  174. @RequestMapping("/new")
  175. public ModelAndView patientNew( HttpServletRequest request,HttpServletResponse response ) {
  176. ModelAndView mv = setMV("patient/new");
  177. String sesCenterCode = LifeCenterSessionController.getSession( request, "sesCenterCode" );
  178. String sesId = LifeCenterSessionController.getSession( request, "sesId" );
  179. String sesName = LifeCenterSessionController.getSession( request, "sesName" );
  180. String sesCenterName = LifeCenterSessionController.getSession( request, "sesCenterName" );
  181. String logCenterName = !sesCenterName.equals( "" )? "["+sesCenterName+"] " : "";
  182. //개인정보로그
  183. String processingContents = "신규환자등록페이지 접속";
  184. PrivateLogDTO logDTO = new PrivateLogDTO();
  185. logDTO.setId( sesId );
  186. logDTO.setAccessorDetail( logCenterName + sesName + " (" + sesId + ")" );
  187. logDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) );
  188. logDTO.setFullUrl( LifeCenterFunction.getFullURL( request ) );
  189. logDTO.setProcessingTarget( "" );
  190. logDTO.setProcessingContents( processingContents );
  191. // privateLogService.insertPrivateAccessLog( logDTO );
  192. // 세션의 센터코드 들고와서 치료센터명 조회후 view 전달
  193. CenterInfoDTO dto = new CenterInfoDTO();
  194. dto.setCenterCode( Integer.valueOf( sesCenterCode ) );
  195. dto.setStaffId( sesId );
  196. int centerCount = centerService.selectCenterOneCount( dto );
  197. String centerName = "";
  198. if( centerCount > 0 ) {
  199. centerName = centerService.selectCenterInfoOne( dto ).getCenterName();
  200. }
  201. StaffDTO staffDTO = new StaffDTO();
  202. List<StaffDTO> staffList = new ArrayList<StaffDTO>();
  203. staffDTO.setGroupIdx( 2 ); //2설정 set 조회시 해당센터 모든 의료진 리스트표출
  204. staffDTO.setCenterCode( Integer.valueOf( sesCenterCode ) );
  205. staffDTO.setUseYn( "" );
  206. int staffCount = staffService.selectMemberListCount( staffDTO );
  207. if( staffCount > 0 ) {
  208. staffDTO.setLimit( 0 );
  209. staffDTO.setLimitMax( staffCount );
  210. staffList = staffService.selectMemberList( staffDTO );
  211. }
  212. mv.addObject( "centerName", centerName );
  213. mv.addObject( "centerCount", centerCount );
  214. mv.addObject( "actionType", "new" );
  215. mv.addObject( "staffList", staffList );
  216. return mv;
  217. }
  218. @RequestMapping("/new/insert")
  219. @Transactional(propagation=Propagation.REQUIRED)
  220. public String patientNewInsert(
  221. @ModelAttribute("dto") final PatientDTO dto,
  222. HttpServletRequest request,HttpServletResponse response ) throws Exception {
  223. int sesCenterCode = Integer.valueOf( LifeCenterSessionController.getSession( request, "sesCenterCode" ) ) ;
  224. String sesId = LifeCenterSessionController.getSession( request, "sesId" );
  225. String sesName = LifeCenterSessionController.getSession( request, "sesName" );
  226. String sesCenterName = LifeCenterSessionController.getSession( request, "sesCenterName" );
  227. String logCenterName = !sesCenterName.equals( "" )? "["+sesCenterName+"] " : "";
  228. //patientCare Insert
  229. //System.out.println( "dto.getJumin().substring(2) : " + dto.getJumin().replace( "-" , "" ).substring(2) );
  230. String jumin = dto.getJumin();
  231. jumin = LifeCenterFunction.removeStringChar(jumin, "-");
  232. dto.setJumin( jumin );
  233. dto.setId( dto.getWardNumber().trim() + dto.getRoomNumber().trim() );
  234. // 환자 password는 생년월일(yyyymmdd)을 암호화
  235. // dto.setPw( LifeCenterFunction.aesEncrypt( config.aesKey, config.IV, jumin ) );
  236. // dto.setPw( LifeCenterFunction.sha256Encrypt( jumin ) );
  237. dto.setPw(jumin);
  238. dto.setCenterCode( sesCenterCode );
  239. dto.setState( "H" ); // H : 입소
  240. dto.setCreateBy( sesId );
  241. if( dto.getDisisolationDate() != null && dto.getDisisolationDate().equals( "" ) ) {
  242. dto.setDisisolationDate( null );
  243. }
  244. if( dto.getSymptomStartDate() != null && dto.getSymptomStartDate().equals( "" ) ) {
  245. dto.setSymptomStartDate( null );
  246. }
  247. if (dto.getExpectedDischargeDate() != null && dto.getExpectedDischargeDate().equals("")) {
  248. dto.setExpectedDischargeDate(null);
  249. }
  250. // base64 decode 주민뒷자리
  251. if (!dto.getResidentNumberLast().equals("")) {
  252. byte[] decoded = Base64.getDecoder().decode(dto.getResidentNumberLast());
  253. dto.setResidentNumberLast(new String(decoded, StandardCharsets.UTF_8));
  254. }
  255. // base64 decode 외국인등록번호 뒷자리
  256. if (!dto.getForeignNumberLast().equals("")) {
  257. byte[] decoded = Base64.getDecoder().decode(dto.getForeignNumberLast());
  258. dto.setForeignNumberLast(new String(decoded, StandardCharsets.UTF_8));
  259. }
  260. // base64 decode 여권번호
  261. if (!dto.getPassportNumber().equals("")) {
  262. byte[] decoded = Base64.getDecoder().decode(dto.getPassportNumber());
  263. dto.setPassportNumber(new String(decoded, StandardCharsets.UTF_8));
  264. }
  265. patientService.insertPatientCare( dto ); // 환지 기본정보 insert
  266. int patientIdx = dto.getPatientIdx();
  267. //개인정보로그
  268. String processingContents = "신규환자 생성";
  269. PrivateLogDTO logDTO = new PrivateLogDTO();
  270. logDTO.setId( sesId );
  271. logDTO.setAccessorDetail( logCenterName + sesName + " (" + sesId + ")" );
  272. logDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) );
  273. logDTO.setFullUrl( LifeCenterFunction.getFullURL( request ) );
  274. logDTO.setProcessingTarget( "(환자)" + dto.getPatientName() + "["+dto.getPatientIdx()+"]" );
  275. logDTO.setProcessingContents( processingContents );
  276. // privateLogService.insertPrivateAccessLog( logDTO );
  277. dto.setPatientIdx( patientIdx );
  278. //patientDisease Insert
  279. dto.setEtcCheck( dto.getEtcCheckDisease() );
  280. dto.setEtcContent( dto.getEtcContentDisease() );
  281. patientService.insertPatientDisease( dto );
  282. //patientSymptom Insert
  283. dto.setEtcCheck( dto.getEtcCheckSymptom() );
  284. dto.setEtcContent( dto.getEtcContentSymptom() );
  285. dto.setBloodPressureLevel( dto.getBloodPressureLevelCon() + "|" + dto.getBloodPressureLevelRel() );
  286. //
  287. patientService.insertPatientSymptom( dto );
  288. return "redirect:/patient/info?patientIdx=" + patientIdx;
  289. }
  290. @RequestMapping("/info")
  291. public ModelAndView patientInfo( @ModelAttribute("dto") PatientDTO dto,
  292. HttpServletRequest request,HttpServletResponse response ) throws Exception {
  293. String referer = request.getHeader("referer");
  294. ModelAndView mv = setMV("patient/info");
  295. int patientIdx = dto.getPatientIdx();
  296. String sesId = LifeCenterSessionController.getSession( request, "sesId" );
  297. String sesName = LifeCenterSessionController.getSession( request, "sesName" );
  298. String sesCenterName = LifeCenterSessionController.getSession( request, "sesCenterName" );
  299. String logCenterName = !sesCenterName.equals( "" )? "["+sesCenterName+"] " : "";
  300. dto = patientService.selectPatientOne(dto);
  301. //개인정보로그
  302. String processingContents = "환자상세 조회 ";
  303. PrivateLogDTO logDTO = new PrivateLogDTO();
  304. logDTO.setId( sesId );
  305. logDTO.setAccessorDetail( logCenterName + sesName + " (" + sesId + ")" );
  306. logDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) );
  307. logDTO.setFullUrl( LifeCenterFunction.getFullURL( request ) );
  308. logDTO.setProcessingTarget( "(환자)" + dto.getPatientName() + "["+dto.getPatientIdx()+"]" );
  309. logDTO.setProcessingContents( processingContents );
  310. // privateLogService.insertPrivateAccessLog( logDTO );
  311. String jumin = dto.getJumin();
  312. jumin = LifeCenterFunction.changeJuminToBirthday(jumin);
  313. dto.setJumin(jumin);
  314. dto.setPatientPhone(LifeCenterFunction.phone(dto.getPatientPhone()));
  315. dto.setGuardianPhone(LifeCenterFunction.phone(dto.getGuardianPhone()));
  316. String bloodPress = dto.getBloodPressureLevel();
  317. try {
  318. if (!bloodPress.equals("") && !bloodPress.equals("|")) {
  319. String[] bloodPressureLevel = bloodPress.split("[|]");
  320. if (bloodPressureLevel[0] != null) {
  321. dto.setBloodPressureLevelCon(bloodPressureLevel[0]);
  322. }
  323. if (bloodPressureLevel[1] != null) {
  324. dto.setBloodPressureLevelRel(bloodPressureLevel[1]);
  325. }
  326. }
  327. } catch (Exception e) {
  328. //TODO: handle exception
  329. dto.setBloodPressureLevelCon("0");
  330. dto.setBloodPressureLevelRel("0");
  331. }
  332. String strDisease = "";
  333. String strSymptom = LifeCenterFunction.getSymptom(dto);
  334. if (dto.getBasalDiseaseYn().equals("Y")) {
  335. strDisease = LifeCenterFunction.getDisease(dto);
  336. }
  337. StaffDTO staffDTO = new StaffDTO();
  338. List<StaffDTO> staffList = new ArrayList<StaffDTO>();
  339. staffDTO.setGroupIdx( 2 ); //2설정 set 조회시 해당센터 모든 의료진 리스트표출
  340. staffDTO.setCenterCode( Integer.valueOf( dto.getCenterCode() ) );
  341. staffDTO.setUseYn( "" );
  342. int staffCount = staffService.selectMemberListCount( staffDTO );
  343. if( staffCount > 0 ) {
  344. staffDTO.setLimit( 0 );
  345. staffDTO.setLimitMax( staffCount );
  346. staffList = staffService.selectMemberList( staffDTO );
  347. }
  348. CenterInfoDTO cdto = new CenterInfoDTO();
  349. List<CenterInfoDTO> centerListAll = centerService.selectCenterListAll( cdto );
  350. mv.addObject( "disease", strDisease );
  351. mv.addObject( "symptom", strSymptom );
  352. mv.addObject( "patientIdx", patientIdx );
  353. mv.addObject( "enIdx", LifeCenterFunction.aesEncrypt( config.aesKey, config.IV, String.valueOf( patientIdx ) ) );
  354. mv.addObject( "info", dto );
  355. mv.addObject( "staffList", staffList );
  356. mv.addObject( "referer", referer );
  357. mv.addObject( "centerListAll", centerListAll );
  358. return mv;
  359. }
  360. @RequestMapping( value="/changeCenterInfo", method=RequestMethod.POST )
  361. @Transactional(propagation=Propagation.REQUIRED)
  362. public String changeCenterInfo(
  363. @RequestParam(value="oldCenterCode", required=true ) int oldCenterCode,
  364. @RequestParam(value="newCenterCode", required=true ) int newCenterCode,
  365. @RequestParam(value="oldCenterName", required=true ) String oldCenterName,
  366. @RequestParam(value="newCenterName", required=true ) String newCenterName,
  367. @RequestParam(value="patientIdx", required=true ) int patientIdx,
  368. @RequestParam(value="patientName", required=true ) String patientName,
  369. HttpServletRequest request,HttpServletResponse response ) {
  370. String sesId = LifeCenterSessionController.getSession( request, "sesId" );
  371. String comment = patientName+"[patient_idx:"+13+"] - " + oldCenterName + "[center_code:"+oldCenterCode+"] => " + newCenterName + "[center_code:"+newCenterCode+"]";
  372. PatientDTO dto = new PatientDTO();
  373. dto.setOldCenterCode( oldCenterCode );
  374. dto.setNewCenterCode( newCenterCode );
  375. dto.setPatientIdx( patientIdx );
  376. dto.setUpdateBy( sesId );
  377. dto.setComment( comment );
  378. // System.err.println( "comment : " + comment );
  379. patientService.updatePatientCenterInfo(dto);
  380. patientService.insertCenterChangeLog(dto);
  381. return "redirect:/patient/list";
  382. }
  383. @RequestMapping("/delete")
  384. @Transactional(propagation=Propagation.REQUIRED)
  385. public String patientDelete( @RequestParam( value="enIdx", required = true ) String enIdx,
  386. @RequestParam( value="deleteReason", required = false, defaultValue = "" ) String deleteReason,
  387. HttpServletRequest request,HttpServletResponse response ) throws Exception {
  388. String deIdx = LifeCenterFunction.aesDecrypt( config.aesKey, config.IV, enIdx );
  389. int patientIdx = Integer.valueOf( deIdx );
  390. PatientDTO dto = new PatientDTO();
  391. dto.setPatientIdx( patientIdx );
  392. // System.err.println( "patientIdx : " + patientIdx );
  393. int total = patientService.selectPatientOneCount(dto);
  394. if( total == 0 ) {
  395. LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '이미 삭제되었거나 존재하지않는 환자입니다.', callBack : function(){ history.back(); } });" );
  396. return "/common/blank";
  397. } else {
  398. // patientService.deletePatientCare(dto);
  399. // 환자데이터를 삭제하지않고 flag 값을 변경 (21.04.12 수정)
  400. PatientDTO patientOne = patientService.selectPatientOne(dto);
  401. dto.setUseYn( "N" );
  402. dto.setDeleteReason( deleteReason );
  403. patientService.updatePatientCareUseYn(dto);
  404. String sesId = LifeCenterSessionController.getSession( request, "sesId" );
  405. String sesName = LifeCenterSessionController.getSession( request, "sesName" );
  406. String sesCenterName = LifeCenterSessionController.getSession( request, "sesCenterName" );
  407. String logCenterName = !sesCenterName.equals( "" )? "["+sesCenterName+"] " : "";
  408. String processingContents = "환자삭제 [사유:"+deleteReason+"]";
  409. PrivateLogDTO logDTO = new PrivateLogDTO();
  410. logDTO.setId( sesId );
  411. logDTO.setAccessorDetail( logCenterName + sesName + " (" + sesId + ")" );
  412. logDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) );
  413. logDTO.setFullUrl( LifeCenterFunction.getFullURL( request ) );
  414. logDTO.setProcessingTarget( "(환자)" + patientOne.getPatientName() + "["+patientOne.getPatientIdx()+"]" );
  415. logDTO.setProcessingContents( processingContents );
  416. // privateLogService.insertPrivateAccessLog( logDTO );
  417. }
  418. LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '환자정보가 삭제되었습니다. ', callBack : function(){ location.href='./list'; } });" );
  419. return "/common/blank";
  420. }
  421. @RequestMapping("/edit")
  422. public ModelAndView patientEdit(
  423. @ModelAttribute("dto") PatientDTO patientDTO,
  424. HttpServletRequest request,HttpServletResponse response ) {
  425. ModelAndView mv = setMV("patient/edit");
  426. String sesCenterCode = LifeCenterSessionController.getSession( request, "sesCenterCode" );
  427. String sesId = LifeCenterSessionController.getSession( request, "sesId" );
  428. int patientIdx = patientDTO.getPatientIdx();
  429. int cnt = patientService.selectPatientOneCount(patientDTO);
  430. if (cnt > 0) {
  431. patientDTO = patientService.selectPatientOne( patientDTO );
  432. String sesName = LifeCenterSessionController.getSession( request, "sesName" );
  433. String sesCenterName = LifeCenterSessionController.getSession( request, "sesCenterName" );
  434. String logCenterName = !sesCenterName.equals( "" )? "["+sesCenterName+"] " : "";
  435. String processingContents = "환자수정페이지 접속";
  436. PrivateLogDTO logDTO = new PrivateLogDTO();
  437. logDTO.setId( sesId );
  438. logDTO.setAccessorDetail( logCenterName + sesName + " (" + sesId + ")" );
  439. logDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) );
  440. logDTO.setFullUrl( LifeCenterFunction.getFullURL( request ) );
  441. logDTO.setProcessingTarget( "(환자)" + patientDTO.getPatientName() + "["+patientDTO.getPatientIdx()+"]" );
  442. logDTO.setProcessingContents( processingContents );
  443. // privateLogService.insertPrivateAccessLog( logDTO );
  444. // 세션의 센터코드 들고와서 치료센터명 조회후 view 전달
  445. // 센터가 존재하는지 체크
  446. CenterInfoDTO dto = new CenterInfoDTO();
  447. dto.setCenterCode( Integer.valueOf( sesCenterCode ) );
  448. dto.setStaffId( sesId );
  449. String centerName = "";
  450. int centerCount = centerService.selectCenterCount( dto );
  451. if( sesCenterCode.equals( "0" ) ) { //센터코드가 없는 시스템권한 계정인경우
  452. centerName = patientDTO.getCenterName();
  453. } else {
  454. if( centerCount > 0 ) {
  455. centerName = centerService.selectCenterInfoOne( dto ).getCenterName();
  456. } else {
  457. LifeCenterFunction.scriptMessage(response, "alertBox({ txt : '문진이 정상적으로 제출되었습니다.', callBack : function(){ history.back(); } });" );
  458. // return ""; 아직처리안함
  459. }
  460. }
  461. String bloodPress = patientDTO.getBloodPressureLevel();
  462. try {
  463. if (!bloodPress.equals("") && !bloodPress.equals("|")) {
  464. String[] bloodPressureLevel = bloodPress.split("[|]");
  465. if (bloodPressureLevel[0] != null) {
  466. patientDTO.setBloodPressureLevelCon(bloodPressureLevel[0]);
  467. }
  468. if (bloodPressureLevel[1] != null) {
  469. patientDTO.setBloodPressureLevelRel(bloodPressureLevel[1]);
  470. }
  471. }
  472. } catch (Exception e) {
  473. // TODO: handle exception
  474. patientDTO.setBloodPressureLevelCon("0");
  475. patientDTO.setBloodPressureLevelRel("0");
  476. }
  477. StaffDTO staffDTO = new StaffDTO();
  478. List<StaffDTO> staffList = new ArrayList<StaffDTO>();
  479. staffDTO.setGroupIdx( 2 ); //2설정 set 조회시 해당센터 모든 의료진 리스트표출
  480. staffDTO.setCenterCode( Integer.valueOf( sesCenterCode ) );
  481. staffDTO.setUseYn( "" );
  482. int staffCount = staffService.selectMemberListCount( staffDTO );
  483. if( staffCount > 0 ) {
  484. staffDTO.setLimit( 0 );
  485. staffDTO.setLimitMax( staffCount );
  486. staffList = staffService.selectMemberList( staffDTO );
  487. }
  488. mv.addObject( "centerName", centerName );
  489. mv.addObject( "centerCount", centerCount );
  490. mv.addObject( "staffList", staffList );
  491. mv.addObject( "patientIdx", patientIdx );
  492. mv.addObject( "patientData", patientDTO );
  493. mv.addObject( "actionType", "edit" );
  494. } else {
  495. mv.addObject( "error", "error" );
  496. mv.addObject( "message", "삭제되었거나 존재하지 않는 환자입니다." );
  497. }
  498. return mv;
  499. }
  500. @RequestMapping("/edit/update")
  501. @Transactional(propagation=Propagation.REQUIRED)
  502. public String patientEditUpdate(
  503. @ModelAttribute("dto") PatientDTO dto,
  504. HttpServletRequest request,HttpServletResponse response ) throws Exception {
  505. int sesCenterCode = Integer.valueOf( LifeCenterSessionController.getSession( request, "sesCenterCode" ) ) ;
  506. String sesId = LifeCenterSessionController.getSession( request, "sesId" );
  507. int patientIdx = dto.getPatientIdx();
  508. dto.setPatientIdx( patientIdx );
  509. PatientDTO originPatientData = patientService.selectPatientOne( dto );
  510. //patientCare Update
  511. String jumin = dto.getJumin();
  512. jumin = LifeCenterFunction.removeStringChar(jumin, "-");
  513. dto.setJumin( jumin );
  514. dto.setId( dto.getWardNumber().trim() + dto.getRoomNumber().trim() );
  515. // dto.setPw( LifeCenterFunction.sha256Encrypt( jumin ) );
  516. dto.setPw(jumin);
  517. dto.setCenterCode( sesCenterCode );
  518. dto.setUpdateBy( sesId );
  519. if( dto.getDisisolationDate() != null && dto.getDisisolationDate().equals( "" ) ) {
  520. dto.setDisisolationDate( null );
  521. }
  522. if( dto.getSymptomStartDate() != null && dto.getSymptomStartDate().equals( "" ) ) {
  523. dto.setSymptomStartDate( null );
  524. }
  525. logger.error("getPw -- > " + dto.getPw());
  526. patientService.updatePatientCare( dto ); // 환지 기본정보
  527. //patientDisease Insert
  528. dto.setEtcCheck( dto.getEtcCheckDisease() );
  529. dto.setEtcContent( dto.getEtcContentDisease() );
  530. patientService.updatePatientDisease( dto );
  531. //patientSymptom Insert
  532. dto.setEtcCheck( dto.getEtcCheckSymptom() );
  533. dto.setEtcContent( dto.getEtcContentSymptom() );
  534. dto.setBloodPressureLevel( dto.getBloodPressureLevelCon() + "|" + dto.getBloodPressureLevelRel() );
  535. // System.err.println( dto.toString() );
  536. patientService.updatePatientSymptom( dto );
  537. dto = new PatientDTO();
  538. dto.setPatientIdx( patientIdx );
  539. PatientDTO newPatientData = patientService.selectPatientOne( dto );
  540. String sesName = LifeCenterSessionController.getSession( request, "sesName" );
  541. String sesCenterName = LifeCenterSessionController.getSession( request, "sesCenterName" );
  542. String logCenterName = !sesCenterName.equals( "" )? "["+sesCenterName+"] " : "";
  543. String processingDetail = "[수정내역 :";
  544. PrivateLogDTO logDTO = new PrivateLogDTO();
  545. int cnt = 0;
  546. try{
  547. Object objNew=newPatientData;
  548. for (Field field : objNew.getClass().getDeclaredFields()){
  549. Object objOrigin=originPatientData;
  550. for (Field field1 : objOrigin.getClass().getDeclaredFields()){
  551. if( field1.getName().equals( field.getName() ) ) {
  552. field1.setAccessible(true);
  553. Object valueOrigin = field1.get(objOrigin);
  554. String originVal = valueOrigin == null ? "": valueOrigin.toString();
  555. field.setAccessible(true);
  556. Object valueNew=field.get(objNew);
  557. String newVal = valueNew == null ? "": valueNew.toString();
  558. // System.err.println(field.getName()+","+originVal + " -> " + newVal);
  559. if( !originVal.equals( newVal ) ) {
  560. // System.out.println(field.getName()+","+originVal + " -> " + newVal);
  561. String nv = cnt >= 1 ? ", " : " ";
  562. processingDetail += nv + field.getName()+"컬럼 값 변경 ("+originVal + " -> " + newVal +")";
  563. cnt ++;
  564. }
  565. }
  566. }
  567. }
  568. processingDetail +="]";
  569. }catch (Exception e){
  570. e.printStackTrace();
  571. }
  572. String processingContents = "환자정보 수정 [총 " + cnt + "건 항목] " + processingDetail;
  573. //System.err.println( "processingContents : " + processingContents );
  574. logDTO.setId( sesId );
  575. logDTO.setAccessorDetail( logCenterName + sesName + " (" + sesId + ")" );
  576. logDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) );
  577. logDTO.setFullUrl( LifeCenterFunction.getFullURL( request ) );
  578. logDTO.setProcessingTarget( "(환자)" + originPatientData.getPatientName() + "["+originPatientData.getPatientIdx()+"]" );
  579. logDTO.setProcessingContents( processingContents );
  580. // privateLogService.insertPrivateAccessLog( logDTO );
  581. return "redirect:/patient/info?patientIdx=" + patientIdx;
  582. }
  583. @RequestMapping("/privacy")
  584. public ModelAndView patientPrivacy() {
  585. ModelAndView mv = setMV("patient/privacy");
  586. return mv;
  587. }
  588. @RequestMapping( value="/nonFaceStart", method = RequestMethod.POST )
  589. @ResponseBody
  590. public String nonFaceStart(
  591. @RequestParam( value="pId", required = true ) String pId,
  592. @RequestParam( value="patientIdx", required = true ) String patientIdx,
  593. @RequestParam( value="roomId", required = true ) String roomId,
  594. @RequestParam( value="pName", required = true ) String pName,
  595. HttpServletRequest request, HttpServletResponse response) throws Exception {
  596. String salt = LifeCenterFunction.getSalt();
  597. String timeStamp = LifeCenterFunction.getTimestamp();
  598. String signature = LifeCenterFunction.getSignature(config.nonFaceApiSecret, salt, timeStamp);
  599. String userId = LifeCenterSessionController.getSession(request, "sesId");
  600. String userNm = LifeCenterSessionController.getSession(request, "sesName");
  601. HashMap<String, String> data = new HashMap<String, String>();
  602. data.put("api_key", config.nonFaceApiKey);
  603. data.put("salt", salt);
  604. data.put("timestamp", timeStamp);
  605. data.put("signature", signature);
  606. data.put("client_id", config.nonFaceClientId);
  607. data.put("member_id", userId);
  608. String result = LifeCenterFunction.httpUrlConnection(config.nonFaceApiTokenUrl, data);
  609. JSONObject object = new JSONObject(result);
  610. String message = "";
  611. String token = "";
  612. for(String key : object.keySet()) {
  613. if (key.equals("errorCode")) {
  614. message = object.getString("message");
  615. } else if (key.equals("token")){
  616. token = object.getString("token");
  617. }
  618. }
  619. if (!message.equals("")) {
  620. //error
  621. } else {
  622. int sesCenterCode = Integer.valueOf( LifeCenterSessionController.getSession( request, "sesCenterCode" ) ) ;
  623. String sesId = LifeCenterSessionController.getSession( request, "sesId" );
  624. String remoteIp = LifeCenterFunction.getRemoteAddr( request );
  625. PushDTO dto = new PushDTO();
  626. dto.setSendType("D");
  627. dto.setTargetType("P");
  628. dto.setPushTitle("비대면 진료");
  629. dto.setPushContent("비대면 진료를 요청하였습니다.");
  630. dto.setPushPayLoad1("nonface");
  631. dto.setCenterCode( sesCenterCode );
  632. dto.setSender( sesId );
  633. dto.setSenderIp( remoteIp );
  634. dto.setSendState( "W" );
  635. pushService.insertPushData(dto);
  636. dto.setPatientIdx(Integer.valueOf(patientIdx));
  637. pushService.insertPushTargetTemp(dto);
  638. }
  639. String hashData = LifeCenterFunction.getSignature(config.nonFaceApiSecret, config.nonFaceApiKey, roomId + userId); //"1011503101"
  640. object.put("api_key", config.nonFaceApiKey);
  641. object.put("member_id", userId);
  642. object.put("token", token);
  643. object.put("room_id", roomId);
  644. object.put("member_name", userNm);
  645. object.put("classify", "d"); // p이면 환자 d이면 의사
  646. object.put("hashData", hashData);
  647. return object.toString();
  648. }
  649. @RequestMapping( value="/excel", method=RequestMethod.POST )
  650. public void getPatientList(
  651. @RequestParam(value="downMemo", required=false, defaultValue="") String downMemo,
  652. @RequestParam(value="inputState", required=false, defaultValue="ALL") String inputState,
  653. @RequestParam(value="patientName", required=false, defaultValue="") String patientName,
  654. @RequestParam(value="startDate", required=false, defaultValue="") String startDate,
  655. @RequestParam(value="endDate", required=false, defaultValue="") String endDate,
  656. @RequestParam(value="excelDateYm", required=false, defaultValue="") String excelDateYm,
  657. @RequestParam(value="page", required=false, defaultValue="1") int page,
  658. HttpServletRequest request,HttpServletResponse response ) {
  659. String userId = LifeCenterSessionController.getSession(request, "sesId");
  660. String sesCenterCode = LifeCenterSessionController.getSession(request, "sesCenterCode");
  661. String sesGroupIdx = LifeCenterSessionController.getSession(request, "sesGroupIdx");
  662. //excel 다운로드 로그 남기기
  663. FileDownloadDTO fileDTO = new FileDownloadDTO();
  664. fileDTO.setId( userId );
  665. fileDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) );
  666. fileDTO.setUrl( request.getRequestURI().toString() );
  667. fileDTO.setMemo( downMemo );
  668. fileDTO.setEtc( "" );
  669. fileDownloadService.insertExcelDownloadLog( fileDTO );
  670. // 권한이 SYSTEM일경우
  671. PatientDTO dto = new PatientDTO();
  672. dto.setCenterCode(Integer.parseInt(sesCenterCode));
  673. dto.setGroupIdx(Integer.valueOf(sesGroupIdx));
  674. dto.setPatientName(patientName);
  675. dto.setState(inputState);
  676. dto.setStartDate(startDate);
  677. dto.setEndDate(endDate);
  678. if (dto.getCenterCode() == 0) {
  679. if( !excelDateYm.equals( "" ) ) {
  680. String[] ymSplit = excelDateYm.split("/");
  681. String y = ymSplit[0];
  682. String m = ymSplit[1];
  683. if( Integer.valueOf(m) < 10 ) {
  684. m = "0" + m;
  685. }
  686. excelDateYm = y+"-"+m;
  687. }
  688. }
  689. dto.setExcelDateYm(excelDateYm);
  690. int total = patientService.selectPatientCount(dto);
  691. List<PatientDTO> result = new ArrayList<PatientDTO>();
  692. if (total > 0) {
  693. dto.setLimit( 0 );
  694. dto.setLimitMax( total );
  695. if (dto.getCenterCode() == 0) {
  696. result = patientService.selectPatientListSystem(dto);
  697. } else {
  698. result = patientService.selectPatientList(dto);
  699. }
  700. for (PatientDTO temp : result) {
  701. result.get(result.indexOf(temp)).setSymptomContent(LifeCenterFunction.getSymptom(temp));
  702. }
  703. }
  704. if (dto.getCenterCode() == 0) {
  705. getPatientListExcelSystem(request, response, result );
  706. } else {
  707. getPatientListExcel(request, response, result );
  708. }
  709. }
  710. private void getPatientListExcel(HttpServletRequest request, HttpServletResponse response, List<PatientDTO> data ) {
  711. String password = LifeCenterSessionController.getSession(request, "sesPhoneNumber");
  712. password = password.toLowerCase();
  713. if (!password.equals("null")) {
  714. password = password.replace("-", "");
  715. password = password.substring(3).trim();
  716. } else {
  717. password = "";
  718. }
  719. Workbook workbook = new XSSFWorkbook();
  720. Sheet sheet1 = workbook.createSheet("firstSheet");
  721. DecimalFormat df = new DecimalFormat("#,###");
  722. //1.셀 스타일 및 폰트 설정
  723. CellStyle styleOfBoardFillFontBlackBold16 = workbook.createCellStyle();
  724. //정렬
  725. styleOfBoardFillFontBlackBold16.setAlignment(CellStyle.ALIGN_CENTER); //가운데 정렬
  726. styleOfBoardFillFontBlackBold16.setVerticalAlignment(CellStyle.VERTICAL_CENTER); //높이 가운데 정렬
  727. //배경색
  728. styleOfBoardFillFontBlackBold16.setFillForegroundColor(IndexedColors.LIGHT_YELLOW.getIndex());
  729. styleOfBoardFillFontBlackBold16.setFillPattern(CellStyle.SOLID_FOREGROUND);
  730. //테두리 선 (우,좌,위,아래)
  731. styleOfBoardFillFontBlackBold16.setBorderRight(HSSFCellStyle.BORDER_THIN);
  732. styleOfBoardFillFontBlackBold16.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  733. styleOfBoardFillFontBlackBold16.setBorderTop(HSSFCellStyle.BORDER_THIN);
  734. styleOfBoardFillFontBlackBold16.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  735. //폰트 설정
  736. Font fontOfGothicBlackBold16 = workbook.createFont();
  737. // fontOfGothicBlackBold16.setFontName("나눔고딕"); //글씨체
  738. fontOfGothicBlackBold16.setFontHeight((short)(10*20)); //사이즈
  739. fontOfGothicBlackBold16.setBoldweight(Font.BOLDWEIGHT_BOLD); //볼드 (굵게)
  740. styleOfBoardFillFontBlackBold16.setFont(fontOfGothicBlackBold16);
  741. int i = 1;
  742. Row row = sheet1.createRow(0);
  743. Cell cell1 = row.createCell(0);
  744. Cell cell2 = row.createCell(1);
  745. Cell cell3 = row.createCell(2);
  746. Cell cell4 = row.createCell(3);
  747. Cell cell5 = row.createCell(4);
  748. Cell cell6 = row.createCell(5);
  749. Cell cell7 = row.createCell(6);
  750. Cell cell8 = row.createCell(7);
  751. Cell cell9 = row.createCell(8);
  752. Cell cell10 = row.createCell(9);
  753. Cell cell11 = row.createCell(10);
  754. Cell cell12 = row.createCell(11);
  755. Cell cell13 = row.createCell(12);
  756. Cell cell14 = row.createCell(13);
  757. Cell cell15 = row.createCell(14);
  758. cell1.setCellStyle(styleOfBoardFillFontBlackBold16);
  759. cell2.setCellStyle(styleOfBoardFillFontBlackBold16);
  760. cell3.setCellStyle(styleOfBoardFillFontBlackBold16);
  761. cell4.setCellStyle(styleOfBoardFillFontBlackBold16);
  762. cell5.setCellStyle(styleOfBoardFillFontBlackBold16);
  763. cell6.setCellStyle(styleOfBoardFillFontBlackBold16);
  764. cell7.setCellStyle(styleOfBoardFillFontBlackBold16);
  765. cell8.setCellStyle(styleOfBoardFillFontBlackBold16);
  766. cell9.setCellStyle(styleOfBoardFillFontBlackBold16);
  767. cell10.setCellStyle(styleOfBoardFillFontBlackBold16);
  768. cell11.setCellStyle(styleOfBoardFillFontBlackBold16);
  769. cell12.setCellStyle(styleOfBoardFillFontBlackBold16);
  770. cell13.setCellStyle(styleOfBoardFillFontBlackBold16);
  771. cell14.setCellStyle(styleOfBoardFillFontBlackBold16);
  772. cell15.setCellStyle(styleOfBoardFillFontBlackBold16);
  773. sheet1.setColumnWidth( 0, 5000); //센터명
  774. sheet1.setColumnWidth( 1, 3000); //환자명
  775. sheet1.setColumnWidth( 2, 4000); //동호실
  776. sheet1.setColumnWidth( 3, 2000); //성별
  777. sheet1.setColumnWidth( 4, 3500); //나이
  778. sheet1.setColumnWidth( 5, 3500); //생년월일
  779. sheet1.setColumnWidth( 6, 3500); //입소일자
  780. sheet1.setColumnWidth( 7, 3500); //상태변경일
  781. sheet1.setColumnWidth( 8, 3800); //상태
  782. sheet1.setColumnWidth( 9, 6000); //체온
  783. sheet1.setColumnWidth( 10, 10000); //혈압
  784. sheet1.setColumnWidth( 11, 6200); //맥박
  785. sheet1.setColumnWidth( 12, 6200); //산소포화도
  786. sheet1.setColumnWidth( 13, 7000); //혈당
  787. sheet1.setColumnWidth( 14, 14000); //임상증상
  788. cell1.setCellValue("생활치료센터명");
  789. cell2.setCellValue("환자명");
  790. cell3.setCellValue("동,호실");
  791. cell4.setCellValue("성별/나이");
  792. cell5.setCellValue("생년월일");
  793. cell6.setCellValue("확진일자");
  794. cell7.setCellValue("입소일자");
  795. cell8.setCellValue("퇴소예정일");
  796. cell9.setCellValue("상태(상태 변경일)");
  797. cell10.setCellValue("체온");
  798. cell11.setCellValue("혈압");
  799. cell12.setCellValue("맥박");
  800. cell13.setCellValue("산소포화도");
  801. cell14.setCellValue("혈당");
  802. cell15.setCellValue("임상증상");
  803. for (PatientDTO dto : data) {
  804. row = sheet1.createRow(i);
  805. cell1 = row.createCell(0);
  806. cell2 = row.createCell(1);
  807. cell3 = row.createCell(2);
  808. cell4 = row.createCell(3);
  809. cell5 = row.createCell(4);
  810. cell6 = row.createCell(5);
  811. cell7 = row.createCell(6);
  812. cell8 = row.createCell(7);
  813. cell9 = row.createCell(8);
  814. cell10 = row.createCell(9);
  815. cell11 = row.createCell(10);
  816. cell12 = row.createCell(11);
  817. cell13 = row.createCell(12);
  818. cell14 = row.createCell(13);
  819. cell15 = row.createCell(14);
  820. String patientName = dto.getPatientName();
  821. String roomWard = ( dto.getWardNumber() == null || dto.getWardNumber().equals( "" ) ) ? "" : dto.getWardNumber()+"동";
  822. roomWard += ( dto.getRoomNumber() == null || dto.getRoomNumber().equals( "" ) ) ? "" : dto.getRoomNumber()+"호 ";
  823. String gender = dto.getGender();
  824. String age = dto.getAge();
  825. String jumin = dto.getJumin();
  826. String confirmationDate = dto.getConfirmationDate();
  827. String hospitalizationDate = dto.getHospitalizationDate();
  828. String expecteDischargeDate = dto.getExpectedDischargeDate();
  829. String disisolationDate = dto.getDisisolationDate();
  830. String state = dto.getState();
  831. String temperature = dto.getTemperature();
  832. String temperatureCreateDate = dto.getTemperatureCreateDate();
  833. String systolicBloodPressure = dto.getSystolicBloodPressure();
  834. String systolicBloodPressureCreateDate = dto.getSystolicBloodPressureCreateDate();
  835. String diastolicBloodPressure = dto.getDiastolicBloodPressure();
  836. String diastolicBloodPressureCreateDate = dto.getDiastolicBloodPressureCreateDate();
  837. String pulseRate = dto.getPulseRate();
  838. String pulseRateCreateDate = dto.getPulseRateCreateDate();
  839. String oxygenSaturation = dto.getOxygenSaturation();
  840. String oxygenSaturationCreateDate = dto.getOxygenSaturationCreateDate();
  841. String bloodSugar = dto.getBloodSugar();
  842. String bloodSugarCreateDate = dto.getBloodSugarCreateDate();
  843. String notMeasured = "-";
  844. String symptomDate = dto.getCreateDate();
  845. String symptomContent = dto.getSymptomContent();
  846. // String symptom = LifeCenterFunction.getSymptom( dto );
  847. String centerName = dto.getCenterName();
  848. cell1.setCellValue( centerName );
  849. cell2.setCellValue( patientName );
  850. cell3.setCellValue( roomWard );
  851. cell4.setCellValue( gender + "/" + age );
  852. cell5.setCellValue( jumin );
  853. cell6.setCellValue( confirmationDate );
  854. cell7.setCellValue( hospitalizationDate );
  855. cell8.setCellValue( expecteDischargeDate );
  856. if (state.equals("입소(지정)")) {
  857. cell9.setCellValue( state );
  858. } else {
  859. cell9.setCellValue( state + "(" + disisolationDate + ")" );
  860. }
  861. cell10.setCellValue( ( temperature == null || temperature.equals("") ) ? notMeasured : temperature + " ˚C (" + temperatureCreateDate + ")" );
  862. cell11.setCellValue( ( systolicBloodPressure == null || systolicBloodPressure.equals("") ) ? notMeasured : systolicBloodPressure + " mmHg / " + diastolicBloodPressure + " mmHg (" + systolicBloodPressureCreateDate + ")" );
  863. cell12.setCellValue( ( pulseRate == null || pulseRate.equals("") ) ? notMeasured : pulseRate + " bpm (" + pulseRateCreateDate + ")" );
  864. cell13.setCellValue( ( oxygenSaturation == null || oxygenSaturation.equals("") ) ? notMeasured : oxygenSaturation + " % (" + oxygenSaturationCreateDate + ")" );
  865. cell14.setCellValue( ( bloodSugar == null || bloodSugar.equals("") ) ? notMeasured : bloodSugar + " mg/dL (" + bloodSugarCreateDate + ")" );
  866. cell15.setCellValue( ( symptomContent == null || symptomDate == null || symptomContent.equals("") || symptomDate.equals( "" ) ) ? notMeasured : symptomContent + " (" + symptomDate + ")" );
  867. i++;
  868. }
  869. row = sheet1.createRow(i);
  870. cell1 = row.createCell(2);
  871. cell2 = row.createCell(3);
  872. cell3 = row.createCell(4);
  873. cell4 = row.createCell(5);
  874. cell5 = row.createCell(6);
  875. cell6 = row.createCell(7);
  876. cell7 = row.createCell(8);
  877. cell8 = row.createCell(9);
  878. cell9 = row.createCell(10);
  879. cell10 = row.createCell(11);
  880. cell11 = row.createCell(12);
  881. cell12 = row.createCell(13);
  882. cell13 = row.createCell(14);
  883. cell14 = row.createCell(15);
  884. cell15 = row.createCell(16);
  885. try {
  886. // File file = new File(".");
  887. // String rootPath = file.getAbsolutePath();
  888. // System.out.println("현재 프로젝트의 경로 : "+rootPath );
  889. // JBOSS에서 구동시 /home1/jboss/jboss-eap-7.3/domain/test/excel-temp 경로에 저장이됨
  890. String tempPath = "../excel-temp/testExcel.xlsx";
  891. String downName = LifeCenterFunction.getNow() + " 환자리스트.xlsx";
  892. File xlsFile = new File(tempPath);
  893. // FileOutputStream fileOut = new FileOutputStream(tempPath);
  894. // workbook.write(fileOut);
  895. // fileOut.close();
  896. ByteArrayOutputStream fileOut = new ByteArrayOutputStream();
  897. FileOutputStream fos = new FileOutputStream(tempPath);
  898. workbook.write(fileOut);
  899. InputStream filein = new ByteArrayInputStream(fileOut.toByteArray());
  900. OPCPackage opc = OPCPackage.open(filein);
  901. POIFSFileSystem fileSystem = new POIFSFileSystem();
  902. EncryptionInfo encryptionInfo = new EncryptionInfo(EncryptionMode.agile);
  903. Encryptor encryptor = encryptionInfo.getEncryptor();
  904. encryptor.confirmPassword(password);
  905. opc.save(encryptor.getDataStream(fileSystem));
  906. opc.flush();
  907. fileSystem.writeFilesystem(fos);
  908. fileOut.close();
  909. opc.close();
  910. filein.close();
  911. fileSystem.close();
  912. LifeCenterFileDownload.download(request, response, tempPath, downName);
  913. xlsFile.delete();
  914. } catch (FileNotFoundException e) {
  915. e.printStackTrace();
  916. } catch (IOException e) {
  917. e.printStackTrace();
  918. } catch (InvalidFormatException e) {
  919. // TODO Auto-generated catch block
  920. e.printStackTrace();
  921. } catch (GeneralSecurityException e) {
  922. // TODO Auto-generated catch block
  923. e.printStackTrace();
  924. }
  925. }
  926. private void getPatientListExcelSystem(HttpServletRequest request, HttpServletResponse response, List<PatientDTO> data ) {
  927. String password = LifeCenterSessionController.getSession(request, "sesPhoneNumber");
  928. password = password.toLowerCase();
  929. if (!password.equals("null")) {
  930. password = password.replace("-", "");
  931. password = password.substring(3).trim();
  932. } else {
  933. password = "";
  934. }
  935. Workbook workbook = new XSSFWorkbook();
  936. Sheet sheet1 = workbook.createSheet("firstSheet");
  937. DecimalFormat df = new DecimalFormat("#,###");
  938. //1.셀 스타일 및 폰트 설정
  939. CellStyle styleOfBoardFillFontBlackBold16 = workbook.createCellStyle();
  940. //정렬
  941. styleOfBoardFillFontBlackBold16.setAlignment(CellStyle.ALIGN_CENTER); //가운데 정렬
  942. styleOfBoardFillFontBlackBold16.setVerticalAlignment(CellStyle.VERTICAL_CENTER); //높이 가운데 정렬
  943. //배경색
  944. styleOfBoardFillFontBlackBold16.setFillForegroundColor(IndexedColors.LIGHT_YELLOW.getIndex());
  945. styleOfBoardFillFontBlackBold16.setFillPattern(CellStyle.SOLID_FOREGROUND);
  946. //테두리 선 (우,좌,위,아래)
  947. styleOfBoardFillFontBlackBold16.setBorderRight(HSSFCellStyle.BORDER_THIN);
  948. styleOfBoardFillFontBlackBold16.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  949. styleOfBoardFillFontBlackBold16.setBorderTop(HSSFCellStyle.BORDER_THIN);
  950. styleOfBoardFillFontBlackBold16.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  951. //폰트 설정
  952. Font fontOfGothicBlackBold16 = workbook.createFont();
  953. // fontOfGothicBlackBold16.setFontName("나눔고딕"); //글씨체
  954. fontOfGothicBlackBold16.setFontHeight((short)(10*20)); //사이즈
  955. fontOfGothicBlackBold16.setBoldweight(Font.BOLDWEIGHT_BOLD); //볼드 (굵게)
  956. styleOfBoardFillFontBlackBold16.setFont(fontOfGothicBlackBold16);
  957. int i = 1;
  958. Row row = sheet1.createRow(0);
  959. Cell cell1 = row.createCell(0);
  960. Cell cell2 = row.createCell(1);
  961. Cell cell3 = row.createCell(2);
  962. Cell cell4 = row.createCell(3);
  963. Cell cell5 = row.createCell(4);
  964. Cell cell6 = row.createCell(5);
  965. Cell cell7 = row.createCell(6);
  966. Cell cell8 = row.createCell(7);
  967. Cell cell9 = row.createCell(8);
  968. cell1.setCellStyle(styleOfBoardFillFontBlackBold16);
  969. cell2.setCellStyle(styleOfBoardFillFontBlackBold16);
  970. cell3.setCellStyle(styleOfBoardFillFontBlackBold16);
  971. cell4.setCellStyle(styleOfBoardFillFontBlackBold16);
  972. cell5.setCellStyle(styleOfBoardFillFontBlackBold16);
  973. cell6.setCellStyle(styleOfBoardFillFontBlackBold16);
  974. cell7.setCellStyle(styleOfBoardFillFontBlackBold16);
  975. cell8.setCellStyle(styleOfBoardFillFontBlackBold16);
  976. cell9.setCellStyle(styleOfBoardFillFontBlackBold16);
  977. sheet1.setColumnWidth( 0, 5000); //센터명
  978. sheet1.setColumnWidth( 1, 3000); //환자명
  979. sheet1.setColumnWidth( 2, 4000); //동호실
  980. sheet1.setColumnWidth( 3, 2000); //성별
  981. sheet1.setColumnWidth( 4, 3500); //나이
  982. sheet1.setColumnWidth( 5, 3500); //생년월일
  983. sheet1.setColumnWidth( 6, 3500); //입소일자
  984. sheet1.setColumnWidth( 7, 3500); //상태변경일
  985. sheet1.setColumnWidth( 8, 3800); //상태
  986. cell1.setCellValue("생활치료센터명");
  987. cell2.setCellValue("환자명");
  988. cell3.setCellValue("동,호실");
  989. cell4.setCellValue("성별/나이");
  990. cell5.setCellValue("생년월일");
  991. cell6.setCellValue("확진일자");
  992. cell7.setCellValue("입소일자");
  993. cell8.setCellValue("퇴소예정일");
  994. cell9.setCellValue("상태(상태 변경일)");
  995. for (PatientDTO dto : data) {
  996. row = sheet1.createRow(i);
  997. cell1 = row.createCell(0);
  998. cell2 = row.createCell(1);
  999. cell3 = row.createCell(2);
  1000. cell4 = row.createCell(3);
  1001. cell5 = row.createCell(4);
  1002. cell6 = row.createCell(5);
  1003. cell7 = row.createCell(6);
  1004. cell8 = row.createCell(7);
  1005. cell9 = row.createCell(8);
  1006. String patientName = dto.getPatientName();
  1007. String roomWard = ( dto.getWardNumber() == null || dto.getWardNumber().equals( "" ) ) ? "" : dto.getWardNumber()+"동";
  1008. roomWard += ( dto.getRoomNumber() == null || dto.getRoomNumber().equals( "" ) ) ? "" : dto.getRoomNumber()+"호 ";
  1009. String gender = dto.getGender();
  1010. String age = dto.getAge();
  1011. String jumin = dto.getJumin();
  1012. String confirmationDate = dto.getConfirmationDate();
  1013. String hospitalizationDate = dto.getHospitalizationDate();
  1014. String expecteDischargeDate = dto.getExpectedDischargeDate();
  1015. String disisolationDate = dto.getDisisolationDate();
  1016. String state = dto.getState();
  1017. String notMeasured = "-";
  1018. String symptomDate = dto.getCreateDate();
  1019. String symptomContent = dto.getSymptomContent();
  1020. // String symptom = LifeCenterFunction.getSymptom( dto );
  1021. String centerName = dto.getCenterName();
  1022. cell1.setCellValue( centerName );
  1023. cell2.setCellValue( patientName );
  1024. cell3.setCellValue( roomWard );
  1025. cell4.setCellValue( gender + "/" + age );
  1026. cell5.setCellValue( jumin );
  1027. cell6.setCellValue( confirmationDate );
  1028. cell7.setCellValue( hospitalizationDate );
  1029. cell8.setCellValue( expecteDischargeDate );
  1030. if (state.equals("입소(지정)")) {
  1031. cell9.setCellValue( state );
  1032. } else {
  1033. cell9.setCellValue( state + "(" + disisolationDate + ")" );
  1034. }
  1035. i++;
  1036. }
  1037. row = sheet1.createRow(i);
  1038. cell1 = row.createCell(2);
  1039. cell2 = row.createCell(3);
  1040. cell3 = row.createCell(4);
  1041. cell4 = row.createCell(5);
  1042. cell5 = row.createCell(6);
  1043. cell6 = row.createCell(7);
  1044. cell7 = row.createCell(8);
  1045. cell8 = row.createCell(9);
  1046. cell9 = row.createCell(10);
  1047. try {
  1048. // File file = new File(".");
  1049. // String rootPath = file.getAbsolutePath();
  1050. // System.out.println("현재 프로젝트의 경로 : "+rootPath );
  1051. // JBOSS에서 구동시 /home1/jboss/jboss-eap-7.3/domain/test/excel-temp 경로에 저장이됨
  1052. String tempPath = "../excel-temp/testExcel.xlsx";
  1053. String downName = LifeCenterFunction.getNow() + " 환자리스트.xlsx";
  1054. File xlsFile = new File(tempPath);
  1055. // FileOutputStream fileOut = new FileOutputStream(tempPath);
  1056. // workbook.write(fileOut);
  1057. // fileOut.close();
  1058. ByteArrayOutputStream fileOut = new ByteArrayOutputStream();
  1059. FileOutputStream fos = new FileOutputStream(tempPath);
  1060. workbook.write(fileOut);
  1061. InputStream filein = new ByteArrayInputStream(fileOut.toByteArray());
  1062. OPCPackage opc = OPCPackage.open(filein);
  1063. POIFSFileSystem fileSystem = new POIFSFileSystem();
  1064. EncryptionInfo encryptionInfo = new EncryptionInfo(EncryptionMode.agile);
  1065. Encryptor encryptor = encryptionInfo.getEncryptor();
  1066. encryptor.confirmPassword(password);
  1067. opc.save(encryptor.getDataStream(fileSystem));
  1068. opc.flush();
  1069. fileSystem.writeFilesystem(fos);
  1070. fileOut.close();
  1071. opc.close();
  1072. filein.close();
  1073. fileSystem.close();
  1074. LifeCenterFileDownload.download(request, response, tempPath, downName);
  1075. xlsFile.delete();
  1076. } catch (FileNotFoundException e) {
  1077. e.printStackTrace();
  1078. } catch (IOException e) {
  1079. e.printStackTrace();
  1080. } catch (InvalidFormatException e) {
  1081. // TODO Auto-generated catch block
  1082. e.printStackTrace();
  1083. } catch (GeneralSecurityException e) {
  1084. // TODO Auto-generated catch block
  1085. e.printStackTrace();
  1086. }
  1087. }
  1088. }