12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448 |
- package com.lemon.lifecenter.controller;
- import java.io.ByteArrayInputStream;
- import java.io.ByteArrayOutputStream;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.security.GeneralSecurityException;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Set;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.lemon.lifecenter.common.LifeCenterController;
- import com.lemon.lifecenter.common.LifeCenterFileDownload;
- import com.lemon.lifecenter.common.LifeCenterFunction;
- import com.lemon.lifecenter.common.LifeCenterSessionController;
- import com.lemon.lifecenter.dto.ClinicConfigurationDTO;
- import com.lemon.lifecenter.dto.FileDownloadDTO;
- import com.lemon.lifecenter.dto.MentalDTO;
- import com.lemon.lifecenter.dto.PatientDTO;
- import com.lemon.lifecenter.dto.PatientMemoDTO;
- import com.lemon.lifecenter.dto.PatientPHRHistoryDTO;
- import com.lemon.lifecenter.dto.PatientPHRLatestDTO;
- import com.lemon.lifecenter.dto.PatientSymptomSimDTO;
- import com.lemon.lifecenter.service.ClinicService;
- import com.lemon.lifecenter.service.FileDownloadService;
- import com.lemon.lifecenter.service.MentalService;
- import com.lemon.lifecenter.service.PHRService;
- import com.lemon.lifecenter.service.PatientService;
- import org.apache.poi.hssf.usermodel.HSSFCellStyle;
- import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
- import org.apache.poi.openxml4j.opc.OPCPackage;
- import org.apache.poi.poifs.crypt.EncryptionInfo;
- import org.apache.poi.poifs.crypt.EncryptionMode;
- import org.apache.poi.poifs.crypt.Encryptor;
- import org.apache.poi.poifs.filesystem.POIFSFileSystem;
- import org.apache.poi.ss.usermodel.Cell;
- import org.apache.poi.ss.usermodel.CellStyle;
- import org.apache.poi.ss.usermodel.Font;
- import org.apache.poi.ss.usermodel.IndexedColors;
- import org.apache.poi.ss.usermodel.Row;
- import org.apache.poi.ss.usermodel.Sheet;
- import org.apache.poi.ss.usermodel.Workbook;
- import org.apache.poi.xssf.usermodel.XSSFWorkbook;
- import org.json.JSONObject;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.ModelAttribute;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.servlet.ModelAndView;
- @Controller
- @RequestMapping("/clinic")
- public class ClinicController extends LifeCenterController {
- @Autowired
- private ClinicService clinicService;
- @Autowired
- private PHRService phrService;
- @Autowired
- private PatientService patientService;
-
- @Autowired
- private FileDownloadService fileDownloadService;
-
- @Autowired
- private MentalService mentalService;
-
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
- private enum FilterType {
- newPatient(0x01),
- alarm(0x02),
- temperatureBlank(0x04),
- bloodPressureBlank(0x08),
- pulseRateBlank(0x10),
- oxygenSaturationBlank(0x20),
- bloodSugarBlank(0x40),
- symptomBlank(0x80),
- mentalBlank(0x100);
-
- private final int value;
-
- FilterType(int value) {
- this.value = value;
- }
-
- public int getValue() {
- return value;
- }
- }
- private String[] parseFilter(String filter) {
- ArrayList<String> arrayList = new ArrayList<String>();
- try {
- int filterValue = Integer.parseInt(filter);
- for (FilterType f: FilterType.values()) {
- if ((filterValue & f.getValue()) == f.getValue()) {
- arrayList.add(f.name());
- System.out.println( f.name() );
- }
- }
- }
- catch( Exception e) {
- // 에러시 필터가 없는 것으로 간주
- }
-
- return arrayList.toArray(new String[arrayList.size()]);
- }
- @RequestMapping("/state")
- public ModelAndView clinicState(HttpServletRequest request,
- @RequestParam(value = "page", required = true, defaultValue = "1") int page,
- @RequestParam(value = "size", required = true, defaultValue = "30") int pageSize,
- @RequestParam(value = "searchText", required = false, defaultValue = "") String searchText,
- @RequestParam(value = "filter", required = false, defaultValue = "") String filter) {
- String centerCode = LifeCenterSessionController.getSession( request, "sesCenterCode" );
- PatientPHRLatestDTO dto = new PatientPHRLatestDTO();
- dto.setLimit((Integer.valueOf(page) - 1) * pageSize);
- dto.setLimitMax(pageSize);
- dto.setCenterCode(centerCode);
- dto.setSearchText(searchText);
- if (!filter.equals("")) {
- String[] filterList = parseFilter(filter);
- System.out.println( "#######################");
- System.out.println( filterList );
- System.out.println("#######################");
-
- if (filterList.length > 0) {
- dto.setFilterList(filterList);
- }
- }
-
- if (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 12) {
- dto.setTimeCriterion("AM");
- } else {
- dto.setTimeCriterion("PM");
- }
- int total = clinicService.selectPHRLatestCount(dto);
- // 서버사이드 렌더링 안함
- // List<PatientPHRLatestDTO> result = new ArrayList<PatientPHRLatestDTO>();
- //
- // if (total > 0) {
- // result = clinicService.selectPHRLatestList(dto);
- // }
- // 알람 임계치 정보
- ClinicConfigurationDTO configDto = new ClinicConfigurationDTO();
- configDto.setCenterCode(Integer.parseInt(centerCode));
- configDto = clinicService.selectConfiguration(configDto);
- ModelAndView mv = setMV("clinic/state");
- mv.addObject("page", page);
- mv.addObject("searchText", searchText);
- mv.addObject("filter", filter);
- mv.addObject("total", total);
- mv.addObject("config", configDto);
- // mv.addObject("items", result);
- return mv;
- }
- @RequestMapping("/info")
- public ModelAndView patientInfo(HttpServletRequest request,
- @RequestParam(value = "patientIdx", required = true, defaultValue = "") int patientIdx,
- @RequestParam(value = "refererSearch", required = false, defaultValue = "") String refererSearch,
- @RequestParam(value = "refererPage", required = false, defaultValue = "") String refererPage,
- @RequestParam(value = "refererFilter", required = false, defaultValue = "") String refererFilter) {
- String centerCode = LifeCenterSessionController.getSession( request, "sesCenterCode" );
-
- // 환자정보
- PatientDTO patientDto = new PatientDTO();
- patientDto.setPatientIdx(patientIdx);
- patientDto = patientService.selectPatientOne(patientDto);
- String jumin = patientDto.getJumin();
- jumin = LifeCenterFunction.changeJuminToBirthday(jumin);
- patientDto.setJumin(jumin);
-
- patientDto.setPatientPhone(LifeCenterFunction.phone(patientDto.getPatientPhone()));
- patientDto.setGuardianPhone(LifeCenterFunction.phone(patientDto.getGuardianPhone()));
-
- String bloodPress = patientDto.getBloodPressureLevel();
-
- if (!bloodPress.equals("") && !bloodPress.equals("|")) {
- String[] bloodPressureLevel = bloodPress.split("[|]");
- if (bloodPressureLevel[0] != null) {
- patientDto.setBloodPressureLevelCon(bloodPressureLevel[0]);
- }
- if (bloodPressureLevel[1] != null) {
- patientDto.setBloodPressureLevelRel(bloodPressureLevel[1]);
- }
- }
-
- String strDisease = "";
- String strSymptom = LifeCenterFunction.getSymptom(patientDto);
- if (patientDto.getBasalDiseaseYn().equals("Y")) {
- strDisease = LifeCenterFunction.getDisease(patientDto);
- }
- // 히스토리 데이터
- PatientPHRHistoryDTO dto = new PatientPHRHistoryDTO();
- dto.setPatientIdx(patientIdx);
- // 체온
- dto.setPhrType("temperature");
- List<PatientPHRHistoryDTO> temperatureResult = phrService.selectPHRHistoryList(dto);
- // 혈압
- dto.setPhrType("bloodPressure");
- List<PatientPHRHistoryDTO> bloodPressureResult = phrService.selectPHRHistoryList(dto);
- // 맥박
- dto.setPhrType("pulseRate");
- List<PatientPHRHistoryDTO> pulseRateResult = phrService.selectPHRHistoryList(dto);
- // 산소포화도
- dto.setPhrType("oxygenSaturation");
- List<PatientPHRHistoryDTO> oxygenSaturationResult = phrService.selectPHRHistoryList(dto);
- // 혈당
- dto.setPhrType("bloodSugar");
- List<PatientPHRHistoryDTO> bloodSugarResult = phrService.selectPHRHistoryList(dto);
- // 증상
- PatientSymptomSimDTO dto2 = new PatientSymptomSimDTO();
- dto2.setPatientIdx(patientIdx);
- List<PatientSymptomSimDTO> symptomResult = phrService.selectSymptomList(dto2);
- // 메모
- PatientMemoDTO dto3 = new PatientMemoDTO();
- dto3.setPatientIdx(patientIdx);
- List<PatientMemoDTO> memoResult = clinicService.selectMemoList(dto3);
- // response
- List<PatientPHRHistoryDTO> bloodPressureUnionResult = getBloodPressureUnionResult(patientIdx, bloodPressureResult, pulseRateResult);
- // 알람 임계치 정보
- ClinicConfigurationDTO configDto = new ClinicConfigurationDTO();
- configDto.setCenterCode(Integer.parseInt(centerCode));
- configDto = clinicService.selectConfiguration(configDto);
- // 정신건강 자가진단 추가 21.06.17
- MentalDTO mDTO = new MentalDTO();
- mDTO.setPatientIdx(patientIdx);
- List<MentalDTO> mentalList = new ArrayList<MentalDTO>();
- int mentalTotal = mentalService.selectMentalHealthTotalCount(mDTO);
- if( mentalTotal > 0 ) {
- mentalList = mentalService.selectMentalHealthTotalList(mDTO);
- }
-
- ModelAndView mv = setMV("clinic/info");
- // 정신건강 항목 데이터
- List<MentalDTO> mentalCheckList = mentalService.selectMentalHealthCheckList(mDTO);
- mv.addObject("mentalCheckList", mentalCheckList);
- mv.addObject("patientIdx", patientIdx);
- mv.addObject("info", patientDto);
- mv.addObject("symptom", strSymptom);
- mv.addObject("disease", strDisease);
- mv.addObject("temperatureResult", temperatureResult);
- mv.addObject("bloodPressureResult", bloodPressureResult);
- mv.addObject("pulseRateResult", pulseRateResult);
- mv.addObject("bloodPressureUnionResult", bloodPressureUnionResult);
- mv.addObject("oxygenSaturationResult", oxygenSaturationResult);
- mv.addObject("bloodSugarResult", bloodSugarResult);
- mv.addObject("symptomResult", symptomResult);
- mv.addObject("memoResult", memoResult);
- mv.addObject("refererSearch", refererSearch);
- mv.addObject("refererPage", refererPage);
- mv.addObject("refererFilter", refererFilter);
- mv.addObject("config", configDto);
- mv.addObject("mentalTotal" , mentalTotal);
- mv.addObject("mentalList" , mentalList);
- return mv;
- }
- @RequestMapping("/config")
- public ModelAndView clinicState(HttpServletRequest request) {
- String centerCode = LifeCenterSessionController.getSession( request, "sesCenterCode" );
- ClinicConfigurationDTO dto = new ClinicConfigurationDTO();
- dto.setCenterCode(Integer.parseInt(centerCode));
-
- dto = clinicService.selectConfiguration(dto);
- ModelAndView mv = setMV("clinic/config");
- mv.addObject("config", dto);
- return mv;
- }
- @RequestMapping("/api/state")
- public @ResponseBody String getStateAPI(HttpServletRequest request,
- @RequestParam(value = "page", required = true, defaultValue = "1") int page,
- @RequestParam(value = "size", required = true, defaultValue = "30") int pageSize,
- @RequestParam(value = "searchText", required = false, defaultValue = "") String searchText,
- @RequestParam(value = "filter", required = false, defaultValue = "") String filter,
- @RequestParam(value = "sortType", required = false, defaultValue = "") String sortType) {
- String centerCode = LifeCenterSessionController.getSession( request, "sesCenterCode" );
- PatientPHRLatestDTO dto = new PatientPHRLatestDTO();
- dto.setLimit((Integer.valueOf(page) - 1) * pageSize);
- dto.setLimitMax(pageSize);
- dto.setCenterCode(centerCode);
- dto.setSearchText(searchText);
- if (!filter.equals("")) {
- String[] filterList = parseFilter(filter);
- if (filterList.length > 0) {
- dto.setFilterList(filterList);
- }
- }
- if (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 12) {
- dto.setTimeCriterion("AM");
- } else {
- dto.setTimeCriterion("PM");
- }
-
- dto.setSortType(sortType);
- int total = clinicService.selectPHRLatestCount(dto);
- List<PatientPHRLatestDTO> result = new ArrayList<PatientPHRLatestDTO>();
- if (total > 0) {
- result = clinicService.selectPHRLatestList(dto);
- }
-
- JSONObject json = new JSONObject();
- json.put("count", total);
- json.put("items", result);
-
- return json.toString();
- }
- @RequestMapping("/api/phrDatas")
- public @ResponseBody List<PatientPHRHistoryDTO> getPhrDatasAPI(
- @RequestParam(value = "patientIdx", required = true, defaultValue = "") int patientIdx,
- @RequestParam(value = "phrType", required = true, defaultValue = "temperature") String phrType) {
- PatientPHRHistoryDTO dto = new PatientPHRHistoryDTO();
- dto.setPatientIdx(patientIdx);
- dto.setPhrType(phrType);
- List<PatientPHRHistoryDTO> result = phrService.selectPHRHistoryList(dto);
-
- boolean needPulseRate = phrType.equals("bloodPressure");
- if (needPulseRate) {
- PatientPHRHistoryDTO dto2 = new PatientPHRHistoryDTO();
- dto2.setPatientIdx(patientIdx);
- dto2.setPhrType("pulseRate");
- List<PatientPHRHistoryDTO> pulseRateResult = phrService.selectPHRHistoryList(dto2);
- List<PatientPHRHistoryDTO> bloodPressureUnionResult = getBloodPressureUnionResult(patientIdx, result, pulseRateResult);
- return bloodPressureUnionResult;
- }
- else {
- return result;
- }
- }
- @RequestMapping(value = "/api/phrData", method = RequestMethod.POST)
- public @ResponseBody String insertPhrDataAPI(@ModelAttribute("dto") final PatientPHRHistoryDTO dto) {
- try {
- phrService.insertPHR(dto);
-
- if (dto.getPhrValueExtra() != null) {
- PatientPHRHistoryDTO pulseRateDto = new PatientPHRHistoryDTO();
- pulseRateDto.setPatientIdx(dto.getPatientIdx());
- pulseRateDto.setPhrType("pulseRate");
- pulseRateDto.setPhrValue(dto.getPhrValueExtra());
- pulseRateDto.setRecordedByName(dto.getRecordedByName());
- if (dto.getRecordedById() != null) {
- pulseRateDto.setRecordedById(dto.getRecordedById());
- }
- if (dto.getRecordedDate() != null) {
- pulseRateDto.setRecordedDate(dto.getRecordedDate());
- }
- phrService.insertPHR(pulseRateDto);
- }
- JSONObject json = new JSONObject();
- json.put("code", "00");
- json.put("message", "");
- return json.toString();
- } catch (Exception e) {
- JSONObject json = new JSONObject();
- json.put("code", "01");
- json.put("message", e.getLocalizedMessage());
- return json.toString();
- }
- }
- @RequestMapping("/api/symptomDatas")
- public @ResponseBody List<PatientSymptomSimDTO> getSymptomDatasAPI(
- @RequestParam(value = "patientIdx", required = true, defaultValue = "") int patientIdx) {
- PatientSymptomSimDTO dto = new PatientSymptomSimDTO();
- dto.setPatientIdx(patientIdx);
- return phrService.selectSymptomList(dto);
- }
- @RequestMapping(value = "/api/symptomData", method = RequestMethod.POST)
- public @ResponseBody String insertSymptomDataAPI(@ModelAttribute("dto") final PatientSymptomSimDTO dto) {
- try {
- phrService.insertSymptom(dto);
- JSONObject json = new JSONObject();
- json.put("code", "00");
- json.put("message", "");
- return json.toString();
- } catch (Exception e) {
- JSONObject json = new JSONObject();
- json.put("code", "01");
- json.put("message", e.getLocalizedMessage());
- return json.toString();
- }
- }
- @RequestMapping("/api/memoDatas")
- public @ResponseBody List<PatientMemoDTO> getMemoDatasAPI(
- @RequestParam(value = "patientIdx", required = true, defaultValue = "") int patientIdx) {
- PatientMemoDTO dto = new PatientMemoDTO();
- dto.setPatientIdx(patientIdx);
- return clinicService.selectMemoList(dto);
- }
- @RequestMapping(value = "/api/memoData", method = RequestMethod.POST)
- public @ResponseBody String insertMemoDataAPI(@ModelAttribute("dto") final PatientMemoDTO dto) {
- try {
- clinicService.insertMemo(dto);
- JSONObject json = new JSONObject();
- json.put("code", "00");
- json.put("message", "");
- return json.toString();
- } catch (Exception e) {
- JSONObject json = new JSONObject();
- json.put("code", "01");
- json.put("message", e.getLocalizedMessage());
- return json.toString();
- }
- }
- @RequestMapping(value = "/api/memoData", method = RequestMethod.DELETE)
- public @ResponseBody String deleteMemoDataAPI(@ModelAttribute("dto") final PatientMemoDTO dto) {
- try {
- clinicService.deleteMemo(dto);
- JSONObject json = new JSONObject();
- json.put("code", "00");
- json.put("message", "");
- return json.toString();
- } catch (Exception e) {
- JSONObject json = new JSONObject();
- json.put("code", "01");
- json.put("message", e.getLocalizedMessage());
- return json.toString();
- }
- }
- @RequestMapping(value = "/api/memoData", method = RequestMethod.PATCH)
- public @ResponseBody String updateMemoDataAPI(@ModelAttribute("dto") final PatientMemoDTO dto) {
- try {
- clinicService.updateMemo(dto);
- JSONObject json = new JSONObject();
- json.put("code", "00");
- json.put("message", "");
- return json.toString();
- } catch (Exception e) {
- JSONObject json = new JSONObject();
- json.put("code", "01");
- json.put("message", e.getLocalizedMessage());
- return json.toString();
- }
- }
-
- private List<PatientPHRHistoryDTO> getBloodPressureUnionResult(int patientIdx, List<PatientPHRHistoryDTO> bloodPressureResult, List<PatientPHRHistoryDTO>pulseRateResult) {
- // 혈압 맥박 정리
- int bloodPressureIndex = 0;
- int pulseRateIndex = 0;
- List<PatientPHRHistoryDTO> bloodPressureUnionResult = new ArrayList<PatientPHRHistoryDTO>();
- while (bloodPressureIndex < bloodPressureResult.size() || pulseRateIndex < pulseRateResult.size()) {
- PatientPHRHistoryDTO union = new PatientPHRHistoryDTO();
- union.setPatientIdx(patientIdx);
- union.setPhrType("bloodPressure");
-
- if (bloodPressureIndex == bloodPressureResult.size()) {
- PatientPHRHistoryDTO pr = pulseRateResult.get(pulseRateIndex);
- union.setCreateDate(pr.getCreateDate());
- union.setRecordedDate(pr.getRecordedDate());
- union.setPhrValueExtra(pr.getPhrValue());
- union.setIsExtraWarning(pr.getIsWarning());
- union.setRecordedByName(pr.getRecordedByName());
- union.setRecordedById(pr.getRecordedById());
- bloodPressureUnionResult.add(union);
- pulseRateIndex += 1;
- continue;
- }
- else if (pulseRateIndex == pulseRateResult.size()) {
- PatientPHRHistoryDTO bp = bloodPressureResult.get(bloodPressureIndex);
- union.setCreateDate(bp.getCreateDate());
- union.setRecordedDate(bp.getRecordedDate());
- union.setPhrValue(bp.getPhrValue());
- union.setPhrValue2(bp.getPhrValue2());
- union.setIsWarning(bp.getIsWarning());
- union.setRecordedByName(bp.getRecordedByName());
- union.setRecordedById(bp.getRecordedById());
- bloodPressureUnionResult.add(union);
- bloodPressureIndex += 1;
- continue;
- }
- PatientPHRHistoryDTO bp = bloodPressureResult.get(bloodPressureIndex);
- PatientPHRHistoryDTO pr = pulseRateResult.get(pulseRateIndex);
- SimpleDateFormat originalFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String bpRecordedDateFormatted = bp.getRecordedDate();
- String prRecordedDateFormatted = pr.getRecordedDate();
- try {
- Date t = originalFormat.parse(bpRecordedDateFormatted);
- bpRecordedDateFormatted = targetFormat.format(t);
- Date t2 = originalFormat.parse(prRecordedDateFormatted);
- prRecordedDateFormatted = targetFormat.format(t2);
- }
- catch (Exception e) {
- }
- int dateDiffer = bpRecordedDateFormatted.compareTo(prRecordedDateFormatted);
- if (dateDiffer == 0) {
- union.setCreateDate(bp.getCreateDate());
- union.setRecordedDate(bp.getRecordedDate());
- union.setPhrValue(bp.getPhrValue());
- union.setPhrValue2(bp.getPhrValue2());
- union.setIsWarning(bp.getIsWarning());
- union.setRecordedByName(bp.getRecordedByName());
- union.setRecordedById(bp.getRecordedById());
- union.setPhrValueExtra(pr.getPhrValue());
- union.setIsExtraWarning(pr.getIsWarning());
- bloodPressureIndex += 1;
- pulseRateIndex += 1;
- }
- else if (dateDiffer < 0) {
- union.setCreateDate(bp.getCreateDate());
- union.setRecordedDate(bp.getRecordedDate());
- union.setPhrValue(bp.getPhrValue());
- union.setPhrValue2(bp.getPhrValue2());
- union.setIsWarning(bp.getIsWarning());
- union.setRecordedByName(bp.getRecordedByName());
- union.setRecordedById(bp.getRecordedById());
- bloodPressureIndex += 1;
- }
- else if (dateDiffer > 0) {
- union.setCreateDate(pr.getCreateDate());
- union.setRecordedDate(pr.getRecordedDate());
- union.setPhrValueExtra(pr.getPhrValue());
- union.setIsExtraWarning(pr.getIsWarning());
- union.setRecordedByName(pr.getRecordedByName());
- union.setRecordedById(pr.getRecordedById());
- pulseRateIndex += 1;
- }
- bloodPressureUnionResult.add(union);
- }
- return bloodPressureUnionResult;
- }
-
- @RequestMapping("/excel")
- public void getExcelFile(
- @RequestParam(value="phrType", required=true, defaultValue="temperature") String phrType,
- @RequestParam(value="patientIdx", required=true, defaultValue="") int patientIdx,
- @RequestParam(value="downMemo", required=true, defaultValue="") String downMemo,
- HttpServletRequest request, HttpServletResponse response ) {
- PatientDTO patientDto = new PatientDTO();
- patientDto.setPatientIdx(patientIdx);
- patientDto = patientService.selectPatientOne(patientDto);
-
- //excel 다운로드 로그 남기기
- String userId = LifeCenterSessionController.getSession(request, "sesId");
-
- FileDownloadDTO fileDTO = new FileDownloadDTO();
- fileDTO.setId( userId );
- fileDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) );
- fileDTO.setUrl( request.getRequestURI().toString() );
- fileDTO.setMemo( downMemo );
- fileDTO.setEtc( "진료관리, " + patientDto.getPatientName() + ", " + patientDto.getJumin() + ", " + Integer.toString(patientDto.getCenterCode()) );
- fileDTO.setPatientIdx( patientIdx );
- fileDownloadService.insertExcelDownloadLog( fileDTO );
-
- this.createExcel(request, response, patientDto);
- }
- private void createExcel(HttpServletRequest request, HttpServletResponse response, PatientDTO patientDto) {
- Workbook workbook = new XSSFWorkbook();
-
- // 셀 스타일 및 폰트 설정
- CellStyle styleOfBoardFillFontBlackBold16 = workbook.createCellStyle();
- // 정렬
- styleOfBoardFillFontBlackBold16.setAlignment(CellStyle.ALIGN_CENTER); //가운데 정렬
- styleOfBoardFillFontBlackBold16.setVerticalAlignment(CellStyle.VERTICAL_CENTER); //높이 가운데 정렬
- // 배경색
- styleOfBoardFillFontBlackBold16.setFillForegroundColor(IndexedColors.LIGHT_YELLOW.getIndex());
- styleOfBoardFillFontBlackBold16.setFillPattern(CellStyle.SOLID_FOREGROUND);
- // 테두리 선 (우,좌,위,아래)
- styleOfBoardFillFontBlackBold16.setBorderRight(HSSFCellStyle.BORDER_THIN);
- styleOfBoardFillFontBlackBold16.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- styleOfBoardFillFontBlackBold16.setBorderTop(HSSFCellStyle.BORDER_THIN);
- styleOfBoardFillFontBlackBold16.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- // 폰트 설정
- Font fontOfGothicBlackBold16 = workbook.createFont();
- // fontOfGothicBlackBold16.setFontName("나눔고딕"); //글씨체
- fontOfGothicBlackBold16.setFontHeight((short)(10*20)); //사이즈
- fontOfGothicBlackBold16.setBoldweight(Font.BOLDWEIGHT_BOLD); //볼드 (굵게)
- styleOfBoardFillFontBlackBold16.setFont(fontOfGothicBlackBold16);
-
- this.createPHRSheet(workbook, styleOfBoardFillFontBlackBold16, patientDto, "체온", "temperature");
- this.createPHRSheet(workbook, styleOfBoardFillFontBlackBold16, patientDto, "혈압", "bloodPressure");
- this.createPHRSheet(workbook, styleOfBoardFillFontBlackBold16, patientDto, "맥박", "pulseRate");
- this.createPHRSheet(workbook, styleOfBoardFillFontBlackBold16, patientDto, "산소포화도", "oxygenSaturation");
- this.createMentalSheet(workbook, styleOfBoardFillFontBlackBold16, patientDto);
- this.createPHRSheet(workbook, styleOfBoardFillFontBlackBold16, patientDto, "혈당", "bloodSugar");
-
- this.createSymptomSheet(workbook, styleOfBoardFillFontBlackBold16, patientDto);
-
- this.createMemoSheet(workbook, styleOfBoardFillFontBlackBold16, patientDto);
-
- try {
- // File file = new File(".");
- // String rootPath = file.getAbsolutePath();
- // System.out.println("현재 프로젝트의 경로 : "+rootPath );
-
- // JBOSS에서 구동시 /home1/jboss/jboss-eap-7.3/domain/test/excel-temp 경로에 저장이됨
- String directoryName = "../excel-temp/";
- File directory = new File(directoryName);
- if (! directory.exists()) {
- directory.mkdir();
- }
-
- String password = LifeCenterSessionController.getSession(request, "sesPhoneNumber");
- password = password.toLowerCase();
- if (!password.equals("null")) {
- password = password.replace("-", "");
- password = password.substring(3).trim();
- } else {
- password = "";
- }
-
- String timestamp = LifeCenterFunction.getNow("yyyy-MM-dd_HH-mm-ss");
- // 다운로드 파일 명: 호실_환자명(생년월일)_건강정보기록_다운로드일시.xlsx
- String downName = patientDto.getRoomNumber() + "_" + patientDto.getPatientName() + "(" + patientDto.getJumin() + ")_건강정보기록_" + timestamp + ".xlsx";
- String tempPath = directoryName + downName;
-
- File xlsFile = new File(tempPath);
- // FileOutputStream fileOut = new FileOutputStream(xlsFile);
- // workbook.write(fileOut);
- //
- // LifeCenterFileDownload.download(request, response, tempPath, downName);
- //
- // xlsFile.delete();
-
- ByteArrayOutputStream fileOut = new ByteArrayOutputStream();
- FileOutputStream fos = new FileOutputStream(tempPath);
- workbook.write(fileOut);
-
- InputStream filein = new ByteArrayInputStream(fileOut.toByteArray());
- OPCPackage opc = OPCPackage.open(filein);
- POIFSFileSystem fileSystem = new POIFSFileSystem();
- EncryptionInfo encryptionInfo = new EncryptionInfo(EncryptionMode.agile);
- Encryptor encryptor = encryptionInfo.getEncryptor();
- encryptor.confirmPassword(password);
- opc.save(encryptor.getDataStream(fileSystem));
- opc.flush();
-
- fileSystem.writeFilesystem(fos);
-
- fileOut.close();
- opc.close();
-
- filein.close();
- fileSystem.close();
-
- LifeCenterFileDownload.download(request, response, tempPath, downName);
- xlsFile.delete();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (InvalidFormatException e) {
- e.printStackTrace();
- } catch (GeneralSecurityException e) {
- e.printStackTrace();
- }
- }
-
- private void createPHRSheet(Workbook workbook, CellStyle styleOfBoardFillFontBlackBold16, PatientDTO patientDto, String phrTypeKorean, String phrType) {
- PatientPHRHistoryDTO patientPHRHistoryDto = new PatientPHRHistoryDTO();
- patientPHRHistoryDto.setPhrType(phrType);
- patientPHRHistoryDto.setPatientIdx(patientDto.getPatientIdx());
-
- int total = phrService.selectPHRHistoryCount(patientPHRHistoryDto);
- List<PatientPHRHistoryDTO> data = new ArrayList<PatientPHRHistoryDTO>();
- if (total > 0) {
- data = phrService.selectPHRHistoryList(patientPHRHistoryDto);
- }
-
- Sheet sheet1 = workbook.createSheet(phrTypeKorean);
- Row row = sheet1.createRow(0);
- Cell cell1 = row.createCell(0);
- Cell cell2 = row.createCell(1);
- Cell cell3 = row.createCell(2);
- Cell cell4 = row.createCell(3);
- Cell cell5 = row.createCell(4);
- Cell cell6 = row.createCell(5);
- cell1.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell2.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell3.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell4.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell5.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell6.setCellStyle(styleOfBoardFillFontBlackBold16);
- sheet1.setColumnWidth( 0, 5000); // 환자명
- sheet1.setColumnWidth( 1, 5000); // 생년월일
- sheet1.setColumnWidth( 2, 5000); // 동, 호실
- sheet1.setColumnWidth( 3, 5000); // 측정일시
- sheet1.setColumnWidth( 4, 3000); // 값
- sheet1.setColumnWidth( 5, 4000); // 기록자
-
- cell1.setCellValue("환자명");
- cell2.setCellValue("생년월일");
- cell3.setCellValue("동,호실");
- cell4.setCellValue("측정일시");
- cell5.setCellValue(phrTypeKorean);
- cell6.setCellValue("기록자");
-
- // 동,호실
- String roomNumber = "";
- if (!patientDto.getWardNumber().equals("")) {
- roomNumber = patientDto.getWardNumber() + "동";
- }
- roomNumber += patientDto.getRoomNumber() + "호";
-
- int i = 1;
- for (PatientPHRHistoryDTO dto : data) {
- row = sheet1.createRow(i);
- cell1 = row.createCell(0);
- cell2 = row.createCell(1);
- cell3 = row.createCell(2);
- cell4 = row.createCell(3);
- cell5 = row.createCell(4);
- cell6 = row.createCell(5);
- // 일시
- String recordedDate = null;
- SimpleDateFormat originalFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- Date t = originalFormat.parse(dto.getRecordedDate());
- recordedDate = targetFormat.format(t);
- } catch (Exception e) {
- recordedDate = dto.getRecordedDate();
- }
- // 값
- String phrValue = "";
- String phrValue2 = "";
- if (phrType.equals("temperature")) {
- phrValue = String.format("%.1f", dto.getPhrValue());
- phrValue2 = String.format("%.1f", dto.getPhrValue2());
- } else {
- phrValue = String.format("%.0f", dto.getPhrValue());
- phrValue2 = String.format("%.0f", dto.getPhrValue2());
- }
- // 기록자
- String recordedByName = dto.getRecordedByName();
- cell1.setCellValue(patientDto.getPatientName());
- cell2.setCellValue(patientDto.getJumin());
- cell3.setCellValue(roomNumber);
-
- cell4.setCellValue(recordedDate);
- if (phrType.equals("bloodPressure")) {
- cell5.setCellValue(phrValue + "/" + phrValue2);
- } else {
- cell5.setCellValue(phrValue);
- }
-
- cell6.setCellValue(recordedByName);
- i++;
- }
- }
-
- private void createSymptomSheet(Workbook workbook, CellStyle styleOfBoardFillFontBlackBold16, PatientDTO patientDto) {
-
- PatientSymptomSimDTO patientSymptomSimDto = new PatientSymptomSimDTO();
- patientSymptomSimDto.setPatientIdx(patientDto.getPatientIdx());
-
- int total = phrService.selectSymptomCount(patientSymptomSimDto);
- List<PatientSymptomSimDTO> data = new ArrayList<PatientSymptomSimDTO>();
- if (total > 0) {
- data = phrService.selectSymptomList(patientSymptomSimDto);
- }
-
- Sheet sheet1 = workbook.createSheet("임상증상");
-
- Row row = sheet1.createRow(0);
- Cell cell1 = row.createCell(0);
- Cell cell2 = row.createCell(1);
- Cell cell3 = row.createCell(2);
- Cell cell4 = row.createCell(3);
- Cell cell5 = row.createCell(4);
- Cell cell6 = row.createCell(5);
- Cell cell7 = row.createCell(6);
- Cell cell8 = row.createCell(7);
- Cell cell9 = row.createCell(8);
- Cell cell10 = row.createCell(9);
- Cell cell11 = row.createCell(10);
- Cell cell12 = row.createCell(11);
- Cell cell13 = row.createCell(12);
- Cell cell14 = row.createCell(13);
- Cell cell15 = row.createCell(14);
- Cell cell16 = row.createCell(15);
- Cell cell17 = row.createCell(16);
- Cell cell18 = row.createCell(17);
- Cell cell19 = row.createCell(18);
- Cell cell20 = row.createCell(19);
- Cell cell21 = row.createCell(20);
- cell1.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell2.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell3.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell4.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell5.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell6.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell7.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell8.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell9.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell10.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell11.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell12.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell13.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell14.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell15.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell16.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell17.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell18.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell19.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell20.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell21.setCellStyle(styleOfBoardFillFontBlackBold16);
- sheet1.setColumnWidth(0, 5000); // 환자명
- sheet1.setColumnWidth(1, 5000); // 생년월일
- sheet1.setColumnWidth(2, 5000); // 동호실
- sheet1.setColumnWidth(3, 5000); // 측정일시
- sheet1.setColumnWidth(4, 3000); // 기침
- sheet1.setColumnWidth(5, 3000); // 호흡곤란
- sheet1.setColumnWidth(6, 3000); // 오한
- sheet1.setColumnWidth(7, 3000); // 근육통
- sheet1.setColumnWidth(8, 3000); // 두통
- sheet1.setColumnWidth(9, 3000); // 인후통
- sheet1.setColumnWidth(10, 3000); // 후각/미각 손실
- sheet1.setColumnWidth(11, 3000); // 피로
- sheet1.setColumnWidth(12, 3000); // 식욕감소
- sheet1.setColumnWidth(13, 3000); // 가래
- sheet1.setColumnWidth(14, 3000); // 오심
- sheet1.setColumnWidth(15, 3000); // 구토
- sheet1.setColumnWidth(16, 3000); // 설사
- sheet1.setColumnWidth(17, 3000); // 어지러움
- sheet1.setColumnWidth(18, 3000); // 콧물/코막힘
- sheet1.setColumnWidth(19, 3000); // 기타증상
- sheet1.setColumnWidth(20, 5000); // 기록자
-
- cell1.setCellValue("환자명");
- cell2.setCellValue("생년월일");
- cell3.setCellValue("동,호실");
- cell4.setCellValue("측정일시");
- cell5.setCellValue("기침");
- cell6.setCellValue("호흡곤란");
- cell7.setCellValue("오한");
- cell8.setCellValue("근육통");
- cell9.setCellValue("두통");
- cell10.setCellValue("인후통");
- cell11.setCellValue("후각/미각 손실");
- cell12.setCellValue("피로");
- cell13.setCellValue("식욕감소");
- cell14.setCellValue("가래");
- cell15.setCellValue("오심");
- cell16.setCellValue("구토");
- cell17.setCellValue("설사");
- cell18.setCellValue("어지러움");
- cell19.setCellValue("콧물/코막힘");
- cell20.setCellValue("기타증상");
- cell21.setCellValue("기록자");
-
- // 동,호실
- String roomNumber = "";
- if (!patientDto.getWardNumber().equals("")) {
- roomNumber = patientDto.getWardNumber() + "동";
- }
- roomNumber += patientDto.getRoomNumber() + "호";
-
- int i = 1;
- for (int index = data.size() - 1; index >= 0; index--) {
- PatientSymptomSimDTO dto = data.get(index);
- row = sheet1.createRow(i);
- cell1 = row.createCell(0);
- cell2 = row.createCell(1);
- cell3 = row.createCell(2);
- cell4 = row.createCell(3);
- cell5 = row.createCell(4);
- cell6 = row.createCell(5);
- cell7 = row.createCell(6);
- cell8 = row.createCell(7);
- cell9 = row.createCell(8);
- cell10 = row.createCell(9);
- cell11 = row.createCell(10);
- cell12 = row.createCell(11);
- cell13 = row.createCell(12);
- cell14 = row.createCell(13);
- cell15 = row.createCell(14);
- cell16 = row.createCell(15);
- cell17 = row.createCell(16);
- cell18 = row.createCell(17);
- cell19 = row.createCell(18);
- cell20 = row.createCell(19);
- cell21 = row.createCell(20);
-
- String recordedDate = null;
- SimpleDateFormat originalFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- Date t = originalFormat.parse(dto.getRecordedDate());
- recordedDate = targetFormat.format(t);
- } catch (Exception e) {
- recordedDate = dto.getRecordedDate();
- }
-
- cell1.setCellValue(patientDto.getPatientName());
- cell2.setCellValue(patientDto.getJumin());
- cell3.setCellValue(roomNumber);
- cell4.setCellValue(recordedDate);
- cell5.setCellValue(dto.getCoughCheck().equals("Y") ? "V" : "-");
- cell6.setCellValue(dto.getDyspneaCheck().equals("Y") ? "V" : "-");
- cell7.setCellValue(dto.getColdFitCheck().equals("Y") ? "V" : "-");
- cell8.setCellValue(dto.getMusclePainCheck().equals("Y") ? "V" : "-");
- cell9.setCellValue(dto.getHeadacheCheck().equals("Y") ? "V" : "-");
- cell10.setCellValue(dto.getSoreThroatCheck().equals("Y") ? "V" : "-");
- cell11.setCellValue(dto.getSmellPalateCheck().equals("Y") ? "V" : "-");
- cell12.setCellValue(dto.getFatigueCheck().equals("Y") ? "V" : "-");
- cell13.setCellValue(dto.getAppetiteLossCheck().equals("Y") ? "V" : "-");
- cell14.setCellValue(dto.getSputumCheck().equals("Y") ? "V" : "-");
- cell15.setCellValue(dto.getOcinCheck().equals("Y") ? "V" : "-");
- cell16.setCellValue(dto.getVomitingCheck().equals("Y") ? "V" : "-");
- cell17.setCellValue(dto.getDiarrheaCheck().equals("Y") ? "V" : "-");
- cell18.setCellValue(dto.getDizzinessCheck().equals("Y") ? "V" : "-");
- cell19.setCellValue(dto.getNoseCheck().equals("Y") ? "V" : "-");
- cell20.setCellValue(dto.getEtcCheck().equals("Y") ? dto.getEtcContent() : "-");
- cell21.setCellValue(dto.getRecordedByName());
- i++;
- }
- }
-
- private void createMemoSheet(Workbook workbook, CellStyle styleOfBoardFillFontBlackBold16, PatientDTO patientDto) {
-
- PatientMemoDTO patientMemoDto = new PatientMemoDTO();
- patientMemoDto.setPatientIdx(patientDto.getPatientIdx());
-
- List<PatientMemoDTO> data = new ArrayList<PatientMemoDTO>();
- data = clinicService.selectMemoList(patientMemoDto);
-
- Sheet sheet1 = workbook.createSheet("의료진 메모");
-
- Row row = sheet1.createRow(0);
- Cell cell1 = row.createCell(0);
- Cell cell2 = row.createCell(1);
- Cell cell3 = row.createCell(2);
- Cell cell4 = row.createCell(3);
- Cell cell5 = row.createCell(4);
- Cell cell6 = row.createCell(5);
- cell1.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell2.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell3.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell4.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell5.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell6.setCellStyle(styleOfBoardFillFontBlackBold16);
- sheet1.setColumnWidth(0, 5000); // 환자명
- sheet1.setColumnWidth(1, 5000); // 생년월일
- sheet1.setColumnWidth(2, 5000); // 동호실
- sheet1.setColumnWidth(3, 5000); // 처리일시
- sheet1.setColumnWidth(4, 20000); // 내용
- sheet1.setColumnWidth(5, 3000); // 기록자
-
- cell1.setCellValue("환자명");
- cell2.setCellValue("생년월일");
- cell3.setCellValue("동,호실");
- cell4.setCellValue("처리일시");
- cell5.setCellValue("내용");
- cell6.setCellValue("기록자");
-
- // 동,호실
- String roomNumber = "";
- if (!patientDto.getWardNumber().equals("")) {
- roomNumber = patientDto.getWardNumber() + "동";
- }
- roomNumber += patientDto.getRoomNumber() + "호";
-
- int i = 1;
- for (int index = data.size() - 1; index >= 0; index--) {
- PatientMemoDTO dto = data.get(index);
- row = sheet1.createRow(i);
- cell1 = row.createCell(0);
- cell2 = row.createCell(1);
- cell3 = row.createCell(2);
- cell4 = row.createCell(3);
- cell5 = row.createCell(4);
- cell6 = row.createCell(5);
-
- String recordedDate = null;
- SimpleDateFormat originalFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- Date t = originalFormat.parse(dto.getRecordedDate());
- recordedDate = targetFormat.format(t);
- } catch (Exception e) {
- recordedDate = dto.getRecordedDate();
- }
-
- cell1.setCellValue(patientDto.getPatientName());
- cell2.setCellValue(patientDto.getJumin());
- cell3.setCellValue(roomNumber);
- cell4.setCellValue(recordedDate);
- cell5.setCellValue(dto.getContents());
- cell6.setCellValue(dto.getRecordedByName());
-
- CellStyle cs = workbook.createCellStyle();
- cs.setWrapText(true);
- cs.setVerticalAlignment(CellStyle.VERTICAL_CENTER); //높이 가운데 정렬
- cell5.setCellStyle(cs);
- i++;
- }
- }
-
- private void createMentalSheet(Workbook workbook, CellStyle styleOfBoardFillFontBlackBold16, PatientDTO patientDto) {
- // 정신건강 자가진단 추가 21.06.17
- MentalDTO mDTO = new MentalDTO();
- mDTO.setPatientIdx(patientDto.getPatientIdx());
- List<MentalDTO> data = new ArrayList<MentalDTO>();
- int mentalTotal = mentalService.selectMentalHealthTotalCount(mDTO);
- if (mentalTotal > 0) {
- data = mentalService.selectMentalHealthTotalList(mDTO);
- }
- Sheet sheet1 = workbook.createSheet("정신건강");
- Row row = sheet1.createRow(0);
- Cell cell1 = row.createCell(0);
- Cell cell2 = row.createCell(1);
- Cell cell3 = row.createCell(2);
- Cell cell4 = row.createCell(3);
- Cell cell5 = row.createCell(4);
- Cell cell6 = row.createCell(5);
- Cell cell7 = row.createCell(6);
- Cell cell8 = row.createCell(7);
- cell1.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell2.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell3.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell4.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell5.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell6.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell7.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell8.setCellStyle(styleOfBoardFillFontBlackBold16);
- sheet1.setColumnWidth(0, 5000); // 측정일시
- sheet1.setColumnWidth(1, 7000); // 외상후 스트레스 증상(총점)
- sheet1.setColumnWidth(2, 4000); // 우울(총점)
- sheet1.setColumnWidth(3, 5000); // 우울(9번 문항)
- sheet1.setColumnWidth(4, 3000); // VAS
- sheet1.setColumnWidth(5, 4000); // 상담연계동의
- sheet1.setColumnWidth(6, 4000); // 기록자
- sheet1.setColumnWidth(7, 5000); // 기록일
- cell1.setCellValue("측정일시");
- cell2.setCellValue("외상후 스트레스 증상(총점)");
- cell3.setCellValue("우울(총점)");
- cell4.setCellValue("우울(9번 문항)");
- cell5.setCellValue("VAS");
- cell6.setCellValue("상담연계동의");
- cell7.setCellValue("기록자");
- cell8.setCellValue("기록일");
- int i = 1;
- for (MentalDTO dto : data ) {
- row = sheet1.createRow(i);
- cell1 = row.createCell(0);
- cell2 = row.createCell(1);
- cell3 = row.createCell(2);
- cell4 = row.createCell(3);
- cell5 = row.createCell(4);
- cell6 = row.createCell(5);
- cell7 = row.createCell(6);
- cell8 = row.createCell(7);
- cell1.setCellValue( dto.getRecordedDate() );
- cell2.setCellValue( dto.getStressTotal() );
- cell3.setCellValue( dto.getDepressedTotal() );
- cell4.setCellValue( dto.getDepressedNine() );
- cell5.setCellValue( dto.getVasTotal() );
- cell6.setCellValue( dto.getAgreeYn().equals("Y") ? "동의" : "비동의" );
- cell7.setCellValue( dto.getCreatedBy() );
- cell8.setCellValue( dto.getCreateDate() );
- CellStyle cs = workbook.createCellStyle();
- cs.setWrapText(true);
- cs.setVerticalAlignment(CellStyle.VERTICAL_CENTER); // 높이 가운데 정렬
- cell5.setCellStyle(cs);
- i++;
- }
- }
- @RequestMapping("/api/configuration")
- public @ResponseBody ClinicConfigurationDTO getConfigurationAPI(
- @RequestParam(value = "centerCode", required = true, defaultValue = "") int centerCode) {
- ClinicConfigurationDTO dto = new ClinicConfigurationDTO();
- dto.setCenterCode(centerCode);
-
- return clinicService.selectConfiguration(dto);
- }
- @RequestMapping(value = "/api/configuration", method = RequestMethod.POST)
- public @ResponseBody String insertConfigurationAPI(@ModelAttribute("dto") final ClinicConfigurationDTO dto) {
- try {
- clinicService.insertConfiguration(dto);
- JSONObject json = new JSONObject();
- json.put("code", "00");
- json.put("message", "");
- return json.toString();
- } catch (Exception e) {
- JSONObject json = new JSONObject();
- json.put("code", "01");
- json.put("message", e.getLocalizedMessage());
- return json.toString();
- }
- }
- @RequestMapping(value = "/api/configuration", method = RequestMethod.DELETE)
- public @ResponseBody String deleteConfigurationAPI(@ModelAttribute("dto") final ClinicConfigurationDTO dto) {
- try {
- clinicService.deleteConfiguration(dto);
- JSONObject json = new JSONObject();
- json.put("code", "00");
- json.put("message", "");
- return json.toString();
- } catch (Exception e) {
- JSONObject json = new JSONObject();
- json.put("code", "01");
- json.put("message", e.getLocalizedMessage());
- return json.toString();
- }
- }
- @RequestMapping(value = "/api/configuration/display", method = RequestMethod.PATCH)
- public @ResponseBody String updateDisplayConfigurationAPI(@ModelAttribute("dto") final ClinicConfigurationDTO dto) {
- try {
- clinicService.updateDisplayConfiguration(dto);
- JSONObject json = new JSONObject();
- json.put("code", "00");
- json.put("message", "");
- return json.toString();
- } catch (Exception e) {
- JSONObject json = new JSONObject();
- json.put("code", "01");
- json.put("message", e.getLocalizedMessage());
- return json.toString();
- }
- }
-
- @RequestMapping(value = "/api/configuration/threshold", method = RequestMethod.PATCH)
- public @ResponseBody String updateThresholdConfigurationAPI(@ModelAttribute("dto") final ClinicConfigurationDTO dto) {
- try {
- clinicService.updateThresholdConfiguration(dto);
- JSONObject json = new JSONObject();
- json.put("code", "00");
- json.put("message", "");
- return json.toString();
- } catch (Exception e) {
- JSONObject json = new JSONObject();
- json.put("code", "01");
- json.put("message", e.getLocalizedMessage());
- return json.toString();
- }
- }
- @RequestMapping(value = "/api/mentalDetail", method = RequestMethod.POST)
- public @ResponseBody String selectMentalRecord(
- @RequestParam(value = "totalIdx", required = true ) int totalIdx,
- HttpServletRequest request ) {
- try {
- MentalDTO dto = new MentalDTO();
- dto.setTotalIdx(totalIdx);
-
- JSONObject json = new JSONObject();
-
- json.put("code", "00");
- json.put("data", mentalService.selectMentalHealthRecord(dto) );
-
- return json.toString();
-
- } catch (Exception e) {
- JSONObject json = new JSONObject();
- json.put("code", "01");
- json.put("message", e.getLocalizedMessage());
- return json.toString();
- }
- }
- @RequestMapping(value = "/api/mentalInsert", method = RequestMethod.POST)
- public @ResponseBody String insertMentalData(@ModelAttribute("dto") MentalDTO dto, HttpServletRequest request ) {
- try{
- Set<String> keySet = request.getParameterMap().keySet();
- String createdBy = LifeCenterSessionController.getSession(request, "sesName");
- String recordId = LifeCenterSessionController.getSession(request, "sesId");
- int patientIdx = dto.getPatientIdx();
-
- List<MentalDTO> mentalList = mentalService.selectMentalHealthCheckList(dto);
- HashMap<String, String> ml = new HashMap<String, String>();
-
- for (MentalDTO d : mentalList) {
- ml.put(d.getItemCode(), d.getEtcCode());
- }
-
- int stressTotal = 0;
- int depressedTotal = 0;
- int depressedNine = 0;
- int vasTotal = 0;
- String agreeYn = "";
- String recordedDate = "";
-
- // total 통계부터 insert 계산
- for (String key : keySet) {
- if (key.equals("recordedDate")) {
- System.out.println( "request.getParameter(key) : " + request.getParameter(key) );
- recordedDate = request.getParameter(key).equals("") ? LifeCenterFunction.getNow("yyyy-MM-dd HH:mm").toString(): request
- .getParameter(key);
- continue;
- }
- if (key.equals("patientIdx")) continue;
-
- dto = new MentalDTO();
- String itemCode = key.trim();
-
- int itemScore = Integer.valueOf(request.getParameter(key));
-
- if (itemCode.equals("agree")) {
- agreeYn = itemScore == 1 ? "Y" : "N";
- continue;
- }
-
-
- if (ml.get(key).equals("stress")) {
- stressTotal += itemScore;
- } else if (ml.get(key).equals("depressed")) {
- // 우울-> 9번항목 itemCode는 A0016이다
- if (key.equals("A0016")) {
- depressedNine = itemScore;
- }
-
- // 우울 마지막항목 itemCode는 A0017이다 마지막항목은 총점제외
- if (!itemCode.equals("A0017")) {
- depressedTotal += itemScore;
- }
- } else if (ml.get(key).equals("vas")) {
- vasTotal += itemScore;
- }
-
- }
-
- dto.setPatientIdx(patientIdx);
- dto.setCreatedBy(createdBy);
- dto.setStressTotal(stressTotal);
- dto.setDepressedTotal(depressedTotal);
- dto.setDepressedNine(depressedNine);
- dto.setVasTotal(vasTotal);
- dto.setAgreeYn(agreeYn);
- dto.setRecordId(recordId);
- mentalService.insertMentalHealthTotal(dto);
- int totalIdx = dto.getIdx();
-
- // detail 상세점수
- for (String key : keySet) {
- if (key.equals("patientIdx"))
- continue;
- if (key.equals("agree"))
- continue;
- if (key.equals("recordedDate"))
- continue;
-
- dto = new MentalDTO();
- int itemScore = Integer.valueOf(request.getParameter(key));
- String itemCode = key.trim();
-
- dto.setTotalIdx(totalIdx);
- dto.setPatientIdx(patientIdx);
- dto.setCreatedBy(createdBy);
- dto.setItemCode(itemCode);
- dto.setItemScore(itemScore);
-
- mentalService.insertMentalHealthRecord(dto);
- }
-
- JSONObject json = new JSONObject();
-
- json.put("createDate", LifeCenterFunction.getNow("yyyy-MM-dd HH:mm").toString() );
- json.put("stressTotal", stressTotal);
- json.put("depressedTotal", depressedTotal);
- json.put("depressedNine", depressedNine);
- json.put("vasTotal", vasTotal);
- json.put("agreeYn", agreeYn);
- json.put("createdBy", createdBy);
- json.put("recordedDate", recordedDate);
- json.put("totalIdx", totalIdx);
-
-
- json.put("code", "00");
- json.put("message", "");
- return json.toString();
- } catch (Exception e) {
- JSONObject json = new JSONObject();
- json.put("code", "01");
- json.put("message", e.getLocalizedMessage());
- return json.toString();
- }
- }
- }
|