Merge branch 'dev/technical-debt/clean-code' of ssh://172.16.55.31/volume1/git/SC-be-java into dev/technical-debt/clean-code

This commit is contained in:
Salman Manoe 2024-12-17 08:13:36 +07:00
commit 980ba07f9f
22 changed files with 973 additions and 1960 deletions

View File

@ -1,126 +1,106 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AdmisiRencanaPindahRuanganService;
import com.jasamedika.medifirst2000.vo.AdmisiRencanaPindahRuanganVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
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 com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.entities.AdmisiRencanaPindahRuangan;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AdmisiRencanaPindahRuanganService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.AdmisiRencanaPindahRuanganVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttptatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController
@RequestMapping("/admisi-rencana-pasien")
public class AdmisiRencanaPindahRuanganController extends LocaleController<AdmisiRencanaPindahRuanganVO>{
public class AdmisiRencanaPindahRuanganController extends LocaleController<AdmisiRencanaPindahRuanganVO> {
@Autowired
private AdmisiRencanaPindahRuanganService service;
private static final Logger LOGGER = LoggerFactory.getLogger(AdmisiRencanaPindahRuanganController.class);
@RequestMapping(value = "/save-admisi-rencana", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> saveAdmisiRencana(@Valid @RequestBody AdmisiRencanaPindahRuanganVO vo,HttpServletRequest request) {
try {
Map<String,Object> result = service.save(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
private AdmisiRencanaPindahRuanganService service;
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when saveB3RuanganInputData", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when saveB3RuanganInputData", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-admisi-rencana", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getDataGrid(
@RequestParam(value = "startDate", required = false) String startDate,
@RequestParam(value = "endDate", required = false) String endDate,
private static final Logger LOGGER = LoggerFactory.getLogger(AdmisiRencanaPindahRuanganController.class);
@RequestMapping(value = "/save-admisi-rencana", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveAdmisiRencana(@Valid @RequestBody AdmisiRencanaPindahRuanganVO vo,
HttpServletRequest request) {
try {
Map<String,Object> result = service.getDataGrid(startDate,endDate);
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
} else{
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
Map<String, Object> result = service.save(vo);
if (null != result)
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got ServiceVOException {} when save", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got JpaSystemException {} when save", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-admisi-rencana", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getDataGrid(
@RequestParam(value = "startDate", required = false) String startDate,
@RequestParam(value = "endDate", required = false) String endDate, HttpServletRequest request) {
try {
Map<String, Object> result = service.getDataGrid(startDate, endDate);
if (null != result) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getDataGrid", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getDataGrid", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getDataGrid", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getDataGrid", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/get-one-admisi-rencana")
public Map<String,Object> getOneDataGrid(
@RequestParam(value = "noRec", required = false) String noRec) {
Map<String,Object> result = service.getOneDataGrid(noRec);
return result;
public Map<String, Object> getOneDataGrid(@RequestParam(value = "noRec", required = false) String noRec) {
return service.getOneDataGrid(noRec);
}
@RequestMapping(value = "/update-admisi-rencana", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> updateAdmisiRencana(@Valid @RequestBody AdmisiRencanaPindahRuanganVO vo,HttpServletRequest request) {
try {
Map<String,Object> result = service.update(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
@RequestMapping(value = "/update-admisi-rencana", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> updateAdmisiRencana(@Valid @RequestBody AdmisiRencanaPindahRuanganVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = service.update(vo);
if (null != result)
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when saveB3RuanganInputData", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when update", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when saveB3RuanganInputData", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got exception {} when update", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/find-admisi-rencana")
public Map<String,Object> findAdmisiRencana(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "100") Integer limit,
@RequestParam(value = "sort", required = false, defaultValue = "noRec") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@RequestParam(value = "tanggalAwal", required = false) String tanggalAwal,
@RequestParam(value = "tanggalAhir", required = false) String tanggalAhir) {
Map<String, Object> resultPageMap = service.findAdmisiRencana(page, limit, sort, dir, tanggalAwal, tanggalAhir);
return resultPageMap;
}
}

View File

@ -1,179 +1,148 @@
package com.jasamedika.medifirst2000.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
package com.jasamedika.medifirst2000.controller;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AdvokasiHukumMedicolegalService;
import com.jasamedika.medifirst2000.vo.UsulanEvaluasiVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
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 com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AdvokasiHukumMedicolegalService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.UsulanEvaluasiVO;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttptatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController
@RequestMapping("/advokasi-hukum-medicolegal")
public class AdvokasiHukumMedicolegalController extends LocaleController<UsulanEvaluasiVO>
{
private static final Logger LOGGER = LoggerFactory.getLogger(AdvokasiHukumMedicolegalController.class);
public class AdvokasiHukumMedicolegalController extends LocaleController<UsulanEvaluasiVO> {
private static final Logger LOGGER = LoggerFactory.getLogger(AdvokasiHukumMedicolegalController.class);
@Autowired
private AdvokasiHukumMedicolegalService advokasiHukumMedicolegalService;
@RequestMapping( value = "/save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> saveEvaluasiRekanan(
@RequestBody UsulanEvaluasiVO vo, HttpServletRequest request) {
@RequestMapping(value = "/save", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<String> saveEvaluasiRekanan(@RequestBody UsulanEvaluasiVO vo, HttpServletRequest request) {
try {
String result = advokasiHukumMedicolegalService.saveEvaluasiRekanan(vo);
if (result != null)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when savePlanningDHM", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when saveEvaluasiRekanan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when savePlanningDHM", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
LOGGER.error("Got JpaSystemException {} when saveEvaluasiRekanan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-no-evaluasi", method = RequestMethod.GET)
public ResponseEntity<Map<String,Object>> getNoEvaluasi(HttpServletRequest request) {
@RequestMapping(value = "/get-no-evaluasi", method = GET)
public ResponseEntity<Map<String, Object>> getNoEvaluasi(HttpServletRequest request) {
try {
String noSurat= advokasiHukumMedicolegalService.noAdvokasiHukumMedicolegal();
Map<String,Object> result=new HashMap<String,Object>();
String noSurat = advokasiHukumMedicolegalService.noAdvokasiHukumMedicolegal();
Map<String, Object> result = new HashMap<>();
result.put("noSurat", noSurat);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add nota-dinas", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when noAdvokasiHukumMedicolegal", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add nota-dinas", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
LOGGER.error("Got exception {} when noAdvokasiHukumMedicolegal", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-list-evaluasi-by-ruangan-tujuan", method = RequestMethod.GET)
public ResponseEntity<List<Map<String,Object>>> getListUsulanEvaluasiByRuanganTujuan(
@RequestMapping(value = "/get-list-evaluasi-by-ruangan-tujuan", method = GET)
public ResponseEntity<List<Map<String, Object>>> getListUsulanEvaluasiByRuanganTujuan(
@RequestParam(value = "noUsulan", required = false) String noUsulan,
@RequestParam(value = "tglAwal", required = true)String tglAwal,
@RequestParam(value = "tglAkhir", required = true)String tglAkhir,
@RequestParam(value = "ruanganId", required = true)Integer ruanganId,
HttpServletRequest request) {
@RequestParam(value = "tglAwal") String tglAwal, @RequestParam(value = "tglAkhir") String tglAkhir,
@RequestParam(value = "ruanganId") Integer ruanganId, HttpServletRequest request) {
try {
List<Map<String,Object>> noSurat= advokasiHukumMedicolegalService.listAdvokasiHukumMedicolegalByRuanganTujuan(tglAwal, tglAkhir,noUsulan,ruanganId);
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(noSurat, HttpStatus.OK,mapHeaderMessage);
List<Map<String, Object>> noSurat = advokasiHukumMedicolegalService
.listAdvokasiHukumMedicolegalByRuanganTujuan(tglAwal, tglAkhir, noUsulan, ruanganId);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(noSurat, OK, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add nota-dinas", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when listAdvokasiHukumMedicolegalByRuanganTujuan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add nota-dinas", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
LOGGER.error("Got JpaSystemException {} when listAdvokasiHukumMedicolegalByRuanganTujuan",
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-list-evaluasi-by-ruangan-pembuat", method = RequestMethod.GET)
public ResponseEntity<List<Map<String,Object>>> getListUsulanEvaluasiByRuanganPembuat(
@RequestMapping(value = "/get-list-evaluasi-by-ruangan-pembuat", method = GET)
public ResponseEntity<List<Map<String, Object>>> getListUsulanEvaluasiByRuanganPembuat(
@RequestParam(value = "noUsulan", required = false) String noUsulan,
@RequestParam(value = "tglAwal", required = true)String tglAwal,
@RequestParam(value = "tglAkhir", required = true)String tglAkhir,
@RequestParam(value = "ruanganId", required = true)Integer ruanganId,
HttpServletRequest request) {
@RequestParam(value = "tglAwal") String tglAwal, @RequestParam(value = "tglAkhir") String tglAkhir,
@RequestParam(value = "ruanganId") Integer ruanganId, HttpServletRequest request) {
try {
List<Map<String,Object>> noSurat= advokasiHukumMedicolegalService.listAdvokasiHukumMedicolegalByRuanganPembuat(tglAwal, tglAkhir, noUsulan, ruanganId);
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(noSurat, HttpStatus.OK,mapHeaderMessage);
List<Map<String, Object>> noSurat = advokasiHukumMedicolegalService
.listAdvokasiHukumMedicolegalByRuanganPembuat(tglAwal, tglAkhir, noUsulan, ruanganId);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(noSurat, OK, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add nota-dinas", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when listAdvokasiHukumMedicolegalByRuanganPembuat", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add nota-dinas", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
LOGGER.error("Got exception {} when listAdvokasiHukumMedicolegalByRuanganPembuat", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-by-nousulan/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> getUsulanEvaluasiByNoUsulan(
@RequestParam(value = "noUsulan", required = true) String noUsulan) {
Map<String,Object> resultPageMap = advokasiHukumMedicolegalService.advokasiHukumMedicolegalByNoUsulan(noUsulan);
return RestUtil.getJsonResponse(resultPageMap, HttpStatus.OK, mapHeaderMessage);
@RequestMapping(value = "/get-by-nousulan/", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getUsulanEvaluasiByNoUsulan(
@RequestParam(value = "noUsulan") String noUsulan) {
Map<String, Object> resultPageMap = advokasiHukumMedicolegalService
.advokasiHukumMedicolegalByNoUsulan(noUsulan);
return getJsonResponse(resultPageMap, OK, mapHeaderMessage);
}
@RequestMapping( value = "/save-rekomendasi", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> saveRekomendasi(
@RequestBody UsulanEvaluasiVO vo, HttpServletRequest request) {
@RequestMapping(value = "/save-rekomendasi", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveRekomendasi(@RequestBody UsulanEvaluasiVO vo,
HttpServletRequest request) {
try {
Map<String,Object> result = advokasiHukumMedicolegalService.saveRekomendasiEvaluasiRekanan(vo);
Map<String, Object> result = advokasiHukumMedicolegalService.saveRekomendasiEvaluasiRekanan(vo);
if (result != null)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when savePlanningDHM", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when saveRekomendasiEvaluasiRekanan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when savePlanningDHM", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
LOGGER.error("Got JpaSystemException {} when saveRekomendasiEvaluasiRekanan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
}

View File

@ -1,7 +1,6 @@
package com.jasamedika.medifirst2000.controller;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.entities.Agama;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
@ -10,7 +9,6 @@ import com.jasamedika.medifirst2000.vo.AgamaVO;
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.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
@ -21,7 +19,6 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
@ -35,24 +32,13 @@ import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController
@RequestMapping("/agama")
public class AgamaController extends LocaleController<AgamaVO> implements IBaseRestController<AgamaVO> {
public class AgamaController extends LocaleController<AgamaVO> {
@Autowired
private AgamaService<Agama> agamaService;
private static final Logger LOGGER = LoggerFactory.getLogger(AgamaController.class);
@Override
public ResponseEntity<Collection<AgamaVO>> getAllVOWithQueryString(HttpServletRequest request, Integer page,
Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<AgamaVO> getVO(Integer id) {
return null;
}
@RequestMapping(value = "/save-agama/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<String> addVO(@Valid @RequestBody AgamaVO vo, HttpServletRequest request) {
try {
@ -61,11 +47,11 @@ public class AgamaController extends LocaleController<AgamaVO> implements IBaseR
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse("", CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got ServiceVOException {} when save Agama", e.getMessage());
LOGGER.error("Got ServiceVOException {} when add", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got JpaSystemException {} when save Agama", jse.getMessage());
LOGGER.error("Got JpaSystemException {} when add", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
@ -78,11 +64,11 @@ public class AgamaController extends LocaleController<AgamaVO> implements IBaseR
if (null != result)
return getJsonResponse("", OK);
} catch (ServiceVOException e) {
LOGGER.error("Got ServiceVOException {} when update Agama", e.getMessage());
LOGGER.error("Got ServiceVOException {} when update", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got JpaSystemException {} when update Agama", jse.getMessage());
LOGGER.error("Got JpaSystemException {} when update", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
@ -95,23 +81,17 @@ public class AgamaController extends LocaleController<AgamaVO> implements IBaseR
if (agamaService.delete(id))
return getJsonResponse("", CREATED);
} catch (ServiceVOException e) {
LOGGER.error("Got ServiceVOException {} when delete Agama", e.getMessage());
LOGGER.error("Got ServiceVOException {} when delete", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got JpaSystemException {} when delete Agama", jse.getMessage());
LOGGER.error("Got JpaSystemException {} when delete", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
return getJsonHttptatus(NOT_ACCEPTABLE);
}
@Override
public ResponseEntity<List<AgamaVO>> getAllVO() {
List<AgamaVO> agamaList = agamaService.findAll();
return getJsonResponse(agamaList, HttpStatus.OK);
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/search-agama", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Collection<AgamaVO>> getAllVOWithQueryString(
@ -124,9 +104,4 @@ public class AgamaController extends LocaleController<AgamaVO> implements IBaseR
return constructListPageResult(resultPageMap);
}
@Override
public ResponseEntity<String> addVO(AgamaVO vo) {
return null;
}
}

View File

@ -1,77 +0,0 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AkunService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.AkunVO;
@RestController
@RequestMapping("/akun")
public class AkunController extends LocaleController<AkunVO>{
@Autowired
private AkunService akunService;
private static final Logger LOGGER = LoggerFactory
.getLogger(AkunController.class);
@RequestMapping(value = "/save-akun",
method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveAkun(@Valid @RequestBody AkunVO vo, HttpServletRequest request) {
try {
Map<String,Object> result = akunService.saveAkun(vo);
if (null != result);
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when saveAkun", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when saveAkun", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/find-all-akun", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> findAllAkun(HttpServletRequest request) {
Map<String, Object> result=null;
try {
result = akunService.findAllAkun();
Boolean dataFound = new Boolean((boolean) result.get("dataFound"));
if (dataFound) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
} else {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR, getMessage(MessageResource.LABEL_ERROR, request));
}
}catch(Exception ex){
ex.printStackTrace();
}
return RestUtil.getJsonResponse(result, HttpStatus.OK);
}
}

View File

@ -1,43 +1,19 @@
package com.jasamedika.medifirst2000.controller;
import java.awt.Rectangle;
import java.util.Collection;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriComponentsBuilder;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.entities.AgamaM;
import com.jasamedika.medifirst2000.entities.Pasien;
import com.jasamedika.medifirst2000.entities.PurchasedTest;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.entities.Alamat;
import com.jasamedika.medifirst2000.service.AlamatService;
import com.jasamedika.medifirst2000.service.ModelService;
import com.jasamedika.medifirst2000.service.PasienService;
//import com.jasamedika.medifirst2000.service.TestService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.AlamatVO;
import com.jasamedika.medifirst2000.vo.ModelVO;
import com.jasamedika.medifirst2000.vo.ModelVO;
import com.jasamedika.medifirst2000.vo.PasienVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.OK;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
/**
* Controller class for Pasien Business
@ -46,52 +22,21 @@ import com.jasamedika.medifirst2000.vo.PasienVO;
*/
@RestController
@RequestMapping("/alamat")
public class AlamatController extends LocaleController<PasienVO> implements IBaseRestController<AlamatVO> {
public class AlamatController extends LocaleController<PasienVO> {
@Autowired
private AlamatService alamatService;
private AlamatService<Alamat> alamatService;
@Override
public ResponseEntity<String> addVO(AlamatVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(AlamatVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<AlamatVO>> getAllVO() {
return null;
}
@RequestMapping(value = "/cari-alamat-id/{id}", method = RequestMethod.GET)
@RequestMapping(value = "/cari-alamat-id/{id}", method = GET)
public ResponseEntity<AlamatVO> getVO(@PathVariable("id") Integer id) {
AlamatVO alamatVO = alamatService.findById(id);
return RestUtil.getJsonResponse(alamatVO, HttpStatus.OK);
return getJsonResponse(alamatVO, OK);
}
@RequestMapping(value = "/cari-alamat-by-pasien-id/{id}", method = RequestMethod.GET)
@RequestMapping(value = "/cari-alamat-by-pasien-id/{id}", method = GET)
public ResponseEntity<AlamatVO> getByPasienVO(@PathVariable("id") Integer id) {
AlamatVO alamatVO = alamatService.findByPasienId(id);
return RestUtil.getJsonResponse(alamatVO, HttpStatus.OK);
}
@Override
public ResponseEntity<Collection<AlamatVO>> getAllVOWithQueryString(HttpServletRequest request, Integer page,
Integer limit, String sort, String dir) {
return null;
return getJsonResponse(alamatVO, OK);
}
}

View File

@ -1,227 +1,142 @@
package com.jasamedika.medifirst2000.controller;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.dto.AlatDto;
import com.jasamedika.medifirst2000.entities.Alat;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AlatService;
import com.jasamedika.medifirst2000.vo.AlatVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
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 com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.dto.AlatDto;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AlatService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.AlatVO;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttptatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController
@RequestMapping("/alat")
public class AlatController extends LocaleController<AlatVO> {
@Autowired
private AlatService alatService;
private static final Logger LOGGER = LoggerFactory
.getLogger(AlatController.class);
@RequestMapping(value = "/save-alat/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> addVO(@Valid @RequestBody AlatVO vo,HttpServletRequest request) {
try{
Map<String, Object> result = alatService.addAlat(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Alat", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Alat", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/update-alat/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> updateVO(@Valid @RequestBody AlatVO vo,HttpServletRequest request) {
try{
Map<String, Object> result = alatService.addAlat(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when update Alat", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when update Alat", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/find-all-alat/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> getAllVO(HttpServletRequest request) {
try {
Map<String,Object> result=alatService.findAllAlat();
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when get all alat", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when get all alat", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
private AlatService<Alat> alatService;
@RequestMapping(value="/save-mesin-cuci", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> saveMesinCuci(@RequestBody AlatDto dto,
HttpServletRequest request) {
Map<String,Object> result = alatService.saveAlat(dto);
private static final Logger LOGGER = LoggerFactory.getLogger(AlatController.class);
@RequestMapping(value = "/find-all-alat/", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getAllVO(HttpServletRequest request) {
try {
Map<String, Object> result = alatService.findAllAlat();
if (null != result)
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got ServiceVOException {} when findAllAlat", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got JpaSystemException {} when findAllAlat", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/save-mesin-cuci", method = POST, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveMesinCuci(@RequestBody AlatDto dto, HttpServletRequest request) {
Map<String, Object> result = alatService.saveAlat(dto);
if (!result.isEmpty()) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
}
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
}
@RequestMapping(value="/get-mesin-cuci", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> get(
@RequestParam(value="alatId", required = true) Integer alatId,
HttpServletRequest request) {
Map<String, Object> result = alatService.getByAlatId(alatId);
if (result!=null) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
}
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
}
@RequestMapping(value="/get-all-mesin-cuci", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getAll(
HttpServletRequest request) {
@RequestMapping(value = "/get-all-mesin-cuci", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getAll(HttpServletRequest request) {
List<Map<String, Object>> result = alatService.getAllAlat();
if (result!=null) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
if (result != null) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
}
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
}
@RequestMapping(value="/get-mesin-aset", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getAllRuangan(
HttpServletRequest request) {
@RequestMapping(value = "/get-mesin-aset", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getAllRuangan(HttpServletRequest request) {
List<Map<String, Object>> result = alatService.getAllProdukAset();
if (result!=null) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
if (result != null) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
}
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
}
@RequestMapping(value="/get-satuan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getSatuan(
HttpServletRequest request) {
@RequestMapping(value = "/get-satuan", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getSatuan(HttpServletRequest request) {
List<Map<String, Object>> result = alatService.getAllSatuanStandar();
if (result!=null) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
if (result != null) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
}
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
}
@RequestMapping(value="/get-departemen-laundry", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getDepartemenLaundry(
HttpServletRequest request) {
@RequestMapping(value = "/get-departemen-laundry", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getDepartemenLaundry(HttpServletRequest request) {
Map<String, Object> result = alatService.getDepartemenLaundry();
if (result!=null) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
if (result != null) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
}
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
}
@RequestMapping(value="/get-max-no-mesin", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getMaxId(
HttpServletRequest request) {
@RequestMapping(value = "/get-max-no-mesin", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getMaxId(HttpServletRequest request) {
Map<String, Object> result = alatService.getMaxId();
if (result!=null) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
if (result != null) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
}
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
}
@RequestMapping(value="/get-produkasetid-alatid", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-produkasetid-alatid", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getProdukAsetAlat(
@RequestParam(value="produkAsetId", required = true) Integer produkAsetId,
@RequestParam(value="alatId", required = true) Integer alatId,
@RequestParam(value = "produkAsetId") Integer produkAsetId, @RequestParam(value = "alatId") Integer alatId,
HttpServletRequest request) {
Map<String, Object> result = alatService.cekMesiId(produkAsetId, alatId);
if (result!=null) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
if (result != null) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
}
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
}
@RequestMapping(value="/get-asset-laundry",
method=RequestMethod.GET,
produces=MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> gerAssetLaundry(HttpServletRequest request){
Map<String, Object> result = this.alatService.findAssetLaundry();
return result;
@RequestMapping(value = "/get-asset-laundry", method = GET, produces = APPLICATION_JSON_VALUE)
public Map<String, Object> gerAssetLaundry(HttpServletRequest request) {
return this.alatService.findAssetLaundry();
}
@RequestMapping(value="/get-mesin-laundry",
method=RequestMethod.GET,
produces=MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> gerMesinLaundry(HttpServletRequest request){
Map<String, Object> result = this.alatService.getMesinLaundry();
return result;
@RequestMapping(value = "/get-mesin-laundry", method = GET, produces = APPLICATION_JSON_VALUE)
public Map<String, Object> gerMesinLaundry(HttpServletRequest request) {
return this.alatService.getMesinLaundry();
}
}

View File

@ -1,35 +1,32 @@
package com.jasamedika.medifirst2000.controller;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AnamnesisService;
import com.jasamedika.medifirst2000.vo.AnamnesisVO;
import com.jasamedika.medifirst2000.vo.RegistrasiPelayananVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AnamnesisService;
import com.jasamedika.medifirst2000.service.AnamnesisService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.AnamnesisVO;
import com.jasamedika.medifirst2000.vo.AnamnesisVO;
import com.jasamedika.medifirst2000.vo.RegistrasiPelayananVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttptatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
/**
* Controller class for Registrasi Pasien Business
@ -38,62 +35,43 @@ import com.jasamedika.medifirst2000.vo.RegistrasiPelayananVO;
*/
@RestController
@RequestMapping("/anamnesis")
public class AnamnesisController extends LocaleController<RegistrasiPelayananVO>{
public class AnamnesisController extends LocaleController<RegistrasiPelayananVO> {
@Autowired
private AnamnesisService service;
private static final Logger LOGGER = LoggerFactory.getLogger(AnamnesisController.class);
@RequestMapping(value = "/save-anamnesis", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> saveAnamnesis(@Valid @RequestBody AnamnesisVO vo,HttpServletRequest request) {
try {
Map<String,Object> result = service.saveAnamnesis(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
private AnamnesisService service;
private static final Logger LOGGER = LoggerFactory.getLogger(AnamnesisController.class);
@RequestMapping(value = "/save-anamnesis", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveAnamnesis(@Valid @RequestBody AnamnesisVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = service.saveAnamnesis(vo);
if (null != result)
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when saveAnamnesis", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when saveAnamnesis", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when saveAnamnesis", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when saveAnamnesis", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-anamnesis/{noCm}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-anamnesis/{noCm}", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getTindakanByIdUserAndPeriod(@PathVariable("noCm") String noCm,
HttpServletRequest request) {
List<Map<String, Object>> result = null;
List<Map<String, Object>> result;
try {
result = service.getAnamnesis(noCm);
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
} catch (Exception e) {
e.printStackTrace();
throw new ServiceVOException(e.getMessage());
}
return RestUtil.getJsonResponse(result, HttpStatus.OK);
return getJsonResponse(result, OK);
}
@RequestMapping(value = "/get-anamnesis1/{noCm}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getAnamnesis(@PathVariable("noCm") String noCm,
HttpServletRequest request) {
List<Map<String, Object>> result = null;
try {
result = service.getAnamnesis(noCm);
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
} catch (Exception e) {
e.printStackTrace();
}
return RestUtil.getJsonResponse(result, HttpStatus.OK);
}
}

View File

@ -1,37 +1,33 @@
package com.jasamedika.medifirst2000.controller;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
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.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.entities.Pengendali;
import com.jasamedika.medifirst2000.entities.Ruangan;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AnggaranService;
import com.jasamedika.medifirst2000.service.DetailAnggaranService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.HeadAnggaranVO;
import com.jasamedika.medifirst2000.vo.VerifikasiSpekAnggaranVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttptatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController
@RequestMapping("/anggaran")
@ -55,201 +51,139 @@ public class AnggaranController extends LocaleController<HeadAnggaranVO> {
@RequestParam(value = "dateStart", required = false) String dateStart,
@RequestParam(value = "dateEnd", required = false) String dateEnd,
@RequestParam(value = "tahun", required = false) Integer tahun,
@RequestParam(value = "gridFor", required = true) String gridFor,
@RequestParam(value = "gridFor") String gridFor,
@RequestParam(value = "pengendaliId", required = false) Integer pengendaliId) {
Map<String, Object> resultPageMap = service.detailSpekAnggaran(page, limit, sort, dir, dateStart, dateEnd,
tahun, gridFor, pengendaliId);
return resultPageMap;
return service.detailSpekAnggaran(page, limit, sort, dir, dateStart, dateEnd, tahun, gridFor, pengendaliId);
}
@RequestMapping(value = "/save-pengajuan-usulan-anggaran-baru", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/save-pengajuan-usulan-anggaran-baru", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePengajuanUsulanAnggaranBaru(@Valid @RequestBody HeadAnggaranVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = service.savePengajuanUsulanAnggaranBaru(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when savePengajuanUsulanAnggaran", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when savePengajuanUsulanAnggaranBaru", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when savePengajuanUsulanAnggaran", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when savePengajuanUsulanAnggaranBaru", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-detail-anggaran/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> findDetailSpekAnggaranByParent(
@RequestParam(value = "noRec", required = true) String noRec,
@RequestMapping(value = "/get-detail-anggaran/", method = GET, produces = APPLICATION_JSON_VALUE)
public Map<String, Object> findDetailSpekAnggaranByParent(@RequestParam(value = "noRec") String noRec,
@RequestParam(value = "parameter", required = false) String parameter,
@RequestParam(value = "asalProdukId", required = false) Integer asalProdukId,
@RequestParam(value = "mataAnggaranId", required = false) Integer mataAnggaranId) {
Map<String, Object> detailAnggaran = detailAnggaranService.findDetailSpekAnggaranByParent(noRec, parameter,
asalProdukId, mataAnggaranId);
return detailAnggaran;
return detailAnggaranService.findDetailSpekAnggaranByParent(noRec, parameter, asalProdukId, mataAnggaranId);
}
@RequestMapping(value = "/save-verifikasi-spek-anggaran", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/save-verifikasi-spek-anggaran", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveVerifikasiSpekAnggaran(
@Valid @RequestBody VerifikasiSpekAnggaranVO vo, HttpServletRequest request) {
try {
Map<String, Object> result = service.saveVerifikasiSpekAnggaran(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when savePengajuanUsulanAnggaran", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when saveVerifikasiSpekAnggaran", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when savePengajuanUsulanAnggaran", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when saveVerifikasiSpekAnggaran", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/save-un-verifikasi-spek-anggaran", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/save-un-verifikasi-spek-anggaran", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveUnVerifikasiSpekAnggaran(
@Valid @RequestBody VerifikasiSpekAnggaranVO vo, HttpServletRequest request) {
try {
Map<String, Object> result = service.saveUnVerifikasiSpekAnggaran(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when savePengajuanUsulanAnggaran", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when saveUnVerifikasiSpekAnggaran", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when savePengajuanUsulanAnggaran", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when saveUnVerifikasiSpekAnggaran", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-kode-produk", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> gedProdukByNama(
@RequestParam(value = "namaProduk", required = true) String namaProduk) {
Map<String, Object> result = new HashMap<>();
ResponseEntity<Map<String, Object>> restUtil = null;
try {
result = service.gedProdukByNama(namaProduk);
if (null != result) {
restUtil = RestUtil.getJsonResponse(result, HttpStatus.FOUND, mapHeaderMessage);
} else {
restUtil = RestUtil.getJsonResponse(null, HttpStatus.NOT_FOUND, mapHeaderMessage);
}
} catch (IllegalArgumentException e) {
restUtil = RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
}
return restUtil;
}
@RequestMapping(value = "/get-pengendali", method = RequestMethod.GET)
@RequestMapping(value = "/get-pengendali", method = GET)
public ResponseEntity<Pengendali> getPengendali(HttpServletRequest request) {
try {
Pengendali pengendali = service.getPengendaliByUserLogin();
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(pengendali, HttpStatus.OK, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(pengendali, OK, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when get all pengendali", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getPengendaliByUserLogin", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when get all dokter", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getPengendaliByUserLogin", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-ruangan", method = RequestMethod.GET)
@RequestMapping(value = "/get-ruangan", method = GET)
public ResponseEntity<Ruangan> getRuangan(HttpServletRequest request) {
try {
Ruangan ruangan = service.getRuanganByUserLogin();
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(ruangan, HttpStatus.OK, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(ruangan, OK, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when get all dokter", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getRuanganByUserLogin", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when get all dokter", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getRuanganByUserLogin", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-all-dokter", method = RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getJenisProduk(HttpServletRequest request) {
try {
Map<String, Object> listJenisProduk = service.getJenisProduk();
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(listJenisProduk, HttpStatus.OK, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when get all dokter", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when get all dokter", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
// add by Arya 2017-01-19
@RequestMapping(value = "/edit-pengajuan-usulan-anggaran", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/edit-pengajuan-usulan-anggaran", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> editPengajuanUsulanAnggaran(@Valid @RequestBody HeadAnggaranVO vo,
@RequestParam(value = "noRec", required = false) String noRec, HttpServletRequest request) {
try {
Map<String, Object> result = service.editPengajuanUsulanAnggaran(vo, noRec);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when editPengajuanUsulanAnggaran", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when editPengajuanUsulanAnggaran", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when editPengajuanUsulanAnggaran", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when editPengajuanUsulanAnggaran", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
// end add by Arya 2017-01-19
// add by Arya 2017-01-30
@RequestMapping(value = "/get-pengajuan-usulan-anggaran-by-norec/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> findPengajuanUsulanAnggaranByNoRec(
@RequestParam(value = "noRec", required = true) String noRec) {
Map<String, Object> detailAnggaran = service.findPengajuanUsulanAnggaranByNoRec(noRec);
return detailAnggaran;
@RequestMapping(value = "/get-pengajuan-usulan-anggaran-by-norec/", method = GET, produces = APPLICATION_JSON_VALUE)
public Map<String, Object> findPengajuanUsulanAnggaranByNoRec(@RequestParam(value = "noRec") String noRec) {
return service.findPengajuanUsulanAnggaranByNoRec(noRec);
}
// end add by Arya 2017-01-30
//add by Arya 2017-02-02
// add by Arya 2017-02-02
@RequestMapping(value = "/daftar-detail-anggaran")
@ResponseBody
public Map<String, Object> getDetailAnggaran(
@ -261,12 +195,8 @@ public class AnggaranController extends LocaleController<HeadAnggaranVO> {
@RequestParam(value = "dateEnd", required = false) String dateEnd,
@RequestParam(value = "tahun", required = false) Integer tahun,
@RequestParam(value = "pengendaliId", required = false) Integer pengendaliId) {
Map<String, Object> resultPageMap = service.getDetailAnggaran(page, limit, sort, dir, dateStart, dateEnd,
tahun, pengendaliId);
return resultPageMap;
return service.getDetailAnggaran(page, limit, sort, dir, dateStart, dateEnd, tahun, pengendaliId);
}
//end add by Arya 2017-02-02
// end add by Arya 2017-02-02
}

View File

@ -1,64 +1,60 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Arrays;
import java.util.List;
import org.springframework.http.HttpStatus;
import java.util.Collections;
import java.util.List;
public class ApiError {
private HttpStatus status;
private String message;
private List<String> errors;
private HttpStatus status;
private String message;
private List<String> errors;
//
public ApiError() {
super();
}
public ApiError() {
super();
}
public ApiError(final HttpStatus status, final String message, final List<String> errors) {
super();
this.status = status;
this.message = message;
this.errors = errors;
}
public ApiError(final HttpStatus status, final String message, final List<String> errors) {
super();
this.status = status;
this.message = message;
this.errors = errors;
}
public ApiError(final HttpStatus status, final String message, final String error) {
super();
this.status = status;
this.message = message;
errors = Collections.singletonList(error);
}
public ApiError(final HttpStatus status, final String message, final String error) {
super();
this.status = status;
this.message = message;
errors = Arrays.asList(error);
}
public HttpStatus getStatus() {
return status;
}
//
public void setStatus(final HttpStatus status) {
this.status = status;
}
public HttpStatus getStatus() {
return status;
}
public String getMessage() {
return message;
}
public void setStatus(final HttpStatus status) {
this.status = status;
}
public void setMessage(final String message) {
this.message = message;
}
public String getMessage() {
return message;
}
public List<String> getErrors() {
return errors;
}
public void setMessage(final String message) {
this.message = message;
}
public void setErrors(final List<String> errors) {
this.errors = errors;
}
public List<String> getErrors() {
return errors;
}
public void setErrors(final List<String> errors) {
this.errors = errors;
}
public void setError(final String error) {
errors = Arrays.asList(error);
}
public void setError(final String error) {
errors = Collections.singletonList(error);
}
}

View File

@ -47,11 +47,11 @@ public class ApresiasiAtasLayananController extends LocaleController<ApresiasiAt
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got ServiceVOException {} when save Apresiasi Atas Layanan", e.getMessage());
LOGGER.error("Got ServiceVOException {} when addApresiasiAtasLayanan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got JpaSystemException {} when save Apresiasi Atas Layanan", jse.getMessage());
LOGGER.error("Got JpaSystemException {} when addApresiasiAtasLayanan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}

View File

@ -1,66 +1,64 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AsesmenGiziAwalService;
import com.jasamedika.medifirst2000.vo.AsesmenGiziAwalVO;
import com.jasamedika.medifirst2000.vo.RegistrasiPelayananVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AsesmenGiziAwalService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.AsesmenGiziAwalVO;
import com.jasamedika.medifirst2000.vo.RegistrasiPelayananVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttptatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
/**
* Controller class for Registrasi Pasien Business
* Controller class for Asesmen Gizi Awal Service
*
* @author Adik
*/
@RestController
@RequestMapping("/asesmen-gizi-awal")
public class AsesmenGiziAwalController extends LocaleController<RegistrasiPelayananVO>{
public class AsesmenGiziAwalController extends LocaleController<RegistrasiPelayananVO> {
@Autowired
private AsesmenGiziAwalService asesmenGiziAwalService;
private static final Logger LOGGER = LoggerFactory
.getLogger(AsesmenGiziAwalController.class);
@RequestMapping(value = "/save-asesmen-gizi-awal", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveAsesmenGiziAwal(@Valid @RequestBody AsesmenGiziAwalVO vo,HttpServletRequest request) {
private static final Logger LOGGER = LoggerFactory.getLogger(AsesmenGiziAwalController.class);
@RequestMapping(value = "/save-asesmen-gizi-awal", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveAsesmenGiziAwal(@Valid @RequestBody AsesmenGiziAwalVO vo,
HttpServletRequest request) {
try {
Map<String,Object> result=asesmenGiziAwalService.saveAsesmenGiziAwal(vo);
Map<String, Object> result = asesmenGiziAwalService.saveAsesmenGiziAwal(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
SaveLog("Assesment Gizi Awal", "Pemeriksaan",request);
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
SaveLog("Assesment Gizi Awal", "Pemeriksaan", request);
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when saveAsesmenGiziAwal", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when saveAsesmenGiziAwal", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when saveAsesmenGiziAwal", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when saveAsesmenGiziAwal", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
}

View File

@ -46,11 +46,11 @@ public class AsesmenGiziLanjutController extends LocaleController<RegistrasiPela
SaveLog("Assesment Gizi Lanjut", "Pemeriksaan Khusus", request);
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got ServiceVOException {} when save Asesmen Gizi Lanjut", e.getMessage());
LOGGER.error("Got ServiceVOException {} when saveAsesmenGiziLanjut", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got JpaSystemException {} when save Asesmen Gizi Lanjut", jse.getMessage());
LOGGER.error("Got JpaSystemException {} when saveAsesmenGiziLanjut", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}

View File

@ -1,58 +0,0 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AssetService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.AssetVO;
@RestController
@RequestMapping("/asset")
public class AssetController extends LocaleController<AssetVO> {
@Autowired
private AssetService assetService;
private static final Logger LOGGER = LoggerFactory.getLogger(AssetController.class);
@RequestMapping(value = "/save-asset", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveAsset(@Valid @RequestBody AssetVO vo,HttpServletRequest request) {
try {
Map<String,Object> result = assetService.saveAsset(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when saveAsset", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when saveAsset", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
}

View File

@ -1,249 +1,162 @@
package com.jasamedika.medifirst2000.controller;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AsuhanKeperawatanPeriOperatifService;
import com.jasamedika.medifirst2000.vo.AsuhanKeperawatanPeriOperatifVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
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 com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AsuhanKeperawatanPeriOperatifService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.AsuhanKeperawatanPeriOperatifVO;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttptatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
@RestController
@RequestMapping("/asuhan-keperawatan-master")
public class AsuhanKeperawatanPeriOperasiController extends LocaleController<AsuhanKeperawatanPeriOperatifVO>{
private static final Logger LOGGER = LoggerFactory.getLogger(AsuhanKeperawatanPeriOperasiController.class);
public class AsuhanKeperawatanPeriOperasiController extends LocaleController<AsuhanKeperawatanPeriOperatifVO> {
private static final Logger LOGGER = LoggerFactory.getLogger(AsuhanKeperawatanPeriOperasiController.class);
@Autowired
private AsuhanKeperawatanPeriOperatifService asuhanKeperawatanPeriOperatifService;
@RequestMapping(
value = "/save-asuhan-keperawatan-master",
method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveAsuhanPerawat(
@Valid @RequestBody AsuhanKeperawatanPeriOperatifVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = this.asuhanKeperawatanPeriOperatifService.saveAsuhan(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when saveAsuhanPerawat", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when saveAsuhanPerawat", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(
value = "/get-list-data",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-list-data", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getLoadData(HttpServletRequest request) {
try {
Map<String, Object> result = this.asuhanKeperawatanPeriOperatifService.getAllAsuhan();
if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage);
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getLoadData", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getAllAsuhan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getLoadData", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getAllAsuhan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(
value = "/get-list-data-intra-operasi",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getLoadDataIntraOperasi(HttpServletRequest request) {
@RequestMapping(value = "/get-list-data-intra-operasi", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getLoadDataIntraOperasi(HttpServletRequest request) {
try {
Map<String, Object> result = this.asuhanKeperawatanPeriOperatifService.getAllIntraOperasiPerawatBedah();
if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage);
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getLoadDataIntraOperasi", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getAllIntraOperasiPerawatBedah", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getLoadDataIntraOperasi", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getAllIntraOperasiPerawatBedah", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(
value = "/get-list-data-post-operasi",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getLoadDataPostOperasi(HttpServletRequest request) {
@RequestMapping(value = "/get-list-data-post-operasi", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getLoadDataPostOperasi(HttpServletRequest request) {
try {
Map<String, Object> result = this.asuhanKeperawatanPeriOperatifService.getAllPostOperasiPerawatBedah();
if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage);
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getLoadDataPostOperasi", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getAllPostOperasiPerawatBedah", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getLoadDataPostOperasi", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getAllPostOperasiPerawatBedah", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(
value = "/get-list-data-intra-operasi-anestesi",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-list-data-intra-operasi-anestesi", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getLoadDataIntraOperasiAnestesi(HttpServletRequest request) {
try {
Map<String, Object> result = this.asuhanKeperawatanPeriOperatifService.getAllIntraOperasiAnestesi();
if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
//return result;
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage);
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getLoadDataIntraOperasiAnestesi", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getAllIntraOperasiAnestesi", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getLoadDataIntraOperasiAnestesi", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getAllIntraOperasiAnestesi", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(
value = "/get-list-data-post-operasi-anestesi",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getLoadDataPostOperasiAnestesi(HttpServletRequest request) {
try {
Map<String, Object> result = this.asuhanKeperawatanPeriOperatifService.getAllPostOperasiAnestesi();
if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
//return result;
} else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getLoadDataPostOperasiAnestesi", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getLoadDataPostOperasiAnestesi", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
@RequestMapping(value = "/get-list-data-post-operasi-anestesi", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getLoadDataPostOperasiAnestesi(HttpServletRequest request) {
try {
Map<String, Object> result = this.asuhanKeperawatanPeriOperatifService.getAllPostOperasiAnestesi();
if (null != result) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got ServiceVOException {} when getAllPostOperasiAnestesi", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got JpaSystemException {} when getAllPostOperasiAnestesi", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
@RequestMapping(
value = "/get-list-data-intra-operasi-perawat-bedah-v1",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getLoadDataIntraOperasiPerawatBedahV1(HttpServletRequest request) {
try {
Map<String, Object> result = this.asuhanKeperawatanPeriOperatifService.getAllIntraOperasiPerawatBedahV1();
if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
//return result;
} else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getLoadDataIntraOperasiAnestesi", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getLoadDataIntraOperasiAnestesi", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
@RequestMapping(value = "/get-list-data-intra-operasi-perawat-bedah-v1", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getLoadDataIntraOperasiPerawatBedahV1(HttpServletRequest request) {
try {
Map<String, Object> result = this.asuhanKeperawatanPeriOperatifService.getAllIntraOperasiPerawatBedahV1();
if (null != result) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got ServiceVOException {} when getAllIntraOperasiPerawatBedahV1", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got JpaSystemException {} when getAllIntraOperasiPerawatBedahV1", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
}

View File

@ -1,128 +1,104 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AsuhanKeperawatanPeriOperasiHeaderService;
import com.jasamedika.medifirst2000.vo.AsuhanKeperawatanPeriOperasiHeaderVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestBody;
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 com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AsuhanKeperawatanPeriOperasiHeaderService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.AsuhanKeperawatanPeriOperasiHeaderVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttptatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController
@RequestMapping("/asuhan-keperawatan-peri-operasi")
public class AsuhanKeperawatanPeriOperasiHeaderController extends LocaleController<AsuhanKeperawatanPeriOperasiHeaderVO>{
public class AsuhanKeperawatanPeriOperasiHeaderController
extends LocaleController<AsuhanKeperawatanPeriOperasiHeaderVO> {
private static final Logger LOGGER = LoggerFactory.getLogger(AsuhanKeperawatanPeriOperasiHeaderController.class);
@Autowired
private AsuhanKeperawatanPeriOperasiHeaderService asuhanKeperawatanPeriOperasiHeaderService;
@RequestMapping(
value = "/save-asuhan-perawat",
method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/save-asuhan-perawat", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveAsuhanKeperawatan(
@Valid @RequestBody AsuhanKeperawatanPeriOperasiHeaderVO vo, HttpServletRequest request) {
try {
Map<String, Object> result = this.asuhanKeperawatanPeriOperasiHeaderService.saveAsuhanHeader(vo);
if (result != null)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when saveAsuhanKeperawatan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when saveAsuhanHeader", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when saveAsuhanKeperawatan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
LOGGER.error("Got JpaSystemException {} when saveAsuhanHeader", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(
value = "/get-list-by-notrans",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getLoadDataByNoTrans(
@RequestParam(value = "notrans", required = true) String notrans, HttpServletRequest request) {
@RequestMapping(value = "/get-list-by-notrans", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getLoadDataByNoTrans(@RequestParam(value = "notrans") String notrans,
HttpServletRequest request) {
try {
Map<String, Object> result = this.asuhanKeperawatanPeriOperasiHeaderService.getListAsuhanByNoTrans(notrans);
if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage);
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getLoadDataByNoTrans", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getListAsuhanByNoTrans", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getLoadDataByNoTrans", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getListAsuhanByNoTrans", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(
value = "get-pasien-operasi",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getPasienDaftarOperasi(
@RequestParam(value = "noRec", required = true) String noRec, HttpServletRequest request) {
@RequestMapping(value = "get-pasien-operasi", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getPasienDaftarOperasi(@RequestParam(value = "noRec") String noRec,
HttpServletRequest request) {
try {
Map<String, Object> result = this.asuhanKeperawatanPeriOperasiHeaderService.getPasienDaftarOperasi(noRec);
if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage);
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getPasienDaftarOperasi", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getPasienDaftarOperasi", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getPasienDaftarOperasi", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getPasienDaftarOperasi", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
}

View File

@ -64,11 +64,11 @@ public class AsuransiController extends LocaleController<PemakaianAsuransiVO> {
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got ServiceVOException {} when add Pasien", e.getMessage());
LOGGER.error("Got ServiceVOException {} when savePemakaianAsuransi", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got JpaSystemException {} when add Pasien", jse.getMessage());
LOGGER.error("Got JpaSystemException {} when savePemakaianAsuransi", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}

View File

@ -7,14 +7,12 @@ import com.jasamedika.medifirst2000.notification.MessagePublisher;
import com.jasamedika.medifirst2000.security.model.UserAuthentication;
import com.jasamedika.medifirst2000.security.service.TokenAuthenticationService;
import com.jasamedika.medifirst2000.service.ActivityPegawaiService;
import com.jasamedika.medifirst2000.service.AgamaService;
import com.jasamedika.medifirst2000.service.JadwalDokterService;
import com.jasamedika.medifirst2000.service.LoginUserService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.util.JsonUtil;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.AgamaVO;
import com.jasamedika.medifirst2000.vo.LoginUserVO;
import com.jasamedika.medifirst2000.vo.custom.AuthVO;
import org.slf4j.Logger;
@ -29,7 +27,10 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* Controller class for Authenticate Business
@ -39,6 +40,7 @@ import java.util.*;
@RestController
@RequestMapping("/auth")
public class AuthenticateController {
private static final Logger LOGGER = LoggerFactory.getLogger(AuthenticateController.class);
protected Map<String, String> mapHeaderMessage = new HashMap<>();
@ -52,9 +54,6 @@ public class AuthenticateController {
@Autowired
private LoginUserService loginUserService;
@Autowired
public AgamaService<AgamaVO> agamaService;
@Autowired
private ActivityPegawaiService activityPegawaiService;
@ -91,7 +90,7 @@ public class AuthenticateController {
return RestUtil.getJsonHttptatus(HttpStatus.BAD_REQUEST, mapHeaderMessage);
}
LOGGER.info("starting logging {}", vo.getNamaUser() + " at " + DateUtil.getIndonesianStringDate(new Date()));
LOGGER.info("starting sign-in {}", vo.getNamaUser() + " at " + DateUtil.getIndonesianStringDate(new Date()));
try {
mapHeaderMessage = new HashMap<>();
@ -104,7 +103,6 @@ public class AuthenticateController {
String token = tokenAuthenticationService.addAuthentication(httpResponse,
new UserAuthentication(new User(loginUserVo.getNamaUser(), loginUserVo.getKataSandi(),
Collections.singletonList(authority))));
boolean isSupervising = request.getHeader(Constants.HttpHeader.SUPERVISING) != null;
if (isSupervising) { // supervising login
mapHeaderMessage.put("X-AUTH-SUPERVISOR-TOKEN", token);
@ -139,7 +137,7 @@ public class AuthenticateController {
public ResponseEntity<AuthVO> signOut(@RequestBody AuthVO vo, HttpServletResponse httpResponse) {
LoginUserVO loginUserVO = loginUserService.findById(vo.getId());
LOGGER.info("starting logout {}",
LOGGER.info("starting sign-out {}",
loginUserVO.getNamaUser() + " at " + DateUtil.getIndonesianStringDate(new Date()));
Integer idPegawai = 0;
@ -158,7 +156,8 @@ public class AuthenticateController {
return RestUtil.getJsonHttptatus(HttpStatus.BAD_REQUEST, mapHeaderMessage);
}
LOGGER.info("starting logging {}", vo.getNamaUser() + " at " + DateUtil.getIndonesianStringDate(new Date()));
LOGGER.info("starting sign-in-mobile {}",
vo.getNamaUser() + " at " + DateUtil.getIndonesianStringDate(new Date()));
try {
mapHeaderMessage = new HashMap<>();
@ -201,7 +200,7 @@ public class AuthenticateController {
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
}
} catch (Exception ex) {
LOGGER.error("Signing-in error {}", ex.getMessage());
LOGGER.error("Signing-in-mobile error {}", ex.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.UNAUTHORIZED);
}
@ -212,7 +211,7 @@ public class AuthenticateController {
public ResponseEntity<AuthVO> signOutMobile(@RequestBody AuthVO vo, HttpServletResponse httpResponse) {
LoginUserVO loginUserVO = loginUserService.findById(vo.getId());
LOGGER.info("starting logout {}",
LOGGER.info("starting sign-out-mobile {}",
loginUserVO.getNamaUser() + " at " + DateUtil.getIndonesianStringDate(new Date()));
Integer idPegawai = 0;
@ -221,4 +220,5 @@ public class AuthenticateController {
loggingSystemAsynchronous.saveSignOutLog(loginUserVO.getNamaUser(), idPegawai);
return RestUtil.getJsonResponse(vo, HttpStatus.OK);
}
}

View File

@ -1,182 +1,163 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.B3RuanganInputDataService;
import com.jasamedika.medifirst2000.vo.B3RuanganInputDataVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
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 com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.B3RuanganInputDataService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.B3DaftarBahanBerbahayaVO;
import com.jasamedika.medifirst2000.vo.B3RuanganInputDataVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttptatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController
@RequestMapping("/b3-Ruangan-Input-Data")
public class B3RuanganInputDataController extends LocaleController<B3RuanganInputDataVO>{
public class B3RuanganInputDataController extends LocaleController<B3RuanganInputDataVO> {
@Autowired
private B3RuanganInputDataService service;
private static final Logger LOGGER = LoggerFactory.getLogger(B3RuanganInputDataController.class);
@RequestMapping(value = "/get-login-petugas", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-login-petugas", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getLoginUser(HttpServletRequest request) {
try {
Map<String,Object> result = service.getUserLogin();
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
} else{
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
Map<String, Object> result = service.getUserLogin();
if (null != result) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getLoginUser", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getUserLogin", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getLoginUser", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getUserLogin", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-ruangan", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getRuangan(HttpServletRequest request) {
try {
Map<String,Object> result = service.getRuangan();
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
} else{
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
Map<String, Object> result = service.getRuangan();
if (null != result) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getRuangan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getRuangan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getRuangan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getRuangan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-stok-global", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-stok-global", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getB3StokGlobal(HttpServletRequest request) {
try {
Map<String,Object> result = service.getB3StokGlobal();
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
} else{
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
Map<String, Object> result = service.getB3StokGlobal();
if (null != result) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getB3StokGlobal", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getB3StokGlobal", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getB3StokGlobal", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getB3StokGlobal", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/save-bahan-b3", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveB3RuanganInputData(@Valid @RequestBody B3RuanganInputDataVO vo, HttpServletRequest request) {
try {
Map<String,Object> result = service.saveB3RuanganInputData(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
@RequestMapping(value = "/save-bahan-b3", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveB3RuanganInputData(@Valid @RequestBody B3RuanganInputDataVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = service.saveB3RuanganInputData(vo);
if (null != result)
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when saveB3RuanganInputData", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when saveB3RuanganInputData", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when saveB3RuanganInputData", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when saveB3RuanganInputData", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-bahan-b3", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-bahan-b3", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getB3RuanganInputDataByRuangan(
@RequestParam(value = "ruanganId", required = true) Integer ruanganId, HttpServletRequest request) {
@RequestParam(value = "ruanganId") Integer ruanganId, HttpServletRequest request) {
try {
Map<String,Object> result = service.getB3RuanganInput(ruanganId);
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
} else{
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
Map<String, Object> result = service.getB3RuanganInput(ruanganId);
if (null != result) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getB3RuanganInputDataByRuangan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getB3RuanganInput", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getB3RuanganInputDataByRuangan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getB3RuanganInput", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/update-bahan-b3", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> updateB3DaftarBahanBerbahaya(@Valid @RequestBody B3DaftarBahanBerbahayaVO vo, HttpServletRequest request) {
try {
Integer result = service.updateB3DaftarBahanBerbahaya(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(vo.getNoRec(), HttpStatus.OK,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when updateB3DaftarBahanBerbahaya", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when updateB3DaftarBahanBerbahaya", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/delete-bahan-b3", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Boolean> deleteB3DaftarBahanBerbahaya(
@RequestParam(value = "noRec", required = true) String noRec, HttpServletRequest request) {
@RequestMapping(value = "/delete-bahan-b3", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Boolean> deleteB3DaftarBahanBerbahaya(@RequestParam(value = "noRec") String noRec,
HttpServletRequest request) {
try {
Boolean result = service.deleteB3DaftarBahanBerbahaya(noRec);
if (result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when deleteB3DaftarBahanBerbahaya", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when deleteB3DaftarBahanBerbahaya", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when deleteB3DaftarBahanBerbahaya", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when deleteB3DaftarBahanBerbahaya", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
}

View File

@ -1,189 +0,0 @@
package com.jasamedika.medifirst2000.controller;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.dao.KelasDao;
import com.jasamedika.medifirst2000.dao.RuanganDao;
import com.jasamedika.medifirst2000.dto.BukuRegisterMasukDto;
import com.jasamedika.medifirst2000.service.ReportingPelayananRekamMedisService;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.vo.RegistrasiPelayananVO;
/**
* Controller class for Registrasi Pasien Business
*
*/
@RestController
@RequestMapping("/cetakan")
public class CetakanController extends LocaleController<RegistrasiPelayananVO>
implements IBaseRestController<RegistrasiPelayananVO> {
@Autowired
private ReportingPelayananRekamMedisService reportingPelayananRekamMedisService;
@Autowired
private RuanganDao ruanganDao;
@Autowired
private KelasDao kelasDao;
private String formatBulan(Integer bulan){
String bulanString="";
switch(bulan){
case 1 :
bulanString="januari";
break;
case 2 :
bulanString="februari";
break;
case 3 :
bulanString="maret";
break;
case 4 :
bulanString="april";
break;
case 5 :
bulanString="mei";
break;
case 6 :
bulanString="juni";
break;
case 7 :
bulanString="juli";
break;
case 8 :
bulanString="agustus";
break;
case 9 :
bulanString="september";
break;
case 10 :
bulanString="oktober";
break;
case 11 :
bulanString="november";
break;
case 12 :
bulanString="desember";
break;
}
return bulanString;
}
@RequestMapping("/lapBukuRegisterMasukRi")
public ModelAndView generateLapBukuRegisterMasukRi(ModelAndView m,
@RequestParam(value = "format", required = false) String format,
@RequestParam(value = "startDate", required = true) String startDate,
@RequestParam(value = "endDate", required = true) String endDate,
@RequestParam(value = "ruangan", required = true) Integer ruangan) {
Map<String, Object> map = new HashMap<String, Object>();
String month=(formatBulan(Integer.valueOf(new SimpleDateFormat("MM").format(new Date()))));
String monthFirstCaplock=Character.toString(month.charAt(0)).toUpperCase()+month.substring(1);
String monthAllCaplock=month.toUpperCase();
List<BukuRegisterMasukDto> bukuRegisterMasukList = new ArrayList<BukuRegisterMasukDto>();
List<Object[]> list = reportingPelayananRekamMedisService.findAntrianPasienDiPeriksaByRuanganPeriode(ruangan,startDate,endDate);
for (Object[] data : list) {
String noPendaftaran=(String) data[0];
Date tglPendaftaran=(Date) data[1];
String noCm=(String) data[2];
String namaPasien=(String) data[3];
String jenisKelamin=(String) data[4];
String jenisPasien=(String) data[5];
String statusPasienRs=(String) data[6];
String statusPasien=(String) data[7];
String caraMasuk=(String) data[8];
String ruanganPerujuk=(String) data[9];
String statusKeluar=(String) data[10];
String statusPulang=(String) data[11];
String kondisiPulang=(String) data[12];
Date tglKeluar=(Date) data[13];
String noKamar=(String) data[14];
String noBed=(String) data[15];
String kelasPelayanan=(String) data[16];
String kasusPenyakit=(String) data[17];
BukuRegisterMasukDto dto = new BukuRegisterMasukDto();
dto.setCaraMasuk(caraMasuk);
dto.setJenisKelamin(jenisKelamin);
dto.setJenisPasien(jenisPasien);
dto.setKasusPenyakit(kasusPenyakit);
dto.setKelasPelayanan(kelasPelayanan);
dto.setKondisiPulang(kondisiPulang);
dto.setNoKamar(noKamar);
dto.setNamaPasien(namaPasien);
dto.setNoBed(noBed);
dto.setNoCm(noCm);
dto.setNoPendaftaran(noPendaftaran);
dto.setRuanganPerujuk(ruanganPerujuk);
dto.setStatusKeluar(statusKeluar);
dto.setStatusPasien(statusPasien);
dto.setStatusPasienRs(statusPasienRs);
dto.setStatusPulang(statusPulang);
dto.setTglKeluar(DateUtil.formatDate(tglKeluar));
dto.setTglPendaftaran(DateUtil.formatDate(tglPendaftaran));
bukuRegisterMasukList.add(dto);
}
m.addObject("dataSource", bukuRegisterMasukList);
m.addObject("startDate", startDate);
m.addObject("endDate", endDate);
m.addObject("tanggalReport", (new SimpleDateFormat("dd").format(new Date()))+" "+
monthFirstCaplock+" " + (new SimpleDateFormat("YYYY").format(new Date())));
m.addObject("ruangan", ruanganDao.findOne(ruangan).getNamaRuangan());
m.addObject("format", "pdf");
if (format != null && !format.isEmpty()) {
m.addObject("format", format);
}
return m;
}
@Override
public ResponseEntity<Collection<RegistrasiPelayananVO>> getAllVOWithQueryString(HttpServletRequest request,
Integer page, Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<RegistrasiPelayananVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(RegistrasiPelayananVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(RegistrasiPelayananVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<RegistrasiPelayananVO>> getAllVO() {
return null;
}
}

View File

@ -1,188 +1,108 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.entities.CheckIn;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.CheckInService;
import com.jasamedika.medifirst2000.vo.CheckInVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
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 com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.CheckInService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.CheckInVO;
import com.jasamedika.medifirst2000.vo.PapKebutuhanEdukasiVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttptatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController
@RequestMapping("/check-in")
@JsonIgnoreProperties(ignoreUnknown = true)
public class CheckInController extends LocaleController<CheckInVO> implements IBaseRestController<CheckInVO> {
@JsonIgnoreProperties(ignoreUnknown = true)
public class CheckInController extends LocaleController<CheckInVO> {
private static final Logger LOGGER = LoggerFactory.getLogger(CheckInController.class);
@Autowired
private CheckInService checkInService;
private CheckInService<CheckIn> checkInService;
@Override
public ResponseEntity<Collection<CheckInVO>> getAllVOWithQueryString(HttpServletRequest request, Integer page,
Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<CheckInVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(CheckInVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(CheckInVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<CheckInVO>> getAllVO() {
return null;
}
@RequestMapping(value = "/save-check-in/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> addVO(@Valid @RequestBody CheckInVO vo, HttpServletRequest request) {
@RequestMapping(value = "/save-check-in/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> addVO(@Valid @RequestBody CheckInVO vo, HttpServletRequest request) {
try {
Map<String,Object> result=checkInService.addCheckIn(vo);
Map<String, Object> result = checkInService.addCheckIn(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add CheckIn", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when save check in", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add CheckIn", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when save check in", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/update-check-in/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> edit(@Valid @RequestBody CheckInVO vo,HttpServletRequest request) {
@RequestMapping(value = "/get-check-in-by-norec", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getCheckInByNoRec(@RequestParam(value = "noRec") String noRec,
HttpServletRequest request) {
try {
Map<String,Object> result = checkInService.updateCheckIn(vo);
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
result.put("message", "Berhasil");
}else{
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request ));
result.put("message", "Gagal");
}
return RestUtil.getJsonResponse(result, HttpStatus.CREATED);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add CheckIn", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add CheckIn", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(
value = "/get-check-in-by-norec",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getCheckInByNoRec(
@RequestParam(value = "noRec", required = true) String noRec, HttpServletRequest request){
try {
Map<String,Object> result = this.checkInService.findByNoRec(noRec);
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
} else{
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
Map<String, Object> result = this.checkInService.findByNoRec(noRec);
if (null != result) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getCheckInByNoRec", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when get check in by norec", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getCheckInByNoRec", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(
value = "/get-check-in-by-norec-antrian",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getCheckInByNoRecAntrian(
@RequestParam(value = "noRec", required = true) String noRec, HttpServletRequest request){
try {
Map<String,Object> result = this.checkInService.getCheckInByNoRecAntrian(noRec);
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
} else{
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getCheckInByNoRecAntrian", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getCheckInByNoRecAntrian", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when get check in by norec", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-check-in-by-norec-antrian", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getCheckInByNoRecAntrian(@RequestParam(value = "noRec") String noRec,
HttpServletRequest request) {
try {
Map<String, Object> result = this.checkInService.getCheckInByNoRecAntrian(noRec);
if (null != result) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got ServiceVOException {} when get check in by norec antrian", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when get check in by norec antrian", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
}

View File

@ -1,311 +1,176 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.ItPerbaikanService;
import com.jasamedika.medifirst2000.vo.ItPelaksanaanPerbaikanVO;
import com.jasamedika.medifirst2000.vo.ItPerbaikanVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
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 com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.ItPerbaikanService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.ItPelaksanaanPerbaikanVO;
import com.jasamedika.medifirst2000.vo.ItPerbaikanVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttptatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController
@RequestMapping("/it-perbaikan")
public class ItPerbaikanController extends LocaleController<ItPerbaikanVO>{
public class ItPerbaikanController extends LocaleController<ItPerbaikanVO> {
@Autowired
private ItPerbaikanService service;
private static final Logger LOGGER = LoggerFactory.getLogger(ItPerbaikanController.class);
@RequestMapping(value = "/get-no-order", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-no-order", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getNoOrder(HttpServletRequest request) {
try {
Map<String, Object> result = service.getNoOrderTable();
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
} else{
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
if (null != result) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getJadwalPemeliharaan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when get no order", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getJadwalPemeliharaan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when get no order", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/save-permintaan-perbaikan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePermintaanPerbaikan(@Valid @RequestBody ItPerbaikanVO vo, HttpServletRequest request) {
@RequestMapping(value = "/save-permintaan-perbaikan", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePermintaanPerbaikan(@Valid @RequestBody ItPerbaikanVO vo,
HttpServletRequest request) {
try {
Map<String,Object> result = service.savePermintaanPerbaikan(vo);
try{
Map<String, Object> result = service.savePermintaanPerbaikan(vo);
try {
BroadcastMessageOther("PermintaanPerbaikan", result);
}catch (Exception ex){
ex.printStackTrace();
} catch (Exception ex) {
throw new ServiceVOException(ex.getMessage());
}
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when savePermintaanPerbaikan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when save permintaan perbaikan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when savePermintaanPerbaikan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when save permintaan perbaikan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/find-ruangan-asset", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/find-ruangan-asset", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getRuanganRegistrasiAset(HttpServletRequest request) {
try {
Map<String,Object> result = service.getRuanganPerbaikan();
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
} else{
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
Map<String, Object> result = service.getRuanganPerbaikan();
if (null != result) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getRuanganRegistrasiAset", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when find ruangan asset", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getRuanganRegistrasiAset", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when find ruangan asset", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/find-asset-by-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getAsetPerbaikan(@RequestParam(value = "id", required = true) Integer id, HttpServletRequest request){
try {
Map<String,Object> result = service.getAsetPerbaikan(id);
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
} else{
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getAsetPerbaikan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getAsetPerbaikan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
// @RequestMapping(value = "/get-all-permintaan-perbaikan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<Map<String, Object>> getAllPermintaanPerbaikan(
// @RequestParam(value = "tanggalAwal", required = false) String tanggalAwal,
// @RequestParam(value = "tanggalAkhir", required = false) String tanggalAkhir,
// HttpServletRequest request) {
// try {
// Map<String,Object> result = service.getAllPermintaanPerbaikan(tanggalAwal,tanggalAkhir);
// if (null != result){
// mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
// return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
// } else{
// return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
// }
// } catch (ServiceVOException e) {
// LOGGER.error("Got exception {} when getAllPermintaanPerbaikan", e.getMessage());
// addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
// return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
// } catch (JpaSystemException jse) {
// LOGGER.error("Got exception {} when getAllPermintaanPerbaikan", jse.getMessage());
// addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
// return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
// }
// }
@RequestMapping(value = "/get-one-permintaan-perbaikan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getOnePermintaanPerbaikan(
@RequestParam(value = "noRec", required = true) String noRec,
HttpServletRequest request) {
try {
Map<String,Object> result = service.getOnePermintaanPerbaikan(noRec);
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
} else{
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getOnePermintaanPerbaikan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getOnePermintaanPerbaikan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/save-pelaksanaan-perbaikan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePelaksanaanPerbaikan(@Valid @RequestBody ItPelaksanaanPerbaikanVO vo, HttpServletRequest request) {
try {
//Map<String,Object> result = service.savePelaksanaanPerbaikan(vo);
Map<String,Object> result = this.service.savePelaksanaanPerbaikanRev1(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when savePelaksanaanPerbaikan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when savePelaksanaanPerbaikan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-all-It-perbaikan-by-norec", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getAllItPerbaikanByNoRec(
@RequestParam(value = "noRec", required = true) String noRec,
@RequestMapping(value = "/find-asset-by-ruangan", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getAsetPerbaikan(@RequestParam(value = "id") Integer id,
HttpServletRequest request) {
try {
Map<String,Object> result = service.getAllItPerbaikanByNoRec(noRec);
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
} else{
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
Map<String, Object> result = service.getAsetPerbaikan(id);
if (null != result) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getAllItPerbaikanByNoRec", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when find asset by ruangan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getAllItPerbaikanByNoRec", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when find asset by ruangan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/delete-list-perbaikan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> deleteListPerbaikann(
@RequestParam(value = "noRec", required = true) String noRec,
@RequestMapping(value = "/save-pelaksanaan-perbaikan", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePelaksanaanPerbaikan(@Valid @RequestBody ItPelaksanaanPerbaikanVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = this.service.savePelaksanaanPerbaikanRev1(vo);
if (null != result)
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got ServiceVOException {} when save pelaksanaan perbaikan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got JpaSystemException {} when save pelaksanaan perbaikan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/delete-list-perbaikan", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<String> deleteListPerbaikann(@RequestParam(value = "noRec") String noRec,
HttpServletRequest request) {
try {
Boolean status = service.deleteItPerbaikan(noRec);
if (status){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse("noRec : "+noRec, HttpStatus.OK);
} else{
return RestUtil.getJsonResponse("noRec : null", HttpStatus.BAD_REQUEST);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when deleteListPerbaikann", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when deleteListPerbaikann", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/update-data-perbaikan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> updateDataPerbaikan(@Valid @RequestBody ItPerbaikanVO vo, HttpServletRequest request) {
try {
Map<String, Object> result = service.updatePermintaanPerbaikan(vo);
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when updateJadwalPerbaikanDariRuangan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getJadwalPerbaikanDariRuangan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE);
}
@RequestMapping(value="/get-pelaksanaan-perbaikan-all",
method=RequestMethod.GET,
produces=MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> getPelaksanaanPerbaikanAll(
@RequestParam("startDate")String startDate, @RequestParam("endDate")String endDate, HttpServletRequest request) {
Map<String, Object> result = this.service.getPelaksanaanPerbaikIt(startDate, endDate);
return result;
}
@RequestMapping(value="/get-pelaksanaan-perbaikan-by-noRec",
method=RequestMethod.GET,
produces=MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> getPelaksanaanPerbaikanbyNoRec(
@RequestParam("noRec")String noRec, HttpServletRequest request) {
Map<String, Object> result = this.service.getPelaksanaanPerbaikItByNoRec(noRec);
return result;
}
@RequestMapping(value="/get-kategori-kerusakan-iti",
method=RequestMethod.GET,
produces=MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> getKategoriKerusakan(HttpServletRequest request) {
Map<String, Object> result = this.service.getKategoriKerusakan();
return result;
}
@RequestMapping(value = "/get-asset-by-kelompok-produk",
method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getAssetByKelompokProduk(
@RequestParam(value = "id", required = true) Integer id,
HttpServletRequest request) {
try {
Map<String,Object> result = service.getAssetByKelompokProduk(id);
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
} else{
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
if (status) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse("noRec : " + noRec, OK);
} else {
return getJsonResponse("noRec : null", HttpStatus.BAD_REQUEST);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when get-asset-by-kelompok-produk", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when delete list perbaikan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when get-asset-by-kelompok-produk", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when delete list perbaikan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-kategori-kerusakan-iti", method = GET, produces = APPLICATION_JSON_VALUE)
public Map<String, Object> getKategoriKerusakan(HttpServletRequest request) {
return this.service.getKategoriKerusakan();
}
}

View File

@ -1,42 +1,38 @@
package com.jasamedika.medifirst2000.controller.base;
import com.jasamedika.medifirst2000.base.vo.BaseModelVO;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.jasamedika.medifirst2000.base.vo.BaseModelVO;
import static org.springframework.web.bind.annotation.RequestMethod.*;
/**
* Base Rest Operation for Controller Class
*
* @author Roberto
*/
public interface IBaseRestController<V extends BaseModelVO> extends
IRestPageController<V> {
public interface IBaseRestController<V extends BaseModelVO> extends IRestPageController<V> {
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@RequestMapping(value = "/{id}", method = GET)
@ResponseBody
public ResponseEntity<V> getVO(@PathVariable("id") Integer id);
ResponseEntity<V> getVO(@PathVariable("id") Integer id);
@RequestMapping(value = "/", method = RequestMethod.PUT, consumes = { "application/json" })
@RequestMapping(value = "/", method = PUT, consumes = { "application/json" })
@ResponseBody
public ResponseEntity<String> addVO(@RequestBody V vo);
ResponseEntity<String> addVO(@RequestBody V vo);
@RequestMapping(value = "/", method = RequestMethod.POST, consumes = { "application/json" })
@RequestMapping(value = "/", method = POST, consumes = { "application/json" })
@ResponseBody
public ResponseEntity<String> editVO(@RequestBody V vo);
ResponseEntity<String> editVO(@RequestBody V vo);
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@RequestMapping(value = "/{id}", method = DELETE)
@ResponseBody
public ResponseEntity<String> deleteVO(@PathVariable("id") Integer id);
ResponseEntity<String> deleteVO(@PathVariable("id") Integer id);
@RequestMapping(value = "/", method = RequestMethod.GET)
@RequestMapping(value = "/", method = GET)
@ResponseBody
public ResponseEntity<List<V>> getAllVO();
ResponseEntity<List<V>> getAllVO();
}