Merge branch 'dev/paket/validasi-voucher' into dev/no-cron

This commit is contained in:
Salman Manoe 2024-11-18 13:34:14 +07:00
commit 9c49ef2d3a
12 changed files with 266 additions and 53 deletions

View File

@ -13,9 +13,11 @@ import java.util.Set;
* @since 21 Sep 2023
*/
public interface MapProdukPaketDao extends JpaRepository<MapProdukPaket, String> {
@Query("select mpaket.paketId from MapProdukPaket mpaket")
Set<Integer> findPaketId();
@Query("select mpaket.produkEntriId from MapProdukPaket mpaket")
List<Integer> findProdukEntriId();
}

View File

@ -0,0 +1,17 @@
package com.jasamedika.medifirst2000.dao;
import com.jasamedika.medifirst2000.entities.ProdukPaket;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.Optional;
/**
* @author salmanoe
* @version 1.0.0
* @since 14/11/2024
*/
public interface ProdukPaketDao extends JpaRepository<ProdukPaket, Integer> {
Optional<ProdukPaket> findById(Integer id);
}

View File

@ -0,0 +1,14 @@
package com.jasamedika.medifirst2000.service;
import com.jasamedika.medifirst2000.dto.ProdukPaketDto;
/**
* @author salmanoe
* @version 1.0.0
* @since 14/11/2024
*/
public interface ProdukPaketService {
void save(ProdukPaketDto dto);
}

View File

@ -46,6 +46,7 @@ import static com.jasamedika.medifirst2000.constants.Master.Ruangan.*;
import static com.jasamedika.medifirst2000.constants.Master.SubUnitKerja.*;
import static com.jasamedika.medifirst2000.constants.Master.TipePegawai.PURNA_WAKTU;
import static com.jasamedika.medifirst2000.constants.Master.UnitKerja.KSM_OBGYN;
import static com.jasamedika.medifirst2000.entities.constant.TipePaket.PERSALINAN;
import static com.jasamedika.medifirst2000.enums.JenisMappingProdukPaket.PERAWAT;
import static com.jasamedika.medifirst2000.enums.JenisMappingProdukPaket.TINDAKAN_UTAMA;
@ -151,6 +152,9 @@ public class PelayananPasienServiceImpl extends BaseVoServiceImpl implements Pel
@Autowired
private MapJabatanProfesiDao mapJabatanProfesiDao;
@Autowired
private ProdukPaketDao produkPaketDao;
@Override
public Map<String, Object> savePelayananPasien(PelayananPasienVO vo) {
Map<String, Object> result = new HashMap<>();
@ -3697,6 +3701,7 @@ public class PelayananPasienServiceImpl extends BaseVoServiceImpl implements Pel
private void diskonPaket(String kodeVoucher, List<TagihanPendaftaranDto> dtoList) {
VoucherPaket voucher = getVoucher(kodeVoucher, false);
Optional<ProdukPaket> produkPaket = produkPaketDao.findById(voucher.getPaketId());
List<String> norecPelayanan = dtoList.stream().map(TagihanPendaftaranDto::getNoRec)
.collect(Collectors.toList());
List<PelayananPasien> byNorecPelayanan = pelayananPasienDao.findAll(norecPelayanan);
@ -3709,11 +3714,14 @@ public class PelayananPasienServiceImpl extends BaseVoServiceImpl implements Pel
Integer ibuId = null;
if (CommonUtil.isNotNullOrEmpty(ibuNoCm))
ibuId = pasienDao.findIdByNoCm(ibuNoCm);
if ((CommonUtil.isNotNullOrEmpty(ibuId) && !voucher.getPasienId().equals(ibuId))
|| (CommonUtil.isNullOrEmpty(ibuId) && !voucher.getPasienId().equals(pasienId)))
throw new ServiceVOException("Kode voucher tidak sesuai dengan pasien yang diperuntukkan");
p.setVoucherPaket(voucher);
pasienDaftarDao.save(p);
if (CommonUtil.isNotNullOrEmpty(produkPaket) && produkPaket.isPresent()
&& PERSALINAN.equals(produkPaket.get().getTipePaket())) {
if ((CommonUtil.isNotNullOrEmpty(ibuId) && !voucher.getPasienId().equals(ibuId))
|| (CommonUtil.isNullOrEmpty(ibuId) && !voucher.getPasienId().equals(pasienId)))
throw new ServiceVOException("Kode voucher tidak sesuai dengan pasien yang diperuntukkan");
p.setVoucherPaket(voucher);
pasienDaftarDao.save(p);
}
});
}
{
@ -3979,15 +3987,19 @@ public class PelayananPasienServiceImpl extends BaseVoServiceImpl implements Pel
if (noRegistrasi.isEmpty())
throw new ServiceVOException("Nomor registrasi harus diisi");
VoucherPaket voucher = getVoucher(kodeVoucher, basicValidation);
Optional<ProdukPaket> produkPaket = produkPaketDao.findById(voucher.getPaketId());
PasienDaftar pendaftaran = pasienDaftarDao.findByNoRegistrasi(noRegistrasi);
String ibuNoCm = pendaftaran.getPasien().getReportDisplay();
Integer ibuId = null;
if (CommonUtil.isNotNullOrEmpty(ibuNoCm))
ibuId = pasienDao.findIdByNoCm(ibuNoCm);
if ((CommonUtil.isNotNullOrEmpty(ibuId) && !voucher.getPasienId().equals(ibuId))
|| (CommonUtil.isNullOrEmpty(ibuId) && CommonUtil.isNotNullOrEmpty(pendaftaran)
&& !pendaftaran.getPasien().getId().equals(voucher.getPasienId())))
throw new ServiceVOException("Kode voucher tidak sesuai dengan pasien yang diperuntukkan");
if (CommonUtil.isNotNullOrEmpty(produkPaket) && produkPaket.isPresent()
&& PERSALINAN.equals(produkPaket.get().getTipePaket())) {
if ((CommonUtil.isNotNullOrEmpty(ibuId) && !voucher.getPasienId().equals(ibuId))
|| (CommonUtil.isNullOrEmpty(ibuId) && CommonUtil.isNotNullOrEmpty(pendaftaran)
&& !pendaftaran.getPasien().getId().equals(voucher.getPasienId())))
throw new ServiceVOException("Kode voucher tidak sesuai dengan pasien yang diperuntukkan");
}
return voucher;
}

View File

@ -0,0 +1,37 @@
package com.jasamedika.medifirst2000.service.impl;
import com.jasamedika.medifirst2000.dao.ProdukDao;
import com.jasamedika.medifirst2000.dao.ProdukPaketDao;
import com.jasamedika.medifirst2000.dto.ProdukPaketDto;
import com.jasamedika.medifirst2000.entities.Produk;
import com.jasamedika.medifirst2000.entities.ProdukPaket;
import com.jasamedika.medifirst2000.service.ProdukPaketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* @author salmanoe
* @version 1.0.0
* @since 14/11/2024
*/
@Service
@Transactional
public class ProdukPaketServiceImpl implements ProdukPaketService {
@Autowired
private ProdukPaketDao produkPaketDao;
@Autowired
private ProdukDao produkDao;
@Override
public void save(ProdukPaketDto dto) {
Produk paket = produkDao.findByIdProduk(dto.getProduk().getId());
ProdukPaket produkPaket = ProdukPaket.builder().produk(paket).tipePaket(dto.getTipePaket()).build();
produkPaket.setStatusEnabled(true);
produkPaket.setKdProfile((short) 0);
produkPaketDao.save(produkPaket);
}
}

View File

@ -0,0 +1,30 @@
package com.jasamedika.medifirst2000.dto;
import com.jasamedika.medifirst2000.entities.ProdukDto;
import com.jasamedika.medifirst2000.entities.constant.TipePaket;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author salmanoe
* @version 1.0.0
* @since 14/11/2024
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ProdukPaketDto {
private Integer id;
@Caption(value = "Produk")
private ProdukDto produk;
@Caption("Tipe paket")
private TipePaket tipePaket;
}

View File

@ -1,7 +1,6 @@
package com.jasamedika.medifirst2000.entities;
import com.jasamedika.medifirst2000.base.BaseTransaction;
import com.jasamedika.medifirst2000.entities.constant.JenisPaket;
import com.jasamedika.medifirst2000.enums.JenisMappingProdukPaket;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
@ -9,7 +8,6 @@ import lombok.Setter;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import static javax.persistence.EnumType.STRING;
import static javax.persistence.FetchType.LAZY;
@ -25,6 +23,7 @@ import static javax.persistence.FetchType.LAZY;
@Table(name = "mapprodukpaket_m", uniqueConstraints = {
@UniqueConstraint(columnNames = { "paketfk", "produkPaketfk" }), })
public class MapProdukPaket extends BaseTransaction {
@ManyToOne(fetch = LAZY)
@JoinColumn(name = "paketfk")
@NotNull(message = "Paket tidak boleh kosong")
@ -54,9 +53,4 @@ public class MapProdukPaket extends BaseTransaction {
@Caption(value = "Status Aktif")
private Boolean isAktif;
@Column(length = 30)
@Enumerated(STRING)
@Size(max = 30, message = "Jenis paket maksimal {max} karakter")
@Caption(value = "Jenis paket")
private JenisPaket jenisPaket;
}

View File

@ -0,0 +1,46 @@
package com.jasamedika.medifirst2000.entities;
import com.jasamedika.medifirst2000.base.BaseActive;
import com.jasamedika.medifirst2000.entities.constant.TipePaket;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.*;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import static javax.persistence.EnumType.STRING;
import static javax.persistence.GenerationType.SEQUENCE;
/**
* @author salmanoe
* @version 1.0.0
* @since 13/11/2024
*/
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@Table(name = "produkpaket_m")
public class ProdukPaket extends BaseActive implements Serializable {
@Id
@GeneratedValue(strategy = SEQUENCE)
@Column(name = "id")
private Integer id;
@OneToOne
@MapsId
@JoinColumn(name = "id")
@NotNull(message = "Produk tidak boleh kosong")
@Caption(value = "Produk")
private Produk produk;
@Column(length = 30)
@Enumerated(STRING)
@Caption("Tipe paket")
private TipePaket tipePaket;
}

View File

@ -7,7 +7,7 @@ import lombok.Getter;
* @version 1.0.0
* @since 13/11/2024
*/
public enum JenisPaket {
public enum TipePaket {
PERSALINAN(1, "Persalinan");
@ -16,7 +16,7 @@ public enum JenisPaket {
@Getter
private final String name;
JenisPaket(long id, String name) {
TipePaket(long id, String name) {
this.id = id;
this.name = name;
}
@ -30,10 +30,10 @@ public enum JenisPaket {
return Long.toString(id);
}
public static JenisPaket valueOf(long id) {
for (JenisPaket jenisPaket : values()) {
if (jenisPaket.id == id) {
return jenisPaket;
public static TipePaket valueOf(long id) {
for (TipePaket tipePaket : values()) {
if (tipePaket.id == id) {
return tipePaket;
}
}
throw new IllegalArgumentException("No matching constant for [" + id + "]");

View File

@ -3,7 +3,6 @@ package com.jasamedika.medifirst2000.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.jasamedika.medifirst2000.base.vo.BaseTransactionVO;
import com.jasamedika.medifirst2000.entities.ProdukDto;
import com.jasamedika.medifirst2000.entities.constant.JenisPaket;
import com.jasamedika.medifirst2000.enums.JenisMappingProdukPaket;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
@ -42,6 +41,4 @@ public class MapProdukPaketVO extends BaseTransactionVO {
@Caption(value = "Status Aktif")
private Boolean isAktif;
@Caption(value = "Jenis paket")
private JenisPaket jenisPaket;
}

View File

@ -59,11 +59,11 @@ public class PelayananController extends LocaleController<PelayananPasienVO> {
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());
LOGGER.error("Got ServiceVOException {} 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());
LOGGER.error("Got JpaSystemException {} when calculate indikator pelayanan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
@ -78,11 +78,11 @@ public class PelayananController extends LocaleController<PelayananPasienVO> {
return RestUtil.getJsonResponse(result, HttpStatus.OK);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when validate nama produk", e.getMessage());
LOGGER.error("Got ServiceVOException {} 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());
LOGGER.error("Got JpaSystemException {} when validate nama produk", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
@ -95,11 +95,11 @@ public class PelayananController extends LocaleController<PelayananPasienVO> {
Map<String, Object> 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());
LOGGER.error("Got ServiceVOException {} 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());
LOGGER.error("Got JpaSystemException {} when get mapping paket to produk", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
@ -113,11 +113,11 @@ public class PelayananController extends LocaleController<PelayananPasienVO> {
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());
LOGGER.error("Got ServiceVOException {} 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());
LOGGER.error("Got JpaSystemException {} when get all data paket to produk", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
@ -131,11 +131,11 @@ public class PelayananController extends LocaleController<PelayananPasienVO> {
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());
LOGGER.error("Got ServiceVOException {} 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());
LOGGER.error("Got JpaSystemException {} when get all master satuan standar distinct on", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
@ -152,11 +152,11 @@ public class PelayananController extends LocaleController<PelayananPasienVO> {
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());
LOGGER.error("Got ServiceVOException {} 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());
LOGGER.error("Got JpaSystemException {} when klaim diskon karyawan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
@ -172,11 +172,11 @@ public class PelayananController extends LocaleController<PelayananPasienVO> {
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());
LOGGER.error("Got ServiceVOException {} when reset 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());
LOGGER.error("Got JpaSystemException {} when reset klaim diskon karyawan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
@ -193,11 +193,11 @@ public class PelayananController extends LocaleController<PelayananPasienVO> {
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when check existing harga produk kelas", e.getMessage());
LOGGER.error("Got ServiceVOException {} when check existing harga produk kelas", 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 existing harga produk kelas", jse.getMessage());
LOGGER.error("Got JpaSystemException {} when check existing harga produk kelas", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
@ -212,11 +212,11 @@ public class PelayananController extends LocaleController<PelayananPasienVO> {
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when get daftar tagihan {}", e.getMessage(), noRegistrasi);
LOGGER.error("Got ServiceVOException {} when get daftar tagihan {}", e.getMessage(), noRegistrasi);
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when get daftar tagihan {}", jse.getMessage(), noRegistrasi);
LOGGER.error("Got JpaSystemException {} when get daftar tagihan {}", jse.getMessage(), noRegistrasi);
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
@ -232,12 +232,12 @@ public class PelayananController extends LocaleController<PelayananPasienVO> {
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(dtoList, HttpStatus.OK, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when simpan diskon tagihan", e.getMessage());
LOGGER.error("Got ServiceVOException {} when simpan diskon tagihan", e.getMessage());
Map<String, String> error = new HashMap<>();
error.put("bad_request", e.getMessage());
return RestUtil.getJsonResponse(null, HttpStatus.BAD_REQUEST, error);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when simpan diskon tagihan", jse.getMessage());
LOGGER.error("Got JpaSystemException {} when simpan diskon tagihan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
@ -251,12 +251,12 @@ public class PelayananController extends LocaleController<PelayananPasienVO> {
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(dto, HttpStatus.OK, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when batal diskon paket", e.getMessage());
LOGGER.error("Got ServiceVOException {} when batal diskon paket", e.getMessage());
Map<String, String> error = new HashMap<>();
error.put("bad_request", e.getMessage());
return RestUtil.getJsonResponse(null, HttpStatus.BAD_REQUEST, error);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when batal diskon paket", jse.getMessage());
LOGGER.error("Got JpaSystemException {} when batal diskon paket", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
@ -271,12 +271,12 @@ public class PelayananController extends LocaleController<PelayananPasienVO> {
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(validVoucher, HttpStatus.OK, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when check voucher validity", e.getMessage());
LOGGER.error("Got ServiceVOException {} when check voucher validity", e.getMessage());
Map<String, String> error = new HashMap<>();
error.put("bad_request", e.getMessage());
return RestUtil.getJsonResponse(false, HttpStatus.BAD_REQUEST, error);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when check voucher validity", jse.getMessage());
LOGGER.error("Got JpaSystemException {} when check voucher validity", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
@ -291,12 +291,12 @@ public class PelayananController extends LocaleController<PelayananPasienVO> {
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(vos, HttpStatus.OK, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when simpan mapping list produk paket", e.getMessage());
LOGGER.error("Got ServiceVOException {} when simpan mapping list produk paket", e.getMessage());
Map<String, String> error = new HashMap<>();
error.put("bad_request", e.getMessage());
return RestUtil.getJsonResponse(null, HttpStatus.BAD_REQUEST, error);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when simpan mapping list produk paket", jse.getMessage());
LOGGER.error("Got JpaSystemException {} when simpan mapping list produk paket", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
@ -311,14 +311,15 @@ public class PelayananController extends LocaleController<PelayananPasienVO> {
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(vos, HttpStatus.OK, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when simpan mapping entri produk paket", e.getMessage());
LOGGER.error("Got ServiceVOException {} when simpan mapping entri produk paket", e.getMessage());
Map<String, String> error = new HashMap<>();
error.put("bad_request", e.getMessage());
return RestUtil.getJsonResponse(null, HttpStatus.BAD_REQUEST, error);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when simpan mapping entri produk paket", jse.getMessage());
LOGGER.error("Got JpaSystemException {} when simpan mapping entri produk paket", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
}

View File

@ -0,0 +1,63 @@
package com.jasamedika.medifirst2000.controller;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.dto.ProdukPaketDto;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.ProdukPaketService;
import com.jasamedika.medifirst2000.vo.ProdukVO;
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;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
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.CREATED;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
/**
* @author salmanoe
* @version 1.0.0
* @since 14/11/2024
*/
@RestController
@RequestMapping("/produk")
public class ProdukController extends LocaleController<ProdukVO> {
private static final Logger LOGGER = LoggerFactory.getLogger(ProdukController.class);
@Autowired
private ProdukPaketService produkPaketService;
@RequestMapping(value = "/paket", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Object> simpanDiskonTagihan(HttpServletRequest request, @RequestBody ProdukPaketDto dto) {
try {
produkPaketService.save(dto);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(dto, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got ServiceVOException {} when simpan produk paket", e.getMessage());
Map<String, String> error = new HashMap<>();
error.put("bad_request", e.getMessage());
return getJsonResponse(null, HttpStatus.BAD_REQUEST, error);
} catch (JpaSystemException jse) {
LOGGER.error("Got JpaSystemException {} when simpan produk paket", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
}