package com.jasamedika.medifirst2000.controller; import java.text.ParseException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; 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.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.IndikatorBIOSService; import com.jasamedika.medifirst2000.service.IndikatorBIOSTransaksiService; import com.jasamedika.medifirst2000.service.PasienDaftarService; import com.jasamedika.medifirst2000.service.PelayananPasienService; import com.jasamedika.medifirst2000.service.ProdukService; import com.jasamedika.medifirst2000.service.SatuanStandarService; import com.jasamedika.medifirst2000.util.CommonUtil; import com.jasamedika.medifirst2000.util.rest.RestUtil; import com.jasamedika.medifirst2000.vo.IndikatorBIOSTransaksiVO; import com.jasamedika.medifirst2000.vo.IndikatorBIOSVO; import com.jasamedika.medifirst2000.vo.PelayananPasienVO; @RestController @RequestMapping("/pelayanan") public class PelayananController extends LocaleController { private static final Logger LOGGER = LoggerFactory.getLogger(PelayananController.class); @Autowired private PelayananPasienService pelayananPasienService; @Autowired private PasienDaftarService pasienDaftarService; @Autowired private IndikatorBIOSService indikatorBIOSService; @Autowired private IndikatorBIOSTransaksiService indikatorBIOSTransaksiService; @Autowired private ProdukService produkService; @Autowired private SatuanStandarService satuanStandarService; @RequestMapping(value = "/calculate-indikator-pelayanan", method = RequestMethod.GET) public ResponseEntity>> calculateIndikatorPelayanan(HttpServletRequest request, @RequestParam("tahun") String tahun) throws ParseException { try { List> result = pasienDaftarService.findIndikatorPelayanan(tahun); mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage); } catch (ServiceVOException sve) { LOGGER.error("Got exception {} when calculate indikator pelayanan", sve.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { LOGGER.error("Got exception {} when calculate indikator pelayanan", jse.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); } } @RequestMapping(value = "/save-transaksi-indikator-bios", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity>> saveTransaksiIndikatorBIOS( @Valid @RequestBody List vos, HttpServletRequest request) { try { List> result = indikatorBIOSService.saveIndikatorBIOSTransaksi(vos); 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 save transaksi indikator bios", 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 save transaksi indikator bios", jse.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); } } @RequestMapping(value = "/save-master-indikator-bios", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> saveMasterIndikatorBIOS(HttpServletRequest request, @Valid @RequestBody IndikatorBIOSVO vo) { Map result = new HashMap(); try { IndikatorBIOSVO resultVo = new IndikatorBIOSVO(); if (CommonUtil.isNotNullOrEmpty(vo.getId())) { resultVo = indikatorBIOSService.update(vo); } else { resultVo = indikatorBIOSService.add(vo); } result.put("data", resultVo); if (CommonUtil.isNotNullOrEmpty(result)) { mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); } else { return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE); } } catch (ServiceVOException sve) { LOGGER.error("Got exception {} when add/update master indikator", sve.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { LOGGER.error("Got exception {} when add/update master indikator", jse.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); } } @RequestMapping(value = "/hitung-simpan-bios-layanan-kesehatan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> hitungSimpanBIOSLayananKesehatan(HttpServletRequest request, @RequestParam("tglAwal") String tglAwal, @RequestParam("tglAkhir") String tglAkhir) throws ParseException { try { Map result = new HashMap(); List resultVO = indikatorBIOSTransaksiService .hitungSimpanLayananKesehatanPeriode(tglAwal, tglAkhir); result.put("data", resultVO); if (CommonUtil.isNotNullOrEmpty(result)) { mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); } else { return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE); } } catch (ServiceVOException sve) { LOGGER.error("Got exception {} when get hitung simpan layanan kesehatan", sve.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { LOGGER.error("Got exception {} when get hitung simpan layanan kesehatan", jse.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); } } @RequestMapping(value = "/hitung-simpan-bios-jumlah-pasien", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> hitungSimpanBIOSJumlahPasien(HttpServletRequest request, @RequestParam("tglAwal") String tglAwal, @RequestParam("tglAkhir") String tglAkhir) throws ParseException { try { Map result = new HashMap(); List resultVO = indikatorBIOSTransaksiService .hitungSimpanJumlahPasienPeriode(tglAwal, tglAkhir); result.put("data", resultVO); if (CommonUtil.isNotNullOrEmpty(result)) { mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); } else { return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE); } } catch (ServiceVOException sve) { LOGGER.error("Got exception {} when hitung simpan data jumlah pasien", sve.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { LOGGER.error("Got exception {} when hitung simpan data jumlah pasien", jse.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); } } @RequestMapping(value = "/hitung-simpan-bios-indikator-pelayanan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> hitungSimpanBIOSIndikatorPelayanan(HttpServletRequest request, @RequestParam("tglAwal") String tglAwal, @RequestParam("tglAkhir") String tglAkhir) throws ParseException { try { Map result = new HashMap(); List resultVO = indikatorBIOSTransaksiService .hitungSimpanIndikatorPelayananPeriode(tglAwal, tglAkhir); result.put("data", resultVO); if (CommonUtil.isNotNullOrEmpty(result)) { mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); } else { return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE); } } catch (ServiceVOException sve) { LOGGER.error("Got exception {} when hitung simpan data indikator pelayanan", sve.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { LOGGER.error("Got exception {} when hitung simpan data indikator pelayanan", jse.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); } } @RequestMapping(value = "/indikator-lainnya", method = RequestMethod.GET) public ResponseEntity>> getIndikatorLainnya(HttpServletRequest request) { try { List> result = indikatorBIOSService.findAllIndikatorLainnya(); mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage); } catch (ServiceVOException sve) { LOGGER.error("Got exception {} when get list indikator lainnya", sve.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { LOGGER.error("Got exception {} when get list indikator lainnya", jse.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); } } @RequestMapping(value = "/indikator-penerimaan-keuangan", method = RequestMethod.GET) public ResponseEntity>> getIndikatorPenerimaanKeuangan(HttpServletRequest request) { try { List> result = indikatorBIOSService.findAllIndikatorPenerimaanKeuangan(); mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage); } catch (ServiceVOException sve) { LOGGER.error("Got exception {} when get list indikator penerimaan keuangan", sve.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { LOGGER.error("Got exception {} when get list indikator penerimaan keuangan", jse.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); } } @RequestMapping(value = "/indikator-pengeluaran-keuangan", method = RequestMethod.GET) public ResponseEntity>> getIndikatorPengeluaranKeuangan(HttpServletRequest request) { try { List> result = indikatorBIOSService.findAllIndikatorPengeluaranKeuangan(); mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage); } catch (ServiceVOException sve) { LOGGER.error("Got exception {} when get list indikator pengeluaran keuangan", sve.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { LOGGER.error("Got exception {} when get list indikator pengeluaran keuangan", jse.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); } } @RequestMapping(value = "/check-saldo-awal-exists", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity checkSaldoAwalExists( @RequestParam(value = "indikatorId", required = false) Integer idIndikator, HttpServletRequest request) { try { Boolean result = indikatorBIOSTransaksiService.isSaldoAwalExists(idIndikator); if (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 check saldo awal was exists", 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 check saldo awal was exists", jse.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); } } @RequestMapping(value = "/validate-nama-produk", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> validateNamaProduk(HttpServletRequest request, @RequestParam(value = "idProduk", required = false) Integer idProduk, @RequestParam(value = "namaProduk", required = true) String namaProduk) { try { Map result = produkService.validateNamaProduk(idProduk, namaProduk); return RestUtil.getJsonResponse(result, HttpStatus.OK); } catch (ServiceVOException e) { LOGGER.error("Got exception {} when validate nama produk", 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 validate nama produk", jse.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); } } @RequestMapping(value = "/paket-to-produk", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> getMappingPaketToProduk(HttpServletRequest request, @RequestParam(value = "idMapping", required = true) Integer idMapping) { try { Map result = produkService.getMappingPaketToProduk(idMapping); return RestUtil.getJsonResponse(result, HttpStatus.OK); } catch (ServiceVOException e) { LOGGER.error("Got exception {} when get mapping paket to produk", 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 mapping paket to produk", jse.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); } } @RequestMapping(value = "/all-paket-produk", method = RequestMethod.GET) public ResponseEntity>> getAllPaketToProduk(HttpServletRequest request) { try { List> result = produkService.getAllPaketToProduk(); mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage); } catch (ServiceVOException sve) { LOGGER.error("Got exception {} when get all data paket to produk", sve.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { LOGGER.error("Got exception {} when get all data paket to produk", jse.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); } } @RequestMapping(value = "/master-satuan-standar", method = RequestMethod.GET) public ResponseEntity>> getAllMasterSatuanStandar(HttpServletRequest request) { List> result = new ArrayList<>(); try { result = satuanStandarService.getAll(); mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage); } catch (ServiceVOException sve) { LOGGER.error("Got exception {} when get all master satuan standar distinct on", sve.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { LOGGER.error("Got exception {} when get all master satuan standar distinct on", jse.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); } } @RequestMapping(value = "/klaim-diskon-karyawan", method = RequestMethod.GET) public ResponseEntity> updateKlaimDiskonKaryawan(HttpServletRequest request, @RequestParam(value = "noRegistrasi", required = true) String noRegistrasi, @RequestParam(value = "totalKlaim", required = true) Double totalKlaim) { try { List result = pelayananPasienService.updateKlaimDiskonKaryawan(noRegistrasi, totalKlaim); 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 klaim diskon karyawan", 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 klaim diskon karyawan", jse.getMessage()); addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); } } }