MobileHistoryController.java 11 KB

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