Create service view daftar tagihan sebelum diskon

This commit is contained in:
Salman Manoe 2023-07-14 15:55:50 +07:00
parent 8ffe4036d2
commit 6ea45a2a35
5 changed files with 359 additions and 4 deletions

View File

@ -269,4 +269,16 @@ public interface PelayananPasienDao extends PagingAndSortingRepository<Pelayanan
+ "pr.namaProduk")
List<Map<String, Object>> findPelayananPasienByPetugasAndPelayananPasien(@Param("pegawaiId") Integer idPegawai,
@Param("norecs") List<String> norecs);
@Query("select new Map(pp.noRec as noRec," + "ru.id as idRuangan,ru.namaRuangan as namaRuangan,"
+ "pp.tglPelayanan as tglPelayanan,to_char(pp.tglPelayanan,'dd/MM/yyyy') as tglPelayananStr,"
+ "pr.id as idProduk,pr.namaProduk as namaProduk," + "kls.id as idKelas,kls.namaKelas as namaKelas,"
+ "pg.id as idPegawai,pg.namaLengkap as namaPegawai,"
+ "coalesce(pp.jumlah,0) as jumlah,coalesce(pp.hargaJual,0) as hargaJual,coalesce(pp.hargaDiscount,0) as hargaDiskon,coalesce(pp.jasa,0) as hargaJasa,"
+ "((coalesce(pp.hargaJual,0)-coalesce(pp.hargaDiscount,0))*coalesce(pp.jumlah,0)+coalesce(pp.jasa,0)) as totalHargaJual) "
+ "from PelayananPasienPetugas ppp " + "inner join ppp.pelayananPasien pp "
+ "inner join pp.pasienDaftar apd " + "inner join apd.pasienDaftar pd " + "inner join apd.ruangan ru "
+ "inner join pp.produk pr " + "inner join pp.kelas kls " + "inner join ppp.kdpegawai pg "
+ "where pd.noRegistrasi = :noRegistrasi")
List<Map<String, Object>> findPelayananPasienByTagihanPendaftaran(@Param("noRegistrasi") String noRegistrasi);
}

View File

@ -3,6 +3,7 @@ package com.jasamedika.medifirst2000.service;
import java.util.List;
import java.util.Map;
import com.jasamedika.medifirst2000.dto.TagihanPendaftaranDto;
import com.jasamedika.medifirst2000.vo.PelayananPasienVO;
public interface PelayananPasienService {
@ -26,4 +27,8 @@ public interface PelayananPasienService {
List<Map<String, Object>> logbookFfsTarifDokter(Integer idPegawai, String bulan);
List<Map<String, Object>> detailLogbookTarifDokter(Integer idPegawai, List<String> norecs);
List<TagihanPendaftaranDto> tagihan(String noRegistrasi);
void diskonTagihan(List<TagihanPendaftaranDto> dto);
}

View File

@ -3,6 +3,7 @@ package com.jasamedika.medifirst2000.service.impl;
import com.jasamedika.medifirst2000.constants.Master;
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
import com.jasamedika.medifirst2000.dao.*;
import com.jasamedika.medifirst2000.dto.TagihanPendaftaranDto;
import com.jasamedika.medifirst2000.entities.*;
import com.jasamedika.medifirst2000.service.PelayananPasienService;
import com.jasamedika.medifirst2000.util.CommonUtil;
@ -2231,4 +2232,31 @@ public class PelayananPasienServiceImpl extends BaseVoServiceImpl implements Pel
return pelayananPasienDao.findPelayananPasienByPetugasAndPelayananPasien(idPegawai, norecs);
}
@Override
public List<TagihanPendaftaranDto> tagihan(String noRegistrasi) {
List<TagihanPendaftaranDto> result = new ArrayList<>();
TagihanPendaftaranDto.TagihanPendaftaranDtoBuilder dtoBuilder = TagihanPendaftaranDto.builder();
List<Map<String, Object>> tagihan = pelayananPasienDao.findPelayananPasienByTagihanPendaftaran(noRegistrasi);
tagihan.forEach(t -> {
dtoBuilder.noRec(t.get("noRec").toString()).idRuangan(Integer.parseInt(t.get("idRuangan").toString()))
.namaRuangan(t.get("namaRuangan").toString()).tglPelayanan((Date) t.get("tglPelayanan"))
.tglPelayananStr(t.get("tglPelayananStr").toString())
.idProduk(Integer.parseInt(t.get("idProduk").toString())).namaProduk(t.get("namaProduk").toString())
.idKelas(Integer.parseInt(t.get("idKelas").toString())).namaKelas(t.get("namaKelas").toString())
.idPegawai(Integer.parseInt(t.get("idPegawai").toString()))
.namaPegawai(t.get("namaPegawai").toString()).jumlah(Double.parseDouble(t.get("jumlah").toString()))
.hargaJual(Double.parseDouble(t.get("hargaJual").toString()))
.hargaDiskon(Double.parseDouble(t.get("hargaDiskon").toString()))
.hargaJasa(Double.parseDouble(t.get("hargaJasa").toString()))
.totalHargaJual(Double.parseDouble(t.get("totalHargaJual").toString()));
result.add(dtoBuilder.build());
});
return result;
}
@Override
public void diskonTagihan(List<TagihanPendaftaranDto> dto) {
}
}

View File

@ -0,0 +1,293 @@
package com.jasamedika.medifirst2000.dto;
import java.util.Date;
/**
* @author salmanoe
* @since 14 Jul 2023
*/
public class TagihanPendaftaranDto {
private String noRec;
private Integer idRuangan;
private String namaRuangan;
private Date tglPelayanan;
private String tglPelayananStr;
private Integer idProduk;
private String namaProduk;
private Integer idKelas;
private String namaKelas;
private Integer idPegawai;
private String namaPegawai;
private Double jumlah;
private Double hargaJual;
private Double hargaDiskon;
private Double hargaJasa;
private Double totalHargaJual;
public TagihanPendaftaranDto() {
}
public TagihanPendaftaranDto(String noRec, Integer idRuangan, String namaRuangan, Date tglPelayanan,
String tglPelayananStr, Integer idProduk, String namaProduk, Integer idKelas, String namaKelas,
Integer idPegawai, String namaPegawai, Double jumlah, Double hargaJual, Double hargaDiskon,
Double hargaJasa, Double totalHargaJual) {
super();
this.noRec = noRec;
this.idRuangan = idRuangan;
this.namaRuangan = namaRuangan;
this.tglPelayanan = tglPelayanan;
this.tglPelayananStr = tglPelayananStr;
this.idProduk = idProduk;
this.namaProduk = namaProduk;
this.idKelas = idKelas;
this.namaKelas = namaKelas;
this.idPegawai = idPegawai;
this.namaPegawai = namaPegawai;
this.jumlah = jumlah;
this.hargaJual = hargaJual;
this.hargaDiskon = hargaDiskon;
this.hargaJasa = hargaJasa;
this.totalHargaJual = totalHargaJual;
}
public String getNoRec() {
return noRec;
}
public void setNoRec(String noRec) {
this.noRec = noRec;
}
public Integer getIdRuangan() {
return idRuangan;
}
public void setIdRuangan(Integer idRuangan) {
this.idRuangan = idRuangan;
}
public String getNamaRuangan() {
return namaRuangan;
}
public void setNamaRuangan(String namaRuangan) {
this.namaRuangan = namaRuangan;
}
public Date getTglPelayanan() {
return tglPelayanan;
}
public void setTglPelayanan(Date tglPelayanan) {
this.tglPelayanan = tglPelayanan;
}
public String getTglPelayananStr() {
return tglPelayananStr;
}
public void setTglPelayananStr(String tglPelayananStr) {
this.tglPelayananStr = tglPelayananStr;
}
public Integer getIdProduk() {
return idProduk;
}
public void setIdProduk(Integer idProduk) {
this.idProduk = idProduk;
}
public String getNamaProduk() {
return namaProduk;
}
public void setNamaProduk(String namaProduk) {
this.namaProduk = namaProduk;
}
public Integer getIdKelas() {
return idKelas;
}
public void setIdKelas(Integer idKelas) {
this.idKelas = idKelas;
}
public String getNamaKelas() {
return namaKelas;
}
public void setNamaKelas(String namaKelas) {
this.namaKelas = namaKelas;
}
public Integer getIdPegawai() {
return idPegawai;
}
public void setIdPegawai(Integer idPegawai) {
this.idPegawai = idPegawai;
}
public String getNamaPegawai() {
return namaPegawai;
}
public void setNamaPegawai(String namaPegawai) {
this.namaPegawai = namaPegawai;
}
public Double getJumlah() {
return jumlah;
}
public void setJumlah(Double jumlah) {
this.jumlah = jumlah;
}
public Double getHargaJual() {
return hargaJual;
}
public void setHargaJual(Double hargaJual) {
this.hargaJual = hargaJual;
}
public Double getHargaDiskon() {
return hargaDiskon;
}
public void setHargaDiskon(Double hargaDiskon) {
this.hargaDiskon = hargaDiskon;
}
public Double getHargaJasa() {
return hargaJasa;
}
public void setHargaJasa(Double hargaJasa) {
this.hargaJasa = hargaJasa;
}
public Double getTotalHargaJual() {
return totalHargaJual;
}
public void setTotalHargaJual(Double totalHargaJual) {
this.totalHargaJual = totalHargaJual;
}
public static TagihanPendaftaranDtoBuilder builder() {
return new TagihanPendaftaranDtoBuilder();
}
public static class TagihanPendaftaranDtoBuilder {
private String noRec;
private Integer idRuangan;
private String namaRuangan;
private Date tglPelayanan;
private String tglPelayananStr;
private Integer idProduk;
private String namaProduk;
private Integer idKelas;
private String namaKelas;
private Integer idPegawai;
private String namaPegawai;
private Double jumlah;
private Double hargaJual;
private Double hargaDiskon;
private Double hargaJasa;
private Double totalHargaJual;
public TagihanPendaftaranDtoBuilder() {
}
public TagihanPendaftaranDtoBuilder noRec(final String noRec) {
this.noRec = noRec;
return this;
}
public TagihanPendaftaranDtoBuilder idRuangan(final Integer idRuangan) {
this.idRuangan = idRuangan;
return this;
}
public TagihanPendaftaranDtoBuilder namaRuangan(final String namaRuangan) {
this.namaRuangan = namaRuangan;
return this;
}
public TagihanPendaftaranDtoBuilder tglPelayanan(final Date tglPelayanan) {
this.tglPelayanan = tglPelayanan;
return this;
}
public TagihanPendaftaranDtoBuilder tglPelayananStr(final String tglPelayananStr) {
this.tglPelayananStr = tglPelayananStr;
return this;
}
public TagihanPendaftaranDtoBuilder idProduk(final Integer idProduk) {
this.idProduk = idProduk;
return this;
}
public TagihanPendaftaranDtoBuilder namaProduk(final String namaProduk) {
this.namaProduk = namaProduk;
return this;
}
public TagihanPendaftaranDtoBuilder idKelas(final Integer idKelas) {
this.idKelas = idKelas;
return this;
}
public TagihanPendaftaranDtoBuilder namaKelas(final String namaKelas) {
this.namaKelas = namaKelas;
return this;
}
public TagihanPendaftaranDtoBuilder idPegawai(final Integer idPegawai) {
this.idPegawai = idPegawai;
return this;
}
public TagihanPendaftaranDtoBuilder namaPegawai(final String namaPegawai) {
this.namaPegawai = namaPegawai;
return this;
}
public TagihanPendaftaranDtoBuilder jumlah(final Double jumlah) {
this.jumlah = jumlah;
return this;
}
public TagihanPendaftaranDtoBuilder hargaJual(final Double hargaJual) {
this.hargaJual = hargaJual;
return this;
}
public TagihanPendaftaranDtoBuilder hargaDiskon(final Double hargaDiskon) {
this.hargaDiskon = hargaDiskon;
return this;
}
public TagihanPendaftaranDtoBuilder hargaJasa(final Double hargaJasa) {
this.hargaJasa = hargaJasa;
return this;
}
public TagihanPendaftaranDtoBuilder totalHargaJual(final Double totalHargaJual) {
this.totalHargaJual = totalHargaJual;
return this;
}
public TagihanPendaftaranDto build() {
return new TagihanPendaftaranDto(this.noRec, this.idRuangan, this.namaRuangan, this.tglPelayanan,
this.tglPelayananStr, this.idProduk, this.namaProduk, this.idKelas, this.namaKelas, this.idPegawai,
this.namaPegawai, this.jumlah, this.hargaJual, this.hargaDiskon, this.hargaJasa,
this.totalHargaJual);
}
}
}

View File

@ -4,6 +4,7 @@ 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.dto.TagihanPendaftaranDto;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PasienDaftarService;
import com.jasamedika.medifirst2000.service.PelayananPasienService;
@ -18,10 +19,7 @@ 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.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@ -197,4 +195,23 @@ public class PelayananController extends LocaleController<PelayananPasienVO> {
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/tagihan/daftar/{noRegistrasi}", method = RequestMethod.GET)
public ResponseEntity<List<TagihanPendaftaranDto>> daftarTagihan(HttpServletRequest request,
@PathVariable String noRegistrasi) {
try {
List<TagihanPendaftaranDto> result = pelayananPasienService.tagihan(noRegistrasi);
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 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);
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
}