117 lines
5.7 KiB
Java
117 lines
5.7 KiB
Java
package com.jasamedika.medifirst2000.controller;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
import com.jasamedika.medifirst2000.constants.MessageResource;
|
|
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
|
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
|
import com.jasamedika.medifirst2000.service.KonsultasiService;
|
|
import com.jasamedika.medifirst2000.service.RegistrasiPelayananService;
|
|
import com.jasamedika.medifirst2000.vo.KonsultasiVO;
|
|
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.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.Collection;
|
|
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_ERROR;
|
|
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
|
|
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
|
|
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 KonsultasiController
|
|
*
|
|
* @author Askur
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/konsultasi")
|
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
public class KonsultasiController extends LocaleController<KonsultasiVO> {
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(KonsultasiController.class);
|
|
|
|
@Autowired
|
|
private KonsultasiService<KonsultasiVO> konsultasiService;
|
|
|
|
@Autowired
|
|
private RegistrasiPelayananService<RegistrasiPelayananVO> registrasiPelayananService;
|
|
|
|
@RequestMapping(value = "/save-konsultasi", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
|
public ResponseEntity<Map<String, Object>> save(@Valid @RequestBody KonsultasiVO vo, HttpServletRequest request) {
|
|
try {
|
|
Map<String, Object> result = konsultasiService.addKonsultasi(vo);
|
|
mapHeaderMessage.clear();
|
|
if (null != result) {
|
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
|
} else {
|
|
mapHeaderMessage.put(LABEL_ERROR, getMessage(MessageResource.LABEL_ERROR, request));
|
|
}
|
|
saveLog("Konsultasi", "Dokter");
|
|
return getJsonResponse(result, CREATED, mapHeaderMessage);
|
|
} catch (ServiceVOException e) {
|
|
LOGGER.error("Got ServiceVOException {} when addKonsultasi", e.getMessage());
|
|
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
|
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
|
} catch (JpaSystemException jse) {
|
|
LOGGER.error("Got JpaSystemException {} when addKonsultasi", jse.getMessage());
|
|
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
|
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
|
}
|
|
}
|
|
|
|
@RequestMapping(value = "/antrian-pasien-list-konsul/", method = GET, produces = APPLICATION_JSON_VALUE)
|
|
public ResponseEntity<Collection<KonsultasiVO>> getAllVOWithQueryString(
|
|
@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
|
|
@RequestParam(value = "limit", required = false, defaultValue = "50") Integer limit,
|
|
@RequestParam(value = "sort", required = false, defaultValue = "noRec") String sort,
|
|
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
|
|
@RequestParam(value = "ruanganId", required = false) Integer ruanganId,
|
|
@RequestParam(value = "dateStart", required = false) String dateStart,
|
|
@RequestParam(value = "dateEnd", required = false) String dateEnd,
|
|
@RequestParam(value = "noCm", required = false) String noCm,
|
|
@RequestParam(value = "pegawaiId", required = false) Integer pegawaiId) {
|
|
Map<String, Object> resultPageMap = registrasiPelayananService.findAllAntrianPagingKonsultasi(page, limit, sort,
|
|
dir, ruanganId, dateStart, dateEnd, noCm, pegawaiId);
|
|
return constructListPageResult(resultPageMap);
|
|
}
|
|
|
|
@RequestMapping(value = "/get-riwayat-konsultasi/{noCm}/{startDate}/{endDate}", method = GET, produces = APPLICATION_JSON_VALUE)
|
|
public ResponseEntity<List<Map<String, Object>>> getRiwayatKonsultasi(@PathVariable("noCm") String noCm,
|
|
@PathVariable("startDate") String startDate, @PathVariable("endDate") String endDate,
|
|
HttpServletRequest request) {
|
|
try {
|
|
List<Map<String, Object>> result = konsultasiService.getRiwayatKonsultasi(noCm, startDate, endDate);
|
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
|
return getJsonResponse(result, OK);
|
|
} catch (Exception e) {
|
|
throw new ServiceVOException(e.getMessage());
|
|
}
|
|
}
|
|
|
|
@RequestMapping(value = "/get-konsultasi-kosong", method = GET, produces = APPLICATION_JSON_VALUE)
|
|
public ResponseEntity<List<Map<String, Object>>> getKonsultasiKosong(HttpServletRequest request,
|
|
@RequestParam(value = "tglAwal") String strTglAwal, @RequestParam(value = "tglAkhir") String strTglAkhir) {
|
|
try {
|
|
List<Map<String, Object>> result = konsultasiService.findAllKonsultasiTindakanKosong(strTglAwal,
|
|
strTglAkhir);
|
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
|
return getJsonResponse(result, OK);
|
|
} catch (Exception e) {
|
|
throw new ServiceVOException(e.getMessage());
|
|
}
|
|
}
|
|
}
|