ClinicController.java 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143
  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.security.GeneralSecurityException;
  10. import java.text.SimpleDateFormat;
  11. import java.util.ArrayList;
  12. import java.util.Calendar;
  13. import java.util.Date;
  14. import java.util.List;
  15. import javax.servlet.http.HttpServletRequest;
  16. import javax.servlet.http.HttpServletResponse;
  17. import org.apache.poi.hssf.usermodel.HSSFCellStyle;
  18. import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
  19. import org.apache.poi.openxml4j.opc.OPCPackage;
  20. import org.apache.poi.poifs.crypt.EncryptionInfo;
  21. import org.apache.poi.poifs.crypt.EncryptionMode;
  22. import org.apache.poi.poifs.crypt.Encryptor;
  23. import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  24. import org.apache.poi.ss.usermodel.Cell;
  25. import org.apache.poi.ss.usermodel.CellStyle;
  26. import org.apache.poi.ss.usermodel.Font;
  27. import org.apache.poi.ss.usermodel.IndexedColors;
  28. import org.apache.poi.ss.usermodel.Row;
  29. import org.apache.poi.ss.usermodel.Sheet;
  30. import org.apache.poi.ss.usermodel.Workbook;
  31. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  32. import org.json.JSONObject;
  33. import org.slf4j.Logger;
  34. import org.slf4j.LoggerFactory;
  35. import org.springframework.beans.factory.annotation.Autowired;
  36. import org.springframework.stereotype.Controller;
  37. import org.springframework.web.bind.annotation.ModelAttribute;
  38. import org.springframework.web.bind.annotation.RequestMapping;
  39. import org.springframework.web.bind.annotation.RequestMethod;
  40. import org.springframework.web.bind.annotation.RequestParam;
  41. import org.springframework.web.bind.annotation.ResponseBody;
  42. import org.springframework.web.servlet.ModelAndView;
  43. import com.lemon.lifecenter.common.LifeCenterController;
  44. import com.lemon.lifecenter.common.LifeCenterFileDownload;
  45. import com.lemon.lifecenter.common.LifeCenterFunction;
  46. import com.lemon.lifecenter.common.LifeCenterSessionController;
  47. import com.lemon.lifecenter.dto.ClinicConfigurationDTO;
  48. import com.lemon.lifecenter.dto.FileDownloadDTO;
  49. import com.lemon.lifecenter.dto.PatientDTO;
  50. import com.lemon.lifecenter.dto.PatientMemoDTO;
  51. import com.lemon.lifecenter.dto.PatientPHRHistoryDTO;
  52. import com.lemon.lifecenter.dto.PatientPHRLatestDTO;
  53. import com.lemon.lifecenter.dto.PatientSymptomSimDTO;
  54. import com.lemon.lifecenter.service.ClinicService;
  55. import com.lemon.lifecenter.service.FileDownloadService;
  56. import com.lemon.lifecenter.service.PHRService;
  57. import com.lemon.lifecenter.service.PatientService;
  58. @Controller
  59. @RequestMapping("/clinic")
  60. public class ClinicController extends LifeCenterController {
  61. @Autowired
  62. private ClinicService clinicService;
  63. @Autowired
  64. private PHRService phrService;
  65. @Autowired
  66. private PatientService patientService;
  67. @Autowired
  68. private FileDownloadService fileDownloadService;
  69. private final Logger logger = LoggerFactory.getLogger(this.getClass());
  70. private enum FilterType {
  71. newPatient(0x01),
  72. alarm(0x02),
  73. temperatureBlank(0x04),
  74. bloodPressureBlank(0x08),
  75. pulseRateBlank(0x10),
  76. oxygenSaturationBlank(0x20),
  77. bloodSugarBlank(0x40),
  78. symptomBlank(0x80);
  79. private final int value;
  80. FilterType(int value) {
  81. this.value = value;
  82. }
  83. public int getValue() {
  84. return value;
  85. }
  86. }
  87. private String[] parseFilter(String filter) {
  88. ArrayList<String> arrayList = new ArrayList<String>();
  89. try {
  90. int filterValue = Integer.parseInt(filter);
  91. for (FilterType f: FilterType.values()) {
  92. if ((filterValue & f.getValue()) == f.getValue()) {
  93. arrayList.add(f.name());
  94. }
  95. }
  96. }
  97. catch( Exception e) {
  98. // 에러시 필터가 없는 것으로 간주
  99. }
  100. return arrayList.toArray(new String[arrayList.size()]);
  101. }
  102. @RequestMapping("/state")
  103. public ModelAndView clinicState(HttpServletRequest request,
  104. @RequestParam(value = "page", required = true, defaultValue = "1") int page,
  105. @RequestParam(value = "size", required = true, defaultValue = "30") int pageSize,
  106. @RequestParam(value = "searchText", required = false, defaultValue = "") String searchText,
  107. @RequestParam(value = "filter", required = false, defaultValue = "") String filter) {
  108. String centerCode = LifeCenterSessionController.getSession( request, "sesCenterCode" );
  109. PatientPHRLatestDTO dto = new PatientPHRLatestDTO();
  110. dto.setLimit((Integer.valueOf(page) - 1) * pageSize);
  111. dto.setLimitMax(pageSize);
  112. dto.setCenterCode(centerCode);
  113. dto.setSearchText(searchText);
  114. if (!filter.equals("")) {
  115. String[] filterList = parseFilter(filter);
  116. if (filterList.length > 0) {
  117. dto.setFilterList(filterList);
  118. }
  119. }
  120. int total = clinicService.selectPHRLatestCount(dto);
  121. // 서버사이드 렌더링 안함
  122. // List<PatientPHRLatestDTO> result = new ArrayList<PatientPHRLatestDTO>();
  123. //
  124. // if (total > 0) {
  125. // result = clinicService.selectPHRLatestList(dto);
  126. // }
  127. ModelAndView mv = setMV("clinic/state");
  128. mv.addObject("page", page);
  129. mv.addObject("searchText", searchText);
  130. mv.addObject("filter", filter);
  131. mv.addObject("total", total);
  132. // mv.addObject("items", result);
  133. return mv;
  134. }
  135. @RequestMapping("/info")
  136. public ModelAndView patientInfo(
  137. @RequestParam(value = "patientIdx", required = true, defaultValue = "") int patientIdx,
  138. @RequestParam(value = "refererSearch", required = false, defaultValue = "") String refererSearch,
  139. @RequestParam(value = "refererPage", required = false, defaultValue = "") String refererPage,
  140. @RequestParam(value = "refererFilter", required = false, defaultValue = "") String refererFilter) {
  141. // 환자정보
  142. PatientDTO patientDto = new PatientDTO();
  143. patientDto.setPatientIdx(patientIdx);
  144. patientDto = patientService.selectPatientOne(patientDto);
  145. String jumin = patientDto.getJumin();
  146. jumin = LifeCenterFunction.changeJuminToBirthday(jumin);
  147. patientDto.setJumin(jumin);
  148. patientDto.setPatientPhone(LifeCenterFunction.phone(patientDto.getPatientPhone()));
  149. patientDto.setGuardianPhone(LifeCenterFunction.phone(patientDto.getGuardianPhone()));
  150. String bloodPress = patientDto.getBloodPressureLevel();
  151. if (!bloodPress.equals("") && !bloodPress.equals("|")) {
  152. String[] bloodPressureLevel = bloodPress.split("[|]");
  153. if (bloodPressureLevel[0] != null) {
  154. patientDto.setBloodPressureLevelCon(bloodPressureLevel[0]);
  155. }
  156. if (bloodPressureLevel[1] != null) {
  157. patientDto.setBloodPressureLevelRel(bloodPressureLevel[1]);
  158. }
  159. }
  160. String strDisease = "";
  161. String strSymptom = LifeCenterFunction.getSymptom(patientDto);
  162. if (patientDto.getBasalDiseaseYn().equals("Y")) {
  163. strDisease = LifeCenterFunction.getDisease(patientDto);
  164. }
  165. // 히스토리 데이터
  166. PatientPHRHistoryDTO dto = new PatientPHRHistoryDTO();
  167. dto.setPatientIdx(patientIdx);
  168. // 체온
  169. dto.setPhrType("temperature");
  170. List<PatientPHRHistoryDTO> temperatureResult = phrService.selectPHRHistoryList(dto);
  171. // 혈압
  172. dto.setPhrType("bloodPressure");
  173. List<PatientPHRHistoryDTO> bloodPressureResult = phrService.selectPHRHistoryList(dto);
  174. // 맥박
  175. dto.setPhrType("pulseRate");
  176. List<PatientPHRHistoryDTO> pulseRateResult = phrService.selectPHRHistoryList(dto);
  177. // 산소포화도
  178. dto.setPhrType("oxygenSaturation");
  179. List<PatientPHRHistoryDTO> oxygenSaturationResult = phrService.selectPHRHistoryList(dto);
  180. // 혈당
  181. dto.setPhrType("bloodSugar");
  182. List<PatientPHRHistoryDTO> bloodSugarResult = phrService.selectPHRHistoryList(dto);
  183. // 증상
  184. PatientSymptomSimDTO dto2 = new PatientSymptomSimDTO();
  185. dto2.setPatientIdx(patientIdx);
  186. List<PatientSymptomSimDTO> symptomResult = phrService.selectSymptomList(dto2);
  187. // 메모
  188. PatientMemoDTO dto3 = new PatientMemoDTO();
  189. dto3.setPatientIdx(patientIdx);
  190. List<PatientMemoDTO> memoResult = clinicService.selectMemoList(dto3);
  191. // response
  192. List<PatientPHRHistoryDTO> bloodPressureUnionResult = getBloodPressureUnionResult(patientIdx, bloodPressureResult, pulseRateResult);
  193. ModelAndView mv = setMV("clinic/info");
  194. mv.addObject("patientIdx", patientIdx);
  195. mv.addObject("info", patientDto);
  196. mv.addObject("symptom", strSymptom);
  197. mv.addObject("disease", strDisease);
  198. mv.addObject("temperatureResult", temperatureResult);
  199. mv.addObject("bloodPressureResult", bloodPressureResult);
  200. mv.addObject("pulseRateResult", pulseRateResult);
  201. mv.addObject("bloodPressureUnionResult", bloodPressureUnionResult);
  202. mv.addObject("oxygenSaturationResult", oxygenSaturationResult);
  203. mv.addObject("bloodSugarResult", bloodSugarResult);
  204. mv.addObject("symptomResult", symptomResult);
  205. mv.addObject("memoResult", memoResult);
  206. mv.addObject("refererSearch", refererSearch);
  207. mv.addObject("refererPage", refererPage);
  208. mv.addObject("refererFilter", refererFilter);
  209. return mv;
  210. }
  211. @RequestMapping("/api/state")
  212. public @ResponseBody String getStateAPI(HttpServletRequest request,
  213. @RequestParam(value = "page", required = true, defaultValue = "1") int page,
  214. @RequestParam(value = "size", required = true, defaultValue = "30") int pageSize,
  215. @RequestParam(value = "searchText", required = false, defaultValue = "") String searchText,
  216. @RequestParam(value = "filter", required = false, defaultValue = "") String filter,
  217. @RequestParam(value = "sortType", required = false, defaultValue = "") String sortType) {
  218. String centerCode = LifeCenterSessionController.getSession( request, "sesCenterCode" );
  219. PatientPHRLatestDTO dto = new PatientPHRLatestDTO();
  220. dto.setLimit((Integer.valueOf(page) - 1) * pageSize);
  221. dto.setLimitMax(pageSize);
  222. dto.setCenterCode(centerCode);
  223. dto.setSearchText(searchText);
  224. if (!filter.equals("")) {
  225. String[] filterList = parseFilter(filter);
  226. if (filterList.length > 0) {
  227. dto.setFilterList(filterList);
  228. }
  229. }
  230. if (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 12) {
  231. dto.setTimeCriterion("AM");
  232. } else {
  233. dto.setTimeCriterion("PM");
  234. }
  235. dto.setSortType(sortType);
  236. int total = clinicService.selectPHRLatestCount(dto);
  237. List<PatientPHRLatestDTO> result = new ArrayList<PatientPHRLatestDTO>();
  238. if (total > 0) {
  239. result = clinicService.selectPHRLatestList(dto);
  240. }
  241. JSONObject json = new JSONObject();
  242. json.put("count", total);
  243. json.put("items", result);
  244. return json.toString();
  245. }
  246. @RequestMapping("/api/phrDatas")
  247. public @ResponseBody List<PatientPHRHistoryDTO> getPhrDatasAPI(
  248. @RequestParam(value = "patientIdx", required = true, defaultValue = "") int patientIdx,
  249. @RequestParam(value = "phrType", required = true, defaultValue = "temperature") String phrType) {
  250. PatientPHRHistoryDTO dto = new PatientPHRHistoryDTO();
  251. dto.setPatientIdx(patientIdx);
  252. dto.setPhrType(phrType);
  253. List<PatientPHRHistoryDTO> result = phrService.selectPHRHistoryList(dto);
  254. boolean needPulseRate = phrType.equals("bloodPressure");
  255. if (needPulseRate) {
  256. PatientPHRHistoryDTO dto2 = new PatientPHRHistoryDTO();
  257. dto2.setPatientIdx(patientIdx);
  258. dto2.setPhrType("pulseRate");
  259. List<PatientPHRHistoryDTO> pulseRateResult = phrService.selectPHRHistoryList(dto2);
  260. List<PatientPHRHistoryDTO> bloodPressureUnionResult = getBloodPressureUnionResult(patientIdx, result, pulseRateResult);
  261. return bloodPressureUnionResult;
  262. }
  263. else {
  264. return result;
  265. }
  266. }
  267. @RequestMapping(value = "/api/phrData", method = RequestMethod.POST)
  268. public @ResponseBody String insertPhrDataAPI(@ModelAttribute("dto") final PatientPHRHistoryDTO dto) {
  269. try {
  270. phrService.insertPHR(dto);
  271. if (dto.getPhrValueExtra() != null) {
  272. PatientPHRHistoryDTO pulseRateDto = new PatientPHRHistoryDTO();
  273. pulseRateDto.setPatientIdx(dto.getPatientIdx());
  274. pulseRateDto.setPhrType("pulseRate");
  275. pulseRateDto.setPhrValue(dto.getPhrValueExtra());
  276. pulseRateDto.setRecordedByName(dto.getRecordedByName());
  277. if (dto.getRecordedById() != null) {
  278. pulseRateDto.setRecordedById(dto.getRecordedById());
  279. }
  280. if (dto.getRecordedDate() != null) {
  281. pulseRateDto.setRecordedDate(dto.getRecordedDate());
  282. }
  283. phrService.insertPHR(pulseRateDto);
  284. }
  285. JSONObject json = new JSONObject();
  286. json.put("code", "00");
  287. json.put("message", "");
  288. return json.toString();
  289. } catch (Exception e) {
  290. JSONObject json = new JSONObject();
  291. json.put("code", "01");
  292. json.put("message", e.getLocalizedMessage());
  293. return json.toString();
  294. }
  295. }
  296. @RequestMapping("/api/symptomDatas")
  297. public @ResponseBody List<PatientSymptomSimDTO> getSymptomDatasAPI(
  298. @RequestParam(value = "patientIdx", required = true, defaultValue = "") int patientIdx) {
  299. PatientSymptomSimDTO dto = new PatientSymptomSimDTO();
  300. dto.setPatientIdx(patientIdx);
  301. return phrService.selectSymptomList(dto);
  302. }
  303. @RequestMapping(value = "/api/symptomData", method = RequestMethod.POST)
  304. public @ResponseBody String insertSymptomDataAPI(@ModelAttribute("dto") final PatientSymptomSimDTO dto) {
  305. try {
  306. phrService.insertSymptom(dto);
  307. JSONObject json = new JSONObject();
  308. json.put("code", "00");
  309. json.put("message", "");
  310. return json.toString();
  311. } catch (Exception e) {
  312. JSONObject json = new JSONObject();
  313. json.put("code", "01");
  314. json.put("message", e.getLocalizedMessage());
  315. return json.toString();
  316. }
  317. }
  318. @RequestMapping("/api/memoDatas")
  319. public @ResponseBody List<PatientMemoDTO> getMemoDatasAPI(
  320. @RequestParam(value = "patientIdx", required = true, defaultValue = "") int patientIdx) {
  321. PatientMemoDTO dto = new PatientMemoDTO();
  322. dto.setPatientIdx(patientIdx);
  323. return clinicService.selectMemoList(dto);
  324. }
  325. @RequestMapping(value = "/api/memoData", method = RequestMethod.POST)
  326. public @ResponseBody String insertMemoDataAPI(@ModelAttribute("dto") final PatientMemoDTO dto) {
  327. try {
  328. clinicService.insertMemo(dto);
  329. JSONObject json = new JSONObject();
  330. json.put("code", "00");
  331. json.put("message", "");
  332. return json.toString();
  333. } catch (Exception e) {
  334. JSONObject json = new JSONObject();
  335. json.put("code", "01");
  336. json.put("message", e.getLocalizedMessage());
  337. return json.toString();
  338. }
  339. }
  340. @RequestMapping(value = "/api/memoData", method = RequestMethod.DELETE)
  341. public @ResponseBody String deleteMemoDataAPI(@ModelAttribute("dto") final PatientMemoDTO dto) {
  342. try {
  343. clinicService.deleteMemo(dto);
  344. JSONObject json = new JSONObject();
  345. json.put("code", "00");
  346. json.put("message", "");
  347. return json.toString();
  348. } catch (Exception e) {
  349. JSONObject json = new JSONObject();
  350. json.put("code", "01");
  351. json.put("message", e.getLocalizedMessage());
  352. return json.toString();
  353. }
  354. }
  355. @RequestMapping(value = "/api/memoData", method = RequestMethod.PATCH)
  356. public @ResponseBody String updateMemoDataAPI(@ModelAttribute("dto") final PatientMemoDTO dto) {
  357. try {
  358. clinicService.updateMemo(dto);
  359. JSONObject json = new JSONObject();
  360. json.put("code", "00");
  361. json.put("message", "");
  362. return json.toString();
  363. } catch (Exception e) {
  364. JSONObject json = new JSONObject();
  365. json.put("code", "01");
  366. json.put("message", e.getLocalizedMessage());
  367. return json.toString();
  368. }
  369. }
  370. private List<PatientPHRHistoryDTO> getBloodPressureUnionResult(int patientIdx, List<PatientPHRHistoryDTO> bloodPressureResult, List<PatientPHRHistoryDTO>pulseRateResult) {
  371. // 혈압 맥박 정리
  372. int bloodPressureIndex = 0;
  373. int pulseRateIndex = 0;
  374. List<PatientPHRHistoryDTO> bloodPressureUnionResult = new ArrayList<PatientPHRHistoryDTO>();
  375. while (bloodPressureIndex < bloodPressureResult.size() || pulseRateIndex < pulseRateResult.size()) {
  376. PatientPHRHistoryDTO union = new PatientPHRHistoryDTO();
  377. union.setPatientIdx(patientIdx);
  378. union.setPhrType("bloodPressure");
  379. if (bloodPressureIndex == bloodPressureResult.size()) {
  380. PatientPHRHistoryDTO pr = pulseRateResult.get(pulseRateIndex);
  381. union.setCreateDate(pr.getCreateDate());
  382. union.setRecordedDate(pr.getRecordedDate());
  383. union.setPhrValueExtra(pr.getPhrValue());
  384. union.setRecordedByName(pr.getRecordedByName());
  385. union.setRecordedById(pr.getRecordedById());
  386. bloodPressureUnionResult.add(union);
  387. pulseRateIndex += 1;
  388. continue;
  389. }
  390. else if (pulseRateIndex == pulseRateResult.size()) {
  391. PatientPHRHistoryDTO bp = bloodPressureResult.get(bloodPressureIndex);
  392. union.setCreateDate(bp.getCreateDate());
  393. union.setRecordedDate(bp.getRecordedDate());
  394. union.setPhrValue(bp.getPhrValue());
  395. union.setPhrValue2(bp.getPhrValue2());
  396. union.setRecordedByName(bp.getRecordedByName());
  397. union.setRecordedById(bp.getRecordedById());
  398. bloodPressureUnionResult.add(union);
  399. bloodPressureIndex += 1;
  400. continue;
  401. }
  402. PatientPHRHistoryDTO bp = bloodPressureResult.get(bloodPressureIndex);
  403. PatientPHRHistoryDTO pr = pulseRateResult.get(pulseRateIndex);
  404. SimpleDateFormat originalFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
  405. SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  406. String bpRecordedDateFormatted = bp.getRecordedDate();
  407. String prRecordedDateFormatted = pr.getRecordedDate();
  408. try {
  409. Date t = originalFormat.parse(bpRecordedDateFormatted);
  410. bpRecordedDateFormatted = targetFormat.format(t);
  411. Date t2 = originalFormat.parse(prRecordedDateFormatted);
  412. prRecordedDateFormatted = targetFormat.format(t2);
  413. }
  414. catch (Exception e) {
  415. }
  416. int dateDiffer = bpRecordedDateFormatted.compareTo(prRecordedDateFormatted);
  417. if (dateDiffer == 0) {
  418. union.setCreateDate(bp.getCreateDate());
  419. union.setRecordedDate(bp.getRecordedDate());
  420. union.setPhrValue(bp.getPhrValue());
  421. union.setPhrValue2(bp.getPhrValue2());
  422. union.setRecordedByName(bp.getRecordedByName());
  423. union.setRecordedById(bp.getRecordedById());
  424. union.setPhrValueExtra(pr.getPhrValue());
  425. bloodPressureIndex += 1;
  426. pulseRateIndex += 1;
  427. }
  428. else if (dateDiffer < 0) {
  429. union.setCreateDate(bp.getCreateDate());
  430. union.setRecordedDate(bp.getRecordedDate());
  431. union.setPhrValue(bp.getPhrValue());
  432. union.setPhrValue2(bp.getPhrValue2());
  433. union.setRecordedByName(bp.getRecordedByName());
  434. union.setRecordedById(bp.getRecordedById());
  435. bloodPressureIndex += 1;
  436. }
  437. else if (dateDiffer > 0) {
  438. union.setCreateDate(pr.getCreateDate());
  439. union.setRecordedDate(pr.getRecordedDate());
  440. union.setPhrValueExtra(pr.getPhrValue());
  441. union.setRecordedByName(pr.getRecordedByName());
  442. union.setRecordedById(pr.getRecordedById());
  443. pulseRateIndex += 1;
  444. }
  445. bloodPressureUnionResult.add(union);
  446. }
  447. return bloodPressureUnionResult;
  448. }
  449. @RequestMapping("/excel")
  450. public void getExcelFile(
  451. @RequestParam(value="phrType", required=true, defaultValue="temperature") String phrType,
  452. @RequestParam(value="patientIdx", required=true, defaultValue="") int patientIdx,
  453. @RequestParam(value="downMemo", required=true, defaultValue="") String downMemo,
  454. HttpServletRequest request, HttpServletResponse response ) {
  455. PatientDTO patientDto = new PatientDTO();
  456. patientDto.setPatientIdx(patientIdx);
  457. patientDto = patientService.selectPatientOne(patientDto);
  458. //excel 다운로드 로그 남기기
  459. String userId = LifeCenterSessionController.getSession(request, "sesId");
  460. FileDownloadDTO fileDTO = new FileDownloadDTO();
  461. fileDTO.setId( userId );
  462. fileDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) );
  463. fileDTO.setUrl( request.getRequestURI().toString() );
  464. fileDTO.setMemo( downMemo );
  465. fileDTO.setEtc( "진료관리, " + patientDto.getPatientName() + ", " + patientDto.getJumin() + ", " + Integer.toString(patientDto.getCenterCode()) );
  466. fileDTO.setPatientIdx( patientIdx );
  467. fileDownloadService.insertExcelDownloadLog( fileDTO );
  468. this.createExcel(request, response, patientDto);
  469. }
  470. private void createExcel(HttpServletRequest request, HttpServletResponse response, PatientDTO patientDto) {
  471. Workbook workbook = new XSSFWorkbook();
  472. // 셀 스타일 및 폰트 설정
  473. CellStyle styleOfBoardFillFontBlackBold16 = workbook.createCellStyle();
  474. // 정렬
  475. styleOfBoardFillFontBlackBold16.setAlignment(CellStyle.ALIGN_CENTER); //가운데 정렬
  476. styleOfBoardFillFontBlackBold16.setVerticalAlignment(CellStyle.VERTICAL_CENTER); //높이 가운데 정렬
  477. // 배경색
  478. styleOfBoardFillFontBlackBold16.setFillForegroundColor(IndexedColors.LIGHT_YELLOW.getIndex());
  479. styleOfBoardFillFontBlackBold16.setFillPattern(CellStyle.SOLID_FOREGROUND);
  480. // 테두리 선 (우,좌,위,아래)
  481. styleOfBoardFillFontBlackBold16.setBorderRight(HSSFCellStyle.BORDER_THIN);
  482. styleOfBoardFillFontBlackBold16.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  483. styleOfBoardFillFontBlackBold16.setBorderTop(HSSFCellStyle.BORDER_THIN);
  484. styleOfBoardFillFontBlackBold16.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  485. // 폰트 설정
  486. Font fontOfGothicBlackBold16 = workbook.createFont();
  487. // fontOfGothicBlackBold16.setFontName("나눔고딕"); //글씨체
  488. fontOfGothicBlackBold16.setFontHeight((short)(10*20)); //사이즈
  489. fontOfGothicBlackBold16.setBoldweight(Font.BOLDWEIGHT_BOLD); //볼드 (굵게)
  490. styleOfBoardFillFontBlackBold16.setFont(fontOfGothicBlackBold16);
  491. this.createPHRSheet(workbook, styleOfBoardFillFontBlackBold16, patientDto, "체온", "temperature");
  492. this.createPHRSheet(workbook, styleOfBoardFillFontBlackBold16, patientDto, "혈압", "bloodPressure");
  493. this.createPHRSheet(workbook, styleOfBoardFillFontBlackBold16, patientDto, "맥박", "pulseRate");
  494. this.createPHRSheet(workbook, styleOfBoardFillFontBlackBold16, patientDto, "산소포화도", "oxygenSaturation");
  495. this.createPHRSheet(workbook, styleOfBoardFillFontBlackBold16, patientDto, "혈당", "bloodSugar");
  496. this.createSymptomSheet(workbook, styleOfBoardFillFontBlackBold16, patientDto);
  497. this.createMemoSheet(workbook, styleOfBoardFillFontBlackBold16, patientDto);
  498. try {
  499. // File file = new File(".");
  500. // String rootPath = file.getAbsolutePath();
  501. // System.out.println("현재 프로젝트의 경로 : "+rootPath );
  502. // JBOSS에서 구동시 /home1/jboss/jboss-eap-7.3/domain/test/excel-temp 경로에 저장이됨
  503. String directoryName = "../excel-temp/";
  504. File directory = new File(directoryName);
  505. if (! directory.exists()) {
  506. directory.mkdir();
  507. }
  508. String password = LifeCenterSessionController.getSession(request, "sesPhoneNumber");
  509. password = password.toLowerCase();
  510. if (!password.equals("null")) {
  511. password = password.replace("-", "");
  512. password = password.substring(3).trim();
  513. } else {
  514. password = "";
  515. }
  516. String timestamp = LifeCenterFunction.getNow("yyyy-MM-dd_HH-mm-ss");
  517. // 다운로드 파일 명: 호실_환자명(생년월일)_건강정보기록_다운로드일시.xlsx
  518. String downName = patientDto.getRoomNumber() + "_" + patientDto.getPatientName() + "(" + patientDto.getJumin() + ")_건강정보기록_" + timestamp + ".xlsx";
  519. String tempPath = directoryName + downName;
  520. File xlsFile = new File(tempPath);
  521. // FileOutputStream fileOut = new FileOutputStream(xlsFile);
  522. // workbook.write(fileOut);
  523. //
  524. // LifeCenterFileDownload.download(request, response, tempPath, downName);
  525. //
  526. // xlsFile.delete();
  527. ByteArrayOutputStream fileOut = new ByteArrayOutputStream();
  528. FileOutputStream fos = new FileOutputStream(tempPath);
  529. workbook.write(fileOut);
  530. InputStream filein = new ByteArrayInputStream(fileOut.toByteArray());
  531. OPCPackage opc = OPCPackage.open(filein);
  532. POIFSFileSystem fileSystem = new POIFSFileSystem();
  533. EncryptionInfo encryptionInfo = new EncryptionInfo(EncryptionMode.agile);
  534. Encryptor encryptor = encryptionInfo.getEncryptor();
  535. encryptor.confirmPassword(password);
  536. opc.save(encryptor.getDataStream(fileSystem));
  537. opc.flush();
  538. fileSystem.writeFilesystem(fos);
  539. fileOut.close();
  540. opc.close();
  541. filein.close();
  542. fileSystem.close();
  543. LifeCenterFileDownload.download(request, response, tempPath, downName);
  544. xlsFile.delete();
  545. } catch (FileNotFoundException e) {
  546. e.printStackTrace();
  547. } catch (IOException e) {
  548. e.printStackTrace();
  549. } catch (InvalidFormatException e) {
  550. e.printStackTrace();
  551. } catch (GeneralSecurityException e) {
  552. e.printStackTrace();
  553. }
  554. }
  555. private void createPHRSheet(Workbook workbook, CellStyle styleOfBoardFillFontBlackBold16, PatientDTO patientDto, String phrTypeKorean, String phrType) {
  556. PatientPHRHistoryDTO patientPHRHistoryDto = new PatientPHRHistoryDTO();
  557. patientPHRHistoryDto.setPhrType(phrType);
  558. patientPHRHistoryDto.setPatientIdx(patientDto.getPatientIdx());
  559. int total = phrService.selectPHRHistoryCount(patientPHRHistoryDto);
  560. List<PatientPHRHistoryDTO> data = new ArrayList<PatientPHRHistoryDTO>();
  561. if (total > 0) {
  562. data = phrService.selectPHRHistoryList(patientPHRHistoryDto);
  563. }
  564. Sheet sheet1 = workbook.createSheet(phrTypeKorean);
  565. Row row = sheet1.createRow(0);
  566. Cell cell1 = row.createCell(0);
  567. Cell cell2 = row.createCell(1);
  568. Cell cell3 = row.createCell(2);
  569. Cell cell4 = row.createCell(3);
  570. Cell cell5 = row.createCell(4);
  571. Cell cell6 = row.createCell(5);
  572. cell1.setCellStyle(styleOfBoardFillFontBlackBold16);
  573. cell2.setCellStyle(styleOfBoardFillFontBlackBold16);
  574. cell3.setCellStyle(styleOfBoardFillFontBlackBold16);
  575. cell4.setCellStyle(styleOfBoardFillFontBlackBold16);
  576. cell5.setCellStyle(styleOfBoardFillFontBlackBold16);
  577. cell6.setCellStyle(styleOfBoardFillFontBlackBold16);
  578. sheet1.setColumnWidth( 0, 5000); // 환자명
  579. sheet1.setColumnWidth( 1, 5000); // 생년월일
  580. sheet1.setColumnWidth( 2, 5000); // 동, 호실
  581. sheet1.setColumnWidth( 3, 5000); // 측정일시
  582. sheet1.setColumnWidth( 4, 3000); // 값
  583. sheet1.setColumnWidth( 5, 4000); // 기록자
  584. cell1.setCellValue("환자명");
  585. cell2.setCellValue("생년월일");
  586. cell3.setCellValue("동,호실");
  587. cell4.setCellValue("측정일시");
  588. cell5.setCellValue(phrTypeKorean);
  589. cell6.setCellValue("기록자");
  590. // 동,호실
  591. String roomNumber = "";
  592. if (!patientDto.getWardNumber().equals("")) {
  593. roomNumber = patientDto.getWardNumber() + "동";
  594. }
  595. roomNumber += patientDto.getRoomNumber() + "호";
  596. int i = 1;
  597. for (PatientPHRHistoryDTO dto : data) {
  598. row = sheet1.createRow(i);
  599. cell1 = row.createCell(0);
  600. cell2 = row.createCell(1);
  601. cell3 = row.createCell(2);
  602. cell4 = row.createCell(3);
  603. cell5 = row.createCell(4);
  604. cell6 = row.createCell(5);
  605. // 일시
  606. String recordedDate = null;
  607. SimpleDateFormat originalFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
  608. SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  609. try {
  610. Date t = originalFormat.parse(dto.getRecordedDate());
  611. recordedDate = targetFormat.format(t);
  612. } catch (Exception e) {
  613. recordedDate = dto.getRecordedDate();
  614. }
  615. // 값
  616. String phrValue = "";
  617. String phrValue2 = "";
  618. if (phrType.equals("temperature")) {
  619. phrValue = String.format("%.1f", dto.getPhrValue());
  620. phrValue2 = String.format("%.1f", dto.getPhrValue2());
  621. } else {
  622. phrValue = String.format("%.0f", dto.getPhrValue());
  623. phrValue2 = String.format("%.0f", dto.getPhrValue2());
  624. }
  625. // 기록자
  626. String recordedByName = dto.getRecordedByName();
  627. cell1.setCellValue(patientDto.getPatientName());
  628. cell2.setCellValue(patientDto.getJumin());
  629. cell3.setCellValue(roomNumber);
  630. cell4.setCellValue(recordedDate);
  631. if (phrType.equals("bloodPressure")) {
  632. cell5.setCellValue(phrValue + "/" + phrValue2);
  633. } else {
  634. cell5.setCellValue(phrValue);
  635. }
  636. cell6.setCellValue(recordedByName);
  637. i++;
  638. }
  639. }
  640. private void createSymptomSheet(Workbook workbook, CellStyle styleOfBoardFillFontBlackBold16, PatientDTO patientDto) {
  641. PatientSymptomSimDTO patientSymptomSimDto = new PatientSymptomSimDTO();
  642. patientSymptomSimDto.setPatientIdx(patientDto.getPatientIdx());
  643. int total = phrService.selectSymptomCount(patientSymptomSimDto);
  644. List<PatientSymptomSimDTO> data = new ArrayList<PatientSymptomSimDTO>();
  645. if (total > 0) {
  646. data = phrService.selectSymptomList(patientSymptomSimDto);
  647. }
  648. Sheet sheet1 = workbook.createSheet("임상증상");
  649. Row row = sheet1.createRow(0);
  650. Cell cell1 = row.createCell(0);
  651. Cell cell2 = row.createCell(1);
  652. Cell cell3 = row.createCell(2);
  653. Cell cell4 = row.createCell(3);
  654. Cell cell5 = row.createCell(4);
  655. Cell cell6 = row.createCell(5);
  656. Cell cell7 = row.createCell(6);
  657. Cell cell8 = row.createCell(7);
  658. Cell cell9 = row.createCell(8);
  659. Cell cell10 = row.createCell(9);
  660. Cell cell11 = row.createCell(10);
  661. Cell cell12 = row.createCell(11);
  662. Cell cell13 = row.createCell(12);
  663. Cell cell14 = row.createCell(13);
  664. Cell cell15 = row.createCell(14);
  665. Cell cell16 = row.createCell(15);
  666. Cell cell17 = row.createCell(16);
  667. Cell cell18 = row.createCell(17);
  668. Cell cell19 = row.createCell(18);
  669. Cell cell20 = row.createCell(19);
  670. Cell cell21 = row.createCell(20);
  671. cell1.setCellStyle(styleOfBoardFillFontBlackBold16);
  672. cell2.setCellStyle(styleOfBoardFillFontBlackBold16);
  673. cell3.setCellStyle(styleOfBoardFillFontBlackBold16);
  674. cell4.setCellStyle(styleOfBoardFillFontBlackBold16);
  675. cell5.setCellStyle(styleOfBoardFillFontBlackBold16);
  676. cell6.setCellStyle(styleOfBoardFillFontBlackBold16);
  677. cell7.setCellStyle(styleOfBoardFillFontBlackBold16);
  678. cell8.setCellStyle(styleOfBoardFillFontBlackBold16);
  679. cell9.setCellStyle(styleOfBoardFillFontBlackBold16);
  680. cell10.setCellStyle(styleOfBoardFillFontBlackBold16);
  681. cell11.setCellStyle(styleOfBoardFillFontBlackBold16);
  682. cell12.setCellStyle(styleOfBoardFillFontBlackBold16);
  683. cell13.setCellStyle(styleOfBoardFillFontBlackBold16);
  684. cell14.setCellStyle(styleOfBoardFillFontBlackBold16);
  685. cell15.setCellStyle(styleOfBoardFillFontBlackBold16);
  686. cell16.setCellStyle(styleOfBoardFillFontBlackBold16);
  687. cell17.setCellStyle(styleOfBoardFillFontBlackBold16);
  688. cell18.setCellStyle(styleOfBoardFillFontBlackBold16);
  689. cell19.setCellStyle(styleOfBoardFillFontBlackBold16);
  690. cell20.setCellStyle(styleOfBoardFillFontBlackBold16);
  691. cell21.setCellStyle(styleOfBoardFillFontBlackBold16);
  692. sheet1.setColumnWidth(0, 5000); // 환자명
  693. sheet1.setColumnWidth(1, 5000); // 생년월일
  694. sheet1.setColumnWidth(2, 5000); // 동호실
  695. sheet1.setColumnWidth(3, 5000); // 측정일시
  696. sheet1.setColumnWidth(4, 3000); // 기침
  697. sheet1.setColumnWidth(5, 3000); // 호흡곤란
  698. sheet1.setColumnWidth(6, 3000); // 오한
  699. sheet1.setColumnWidth(7, 3000); // 근육통
  700. sheet1.setColumnWidth(8, 3000); // 두통
  701. sheet1.setColumnWidth(9, 3000); // 인후통
  702. sheet1.setColumnWidth(10, 3000); // 후각/미각 손실
  703. sheet1.setColumnWidth(11, 3000); // 피로
  704. sheet1.setColumnWidth(12, 3000); // 식욕감소
  705. sheet1.setColumnWidth(13, 3000); // 가래
  706. sheet1.setColumnWidth(14, 3000); // 오심
  707. sheet1.setColumnWidth(15, 3000); // 구토
  708. sheet1.setColumnWidth(16, 3000); // 설사
  709. sheet1.setColumnWidth(17, 3000); // 어지러움
  710. sheet1.setColumnWidth(18, 3000); // 콧물/코막힘
  711. sheet1.setColumnWidth(19, 3000); // 기타증상
  712. sheet1.setColumnWidth(20, 5000); // 기록자
  713. cell1.setCellValue("환자명");
  714. cell2.setCellValue("생년월일");
  715. cell3.setCellValue("동,호실");
  716. cell4.setCellValue("측정일시");
  717. cell5.setCellValue("기침");
  718. cell6.setCellValue("호흡곤란");
  719. cell7.setCellValue("오한");
  720. cell8.setCellValue("근육통");
  721. cell9.setCellValue("두통");
  722. cell10.setCellValue("인후통");
  723. cell11.setCellValue("후각/미각 손실");
  724. cell12.setCellValue("피로");
  725. cell13.setCellValue("식욕감소");
  726. cell14.setCellValue("가래");
  727. cell15.setCellValue("오심");
  728. cell16.setCellValue("구토");
  729. cell17.setCellValue("설사");
  730. cell18.setCellValue("어지러움");
  731. cell19.setCellValue("콧물/코막힘");
  732. cell20.setCellValue("기타증상");
  733. cell21.setCellValue("기록자");
  734. // 동,호실
  735. String roomNumber = "";
  736. if (!patientDto.getWardNumber().equals("")) {
  737. roomNumber = patientDto.getWardNumber() + "동";
  738. }
  739. roomNumber += patientDto.getRoomNumber() + "호";
  740. int i = 1;
  741. for (int index = data.size() - 1; index >= 0; index--) {
  742. PatientSymptomSimDTO dto = data.get(index);
  743. row = sheet1.createRow(i);
  744. cell1 = row.createCell(0);
  745. cell2 = row.createCell(1);
  746. cell3 = row.createCell(2);
  747. cell4 = row.createCell(3);
  748. cell5 = row.createCell(4);
  749. cell6 = row.createCell(5);
  750. cell7 = row.createCell(6);
  751. cell8 = row.createCell(7);
  752. cell9 = row.createCell(8);
  753. cell10 = row.createCell(9);
  754. cell11 = row.createCell(10);
  755. cell12 = row.createCell(11);
  756. cell13 = row.createCell(12);
  757. cell14 = row.createCell(13);
  758. cell15 = row.createCell(14);
  759. cell16 = row.createCell(15);
  760. cell17 = row.createCell(16);
  761. cell18 = row.createCell(17);
  762. cell19 = row.createCell(18);
  763. cell20 = row.createCell(19);
  764. cell21 = row.createCell(20);
  765. String recordedDate = null;
  766. SimpleDateFormat originalFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
  767. SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  768. try {
  769. Date t = originalFormat.parse(dto.getRecordedDate());
  770. recordedDate = targetFormat.format(t);
  771. } catch (Exception e) {
  772. recordedDate = dto.getRecordedDate();
  773. }
  774. cell1.setCellValue(patientDto.getPatientName());
  775. cell2.setCellValue(patientDto.getJumin());
  776. cell3.setCellValue(roomNumber);
  777. cell4.setCellValue(recordedDate);
  778. cell5.setCellValue(dto.getCoughCheck().equals("Y") ? "V" : "-");
  779. cell6.setCellValue(dto.getDyspneaCheck().equals("Y") ? "V" : "-");
  780. cell7.setCellValue(dto.getColdFitCheck().equals("Y") ? "V" : "-");
  781. cell8.setCellValue(dto.getMusclePainCheck().equals("Y") ? "V" : "-");
  782. cell9.setCellValue(dto.getHeadacheCheck().equals("Y") ? "V" : "-");
  783. cell10.setCellValue(dto.getSoreThroatCheck().equals("Y") ? "V" : "-");
  784. cell11.setCellValue(dto.getSmellPalateCheck().equals("Y") ? "V" : "-");
  785. cell12.setCellValue(dto.getFatigueCheck().equals("Y") ? "V" : "-");
  786. cell13.setCellValue(dto.getAppetiteLossCheck().equals("Y") ? "V" : "-");
  787. cell14.setCellValue(dto.getSputumCheck().equals("Y") ? "V" : "-");
  788. cell15.setCellValue(dto.getOcinCheck().equals("Y") ? "V" : "-");
  789. cell16.setCellValue(dto.getVomitingCheck().equals("Y") ? "V" : "-");
  790. cell17.setCellValue(dto.getDiarrheaCheck().equals("Y") ? "V" : "-");
  791. cell18.setCellValue(dto.getDizzinessCheck().equals("Y") ? "V" : "-");
  792. cell19.setCellValue(dto.getNoseCheck().equals("Y") ? "V" : "-");
  793. cell20.setCellValue(dto.getEtcCheck().equals("Y") ? dto.getEtcContent() : "-");
  794. cell21.setCellValue(dto.getRecordedByName());
  795. i++;
  796. }
  797. }
  798. private void createMemoSheet(Workbook workbook, CellStyle styleOfBoardFillFontBlackBold16, PatientDTO patientDto) {
  799. PatientMemoDTO patientMemoDto = new PatientMemoDTO();
  800. patientMemoDto.setPatientIdx(patientDto.getPatientIdx());
  801. List<PatientMemoDTO> data = new ArrayList<PatientMemoDTO>();
  802. data = clinicService.selectMemoList(patientMemoDto);
  803. Sheet sheet1 = workbook.createSheet("의료진 메모");
  804. Row row = sheet1.createRow(0);
  805. Cell cell1 = row.createCell(0);
  806. Cell cell2 = row.createCell(1);
  807. Cell cell3 = row.createCell(2);
  808. Cell cell4 = row.createCell(3);
  809. Cell cell5 = row.createCell(4);
  810. Cell cell6 = row.createCell(5);
  811. cell1.setCellStyle(styleOfBoardFillFontBlackBold16);
  812. cell2.setCellStyle(styleOfBoardFillFontBlackBold16);
  813. cell3.setCellStyle(styleOfBoardFillFontBlackBold16);
  814. cell4.setCellStyle(styleOfBoardFillFontBlackBold16);
  815. cell5.setCellStyle(styleOfBoardFillFontBlackBold16);
  816. cell6.setCellStyle(styleOfBoardFillFontBlackBold16);
  817. sheet1.setColumnWidth(0, 5000); // 환자명
  818. sheet1.setColumnWidth(1, 5000); // 생년월일
  819. sheet1.setColumnWidth(2, 5000); // 동호실
  820. sheet1.setColumnWidth(3, 5000); // 처리일시
  821. sheet1.setColumnWidth(4, 20000); // 내용
  822. sheet1.setColumnWidth(5, 3000); // 기록자
  823. cell1.setCellValue("환자명");
  824. cell2.setCellValue("생년월일");
  825. cell3.setCellValue("동,호실");
  826. cell4.setCellValue("처리일시");
  827. cell5.setCellValue("내용");
  828. cell6.setCellValue("기록자");
  829. // 동,호실
  830. String roomNumber = "";
  831. if (!patientDto.getWardNumber().equals("")) {
  832. roomNumber = patientDto.getWardNumber() + "동";
  833. }
  834. roomNumber += patientDto.getRoomNumber() + "호";
  835. int i = 1;
  836. for (int index = data.size() - 1; index >= 0; index--) {
  837. PatientMemoDTO dto = data.get(index);
  838. row = sheet1.createRow(i);
  839. cell1 = row.createCell(0);
  840. cell2 = row.createCell(1);
  841. cell3 = row.createCell(2);
  842. cell4 = row.createCell(3);
  843. cell5 = row.createCell(4);
  844. cell6 = row.createCell(5);
  845. String recordedDate = null;
  846. SimpleDateFormat originalFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
  847. SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  848. try {
  849. Date t = originalFormat.parse(dto.getRecordedDate());
  850. recordedDate = targetFormat.format(t);
  851. } catch (Exception e) {
  852. recordedDate = dto.getRecordedDate();
  853. }
  854. cell1.setCellValue(patientDto.getPatientName());
  855. cell2.setCellValue(patientDto.getJumin());
  856. cell3.setCellValue(roomNumber);
  857. cell4.setCellValue(recordedDate);
  858. cell5.setCellValue(dto.getContents());
  859. cell6.setCellValue(dto.getRecordedByName());
  860. CellStyle cs = workbook.createCellStyle();
  861. cs.setWrapText(true);
  862. cs.setVerticalAlignment(CellStyle.VERTICAL_CENTER); //높이 가운데 정렬
  863. cell5.setCellStyle(cs);
  864. i++;
  865. }
  866. }
  867. @RequestMapping("/api/configuration")
  868. public @ResponseBody ClinicConfigurationDTO getConfigurationAPI(
  869. @RequestParam(value = "centerCode", required = true, defaultValue = "") int centerCode) {
  870. ClinicConfigurationDTO dto = new ClinicConfigurationDTO();
  871. dto.setCenterCode(centerCode);
  872. return clinicService.selectConfiguration(dto);
  873. }
  874. @RequestMapping(value = "/api/configuration", method = RequestMethod.POST)
  875. public @ResponseBody String insertConfigurationAPI(@ModelAttribute("dto") final ClinicConfigurationDTO dto) {
  876. try {
  877. clinicService.insertConfiguration(dto);
  878. JSONObject json = new JSONObject();
  879. json.put("code", "00");
  880. json.put("message", "");
  881. return json.toString();
  882. } catch (Exception e) {
  883. JSONObject json = new JSONObject();
  884. json.put("code", "01");
  885. json.put("message", e.getLocalizedMessage());
  886. return json.toString();
  887. }
  888. }
  889. @RequestMapping(value = "/api/configuration", method = RequestMethod.DELETE)
  890. public @ResponseBody String deleteConfigurationAPI(@ModelAttribute("dto") final ClinicConfigurationDTO dto) {
  891. try {
  892. clinicService.deleteConfiguration(dto);
  893. JSONObject json = new JSONObject();
  894. json.put("code", "00");
  895. json.put("message", "");
  896. return json.toString();
  897. } catch (Exception e) {
  898. JSONObject json = new JSONObject();
  899. json.put("code", "01");
  900. json.put("message", e.getLocalizedMessage());
  901. return json.toString();
  902. }
  903. }
  904. @RequestMapping(value = "/api/configuration/display", method = RequestMethod.PATCH)
  905. public @ResponseBody String updateDisplayConfigurationAPI(@ModelAttribute("dto") final ClinicConfigurationDTO dto) {
  906. try {
  907. clinicService.updateDisplayConfiguration(dto);
  908. JSONObject json = new JSONObject();
  909. json.put("code", "00");
  910. json.put("message", "");
  911. return json.toString();
  912. } catch (Exception e) {
  913. JSONObject json = new JSONObject();
  914. json.put("code", "01");
  915. json.put("message", e.getLocalizedMessage());
  916. return json.toString();
  917. }
  918. }
  919. @RequestMapping(value = "/api/configuration/threshold", method = RequestMethod.PATCH)
  920. public @ResponseBody String updateThresholdConfigurationAPI(@ModelAttribute("dto") final ClinicConfigurationDTO dto) {
  921. try {
  922. clinicService.updateThresholdConfiguration(dto);
  923. JSONObject json = new JSONObject();
  924. json.put("code", "00");
  925. json.put("message", "");
  926. return json.toString();
  927. } catch (Exception e) {
  928. JSONObject json = new JSONObject();
  929. json.put("code", "01");
  930. json.put("message", e.getLocalizedMessage());
  931. return json.toString();
  932. }
  933. }
  934. }