MobileHistoryController.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. package com.lemon.lifecenter.controller;
  2. import java.text.ParseException;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import javax.servlet.http.HttpServletRequest;
  6. import javax.servlet.http.HttpServletResponse;
  7. import org.slf4j.Logger;
  8. import org.slf4j.LoggerFactory;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.stereotype.Controller;
  11. import org.springframework.web.bind.annotation.RequestMapping;
  12. import org.springframework.web.bind.annotation.RequestParam;
  13. import org.springframework.web.servlet.ModelAndView;
  14. import com.lemon.lifecenter.common.LifeCenterController;
  15. import com.lemon.lifecenter.common.LifeCenterFunction;
  16. import com.lemon.lifecenter.common.LifeCenterSessionController;
  17. import com.lemon.lifecenter.dto.PatientDTO;
  18. import com.lemon.lifecenter.dto.PatientHealthDTO;
  19. import com.lemon.lifecenter.service.MobilePatientService;
  20. import com.lemon.lifecenter.service.PatientService;
  21. @Controller
  22. @RequestMapping("/mobile")
  23. public class MobileHistoryController extends LifeCenterController {
  24. private final Logger logger = LoggerFactory.getLogger(this.getClass());
  25. @Autowired
  26. private PatientService patientService;
  27. @Autowired
  28. private MobilePatientService patientMService;
  29. @Autowired
  30. private PatientService pService;
  31. @RequestMapping("/history")
  32. public ModelAndView history(
  33. @RequestParam( value="date", required=false, defaultValue="" ) String date,
  34. HttpServletRequest request, HttpServletResponse response) throws ParseException {
  35. String patientIdx = LifeCenterSessionController.getSession(request, "sesMpIdx");
  36. PatientHealthDTO hdto = new PatientHealthDTO();
  37. PatientHealthDTO historyData = new PatientHealthDTO();
  38. PatientDTO dto = new PatientDTO();
  39. dto.setPatientIdx(Integer.parseInt(patientIdx));
  40. int cnt = patientMService.selectMunJinCount(dto);
  41. if( date.equals( "" ) ){
  42. date = LifeCenterFunction.getNow( "yyyy-MM-dd" );
  43. }
  44. hdto.setCreateDate( date );
  45. hdto.setPatientIdx( Integer.valueOf( patientIdx ) );
  46. // 체온, 맥박수/혈압, 산소포화도, 혈당 기록이 하나라도 되있는지 체크
  47. int historyTotal = pService.selectPatientPhrHistoryTotal( hdto );
  48. if( historyTotal > 0 ) {
  49. historyData = pService.selectPatientPhrHistoryData( hdto );
  50. }
  51. List<PatientDTO> pdto = new ArrayList<PatientDTO>();
  52. List<PatientDTO> symptomData = new ArrayList<PatientDTO>();
  53. // 임상증상 데이터가 하나라도 기록되었는지 체크
  54. int symptomTotal = pService.selectPatientSymptomSimTotal( hdto );
  55. if( symptomTotal > 0 ) {
  56. pdto = pService.selectPatientSymptomSimData( hdto );
  57. }
  58. for( PatientDTO p : pdto ) {
  59. p.setSymptomContent( this.getSymptom( p ) );
  60. System.out.println(" this.getSymptom( p ): " + this.getSymptom( p ));
  61. symptomData.add( p );
  62. }
  63. ModelAndView mv = setMobileMV( "history/history" );
  64. mv.addObject( "historyTotal", historyTotal );
  65. mv.addObject( "historyData", historyData );
  66. mv.addObject( "symptomTotal", symptomTotal );
  67. mv.addObject( "symptomData", symptomData );
  68. mv.addObject( "date", date );
  69. mv.addObject( "prevDate", LifeCenterFunction.getPrevDate( date ) );
  70. mv.addObject( "nextDate", LifeCenterFunction.getNextDate( date ) );
  71. mv.addObject( "nowDate", LifeCenterFunction.getNow( "yyyy-MM-dd" ) );
  72. mv.addObject("munjinCnt", cnt);
  73. return mv;
  74. }
  75. @RequestMapping("/serveyhistory")
  76. public ModelAndView serveyhistory(
  77. HttpServletRequest request, HttpServletResponse response) {
  78. PatientDTO dto = new PatientDTO();
  79. String sesMpIdx = LifeCenterSessionController.getSession(request, "sesMpIdx");
  80. dto.setPatientIdx(Integer.parseInt(sesMpIdx));
  81. dto = patientService.selectPatientOne(dto);
  82. String hDate = dto.getHospitalizationDate();
  83. String cDate = dto.getConfirmationDate();
  84. String sDate = dto.getSymptomStartDate();
  85. String jumin = dto.getJumin();
  86. if (!hDate.equals("")) {
  87. hDate = hDate.split("-")[0] + "년 " + hDate.split("-")[1] + "월 " + hDate.split("-")[2] + "일";
  88. }
  89. if (!cDate.equals("")) {
  90. cDate = cDate.split("-")[0] + "년 " + cDate.split("-")[1] + "월 " + cDate.split("-")[2] + "일";
  91. }
  92. if (!sDate.equals("")) {
  93. sDate = sDate.split("-")[0] + "년 " + sDate.split("-")[1] + "월 " + sDate.split("-")[2] + "일";
  94. }
  95. if (!jumin.equals("")) {
  96. jumin = jumin.substring(0, 4) + "년 " + jumin.substring(4, 6) + "월 " + jumin.substring(6, 8) + "일";
  97. }
  98. dto.setHospitalizationDate(hDate);
  99. dto.setConfirmationDate(cDate);
  100. dto.setSymptomStartDate(sDate);
  101. dto.setJumin(jumin);
  102. String bloodPress = dto.getBloodPressureLevel();
  103. logger.error("bloodPress -- > " + bloodPress);
  104. if (!bloodPress.equals("")) {
  105. String[] bloodPressureLevel = dto.getBloodPressureLevel().split("[|]");
  106. dto.setBloodPressureLevelCon(bloodPressureLevel[0]);
  107. dto.setBloodPressureLevelRel(bloodPressureLevel[1]);
  108. }
  109. String strDisease = "";
  110. String strSymptom = getSymptom(dto);
  111. if (dto.getBasalDiseaseYn().equals("Y")) {
  112. strDisease = getDisease(dto);
  113. }
  114. ModelAndView mv = setMobileMV("history/serveyhistory");
  115. mv.addObject("info", dto);
  116. mv.addObject("disease", strDisease);
  117. mv.addObject("symptom", strSymptom);
  118. return mv;
  119. }
  120. private String getDisease(PatientDTO dto) {
  121. String highBloodPressureCheck = dto.getHighBloodPressureCheck().equals("Y") ? "고혈압" : "";
  122. String lowBloodPressureCheck = dto.getLowBloodPressureCheck().equals("Y") ? "저혈압" : "";
  123. String organTransplantCheck = dto.getOrganTransplantCheck().equals("Y") ? "장기이식(신장, 간 등)" : "";
  124. String diabetesCheck = dto.getDiabetesCheck().equals("Y") ? "당뇨" : "";
  125. String respiratoryDiseaseCheck = dto.getRespiratoryDiseaseCheck().equals("Y") ? "호흡기질환" : "";
  126. String immunologicalDiseaseCheck = dto.getImmunologicalDiseaseCheck().equals("Y") ? "면역질환(류마티스 등)" : "";
  127. String heartDisease = dto.getHeartDisease().equals("Y") ? "심장질환" : "";
  128. String liverDisease = dto.getLiverDisease().equals("Y") ? "간질환" : "";
  129. String operation = dto.getOperation().equals("Y") ? "수술" : "";
  130. String allergyCheck = dto.getAllergyCheck().equals("Y") ? "알레르기" : "";
  131. String kidneyDisease = dto.getKidneyDisease().equals("Y") ? "신장질환" : "";
  132. String cancerName = dto.getCancerName() == null ? "" : "(" + dto.getCancerName() + ")";
  133. String cancerCheck = dto.getCancerCheck().equals("Y") ? "암" + cancerName : "";
  134. String etcContent = dto.getEtcContentDisease() == null ? "" : dto.getEtcContentDisease();
  135. String ectCheckDisease = dto.getEtcCheckDisease().equals("Y") ? "기타(" + etcContent + ")" : "";
  136. ArrayList<String> disease = new ArrayList<String>();
  137. disease.add(highBloodPressureCheck);
  138. disease.add(lowBloodPressureCheck);
  139. disease.add(organTransplantCheck);
  140. disease.add(diabetesCheck);
  141. disease.add(respiratoryDiseaseCheck);
  142. disease.add(immunologicalDiseaseCheck);
  143. disease.add(heartDisease);
  144. disease.add(liverDisease);
  145. disease.add(operation);
  146. disease.add(allergyCheck);
  147. disease.add(kidneyDisease);
  148. disease.add(cancerCheck);
  149. disease.add(ectCheckDisease);
  150. String strDisease = "";
  151. for (int i = 0; i < disease.size(); i++) {
  152. String str = disease.get(i);
  153. if (!str.equals("")) {
  154. strDisease += str;
  155. strDisease += ", ";
  156. }
  157. }
  158. strDisease = strDisease.trim();
  159. if (!strDisease.equals("")) {
  160. strDisease = strDisease.substring(0, strDisease.length()-1);
  161. }
  162. return strDisease;
  163. }
  164. private String getSymptom(PatientDTO dto) {
  165. String feverCheck = dto.getFeverCheck().equals("Y") ? "열감(열나는 느낌)" : "";
  166. String coughCheck = dto.getCoughCheck().equals("Y") ? "기침" : "";
  167. String colic = dto.getColic().equals("Y") ? "복통(배아픔)" : "";
  168. String coldFitCheck = dto.getColdFitCheck().equals("Y") ? "오한(추운 느낌)" : "";
  169. String sputumCheck = dto.getSputumCheck().equals("Y") ? "가래" : "";
  170. String ocinCheck = dto.getOcinCheck().equals("Y") ? "오심(구역질)" : "";
  171. String chestPain = dto.getChestPain().equals("Y") ? "흉통" : "";
  172. String noseCheck = dto.getNoseCheck().equals("Y") ? "콧물 또는 코 막힘" : "";
  173. String vomitingCheck = dto.getVomitingCheck().equals("Y") ? "구토" : "";
  174. String musclePainCheck = dto.getMusclePainCheck().equals("Y") ? "근육통(몸살)" : "";
  175. String soreThroatCheck = dto.getSoreThroatCheck().equals("Y") ? "인후통(목 아픔)" : "";
  176. String diarrheaCheck = dto.getDiarrheaCheck().equals("Y") ? "설사" : "";
  177. String headacheCheck = dto.getHeadacheCheck().equals("Y") ? "두통(머리아픔)" : "";
  178. String dyspneaCheck = dto.getDyspneaCheck().equals("Y") ? "호흡곤란(숨가쁨)" : "";
  179. String fatigueCheck = dto.getFatigueCheck().equals("Y") ? "권태감(피로감)" : "";
  180. String etcContent = dto.getEtcContentSymptom() == null ? "" : dto.getEtcContentSymptom();
  181. String ectCheckSymptom = dto.getEtcCheckSymptom().equals("Y") ? "기타(" + etcContent + ")" : "";
  182. String strSymptom = "";
  183. ArrayList<String> symptom = new ArrayList<String>();
  184. symptom.add(feverCheck);
  185. symptom.add(coughCheck);
  186. symptom.add(colic);
  187. symptom.add(coldFitCheck);
  188. symptom.add(sputumCheck);
  189. symptom.add(ocinCheck);
  190. symptom.add(chestPain);
  191. symptom.add(noseCheck);
  192. symptom.add(vomitingCheck);
  193. symptom.add(musclePainCheck);
  194. symptom.add(soreThroatCheck);
  195. symptom.add(diarrheaCheck);
  196. symptom.add(headacheCheck);
  197. symptom.add(dyspneaCheck);
  198. symptom.add(fatigueCheck);
  199. symptom.add(ectCheckSymptom);
  200. for (int i = 0; i < symptom.size(); i++) {
  201. String str = symptom.get(i);
  202. if (!str.equals("")) {
  203. strSymptom += str;
  204. strSymptom += ", ";
  205. }
  206. }
  207. strSymptom = strSymptom.trim();
  208. if (!strSymptom.equals("")) {
  209. strSymptom = strSymptom.substring(0, strSymptom.length() - 1);
  210. }
  211. return strSymptom;
  212. }
  213. }