Update PelayananPasienServiceImpl.java
Perbaikan validasi kode voucher untuk registrasi anak
This commit is contained in:
parent
af41952f48
commit
bea9b0903e
@ -133,6 +133,9 @@ public class PelayananPasienServiceImpl extends BaseVoServiceImpl implements Pel
|
|||||||
@Autowired
|
@Autowired
|
||||||
private MapPelayananPasienPetugasToPegawaiDao mapPelayananPasienPetugasToPegawaiDao;
|
private MapPelayananPasienPetugasToPegawaiDao mapPelayananPasienPetugasToPegawaiDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PasienDao pasienDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> savePelayananPasien(PelayananPasienVO vo) {
|
public Map<String, Object> savePelayananPasien(PelayananPasienVO vo) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
@ -2276,8 +2279,14 @@ public class PelayananPasienServiceImpl extends BaseVoServiceImpl implements Pel
|
|||||||
.findFirst();
|
.findFirst();
|
||||||
pendaftaran.ifPresent(p -> {
|
pendaftaran.ifPresent(p -> {
|
||||||
Integer pasienId = p.getPasien().getId();
|
Integer pasienId = p.getPasien().getId();
|
||||||
if (!voucher.getPasienId().equals(pasienId))
|
String ibuNoCm = p.getPasien().getReportDisplay();
|
||||||
|
if (CommonUtil.isNotNullOrEmpty(ibuNoCm)) {
|
||||||
|
List<Pasien> ibu = pasienDao.findByNoCm(ibuNoCm.trim());
|
||||||
|
if (CommonUtil.isNotNullOrEmpty(ibu) && !voucher.getPasienId().equals(ibu.get(0).getId()))
|
||||||
throw new ServiceVOException("Kode voucher tidak sesuai dengan pasien yang diperuntukkan");
|
throw new ServiceVOException("Kode voucher tidak sesuai dengan pasien yang diperuntukkan");
|
||||||
|
} else if (!voucher.getPasienId().equals(pasienId)) {
|
||||||
|
throw new ServiceVOException("Kode voucher tidak sesuai dengan pasien yang diperuntukkan");
|
||||||
|
}
|
||||||
p.setVoucherPaket(voucher);
|
p.setVoucherPaket(voucher);
|
||||||
pasienDaftarDao.save(p);
|
pasienDaftarDao.save(p);
|
||||||
});
|
});
|
||||||
@ -2288,8 +2297,14 @@ public class PelayananPasienServiceImpl extends BaseVoServiceImpl implements Pel
|
|||||||
.findFirst();
|
.findFirst();
|
||||||
pendaftaran.ifPresent(p -> {
|
pendaftaran.ifPresent(p -> {
|
||||||
Integer pasienId = p.getPasien().getId();
|
Integer pasienId = p.getPasien().getId();
|
||||||
if (!voucher.getPasienId().equals(pasienId))
|
String ibuNoCm = p.getPasien().getReportDisplay();
|
||||||
|
if (CommonUtil.isNotNullOrEmpty(ibuNoCm)) {
|
||||||
|
List<Pasien> ibu = pasienDao.findByNoCm(ibuNoCm.trim());
|
||||||
|
if (CommonUtil.isNotNullOrEmpty(ibu) && !voucher.getPasienId().equals(ibu.get(0).getId()))
|
||||||
throw new ServiceVOException("Kode voucher tidak sesuai dengan pasien yang diperuntukkan");
|
throw new ServiceVOException("Kode voucher tidak sesuai dengan pasien yang diperuntukkan");
|
||||||
|
} else if (!voucher.getPasienId().equals(pasienId)) {
|
||||||
|
throw new ServiceVOException("Kode voucher tidak sesuai dengan pasien yang diperuntukkan");
|
||||||
|
}
|
||||||
p.setVoucherPaket(voucher);
|
p.setVoucherPaket(voucher);
|
||||||
pasienDaftarDao.save(p);
|
pasienDaftarDao.save(p);
|
||||||
});
|
});
|
||||||
@ -2299,7 +2314,7 @@ public class PelayananPasienServiceImpl extends BaseVoServiceImpl implements Pel
|
|||||||
.findAllByPaketId(voucher.getPaket().getId());
|
.findAllByPaketId(voucher.getPaket().getId());
|
||||||
List<Integer> idProdukMapping = mappingProdukPaket.stream().map(MapProdukPaketToProduk::getProdukId)
|
List<Integer> idProdukMapping = mappingProdukPaket.stream().map(MapProdukPaketToProduk::getProdukId)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
Optional<TagihanPendaftaranDto> dtoPaket = dtoList.stream().filter(dto -> dto.getIsPaket())
|
Optional<TagihanPendaftaranDto> dtoPaket = dtoList.stream().filter(TagihanPendaftaranDto::getIsPaket)
|
||||||
.filter(dto -> !idProdukMapping.contains(dto.getIdProduk()))
|
.filter(dto -> !idProdukMapping.contains(dto.getIdProduk()))
|
||||||
.filter(dto -> !dto.getIdProduk().equals(voucher.getPaketId())).findFirst();
|
.filter(dto -> !dto.getIdProduk().equals(voucher.getPaketId())).findFirst();
|
||||||
if (dtoPaket.isPresent())
|
if (dtoPaket.isPresent())
|
||||||
@ -2490,8 +2505,12 @@ public class PelayananPasienServiceImpl extends BaseVoServiceImpl implements Pel
|
|||||||
VoucherPaket voucher = getVoucher(kodeVoucher, noRegistrasi, false);
|
VoucherPaket voucher = getVoucher(kodeVoucher, noRegistrasi, false);
|
||||||
List<PasienDaftar> listPendaftaranLain = pasienDaftarDao
|
List<PasienDaftar> listPendaftaranLain = pasienDaftarDao
|
||||||
.findByPasienAndVoucherAndNoRegistrasiNot(voucher.getPasienId(), kodeVoucher, noRegistrasi);
|
.findByPasienAndVoucherAndNoRegistrasiNot(voucher.getPasienId(), kodeVoucher, noRegistrasi);
|
||||||
|
listPendaftaranLain.forEach(p -> {
|
||||||
|
if (p.getIsBatalPaket() == null)
|
||||||
|
p.setIsBatalPaket(false);
|
||||||
|
});
|
||||||
Optional<PasienDaftar> first = listPendaftaranLain.stream().filter(PasienDaftar::getIsBatalPaket).findFirst();
|
Optional<PasienDaftar> first = listPendaftaranLain.stream().filter(PasienDaftar::getIsBatalPaket).findFirst();
|
||||||
if (first.isPresent())
|
if (CommonUtil.isNotNullOrEmpty(first) && first.isPresent())
|
||||||
throw new ServiceVOException("Paket dengan menggunakan kode voucher ini sudah dibatalkan");
|
throw new ServiceVOException("Paket dengan menggunakan kode voucher ini sudah dibatalkan");
|
||||||
return !CommonUtil.isNullOrEmpty(voucher);
|
return !CommonUtil.isNullOrEmpty(voucher);
|
||||||
}
|
}
|
||||||
@ -2529,8 +2548,15 @@ public class PelayananPasienServiceImpl extends BaseVoServiceImpl implements Pel
|
|||||||
throw new ServiceVOException("Nomor registrasi harus diisi");
|
throw new ServiceVOException("Nomor registrasi harus diisi");
|
||||||
VoucherPaket voucher = getVoucher(kodeVoucher, basicValidation);
|
VoucherPaket voucher = getVoucher(kodeVoucher, basicValidation);
|
||||||
PasienDaftar pendaftaran = pasienDaftarDao.findByNoRegistrasi(noRegistrasi);
|
PasienDaftar pendaftaran = pasienDaftarDao.findByNoRegistrasi(noRegistrasi);
|
||||||
if (CommonUtil.isNotNullOrEmpty(pendaftaran) && !pendaftaran.getPasien().getId().equals(voucher.getPasienId()))
|
String ibuNoCm = pendaftaran.getPasien().getReportDisplay();
|
||||||
|
if (CommonUtil.isNotNullOrEmpty(ibuNoCm)) {
|
||||||
|
List<Pasien> ibu = pasienDao.findByNoCm(ibuNoCm.trim());
|
||||||
|
if (CommonUtil.isNotNullOrEmpty(ibu) && !voucher.getPasienId().equals(ibu.get(0).getId()))
|
||||||
throw new ServiceVOException("Kode voucher tidak sesuai dengan pasien yang diperuntukkan");
|
throw new ServiceVOException("Kode voucher tidak sesuai dengan pasien yang diperuntukkan");
|
||||||
|
} else if (CommonUtil.isNotNullOrEmpty(pendaftaran)
|
||||||
|
&& !pendaftaran.getPasien().getId().equals(voucher.getPasienId())) {
|
||||||
|
throw new ServiceVOException("Kode voucher tidak sesuai dengan pasien yang diperuntukkan");
|
||||||
|
}
|
||||||
return voucher;
|
return voucher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user