penambahan hitung capaian persentase ketepatan kehadiran entri cppt sebagia daftar hadir dpjp

This commit is contained in:
Salman Manoe 2021-12-06 16:12:55 +07:00
parent 82f3af59d4
commit ad31a6545e
3 changed files with 216 additions and 140 deletions

View File

@ -17,7 +17,7 @@ public interface CatatanPerkembanganPasienTerintegrasiService
List<Map<String, Object>> findDokter(Integer idKsm, Integer idKk, Integer idDr) throws JpaSystemException;
List<Map<String, Object>> findPresensiVisiteDokter(Integer idKsm, Integer idKk, Integer idDr, Long periode)
Map<String, Object> findPresensiVisiteDokter(Integer idKsm, Integer idKk, Integer idDr, Long periode)
throws JpaSystemException;
Map<String, Object> findPresensiVisiteDokter(Integer idPegawai, Long bulan) throws JpaSystemException;

View File

@ -1,5 +1,7 @@
package com.jasamedika.medifirst2000.service.impl;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.Instant;
@ -71,6 +73,27 @@ public class CatatanPerkembanganPasienTerintegrasiServiceImpl extends BaseVoServ
@Autowired
private MapPegawaiJabatanToUnitKerjaDao mapJabatanDao;
public Double getCapaianPresensiCppt(List<CatatanPerkembanganPasienTerintegrasi> data, Integer idDokter,
Integer days) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
DateFormat hf = new SimpleDateFormat("HH:mm:ss");
double totCapaian = 0.0;
for (CatatanPerkembanganPasienTerintegrasi cppt : data) {
if (idDokter.equals(cppt.getPegawai().getId())) {
LocalDateTime tenthOClock = LocalDateTime.of(LocalDate.parse(df.format(cppt.getTglInput())),
LocalTime.of(10, 0, 0, 0));
LocalDateTime tglInput = LocalDateTime.of(LocalDate.parse(df.format(cppt.getTglInput())),
LocalTime.parse(hf.format(cppt.getTglInput())));
if (tglInput.isBefore(tenthOClock) || tglInput.equals(tenthOClock)) {
totCapaian += 100;
}
}
}
return totCapaian / days;
}
@Override
public CatatanPerkembanganPasienTerintegrasiVO add(CatatanPerkembanganPasienTerintegrasiVO vo)
throws JpaSystemException, ServiceVOException {
@ -214,9 +237,10 @@ public class CatatanPerkembanganPasienTerintegrasiServiceImpl extends BaseVoServ
* @return presensi visite dokter
*/
@Override
public List<Map<String, Object>> findPresensiVisiteDokter(Integer idKsm, Integer idKk, Integer idDr, Long periode)
public Map<String, Object> findPresensiVisiteDokter(Integer idKsm, Integer idKk, Integer idDr, Long periode)
throws JpaSystemException {
List<Map<String, Object>> result = new ArrayList<>();
Map<String, Object> result = new HashMap<>();
List<Map<String, Object>> resultDetail = new ArrayList<>();
List<Map<String, Object>> dataInit = new ArrayList<>();
List<Integer> listIdDokter = new ArrayList<>();
@ -253,11 +277,18 @@ public class CatatanPerkembanganPasienTerintegrasiServiceImpl extends BaseVoServ
}
int daysOfMonth = listTgl.size();
Double persenTepatHadir = 0.0;
if (CommonUtil.isNotNullOrEmpty(listIdDokter)) {
List<CatatanPerkembanganPasienTerintegrasi> rawData = cpptDao.findPresensiCPPT(listIdDokter, strStartDate,
strEndDate);
for (Map<String, Object> map : dataInit) {
if (CommonUtil.isNotNullOrEmpty(idDr)) {
for (Integer idDokter : listIdDokter) {
persenTepatHadir = getCapaianPresensiCppt(rawData, idDokter, daysOfMonth);
}
}
for (Map<String, Object> map : dataInit) {
Map<String, Object> mapRs = new HashMap<>();
mapRs.put("cpptId", null);
mapRs.put("tglInput", null);
@ -289,9 +320,11 @@ public class CatatanPerkembanganPasienTerintegrasiServiceImpl extends BaseVoServ
}
mapRs.putAll(map);
result.add(mapRs);
resultDetail.add(mapRs);
}
}
result.put("persenTepatHadir", new BigDecimal(persenTepatHadir).setScale(2, RoundingMode.HALF_UP));
result.put("detail", resultDetail);
return result;
}
@ -302,7 +335,6 @@ public class CatatanPerkembanganPasienTerintegrasiServiceImpl extends BaseVoServ
Date endDate = CommonUtil.lastDayOfMonth(bulan);
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
DateFormat hf = new SimpleDateFormat("HH:mm:ss");
String strStartDate = df.format(startDate);
String strEndDate = df.format(endDate);
@ -323,20 +355,8 @@ public class CatatanPerkembanganPasienTerintegrasiServiceImpl extends BaseVoServ
List<CatatanPerkembanganPasienTerintegrasi> rawData = cpptDao.findPresensiCPPT(listIdDokter, strStartDate,
strEndDate);
for (Map<String, Object> dokter : listDokter) {
double totCapaian = 0.0;
for (CatatanPerkembanganPasienTerintegrasi cppt : rawData) {
if (dokter.get("pegawaiId").equals(cppt.getPegawai().getId())) {
LocalDateTime tenthOClock = LocalDateTime.of(LocalDate.parse(df.format(cppt.getTglInput())),
LocalTime.of(10, 0, 0, 0));
LocalDateTime tglInput = LocalDateTime.of(LocalDate.parse(df.format(cppt.getTglInput())),
LocalTime.parse(hf.format(cppt.getTglInput())));
if (tglInput.isBefore(tenthOClock) || tglInput.equals(tenthOClock)) {
totCapaian += 100;
}
}
}
double avgCapaian = totCapaian / daysOfMonth;
dokter.put("rataCapaian", avgCapaian);
dokter.put("rataCapaian",
getCapaianPresensiCppt(rawData, Integer.valueOf(dokter.get("pegawaiId").toString()), daysOfMonth));
}
return listDokter.get(0);