Update service pelayanan pasien
Penyesuaian diskon paket di verifikasi pasien pulang
This commit is contained in:
parent
87e70a29bd
commit
c687445e3a
@ -9,4 +9,12 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
* @since 16 Aug 2023
|
||||
*/
|
||||
public interface VoucherPaketDao extends JpaRepository<VoucherPaket, String> {
|
||||
/**
|
||||
* Query untuk mendapatkan data voucher paket berdasarkan kode yang diminta
|
||||
*
|
||||
* @param kode
|
||||
* sebuah <code>String</code> 7 karakter kode voucher
|
||||
* @return data entitas <code>VoucherPaket</code>
|
||||
*/
|
||||
VoucherPaket findByKode(String kode);
|
||||
}
|
||||
|
||||
@ -32,5 +32,5 @@ public interface PelayananPasienService {
|
||||
|
||||
List<TagihanPendaftaranDto> tagihan(String noRegistrasi);
|
||||
|
||||
void diskonTagihan(List<TagihanPendaftaranDto> dtoList);
|
||||
void diskonTagihan(String kodeVoucher, List<TagihanPendaftaranDto> dtoList);
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ import static com.jasamedika.medifirst2000.constants.Master.TipePegawai.PURNA_WA
|
||||
|
||||
/**
|
||||
* Implement class for PelayananPasienService
|
||||
*
|
||||
*
|
||||
* @author Generator
|
||||
*/
|
||||
@Service("pelayananPasienService")
|
||||
@ -92,6 +92,12 @@ public class PelayananPasienServiceImpl extends BaseVoServiceImpl implements Pel
|
||||
@Autowired
|
||||
private MapPegawaiLaboratRadiologiDao mapPegawaiLaboratRadiologiDao;
|
||||
|
||||
@Autowired
|
||||
private VoucherPaketDao voucherPaketDao;
|
||||
|
||||
@Autowired
|
||||
private MapProdukPaketToProdukDao mapProdukPaketToProdukDao;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> savePelayananPasien(PelayananPasienVO vo) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
@ -2198,25 +2204,67 @@ public class PelayananPasienServiceImpl extends BaseVoServiceImpl implements Pel
|
||||
}
|
||||
|
||||
@Override
|
||||
public void diskonTagihan(List<TagihanPendaftaranDto> dtoList) {
|
||||
{
|
||||
public void diskonTagihan(String kodeVoucher, List<TagihanPendaftaranDto> dtoList) {
|
||||
if (CommonUtil.isNullOrEmpty(kodeVoucher)) {
|
||||
List<Integer> listIdPegawai = mapPegawaiJabatanToUnitKerjaDao.findPegawaiIdByUnitKerjaIdAndJabatanId(48,
|
||||
1075);
|
||||
boolean accessGranted = loginUserService.accessGranted(loginUserService.getLoginUser(), listIdPegawai);
|
||||
if (!accessGranted)
|
||||
throw new ServiceVOException("Tidak memiliki akses diskon total");
|
||||
}
|
||||
List<String> listNoRec = dtoList.stream().map(TagihanPendaftaranDto::getNoRec).collect(Collectors.toList());
|
||||
List<PelayananPasien> listPelayanan = pelayananPasienDao.findAll(listNoRec);
|
||||
listPelayanan.forEach(p -> {
|
||||
Optional<TagihanPendaftaranDto> dto = dtoList.stream().filter(d -> d.getNoRec().equals(p.getNoRec()))
|
||||
.findFirst();
|
||||
dto.ifPresent(tagihanPendaftaranDto -> {
|
||||
p.setHargaDiscount(tagihanPendaftaranDto.getHargaDiskon());
|
||||
p.setJasa(tagihanPendaftaranDto.getHargaJasa());
|
||||
if (CommonUtil.isNotNullOrEmpty(kodeVoucher)) {
|
||||
VoucherPaket voucher = voucherPaketDao.findByKode(kodeVoucher);
|
||||
if (CommonUtil.isNullOrEmpty(voucher))
|
||||
throw new ServiceVOException("Kode voucher tidak ditemukan");
|
||||
if (voucher.getTglKedaluwarsa().before(new Date()))
|
||||
throw new ServiceVOException("Kode voucher sudah kedaluwarsa pada "
|
||||
+ new SimpleDateFormat("dd MMMM yyyy HH:mm:ss", new Locale("in", "ID"))
|
||||
.format(voucher.getTglKedaluwarsa()));
|
||||
List<String> listNoRec = dtoList.stream().filter(TagihanPendaftaranDto::getIsPaket)
|
||||
.map(TagihanPendaftaranDto::getNoRec).collect(Collectors.toList());
|
||||
List<PelayananPasien> listPelayanan = pelayananPasienDao.findAll(listNoRec);
|
||||
{
|
||||
Optional<PelayananPasien> byPasien = listPelayanan.stream().filter(
|
||||
p -> p.getPasien().getPasienDaftar().getPasien().getId().equals(voucher.getPasien().getId()))
|
||||
.findFirst();
|
||||
if (!byPasien.isPresent())
|
||||
throw new ServiceVOException("Kode voucher tidak sesuai dengan pasien yang diperuntukkan");
|
||||
}
|
||||
{
|
||||
List<Integer> listId = dtoList.stream().map(TagihanPendaftaranDto::getIdProduk)
|
||||
.collect(Collectors.toList());
|
||||
List<MapProdukPaketToProduk> detail = mapProdukPaketToProdukDao
|
||||
.findAllByPaketId(voucher.getPaket().getId());
|
||||
Optional<MapProdukPaketToProduk> byProduk = detail.stream()
|
||||
.filter(d -> !listId.contains(d.getProduk().getId())).findFirst();
|
||||
if (byProduk.isPresent())
|
||||
throw new ServiceVOException("Produk " + byProduk.get().getProduk().getNamaProduk()
|
||||
+ " tidak dapat didiskon karena belum dilakukan mapping");
|
||||
}
|
||||
listPelayanan.forEach(p -> {
|
||||
Optional<TagihanPendaftaranDto> dto = dtoList.stream().filter(d -> d.getNoRec().equals(p.getNoRec()))
|
||||
.findFirst();
|
||||
dto.ifPresent(tagihanPendaftaranDto -> {
|
||||
p.setHargaDiscount(tagihanPendaftaranDto.getHargaDiskon());
|
||||
p.setJasa(tagihanPendaftaranDto.getHargaJasa());
|
||||
p.setIsPasien(tagihanPendaftaranDto.getIsPaket());
|
||||
});
|
||||
});
|
||||
});
|
||||
pelayananPasienDao.save(listPelayanan);
|
||||
pelayananPasienDao.save(listPelayanan);
|
||||
} else {
|
||||
List<String> listNoRec = dtoList.stream().map(TagihanPendaftaranDto::getNoRec).collect(Collectors.toList());
|
||||
List<PelayananPasien> listPelayanan = pelayananPasienDao.findAll(listNoRec);
|
||||
listPelayanan.forEach(p -> {
|
||||
Optional<TagihanPendaftaranDto> dto = dtoList.stream().filter(d -> d.getNoRec().equals(p.getNoRec()))
|
||||
.findFirst();
|
||||
dto.ifPresent(tagihanPendaftaranDto -> {
|
||||
p.setHargaDiscount(tagihanPendaftaranDto.getHargaDiskon());
|
||||
p.setJasa(tagihanPendaftaranDto.getHargaJasa());
|
||||
});
|
||||
});
|
||||
pelayananPasienDao.save(listPelayanan);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -219,19 +219,20 @@ public class PelayananController extends LocaleController<PelayananPasienVO> {
|
||||
|
||||
@RequestMapping(value = "/tagihan/diskon/save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Object> simpanDiskonTagihan(HttpServletRequest request,
|
||||
@RequestParam(value = "kode-voucher", required = false) String kodeVoucher,
|
||||
@RequestBody List<TagihanPendaftaranDto> dtoList) {
|
||||
try {
|
||||
pelayananPasienService.diskonTagihan(dtoList);
|
||||
pelayananPasienService.diskonTagihan(kodeVoucher, dtoList);
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
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(), null);
|
||||
Map<String, String> error = new HashMap<String, String>();
|
||||
error.put("bad-request", e.getMessage());
|
||||
LOGGER.error("Got exception {} 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(), null);
|
||||
LOGGER.error("Got exception {} when simpan diskon tagihan", jse.getMessage());
|
||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
|
||||
@ -219,9 +219,10 @@ public class PelayananController extends LocaleController<PelayananPasienVO> {
|
||||
|
||||
@RequestMapping(value = "/tagihan/diskon/save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Object> simpanDiskonTagihan(HttpServletRequest request,
|
||||
@RequestParam(value = "kode-voucher", required = false) String kodeVoucher,
|
||||
@RequestBody List<TagihanPendaftaranDto> dtoList) {
|
||||
try {
|
||||
pelayananPasienService.diskonTagihan(dtoList);
|
||||
pelayananPasienService.diskonTagihan(kodeVoucher, dtoList);
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(dtoList, HttpStatus.OK, mapHeaderMessage);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user