Update SkoringTindakanFarmakologiService

Pembuatan api service skoring tindakan farmakologi
This commit is contained in:
salmanoe 2022-06-20 13:08:21 +07:00
parent dabd0c1460
commit 3f5a8ad4d6
4 changed files with 291 additions and 18 deletions

View File

@ -84,4 +84,11 @@ public interface SkoringTindakanFarmakologiDao extends PagingAndSortingRepositor
+ "and stf.noRec in (:listNorec)")
List<Map<String, Object>> findAllDup(@Param("listNorec") List<String> listNorec);
@Query(value = "select * from sdm_skoringtindakanfarmakologi_t "
+ "where statusenabled is true and statusverifikasi is true "
+ "and objectprodukfarmakologifk = :produkId and to_char(tanggalmulaiberlaku, 'yyyy-mm-dd') <= :tglMulaiBerlaku "
+ "order by tanggalmulaiberlaku desc, tanggalpembaharuandata desc limit 1", nativeQuery = true)
SkoringTindakanNakes findLast(@Param("produkId") Integer idProduk,
@Param("tglMulaiBerlaku") String tglMulaiBerlaku);
}

View File

@ -15,12 +15,11 @@ import com.jasamedika.medifirst2000.vo.SkoringTindakanFarmakologiVO;
*/
public interface SkoringTindakanFarmakologiService
extends BaseVoService<SkoringTindakanFarmakologi, SkoringTindakanFarmakologiVO, String> {
List<Map<String, Object>> findAllEnabled(String namaProduk, Boolean isVerif, Integer idProfesi)
throws JpaSystemException;
List<Map<String, Object>> findDuplicateSkoring(String namaProduk, Double skor, Integer idProfesi,
Long tglMulaiBerlaku, String noRec) throws JpaSystemException;
List<Map<String, Object>> findAllEnabled(String namaProduk, Boolean isVerif) throws JpaSystemException;
List<Map<String, Object>> findDuplicateSkoring(String namaProduk, Double skor, Long tglMulaiBerlaku, String noRec)
throws JpaSystemException;
Map<String, Object> findAkses(Integer idPegawai) throws JpaSystemException;

View File

@ -1,27 +1,33 @@
package com.jasamedika.medifirst2000.service.impl;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.jpa.JpaSystemException;
import com.jasamedika.medifirst2000.constants.Master;
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
import com.jasamedika.medifirst2000.dao.LoggingUserDao;
import com.jasamedika.medifirst2000.dao.MapPegawaiJabatanToUnitKerjaDao;
import com.jasamedika.medifirst2000.dao.SettingDataFixedDao;
import com.jasamedika.medifirst2000.dao.SkoringTindakanFarmakologiDao;
import com.jasamedika.medifirst2000.dao.SubUnitKerjaDao;
import com.jasamedika.medifirst2000.entities.LoggingUser;
import com.jasamedika.medifirst2000.entities.LoginUser;
import com.jasamedika.medifirst2000.entities.ProdukFarmakologi;
import com.jasamedika.medifirst2000.entities.SkoringTindakanFarmakologi;
import com.jasamedika.medifirst2000.entities.SkoringTindakanNakes;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.SkoringTindakanFarmakologiService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.vo.ProdukFarmakologiVO;
import com.jasamedika.medifirst2000.vo.SkoringTindakanFarmakologiVO;
import com.jasamedika.medifirst2000.vo.SkoringTindakanNakesVO;
/**
* @author salmanoe
@ -43,6 +49,15 @@ public class SkoringTindakanFarmakologiServiceImpl extends BaseVoServiceImpl
@Autowired
private LoggingUserDao loggingUserDao;
@Autowired
private SettingDataFixedDao settingDataFixedDao;
@Autowired
private MapPegawaiJabatanToUnitKerjaDao mappingJabatanDao;
@Autowired
private SubUnitKerjaDao subUnitKerjaDao;
public void addLoggingUser(Integer idLoginUser, String idReferensi, String keterangan) {
LoggingUser loggingUser = new LoggingUser();
LoginUser loginUser = new LoginUser();
@ -144,28 +159,177 @@ public class SkoringTindakanFarmakologiServiceImpl extends BaseVoServiceImpl
@Override
public Map<String, Object> findAllWithPageAndLimitAndSortByAndDirectionParameter(Integer page, Integer limit,
String sort, String dir) {
return null;
}
@Override
public List<Map<String, Object>> findAllEnabled(String namaProduk, Boolean isVerif, Integer idProfesi)
throws JpaSystemException {
// TODO Auto-generated method stub
return null;
public List<Map<String, Object>> findAllEnabled(String namaProduk, Boolean isVerif) throws JpaSystemException {
List<Map<String, Object>> result = new ArrayList<>();
List<Map<String, Object>> data = new ArrayList<>();
List<Map<String, Object>> filter = new ArrayList<>();
if (CommonUtil.isNullOrEmpty(namaProduk) && CommonUtil.isNullOrEmpty(isVerif)) {
data = skoringTindakanDao.findAllEnabled();
} else if (CommonUtil.isNotNullOrEmpty(namaProduk) && CommonUtil.isNullOrEmpty(isVerif)) {
data = skoringTindakanDao.findAllEnabledByProduk(namaProduk.toLowerCase());
} else if (CommonUtil.isNullOrEmpty(namaProduk) && CommonUtil.isNotNullOrEmpty(isVerif)) {
data = skoringTindakanDao.findAllEnabledByVerif(isVerif);
} else if (CommonUtil.isNotNullOrEmpty(namaProduk) && CommonUtil.isNotNullOrEmpty(isVerif)) {
data = skoringTindakanDao.findAllEnabledByProdukVerif(namaProduk.toLowerCase(), isVerif);
}
// filtering
for (Map<String, Object> mapData : data) {
boolean isContained = false;
for (Map<String, Object> mapFilter : filter) {
if (mapData.get("produkId").equals(mapFilter.get("produkId"))) {
isContained = true;
break;
}
}
if (!isContained) {
Map<String, Object> mapFilter = new HashMap<>();
mapFilter.put("produkId", mapData.get("produkId"));
result.add(mapFilter);
}
}
return result;
}
@Override
public List<Map<String, Object>> findDuplicateSkoring(String namaProduk, Double skor, Integer idProfesi,
Long tglMulaiBerlaku, String noRec) throws JpaSystemException {
// TODO Auto-generated method stub
return null;
public List<Map<String, Object>> findDuplicateSkoring(String namaProduk, Double skor, Long tglMulaiBerlaku,
String noRec) throws JpaSystemException {
List<Map<String, Object>> result = new ArrayList<>();
List<String> listNorec = new ArrayList<>();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String patternText = settingDataFixedDao.getSettingDataFixed("patternTextDuplicate");
String replacedNamaProduk = namaProduk.replaceAll(patternText, "").toLowerCase();
if (CommonUtil.isNotNullOrEmpty(noRec)) {
listNorec = skoringTindakanDao.findLastDupSkoring(replacedNamaProduk, skor, patternText, noRec);
if (CommonUtil.isNullOrEmpty(listNorec)) {
listNorec = skoringTindakanDao.findDupSkoring(replacedNamaProduk, df.format(new Date(tglMulaiBerlaku)),
patternText, noRec);
}
} else {
listNorec = skoringTindakanDao.findLastDupSkoring(replacedNamaProduk, skor, patternText);
if (CommonUtil.isNullOrEmpty(listNorec)) {
listNorec = skoringTindakanDao.findDupSkoring(replacedNamaProduk, df.format(new Date(tglMulaiBerlaku)),
patternText);
}
}
if (CommonUtil.isNotNullOrEmpty(listNorec)) {
result = skoringTindakanDao.findAllDup(listNorec);
}
return result;
}
@Override
public Map<String, Object> findAkses(Integer idPegawai) throws JpaSystemException {
// TODO Auto-generated method stub
return null;
Map<String, Object> result = new HashMap<>();
List<Integer> listRs = new ArrayList<>();
List<Integer> listIdUnitKerja = new ArrayList<>();
List<Integer> listUnitKerjaSuperuser = new ArrayList<>();
listIdUnitKerja.add(Master.UnitKerja.BID_JANG);
listIdUnitKerja.addAll(Arrays.asList(Master.UnitKerja.NAKES_LAIN));
listUnitKerjaSuperuser.add(Master.UnitKerja.BAG_SDM);
List<Map<String, Object>> listSuperuser = mappingJabatanDao.findAksesPegawaiPenilai(listIdUnitKerja, idPegawai);
listSuperuser.addAll(mappingJabatanDao.findAksesPegawaiStaf(listUnitKerjaSuperuser, idPegawai));
listSuperuser.addAll(mappingJabatanDao.findAksesPegawaiAtasan(listUnitKerjaSuperuser, idPegawai));
listSuperuser.addAll(mappingJabatanDao.findAksesPegawaiPenilai(listUnitKerjaSuperuser, idPegawai));
if (CommonUtil.isNotNullOrEmpty(listSuperuser)) {
listRs.addAll(listIdUnitKerja);
result.put("isSuperuser", true);
result.put("isAtasan", false);
result.put("isStaf", false);
result.put("listId", listRs);
result.put("listSk", subUnitKerjaDao.getSubunitKerjaByUnitKerja(listRs));
} else {
List<Map<String, Object>> listAtasan = mappingJabatanDao.findAksesPegawaiAtasan(listIdUnitKerja, idPegawai);
if (CommonUtil.isNotNullOrEmpty(listAtasan)) {
for (Map<String, Object> map : listAtasan) {
if (!listRs.contains(Integer.valueOf(map.get("unitKerjaId").toString()))) {
listRs.add(Integer.valueOf(map.get("unitKerjaId").toString()));
}
}
result.put("isSuperuser", false);
result.put("isAtasan", true);
result.put("isStaf", false);
result.put("listId", listRs);
result.put("listSk", subUnitKerjaDao.getSubunitKerjaByUnitKerja(listRs));
} else {
List<Map<String, Object>> listStaf = mappingJabatanDao.findAksesPegawaiStaf(listIdUnitKerja, idPegawai);
if (CommonUtil.isNotNullOrEmpty(listStaf)) {
for (Map<String, Object> map : listStaf) {
if (!listRs.contains(Integer.valueOf(map.get("unitKerjaId").toString()))) {
listRs.add(Integer.valueOf(map.get("unitKerjaId").toString()));
}
}
result.put("isSuperuser", false);
result.put("isAtasan", false);
result.put("isStaf", true);
result.put("listId", listRs);
result.put("listSk", subUnitKerjaDao.getSubunitKerjaByUnitKerja(listRs));
} else {
List<Map<String, Object>> listSuperElse = mappingJabatanDao.findAksesPegawaiPenilai(idPegawai);
if (CommonUtil.isNotNullOrEmpty(listSuperElse)) {
for (Map<String, Object> map : listSuperElse) {
if (!listRs.contains(Integer.valueOf(map.get("unitKerjaId").toString()))) {
listRs.add(Integer.valueOf(map.get("unitKerjaId").toString()));
}
}
result.put("isSuperuser", false);
result.put("isAtasan", false);
result.put("isStaf", false);
result.put("listId", listRs);
result.put("listSk", subUnitKerjaDao.getSubunitKerjaByUnitKerja(listRs));
} else {
List<Map<String, Object>> listAtasanElse = mappingJabatanDao.findAksesPegawaiAtasan(idPegawai);
if (CommonUtil.isNotNullOrEmpty(listAtasanElse)) {
for (Map<String, Object> map : listAtasanElse) {
if (!listRs.contains(Integer.valueOf(map.get("unitKerjaId").toString()))) {
listRs.add(Integer.valueOf(map.get("unitKerjaId").toString()));
}
}
result.put("isSuperuser", false);
result.put("isAtasan", false);
result.put("isStaf", false);
result.put("listId", listRs);
result.put("listSk", subUnitKerjaDao.getSubunitKerjaByUnitKerja(listRs));
} else {
List<Map<String, Object>> listStafElse = mappingJabatanDao.findAksesPegawaiStaf(idPegawai);
if (CommonUtil.isNotNullOrEmpty(listStafElse)) {
for (Map<String, Object> map : listStafElse) {
if (!listRs.contains(Integer.valueOf(map.get("unitKerjaId").toString()))) {
listRs.add(Integer.valueOf(map.get("unitKerjaId").toString()));
}
}
result.put("isSuperuser", false);
result.put("isAtasan", false);
result.put("isStaf", false);
result.put("listId", listRs);
result.put("listSk", subUnitKerjaDao.getSubunitKerjaByUnitKerja(listRs));
}
}
}
}
}
}
return result;
}
}

View File

@ -46,6 +46,7 @@ import com.jasamedika.medifirst2000.service.ProdukNakesService;
import com.jasamedika.medifirst2000.service.ProdukPerawatService;
import com.jasamedika.medifirst2000.service.ProfesiService;
import com.jasamedika.medifirst2000.service.RemunerasiOperasionalService;
import com.jasamedika.medifirst2000.service.SkoringTindakanFarmakologiService;
import com.jasamedika.medifirst2000.service.SkoringTindakanMedisService;
import com.jasamedika.medifirst2000.service.SkoringTindakanNakesService;
import com.jasamedika.medifirst2000.service.SkoringTindakanPerawatService;
@ -72,6 +73,7 @@ import com.jasamedika.medifirst2000.vo.ProdukPerawatVO;
import com.jasamedika.medifirst2000.vo.ProfesiVO;
import com.jasamedika.medifirst2000.vo.RemunerasiOperasionalVO;
import com.jasamedika.medifirst2000.vo.SettingPirSdmVO;
import com.jasamedika.medifirst2000.vo.SkoringTindakanFarmakologiVO;
import com.jasamedika.medifirst2000.vo.SkoringTindakanMedisVO;
import com.jasamedika.medifirst2000.vo.SkoringTindakanNakesVO;
import com.jasamedika.medifirst2000.vo.SkoringTindakanPerawatVO;
@ -159,6 +161,9 @@ public class IkiDanRemunerasiController extends LocaleController<IkiDanRemuneras
@Autowired
private ProdukFarmakologiService produkFarmakologiService;
@Autowired
private SkoringTindakanFarmakologiService skoringTindakanFarmakologiService;
@RequestMapping(value = "/get-load-data", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getLoadData(HttpServletRequest request) {
try {
@ -2477,4 +2482,102 @@ public class IkiDanRemunerasiController extends LocaleController<IkiDanRemuneras
}
}
@RequestMapping(value = "/save-skoring-tindakan-farmakologi", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SkoringTindakanFarmakologiVO> saveSkoringTindakanFarmakologi(HttpServletRequest request,
@Valid @RequestBody SkoringTindakanFarmakologiVO vo) {
try {
SkoringTindakanFarmakologiVO result = new SkoringTindakanFarmakologiVO();
if (CommonUtil.isNotNullOrEmpty(vo.getNoRec())) {
result = skoringTindakanFarmakologiService.update(vo);
} else {
result = skoringTindakanFarmakologiService.add(vo);
}
if (CommonUtil.isNotNullOrEmpty(result)) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} else {
return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE);
}
} catch (ServiceVOException sve) {
LOGGER.error("Got exception {} when add/update skor tindakan oleh kelompok kerja farmakologi",
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 add/update skor tindakan oleh kelompok kerja farmakologi",
jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-all-skoring-tindakan-farmakologi", method = RequestMethod.GET)
public ResponseEntity<List<Map<String, Object>>> getAllSkoringTindakanFarmakologi(HttpServletRequest request,
@RequestParam(value = "namaProduk", required = false) String namaProduk,
@RequestParam(value = "isVerif", required = false) Boolean isVerif) throws ParseException {
try {
List<Map<String, Object>> result = skoringTindakanFarmakologiService.findAllEnabled(namaProduk, isVerif);
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
} catch (ServiceVOException sve) {
LOGGER.error("Got exception {} when get all skoring tindakan oleh kelompok kerja farmakologi",
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 skoring tindakan oleh kelompok kerja farmakologi",
jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-duplicate-skoring-tindakan-farmakologi", method = RequestMethod.GET)
public ResponseEntity<List<Map<String, Object>>> getDuplikatSkoringTindakanFarmakologi(HttpServletRequest request,
@RequestParam(value = "noRec", required = false) String noRec,
@RequestParam(value = "namaProduk", required = true) String namaProduk,
@RequestParam(value = "skor", required = true) Double skor,
@RequestParam(value = "tglBerlaku", required = true) Long tglMulaiBerlaku) throws ParseException {
try {
List<Map<String, Object>> result = skoringTindakanFarmakologiService.findDuplicateSkoring(namaProduk, skor,
tglMulaiBerlaku, noRec);
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
} catch (ServiceVOException sve) {
LOGGER.error("Got exception {} when get duplikat skoring tindakan oleh kelompok kerja farmakologi",
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 duplikat skoring tindakan oleh kelompok kerja farmakologi",
jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-akses-skoring-tindakan-farmakologi", method = RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getAksesSkoringTindakanFarmakologi(HttpServletRequest request,
@RequestParam(value = "pegawaiId", required = true) Integer idPegawai) throws ParseException {
try {
Map<String, Object> result = skoringTindakanFarmakologiService.findAkses(idPegawai);
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
} catch (ServiceVOException sve) {
LOGGER.error("Got exception {} when get akses skoring tindakan oleh kelompok kerja farmakologi",
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 akses skoring tindakan oleh kelompok kerja farmakologi",
jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
}