Update PasienService

Pembuatan service check exists no bpjs calon pasien baru bpjs dari mobile jkn
This commit is contained in:
salmanoe 2022-12-10 20:05:56 +07:00
parent efe92e3a03
commit 3ebf039335
4 changed files with 70 additions and 200 deletions

View File

@ -20,6 +20,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.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -665,15 +666,31 @@ public class BridgingDaftarOnlineController {
public ResponseEntity<Object> saveNewPatient(@Valid @RequestBody PasienVO vo) {
try {
PasienVO result = pasienService.add(vo);
if (null != result)
return new ResponseEntity<>(true, HttpStatus.CREATED);
if (result != null)
return new ResponseEntity<>(result.getId(), HttpStatus.CREATED);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Pasien", e.getMessage());
return new ResponseEntity<>(false, HttpStatus.INTERNAL_SERVER_ERROR);
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Pasien", jse.getMessage());
return new ResponseEntity<>(false, HttpStatus.CONFLICT);
return new ResponseEntity<>(null, HttpStatus.CONFLICT);
}
return new ResponseEntity<>(false, HttpStatus.NOT_ACCEPTABLE);
return new ResponseEntity<>(null, HttpStatus.NOT_ACCEPTABLE);
}
@RequestMapping(value = "/bpjs/medical-record-id/patient/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> getPatientMedicalRecordId(@PathVariable Integer id) {
PasienVO result = pasienService.findById(id);
if (result != null)
return new ResponseEntity<>(result.getNoCm(), HttpStatus.OK);
return new ResponseEntity<>(null, HttpStatus.OK);
}
@RequestMapping(value = "/bpjs/card-number/{noBpjs}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Boolean> checkNoBPJSPasien(@PathVariable String noBpjs) {
PasienVO result = pasienService.findByNoBpjs(noBpjs);
if (result != null)
return new ResponseEntity<>(true, HttpStatus.OK);
return new ResponseEntity<>(null, HttpStatus.OK);
}
}

View File

@ -24,25 +24,18 @@ import com.jasamedika.medifirst2000.entities.Pasien;
*/
@Repository("PasienDao")
public interface PasienDao extends PagingAndSortingRepository<Pasien, Integer> {
// custom query
@Query("select model from Pasien model where model.namaPasien=:nama")
public List<Pasien> findPasienByNama(@Param("nama") String nama);
// @Query("select model from Pasien model join fetch model.agama join fetch
// model.jenisKelamin join fetch model.pekerjaan join fetch model.pendidikan
// join fetch model.statusPerkawinan where model.noCm = :noCm")
@Query("select model from Pasien model where model.noCm = :noCm")
public List<Pasien> findPasienBynoCm(@Param("noCm") String noCm);
// custom query WITH pagination
@Query("select model from Pasien model where model.namaPasien=:nama")
public Page<Pasien> findPagePasienByNama(@Param("nama") String nama, Pageable Page);
// custom query return map example
@Query("select new map(model.id as id, model.namaPasien as nama) from Pasien model")
public List<Map<String, String>> getMapPasien();
// native query example
@Query(value = "SELECT " + "namaPasien AS NAMA " + "FROM Pasien", nativeQuery = true)
List<Object[]> getNativePasien();
@ -51,9 +44,13 @@ public interface PasienDao extends PagingAndSortingRepository<Pasien, Integer> {
@Query("select model from Pasien model,DataAsuransi ap where ap.pasien.noCm = model.noCm and ap.noKepesertaan = :noBpjs")
public List<Pasien> findPasienBynoBpjs(@Param("noBpjs") String noBpjs);
/**
* Data asuransi di laravel sepertinya sudah tidak dipakai
*/
@Query("select model from Pasien model where model.noBpjs = :noBpjs")
public List<Pasien> findPasienByNoBpjs(@Param("noBpjs") String noBpjs);
// @Query("select model from Pasien model where model.noCm =:noCm")
// public List<Pasien> findByNoCm(String noCm);
@Query("select model from Pasien model where model.id =:id")
public Pasien findById(@Param("id") Integer id);

View File

@ -25,6 +25,8 @@ public interface PasienService<T> extends BaseVoService<Pasien, PasienVO, Intege
PasienVO findById(Integer key);
PasienVO findByNoCm(String key);
PasienVO findByNoBpjs(String noBpjs);
PasienVO findByNorecAntrian(String noRec);
@ -39,8 +41,6 @@ public interface PasienService<T> extends BaseVoService<Pasien, PasienVO, Intege
Pasien findPasienById(Integer key);
PasienVO findByNoBpjs(String noBpjs);
List<Map<String, Object>> findIbuAnak(Long tglAwal, Long tglAkhir);
}

View File

@ -96,6 +96,9 @@ public class PasienServiceImpl extends BaseVoServiceImpl implements PasienServic
@Autowired
private PasienDaoCustom pasienDaoCustom;
@Autowired
private BaseConverterImpl<PasienVO, Pasien> converterPasien;
@Autowired
private PasienConverter pasienConverter;
@ -177,28 +180,30 @@ public class PasienServiceImpl extends BaseVoServiceImpl implements PasienServic
if (CommonUtil.isNotNullOrEmpty(vo.getStatusPerkawinan()))
pasien.setStatusPerkawinan(
statusPerkawinanConverter.transferVOToModel(vo.getStatusPerkawinan(), new StatusPerkawinan()));
List<Alamat> listAlamat = new ArrayList<Alamat>();
for (AlamatVO alamatVo : vo.getAlamats()) {
Alamat alamat = new Alamat();
alamat = alamatConverter.transferVOToModel(alamatVo, new Alamat());
if (CommonUtil.isNotNullOrEmpty(alamatVo.getJenisAlamat()))
alamat.setJenisAlamat(jenisAlamatConverter.transferVOToModel(alamatVo.getJenisAlamat(), new JenisAlamat()));
if (CommonUtil.isNotNullOrEmpty(alamatVo.getPropinsi()))
alamat.setPropinsi(propinsiConverter.transferVOToModel(alamatVo.getPropinsi(), new Propinsi()));
if (CommonUtil.isNotNullOrEmpty(alamatVo.getNegara()))
alamat.setNegara(negaraConverter.transferVOToModel(alamatVo.getNegara(), new Negara()));
if (CommonUtil.isNotNullOrEmpty(alamatVo.getRekanan()))
alamat.setRekanan(rekananConverter.transferVOToModel(alamatVo.getRekanan(), new Rekanan()));
if (CommonUtil.isNotNullOrEmpty(alamatVo.getPegawai()))
alamat.setPegawai(loginUserConverter.transferVOToModel(alamatVo.getPegawai(), new LoginUser()));
alamat.setPasien(pasien);
listAlamat.add(alamat);
}
if (listAlamat.size() > 0)
pasien.getAlamats().addAll(listAlamat);
Pasien resultModel = pasienDao.save(pasien);
if (CommonUtil.isNotNullOrEmpty(resultModel.getId())) {
List<Alamat> listAlamat = new ArrayList<Alamat>();
for (AlamatVO alamatVo : vo.getAlamats()) {
Alamat alamat = new Alamat();
alamat = alamatConverter.transferVOToModel(alamatVo, new Alamat());
if (CommonUtil.isNotNullOrEmpty(alamatVo.getJenisAlamat()))
alamat.setJenisAlamat(
jenisAlamatConverter.transferVOToModel(alamatVo.getJenisAlamat(), new JenisAlamat()));
if (CommonUtil.isNotNullOrEmpty(alamatVo.getPropinsi()))
alamat.setPropinsi(propinsiConverter.transferVOToModel(alamatVo.getPropinsi(), new Propinsi()));
if (CommonUtil.isNotNullOrEmpty(alamatVo.getNegara()))
alamat.setNegara(negaraConverter.transferVOToModel(alamatVo.getNegara(), new Negara()));
if (CommonUtil.isNotNullOrEmpty(alamatVo.getRekanan()))
alamat.setRekanan(rekananConverter.transferVOToModel(alamatVo.getRekanan(), new Rekanan()));
if (CommonUtil.isNotNullOrEmpty(alamatVo.getPegawai()))
alamat.setPegawai(loginUserConverter.transferVOToModel(alamatVo.getPegawai(), new LoginUser()));
alamat.setPasien(resultModel);
listAlamat.add(alamat);
}
alamatDao.save(listAlamat);
}
PasienVO resultVo = new PasienVO();
pasienConverter.transferModelToVO(resultModel, resultVo);
resultVo = converterPasien.transferModelToVO(resultModel, resultVo);
return resultVo;
}
@ -216,47 +221,29 @@ public class PasienServiceImpl extends BaseVoServiceImpl implements PasienServic
}
@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public PasienVO findById(Integer key) throws JpaSystemException {
Pasien pasien = pasienDao.findOne(key);
if (pasien == null) {
if (pasien == null)
return null;
}
PasienVO pasienVO = new PasienVO();
pasienConverter.transferModelToVO(pasien, pasienVO);
pasienVO = converterPasien.transferModelToVO(pasien, pasienVO);
return pasienVO;
}
@Override
public PasienVO findByNoBpjs(String noBpjs) {
List<Pasien> data = pasienDao.findPasienByNoBpjs(noBpjs);
Pasien pasien = null;
if (data.size() != 0)
pasien = data.get(0);
PasienVO pasienVO = new PasienVO();
pasienVO = converterPasien.transferModelToVO(pasien, pasienVO);
return pasienVO;
}
@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public List<PasienVO> findAll()
throws JpaSystemException {/*
*
* List<Pasien> pasienList =
* pasienDaoCustom.findAllPasien();
*
* List<PasienVO> pasienVOList = new
* ArrayList<PasienVO>(); for (Pasien
* pasien : pasienList) { PasienVO vo =
* new PasienVO();
* vo=pasienConverter.transferModelToVO(
* pasien, vo); List<AlamatVO>
* listvo=new ArrayList<AlamatVO>();
* for(Alamat
* alamat:pasien.getAlamats()){
*
* listvo.add(alamatConverter.
* transferModelToVO(alamat, new
* AlamatVO()));
*
* } vo.getAlamats().addAll(listvo);
* pasienVOList.add(vo); }
*
* return pasienVOList;
*
*
*/
public List<PasienVO> findAll() throws JpaSystemException {
return null;
}
@ -289,14 +276,7 @@ public class PasienServiceImpl extends BaseVoServiceImpl implements PasienServic
public String generatePasienCM() {
@SuppressWarnings("unchecked")
List<String> nocmList = IteratorUtils.toList(pasienDao.findAllNoCm().iterator());
// String noCM =pasienDao.MaxNoCm(8);
// generate cari no yang hilang
String missNoCm = getCM(nocmList, 8);
// if(missNoCm.equals(noCM))
// {
// Integer maxNoCm=Integer.parseInt(missNoCm)+1;
// missNoCm = StringUtil.formatNumber(maxNoCm.toString(), 8);
// }
return missNoCm;
}
@ -350,18 +330,13 @@ public class PasienServiceImpl extends BaseVoServiceImpl implements PasienServic
Date startDate = null;
Date endDate = null;
// Date birthDate = null;
if (CommonUtil.isNotNullOrEmpty(dateStart)) {
startDate = DateUtil.toDate(dateStart);
}
if (CommonUtil.isNotNullOrEmpty(dateEnd)) {
endDate = DateUtil.toDate(dateEnd);
}
// if (CommonUtil.isNotNullOrEmpty(tanggalLahir)) {
// birthDate = DateUtil.toDate(tanggalLahir);
// }
int totalRow = 0;// pasienDaoCustom.findAllPasienPagingCount(startDate,
// endDate, noCm, namaIbu, birthDate);
int totalRow = 0;
int totalPages = 0;
int pageRequested = page;
@ -423,83 +398,6 @@ public class PasienServiceImpl extends BaseVoServiceImpl implements PasienServic
return constructMapReturn(gridPasienVoList, totalRow, totalPages);
}
/*
* @Override
*
* @Transactional(readOnly=true) public Map<String, Object>
* findByNoCmAndTglLahir(Integer page, Integer limit, String sort, String
* dir, String noCm,String dateStart, String dateEnd, String tanggalLahir,
* String namaAyah) { Map<String, Object> result = new HashMap<>();
*
* Date startDate = null; Date endDate = null; Date birthDate = null; if
* (CommonUtil.isNotNullOrEmpty(dateStart)) { startDate =
* DateUtil.toDate(dateStart); } if (CommonUtil.isNotNullOrEmpty(dateEnd)) {
* endDate = DateUtil.toDate(dateEnd); } if
* (CommonUtil.isNotNullOrEmpty(tanggalLahir)) { birthDate =
* DateUtil.toDate(tanggalLahir); } int totalRow = 0;//
* pasienDaoCustom.findAllPasienPagingCount(startDate, // endDate, noCm,
* namaIbu, birthDate); int totalPages = 0;
*
* int pageRequested = page;
*
* if (totalRow > 0) { totalPages = (int) Math.ceil((double) totalRow /
* (double) limit); } else { totalPages = 0; }
*
* if (pageRequested > totalPages) pageRequested = totalPages; int rowStart
* = pageRequested * limit - limit; if (rowStart < 0) { rowStart = 0; } int
* rowEnd = limit; List<Pasien> pasienList =
* pasienDaoCustom.findAllPasienPagingList(rowStart, rowEnd, startDate,
* endDate, noCm, namaAyah, birthDate);
*
* List<GridPasienVO> gridPasienVoList = new ArrayList<GridPasienVO>(); for
* (Pasien pasien : pasienList) { GridPasienVO gridPasienVO = new
* GridPasienVO();
*
* if(CommonUtil.isNotNullOrEmpty(pasien.getJenisKelamin())) {
* JenisKelaminVO jeniskelamin = new JenisKelaminVO();
*
* if(CommonUtil.isNotNullOrEmpty(pasien.getJenisKelamin().getId())) {
* jeniskelamin.setId(pasien.getJenisKelamin().getId()); }
* if(CommonUtil.isNotNullOrEmpty(pasien.getJenisKelamin().getJenisKelamin()
* )) {
* jeniskelamin.setJenisKelamin(pasien.getJenisKelamin().getJenisKelamin());
* } if(CommonUtil.isNotNullOrEmpty(jeniskelamin)) {
* gridPasienVO.setJenisKelamin(jeniskelamin); } }
* if(CommonUtil.isNotNullOrEmpty(pasien.getNoCm())) {
* gridPasienVO.setNoCm(pasien.getNoCm()); }
* if(CommonUtil.isNotNullOrEmpty(pasien.getTglDaftar())) {
* gridPasienVO.setTglDaftar(pasien.getTglDaftar()); }
* if(CommonUtil.isNotNullOrEmpty(pasien.getTglLahir())) {
* gridPasienVO.setTglLahir(pasien.getTglLahir()); }
* if(CommonUtil.isNotNullOrEmpty(pasien.getNamaAyah())) {
* gridPasienVO.setNamaAyah(pasien.getNamaAyah()); }
* if(CommonUtil.isNotNullOrEmpty(pasien.getNamaPasien())) {
* gridPasienVO.setNamaLengkap(pasien.getNamaPasien()); } if
* (CommonUtil.isNotNullOrEmpty(pasien.getTglLahir())) { Age age =
* AgeCalculator.calculateAge(pasien.getTglLahir()); if
* (CommonUtil.isNotNullOrEmpty(age)) {
* gridPasienVO.setUmur(age.toString()); } }
* if(CommonUtil.isNotNullOrEmpty(gridPasienVO)) {
* gridPasienVoList.add(gridPasienVO); }
*
* Set<AlamatVO>alamatsvo = new HashSet<>(); for(Alamat alamat :
* alamatDao.findAlamatByIdPasien(pasien.getId())){ AlamatVO alamatVO = new
* AlamatVO();
*
* if(CommonUtil.isNotNullOrEmpty(alamat.getId())) {
* alamatVO.setId(alamat.getId()); }
* if(CommonUtil.isNotNullOrEmpty(alamat.getAlamatLengkap())) {
* alamatVO.setAlamatLengkap(alamat.getAlamatLengkap()); }
* if(CommonUtil.isNotNullOrEmpty(alamatVO)) { alamatsvo.add(alamatVO); } }
* if(CommonUtil.isNotNullOrEmpty(alamatsvo)) {
* gridPasienVO.setAlamats(alamatsvo); } }
*
* if(CommonUtil.isNotNullOrEmpty(gridPasienVoList)) { result.put("data",
* gridPasienVoList); }
*
* return result; }
*/
@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public PasienVO findByNoCm(String key) throws JpaSystemException {
@ -516,11 +414,6 @@ public class PasienServiceImpl extends BaseVoServiceImpl implements PasienServic
Set<AlamatVO> alamats = new HashSet<AlamatVO>();
try {
Alamat alamat = alamatDao.findAlamatByPasienId(pasien.getId());
// baseAlamatController.setUseGson(true);
// AlamatVO alamatVo =
// baseAlamatController.transferModelToVO(alamat, new AlamatVO());
// alamats.add(alamatVo);
// pasienVO.setAlamats(alamats);
AlamatVO alamatVo = new AlamatVO();
if (CommonUtil.isNotNullOrEmpty(alamat.getKodePos())) {
@ -618,8 +511,6 @@ public class PasienServiceImpl extends BaseVoServiceImpl implements PasienServic
String missNoCm = StringUtil.formatNumber(number.toString(), 8);
// want to edit by askur 03012017
pasien.setNoCm(missNoCm);
// pasien.setNoCm(generateNumberService.generatePasienCM());
//
pasien.setNoIdentitas(vo.getNoIdentitas());
pasien = pasienDao.save(pasien);
@ -637,14 +528,11 @@ public class PasienServiceImpl extends BaseVoServiceImpl implements PasienServic
@Override
public Pasien findPasienById(Integer key) {
// List modelResult = new ArrayList();
Pasien model = pasienDao.findOne(key);
// String umur = "";
if (CommonUtil.isNotNullOrEmpty(model.getTglLahir())) {
Age age = AgeCalculator.calculateAge(model.getTglLahir());
if (CommonUtil.isNotNullOrEmpty(age)) {
// umur = age.toString();
model.setUmur(new SimpleDateFormat("dd-MM-yyyy").format(model.getTglLahir()));
}
@ -666,33 +554,6 @@ public class PasienServiceImpl extends BaseVoServiceImpl implements PasienServic
return entity;
}
@Override
public PasienVO findByNoBpjs(String noBpjs) {
List<Pasien> data = pasienDao.findPasienBynoBpjs(noBpjs);
Pasien pasien = null;
if (data.size() != 0)
pasien = data.get(0);
if (pasien == null) {
return null;
}
PasienVO pasienVO = new PasienVO();
pasienVO = pasienConverter.transferModelToVO(pasien, pasienVO);
// Set<AlamatVO> alamats = new HashSet<AlamatVO>();
try {
// Alamat alamat = alamatDao.findAlamatByPasienId(pasien.getId());
// baseAlamatController.setUseGson(true);
// AlamatVO alamatVo =
// baseAlamatController.transferModelToVO(alamat, new AlamatVO());
// alamats.add(alamatVo);
// pasienVO.setAlamats(alamats);
} catch (Exception e) {
}
return pasienVO;
}
@Override
public void updateTanggalMeninggal(Pasien p) {
pasienDao.save(p);
@ -714,11 +575,6 @@ public class PasienServiceImpl extends BaseVoServiceImpl implements PasienServic
Set<AlamatVO> alamats = new HashSet<AlamatVO>();
try {
Alamat alamat = alamatDao.findAlamatByPasienId(pasien.getId());
// baseAlamatController.setUseGson(true);
// AlamatVO alamatVo =
// baseAlamatController.transferModelToVO(alamat, new AlamatVO());
// alamats.add(alamatVo);
// pasienVO.setAlamats(alamats);
AlamatVO alamatVo = new AlamatVO();
if (CommonUtil.isNotNullOrEmpty(alamat.getKodePos())) {