123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485 |
- package com.dbs.consentServer.controller;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.Optional;
- import javax.validation.Valid;
- import com.dbs.consentServer.DTO.User;
- import com.dbs.consentServer.DTO.hospitalDTO.PatientInfoDTO;
- import com.dbs.consentServer.DTO.hospitalDTO.PatientListDTO;
- import com.dbs.consentServer.VO.hospitalVO.ConsentFormCategoryVO;
- import com.dbs.consentServer.VO.hospitalVO.GetDoctorVO;
- import com.dbs.consentServer.VO.hospitalVO.GetPatientInfoVO;
- import com.dbs.consentServer.VO.hospitalVO.GetPatientVO;
- import com.dbs.consentServer.VO.hospitalVO.GetUserDeptVO;
- import com.dbs.consentServer.VO.hospitalVO.GetWardDeptVO;
- import com.dbs.consentServer.service.HospitalService;
- import com.dbs.consentServer.util.CommonUtils;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.http.HttpStatus;
- import org.springframework.http.ResponseEntity;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PutMapping;
- 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.RestController;
- import org.springframework.web.server.ResponseStatusException;
- import io.swagger.annotations.Api;
- @Api(tags = {"2. HospitalService "})
- @RestController
- @RequestMapping("/hospitalSvc")
- public class HospitalSvc {
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
- @Autowired
- private HospitalService hospitalService;
- /**
- * 기본정보 조회
- * @param instCd
- * @return
- */
- @RequestMapping(path="/GetBaseData", method=RequestMethod.POST)
- public ArrayList<HashMap<String, String>> GetBaseData(final String instCd) {
- final ArrayList<HashMap<String, String>> result = new ArrayList<HashMap<String, String>>();
- final HashMap<String, String> map = new HashMap<String, String>();
- String baseData = hospitalService.hospitalMapper.getBaseData(instCd);
- if (baseData == null) {
- baseData = "";
- }
- if (baseData.equals("")) {
- map.put("code", "01");
- } else {
- map.put("code", "00");
- map.put("data", baseData);
- }
- result.add(map);
- return result;
- }
- @GetMapping("GetBaseData")
- public ResponseEntity<String> GetBaseData(@RequestParam final Map<String, String> reqQeury){
- HttpStatus status = HttpStatus.OK;
- String body = "";
- final String instCd = Optional.ofNullable(reqQeury.get("instCd")).orElse("");
- if(instCd.equals("")){
- status = HttpStatus.BAD_REQUEST;
- body = "instCd MUST not be null";
- }
- else{
- // 람다 안에서 접근하려면 해당 타입의 array 로 접근하여야 한다. 더럽넹...
- // String[] bodyTemp = { null };
- HttpStatus[] statusTemp = { HttpStatus.OK };
- body = Optional.ofNullable(hospitalService.hospitalMapper.getBaseData(instCd))
- .filter(o -> !o.equals(""))
- .orElseGet(() -> {
- statusTemp[0] = HttpStatus.NO_CONTENT;
- // 204 일때 어딘가에서 body 를 짤라먹는뎅...
- return "no basecode found";
- });
- status = statusTemp[0];
- }
- return new ResponseEntity<String>(body, status);
- }
- /**
- * 기본 탭 설정(입원, 외래 등)
- * @param userId 사용자 아이디
- * @param status 상태 (입원 : I)
- * @param instCd
- */
- @RequestMapping(path="updateUserSetUp", method=RequestMethod.POST)
- public ArrayList<HashMap<String, Object>> updateUserSetup(final String userId, final String status, final String instCd) {
- final ArrayList<HashMap<String, Object>> result = new ArrayList<HashMap<String, Object>>();
- final HashMap<String, Object> map = new HashMap<String, Object>();
- final HashMap<String, String> params = new HashMap<String, String>();
- params.put("instCd", instCd);
- params.put("status", status);
- params.put("userId", userId);
-
- final int rts = hospitalService.updateUserSetUp(params);
- if (rts == 0) {
- map.put("code", "01");
- } else {
- map.put("code", "00");
- map.put("data", rts);
- }
- result.add(map);
- return result;
- }
- /**
- *
- * @param userSet
- * @return
- */
- @PutMapping("updateUserSetUp")
- public ResponseEntity<?> updateUserSetUp(@Valid User.UserSet userSet){
- HttpStatus[] status = { HttpStatus.OK };
- int updated = Optional.ofNullable(hospitalService.updateUserSetUp(userSet))
- .filter(o -> o >= 0)
- .orElseGet(() -> {
- status[0] = HttpStatus.NO_CONTENT;
- return 0;
- });
- return new ResponseEntity<Integer>(updated, status[0]);
- }
-
- /**
- * 로그인 프로세스
- * @param userId 사용자 ID
- * @param userPw 사용자 PW
- * @param dutInstCd 기관코드
- * @param certSucc 인증여부(문자열로 내려옴, true면 공인인증서 로그인을 통해 들어온것)
- * @return
- */
- @RequestMapping(path="/doLogin", method=RequestMethod.POST)
- public ArrayList<HashMap<String, Object>> doLogin(final String userId, final String userPw, final String dutInstCd, final String certSucc) {
- final ArrayList<HashMap<String, Object>> result = new ArrayList<HashMap<String, Object>>();
- final HashMap<String, Object> map = new HashMap<String, Object>();
- String encryptPw = hospitalService.hospitalMapper.doLogin(userId);
- if (encryptPw == null) {
- encryptPw = "";
- }
- if (certSucc.equals("false")) {
- if (!encryptPw.equals(userPw)) {
- map.put("code", "02");
- return result;
- }
- }
- final String sysCd = "HIS031";
- final HashMap<String, String> params = new HashMap<String, String>();
- params.put("userId", userId);
- params.put("sysCd", sysCd);
- final ArrayList<GetUserDeptVO> userDeptList = hospitalService.hospitalMapper.getUserDeptList(params);
- map.put("code", "00");
- map.put("data", userDeptList);
- result.add(map);
- return result;
- }
- /**
- * 병동 리스트
- * @param instCd
- * @return
- */
- @RequestMapping(path="/getWardList", method=RequestMethod.POST)
- public ArrayList<HashMap<String, Object>> getWardList(final String instCd) {
- final ArrayList<HashMap<String, Object>> result = new ArrayList<HashMap<String, Object>>();
- final HashMap<String, Object> map = new HashMap<String, Object>();
- final ArrayList<GetWardDeptVO> wardList = hospitalService.getWardList(instCd);
-
- if (wardList.size() == 0) {
- map.put("code", "01");
- } else {
- map.put("code", "00");
- map.put("data", wardList);
- }
- result.add(map);
- return result;
- }
- /**
- * 병동 리스트 조회
- *
- * @param reqQeury
- * @return
- * 검색된 병동 목록을 반환, instCd 가 null 일경우 BAD_REQUEST 반환
- * 병동 목록이 없을 경우 NO_CONTENT 반환
- */
- @GetMapping("getWardList")
- public ArrayList<GetWardDeptVO> getWardList(@RequestParam final Map<String, String> reqQeury) {
- final String instCd = Optional.ofNullable(reqQeury.get("instCd")).orElseThrow(() -> new ResponseStatusException(HttpStatus.BAD_REQUEST, "instCd is null"));
- return Optional.ofNullable(
- hospitalService.getWardList(instCd)).filter(o -> !o.isEmpty())
- .orElseThrow(() -> new ResponseStatusException(HttpStatus.NO_CONTENT, "no ward list found"));
- }
- /**
- * 진료과 리스트
- * @param instCd
- * @param ordType
- * @return
- */
- @RequestMapping(path="getDeptList", method=RequestMethod.POST)
- public ArrayList<HashMap<String, Object>> getDeptList(final String instCd, final String ordType) {
- final ArrayList<HashMap<String, Object>> result = new ArrayList<HashMap<String, Object>>();
- final HashMap<String, Object> map = new HashMap<>();
- final HashMap<String, String> params = new HashMap<String, String>();
- params.put("instCd", instCd);
- params.put("ordType", ordType);
- final ArrayList<GetWardDeptVO> deptList = hospitalService.getDeptList(params);
- if (deptList.size() == 0) {
- map.put("code", "01");
- } else {
- map.put("code", "00");
- map.put("data", deptList);
- }
- result.add(map);
- return result;
- }
- @GetMapping("getDeptList")
- public ArrayList<GetWardDeptVO> getDeptList(@RequestParam final Map<String, String> reqQeury) {
- final HashMap<String, String> params = new HashMap<>();
- params.put("instCd", Optional.ofNullable(reqQeury.get("instCd")).orElseThrow(() -> new ResponseStatusException(HttpStatus.BAD_REQUEST, "instCd is null")));
- params.put("ordType", Optional.ofNullable(reqQeury.get("ordType")).orElseThrow(() -> new ResponseStatusException(HttpStatus.BAD_REQUEST, "ordType is null")));
-
- return Optional.ofNullable(hospitalService.getDeptList(params)).filter(o -> !o.isEmpty())
- .orElseThrow(() -> new ResponseStatusException(HttpStatus.NO_CONTENT, "item not found"));
- }
- /**
- * 진료과에 따른 진료의 리스트
- * @param instCd
- * @param ordDeptCd
- * @param srchDd
- * @return
- */
- @RequestMapping(path="getDoctorList", method=RequestMethod.POST)
- public ArrayList<HashMap<String, Object>> getDoctorList(final String instCd, final String ordDeptCd, final String srchDd) {
- final ArrayList<HashMap<String, Object>> result = new ArrayList<HashMap<String, Object>>();
- final HashMap<String, Object> map = new HashMap<String, Object>();
- final HashMap<String, String> params = new HashMap<String, String>();
- params.put("instCd", instCd);
- params.put("ordDeptCd", ordDeptCd);
- params.put("srchDd", srchDd);
- final ArrayList<GetDoctorVO> doctorList = hospitalService.getDoctorList(params);
- if (doctorList.size() == 0) {
- map.put("code", "01");
- } else {
- map.put("code", "00");
- map.put("data", doctorList);
- }
- result.add(map);
- return result;
- }
- @GetMapping("getDoctorList")
- public ArrayList<GetDoctorVO> getDoctorList(@RequestParam final Map<String, String> reqQeury) {
- final HashMap<String, String> params = new HashMap<String, String>();
- params.put("instCd", Optional.ofNullable(reqQeury.get("instCd")).orElseThrow(() -> new ResponseStatusException(HttpStatus.BAD_REQUEST, "instCd is null")));
- params.put("ordDeptCd", Optional.ofNullable(reqQeury.get("ordDeptCd")).orElseThrow(() -> new ResponseStatusException(HttpStatus.BAD_REQUEST, "ordDeptCd is null")));
- params.put("srchDd", Optional.ofNullable(reqQeury.get("srchDd")).orElseThrow(() -> new ResponseStatusException(HttpStatus.BAD_REQUEST, "srchDd is null")));
- return Optional.ofNullable(hospitalService.getDoctorList(params)).filter(o -> !o.isEmpty())
- .orElseThrow(() -> new ResponseStatusException(HttpStatus.NO_CONTENT , "no doctor list found"));
- }
- /**
- * 환자 리스트 조회
- * @param patientListDTO
- * @return
- */
- @RequestMapping(path="getPatientList", method=RequestMethod.POST)
- public ArrayList<HashMap<String, Object>> getPatientList(final PatientListDTO patientListDTO) {
- final ArrayList<HashMap<String, Object>> result = new ArrayList<HashMap<String, Object>>();
- final HashMap<String, Object> map = new HashMap<String, Object>();
- ArrayList<GetPatientVO> patientList = new ArrayList<>();
- if (patientListDTO == null) {
- map.put("code", "01");
- map.put("data", patientList);
- result.add(map);
- return result;
- }
- String selectFlag = patientListDTO.getSelectFlag();
- final String patientState = patientListDTO.getPatientState();
- String myPatient = patientListDTO.getMyPatient();
- logger.debug("patientState -- > " + patientListDTO.getPatientState());
- if (selectFlag.equals("SR")) {
- if (patientState.equals("A")) {
- selectFlag = "I";
- } else if (patientState.equals("0")) {
- selectFlag = "O";
- } else if (patientState.equals("1")) {
- selectFlag = "1";
- }
- patientListDTO.setPatientState("");
- }
- if (myPatient.equals("")) {
- myPatient = "N";
- }
- patientListDTO.setMyPatient(myPatient);
- patientList = hospitalService.getPatientList(patientListDTO);
- if (patientList.size() == 0) {
- map.put("code", "02");
- } else {
- map.put("code", "00");
- }
- map.put("data", patientList);
- result.add(map);
- return result;
- }
- /**
- * 환자상세 정보 조회
- * @param patientInfoDTO
- * @return
- */
- @RequestMapping(path="getPatientInfo", method=RequestMethod.POST)
- public ArrayList<HashMap<String, Object>> getPatientInfo(final PatientInfoDTO patientInfoDTO) {
- final ArrayList<HashMap<String, Object>> result = new ArrayList<HashMap<String, Object>>();
- final HashMap<String, Object> map = new HashMap<String, Object>();
- ArrayList<GetPatientInfoVO> patientInfo = new ArrayList<GetPatientInfoVO>();
- if (patientInfoDTO == null) {
- map.put("code", "01");
- map.put("data", patientInfo);
- result.add(map);
- return result;
- }
- final String opRsrvNo = patientInfoDTO.getOpRsrvNo() == null ? "" : patientInfoDTO.getOpRsrvNo();
- patientInfoDTO.setOpRsrvNo(opRsrvNo);
- patientInfo = hospitalService.getPatientInfo(patientInfoDTO);
-
- if (patientInfo.size() == 0) {
- map.put("code", "02");
- } else {
- map.put("code", "00");
- }
- map.put("data", patientInfo);
- result.add(map);
- return result;
- }
- /**
- * 사용자 즐겨찾기 추가
- * 리턴이 0이면 실패 1이면 성공
- * @param userId 사용자 아이디
- * @param formCd 서식 코드
- * @param instCd 기관 코드
- */
- @RequestMapping(path="setUserFormSetList", method=RequestMethod.POST)
- public ArrayList<HashMap<String, Object>> setUserFormSetList(final String userId, final String formCd, final String instCd) {
- final ArrayList<HashMap<String, Object>> result = new ArrayList<HashMap<String, Object>>();
- final HashMap<String, Object> map = new HashMap<String, Object>();
- final HashMap<String, String> params = new HashMap<String, String>();
- params.put("userId", userId);
- params.put("formCd", formCd);
- params.put("instCd", instCd);
- logger.debug("params -- > " + params);
- final int rCount = hospitalService.setUserFormSet(params);
- logger.debug("result -- > " + result);
- if (rCount == 0) {
- map.put("code", "01");
- } else {
- map.put("code", "00");
- map.put("data", rCount);
- }
- result.add(map);
- return result;
- }
- /**
- * 즐겨찾기 삭제
- * 리턴이 0이면 실패 1이면 성공
- * @param idx
- * @param userId
- * @param formCd
- * @param instCd
- * @return
- */
- @RequestMapping(path="delUserFormSet", method=RequestMethod.POST)
- public ArrayList<HashMap<String, Object>> delUserFormSet(final String idx, final String userId, final String formCd, final String instCd) {
- final ArrayList<HashMap<String, Object>> result = new ArrayList<HashMap<String, Object>>();
- final HashMap<String, Object> map = new HashMap<String, Object>();
- final HashMap<Object, Object> params = new HashMap<Object, Object>();
- logger.debug("idx -- > " + idx);
- logger.debug("idx getClass-- > " + idx.getClass());
- final boolean intChk = CommonUtils.isNumeric(idx);
- if (intChk != true) {
- map.put("code", "01");
- result.add(map);
- return result;
- }
-
- params.put("idx", Integer.parseInt(idx));
- params.put("userId", userId);
- params.put("formCd", formCd);
- params.put("instCd", instCd);
- final int rCount = hospitalService.delUserFormSet(params);
- if (rCount == 0) {
- map.put("code", "02");
- } else {
- map.put("code", "00");
- map.put("data", rCount);
- }
- result.add(map);
- return result;
- }
- @RequestMapping(path="getConsentFormCategory", method=RequestMethod.POST)
- public ArrayList<HashMap<String, Object>> getConsentFormCategory() {
- final ArrayList<HashMap<String, Object>> result = new ArrayList<HashMap<String, Object>>();
- final HashMap<String, Object> map = new HashMap<String, Object>();
- ArrayList<ConsentFormCategoryVO> categoryList = new ArrayList<ConsentFormCategoryVO>();
- categoryList = hospitalService.getConsentFormCategory();
- if (categoryList.size() == 0) {
- map.put("code", "01");
- } else {
- map.put("code", "00");
- map.put("data", categoryList);
- }
- result.add(map);
- return result;
- }
- }
|