package com.jasamedika.medifirst2000.service.impl;

import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.joda.time.Chronology;
import org.joda.time.chrono.ISOChronology;
import org.joda.time.chrono.IslamicChronology;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jasamedika.medifirst2000.constants.Master;
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
import com.jasamedika.medifirst2000.dao.CustomIndexKerjaDao;
import com.jasamedika.medifirst2000.dao.DetailLogbookDokterDao;
import com.jasamedika.medifirst2000.dao.IkiDanRemunerasiDao;
import com.jasamedika.medifirst2000.dao.IndekKinerjaDao;
import com.jasamedika.medifirst2000.dao.IndeksKinerjaIndividuDao;
import com.jasamedika.medifirst2000.dao.LogbookDokterDao;
import com.jasamedika.medifirst2000.dao.MapKalenderToHariLiburDao;
import com.jasamedika.medifirst2000.dao.MapPegawaiLaboratRadiologiDao;
import com.jasamedika.medifirst2000.dao.MapRuanganToProdukDao;
import com.jasamedika.medifirst2000.dao.MonitoringAbsenDao;
import com.jasamedika.medifirst2000.dao.NilaiIndexKinerjaIndividuDao;
import com.jasamedika.medifirst2000.dao.PegawaiDao;
import com.jasamedika.medifirst2000.dao.PelayananPasienDetailDao;
import com.jasamedika.medifirst2000.dao.RevIndekKinerjaDao;
import com.jasamedika.medifirst2000.dao.SettingDataFixedDao;
import com.jasamedika.medifirst2000.dao.TabelAcuanIndeksIKIDao;
import com.jasamedika.medifirst2000.dao.UraianTugasTransaksiDao;
import com.jasamedika.medifirst2000.dao.custom.IndeksKinerjaDaoCustom;
import com.jasamedika.medifirst2000.dao.custom.RevIndeksKinerjaDaoCustom;
import com.jasamedika.medifirst2000.entities.CustomIndexKerja;
import com.jasamedika.medifirst2000.entities.CustomUraianKerja;
import com.jasamedika.medifirst2000.entities.DetailLogbookDokter;
import com.jasamedika.medifirst2000.entities.IndekKinerja;
import com.jasamedika.medifirst2000.entities.IndeksKinerjaIndividu;
import com.jasamedika.medifirst2000.entities.Jabatan;
import com.jasamedika.medifirst2000.entities.Kalender;
import com.jasamedika.medifirst2000.entities.KomponenIKI;
import com.jasamedika.medifirst2000.entities.LogbookDokter;
import com.jasamedika.medifirst2000.entities.LoginUser;
import com.jasamedika.medifirst2000.entities.MapKalenderToHariLibur;
import com.jasamedika.medifirst2000.entities.MapPegawaiLaboratRadiologi;
import com.jasamedika.medifirst2000.entities.MapUraianTugasToRincianKegiatan;
import com.jasamedika.medifirst2000.entities.NilaiIndexKinerjaIndividu;
import com.jasamedika.medifirst2000.entities.Pegawai;
import com.jasamedika.medifirst2000.entities.TabelAcuanIndeksIKI;
import com.jasamedika.medifirst2000.service.IndekKinerjaService;
import com.jasamedika.medifirst2000.service.LoginUserService;
import com.jasamedika.medifirst2000.service.MonitoringAbsenService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.util.CurrencyUtil;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.util.JsonUtil;
import com.jasamedika.medifirst2000.vo.CustomIndexKerjaVO;
import com.jasamedika.medifirst2000.vo.CustomUraianKerjaVO;
import com.jasamedika.medifirst2000.vo.IndekKinerjaVO;
import com.jasamedika.medifirst2000.vo.IndeksKinerjaIndividuCustomVO;
import com.jasamedika.medifirst2000.vo.IndeksKinerjaIndividuVO;
import com.jasamedika.medifirst2000.vo.KomponenIKIVO;
import com.jasamedika.medifirst2000.vo.MapKalenderToHariLiburVO;
import com.jasamedika.medifirst2000.vo.MapUraianTugasToRincianKegiatanVO;
import com.jasamedika.medifirst2000.vo.NilaiIndexKinerjaIndividuVO;
import com.jasamedika.medifirst2000.vo.PegawaiVO;
import com.jasamedika.medifirst2000.vo.TabelAcuanIndeksIKIVO;

/**
 * Implement class for IndekKinerjaService
 * 
 * @author Generator
 * @param <T>
 */
@Service("indekKinerjaService")
public class IndekKinerjaServiceImpl extends BaseVoServiceImpl implements IndekKinerjaService {
	@Autowired
	private BaseConverterImpl<CustomIndexKerjaVO, CustomIndexKerja> customIndexKerjaConverter;

	@Autowired
	private BaseConverterImpl<IndekKinerjaVO, IndekKinerja> indekKinerjaConverter;

	@Autowired
	private BaseConverterImpl<IndeksKinerjaIndividuVO, IndeksKinerjaIndividu> indekKinerjaIndividuConverter;

	@Autowired
	private BaseConverterImpl<KomponenIKIVO, KomponenIKI> komponenIKIConverter;

	@Autowired
	private BaseConverterImpl<TabelAcuanIndeksIKIVO, TabelAcuanIndeksIKI> tabelAcuanIndeksIKIConverter;

	@Autowired
	private BaseConverterImpl<MapUraianTugasToRincianKegiatanVO, MapUraianTugasToRincianKegiatan> uraianTugasConverter;

	@Autowired
	private BaseConverterImpl<CustomUraianKerjaVO, CustomUraianKerja> customUraianKerjaConverter;

	@Autowired
	private BaseConverterImpl<NilaiIndexKinerjaIndividuVO, NilaiIndexKinerjaIndividu> nilaiIndexKinerjaIndividuConverter;

	@Autowired
	private BaseConverterImpl<PegawaiVO, Pegawai> pegawaiConverter;

	@Autowired
	private BaseConverterImpl<MapKalenderToHariLiburVO, MapKalenderToHariLibur> mapKalenderToHariLiburConverter;

	@Autowired
	private MonitoringAbsenDao monitoringAbsenDao;

	@Autowired
	private MapPegawaiLaboratRadiologiDao mapPegawaiLaboratRadiologiDao;

	@Autowired
	private IkiDanRemunerasiDao ikiDanRemunerasiDao;

	@Autowired
	private IndekKinerjaDao indekKinerjaDao;

	@Autowired
	private SettingDataFixedDao settingDataFixedDao;

	@Autowired
	private MapKalenderToHariLiburDao mapKalenderToHariLiburDao;

	@Autowired
	private IndeksKinerjaIndividuDao indeksKinerjaIndividuDao;

	@Autowired
	private NilaiIndexKinerjaIndividuDao nilaiIndexKinerjaIndividuDao;

	@Autowired
	private PegawaiDao pegawaiDao;

	@Autowired
	private UraianTugasTransaksiDao uraianTugasTransaksiDao;

	@Autowired
	private CustomIndexKerjaDao customIndexKerjaDao;

	@Autowired
	private TabelAcuanIndeksIKIDao tabelAcuanIndeksIKIDao;

	@Autowired
	private MapRuanganToProdukDao mapRuanganToProdukDao;

	@Autowired
	private RevIndekKinerjaDao revIndekKinerjaDao;

	@Autowired
	private LogbookDokterDao logbookDokterDao;

	@Autowired
	private DetailLogbookDokterDao detailLogbookDokterDao;

	@Autowired
	private PelayananPasienDetailDao pelayananPasienDetailDao;

	@Autowired
	private IndeksKinerjaDaoCustom indeksKinerjaDaoCustom;

	@Autowired
	private RevIndeksKinerjaDaoCustom revIndeksKinerjaDaoCustom;

	@Autowired
	private LoginUserService loginUserService;

	@Autowired
	private MonitoringAbsenService monitoringAbsenService;

	public static int getDayOfWeek(Date date) {
		DayOfWeek day = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().getDayOfWeek();

		return day.getValue();
	}

	@Override
	@Transactional(readOnly = false)
	public Map<String, Object> saveIndekKinerja(List<IndekKinerjaVO> vo) {
		Map<String, Object> result = new HashMap<String, Object>();
		for (IndekKinerjaVO indekKinerjaVO : vo) {
			if (indekKinerjaVO.getIsCustom() == true) {
				CustomIndexKerja model = new CustomIndexKerja();
				try {
					model = customIndexKerjaConverter.transferVOToModel(indekKinerjaVO.ToMap(), model);

					model.setNoRec(indekKinerjaVO.getNoRec());
					if (CommonUtil.isNotNullOrEmpty(indekKinerjaVO.getUraianTugas())) {
						model.setUraianTugas(customUraianKerjaConverter
								.transferVOToModel(indekKinerjaVO.getUraianTugas().ToMap(), new CustomUraianKerja()));
					}
				} catch (IllegalArgumentException | IllegalAccessException e) {
					e.printStackTrace();
				}
				model.setValue(indekKinerjaVO.getNilai());
				model.setTanggal(indekKinerjaVO.getTanggal());
				CustomIndexKerja resultDomain = customIndexKerjaDao.save(model);
				if (CommonUtil.isNotNullOrEmpty(resultDomain)) {
					result.put("noRec", resultDomain.getNoRec());
				}
			} else {
				IndekKinerja model = new IndekKinerja();
				model = indekKinerjaConverter.transferVOToModel(indekKinerjaVO, model);
				model.setNoRec(indekKinerjaVO.getNoRec());
				if (CommonUtil.isNotNullOrEmpty(indekKinerjaVO.getUraianTugas())) {
					model.setUraianTugas(uraianTugasConverter.transferVOToModel(indekKinerjaVO.getUraianTugas(),
							new MapUraianTugasToRincianKegiatan()));
				}
				if (CommonUtil.isNotNullOrEmpty(indekKinerjaVO.getPegawai())) {
					model.setPegawai(pegawaiConverter.transferVOToModel(indekKinerjaVO.getPegawai(), new Pegawai()));
				}

				IndekKinerja resultDomain = indekKinerjaDao.save(model);
				if (CommonUtil.isNotNullOrEmpty(resultDomain)) {
					result.put("noRec", resultDomain.getNoRec());
				}
			}
		}
		return result;
	}

	@Override
	public Map<String, Object> findPegawaiByRuangan(Integer tahun, Integer bulan, Integer pegawai) {
		Map<String, Object> result = new HashMap<String, Object>();
		try {

			result.put("items", JsonUtil.ToMaps(indekKinerjaDao.findKinerja(tahun, bulan, pegawai)));
		} catch (IllegalArgumentException | IllegalAccessException e) {
			e.printStackTrace();
		}
		return result;
	}

	@Override
	public List<Map<String, Object>> findAllTindakanByPeriod(Integer idPegawai) {
		Pegawai pegawai = this.getPegawaiByUserLogin();
		List<Integer> listException = getDetailProdukAdministrasi(pegawai);
		List<Map<String, Object>> result = new ArrayList<>();

		// check dokter patologi anatomi, lab klinik, radiologi, atw bukan
		List<Integer> listDJP = new ArrayList<>();
		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(pegawai.getId())) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabPA");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK)
				.contains(pegawai.getId())) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabKlinik");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(pegawai.getId())) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukRadiologi");
		} else {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLogbook");
		}

		if (CommonUtil.isNotNullOrEmpty(listException)) {
			listDJP.addAll(listException);
		}

		String prevMonth = "";
		Integer startMonth = 0;
		Integer startYear = 0;
		// start period
		Calendar startCal = Calendar.getInstance();
		if (startCal.get(Calendar.MONTH) == 0) { // jika januari
			startCal.add(Calendar.YEAR, -1); // tahun awalnya adalah tahun lalu
			startMonth = 12;
			startYear = startCal.get(Calendar.YEAR);
		} else { // jika bulan februari dst
			// karena dimulai dari array 0
			startMonth = startCal.get(Calendar.MONTH);
			if (startMonth < 10) {
				prevMonth = "0" + startMonth;
			}
			startYear = startCal.get(Calendar.YEAR);
		}
		String startPeriod = startYear + "-" + prevMonth;
		// end period
		String thisMonth = "";
		Calendar endCal = Calendar.getInstance();
		// karena dimulai dari array 0
		Integer endMonth = endCal.get(Calendar.MONTH) + 1;
		if (endMonth < 10) {
			thisMonth = "0" + endMonth;
		}
		Integer endYear = endCal.get(Calendar.YEAR);
		String endPeriod = endYear + "-" + thisMonth;

		Date start = DateUtil.startMonth(startPeriod);
		Date end = DateUtil.endMonth(endPeriod);
		result = revIndekKinerjaDao.getAllTindakanByPeriod(idPegawai, start, end, listDJP);

		return result;
	}

	@Override
	public List<Map<String, Object>> findTindakanByUserId(Integer idPegawai, String startDate, String endDate,
			Integer idProduk) {
		Pegawai pegawai = this.getPegawaiByUserLogin();
		List<Integer> listException = getDetailProdukAdministrasi(pegawai);
		List<Map<String, Object>> result = new ArrayList<>();

		// check dokter patologi anatomi, lab klinik, radiologi, atw bukan
		List<Integer> listDJP = new ArrayList<>();
		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(pegawai.getId())) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabPA");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK)
				.contains(pegawai.getId())) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabKlinik");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(pegawai.getId())) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukRadiologi");
		} else {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLogbook");
		}

		if (CommonUtil.isNotNullOrEmpty(listException)) {
			listDJP.addAll(listException);
		}
		if (CommonUtil.isNotNullOrEmpty(idProduk)) {
			result = revIndekKinerjaDao.findTindakanByIdUser(idPegawai, startDate, endDate, idProduk, listDJP);
		} else {
			result = revIndekKinerjaDao.findTindakanByIdUser(idPegawai, startDate, endDate, listDJP);
		}

		return result;
	}

	@Override
	public List<Map<String, Object>> findByUserId(String startDate, String endDate) {
		Pegawai pegawai = this.getPegawaiByUserLogin();
		List<Integer> listException = getDetailProdukAdministrasi(pegawai);
		List<Map<String, Object>> result = new ArrayList<>();

		// check dokter patologi anatomi, lab klinik, radiologi, atw bukan
		List<Integer> listDJP = new ArrayList<>();
		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(pegawai.getId())) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabPA");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK)
				.contains(pegawai.getId())) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabKlinik");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(pegawai.getId())) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukRadiologi");
		} else {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLogbook");
		}

		if (CommonUtil.isNotNullOrEmpty(listException)) {
			listDJP.addAll(listException);
		}
		result = revIndekKinerjaDao.findByIdUser(pegawai.getId(), startDate, endDate, listDJP);

		return result;
	}

	@Override
	public List<Map<String, Object>> findTindakanByIdUserAndPeriod(String month) {
		Date start = DateUtil.startMonth(month);
		Date end = DateUtil.endMonth(month);
		Pegawai pegawai = new Pegawai();
		pegawai = this.getPegawaiByUserLogin();
		List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
		List<Map<String, Object>> hasil = new ArrayList<Map<String, Object>>();
		List<Integer> listDetailException = getDetailProdukAdministrasi(pegawai);
		for (int i = 1; i <= 31; i++) {
			Map<String, Object> map = new HashMap<String, Object>();

			String date = "";
			if (i < 10) {
				date = month + "-0" + i;
			} else {
				date = month + "-" + i;
			}
			int idPegawai = pegawai.getId();
			Long totalPerTanggal;
			if (CommonUtil.isNullOrEmpty(listDetailException)) {
				result = indekKinerjaDao.findTindakanByIdUserAndPeriod(idPegawai, start, end,
						splitIdProdukAdministrasi());
				totalPerTanggal = indekKinerjaDao.findTotalTindakanPerTanggal(idPegawai, date,
						splitIdProdukAdministrasi());
			} else {
				result = indekKinerjaDao.findTindakanByIdUserAndPeriodWithException(idPegawai, start, end,
						splitIdProdukAdministrasi(), listDetailException);
				totalPerTanggal = indekKinerjaDao.findTotalTindakanPerTanggalWithException(idPegawai, date,
						splitIdProdukAdministrasi(), listDetailException);
			}
			if (CommonUtil.isNotNullOrEmpty(result)) {
				map.put("date", date);
				map.put("result", result);
				map.put("total", totalPerTanggal);
				hasil.add(map);
			}
		}

		return hasil;
	}

	@Override
	public Pegawai getPegawaiByUserLogin() {
		LoginUser loginUser = loginUserService.getLoginUser();
		Pegawai r = new Pegawai();
		if (CommonUtil.isNotNullOrEmpty(loginUser.getPegawai())) {
			r = loginUser.getPegawai();
		}
		return r;
	}
	// sementara dipasang disini untuk menggambil id pegawai

	@Override
	public Double getPoin(Double totalTarif, Double percentage, Double tarif) {
		DecimalFormat df = new DecimalFormat("#.##");
		Double poin = (totalTarif * percentage) / tarif;
		Double result = Double.parseDouble(df.format(poin));
		return result;
	}

	/**
	 * Formula menghitung poin logbook dokter dengan penyesuaian poin jika
	 * diskon jasamedis
	 * 
	 * @param totalTarif
	 *            : harga tindakan yang disepakati
	 * @param percentage
	 *            : persentase bagian tertentu yang menjadi hak dokter
	 * @param tarif
	 *            : konstanta pembagi
	 * @param isDiskonJasamedis
	 *            : status diskon jasamedis yang dilakukan dokter
	 * @return poin logbook medis
	 */
	public Double getPoinLogbookDokter(Double totalTarif, Double percentage, Double tarif, Boolean isDiskonJasamedis) {
		if (isDiskonJasamedis) {
			return 0.0;
		} else {
			DecimalFormat df = new DecimalFormat("#.##");
			Double poin = (totalTarif * percentage) / tarif;
			Double result = Double.parseDouble(df.format(poin));
			return result;
		}
	}

	public Double getPoinLogbookDokter(Double hargaKomponen, Boolean isDiskonJasamedis) {
		if (isDiskonJasamedis) {
			return 0.0;
		} else {
			return hargaKomponen / Master.LogbookDokter.KOMPONEN_DASAR;
		}
	}

	@Override
	public List<Map<String, Object>> findUraianTugas() {
		Pegawai pegawai = this.getPegawaiByUserLogin();
		Jabatan jabatan = pegawaiDao.findJabatanInternalByIdPegawai(pegawai.getId());// jabatanFungsional
		List<Integer> idJabtanManajerial = pegawaiDao.findIdJabatanManajerialByIdPegawai(pegawai.getId());// jabatanManajerial
		List<Map<String, Object>> result = indekKinerjaDao.findUraianTugas(jabatan.getId());
		for (Integer id : idJabtanManajerial) {
			List<Map<String, Object>> uraianTugasManjerial = indekKinerjaDao.findUraianTugas(id);
			result.addAll(uraianTugasManjerial);
		}
		return result;
	}

	@Override
	public List<Map<String, Object>> findCountTindakanByIdUserAndPeriod(String startDate, String endDate) {
		Pegawai pegawai = this.getPegawaiByUserLogin();
		List<Map<String, Object>> datas = new ArrayList<>();
		Long size;

		List<Integer> listDetailException = getDetailProdukAdministrasi(pegawai.getId());

		// check dokter patologi anatomi, lab klinik, radiologi, atw bukan
		List<Integer> listDJP = new ArrayList<>();
		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(pegawai.getId())) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabPA");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK)
				.contains(pegawai.getId())) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabKlinik");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(pegawai.getId())) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukRadiologi");
		} else {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLogbook");
		}

		if (CommonUtil.isNotNullOrEmpty(listDetailException)) {
			listDJP.addAll(listDetailException);
		}
		datas = revIndekKinerjaDao.findCountTindakanByIdUser(pegawai.getId(), startDate, endDate, listDJP);
		size = revIndekKinerjaDao.findTotalTindakan(pegawai.getId(), startDate, endDate, listDJP);

		List<Map<String, Object>> hasil = new ArrayList<Map<String, Object>>();
		for (Map<String, Object> data : datas) {
			Map<String, Object> result = new HashMap<String, Object>();
			long jumlah = 0;
			if (data.get("count") != null) {
				jumlah = (long) data.get("count");
			}
			result.put("namaProduk", data.get("namaProduk"));
			result.put("count", data.get("count"));
			double persen = (((double) jumlah / (double) size) * 100);
			persen = (double) Math.round(persen * 100) / 100;
			data.put("persen", persen);
			hasil.add(data);

		}
		return hasil;

	}

	@Override
	public List<Map<String, Object>> findCountTindakanByIdUserAndPeriod(Integer idPegawai, String startDate,
			String endDate) {
		Pegawai pegawai = this.getPegawaiByUserLogin();
		List<Map<String, Object>> datas = new ArrayList<>();
		Long size;

		List<Integer> listDetailException = getDetailProdukAdministrasi(idPegawai);

		// check dokter patologi anatomi, lab klinik, radiologi, atw bukan
		List<Integer> listDJP = new ArrayList<>();
		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(pegawai.getId())) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabPA");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK)
				.contains(pegawai.getId())) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabKlinik");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(pegawai.getId())) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukRadiologi");
		} else {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLogbook");
		}

		if (CommonUtil.isNotNullOrEmpty(listDetailException)) {
			listDJP.addAll(listDetailException);
		}
		datas = revIndekKinerjaDao.findCountTindakanByIdUser(idPegawai, startDate, endDate, listDJP);
		size = revIndekKinerjaDao.findTotalTindakan(idPegawai, startDate, endDate, listDJP);

		List<Map<String, Object>> hasil = new ArrayList<Map<String, Object>>();
		for (Map<String, Object> data : datas) {
			Map<String, Object> result = new HashMap<String, Object>();
			long jumlah = 0;
			if (data.get("count") != null) {
				jumlah = (long) data.get("count");
			}
			result.put("namaProduk", data.get("namaProduk"));
			result.put("count", data.get("count"));
			double persen = (((double) jumlah / (double) size) * 100);
			persen = (double) Math.round(persen * 100) / 100;
			data.put("persen", persen);
			hasil.add(data);

		}
		return hasil;

	}

	@Override
	public Map<String, Object> detailPoin(String tgl, Integer idPegawai) {

		Map<String, Object> result = new HashMap<String, Object>();
		Pegawai pgw = pegawaiDao.findOne(idPegawai);
		Double total = 0.0;
		List<Map<String, Object>> datas = new ArrayList<>();
		List<Map<String, Object>> temp = new ArrayList<>();
		List<Integer> listDetailException = getDetailProdukAdministrasi(pgw);

		temp = indeksKinerjaDaoCustom.findTindakanByIdUser(idPegawai, tgl, splitIdProdukAdministrasi(), false,
				listDetailException);

		datas.addAll(temp);
		for (Map<String, Object> data : datas) {
			int idDetail = (int) data.get("detailId");
			Double pointQty = 0.0;
			Double percentage = 0.0;
			Double tarif = 0.0;

			Map<String, Object> perhitunganPoin = indekKinerjaDao.findVariabelPembagiPoin(idDetail);
			if (CommonUtil.isNotNullOrEmpty(perhitunganPoin)) {
				percentage = (Double) perhitunganPoin.get("pembagiPoin");
				data.put("persentase(%)", percentage);
				tarif = ((Double) perhitunganPoin.get("persentasePoin"));
				data.put("tarif", tarif);
			}

			percentage = percentage / 100;
			Double harga = (Double) data.get("harga");
			Long count = (Long) data.get("count");
			if (tarif != 0) {
				Double point = getPoin(harga, percentage, tarif);
				pointQty = point * count.doubleValue();
			}
			total += pointQty;
		}
		result.put("tgl", tgl);
		result.put("idPegawai", idPegawai);
		result.put("total", total);
		result.put("listData", datas);
		return result;

	}

	@Override
	public Map<String, Object> getIndekKinerjaKuantitasData(String periode, Integer id, Boolean isNew) {
		Map<String, Object> result = new HashMap<String, Object>();
		Map<String, Object> pelayananPasien = new HashMap<String, Object>();
		List<Map<String, Object>> listResult = new ArrayList<Map<String, Object>>();
		if (isNew == null)
			isNew = false;
		Double total = 0.0;

		Jabatan jabatan = pegawaiDao.findJabatanInternalByIdPegawai(id);// jabatanFungsional
		Integer idJabatan = 0;
		if (CommonUtil.isNotNullOrEmpty(jabatan)) {
			idJabatan = jabatan.getId();
		}
		List<Integer> idJabtanManajerial = pegawaiDao.findIdJabatanManajerialByIdPegawai(id);// jabatanManajerial
		List<Map<String, Object>> temp = uraianTugasTransaksiDao.findAllUraianTugasByIdJabatan(idJabatan);// getAllUraianKerja
		for (Integer idPegawai : idJabtanManajerial) {
			List<Map<String, Object>> uraianTugasManjerial = uraianTugasTransaksiDao
					.findAllUraianTugasByIdJabatan(idPegawai);
			temp.addAll(uraianTugasManjerial);
		}

		for (Map<String, Object> data : temp) {
			int idRincianKegiatan = (int) data.get("idRincianKegiatan");
			Double hasil = 0.0;
			if (idRincianKegiatan == getIdPelayananPasien()) {
				pelayananPasien = kuantitasPelayanan(periode, id, 10);
				listResult.add(pelayananPasien);
				hasil = ((Double) pelayananPasien.get("hasil"));
				total += hasil;
			} else {
				Map<String, Object> dataMaster = uraianTugasTransaksiDao.findUraianTugas(id, idRincianKegiatan,
						periode);
				if (CommonUtil.isNotNullOrEmpty(dataMaster)) {
					total += ((Double) dataMaster.get("hasil"));
					listResult.add(dataMaster);
				} else {
					data.put("bobot", 0);
					data.put("target", 0);
					data.put("nilai", 0);
					data.put("hasil", 0);
					data.put("total", 0);
					data.put("periode", periode);
					listResult.add(data);
				}

			}
		}

		result.put("uraianTugas", listResult);
		result.put("totalKuantitas", total);
		return result;
	}

	public Map<String, Object> kuantitasPelayanan(String periode, int idPegawai, int rincianKegiatan) {
		Map<String, Object> result = new HashMap<String, Object>();
		Double nilai = 0.0;
		Double totalAll = 0.0;
		Double hasil = 0.0;
		Double target = 0.0;
		Double bobot = 0.0;
		List<Map<String, Object>> listpelayananPasien = this.getAllTindakanByDokterReport(periode, idPegawai);
		if (CommonUtil.isNotNullOrEmpty(listpelayananPasien)) {
			// get the last index
			Map<String, Object> pelayananPasien = listpelayananPasien.get(listpelayananPasien.size() - 1);
			if (CommonUtil.isNotNullOrEmpty(pelayananPasien.get("totalPoint"))) {
				totalAll = (Double) pelayananPasien.get("totalPoin");
				Map<String, Object> uraianTugas = uraianTugasTransaksiDao.findUraianTugas(idPegawai, rincianKegiatan,
						periode);
				if (CommonUtil.isNotNullOrEmpty(uraianTugas))

				{
					target = (Double) uraianTugas.get("target");
					bobot = (Double) uraianTugas.get("bobot");
					if (target != 0.0) {
						nilai = getNilai(totalAll, target);
					}
					hasil = getHasil(nilai, bobot);
				}
			}
		}

		result.put("rincianKegiatan", "Pelayanan Pasien");
		result.put("periode", periode);
		result.put("total", totalAll);
		result.put("nilai", nilai);
		result.put("hasil", hasil);
		result.put("target", target);
		result.put("bobot", bobot);
		result.put("idRincianKegiatan", rincianKegiatan);
		return result;
	}

	@Override
	public Map<String, Object> rekapPoin(String periode, int idPegawai) {
		Pegawai pgw = pegawaiDao.findOne(idPegawai);
		Map<String, Object> result = new HashMap<String, Object>();
		Double nilai = 0.0;
		Double totalAll = 0.0;
		List<Integer> listDetailException = getDetailProdukAdministrasi(pgw);
		int maxday = monitoringAbsenService.iterateDate(periode + "-01");
		for (int i = 1; i <= maxday; i++) {
			String date = "";
			Double total = 0.0;
			if (i < 10) {
				date = periode + "-0" + i;
			} else {
				date = periode + "-" + i;
			}
			List<Map<String, Object>> datas = new ArrayList<>();
			List<Map<String, Object>> temp = new ArrayList<>();
			List<Map<String, Object>> temps = new ArrayList<>();
			temp = indeksKinerjaDaoCustom.findAllProdukPerTanggal(idPegawai, date, splitIdProdukAdministrasi(), false,
					null, null, listDetailException);
			temps = indeksKinerjaDaoCustom.findAllProdukPerTanggal(idPegawai, date, splitIdProdukAdministrasi(), true,
					null, null, listDetailException);

			datas.addAll(temp);
			temp.addAll(temps);
			for (Map<String, Object> data : datas) {
				int idDetail = (int) data.get("detailId");
				Double pointQty = 0.0;
				Double percentage = 0.0;
				Double tarif = 0.0;

				Map<String, Object> perhitunganPoin = indekKinerjaDao.findVariabelPembagiPoin(idDetail);
				if (CommonUtil.isNotNullOrEmpty(perhitunganPoin)) {
					percentage = (Double) perhitunganPoin.get("pembagiPoin");
					tarif = ((Double) perhitunganPoin.get("persentasePoin"));
				}

				percentage = percentage / 100;
				Double harga = (Double) data.get("harga");
				Long count = (Long) data.get("count");
				if (tarif != 0) {
					Double point = getPoin(harga, percentage, tarif);
					pointQty = point * count.doubleValue();
				}
				total += pointQty;
			}
			result.put(i + "", total);
			totalAll += total;
		}
		result.put("periode", periode);
		result.put("total", totalAll);
		result.put("nilai", nilai);

		return result;
	}

	@Override
	public Double getNilai(Double jumlah, Double target) {
		Double result = jumlah / target;
		if (result.isNaN()) {
			result = 0.0;
		}
		return result;
	}

	@Override
	public Double getHasil(Double nilai, Double bobot) {
		Double result = (nilai * bobot);
		if (result.isNaN()) {
			result = 0.0;
		}
		return result;
	}

	public int getIdPelayananPasien() {
		String temp = indekKinerjaDao.findIdPelayananPasien();
		int id = Integer.parseInt(temp);
		return id;
	}

	@Override
	public List<Map<String, Object>> findUraianTugasByTanggal(String date) {
		String periode = date.substring(0, 7);
		List<Map<String, Object>> temp = uraianTugasTransaksiDao
				.findUraianTugasByPeriode(getPegawaiByUserLogin().getId(), periode);
		List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();

		for (Map<String, Object> data : temp) {
			if (CommonUtil.isNotNullOrEmpty(data.get("rincianKegiatanId"))) {
				Integer idRincian = (Integer) data.get("rincianKegiatanId");
				Double capaian = 0.0;
				Map<String, Object> uraianTugas = uraianTugasTransaksiDao
						.findUraianTugasByTanggalAndRincianKegiatan(getPegawaiByUserLogin().getId(), idRincian, date);
				if (CommonUtil.isNotNullOrEmpty(uraianTugas)) {
					capaian = (Double) uraianTugas.get("capaian");
				} // if rincian kegiatan is pelayanan pasien
				if (idRincian == getIdPelayananPasien()) {

					Long jumlahPerTanggal = indekKinerjaDao.findTotalTindakanPerTanggalDanJenisProduk(
							getPegawaiByUserLogin().getId(), date, splitIdProdukAdministrasi());
					capaian = jumlahPerTanggal.doubleValue();
				}

				data.put("capaian", capaian);
				result.add(data);
			}
		}
		return result;
	}

	@Override
	public Map<String, Object> SaveTotalIndexKinerja(NilaiIndexKinerjaIndividuVO vo) {
		Map<String, Object> result = new HashMap<String, Object>();

		if (CommonUtil.isNotNullOrEmpty(vo)) {
			NilaiIndexKinerjaIndividu nilaiIndexKinerjaIndividu = nilaiIndexKinerjaIndividuConverter
					.transferVOToModel(vo, new NilaiIndexKinerjaIndividu());
			Pegawai pegawai = pegawaiConverter.transferVOToModel(vo.getPegawai(), new Pegawai());
			nilaiIndexKinerjaIndividu.setPegawai(pegawai);
			if (CommonUtil.isNotNullOrEmpty(nilaiIndexKinerjaIndividu)) {
				NilaiIndexKinerjaIndividu model = nilaiIndexKinerjaIndividuDao.save(nilaiIndexKinerjaIndividu);
				result.put(model.getPeriode() + "", model.noRec);
			}
		}
		return result;
	}

	@Override
	public Map<String, Object> saveIndekKinerjaIndividu(IndeksKinerjaIndividuVO vo) {
		Map<String, Object> result = new HashMap<String, Object>();
		if (CommonUtil.isNotNullOrEmpty(vo)) {
			IndeksKinerjaIndividu indekKinerjaIndividu = indekKinerjaIndividuConverter.transferVOToModel(vo,
					new IndeksKinerjaIndividu());
			Pegawai pegawai = pegawaiConverter.transferVOToModel(vo.getPegawai(), new Pegawai());
			KomponenIKI komponenIKI = komponenIKIConverter.transferVOToModel(vo.getKomponenIKI(), new KomponenIKI());
			indekKinerjaIndividu.setKomponenIKI(komponenIKI);
			indekKinerjaIndividu.setPegawai(pegawai);
			String periode = indekKinerjaIndividu.getPeriode().substring(0, 7);
			indekKinerjaIndividu.setPeriode(periode);
			NilaiIndexKinerjaIndividu nilaiIndexKinerjaIndividu = nilaiIndexKinerjaIndividuConverter
					.transferVOToModel(vo.getNilaiIndexKinerjaIndividu(), new NilaiIndexKinerjaIndividu());
			Map<String, Object> nilaiIKI = indekKinerjaDao.findNilaiIndeksKinerja(pegawai.getId(), periode);
			if (CommonUtil.isNotNullOrEmpty(indekKinerjaIndividu)) {
				IndeksKinerjaIndividu model = indeksKinerjaIndividuDao.save(indekKinerjaIndividu);
				result.put(model.getPeriode() + "", model.noRec);
				if (CommonUtil.isNotNullOrEmpty(model)) {
					if (CommonUtil.isNotNullOrEmpty(nilaiIKI)) {
						String noRec = (String) nilaiIKI.get("noRec");
						nilaiIndexKinerjaIndividu.setNoRec(noRec);
						NilaiIndexKinerjaIndividu modell = nilaiIndexKinerjaIndividuDao.save(nilaiIndexKinerjaIndividu);
						result.put(modell.getPeriode() + "", modell.noRec);
					}
				}
				nilaiIndexKinerjaIndividu.setPegawai(pegawai);
				if (CommonUtil.isNotNullOrEmpty(nilaiIKI)) {
					String noRec = (String) nilaiIKI.get("noRec");
					nilaiIndexKinerjaIndividu.setNoRec(noRec);
				}

			}
		}
		return result;
	}

	@Override
	public Map<String, Object> saveAllIndekKinerja(IndeksKinerjaIndividuCustomVO vo) {
		Map<String, Object> result = new HashMap<String, Object>();
		NilaiIndexKinerjaIndividu nilaiIndexKinerjaIndividu = new NilaiIndexKinerjaIndividu();
		Map<String, Object> nilaiIKI = new HashMap<String, Object>();
		int state = 0;
		if (CommonUtil.isNotNullOrEmpty(vo)) {
			for (IndeksKinerjaIndividuVO temp : vo.getIndeksKinerjaIndividu()) {
				IndeksKinerjaIndividu indekKinerjaIndividu = indekKinerjaIndividuConverter.transferVOToModel(temp,
						new IndeksKinerjaIndividu());
				indekKinerjaIndividu.setKeterangan(temp.getKeterangan());
				Pegawai pegawai = pegawaiConverter.transferVOToModel(temp.getPegawai(), new Pegawai());
				KomponenIKI komponenIKI = komponenIKIConverter.transferVOToModel(temp.getKomponenIKI(),
						new KomponenIKI());
				indekKinerjaIndividu.setKomponenIKI(komponenIKI);
				indekKinerjaIndividu.setPegawai(pegawai);
				String periode = indekKinerjaIndividu.getPeriode().substring(0, 7);
				indekKinerjaIndividu.setPeriode(periode);
				nilaiIndexKinerjaIndividu = nilaiIndexKinerjaIndividuConverter
						.transferVOToModel(temp.getNilaiIndexKinerjaIndividu(), new NilaiIndexKinerjaIndividu());
				if (CommonUtil.isNotNullOrEmpty(indekKinerjaIndividu)) {
					IndeksKinerjaIndividu model = indeksKinerjaIndividuDao.save(indekKinerjaIndividu);
					result.put(model.getPeriode() + "", model.noRec);
					state++;
				}
				nilaiIndexKinerjaIndividu.setPegawai(pegawai);
				nilaiIKI = indekKinerjaDao.findNilaiIndeksKinerja(pegawai.getId(), periode);// getnilaiIndekskinerjaindividu
			}
		}
		if (CommonUtil.isNotNullOrEmpty(nilaiIKI)) {
			String noRec = (String) nilaiIKI.get("noRec");
			nilaiIndexKinerjaIndividu.setNoRec(noRec);
		}
		if (state == vo.getIndeksKinerjaIndividu().size()) {
			if (CommonUtil.isNotNullOrEmpty(nilaiIndexKinerjaIndividu)) {
				NilaiIndexKinerjaIndividu model = nilaiIndexKinerjaIndividuDao.save(nilaiIndexKinerjaIndividu);
				result.put(model.getPeriode() + "", model.noRec);
			}
		}
		return result;
	}

	@Override
	public Map<String, Object> findKualitasAndInovasi(String periode, Integer idPegawai) {
		Map<String, Object> result = new HashMap<String, Object>();
		Map<String, Object> remun = ikiDanRemunerasiDao.findRemun(idPegawai, periode);
		if (CommonUtil.isNotNullOrEmpty(remun)) {
			result.put("status", true);// remun sudah dihitung
		} else {
			result.put("status", false);
		}
		Date start = DateUtil.startMonth(periode);
		Date end = DateUtil.endMonth(periode);
		Double indeksKehadiran = indekKinerjaDao.findIndexKehadiran(idPegawai, start, end);
		Map<String, Object> totalIKI = indekKinerjaDao.findNilaiIndeksKinerja(idPegawai, periode);
		if (CommonUtil.isNotNullOrEmpty(totalIKI)) {
			result.put("totalIki", totalIKI.get("totalIKI") != null ? totalIKI.get("totalIKI") : 0.0);
		} else {
			result.put("totalIki", 0.0);
		}
		result.put("capaian", indeksKehadiran);
		List<Map<String, Object>> listIndeksKinerja = indekKinerjaDao.findKualitasAndInovasi(idPegawai, periode);
		result.put("IndeksKinerja", listIndeksKinerja);
		return result;
	}

	@Override
	public Map<String, Object> findKehadiran(String periode, Integer idPegawai) {
		Map<String, Object> result = new HashMap<String, Object>();
		Pegawai pegawai = pegawaiDao.findOne(idPegawai);
		if (CommonUtil.isNotNullOrEmpty(pegawai)) {

			Integer target = 1;
			result.put("target", target);
			Double bobot = indekKinerjaDao.findBobotKehadiran();
			result.put("bobot", bobot);
			String startDate = periode + "-01";
			int maxDay = monitoringAbsenService.iterateDate(startDate);
			String endDate = periode + "-" + maxDay;

			Map<String, Object> data = monitoringAbsenService.rekapitulasiIndeksKehadiranByPegawai(idPegawai, startDate,
					endDate);
			if (CommonUtil.isNotNullOrEmpty(data)) {
				if (CommonUtil.isNotNullOrEmpty(data.get("jumlahHariKerja"))) {
					result.put("capaian", data.get("P1persen"));
					Double capaian = (Double) data.get("P1persen");
					Double nilai = this.getNilai(capaian, target.doubleValue());
					result.put("nilai", nilai);
					Double hasil = this.getHasil(nilai, bobot);
					if (hasil > bobot) {
						result.put("hasil", bobot);
					} else {
						result.put("hasil", hasil);
					}
				}
			}
		}
		return result;
	}

	@Override
	public Map<String, Object> rekapIKI(Integer ruanganId, String periode) {
		Map<String, Object> result = new HashMap<String, Object>();
		List<Map<String, Object>> listIKI = new ArrayList<Map<String, Object>>();
		if (CommonUtil.isNotNullOrEmpty(ruanganId)) {
			listIKI = nilaiIndexKinerjaIndividuDao.findRekapitulasiIKI(ruanganId, periode);
		} else {
			listIKI = nilaiIndexKinerjaIndividuDao.findAllRekapitulasiIKI(periode);
		}
		Double jumlah = 0.0;
		Integer index = 0;
		String unitKerja = "";
		for (Map<String, Object> data : listIKI) {
			index++;
			if (CommonUtil.isNotNullOrEmpty(data.get("totalIKI"))) {
				jumlah += (Double) data.get("totalIKI");
				unitKerja = (String) data.get("unitKerja");
			}
		}
		result.put("listIKI", listIKI);
		result.put("unitKerja", unitKerja);
		result.put("jumlah", jumlah / (index.doubleValue()));
		return result;
	}

	@Override
	public List<Map<String, Object>> getIndekKinerjaKuantitasPerUnitKerja(String periode, Integer idUnitKerja) {
		List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
		List<Integer> listPegawai = monitoringAbsenDao.findPegawaiaAktifDanKaryawanByRuangan(idUnitKerja);
		for (Integer id : listPegawai) {
			Map<String, Object> pelayananPasien = kuantitasPelayanan(periode, id, getIdPelayananPasien());
			Pegawai pegawai = pegawaiDao.getPegawaiById(id);
			pelayananPasien.put("namaPegawai", pegawai.getNamaLengkap());
			result.add(pelayananPasien);
		}
		return result;
	}

	@Override
	public List<Integer> splitIdProdukAdministrasi() {
		List<Integer> listId = new ArrayList<Integer>();
		String idJenisProdukAdministrasi = indekKinerjaDao.findIdJenisProdukAdministrasi();
		if (CommonUtil.isNotNullOrEmpty(idJenisProdukAdministrasi)) {
			String idSplit[] = idJenisProdukAdministrasi.split(",");
			for (int i = 0; i < idSplit.length; i++) {
				listId.add(Integer.parseInt(idSplit[i]));
			}
		}
		return listId;
	}

	@Override
	public List<Integer> splitIdProdukAdministrasiAndLaborat() {
		List<Integer> listId = splitIdProdukAdministrasi();

		List<Integer> listIdProduk = mapRuanganToProdukDao.findJenisProdukExepetion(
				Integer.parseInt(settingDataFixedDao.getSettingDataFixed("ruanganLabFilterLog")));
		if (CommonUtil.isNotNullOrEmpty(listIdProduk)) {
			listId.addAll(listIdProduk);
		}
		return listId;
	}

	@Override
	public List<Integer> getDetailProdukAdministrasi(Pegawai pgw) {
		List<MapPegawaiLaboratRadiologi> maps = mapPegawaiLaboratRadiologiDao.findAllDataObject();
		Boolean isLab = false;
		if (CommonUtil.isNotNullOrEmpty(maps)) {
			if (CommonUtil.isNotNullOrEmpty(pgw.getId())) {
				for (MapPegawaiLaboratRadiologi tmps : maps) {
					if (pgw.getId().equals(tmps.getPegawaiId())) {
						isLab = true;
						break;
					}
				}
			}
		}

		List<Integer> listIdProduk = new ArrayList<>();
		if (isLab) {
			listIdProduk = splitIdProdukAdministrasiAndLaborat();
		}
		return listIdProduk;
	}

	@Override
	public List<Integer> getDetailProdukAdministrasi(Integer idPegawai) {
		List<MapPegawaiLaboratRadiologi> maps = mapPegawaiLaboratRadiologiDao.findAllDataObject();
		Boolean isLab = false;
		if (CommonUtil.isNotNullOrEmpty(maps)) {
			if (CommonUtil.isNotNullOrEmpty(idPegawai)) {
				for (MapPegawaiLaboratRadiologi tmps : maps) {
					if (idPegawai.equals(tmps.getPegawaiId())) {
						isLab = true;
						break;
					}
				}
			}
		}

		List<Integer> listIdProduk = new ArrayList<>();
		if (isLab) {
			listIdProduk = splitIdProdukAdministrasiAndLaborat();
		}
		return listIdProduk;
	}

	@Override
	public Map<String, Object> saveTabelAcuanIndeksIKI(List<TabelAcuanIndeksIKIVO> vos) {
		Map<String, Object> result = new HashMap<String, Object>();
		for (TabelAcuanIndeksIKIVO vo : vos) {
			TabelAcuanIndeksIKI model = tabelAcuanIndeksIKIConverter.transferVOToModel(vo, new TabelAcuanIndeksIKI());
			if (CommonUtil.isNotNullOrEmpty(model)) {
				tabelAcuanIndeksIKIDao.save(model);
				result.put("id", model.getIndeks());
			}
		}

		return result;
	}

	@Override
	public List<Map<String, Object>> findAcuanIndeksIKI() {
		List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
		List<TabelAcuanIndeksIKI> datas = tabelAcuanIndeksIKIDao.findAllAcuan();
		for (TabelAcuanIndeksIKI data : datas) {
			try {
				result.add(data.ToMap());
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		}
		return result;
	}

	@Override
	public Double getIndeksIKI(Double nilai) {
		Double result = indekKinerjaDao.findIndeksIKI(nilai);
		return result;
	}

	@Override
	@Transactional
	public List<Map<String, Object>> getAllTindakanByDokter(String periode, Integer idPegawai) {
		List<Map<String, Object>> results = new ArrayList<>();
		List<Map<String, Object>> tindakans = new ArrayList<>();
		Pegawai pgw = pegawaiDao.findOne(idPegawai);
		List<Integer> listDetailException = getDetailProdukAdministrasi(pgw);
		String month = periode.substring(0, 7);

		// Check dokter radiologi/klinik/patologi anatom/bukan
		List<Integer> listDJP = new ArrayList<>();
		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabPA");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabKlinik");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukRadiologi");
		} else {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLogbook");
		}

		if (CommonUtil.isNotNullOrEmpty(listDetailException)) {
			listDJP.addAll(listDetailException);
		}

		List<Integer> drAnastesiList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_ANESTESI);
		List<Integer> drPatologiAnatomiList = pegawaiDao
				.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI);

		List<Integer> listKelas2Down = splitDataSettingDatafixed("KelasTindakanRemun");
		List<Integer> listTindakanAnastesiException = splitDataSettingDatafixed("excepTindakAnastesi");
		Integer bpjsKelPasienId = Integer.valueOf(settingDataFixedDao.getSettingDataFixed("bpjsRemun"));

		String tarifSatuHarga = settingDataFixedDao.getSettingDataFixed("tarifSatuHarga");
		Boolean isTarifSatuHarga = Boolean.parseBoolean(tarifSatuHarga);

		String departementRawatInap = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRawatInap");
		String departementICU = settingDataFixedDao.getSettingDataFixed("KdInstalasiICU");
		String departementBedahSentral = settingDataFixedDao.getSettingDataFixed("KdInstalasiBedahSentral");
		String departementRawatJalan = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRawatJalan");
		String instalasiGawatDarurat = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiGawatDarurat");
		String instalasiRehabilMedik = settingDataFixedDao
				.getSettingDataFixed("KdDepartemenInstalasiRehabilitasiMedik");
		String instalasiLaboratorium = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiLaboratorium");
		String instalasiRadiologi = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRadiologi");
		String departemenPeristi = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiPeristi");

		List<String> listAllDepartemen = new ArrayList<>();
		listAllDepartemen.add(departementRawatInap);
		listAllDepartemen.add(departementICU);
		listAllDepartemen.add(departementBedahSentral);
		listAllDepartemen.add(departemenPeristi);
		listAllDepartemen.add(departementRawatJalan);
		listAllDepartemen.add(instalasiGawatDarurat);
		listAllDepartemen.add(instalasiRehabilMedik);
		listAllDepartemen.add(instalasiLaboratorium);
		listAllDepartemen.add(instalasiRadiologi);

		List<String> listInapDepartemen = new ArrayList<>();
		listInapDepartemen.add(departementRawatInap);
		listInapDepartemen.add(departementICU);
		listInapDepartemen.add(departementBedahSentral);
		listInapDepartemen.add(departemenPeristi);

		List<String> listJalanDepartemen = new ArrayList<>();
		listJalanDepartemen.add(departementRawatJalan);
		listJalanDepartemen.add(instalasiGawatDarurat);
		listJalanDepartemen.add(instalasiRehabilMedik);
		listJalanDepartemen.add(instalasiLaboratorium);
		listJalanDepartemen.add(instalasiRadiologi);

		if (CommonUtil.isNotNullOrEmpty(periode) && periode.equals(month)) {
			tindakans = revIndekKinerjaDao.findIdProdukByIdUser(idPegawai, periode, listDJP);
		} else {
			tindakans = revIndekKinerjaDao.findIdProdukHarianByIdUser(idPegawai, periode, listDJP);
		}

		for (Map<String, Object> tindakan : tindakans) {
			Map<String, Object> result = new HashMap<String, Object>();
			Double pointQty = 0.0;
			Double percentage = 0.0;
			Double tarif = 0.0;
			Double harga = 0.0;
			Long count = (long) 0;
			Double point = 0.0;
			tarif = 45000.0;

			List<Map<String, Object>> datas = revIndeksKinerjaDaoCustom.findAllProdukPerPeriode(idPegawai, periode,
					(Integer) tindakan.get("idProduk"), (Integer) tindakan.get("idKelas"),
					(Integer) tindakan.get("idJenisPelaksana"), listKelas2Down, listAllDepartemen, listInapDepartemen,
					listJalanDepartemen, bpjsKelPasienId, drPatologiAnatomiList);

			result.putAll(tindakan);
			if (CommonUtil.isNotNullOrEmpty(datas)) {
				for (Map<String, Object> data : datas) {
					if (CommonUtil.isNotNullOrEmpty(data.get("count"))) {
						count += (Long) data.get("count");
					}
				}
			}

			if (drAnastesiList.contains(idPegawai)) {
				if (listTindakanAnastesiException.contains(tindakan.get("idProduk"))) {
					percentage = 30.0;
				} else if ((Integer) tindakan.get("idJenisPelaksana") == 4) {
					percentage = 30.0;
				} else {
					percentage = 15.0;
				}
			} else {
				if ((Integer) tindakan.get("idJenisPelaksana") == 13) {
					percentage = 15.0;
				} else {
					percentage = 30.0;
				}
			}

			percentage = percentage / 100;
			if (isTarifSatuHarga) {
				harga = (Double) tindakan.get("hargaKelas1");
				if (CommonUtil.isNullOrEmpty(harga)) {
					harga = (Double) tindakan.get("harga");
				}
			} else {
				harga = (Double) tindakan.get("harga");
			}

			if (tarif != 0) {
				point = getPoin(harga, percentage, tarif);
				result.put("poin", point);
			}

			if (CommonUtil.isNotNullOrEmpty(datas)) {
				result.put("idPegawai", idPegawai);
				result.put("datas", datas);
				result.put("totalTindakan", count);
				pointQty = point * count.doubleValue();
				result.put("pointQty", pointQty);
				results.add(result);
			}

		}
		return results;
	}

	@Override
	public List<Map<String, Object>> findPatientDetailForEveryTindakan(Integer idProduk, Integer idKelas,
			Integer idPegawai, String tgl, Boolean ffs) {

		Pegawai pgw = pegawaiDao.findOne(idPegawai);
		Integer kategoryPgw = pgw.getKategoryPegawaiId();

		List<Integer> listKelas2Down = splitDataSettingDatafixed("KelasTindakanRemun");

		String departementRawatInap = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRawatInap");
		String departementICU = settingDataFixedDao.getSettingDataFixed("KdInstalasiICU");
		String departementBedahSentral = settingDataFixedDao.getSettingDataFixed("KdInstalasiBedahSentral");
		String departementRawatJalan = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRawatJalan");
		String instalasiGawatDarurat = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiGawatDarurat");
		String instalasiRehabilMedik = settingDataFixedDao
				.getSettingDataFixed("KdDepartemenInstalasiRehabilitasiMedik");
		String instalasiLaboratorium = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiLaboratorium");
		String instalasiRadiologi = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRadiologi");
		String departemenPeristi = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiPeristi");

		List<String> listAllDepartemen = new ArrayList<>();
		listAllDepartemen.add(departementRawatInap);
		listAllDepartemen.add(departementICU);
		listAllDepartemen.add(departementBedahSentral);
		listAllDepartemen.add(departemenPeristi);
		listAllDepartemen.add(departementRawatJalan);
		listAllDepartemen.add(instalasiGawatDarurat);
		listAllDepartemen.add(instalasiRehabilMedik);
		listAllDepartemen.add(instalasiLaboratorium);
		listAllDepartemen.add(instalasiRadiologi);

		List<String> listInapDepartemen = new ArrayList<>();
		listInapDepartemen.add(departementRawatInap);
		listInapDepartemen.add(departementICU);
		listInapDepartemen.add(departementBedahSentral);
		listInapDepartemen.add(departemenPeristi);

		List<String> listJalanDepartemen = new ArrayList<>();
		listJalanDepartemen.add(departementRawatJalan);
		listJalanDepartemen.add(instalasiGawatDarurat);
		listJalanDepartemen.add(instalasiRehabilMedik);
		listJalanDepartemen.add(instalasiLaboratorium);
		listJalanDepartemen.add(instalasiRadiologi);

		Integer idBPJS = Integer.valueOf(settingDataFixedDao.getSettingDataFixed("bpjsRemun"));
		List<Integer> listKategoriDokterLuar = splitDataSettingDatafixed("kategoryPegawaiDokterLuar");

		List<Integer> drPatologiAnatomiList = pegawaiDao
				.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI);

		List<Map<String, Object>> DetailPasien = new ArrayList<>();

		if (listKategoriDokterLuar.contains(kategoryPgw)) {
			DetailPasien = revIndeksKinerjaDaoCustom.findPatientDetailDokterLuarForEveryTindakan(idPegawai, tgl,
					idProduk, idKelas, listAllDepartemen);
		} else {
			DetailPasien = revIndeksKinerjaDaoCustom.findPatientDetailForEveryTindakan(idProduk, idPegawai, idKelas,
					tgl, listKelas2Down, listAllDepartemen, listInapDepartemen, listJalanDepartemen, idBPJS,
					drPatologiAnatomiList, ffs);
		}

		return DetailPasien;
	}

	@Override
	public List<Map<String, Object>> findPatientDetailForEveryTindakanAll(Integer idProduk, Double harga,
			Integer idPegawai, String periode) {
		List<String> listFriday = indeksKinerjaDaoCustom.convertMonthtoDateCustom(periode, true);
		List<String> listSK = indeksKinerjaDaoCustom.convertMonthtoDateCustom(periode, false);
		List<String> listRanap = indeksKinerjaDaoCustom.convertMonthtoDateCustom(periode, null);
		List<Map<String, Object>> DetailPasien = indeksKinerjaDaoCustom.findPatientDetailForEveryTindakanAll(idProduk,
				harga, idPegawai, periode, listFriday, listSK, listRanap);
		return DetailPasien;
	}

	@Override
	public List<Map<String, Object>> findPatientDetailForEveryTindakanAllV2(Integer idPegawai, String tgl) {
		List<String> listFriday = indeksKinerjaDaoCustom.convertMonthtoDateCustom(tgl, true);
		List<String> listSK = indeksKinerjaDaoCustom.convertMonthtoDateCustom(tgl, false);
		List<String> listRanap = indeksKinerjaDaoCustom.convertMonthtoDateCustom(tgl, null);
		List<Map<String, Object>> DetailPasien = indeksKinerjaDaoCustom
				.findPatientDetailForEveryTindakanAllV2(idPegawai, tgl, listFriday, listSK, listRanap);
		return DetailPasien;
	}

	@Override
	@Transactional
	public void generateAllTindakanDokter() {
		SimpleDateFormat monthFormat = new SimpleDateFormat("yyyy-MM");

		List<Integer> allPegawaiKedokteran = pegawaiDao.getPegawaiKedokteran();
		Calendar cal = Calendar.getInstance();
		cal.add(Calendar.MONTH, -1);
		String periode = monthFormat.format(cal.getTime());
		for (Integer idPegawai : allPegawaiKedokteran) {
			List<Map<String, Object>> allTindakanDokter = getAllTindakanDokter(periode, idPegawai);
			for (Map<String, Object> map : allTindakanDokter) {
				LogbookDokter logbookDokter = new LogbookDokter();

				logbookDokter.setIdPegawai(idPegawai);
				logbookDokter.setIdProduk((Integer) map.get("idProduk"));
				logbookDokter.setNamaProduk((String) map.get("namaProduk"));
				logbookDokter.setHargaKelas1((Double) map.get("hargaKelas1"));
				logbookDokter.setTotalTindakan((Long) map.get("totalTindakan"));
				logbookDokter.setDetailId((Integer) map.get("detailId"));
				logbookDokter.setNamaKelas((String) map.get("namaKelas"));
				logbookDokter.setIdKelas((Integer) map.get("idKelas"));
				logbookDokter.setPoinQty((Double) map.get("pointQty"));
				logbookDokter.setPoin((Double) map.get("poin"));
				logbookDokter.setIdJenisPelaksana((Integer) map.get("idJenisPelaksana"));
				logbookDokter.setHarga((Double) map.get("harga"));
				logbookDokter.setDetailJenisProduk((String) map.get("detailJenisProduk"));
				logbookDokter.setStatusEnabled(true);
				// kode profile rumah sakit
				logbookDokter.setKdProfile((short) 0);
				logbookDokterDao.save(logbookDokter);

				@SuppressWarnings("unchecked")
				List<Map<String, Object>> datas = (List<Map<String, Object>>) map.get("datas");
				for (Map<String, Object> data : datas) {
					DetailLogbookDokter detailLogbookDokter = new DetailLogbookDokter();
					SimpleDateFormat tanggalFormat = new SimpleDateFormat("yyyy-MM-dd");
					Date tanggal = new Date();
					try {
						tanggal = tanggalFormat.parse(data.get("tanggal").toString());
					} catch (ParseException e) {
						e.printStackTrace();
					}

					detailLogbookDokter.setCount((Long) data.get("count"));
					detailLogbookDokter.setHarga((Double) data.get("harga"));
					detailLogbookDokter.setTanggal(tanggal);
					detailLogbookDokter.setLogbookDokter(logbookDokter);
					detailLogbookDokter.setStatusEnabled(true);
					detailLogbookDokter.setKdProfile((short) 0);
					detailLogbookDokterDao.save(detailLogbookDokter);
				}

			}
		}
	}

	@Override
	@Transactional
	public List<Map<String, Object>> getAllTindakanDokter(String periode, Integer idPegawai) {
		List<Map<String, Object>> results = new ArrayList<>();
		List<Map<String, Object>> tindakans = new ArrayList<>();

		Pegawai pgw = pegawaiDao.findOne(idPegawai);
		List<Integer> listDetailException = getDetailProdukAdministrasi(pgw);

		// Check dokter radiologi/klinik/patologi anatom/bukan
		List<Integer> listDJP = new ArrayList<>();
		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabPA");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabKlinik");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukRadiologi");
		} else {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLogbook");
		}

		if (CommonUtil.isNotNullOrEmpty(listDetailException)) {
			listDJP.addAll(listDetailException);
		}

		List<Integer> drAnastesiList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_ANESTESI);
		List<Integer> drPatologiAnatomiList = pegawaiDao
				.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI);

		List<Integer> listKelas2Down = splitDataSettingDatafixed("KelasTindakanRemun");
		List<Integer> listTindakanAnastesiException = splitDataSettingDatafixed("excepTindakAnastesi");
		Integer bpjsKelPasienId = Integer.valueOf(settingDataFixedDao.getSettingDataFixed("bpjsRemun"));

		String tarifSatuHarga = settingDataFixedDao.getSettingDataFixed("tarifSatuHarga");
		Boolean isTarifSatuHarga = Boolean.parseBoolean(tarifSatuHarga);

		String departementRawatInap = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRawatInap");
		String departementICU = settingDataFixedDao.getSettingDataFixed("KdInstalasiICU");
		String departementBedahSentral = settingDataFixedDao.getSettingDataFixed("KdInstalasiBedahSentral");
		String departementRawatJalan = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRawatJalan");
		String instalasiGawatDarurat = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiGawatDarurat");
		String instalasiRehabilMedik = settingDataFixedDao
				.getSettingDataFixed("KdDepartemenInstalasiRehabilitasiMedik");
		String instalasiLaboratorium = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiLaboratorium");
		String instalasiRadiologi = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRadiologi");
		String departemenPeristi = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiPeristi");

		List<String> listAllDepartemen = new ArrayList<>();
		listAllDepartemen.add(departementRawatInap);
		listAllDepartemen.add(departementICU);
		listAllDepartemen.add(departementBedahSentral);
		listAllDepartemen.add(departemenPeristi);
		listAllDepartemen.add(departementRawatJalan);
		listAllDepartemen.add(instalasiGawatDarurat);
		listAllDepartemen.add(instalasiRehabilMedik);
		listAllDepartemen.add(instalasiLaboratorium);
		listAllDepartemen.add(instalasiRadiologi);

		List<String> listInapDepartemen = new ArrayList<>();
		listInapDepartemen.add(departementRawatInap);
		listInapDepartemen.add(departementICU);
		listInapDepartemen.add(departementBedahSentral);
		listInapDepartemen.add(departemenPeristi);

		List<String> listJalanDepartemen = new ArrayList<>();
		listJalanDepartemen.add(departementRawatJalan);
		listJalanDepartemen.add(instalasiGawatDarurat);
		listJalanDepartemen.add(instalasiRehabilMedik);
		listJalanDepartemen.add(instalasiLaboratorium);
		listJalanDepartemen.add(instalasiRadiologi);

		tindakans = revIndekKinerjaDao.findIdProdukByIdUser(idPegawai, periode, listDJP);

		for (Map<String, Object> tindakan : tindakans) {
			Map<String, Object> result = new HashMap<String, Object>();
			Double pointQty = 0.0;
			Double percentage = 0.0;
			Double tarif = 0.0;
			Double harga = 0.0;

			if (drAnastesiList.contains(idPegawai)) {
				if (listTindakanAnastesiException.contains(tindakan.get("idProduk"))) {
					percentage = 30.0;
				} else if ((Integer) tindakan.get("idJenisPelaksana") == 4) {
					percentage = 30.0;
				} else {
					percentage = 15.0;
				}
			} else {
				if ((Integer) tindakan.get("idJenisPelaksana") == 13) {
					percentage = 15.0;
				} else {
					percentage = 30.0;
				}
			}
			tarif = 45000.0;

			percentage = percentage / 100;
			if (isTarifSatuHarga) {
				harga = (Double) tindakan.get("hargaKelas1");
				if (CommonUtil.isNullOrEmpty(harga)) {
					harga = (Double) tindakan.get("harga");
				}
			} else {
				harga = (Double) tindakan.get("harga");
			}
			Long count = (long) 0;
			Double point = 0.0;

			if (tarif != 0) {
				point = getPoin(harga, percentage, tarif);
				result.put("poin", point);
			}

			List<Map<String, Object>> datas = revIndeksKinerjaDaoCustom.findAllProdukPerPeriode(idPegawai, periode,
					(Integer) tindakan.get("idProduk"), (Integer) tindakan.get("idKelas"),
					(Integer) tindakan.get("idJenisPelaksana"), listKelas2Down, listAllDepartemen, listInapDepartemen,
					listJalanDepartemen, bpjsKelPasienId, drPatologiAnatomiList);
			result.putAll(tindakan);
			if (CommonUtil.isNotNullOrEmpty(datas)) {
				for (Map<String, Object> data : datas) {
					if (CommonUtil.isNotNullOrEmpty(data.get("count"))) {
						count += (Long) data.get("count");

						if (CommonUtil.isNotNullOrEmpty(data.get("tanggal"))) {
							String tgl = (String) data.get("tanggal");
							tgl = tgl.substring(8, 10);
							result.put(tgl, data.get("count") + "");
						}
					}
				}
			}
			if (CommonUtil.isNotNullOrEmpty(datas)) {
				result.put("datas", datas);
				result.put("totalTindakan", count);
				pointQty = point * count.doubleValue();
				result.put("pointQty", pointQty);
				results.add(result);
			}
		}
		return results;
	}

	@Override
	@Transactional
	public List<Map<String, Object>> getAllTindakanByDokterReport(String periode, Integer idPegawai) {
		List<Map<String, Object>> results = new ArrayList<>();
		Pegawai pgw = pegawaiDao.findOne(idPegawai);
		List<Integer> listDetailException = getDetailProdukAdministrasi(pgw);
		List<Map<String, Object>> tindakans = new ArrayList<>();

		// Check dokter radiologi/klinik/patologi anatom/bukan
		List<Integer> listDJP = new ArrayList<>();
		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabPA");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabKlinik");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukRadiologi");
		} else {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLogbook");
		}

		if (CommonUtil.isNotNullOrEmpty(listDetailException)) {
			listDJP.addAll(listDetailException);
		}

		List<Integer> drAnastesiList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_ANESTESI);
		List<Integer> drPatologiAnatomiList = pegawaiDao
				.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI);

		List<Integer> listKelas2Down = splitDataSettingDatafixed("KelasTindakanRemun");
		List<Integer> listTindakanAnastesiException = splitDataSettingDatafixed("excepTindakAnastesi");
		Integer bpjsKelPasienId = Integer.valueOf(settingDataFixedDao.getSettingDataFixed("bpjsRemun"));

		String tarifSatuHarga = settingDataFixedDao.getSettingDataFixed("tarifSatuHarga");
		Boolean isTarifSatuHarga = Boolean.parseBoolean(tarifSatuHarga);

		String departementRawatInap = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRawatInap");
		String departementICU = settingDataFixedDao.getSettingDataFixed("KdInstalasiICU");
		String departementBedahSentral = settingDataFixedDao.getSettingDataFixed("KdInstalasiBedahSentral");
		String departementRawatJalan = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRawatJalan");
		String instalasiGawatDarurat = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiGawatDarurat");
		String instalasiRehabilMedik = settingDataFixedDao
				.getSettingDataFixed("KdDepartemenInstalasiRehabilitasiMedik");
		String instalasiLaboratorium = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiLaboratorium");
		String instalasiRadiologi = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRadiologi");
		String departemenPeristi = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiPeristi");

		List<String> listAllDepartemen = new ArrayList<>();
		listAllDepartemen.add(departementRawatInap);
		listAllDepartemen.add(departementICU);
		listAllDepartemen.add(departementBedahSentral);
		listAllDepartemen.add(departemenPeristi);
		listAllDepartemen.add(departementRawatJalan);
		listAllDepartemen.add(instalasiGawatDarurat);
		listAllDepartemen.add(instalasiRehabilMedik);
		listAllDepartemen.add(instalasiLaboratorium);
		listAllDepartemen.add(instalasiRadiologi);

		List<String> listInapDepartemen = new ArrayList<>();
		listInapDepartemen.add(departementRawatInap);
		listInapDepartemen.add(departementICU);
		listInapDepartemen.add(departementBedahSentral);
		listInapDepartemen.add(departemenPeristi);

		List<String> listJalanDepartemen = new ArrayList<>();
		listJalanDepartemen.add(departementRawatJalan);
		listJalanDepartemen.add(instalasiGawatDarurat);
		listJalanDepartemen.add(instalasiRehabilMedik);
		listJalanDepartemen.add(instalasiLaboratorium);
		listJalanDepartemen.add(instalasiRadiologi);

		tindakans = revIndekKinerjaDao.findIdProdukByIdUser(idPegawai, periode, listDJP);

		DecimalFormat df = new DecimalFormat("#.##");
		Double totalPoint = 0.0;
		int maxday = monitoringAbsenService.iterateDate(periode + "-01");

		for (Map<String, Object> tindakan : tindakans) {
			Map<String, Object> result = new HashMap<String, Object>();
			Double pointQty = 0.0;
			Double percentage = 0.0;
			Double tarif = 0.0;
			Double harga = 0.0;

			if (drAnastesiList.contains(idPegawai)) {
				if (listTindakanAnastesiException.contains(tindakan.get("idProduk"))) {
					percentage = 30.0;
				} else if ((Integer) tindakan.get("idJenisPelaksana") == 4) {
					percentage = 30.0;
				} else {
					percentage = 15.0;
				}
			} else {
				if ((Integer) tindakan.get("idJenisPelaksana") == 13) {
					percentage = 15.0;
				} else {
					percentage = 30.0;
				}
			}
			tarif = 45000.0;

			percentage = percentage / 100;
			if (isTarifSatuHarga) {
				harga = (Double) tindakan.get("hargaKelas1");
				if (CommonUtil.isNullOrEmpty(harga)) {
					harga = (Double) tindakan.get("harga");
				}
			} else {
				harga = (Double) tindakan.get("harga");
			}
			Long count = (long) 0;
			Double point = 0.0;

			if (tarif != 0) {
				point = getPoin(harga, percentage, tarif);
				result.put("poin", point);
				result.put("poins", df.format(point));
			}

			List<Map<String, Object>> datas = revIndeksKinerjaDaoCustom.findAllProdukPerPeriode(idPegawai, periode,
					(Integer) tindakan.get("idProduk"), (Integer) tindakan.get("idKelas"),
					(Integer) tindakan.get("idJenisPelaksana"), listKelas2Down, listAllDepartemen, listInapDepartemen,
					listJalanDepartemen, bpjsKelPasienId, drPatologiAnatomiList);
			result.put("hargas", CurrencyUtil.getPriceInINA(harga).replace("Rp.", ""));
			result.putAll(tindakan);
			if (CommonUtil.isNotNullOrEmpty(datas)) {
				for (Map<String, Object> data : datas) {
					if (CommonUtil.isNotNullOrEmpty(data.get("count"))) {
						count += (Long) data.get("count");

						if (CommonUtil.isNotNullOrEmpty(data.get("tanggal"))) {
							String tgl = (String) data.get("tanggal");
							tgl = tgl.substring(8, 10);
							result.put(tgl, data.get("count") + "");
						}
					}
				}
			}
			if (CommonUtil.isNotNullOrEmpty(datas)) {
				result.put("datas", datas);
				result.put("totalTindakan", count);
				pointQty = point * count.doubleValue();
				result.put("pointQty", pointQty);
				result.put("pointQtys", df.format(pointQty));
				results.add(result);
			}
			totalPoint += pointQty;
			result.put("totalPoin", totalPoint);
			result.put("totalPoint", df.format(totalPoint));
			result.put("maxDay", maxday);
		}
		return results;
	}

	@Override
	public Map<String, Object> saveMapKalenderToHariLibur(MapKalenderToHariLiburVO vo) {
		Map<String, Object> result = new HashMap<String, Object>();
		if (CommonUtil.isNotNullOrEmpty(vo)) {
			MapKalenderToHariLibur mapKalenderToHariLibur = mapKalenderToHariLiburConverter.transferVOToModel(vo,
					new MapKalenderToHariLibur());
			if (CommonUtil.isNotNullOrEmpty(vo.getTanggal())) {
				Kalender kalender = mapKalenderToHariLiburDao
						.getKalender(new SimpleDateFormat("yyyy-MM-dd").format(vo.getTanggal().getTanggal()));
				mapKalenderToHariLibur.setTgl(kalender);
			}
			if (CommonUtil.isNotNullOrEmpty(mapKalenderToHariLibur)) {
				MapKalenderToHariLibur model = mapKalenderToHariLiburDao.save(mapKalenderToHariLibur);
				result.put("id", model.getId());
			}

		}
		return result;
	}

	@Override
	public List<Map<String, Object>> getAllMapKalenderToHariLibur() {
		List<Map<String, Object>> result = mapKalenderToHariLiburDao.getAllByStatusEnabled();
		for (Map<String, Object> data : result) {
			if (CommonUtil.isNotNullOrEmpty(data.get("tanggal"))) {
				Calendar cal = Calendar.getInstance();
				cal.setTime((Date) data.get("tanggal"));
				int month = cal.get(Calendar.MONTH) + 1;
				data.put("date", +month + "/" + cal.get(Calendar.DATE) + "/" + cal.get(Calendar.YEAR));
			}
		}
		return result;
	}

	@Override
	@Transactional
	public List<Map<String, Object>> getAllTindakanByDokterForfeeForService(String periode, Integer idPegawai) {
		List<Map<String, Object>> results = new ArrayList<>();
		List<Map<String, Object>> tindakans = new ArrayList<>();
		Pegawai pgw = pegawaiDao.findOne(idPegawai);
		Integer kategoryPgw = pgw.getKategoryPegawaiId();
		List<Integer> listDetailException = getDetailProdukAdministrasi(pgw);
		String month = periode.substring(0, 7);

		// Check dokter radiologi/klinik/patologi anatom/bukan
		List<Integer> listDJP = new ArrayList<>();
		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabPA");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabKlinik");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukRadiologi");
		} else {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLogbook");
		}

		if (CommonUtil.isNotNullOrEmpty(listDetailException)) {
			listDJP.addAll(listDetailException);
		}

		List<Integer> drAnastesiList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_ANESTESI);
		List<Integer> drPatologiAnatomiList = pegawaiDao
				.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI);

		List<Integer> listKelas2Down = splitDataSettingDatafixed("KelasTindakanRemun");
		List<Integer> listTindakanAnastesiException = splitDataSettingDatafixed("excepTindakAnastesi");
		List<Integer> listKategoriDokterLuar = splitDataSettingDatafixed("kategoryPegawaiDokterLuar");

		Integer bpjsKelPasienId = Integer.valueOf(settingDataFixedDao.getSettingDataFixed("bpjsRemun"));

		String tarifSatuHarga = settingDataFixedDao.getSettingDataFixed("tarifSatuHarga");
		Boolean isTarifSatuHarga = Boolean.parseBoolean(tarifSatuHarga);

		String departementRawatInap = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRawatInap");
		String departementICU = settingDataFixedDao.getSettingDataFixed("KdInstalasiICU");
		String departementBedahSentral = settingDataFixedDao.getSettingDataFixed("KdInstalasiBedahSentral");
		String departementRawatJalan = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRawatJalan");
		String instalasiGawatDarurat = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiGawatDarurat");
		String instalasiRehabilMedik = settingDataFixedDao
				.getSettingDataFixed("KdDepartemenInstalasiRehabilitasiMedik");
		String instalasiLaboratorium = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiLaboratorium");
		String instalasiRadiologi = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRadiologi");
		String departemenPeristi = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiPeristi");

		List<String> listAllDepartemen = new ArrayList<>();
		listAllDepartemen.add(departementRawatInap);
		listAllDepartemen.add(departementICU);
		listAllDepartemen.add(departementBedahSentral);
		listAllDepartemen.add(departemenPeristi);
		listAllDepartemen.add(departementRawatJalan);
		listAllDepartemen.add(instalasiGawatDarurat);
		listAllDepartemen.add(instalasiRehabilMedik);
		listAllDepartemen.add(instalasiLaboratorium);
		listAllDepartemen.add(instalasiRadiologi);

		List<String> listInapDepartemen = new ArrayList<>();
		listInapDepartemen.add(departementRawatInap);
		listInapDepartemen.add(departementICU);
		listInapDepartemen.add(departementBedahSentral);
		listInapDepartemen.add(departemenPeristi);

		List<String> listJalanDepartemen = new ArrayList<>();
		listJalanDepartemen.add(departementRawatJalan);
		listJalanDepartemen.add(instalasiGawatDarurat);
		listJalanDepartemen.add(instalasiRehabilMedik);
		listJalanDepartemen.add(instalasiLaboratorium);
		listJalanDepartemen.add(instalasiRadiologi);

		if (CommonUtil.isNotNullOrEmpty(periode) && periode.equals(month)) {
			tindakans = revIndekKinerjaDao.findIdProdukByIdUser(idPegawai, periode, listDJP);
		} else {
			tindakans = revIndekKinerjaDao.findIdProdukHarianByIdUser(idPegawai, periode, listDJP);
		}

		for (Map<String, Object> tindakan : tindakans) {
			Map<String, Object> result = new HashMap<String, Object>();
			Double pointQty = 0.0;
			Double percentage = 0.0;
			Double tarif = 0.0;
			Double harga = 0.0;

			if (drAnastesiList.contains(idPegawai)) {
				if (listTindakanAnastesiException.contains(tindakan.get("idProduk"))) {
					percentage = 30.0;
				} else if ((Integer) tindakan.get("idJenisPelaksana") == 4) {
					percentage = 30.0;
				} else {
					percentage = 15.0;
				}
			} else {
				if ((Integer) tindakan.get("idJenisPelaksana") == 13) {
					percentage = 15.0;
				} else {
					percentage = 30.0;
				}
			}
			tarif = 45000.0;

			percentage = percentage / 100;
			if (isTarifSatuHarga) {
				harga = (Double) tindakan.get("hargaKelas1");
				if (CommonUtil.isNullOrEmpty(harga)) {
					harga = (Double) tindakan.get("harga");
				}
			} else {
				harga = (Double) tindakan.get("harga");
			}
			Long count = (long) 0;
			Double point = 0.0;
			if (tarif != 0) {
				point = getPoin(harga, percentage, tarif);
				result.put("poin", point);
			}

			List<Map<String, Object>> datas = new ArrayList<>();
			if (listKategoriDokterLuar.contains(kategoryPgw)) {
				datas = revIndeksKinerjaDaoCustom.findAllProdukDokterLuarPerPeriode(idPegawai, periode,
						(Integer) tindakan.get("idProduk"), (Integer) tindakan.get("idKelas"),
						(Integer) tindakan.get("idJenisPelaksana"), listAllDepartemen);
			} else {
				datas = revIndeksKinerjaDaoCustom.findAllProdukFfsPerPeriode(idPegawai, periode,
						(Integer) tindakan.get("idProduk"), (Integer) tindakan.get("idKelas"),
						(Integer) tindakan.get("idJenisPelaksana"), listKelas2Down, listAllDepartemen,
						listInapDepartemen, listJalanDepartemen, bpjsKelPasienId, drPatologiAnatomiList);
			}

			result.putAll(tindakan);
			if (CommonUtil.isNotNullOrEmpty(datas)) {
				for (Map<String, Object> data : datas) {
					if (CommonUtil.isNotNullOrEmpty(data.get("count"))) {
						count += (Long) data.get("count");
					}
				}
			}

			if (CommonUtil.isNotNullOrEmpty(datas)) {
				result.put("idPegawai", idPegawai);
				result.put("datas", datas);
				result.put("totalTindakan", count);
				pointQty = point * count.doubleValue();
				result.put("pointQty", pointQty);
				results.add(result);
			}

		}
		return results;
	}

	@Override
	public Map<String, Object> getRekapitulasiCapaianUraianTugas(String periode, Integer id) {
		Map<String, Object> result = new HashMap<String, Object>();
		List<Map<String, Object>> listResult = new ArrayList<Map<String, Object>>();
		Double total = 0.0;

		Jabatan jabatan = pegawaiDao.findJabatanInternalByIdPegawai(id);// jabatanFungsional
		Integer idJabatan = 0;
		if (CommonUtil.isNotNullOrEmpty(jabatan)) {
			idJabatan = jabatan.getId();
		}
		List<Integer> idJabtanManajerial = pegawaiDao.findIdJabatanManajerialByIdPegawai(id);// jabatanManajerial
		List<Map<String, Object>> temp = uraianTugasTransaksiDao.findAllUraianTugasByIdJabatan(idJabatan);// getAllUraianKerja
		for (Integer idPegawai : idJabtanManajerial) {
			List<Map<String, Object>> uraianTugasManjerial = uraianTugasTransaksiDao
					.findAllUraianTugasByIdJabatan(idPegawai);
			temp.addAll(uraianTugasManjerial);
		}

		for (Map<String, Object> data : temp) {
			int idRincianKegiatan = (int) data.get("idRincianKegiatan");
			Double hasil = 0.0;
			if (idRincianKegiatan != getIdPelayananPasien()) {
				Map<String, Object> dataMaster = uraianTugasTransaksiDao.findUraianTugas(id, idRincianKegiatan,
						periode);
				int maxday = monitoringAbsenService.iterateDate(periode + "-01");
				for (int i = 1; i <= maxday; i++) {
					String date = "";
					if (i < 10) {
						date = periode + "-0" + i;
					} else {
						date = periode + "-" + i;
					}
					Double capaian = uraianTugasTransaksiDao.findCapaianByTanggal(id, idRincianKegiatan, date);
					if (CommonUtil.isNotNullOrEmpty(capaian)) {
						data.put(i + "", capaian);
					} else {
						data.put(i + "", 0);
					}
				}
				Double subtotal = 0.0;
				Double target = 0.0;
				Double bobot = 0.0;
				Double nilai = 0.0;

				if (CommonUtil.isNotNullOrEmpty(dataMaster)) {
					if (CommonUtil.isNotNullOrEmpty(dataMaster.get("total"))) {
						subtotal = (Double) dataMaster.get("total");
					}
					data.put("total", subtotal);
					if (CommonUtil.isNotNullOrEmpty(dataMaster.get("target"))) {
						target = (Double) dataMaster.get("target");
					}
					data.put("target", target);
					if (CommonUtil.isNotNullOrEmpty(dataMaster.get("bobot"))) {
						bobot = (Double) dataMaster.get("bobot");
					}
				}
				data.put("bobot", bobot);
				if (target != 0.0) {
					nilai = getNilai(subtotal, target);
				}
				data.put("nilai", nilai);
				hasil = getHasil(nilai, bobot);
				data.put("hasil", hasil);
				data.put("periode", periode);
				total += hasil;
				listResult.add(data);
			}
		}
		result.put("uraianTugas", listResult);
		result.put("totalKuantitas", total);
		return result;
	}

	@Override
	public List<Map<String, Object>> reportrekapitulasi(Integer idPegawai, String periode, Boolean isFFS) {
		List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
		if (isFFS) {
			result = getAllTindakanByDokterForfeeForServiceReportReview(periode, idPegawai);
		} else {
			result = getAllTindakanByDokterReport2Review(periode, idPegawai);
		}

		return result;
	}

	@Override
	public List<Map<String, Object>> getAllTindakanByDokterReport2(String periode, Integer idPegawai) {
		List<Map<String, Object>> results = new ArrayList<>();
		Pegawai pgw = pegawaiDao.findOne(idPegawai);
		List<Integer> listDetailException = getDetailProdukAdministrasi(pgw);
		List<Map<String, Object>> tindakans = new ArrayList<>();

		// Check dokter radiologi/klinik/patologi anatom/bukan
		List<Integer> listDJP = new ArrayList<>();
		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabPA");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabKlinik");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukRadiologi");
		} else {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLogbook");
		}

		if (CommonUtil.isNotNullOrEmpty(listDetailException)) {
			listDJP.addAll(listDetailException);
		}

		List<Integer> drAnastesiList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_ANESTESI);
		List<Integer> drPatologiAnatomiList = pegawaiDao
				.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI);

		List<Integer> listKelas2Down = splitDataSettingDatafixed("KelasTindakanRemun");
		List<Integer> listTindakanAnastesiException = splitDataSettingDatafixed("excepTindakAnastesi");
		Integer bpjsKelPasienId = Integer.valueOf(settingDataFixedDao.getSettingDataFixed("bpjsRemun"));

		String tarifSatuHarga = settingDataFixedDao.getSettingDataFixed("tarifSatuHarga");
		Boolean isTarifSatuHarga = Boolean.parseBoolean(tarifSatuHarga);

		String departementRawatInap = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRawatInap");
		String departementICU = settingDataFixedDao.getSettingDataFixed("KdInstalasiICU");
		String departementBedahSentral = settingDataFixedDao.getSettingDataFixed("KdInstalasiBedahSentral");
		String departementRawatJalan = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRawatJalan");
		String instalasiGawatDarurat = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiGawatDarurat");
		String instalasiRehabilMedik = settingDataFixedDao
				.getSettingDataFixed("KdDepartemenInstalasiRehabilitasiMedik");
		String instalasiLaboratorium = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiLaboratorium");
		String instalasiRadiologi = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRadiologi");
		String departemenPeristi = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiPeristi");

		List<String> listAllDepartemen = new ArrayList<>();
		listAllDepartemen.add(departementRawatInap);
		listAllDepartemen.add(departementICU);
		listAllDepartemen.add(departementBedahSentral);
		listAllDepartemen.add(departemenPeristi);
		listAllDepartemen.add(departementRawatJalan);
		listAllDepartemen.add(instalasiGawatDarurat);
		listAllDepartemen.add(instalasiRehabilMedik);
		listAllDepartemen.add(instalasiLaboratorium);
		listAllDepartemen.add(instalasiRadiologi);

		List<String> listInapDepartemen = new ArrayList<>();
		listInapDepartemen.add(departementRawatInap);
		listInapDepartemen.add(departementICU);
		listInapDepartemen.add(departementBedahSentral);
		listInapDepartemen.add(departemenPeristi);

		List<String> listJalanDepartemen = new ArrayList<>();
		listJalanDepartemen.add(departementRawatJalan);
		listJalanDepartemen.add(instalasiGawatDarurat);
		listJalanDepartemen.add(instalasiRehabilMedik);
		listJalanDepartemen.add(instalasiLaboratorium);
		listJalanDepartemen.add(instalasiRadiologi);

		tindakans = revIndekKinerjaDao.findIdProdukByIdUser(idPegawai, periode, listDJP);

		for (Map<String, Object> tindakan : tindakans) {
			Map<String, Object> result = new HashMap<String, Object>();
			Double percentage = 0.0;
			Double tarif = 0.0;
			Double harga = 0.0;

			if (drAnastesiList.contains(idPegawai)) {
				if (listTindakanAnastesiException.contains(tindakan.get("idProduk"))) {
					percentage = 30.0;
				} else if ((Integer) tindakan.get("idJenisPelaksana") == 4) {
					percentage = 30.0;
				} else {
					percentage = 15.0;
				}
			} else {
				if ((Integer) tindakan.get("idJenisPelaksana") == 13) {
					percentage = 15.0;
				} else {
					percentage = 30.0;
				}
			}
			tarif = 45000.0;

			percentage = percentage / 100;
			if (isTarifSatuHarga) {
				harga = (Double) tindakan.get("hargaKelas1");
				if (CommonUtil.isNullOrEmpty(harga)) {
					harga = (Double) tindakan.get("harga");
				}
			} else {
				harga = (Double) tindakan.get("harga");
			}
			Long count = (long) 0;
			Double point = 0.0;
			if (tarif != 0) {
				point = getPoin(harga, percentage, tarif);
				result.put("poin", point);
			}

			List<Map<String, Object>> datas = revIndeksKinerjaDaoCustom.findAllProdukPerPeriode(idPegawai, periode,
					(Integer) tindakan.get("idProduk"), (Integer) tindakan.get("idKelas"),
					(Integer) tindakan.get("idJenisPelaksana"), listKelas2Down, listAllDepartemen, listInapDepartemen,
					listJalanDepartemen, bpjsKelPasienId, drPatologiAnatomiList);
			result.putAll(tindakan);

			if (CommonUtil.isNotNullOrEmpty(datas)) {
				for (Map<String, Object> data : datas) {
					Map<String, Object> tmp = new HashMap<String, Object>();
					tmp.putAll(tindakan);
					tmp.put("count", data.get("count"));
					tmp.put("tglPelayanan", data.get("tanggal"));
					count += (Long) data.get("count");
					if (CommonUtil.isNotNullOrEmpty(data.get("count"))) {
						results.add(tmp);
					}
				}
			}

		}

		return results;
	}

	@Override
	public List<Map<String, Object>> getAllTindakanByDokterForfeeForServiceReport(String periode, Integer idPegawai) {
		List<Map<String, Object>> results = new ArrayList<>();
		Pegawai pgw = pegawaiDao.findOne(idPegawai);
		Integer kategoryPgw = pgw.getKategoryPegawaiId();
		List<Integer> listDetailException = getDetailProdukAdministrasi(pgw);
		List<Map<String, Object>> tindakans = new ArrayList<>();

		// Check dokter radiologi/klinik/patologi anatom/bukan
		List<Integer> listDJP = new ArrayList<>();
		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabPA");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabKlinik");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukRadiologi");
		} else {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLogbook");
		}

		if (CommonUtil.isNotNullOrEmpty(listDetailException)) {
			listDJP.addAll(listDetailException);
		}

		List<Integer> drAnastesiList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_ANESTESI);
		List<Integer> drPatologiAnatomiList = pegawaiDao
				.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI);

		List<Integer> listKelas2Down = splitDataSettingDatafixed("KelasTindakanRemun");
		List<Integer> listTindakanAnastesiException = splitDataSettingDatafixed("excepTindakAnastesi");
		List<Integer> listKategoriDokterLuar = splitDataSettingDatafixed("kategoryPegawaiDokterLuar");
		Integer bpjsKelPasienId = Integer.valueOf(settingDataFixedDao.getSettingDataFixed("bpjsRemun"));

		String tarifSatuHarga = settingDataFixedDao.getSettingDataFixed("tarifSatuHarga");
		Boolean isTarifSatuHarga = Boolean.parseBoolean(tarifSatuHarga);

		String departementRawatInap = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRawatInap");
		String departementICU = settingDataFixedDao.getSettingDataFixed("KdInstalasiICU");
		String departementBedahSentral = settingDataFixedDao.getSettingDataFixed("KdInstalasiBedahSentral");
		String departementRawatJalan = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRawatJalan");
		String instalasiGawatDarurat = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiGawatDarurat");
		String instalasiRehabilMedik = settingDataFixedDao
				.getSettingDataFixed("KdDepartemenInstalasiRehabilitasiMedik");
		String instalasiLaboratorium = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiLaboratorium");
		String instalasiRadiologi = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRadiologi");
		String departemenPeristi = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiPeristi");

		List<String> listAllDepartemen = new ArrayList<>();
		listAllDepartemen.add(departementRawatInap);
		listAllDepartemen.add(departementICU);
		listAllDepartemen.add(departementBedahSentral);
		listAllDepartemen.add(departemenPeristi);
		listAllDepartemen.add(departementRawatJalan);
		listAllDepartemen.add(instalasiGawatDarurat);
		listAllDepartemen.add(instalasiRehabilMedik);
		listAllDepartemen.add(instalasiLaboratorium);
		listAllDepartemen.add(instalasiRadiologi);

		List<String> listInapDepartemen = new ArrayList<>();
		listInapDepartemen.add(departementRawatInap);
		listInapDepartemen.add(departementICU);
		listInapDepartemen.add(departementBedahSentral);
		listInapDepartemen.add(departemenPeristi);

		List<String> listJalanDepartemen = new ArrayList<>();
		listJalanDepartemen.add(departementRawatJalan);
		listJalanDepartemen.add(instalasiGawatDarurat);
		listJalanDepartemen.add(instalasiRehabilMedik);
		listJalanDepartemen.add(instalasiLaboratorium);
		listJalanDepartemen.add(instalasiRadiologi);

		tindakans = revIndekKinerjaDao.findIdProdukByIdUser(idPegawai, periode, listDJP);

		for (Map<String, Object> tindakan : tindakans) {
			Map<String, Object> result = new HashMap<String, Object>();
			Double percentage = 0.0;
			Double tarif = 0.0;
			Double harga = 0.0;

			if (drAnastesiList.contains(idPegawai)) {
				if (listTindakanAnastesiException.contains(tindakan.get("idProduk"))) {
					percentage = 30.0;
				} else if ((Integer) tindakan.get("idJenisPelaksana") == 4) {
					percentage = 30.0;
				} else {
					percentage = 15.0;
				}
			} else {
				if ((Integer) tindakan.get("idJenisPelaksana") == 13) {
					percentage = 15.0;
				} else {
					percentage = 30.0;
				}
			}
			tarif = 45000.0;

			percentage = percentage / 100;
			if (isTarifSatuHarga) {
				harga = (Double) tindakan.get("hargaKelas1");
				if (CommonUtil.isNullOrEmpty(harga)) {
					harga = (Double) tindakan.get("harga");
				}
			} else {
				harga = (Double) tindakan.get("harga");
			}
			Long count = (long) 0;
			Double point = 0.0;
			if (tarif != 0) {
				point = getPoin(harga, percentage, tarif);
				result.put("poin", point);
			}

			List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
			if (listKategoriDokterLuar.contains(kategoryPgw)) {
				datas = revIndeksKinerjaDaoCustom.findAllProdukDokterLuarPerPeriode(idPegawai, periode,
						(Integer) tindakan.get("idProduk"), (Integer) tindakan.get("idKelas"),
						(Integer) tindakan.get("idJenisPelaksana"), listAllDepartemen);
			} else {
				datas = revIndeksKinerjaDaoCustom.findAllProdukFfsPerPeriode(idPegawai, periode,
						(Integer) tindakan.get("idProduk"), (Integer) tindakan.get("idKelas"),
						(Integer) tindakan.get("idJenisPelaksana"), listKelas2Down, listAllDepartemen,
						listInapDepartemen, listJalanDepartemen, bpjsKelPasienId, drPatologiAnatomiList);
			}
			result.putAll(tindakan);

			result.putAll(tindakan);
			if (CommonUtil.isNotNullOrEmpty(datas)) {
				for (Map<String, Object> data : datas) {
					Map<String, Object> tmp = new HashMap<String, Object>();

					tmp.putAll(tindakan);
					tmp.put("count", data.get("count"));
					tmp.put("tglPelayanan", data.get("tanggal"));
					if (CommonUtil.isNotNullOrEmpty(data.get("count"))) {
						count += (Long) data.get("count");
						results.add(tmp);
					}
				}
			}

		}

		return results;
	}

	@Override
	public List<Map<String, Object>> getAllTindakanRekapReportRev(String periode, Integer idPegawai) {
		List<Map<String, Object>> results = new ArrayList<>();
		Pegawai pgw = pegawaiDao.findOne(idPegawai);
		Integer kategoryPgw = pgw.getKategoryPegawaiId();

		List<Integer> listDetailException = getDetailProdukAdministrasi(pgw);
		List<Map<String, Object>> tindakans = new ArrayList<>();

		// Check dokter radiologi/klinik/patologi anatom/bukan
		List<Integer> listDJP = new ArrayList<>();
		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabPA");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabKlinik");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukRadiologi");
		} else {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLogbook");
		}

		if (CommonUtil.isNotNullOrEmpty(listDetailException)) {
			listDJP.addAll(listDetailException);
		}

		List<Integer> drAnastesiList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_ANESTESI);
		List<Integer> drPatologiAnatomiList = pegawaiDao
				.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI);

		List<Integer> listKelas2Down = splitDataSettingDatafixed("KelasTindakanRemun");
		List<Integer> listTindakanAnastesiException = splitDataSettingDatafixed("excepTindakAnastesi");
		List<Integer> listKategoriDokterLuar = splitDataSettingDatafixed("kategoryPegawaiDokterLuar");
		Integer bpjsKelPasienId = Integer.valueOf(settingDataFixedDao.getSettingDataFixed("bpjsRemun"));

		String departementRawatInap = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRawatInap");
		String departementICU = settingDataFixedDao.getSettingDataFixed("KdInstalasiICU");
		String departementBedahSentral = settingDataFixedDao.getSettingDataFixed("KdInstalasiBedahSentral");
		String departementRawatJalan = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRawatJalan");
		String instalasiGawatDarurat = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiGawatDarurat");
		String instalasiRehabilMedik = settingDataFixedDao
				.getSettingDataFixed("KdDepartemenInstalasiRehabilitasiMedik");
		String instalasiLaboratorium = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiLaboratorium");
		String instalasiRadiologi = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRadiologi");
		String departemenPeristi = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiPeristi");

		List<String> listAllDepartemen = new ArrayList<>();
		listAllDepartemen.add(departementRawatInap);
		listAllDepartemen.add(departementICU);
		listAllDepartemen.add(departementBedahSentral);
		listAllDepartemen.add(departemenPeristi);
		listAllDepartemen.add(departementRawatJalan);
		listAllDepartemen.add(instalasiGawatDarurat);
		listAllDepartemen.add(instalasiRehabilMedik);
		listAllDepartemen.add(instalasiLaboratorium);
		listAllDepartemen.add(instalasiRadiologi);

		List<String> listInapDepartemen = new ArrayList<>();
		listInapDepartemen.add(departementRawatInap);
		listInapDepartemen.add(departementICU);
		listInapDepartemen.add(departementBedahSentral);
		listInapDepartemen.add(departemenPeristi);

		List<String> listJalanDepartemen = new ArrayList<>();
		listJalanDepartemen.add(departementRawatJalan);
		listJalanDepartemen.add(instalasiGawatDarurat);
		listJalanDepartemen.add(instalasiRehabilMedik);
		listJalanDepartemen.add(instalasiLaboratorium);
		listJalanDepartemen.add(instalasiRadiologi);

		tindakans = revIndekKinerjaDao.findIdProdukByIdUser(idPegawai, periode, listDJP);

		for (Map<String, Object> tindakan : tindakans) {
			Map<String, Object> result = new HashMap<String, Object>();
			Double percentage = 0.0;
			Double tarif = 0.0;
			Double harga = 0.0;
			Long count = (long) 0;
			Long countRemun = (long) 0;
			Long countFfs = (long) 0;
			Double point = 0.0;
			tarif = 45000.0;

			Long remun = revIndeksKinerjaDaoCustom.countAllProdukPerPeriode(idPegawai, periode,
					(Integer) tindakan.get("idProduk"), (Integer) tindakan.get("idKelas"),
					(Integer) tindakan.get("idJenisPelaksana"), listKelas2Down, listAllDepartemen, listInapDepartemen,
					listJalanDepartemen, bpjsKelPasienId, drPatologiAnatomiList);
			if (CommonUtil.isNullOrEmpty(remun)) {
				remun = 0L;
			}

			Long ffs = 0L;
			if (listKategoriDokterLuar.contains(kategoryPgw)) {
				ffs = revIndeksKinerjaDaoCustom.countAllProdukDokterLuarPerPeriode(idPegawai, periode,
						(Integer) tindakan.get("idProduk"), (Integer) tindakan.get("idKelas"),
						(Integer) tindakan.get("idJenisPelaksana"), listAllDepartemen);
			} else {
				ffs = revIndeksKinerjaDaoCustom.countAllProdukFfsPerPeriode(idPegawai, periode,
						(Integer) tindakan.get("idProduk"), (Integer) tindakan.get("idKelas"),
						(Integer) tindakan.get("idJenisPelaksana"), listKelas2Down, listAllDepartemen,
						listInapDepartemen, listJalanDepartemen, bpjsKelPasienId, drPatologiAnatomiList);
			}
			if (CommonUtil.isNullOrEmpty(ffs)) {
				ffs = 0L;
			}

			result.putAll(tindakan);

			if (drAnastesiList.contains(idPegawai)) {
				if (listTindakanAnastesiException.contains(tindakan.get("idProduk"))) {
					percentage = 30.0;
				} else if ((Integer) tindakan.get("idJenisPelaksana") == 4) {
					percentage = 30.0;
				} else {
					percentage = 15.0;
				}
			} else {
				if ((Integer) tindakan.get("idJenisPelaksana") == 13) {
					percentage = 15.0;
				} else {
					percentage = 30.0;
				}
			}

			percentage = percentage / 100;
			harga = (Double) tindakan.get("harga");

			if (tarif != 0) {
				point = getPoin(harga, percentage, tarif);
				result.put("poin", point);
			}

			Map<String, Object> tmp = new HashMap<String, Object>();
			if (CommonUtil.isNotNullOrEmpty(remun) || CommonUtil.isNotNullOrEmpty(ffs)) {
				if (CommonUtil.isNotNullOrEmpty(remun)) {
					tmp.put("remun", remun);
				} else {
					tmp.put("remun", 0);
				}
				if (CommonUtil.isNotNullOrEmpty(tmp.get("remun"))) {
					countRemun += (Long) tmp.get("remun");
				}
				if (CommonUtil.isNotNullOrEmpty(ffs)) {
					tmp.put("ffs", ffs);
				} else {
					tmp.put("ffs", 0);
				}
				if (CommonUtil.isNotNullOrEmpty(tmp.get("ffs"))) {
					countFfs += (Long) tmp.get("ffs");
				}
				tmp.putAll(tindakan);
				tmp.put("count", (ffs + remun));
				if (CommonUtil.isNotNullOrEmpty(tmp.get("count"))) {
					count += (Long) tmp.get("count");
				}
				results.add(tmp);
			}

		}

		Collections.sort(results, new Comparator<Map<String, Object>>() {
			public int compare(final Map<String, Object> o1, final Map<String, Object> o2) {
				// ascending order
				return ((String) o1.get("namaProduk")).compareTo((String) o2.get("namaProduk"));
			}
		});
		return results;

	}

	@Override
	public List<Map<String, Object>> getAllTindakanRekapReport(String periode, Integer idPegawai) {
		List<Map<String, Object>> results = new ArrayList<>();
		Pegawai pgw = pegawaiDao.findOne(idPegawai);

		List<Integer> listDetailException = getDetailProdukAdministrasi(pgw);
		List<Map<String, Object>> tindakans = new ArrayList<>();

		// check dokter patologi anatomi, lab klinik, radiologi, atw yg lain
		List<Integer> listDJP = new ArrayList<>();
		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabPA");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLabKlinik");
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(idPegawai)) {
			listDJP = splitDataSettingDatafixed("detailJenisProdukRadiologi");
		} else {
			listDJP = splitDataSettingDatafixed("detailJenisProdukLogbook");
		}

		if (CommonUtil.isNotNullOrEmpty(listDetailException)) {
			listDJP.addAll(listDetailException);
		}

		String tarifSatuHarga = settingDataFixedDao.getSettingDataFixed("tarifSatuHarga");
		Boolean isTarifSatuHarga = Boolean.parseBoolean(tarifSatuHarga);

		List<Integer> drAnastesiList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_ANESTESI);
		List<Integer> listTindakanAnastesiException = splitDataSettingDatafixed("excepTindakAnastesi");

		tindakans = revIndekKinerjaDao.findIdProdukByIdUser(idPegawai, periode, listDJP);

		List<String> listFriday = indeksKinerjaDaoCustom.convertMonthtoDateCustom(periode, true);
		List<String> listSK = indeksKinerjaDaoCustom.convertMonthtoDateCustom(periode, false);
		for (Map<String, Object> tindakan : tindakans) {
			Map<String, Object> result = new HashMap<String, Object>();
			Double percentage = 0.0;
			Double tarif = 0.0;
			Double harga = 0.0;

			if (drAnastesiList.contains(idPegawai)) {
				if (listTindakanAnastesiException.contains(tindakan.get("idProduk"))) {
					percentage = 30.0;
				} else if ((Integer) tindakan.get("idJenisPelaksana") == 4) {
					percentage = 30.0;
				} else {
					percentage = 15.0;
				}
			} else {
				if ((Integer) tindakan.get("idJenisPelaksana") == 13) {
					percentage = 15.0;
				} else {
					percentage = 30.0;
				}
			}
			tarif = 45000.0;

			percentage = percentage / 100;
			if (isTarifSatuHarga) {
				harga = (Double) tindakan.get("hargaKelas1");
				if (CommonUtil.isNullOrEmpty(harga)) {
					harga = (Double) tindakan.get("harga");
				}
			} else {
				harga = (Double) tindakan.get("harga");
			}

			Long count = (long) 0;
			Double point = 0.0;
			if (tarif != 0) {
				point = getPoin(harga, percentage, tarif);
				result.put("poin", point);
			}

			List<String> listRanap = indeksKinerjaDaoCustom.convertMonthtoDateCustom(periode, null);

			Long remun = revIndeksKinerjaDaoCustom.countAllProdukPerPeriode(idPegawai, periode, false,
					(Integer) tindakan.get("idProduk"), (Integer) tindakan.get("idKelas"), listFriday, listSK,
					listRanap);

			if (CommonUtil.isNullOrEmpty(remun)) {
				remun = 0L;
			}

			listRanap = indeksKinerjaDaoCustom.convertMonthtoDateCustomFeeForService(periode, false);

			Long ffs = revIndeksKinerjaDaoCustom.countAllProdukPerPeriode(idPegawai, periode, true,
					(Integer) tindakan.get("idProduk"), (Integer) tindakan.get("idKelas"), listFriday, listSK,
					listRanap);

			if (CommonUtil.isNullOrEmpty(ffs)) {
				ffs = 0L;
			}

			result.putAll(tindakan);

			Map<String, Object> tmp = new HashMap<String, Object>();
			if (CommonUtil.isNotNullOrEmpty(remun) || CommonUtil.isNotNullOrEmpty(ffs)) {
				if (CommonUtil.isNotNullOrEmpty(remun)) {
					tmp.put("remun", remun);
				} else {
					tmp.put("remun", 0);
				}
				if (CommonUtil.isNotNullOrEmpty(ffs)) {
					tmp.put("ffs", ffs);
				} else {
					tmp.put("ffs", 0);
				}
				tmp.putAll(tindakan);
				tmp.put("count", (ffs + remun));
				if (CommonUtil.isNotNullOrEmpty(tmp.get("count"))) {
					count += (Long) tmp.get("count");
				}
				results.add(tmp);
			}

		}

		Collections.sort(results, new Comparator<Map<String, Object>>() {
			public int compare(final Map<String, Object> o1, final Map<String, Object> o2) {
				// ascending order
				return ((String) o1.get("namaProduk")).compareTo((String) o2.get("namaProduk"));
			}
		});
		return results;
	}

	@Override
	public List<Map<String, Object>> getAllTindakanRekapReportWithPasien(String periode, Integer idPegawai) {
		List<Map<String, Object>> results = new ArrayList<>();
		Pegawai pgw = pegawaiDao.findOne(idPegawai);
		List<Integer> listDetailException = getDetailProdukAdministrasi(pgw);
		List<Map<String, Object>> tindakans = new ArrayList<>();
		String tarifSatuHarga = settingDataFixedDao.getSettingDataFixed("tarifSatuHarga");
		Boolean isTarifSatuHarga = Boolean.parseBoolean(tarifSatuHarga);

		List<Integer> drAnastesiList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_ANESTESI);
		List<Integer> listTindakanAnastesiException = splitDataSettingDatafixed("excepTindakAnastesi");

		Date start = DateUtil.startMonth(periode);
		Date end = DateUtil.endMonth(periode);

		if (CommonUtil.isNullOrEmpty(listDetailException)) {
			tindakans = indekKinerjaDao.findIdProdukByIdUser(idPegawai, start, end, splitIdProdukAdministrasi());
		} else {
			tindakans = indekKinerjaDao.findIdProdukByIdUserWithDetailException(idPegawai, start, end,
					splitIdProdukAdministrasi(), listDetailException);
		}

		for (Map<String, Object> tindakan : tindakans) {
			Map<String, Object> result = new HashMap<String, Object>();
			Double percentage = 0.0;
			Double tarif = 0.0;
			Double harga = 0.0;

			if (drAnastesiList.contains(idPegawai)) {
				if (listTindakanAnastesiException.contains(tindakan.get("idProduk"))) {
					percentage = 30.0;
				} else if ((Integer) tindakan.get("idJenisPelaksana") == 4) {
					percentage = 30.0;
				} else {
					percentage = 15.0;
				}
			} else {
				if ((Integer) tindakan.get("idJenisPelaksana") == 13) {
					percentage = 15.0;
				} else {
					percentage = 30.0;
				}
			}
			tarif = 45000.0;

			percentage = percentage / 100;

			if (isTarifSatuHarga) {
				harga = (Double) tindakan.get("hargaKelas1");
				if (CommonUtil.isNullOrEmpty(harga)) {
					harga = (Double) tindakan.get("harga");
				}
			} else {
				harga = (Double) tindakan.get("harga");
			}
			Long count = (long) 0;
			Double point = 0.0;
			if (tarif != 0) {
				point = getPoin(harga, percentage, tarif);
				result.put("poin", point);
			}
			List<String> listFriday = indeksKinerjaDaoCustom.convertMonthtoDateCustom(periode, true);
			List<String> listSK = indeksKinerjaDaoCustom.convertMonthtoDateCustom(periode, false);
			List<String> listRanap = indeksKinerjaDaoCustom.convertMonthtoDateCustom(periode, null);

			Long remun = (long) indeksKinerjaDaoCustom.findAllProdukPerPeriodeRekap(idPegawai, periode,
					splitIdProdukAdministrasi(), false, (Integer) tindakan.get("idProduk"),
					(Double) tindakan.get("harga"), listFriday, listSK, listRanap, listDetailException);

			Long ffs = (long) indeksKinerjaDaoCustom.findAllProdukPerPeriodeFeeForServicesReport(idPegawai, periode,
					splitIdProdukAdministrasi(), false, (Integer) tindakan.get("idProduk"),
					(Double) tindakan.get("harga"), false, listDetailException);

			result.putAll(tindakan);

			Map<String, Object> tmp = new HashMap<String, Object>();
			if (CommonUtil.isNotNullOrEmpty(remun) || CommonUtil.isNotNullOrEmpty(ffs)) {
				if (CommonUtil.isNotNullOrEmpty(remun)) {
					tmp.put("remun", remun);
				} else {
					tmp.put("remun", 0);
				}
				if (CommonUtil.isNotNullOrEmpty(ffs)) {
					tmp.put("ffs", ffs);
				} else {
					tmp.put("ffs", 0);
				}
				tmp.putAll(tindakan);
				tmp.put("count", (Long) (ffs + remun));
				if (CommonUtil.isNotNullOrEmpty(tmp.get("count"))) {
					count += (Long) tmp.get("count");
				}
				results.add(tmp);
			}

		}

		Collections.sort(results, new Comparator<Map<String, Object>>() {
			public int compare(final Map<String, Object> o1, final Map<String, Object> o2) {
				// ascending order
				return ((String) o1.get("namaProduk")).compareTo((String) o2.get("namaProduk"));
			}
		});
		return results;
	}

	public Date batasAkhirTarifLama() {
		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
		try {
			return dateFormat.parse(GetSettingDataFixed("batasAkhirTarif2017"));
		} catch (ParseException e) {
			e.printStackTrace();

			return null;
		}
	}

	@Override
	public List<Map<String, Object>> getAllTindakanByDokterReview(String periode, Integer idPegawai,
			Integer idAlternatif) {
		if (pegawaiDao.getPegawaiByKategoryPegawai(Arrays.asList(Master.KategoryPegawai.DOKTER_LUAR))
				.contains(idPegawai)) {
			return new ArrayList<>();
		}

		List<Map<String, Object>> result = new ArrayList<>();
		List<Map<String, Object>> rawResult = new ArrayList<>();
		List<Map<String, Object>> countResult = new ArrayList<>();

		List<Integer> listProdukId = new ArrayList<>();
		List<Integer> listKelasId = new ArrayList<>();
		List<Integer> listPelaksanaId = new ArrayList<>();
		List<Integer> listDetailJenisProduk = new ArrayList<>();
		List<Integer> listDetailJenisProdukException = new ArrayList<>();
		List<String> listTanggalPelayanan = new ArrayList<>();

		Double harga = 0.0;
		Double point = 0.0;
		Double pointQty = 0.0;
		Double formatPointQty = 0.0;
		Double formatRpKontribusi = 0.0;
		Double percentage = 0.0;

		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
		Date datePeriode = new Date();
		try {
			datePeriode = dateFormat.parse(periode);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		Date dateAkhirTarifLama = batasAkhirTarifLama();
		boolean isSatuTarif = false;

		DecimalFormat df = new DecimalFormat("#.##");
		DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

		LocalDateTime PSBBDate = LocalDateTime.of(2020, 9, 14, 0, 0, 0);
		LocalDateTime PSBBEnd = LocalDateTime.parse(GetSettingDataFixed("psbbperiod"), dtf);

		List<Integer> drAnastesiList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_ANESTESI);
		List<Integer> drKsmUmumList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_UMUM);
		List<Integer> drKkPediatrikGDList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PEDIATRIK_GD);
		List<Integer> drKkPerinatologiList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PERINATOLOGI);
		List<Integer> laboranRadiologList = mapPegawaiLaboratRadiologiDao.findPegawaiLaboranRadiolog();

		List<Integer> idsRegDJPAdminNonPK = splitDataSettingDatafixed("admin_nonpk");
		List<Integer> idsRegDJPMedisUtama = splitDataSettingDatafixed("medis_utama");
		List<Integer> idsRegDJPPenunjangPA = splitDataSettingDatafixed("penunjang_pa");
		List<Integer> idsRegDJPPenunjangPK = splitDataSettingDatafixed("penunjang_pk");
		List<Integer> idsRegDJPPenunjangRad = splitDataSettingDatafixed("penunjang_radiologi");

		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPA;
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPK;
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangRad;
		} else {
			listDetailJenisProduk = idsRegDJPMedisUtama;
		}

		if (laboranRadiologList.contains(idPegawai)) {
			listDetailJenisProdukException = idsRegDJPAdminNonPK;
			listDetailJenisProdukException.removeAll(listDetailJenisProduk);
		}

		List<Map<String, Object>> listData = revIndekKinerjaDao.getAllTindakanDokter(Master.Kelas.KELAS_SATU, idPegawai,
				Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA, periode);

		List<Integer> idsDokterUmumIGD = splitDataSettingDatafixed("pr_dokter_umum_igd");
		List<Integer> idsDokterPediatrikGD = splitDataSettingDatafixed("pr_dokter_pediatrik_gd");
		List<Integer> idsDokterPerinatologi = splitDataSettingDatafixed("pr_dokter_perinatologi");
		List<Integer> idsPenunjangBukanAnestesi = splitDataSettingDatafixed("pr_penunjang_nonanestesi");
		Double komponenDasar = Double.parseDouble(GetSettingDataFixed("ld_komponen_dasar"));
		Double persenOperator = Double.parseDouble(GetSettingDataFixed("ld_persen_operator"));
		Double persenCooperator = Double.parseDouble(GetSettingDataFixed("ld_persen_cooperator"));
		if (datePeriode.before(dateAkhirTarifLama) || datePeriode.equals(dateAkhirTarifLama)) {
			komponenDasar = 45_000.0;
			persenOperator = 30.0;
			persenCooperator = 15.0;
			isSatuTarif = true;
		} else if (idAlternatif == 1 && datePeriode.after(dateAkhirTarifLama)) {
			komponenDasar = 120_000.0;
			persenOperator = 60.0;
			persenCooperator = 30.0;
		} else if (idAlternatif == 2 && datePeriode.after(dateAkhirTarifLama)) {
			komponenDasar = 210_000.0;
			persenOperator = 70.0;
			persenCooperator = 35.0;
		} else if (idAlternatif == 3 && datePeriode.after(dateAkhirTarifLama)) {
			komponenDasar = 120_000.0;
			persenOperator = 40.0;
			persenCooperator = 20.0;
		} else if (idAlternatif == 4 && datePeriode.after(dateAkhirTarifLama)) {
			komponenDasar = 210_000.0;
			persenOperator = 40.0;
			persenCooperator = 20.0;
		} else if (idAlternatif == 5 && datePeriode.after(dateAkhirTarifLama)) {
			komponenDasar = 80_000.0;
			persenOperator = 40.0;
			persenCooperator = 20.0;
		} else if (idAlternatif == 6 && datePeriode.after(dateAkhirTarifLama)) {
			komponenDasar = 120_000.0;
			persenOperator = 50.0;
			persenCooperator = 25.0;
		}

		// LOGIC_RULES_REMUN
		if (CommonUtil.isNotNullOrEmpty(listData)) {
			for (Map<String, Object> map : listData) {
				if (drKkPediatrikGDList.contains(map.get("idPegawai"))) {
					if (idsDokterPediatrikGD.contains(map.get("idProduk"))) {
						rawResult.add(map);
					} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
						Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
						String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
						String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
						LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
						LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
						LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

						String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
								+ map.get("jamMasuk").toString().substring(3) + ":00";
						LocalTime timeMasuk = LocalTime.parse(jamMasuk);
						LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

						String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
								+ map.get("jamPulang").toString().substring(3) + ":00";
						LocalTime timePulang = LocalTime.parse(jamPulang);
						LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

						if (map.get("namaShift").toString().contains("Malam")) {
							datePulang = datePulang.plusDays(1);
						}

						if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulang))) {
							rawResult.add(map);
						}
					} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
							.contains(Integer.parseInt(map.get("departemenId").toString()))) {
						if (map.get("namaProduk").toString().toLowerCase().contains(Master.VISIT)
								&& map.get("idPegawai").toString().equals(map.get("idDPJP"))) {
							rawResult.add(map);
						}
					}
				} else if (!drKkPediatrikGDList.contains(map.get("idPegawai"))) {
					if (listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))) {
						if (idsRegDJPPenunjangPA.contains(Integer.parseInt(map.get("detailId").toString()))
								|| idsRegDJPPenunjangPK.contains(Integer.parseInt(map.get("detailId").toString()))) {
							rawResult.add(map);
						} else if (Master.KelompokPasien.BPJS
								.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.KEMENKES
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.JAMKESDA
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
							rawResult.add(map);
						} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
							Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
							String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
							String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
							LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
							LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
							LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

							String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
									+ map.get("jamMasuk").toString().substring(3) + ":00";
							LocalTime timeMasuk = LocalTime.parse(jamMasuk);
							LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

							String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
									+ map.get("jamPulang").toString().substring(3) + ":00";
							LocalTime timePulang = LocalTime.parse(jamPulang);
							LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

							String jamPulangPSBB = "";
							LocalTime timePulangPSBB = LocalTime.now();
							LocalDateTime datePulangPSBB = LocalDateTime.now();
							if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
								jamPulangPSBB = "14:00:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
								jamPulangPSBB = "14:30:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else {
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
							}

							if (map.get("namaShift").toString().contains("Malam")) {
								datePulang = datePulang.plusDays(1);
							}

							if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								rawResult.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))) {
								rawResult.add(map);
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))
									&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
											.contains(Integer.parseInt(map.get("idKelas").toString()))) {
								rawResult.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
									&& map.get("namaShift").toString().equals("Non Shift")
									&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
									&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
									&& (dateTimePelayanan.isBefore(PSBBEnd) || dateTimePelayanan.isEqual(PSBBEnd))) {
								if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulangPSBB))) {
									rawResult.add(map);
								}
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								rawResult.add(map);
							}
						} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
								&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
										.contains(Integer.parseInt(map.get("idKelas").toString()))) {
							rawResult.add(map);
						}
					} else if (!listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))
							&& map.get("departemenId").equals(Master.Departemen.IGD)
							&& drKsmUmumList.contains(idPegawai)
							&& idsDokterUmumIGD.contains(Integer.parseInt(map.get("idProduk").toString()))) {
						if (Master.KelompokPasien.BPJS.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.KEMENKES
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.JAMKESDA
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
							rawResult.add(map);
						} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
							Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
							String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
							String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
							LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
							LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
							LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

							String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
									+ map.get("jamMasuk").toString().substring(3) + ":00";
							LocalTime timeMasuk = LocalTime.parse(jamMasuk);
							LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

							String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
									+ map.get("jamPulang").toString().substring(3) + ":00";
							LocalTime timePulang = LocalTime.parse(jamPulang);
							LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

							String jamPulangPSBB = "";
							LocalTime timePulangPSBB = LocalTime.now();
							LocalDateTime datePulangPSBB = LocalDateTime.now();
							if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
								jamPulangPSBB = "14:00:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
								jamPulangPSBB = "14:30:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else {
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
							}

							if (map.get("namaShift").toString().contains("Malam")) {
								datePulang = datePulang.plusDays(1);
							}

							if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								rawResult.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))) {
								rawResult.add(map);
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))
									&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
											.contains(Integer.parseInt(map.get("idKelas").toString()))) {
								rawResult.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
									&& map.get("namaShift").toString().equals("Non Shift")
									&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
									&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
									&& (dateTimePelayanan.isBefore(PSBBEnd) || dateTimePelayanan.isEqual(PSBBEnd))) {
								if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulangPSBB))) {
									rawResult.add(map);
								}
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								rawResult.add(map);
							}
						} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
								&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
										.contains(Integer.parseInt(map.get("idKelas").toString()))) {
							rawResult.add(map);
						}

					} else if (!listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))
							&& drKkPerinatologiList.contains(idPegawai)
							&& idsDokterPerinatologi.contains(Integer.parseInt(map.get("idProduk").toString()))) {
						if (Master.KelompokPasien.BPJS.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.KEMENKES
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.JAMKESDA
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
							rawResult.add(map);
						} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
							Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
							String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
							String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
							LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
							LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
							LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

							String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
									+ map.get("jamMasuk").toString().substring(3) + ":00";
							LocalTime timeMasuk = LocalTime.parse(jamMasuk);
							LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

							String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
									+ map.get("jamPulang").toString().substring(3) + ":00";
							LocalTime timePulang = LocalTime.parse(jamPulang);
							LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

							String jamPulangPSBB = "";
							LocalTime timePulangPSBB = LocalTime.now();
							LocalDateTime datePulangPSBB = LocalDateTime.now();
							if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
								jamPulangPSBB = "14:00:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
								jamPulangPSBB = "14:30:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else {
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
							}

							if (map.get("namaShift").toString().contains("Malam")) {
								datePulang = datePulang.plusDays(1);
							}

							if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								rawResult.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))) {
								rawResult.add(map);
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))
									&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
											.contains(Integer.parseInt(map.get("idKelas").toString()))) {
								rawResult.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
									&& map.get("namaShift").toString().equals("Non Shift")
									&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
									&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
									&& (dateTimePelayanan.isBefore(PSBBEnd) || dateTimePelayanan.isEqual(PSBBEnd))) {
								if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulangPSBB))) {
									rawResult.add(map);
								}
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								rawResult.add(map);
							}
						} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
								&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
										.contains(Integer.parseInt(map.get("idKelas").toString()))) {
							rawResult.add(map);
						}
					} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProdukException)
							&& listDetailJenisProdukException
									.contains(Integer.parseInt(map.get("detailId").toString()))) {
						if (idsRegDJPPenunjangPA.contains(Integer.parseInt(map.get("detailId").toString()))
								|| idsRegDJPPenunjangPK.contains(Integer.parseInt(map.get("detailId").toString()))) {
							rawResult.add(map);
						} else if (Master.KelompokPasien.BPJS
								.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.KEMENKES
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.JAMKESDA
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
							rawResult.add(map);
						} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
							Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
							String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
							String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
							LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
							LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
							LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

							String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
									+ map.get("jamMasuk").toString().substring(3) + ":00";
							LocalTime timeMasuk = LocalTime.parse(jamMasuk);
							LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

							String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
									+ map.get("jamPulang").toString().substring(3) + ":00";
							LocalTime timePulang = LocalTime.parse(jamPulang);
							LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

							String jamPulangPSBB = "";
							LocalTime timePulangPSBB = LocalTime.now();
							LocalDateTime datePulangPSBB = LocalDateTime.now();
							if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
								jamPulangPSBB = "14:00:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
								jamPulangPSBB = "14:30:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else {
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
							}

							if (map.get("namaShift").toString().contains("Malam")) {
								datePulang = datePulang.plusDays(1);
							}

							if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								rawResult.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))) {
								rawResult.add(map);
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))
									&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
											.contains(Integer.parseInt(map.get("idKelas").toString()))) {
								rawResult.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
									&& map.get("namaShift").toString().equals("Non Shift")
									&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
									&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
									&& (dateTimePelayanan.isBefore(PSBBEnd) || dateTimePelayanan.isEqual(PSBBEnd))) {
								if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulangPSBB))) {
									rawResult.add(map);
								}
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								rawResult.add(map);
							}
						} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
								&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
										.contains(Integer.parseInt(map.get("idKelas").toString()))) {
							rawResult.add(map);
						}
					}
				}
			}
		}

		if (CommonUtil.isNotNullOrEmpty(rawResult)) {
			for (Map<String, Object> map : rawResult) {
				if (!Arrays.asList(Master.JenisPetugasPelaksana.DOKTER_ANASTESI_OR_ASISTEN_SPESIALIS)
						.contains(Integer.parseInt(map.get("idJenisPelaksana").toString()))) {
					map.put("idJenisPelaksana", Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA);
				}
				if (!listProdukId.contains(Integer.parseInt(map.get("idProduk").toString()))) {
					listProdukId.add(Integer.parseInt(map.get("idProduk").toString()));
				}
				if (!listKelasId.contains(Integer.parseInt(map.get("idKelas").toString()))) {
					listKelasId.add(Integer.parseInt(map.get("idKelas").toString()));
				}
				if (!listTanggalPelayanan.contains(map.get("tanggal").toString())) {
					listTanggalPelayanan.add(map.get("tanggal").toString());
				}
				if (!listPelaksanaId.contains(Integer.parseInt(map.get("idJenisPelaksana").toString()))) {
					listPelaksanaId.add(Integer.parseInt(map.get("idJenisPelaksana").toString()));
				}
			}

			Collections.sort(listKelasId, Collections.reverseOrder());
			for (Integer idProduk : listProdukId) {
				for (Integer idKelas : listKelasId) {
					for (Integer idPelaksana : listPelaksanaId) {
						for (String tanggal : listTanggalPelayanan) {
							Map<String, Object> mapResult1 = new HashMap<>();
							Map<String, Object> mapResult2 = new HashMap<>();
							double count1 = 0.0;
							double count2 = 0.0;
							int dataCount1 = 0;
							int dataCount2 = 0;
							for (Map<String, Object> map : rawResult) {
								if (Integer.parseInt(map.get("idProduk").toString()) == idProduk
										&& Integer.parseInt(map.get("idKelas").toString()) == idKelas
										&& Integer.parseInt(map.get("idJenisPelaksana").toString()) == idPelaksana
										&& map.get("tanggal").toString().equals(tanggal)
										&& (Double.parseDouble(map.get("diskon").toString()) > 0
												&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
														.valueOf(map.get("statusDiskon").toString()).equals(0)))) {
									if (drKkPerinatologiList.contains(idPegawai)) {
										if ((Arrays.asList(Master.Produk.MONITORING_INTERVENSI)
												.contains(map.get("idProduk"))
												|| map.get("namaProduk").toString().toLowerCase()
														.contains(Master.VISIT))
												&& count1 < 2) {
											count1 = count1 + Double.parseDouble(map.get("count").toString());
										} else if (!Arrays.asList(Master.Produk.MONITORING_INTERVENSI)
												.contains(map.get("idProduk"))
												&& !map.get("namaProduk").toString().toLowerCase()
														.contains(Master.VISIT)) {
											count1 = count1 + Double.parseDouble(map.get("count").toString());
										}
									} else {
										count1 = count1 + Double.parseDouble(map.get("count").toString());
									}
									dataCount1 = dataCount1 + 1;
									if (dataCount1 == 1) {
										mapResult1.putAll(map);
									}
								} else if (Integer.parseInt(map.get("idProduk").toString()) == idProduk
										&& Integer.parseInt(map.get("idKelas").toString()) == idKelas
										&& Integer.parseInt(map.get("idJenisPelaksana").toString()) == idPelaksana
										&& map.get("tanggal").toString().equals(tanggal)) {
									if (drKkPerinatologiList.contains(idPegawai)) {
										if ((Arrays.asList(Master.Produk.MONITORING_INTERVENSI)
												.contains(map.get("idProduk"))
												|| map.get("namaProduk").toString().toLowerCase()
														.contains(Master.VISIT))
												&& count2 < 2) {
											count2 = count2 + Double.parseDouble(map.get("count").toString());
										} else if (!Arrays.asList(Master.Produk.MONITORING_INTERVENSI)
												.contains(map.get("idProduk"))
												&& !map.get("namaProduk").toString().toLowerCase()
														.contains(Master.VISIT)) {
											count2 = count2 + Double.parseDouble(map.get("count").toString());
										}
									} else {
										count2 = count2 + Double.parseDouble(map.get("count").toString());
									}
									dataCount2 = dataCount2 + 1;
									if (dataCount2 == 1) {
										mapResult2.putAll(map);
									}
								}
							}
							if (CommonUtil.isNotNullOrEmpty(mapResult1.get("count"))) {
								mapResult1.put("count", count1);
								countResult.add(mapResult1);
							}
							if (CommonUtil.isNotNullOrEmpty(mapResult2.get("count"))) {
								mapResult2.put("count", count2);
								countResult.add(mapResult2);
							}
						}
					}
				}
			}

			for (Integer idProduk : listProdukId) {
				for (Integer idKelas : listKelasId) {
					for (Integer idPelaksana : listPelaksanaId) {
						Map<String, Object> mapResult1 = new HashMap<>();
						Map<String, Object> mapResult2 = new HashMap<>();
						List<Map<String, Object>> datas1 = new ArrayList<>();
						List<Map<String, Object>> datas2 = new ArrayList<>();
						Double totalKonsul1 = 0.0;
						Double totalKonsul2 = 0.0;
						Double totalVisit1 = 0.0;
						Double totalVisit2 = 0.0;
						Double totalTindakan1 = 0.0;
						Double totalTindakan2 = 0.0;
						Double totalProduk1 = 0.0;
						Double totalProduk2 = 0.0;
						int counter1 = 0;
						int counter2 = 0;
						boolean isDiskonJasamedis1 = false;
						boolean isDiskonJasamedis2 = false;
						for (Map<String, Object> map : countResult) {
							Map<String, Object> countMap = new HashMap<>();
							if (Integer.parseInt(map.get("idProduk").toString()) == idProduk
									&& Integer.parseInt(map.get("idKelas").toString()) == idKelas
									&& Integer.parseInt(map.get("idJenisPelaksana").toString()) == idPelaksana
									&& (Double.parseDouble(map.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
													.valueOf(map.get("statusDiskon").toString()).equals(0)))) {
								countMap.put("count", map.get("count"));
								if (isSatuTarif && CommonUtil.isNotNullOrEmpty(map.get("hargaKelas1"))) {
									countMap.put("harga", map.get("hargaKelas1"));
								} else {
									countMap.put("harga", map.get("harga"));
								}
								countMap.put("tanggal", map.get("tanggal"));
								datas1.add(countMap);
								if (map.get("namaProduk").toString().toLowerCase().contains("konsul")) {
									totalKonsul1 = totalKonsul1 + Double.parseDouble(map.get("count").toString());
								} else if (map.get("namaProduk").toString().toLowerCase().contains("visit")) {
									totalVisit1 = totalVisit1 + Double.parseDouble(map.get("count").toString());
								} else {
									totalTindakan1 = totalTindakan1 + Double.parseDouble(map.get("count").toString());
								}
								totalProduk1 = totalProduk1 + Double.parseDouble(map.get("count").toString());
								counter1 = counter1 + 1;
								if (counter1 == 1) {
									mapResult1.putAll(map);
								}
							} else if (Integer.parseInt(map.get("idProduk").toString()) == idProduk
									&& Integer.parseInt(map.get("idKelas").toString()) == idKelas
									&& Integer.parseInt(map.get("idJenisPelaksana").toString()) == idPelaksana) {
								countMap.put("count", map.get("count"));
								if (isSatuTarif && CommonUtil.isNotNullOrEmpty(map.get("hargaKelas1"))) {
									countMap.put("harga", map.get("hargaKelas1"));
								} else {
									countMap.put("harga", map.get("harga"));
								}
								countMap.put("tanggal", map.get("tanggal"));
								datas2.add(countMap);
								if (map.get("namaProduk").toString().toLowerCase().contains("konsul")) {
									totalKonsul2 = totalKonsul2 + Double.parseDouble(map.get("count").toString());
								} else if (map.get("namaProduk").toString().toLowerCase().contains("visit")) {
									totalVisit2 = totalVisit2 + Double.parseDouble(map.get("count").toString());
								} else {
									totalTindakan2 = totalTindakan2 + Double.parseDouble(map.get("count").toString());
								}
								totalProduk2 = totalProduk2 + Double.parseDouble(map.get("count").toString());
								counter2 = counter2 + 1;
								if (counter2 == 1) {
									mapResult2.putAll(map);
								}
							}
						}
						if (CommonUtil.isNotNullOrEmpty(mapResult1.get("count"))) {
							if (isSatuTarif) {
								if (isSatuTarif && CommonUtil.isNotNullOrEmpty(mapResult1.get("hargaKelas1"))) {
									harga = Double.parseDouble(mapResult1.get("hargaKelas1").toString());
								} else {
									harga = Double.parseDouble(mapResult1.get("harga").toString());
								}
							} else {
								harga = Double.parseDouble(mapResult1.get("harga").toString());
							}

							if (drAnastesiList.contains(idPegawai)) {
								if (idsPenunjangBukanAnestesi.contains(mapResult1.get("idProduk"))) {
									percentage = persenOperator;
								} else if ((Integer) mapResult1
										.get("idJenisPelaksana") == Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA) {
									percentage = persenOperator;
									if (Double.parseDouble(mapResult1.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(mapResult1.get("statusDiskon")) || Integer
													.valueOf(mapResult1.get("statusDiskon").toString()).equals(0))) {
										Double totalDiskonJasamedis = pelayananPasienDetailDao
												.totalDiskonJasamedis(mapResult1.get("noRec").toString());
										if (CommonUtil.isNotNullOrEmpty(totalDiskonJasamedis)
												&& totalDiskonJasamedis > 0.0) {
											isDiskonJasamedis1 = true;
										}
									}
								} else {
									percentage = persenCooperator;
								}
							} else {
								if ((Integer) mapResult1
										.get("idJenisPelaksana") == Master.JenisPetugasPelaksana.ASISTEN_SPESIALIS) {
									percentage = persenCooperator;
								} else {
									percentage = persenOperator;
									if (Double.parseDouble(mapResult1.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(mapResult1.get("statusDiskon")) || Integer
													.valueOf(mapResult1.get("statusDiskon").toString()).equals(0))) {
										Double totalDiskonJasamedis = pelayananPasienDetailDao
												.totalDiskonJasamedis(mapResult1.get("noRec").toString());
										if (CommonUtil.isNotNullOrEmpty(totalDiskonJasamedis)
												&& totalDiskonJasamedis > 0.0) {
											isDiskonJasamedis1 = true;
										}
									}
								}
							}

							percentage = percentage / 100;
							point = getPoinLogbookDokter(harga, percentage, komponenDasar, isDiskonJasamedis1);
							pointQty = point * totalProduk1.doubleValue();
							formatPointQty = Double.parseDouble(df.format(pointQty));

							// if (Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA
							// .equals(mapResult1.get("idJenisPelaksana"))) {
							// Optional<Double> nettoKomponen =
							// detailHargaNettoDao.findHargetNetto1Komponen(
							// Master.KomponenHarga.JASA_DOKTER,
							// Integer.parseInt(mapResult1.get("idProduk").toString()),
							// Integer.parseInt(mapResult1.get("idKelas").toString()));
							// formatRpKontribusi = totalProduk1
							// * (nettoKomponen != null ?
							// nettoKomponen.orElse(0.0) : 0.0);
							// } else if
							// (Master.JenisPetugasPelaksana.DOKTER_ANASTESI
							// .equals(mapResult1.get("idJenisPelaksana"))) {
							// Optional<Double> nettoKomponen =
							// detailHargaNettoDao.findHargetNetto1Komponen(
							// Master.KomponenHarga.JASA_DOKTER_ANASTESI,
							// Integer.parseInt(mapResult1.get("idProduk").toString()),
							// Integer.parseInt(mapResult1.get("idKelas").toString()));
							// formatRpKontribusi = totalProduk1
							// * (nettoKomponen != null ?
							// nettoKomponen.orElse(0.0) : 0.0);
							// } else if
							// (Master.JenisPetugasPelaksana.ASISTEN_SPESIALIS
							// .equals(mapResult1.get("idJenisPelaksana"))) {
							// Optional<Double> nettoKomponen =
							// detailHargaNettoDao.findHargetNetto1Komponen(
							// Master.KomponenHarga.JASA_ASISTEN_SPESIALIS,
							// Integer.parseInt(mapResult1.get("idProduk").toString()),
							// Integer.parseInt(mapResult1.get("idKelas").toString()));
							// formatRpKontribusi = totalProduk1
							// * (nettoKomponen != null ?
							// nettoKomponen.orElse(0.0) : 0.0);
							// }

							mapResult1.put("totalKonsul", totalKonsul1.longValue());
							mapResult1.put("totalVisit", totalVisit1.longValue());
							mapResult1.put("totalTindakan", totalTindakan1.longValue());
							mapResult1.put("totalProduk", totalProduk1.longValue());
							mapResult1.put("datas", datas1);
							mapResult1.put("poin", point);
							mapResult1.put("pointQty", formatPointQty);
							mapResult1.put("kontribusi", formatRpKontribusi);
							mapResult1.put("isSatuTarif", isSatuTarif);

							result.add(mapResult1);
						}
						if (CommonUtil.isNotNullOrEmpty(mapResult2.get("count"))) {
							if (isSatuTarif) {
								if (CommonUtil.isNotNullOrEmpty(mapResult2.get("hargaKelas1"))) {
									harga = Double.parseDouble(mapResult2.get("hargaKelas1").toString());
								} else {
									harga = Double.parseDouble(mapResult2.get("harga").toString());
								}
							} else {
								harga = Double.parseDouble(mapResult2.get("harga").toString());
							}

							if (drAnastesiList.contains(idPegawai)) {
								if (idsPenunjangBukanAnestesi.contains(mapResult2.get("idProduk"))) {
									percentage = persenOperator;
								} else if ((Integer) mapResult2
										.get("idJenisPelaksana") == Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA) {
									percentage = persenOperator;
									if (Double.parseDouble(mapResult2.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(mapResult2.get("statusDiskon")) || Integer
													.valueOf(mapResult2.get("statusDiskon").toString()).equals(0))) {
										Double totalDiskonJasamedis = pelayananPasienDetailDao
												.totalDiskonJasamedis(mapResult2.get("noRec").toString());
										if (CommonUtil.isNotNullOrEmpty(totalDiskonJasamedis)
												&& totalDiskonJasamedis > 0.0) {
											isDiskonJasamedis2 = true;
										}
									}
								} else {
									percentage = persenCooperator;
								}
							} else {
								if ((Integer) mapResult2
										.get("idJenisPelaksana") == Master.JenisPetugasPelaksana.ASISTEN_SPESIALIS) {
									percentage = persenCooperator;
								} else {
									percentage = persenOperator;
									if (Double.parseDouble(mapResult2.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(mapResult2.get("statusDiskon")) || Integer
													.valueOf(mapResult2.get("statusDiskon").toString()).equals(0))) {
										Double totalDiskonJasamedis = pelayananPasienDetailDao
												.totalDiskonJasamedis(mapResult2.get("noRec").toString());
										if (CommonUtil.isNotNullOrEmpty(totalDiskonJasamedis)
												&& totalDiskonJasamedis > 0.0) {
											isDiskonJasamedis2 = true;
										}
									}
								}
							}

							percentage = percentage / 100;
							point = getPoinLogbookDokter(harga, percentage, komponenDasar, isDiskonJasamedis2);
							pointQty = point * totalProduk2.doubleValue();
							formatPointQty = Double.parseDouble(df.format(pointQty));

							// if (Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA
							// .equals(mapResult2.get("idJenisPelaksana"))) {
							// Optional<Double> nettoKomponen =
							// detailHargaNettoDao.findHargetNetto1Komponen(
							// Master.KomponenHarga.JASA_DOKTER,
							// Integer.parseInt(mapResult2.get("idProduk").toString()),
							// Integer.parseInt(mapResult2.get("idKelas").toString()));
							// formatRpKontribusi = totalProduk2
							// * (nettoKomponen != null ?
							// nettoKomponen.orElse(0.0) : 0.0);
							// } else if
							// (Master.JenisPetugasPelaksana.DOKTER_ANASTESI
							// .equals(mapResult2.get("idJenisPelaksana"))) {
							// Optional<Double> nettoKomponen =
							// detailHargaNettoDao.findHargetNetto1Komponen(
							// Master.KomponenHarga.JASA_DOKTER_ANASTESI,
							// Integer.parseInt(mapResult2.get("idProduk").toString()),
							// Integer.parseInt(mapResult2.get("idKelas").toString()));
							// formatRpKontribusi = totalProduk2
							// * (nettoKomponen != null ?
							// nettoKomponen.orElse(0.0) : 0.0);
							// } else if
							// (Master.JenisPetugasPelaksana.ASISTEN_SPESIALIS
							// .equals(mapResult2.get("idJenisPelaksana"))) {
							// Optional<Double> nettoKomponen =
							// detailHargaNettoDao.findHargetNetto1Komponen(
							// Master.KomponenHarga.JASA_ASISTEN_SPESIALIS,
							// Integer.parseInt(mapResult2.get("idProduk").toString()),
							// Integer.parseInt(mapResult2.get("idKelas").toString()));
							// formatRpKontribusi = totalProduk2
							// * (nettoKomponen != null ?
							// nettoKomponen.orElse(0.0) : 0.0);
							// }

							mapResult2.put("totalKonsul", totalKonsul2.longValue());
							mapResult2.put("totalVisit", totalVisit2.longValue());
							mapResult2.put("totalTindakan", totalTindakan2.longValue());
							mapResult2.put("totalProduk", totalProduk2.longValue());
							mapResult2.put("datas", datas2);
							mapResult2.put("poin", point);
							mapResult2.put("pointQty", formatPointQty);
							mapResult2.put("kontribusi", formatRpKontribusi);
							mapResult2.put("isSatuTarif", isSatuTarif);

							result.add(mapResult2);
						}
					}
				}
			}
		}

		return result;
	}

	@Override
	public List<Map<String, Object>> getAllTindakanByDokterReviewForReport(String periode, Integer idPegawai) {
		if (pegawaiDao.getPegawaiByKategoryPegawai(Arrays.asList(Master.KategoryPegawai.DOKTER_LUAR))
				.contains(idPegawai)) {
			return new ArrayList<>();
		}

		List<Map<String, Object>> result = new ArrayList<>();
		List<Map<String, Object>> rawResult = new ArrayList<>();
		List<Map<String, Object>> countResult = new ArrayList<>();

		List<Integer> listProdukId = new ArrayList<>();
		List<Integer> listKelasId = new ArrayList<>();
		List<Integer> listDetailJenisProduk = new ArrayList<>();
		List<Integer> listDetailJenisProdukException = new ArrayList<>();
		List<String> listTanggalPelayanan = new ArrayList<>();

		Double harga = 0.0;
		Double point = 0.0;
		Double pointQty = 0.0;
		Double formatPointQty = 0.0;
		Double percentage = 0.0;

		DecimalFormat df = new DecimalFormat("#.##");
		DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

		LocalDateTime PSBBDate = LocalDateTime.of(2020, 9, 14, 0, 0, 0);
		LocalDateTime PSBBEnd = LocalDateTime.parse(GetSettingDataFixed("psbbperiod"), dtf);

		List<Integer> drAnastesiList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_ANESTESI);
		List<Integer> drKsmUmumList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_UMUM);
		List<Integer> laboranRadiologList = mapPegawaiLaboratRadiologiDao.findPegawaiLaboranRadiolog();

		List<Integer> idsRegDJPAdminNonPK = splitDataSettingDatafixed("admin_nonpk");
		List<Integer> idsRegDJPMedisUtama = splitDataSettingDatafixed("medis_utama");
		List<Integer> idsRegDJPPenunjangPA = splitDataSettingDatafixed("penunjang_pa");
		List<Integer> idsRegDJPPenunjangPK = splitDataSettingDatafixed("penunjang_pk");
		List<Integer> idsRegDJPPenunjangRad = splitDataSettingDatafixed("penunjang_radiologi");

		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPA;
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPK;
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangRad;
		} else {
			listDetailJenisProduk = idsRegDJPMedisUtama;
		}

		if (laboranRadiologList.contains(idPegawai)) {
			listDetailJenisProdukException = idsRegDJPAdminNonPK;
			listDetailJenisProdukException.removeAll(listDetailJenisProduk);
		}

		List<Map<String, Object>> listData = revIndekKinerjaDao.getAllTindakanDokter(Master.Kelas.KELAS_SATU, idPegawai,
				Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA, periode);

		List<Integer> idsDokterUmumIGD = splitDataSettingDatafixed("pr_dokter_umum_igd");
		List<Integer> idsPenunjangBukanAnestesi = splitDataSettingDatafixed("pr_penunjang_nonanestesi");
		Double komponenDasar = Double.parseDouble(GetSettingDataFixed("ld_komponen_dasar"));
		Double persenOperator = Double.parseDouble(GetSettingDataFixed("ld_persen_operator"));
		Double persenCooperator = Double.parseDouble(GetSettingDataFixed("ld_persen_cooperator"));

		// LOGIC_RULES_REMUN
		if (CommonUtil.isNotNullOrEmpty(listData)) {
			for (Map<String, Object> map : listData) {
				if (listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))) {
					if (idsRegDJPPenunjangPA.contains(Integer.parseInt(map.get("detailId").toString()))
							|| idsRegDJPPenunjangPK.contains(Integer.parseInt(map.get("detailId").toString()))) {
						rawResult.add(map);
					} else if (Master.KelompokPasien.BPJS
							.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
							|| Master.KelompokPasien.KEMENKES
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
							|| Master.KelompokPasien.JAMKESDA
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
						rawResult.add(map);
					} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
						Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
						String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
						String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
						LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
						LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
						LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

						String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
								+ map.get("jamMasuk").toString().substring(3) + ":00";
						LocalTime timeMasuk = LocalTime.parse(jamMasuk);
						LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

						String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
								+ map.get("jamPulang").toString().substring(3) + ":00";
						LocalTime timePulang = LocalTime.parse(jamPulang);
						LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

						String jamPulangPSBB = "";
						LocalTime timePulangPSBB = LocalTime.now();
						LocalDateTime datePulangPSBB = LocalDateTime.now();
						if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
								|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
								|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
								|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
							jamPulangPSBB = "14:00:00";
							timePulangPSBB = LocalTime.parse(jamPulangPSBB);
							datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
						} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
							jamPulangPSBB = "14:30:00";
							timePulangPSBB = LocalTime.parse(jamPulangPSBB);
							datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
						} else {
							datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
						}

						if (map.get("namaShift").toString().contains("Malam")) {
							datePulang = datePulang.plusDays(1);
						}

						if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulang))) {
							rawResult.add(map);
						} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
								&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
								&& Arrays.stream(Master.KONSUL_VISIT)
										.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
								&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
										|| dateTimePelayanan.isAfter(datePulang))) {
							rawResult.add(map);
						} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
										|| dateTimePelayanan.isAfter(datePulang))
								&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
										.contains(Integer.parseInt(map.get("idKelas").toString()))) {
							rawResult.add(map);
						} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
								&& map.get("namaShift").toString().equals("Non Shift")
								&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
								&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
								&& (dateTimePelayanan.isBefore(PSBBEnd) || dateTimePelayanan.isEqual(PSBBEnd))) {
							if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
									&& dateTimePelayanan.isBefore(datePulangPSBB))) {
								rawResult.add(map);
							}
						} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulang))) {
							rawResult.add(map);
						}
					} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
							&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
							&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
									.contains(Integer.parseInt(map.get("idKelas").toString()))) {
						rawResult.add(map);
					}
				} else if (!listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))
						&& map.get("departemenId").equals(Master.Departemen.IGD) && drKsmUmumList.contains(idPegawai)
						&& idsDokterUmumIGD.contains(Integer.parseInt(map.get("idProduk").toString()))) {
					if (Master.KelompokPasien.BPJS.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
							|| Master.KelompokPasien.KEMENKES
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
							|| Master.KelompokPasien.JAMKESDA
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
						rawResult.add(map);
					} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
						Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
						String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
						String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
						LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
						LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
						LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

						String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
								+ map.get("jamMasuk").toString().substring(3) + ":00";
						LocalTime timeMasuk = LocalTime.parse(jamMasuk);
						LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

						String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
								+ map.get("jamPulang").toString().substring(3) + ":00";
						LocalTime timePulang = LocalTime.parse(jamPulang);
						LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

						String jamPulangPSBB = "";
						LocalTime timePulangPSBB = LocalTime.now();
						LocalDateTime datePulangPSBB = LocalDateTime.now();
						if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
								|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
								|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
								|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
							jamPulangPSBB = "14:00:00";
							timePulangPSBB = LocalTime.parse(jamPulangPSBB);
							datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
						} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
							jamPulangPSBB = "14:30:00";
							timePulangPSBB = LocalTime.parse(jamPulangPSBB);
							datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
						} else {
							datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
						}

						if (map.get("namaShift").toString().contains("Malam")) {
							datePulang = datePulang.plusDays(1);
						}

						if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulang))) {
							rawResult.add(map);
						} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
								&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
								&& Arrays.stream(Master.KONSUL_VISIT)
										.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
								&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
										|| dateTimePelayanan.isAfter(datePulang))) {
							rawResult.add(map);
						} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
										|| dateTimePelayanan.isAfter(datePulang))
								&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
										.contains(Integer.parseInt(map.get("idKelas").toString()))) {
							rawResult.add(map);
						} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
								&& map.get("namaShift").toString().equals("Non Shift")
								&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
								&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
								&& (dateTimePelayanan.isBefore(PSBBEnd) || dateTimePelayanan.isEqual(PSBBEnd))) {
							if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
									&& dateTimePelayanan.isBefore(datePulangPSBB))) {
								rawResult.add(map);
							}
						} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulang))) {
							rawResult.add(map);
						}
					} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
							&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
							&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
									.contains(Integer.parseInt(map.get("idKelas").toString()))) {
						rawResult.add(map);
					}
				} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProdukException)
						&& listDetailJenisProdukException.contains(Integer.parseInt(map.get("detailId").toString()))) {
					if (idsRegDJPPenunjangPA.contains(Integer.parseInt(map.get("detailId").toString()))
							|| idsRegDJPPenunjangPK.contains(Integer.parseInt(map.get("detailId").toString()))) {
						rawResult.add(map);
					} else if (Master.KelompokPasien.BPJS
							.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
							|| Master.KelompokPasien.KEMENKES
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
							|| Master.KelompokPasien.JAMKESDA
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
						rawResult.add(map);
					} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
						Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
						String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
						String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
						LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
						LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
						LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

						String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
								+ map.get("jamMasuk").toString().substring(3) + ":00";
						LocalTime timeMasuk = LocalTime.parse(jamMasuk);
						LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

						String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
								+ map.get("jamPulang").toString().substring(3) + ":00";
						LocalTime timePulang = LocalTime.parse(jamPulang);
						LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

						String jamPulangPSBB = "";
						LocalTime timePulangPSBB = LocalTime.now();
						LocalDateTime datePulangPSBB = LocalDateTime.now();
						if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
								|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
								|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
								|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
							jamPulangPSBB = "14:00:00";
							timePulangPSBB = LocalTime.parse(jamPulangPSBB);
							datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
						} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
							jamPulangPSBB = "14:30:00";
							timePulangPSBB = LocalTime.parse(jamPulangPSBB);
							datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
						} else {
							datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
						}

						if (map.get("namaShift").toString().contains("Malam")) {
							datePulang = datePulang.plusDays(1);
						}

						if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulang))) {
							rawResult.add(map);
						} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
								&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
								&& Arrays.stream(Master.KONSUL_VISIT)
										.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
								&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
										|| dateTimePelayanan.isAfter(datePulang))) {
							rawResult.add(map);
						} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
										|| dateTimePelayanan.isAfter(datePulang))
								&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
										.contains(Integer.parseInt(map.get("idKelas").toString()))) {
							rawResult.add(map);
						} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
								&& map.get("namaShift").toString().equals("Non Shift")
								&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
								&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
								&& (dateTimePelayanan.isBefore(PSBBEnd) || dateTimePelayanan.isEqual(PSBBEnd))) {
							if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
									&& dateTimePelayanan.isBefore(datePulangPSBB))) {
								rawResult.add(map);
							}
						} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulang))) {
							rawResult.add(map);
						}
					} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
							&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
							&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
									.contains(Integer.parseInt(map.get("idKelas").toString()))) {
						rawResult.add(map);
					}
				}
			}
		}

		if (CommonUtil.isNotNullOrEmpty(rawResult)) {
			for (Map<String, Object> map : rawResult) {
				if (!Arrays.asList(Master.JenisPetugasPelaksana.DOKTER_ANASTESI_OR_ASISTEN_SPESIALIS)
						.contains(Integer.parseInt(map.get("idJenisPelaksana").toString()))) {
					map.put("idJenisPelaksana", Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA);
				}
				if (!listProdukId.contains(Integer.parseInt(map.get("idProduk").toString()))) {
					listProdukId.add(Integer.parseInt(map.get("idProduk").toString()));
				}
				if (!listKelasId.contains(Integer.parseInt(map.get("idKelas").toString()))) {
					listKelasId.add(Integer.parseInt(map.get("idKelas").toString()));
				}
				if (!listTanggalPelayanan.contains(map.get("tanggal").toString())) {
					listTanggalPelayanan.add(map.get("tanggal").toString());
				}
			}

			Collections.sort(listKelasId, Collections.reverseOrder());
			for (Integer idProduk : listProdukId) {
				for (Integer idKelas : listKelasId) {
					for (String tanggal : listTanggalPelayanan) {
						Map<String, Object> mapResult = new HashMap<>();
						double count = 0.0;
						int dataCount = 0;
						for (Map<String, Object> map : rawResult) {
							if (Integer.parseInt(map.get("idProduk").toString()) == idProduk
									&& Integer.parseInt(map.get("idKelas").toString()) == idKelas
									&& map.get("tanggal").toString().equals(tanggal)) {
								count = count + Double.parseDouble(map.get("count").toString());
								dataCount = dataCount + 1;
								if (dataCount == 1) {
									mapResult.putAll(map);
								}
							}
						}
						if (CommonUtil.isNotNullOrEmpty(mapResult.get("count"))) {
							mapResult.put("count", count);
							countResult.add(mapResult);
						}
					}
				}
			}

			for (Integer idProduk : listProdukId) {
				for (Integer idKelas : listKelasId) {
					Map<String, Object> mapResult = new HashMap<>();
					List<Map<String, Object>> datas = new ArrayList<>();
					Double totalKonsul = 0.0;
					Double totalVisit = 0.0;
					Double totalTindakan = 0.0;
					Double totalProduk = 0.0;
					int counter = 0;
					for (Map<String, Object> map : countResult) {
						Map<String, Object> countMap = new HashMap<>();
						if (Integer.parseInt(map.get("idProduk").toString()) == idProduk
								&& Integer.parseInt(map.get("idKelas").toString()) == idKelas) {
							countMap.put("count", map.get("count"));
							if (CommonUtil.isNotNullOrEmpty(map.get("hargaKelas1"))) {
								countMap.put("harga", map.get("hargaKelas1"));
							} else {
								countMap.put("harga", map.get("harga"));
							}
							countMap.put("tanggal", map.get("tanggal"));
							datas.add(countMap);
							if (map.get("namaProduk").toString().toLowerCase().contains("konsul")) {
								totalKonsul = totalKonsul + Double.parseDouble(map.get("count").toString());
							} else if (map.get("namaProduk").toString().toLowerCase().contains("visit")) {
								totalVisit = totalVisit + Double.parseDouble(map.get("count").toString());
							} else {
								totalTindakan = totalTindakan + Double.parseDouble(map.get("count").toString());
							}
							totalProduk = totalProduk + Double.parseDouble(map.get("count").toString());
							counter = counter + 1;
							if (counter == 1) {
								mapResult.putAll(map);
							}
						}
					}
					if (CommonUtil.isNotNullOrEmpty(mapResult.get("count"))) {
						if (Master.LogbookDokter.IS_TARIF_SATU_HARGA) {
							if (CommonUtil.isNotNullOrEmpty(mapResult.get("hargaKelas1"))) {
								harga = Double.parseDouble(mapResult.get("hargaKelas1").toString());
							} else {
								harga = Double.parseDouble(mapResult.get("harga").toString());
							}
						} else {
							harga = Double.parseDouble(mapResult.get("harga").toString());
						}

						if (drAnastesiList.contains(idPegawai)) {
							if (idsPenunjangBukanAnestesi.contains(mapResult.get("idProduk"))) {
								percentage = persenOperator;
							} else if ((Integer) mapResult
									.get("idJenisPelaksana") == Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA) {
								percentage = persenOperator;
							} else {
								percentage = persenCooperator;
							}
						} else {
							if ((Integer) mapResult
									.get("idJenisPelaksana") == Master.JenisPetugasPelaksana.ASISTEN_SPESIALIS) {
								percentage = persenCooperator;
							} else {
								percentage = persenOperator;
							}
						}

						percentage = percentage / 100;
						point = getPoin(harga, percentage, komponenDasar);
						pointQty = point * totalProduk.doubleValue();
						formatPointQty = Double.parseDouble(df.format(pointQty));

						mapResult.put("totalKonsul", totalKonsul.longValue());
						mapResult.put("totalVisit", totalVisit.longValue());
						mapResult.put("totalTindakan", totalTindakan.longValue());
						mapResult.put("totalProduk", totalProduk.longValue());
						mapResult.put("datas", datas);
						mapResult.put("poin", point);
						mapResult.put("pointQty", formatPointQty);

						result.add(mapResult);
					}
				}
			}
		}

		return result;
	}

	@Override
	public List<Map<String, Object>> getAllTindakanByDokterReportReview(String periode, Integer idPegawai,
			Integer idAlternatif) {
		List<Map<String, Object>> result = new ArrayList<>();
		List<Map<String, Object>> rawResult = new ArrayList<>();
		List<Map<String, Object>> countResult = new ArrayList<>();

		List<Integer> listProdukId = new ArrayList<>();
		List<Integer> listKelasId = new ArrayList<>();
		List<Integer> listPelaksanaId = new ArrayList<>();
		List<Integer> listDetailJenisProduk = new ArrayList<>();
		List<Integer> listDetailJenisProdukException = new ArrayList<>();
		List<String> listTanggalPelayanan = new ArrayList<>();

		DecimalFormat df = new DecimalFormat("#.##");
		DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

		LocalDateTime PSBBDate = LocalDateTime.of(2020, 9, 14, 0, 0, 0);
		LocalDateTime PSBBEnd = LocalDateTime.parse(GetSettingDataFixed("psbbperiod"), dtf);

		Double harga = 0.0;
		Double point = 0.0;
		Double pointQty = 0.0;
		Double percentage = 0.0;
		Double totalPoint = 0.0;
		Long tindakanTotal = 0L;

		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
		Date datePeriode = new Date();
		try {
			datePeriode = dateFormat.parse(periode);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		Date dateAkhirTarifLama = batasAkhirTarifLama();
		boolean isSatuTarif = false;

		int maxday = monitoringAbsenService.iterateDate(periode + "-01");

		List<Integer> drAnastesiList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_ANESTESI);
		List<Integer> drKsmUmumList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_UMUM);
		List<Integer> drKkPediatrikGDList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PEDIATRIK_GD);
		List<Integer> drKkPerinatologiList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PERINATOLOGI);
		List<Integer> laboranRadiologList = mapPegawaiLaboratRadiologiDao.findPegawaiLaboranRadiolog();

		List<Integer> idsRegDJPAdminNonPK = splitDataSettingDatafixed("admin_nonpk");
		List<Integer> idsRegDJPMedisUtama = splitDataSettingDatafixed("medis_utama");
		List<Integer> idsRegDJPPenunjangPA = splitDataSettingDatafixed("penunjang_pa");
		List<Integer> idsRegDJPPenunjangPK = splitDataSettingDatafixed("penunjang_pk");
		List<Integer> idsRegDJPPenunjangRad = splitDataSettingDatafixed("penunjang_radiologi");

		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPA;
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPK;
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangRad;
		} else {
			listDetailJenisProduk = idsRegDJPMedisUtama;
		}

		if (laboranRadiologList.contains(idPegawai)) {
			listDetailJenisProdukException = idsRegDJPAdminNonPK;
			listDetailJenisProdukException.removeAll(listDetailJenisProduk);
		}

		List<Map<String, Object>> listData = revIndekKinerjaDao.getAllTindakanDokter(Master.Kelas.KELAS_SATU, idPegawai,
				Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA, periode);

		List<Integer> idsDokterUmumIGD = splitDataSettingDatafixed("pr_dokter_umum_igd");
		List<Integer> idsDokterPediatrikGD = splitDataSettingDatafixed("pr_dokter_pediatrik_gd");
		List<Integer> idsDokterPerinatologi = splitDataSettingDatafixed("pr_dokter_perinatologi");
		List<Integer> idsPenunjangBukanAnestesi = splitDataSettingDatafixed("pr_penunjang_nonanestesi");
		Double komponenDasar = Double.parseDouble(GetSettingDataFixed("ld_komponen_dasar"));
		Double persenOperator = Double.parseDouble(GetSettingDataFixed("ld_persen_operator"));
		Double persenCooperator = Double.parseDouble(GetSettingDataFixed("ld_persen_cooperator"));
		if (datePeriode.before(dateAkhirTarifLama) || datePeriode.equals(dateAkhirTarifLama)) {
			komponenDasar = 45_000.0;
			persenOperator = 30.0;
			persenCooperator = 15.0;
			isSatuTarif = true;
		} else if (idAlternatif == 1 && datePeriode.after(dateAkhirTarifLama)) {
			komponenDasar = 120_000.0;
			persenOperator = 60.0;
			persenCooperator = 30.0;
		} else if (idAlternatif == 2 && datePeriode.after(dateAkhirTarifLama)) {
			komponenDasar = 210_000.0;
			persenOperator = 70.0;
			persenCooperator = 35.0;
		} else if (idAlternatif == 3 && datePeriode.after(dateAkhirTarifLama)) {
			komponenDasar = 120_000.0;
			persenOperator = 40.0;
			persenCooperator = 20.0;
		} else if (idAlternatif == 4 && datePeriode.after(dateAkhirTarifLama)) {
			komponenDasar = 210_000.0;
			persenOperator = 40.0;
			persenCooperator = 20.0;
		} else if (idAlternatif == 5 && datePeriode.after(dateAkhirTarifLama)) {
			komponenDasar = 80_000.0;
			persenOperator = 40.0;
			persenCooperator = 20.0;
		} else if (idAlternatif == 6 && datePeriode.after(dateAkhirTarifLama)) {
			komponenDasar = 120_000.0;
			persenOperator = 50.0;
			persenCooperator = 25.0;
		}

		// LOGIC_RULES_REMUN
		if (CommonUtil.isNotNullOrEmpty(listData)) {
			for (Map<String, Object> map : listData) {
				if (drKkPediatrikGDList.contains(map.get("idPegawai"))) {
					if (idsDokterPediatrikGD.contains(map.get("idProduk"))) {
						rawResult.add(map);
					} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
						Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
						String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
						String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
						LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
						LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
						LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

						String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
								+ map.get("jamMasuk").toString().substring(3) + ":00";
						LocalTime timeMasuk = LocalTime.parse(jamMasuk);
						LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

						String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
								+ map.get("jamPulang").toString().substring(3) + ":00";
						LocalTime timePulang = LocalTime.parse(jamPulang);
						LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

						if (map.get("namaShift").toString().contains("Malam")) {
							datePulang = datePulang.plusDays(1);
						}

						if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulang))) {
							rawResult.add(map);
						}
					} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
							.contains(Integer.parseInt(map.get("departemenId").toString()))) {
						if (map.get("namaProduk").toString().toLowerCase().contains(Master.VISIT)
								&& map.get("idPegawai").toString().equals(map.get("idDPJP"))) {
							rawResult.add(map);
						}
					}
				} else if (!drKkPediatrikGDList.contains(map.get("idPegawai"))) {
					if (listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))) {
						if (idsRegDJPPenunjangPA.contains(Integer.parseInt(map.get("detailId").toString()))
								|| idsRegDJPPenunjangPK.contains(Integer.parseInt(map.get("detailId").toString()))) {
							rawResult.add(map);
						} else if (Master.KelompokPasien.BPJS
								.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.KEMENKES
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.JAMKESDA
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
							rawResult.add(map);
						} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
							Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
							String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
							String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
							LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
							LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
							LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

							String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
									+ map.get("jamMasuk").toString().substring(3) + ":00";
							LocalTime timeMasuk = LocalTime.parse(jamMasuk);
							LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

							String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
									+ map.get("jamPulang").toString().substring(3) + ":00";
							LocalTime timePulang = LocalTime.parse(jamPulang);
							LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

							String jamPulangPSBB = "";
							LocalTime timePulangPSBB = LocalTime.now();
							LocalDateTime datePulangPSBB = LocalDateTime.now();
							if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
								jamPulangPSBB = "14:00:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
								jamPulangPSBB = "14:30:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else {
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
							}

							if (map.get("namaShift").toString().contains("Malam")) {
								datePulang = datePulang.plusDays(1);
							}

							if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								rawResult.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))) {
								rawResult.add(map);
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))
									&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
											.contains(Integer.parseInt(map.get("idKelas").toString()))) {
								rawResult.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
									&& map.get("namaShift").toString().equals("Non Shift")
									&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
									&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
									&& (dateTimePelayanan.isBefore(PSBBEnd) || dateTimePelayanan.isEqual(PSBBEnd))) {
								if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulangPSBB))) {
									rawResult.add(map);
								}
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& (dateTimePelayanan.isBefore(datePulang)
													|| dateTimePelayanan.isEqual(datePulang)))) {
								rawResult.add(map);
							}
						} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
								&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
										.contains(Integer.parseInt(map.get("idKelas").toString()))) {
							rawResult.add(map);
						}
					} else if (!listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))
							&& map.get("departemenId").equals(Master.Departemen.IGD)
							&& drKsmUmumList.contains(idPegawai)
							&& idsDokterUmumIGD.contains(Integer.parseInt(map.get("idProduk").toString()))) {
						if (Master.KelompokPasien.BPJS.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.KEMENKES
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.JAMKESDA
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
							rawResult.add(map);
						} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
							Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
							String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
							String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
							LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
							LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
							LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

							String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
									+ map.get("jamMasuk").toString().substring(3) + ":00";
							LocalTime timeMasuk = LocalTime.parse(jamMasuk);
							LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

							String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
									+ map.get("jamPulang").toString().substring(3) + ":00";
							LocalTime timePulang = LocalTime.parse(jamPulang);
							LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

							String jamPulangPSBB = "";
							LocalTime timePulangPSBB = LocalTime.now();
							LocalDateTime datePulangPSBB = LocalDateTime.now();
							if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
								jamPulangPSBB = "14:00:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
								jamPulangPSBB = "14:30:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else {
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
							}

							if (map.get("namaShift").toString().contains("Malam")) {
								datePulang = datePulang.plusDays(1);
							}

							if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								rawResult.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))) {
								rawResult.add(map);
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))
									&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
											.contains(Integer.parseInt(map.get("idKelas").toString()))) {
								rawResult.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
									&& map.get("namaShift").toString().equals("Non Shift")
									&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
									&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
									&& (dateTimePelayanan.isBefore(PSBBEnd) || dateTimePelayanan.isEqual(PSBBEnd))) {
								if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulangPSBB))) {
									rawResult.add(map);
								}
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								rawResult.add(map);
							}
						} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
								&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
										.contains(Integer.parseInt(map.get("idKelas").toString()))) {
							rawResult.add(map);
						}
					} else if (!listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))
							&& drKkPerinatologiList.contains(idPegawai)
							&& idsDokterPerinatologi.contains(Integer.parseInt(map.get("idProduk").toString()))) {
						if (Master.KelompokPasien.BPJS.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.KEMENKES
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.JAMKESDA
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
							rawResult.add(map);
						} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
							Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
							String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
							String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
							LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
							LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
							LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

							String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
									+ map.get("jamMasuk").toString().substring(3) + ":00";
							LocalTime timeMasuk = LocalTime.parse(jamMasuk);
							LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

							String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
									+ map.get("jamPulang").toString().substring(3) + ":00";
							LocalTime timePulang = LocalTime.parse(jamPulang);
							LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

							String jamPulangPSBB = "";
							LocalTime timePulangPSBB = LocalTime.now();
							LocalDateTime datePulangPSBB = LocalDateTime.now();
							if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
								jamPulangPSBB = "14:00:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
								jamPulangPSBB = "14:30:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else {
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
							}

							if (map.get("namaShift").toString().contains("Malam")) {
								datePulang = datePulang.plusDays(1);
							}

							if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								rawResult.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))) {
								rawResult.add(map);
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))
									&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
											.contains(Integer.parseInt(map.get("idKelas").toString()))) {
								rawResult.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
									&& map.get("namaShift").toString().equals("Non Shift")
									&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
									&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
									&& (dateTimePelayanan.isBefore(PSBBEnd) || dateTimePelayanan.isEqual(PSBBEnd))) {
								if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulangPSBB))) {
									rawResult.add(map);
								}
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								rawResult.add(map);
							}
						} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
								&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
										.contains(Integer.parseInt(map.get("idKelas").toString()))) {
							rawResult.add(map);
						}
					} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProdukException)
							&& listDetailJenisProdukException
									.contains(Integer.parseInt(map.get("detailId").toString()))) {
						if (idsRegDJPPenunjangPA.contains(Integer.parseInt(map.get("detailId").toString()))
								|| idsRegDJPPenunjangPK.contains(Integer.parseInt(map.get("detailId").toString()))) {
							rawResult.add(map);
						} else if (Master.KelompokPasien.BPJS
								.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.KEMENKES
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.JAMKESDA
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
							rawResult.add(map);
						} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
							Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
							String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
							String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
							LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
							LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
							LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

							String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
									+ map.get("jamMasuk").toString().substring(3) + ":00";
							LocalTime timeMasuk = LocalTime.parse(jamMasuk);
							LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

							String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
									+ map.get("jamPulang").toString().substring(3) + ":00";
							LocalTime timePulang = LocalTime.parse(jamPulang);
							LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

							String jamPulangPSBB = "";
							LocalTime timePulangPSBB = LocalTime.now();
							LocalDateTime datePulangPSBB = LocalDateTime.now();
							if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
								jamPulangPSBB = "14:00:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
								jamPulangPSBB = "14:30:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else {
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
							}

							if (map.get("namaShift").toString().contains("Malam")) {
								datePulang = datePulang.plusDays(1);
							}

							if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								rawResult.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))) {
								rawResult.add(map);
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isAfter(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))
									&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
											.contains(Integer.parseInt(map.get("idKelas").toString()))) {
								rawResult.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
									&& map.get("namaShift").toString().equals("Non Shift")
									&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
									&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
									&& (dateTimePelayanan.isBefore(PSBBEnd) || dateTimePelayanan.isEqual(PSBBEnd))) {
								if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulangPSBB))) {
									rawResult.add(map);
								}
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								rawResult.add(map);
							}
						} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
								&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
										.contains(Integer.parseInt(map.get("idKelas").toString()))) {
							rawResult.add(map);
						}
					}
				}
			}
		}

		if (CommonUtil.isNotNullOrEmpty(rawResult)) {
			for (Map<String, Object> map : rawResult) {
				if (!Arrays.asList(Master.JenisPetugasPelaksana.DOKTER_ANASTESI_OR_ASISTEN_SPESIALIS)
						.contains(Integer.parseInt(map.get("idJenisPelaksana").toString()))) {
					map.put("idJenisPelaksana", Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA);
				}
				if (!listProdukId.contains(Integer.parseInt(map.get("idProduk").toString()))) {
					listProdukId.add(Integer.parseInt(map.get("idProduk").toString()));
				}
				if (!listKelasId.contains(Integer.parseInt(map.get("idKelas").toString()))) {
					listKelasId.add(Integer.parseInt(map.get("idKelas").toString()));
				}
				if (!listTanggalPelayanan.contains(map.get("tanggal").toString())) {
					listTanggalPelayanan.add(map.get("tanggal").toString());
				}
				if (!listPelaksanaId.contains(Integer.parseInt(map.get("idJenisPelaksana").toString()))) {
					listPelaksanaId.add(Integer.parseInt(map.get("idJenisPelaksana").toString()));
				}
			}

			Collections.sort(listKelasId, Collections.reverseOrder());
			for (Integer idProduk : listProdukId) {
				for (Integer idKelas : listKelasId) {
					for (Integer idPelaksana : listPelaksanaId) {
						for (String tanggal : listTanggalPelayanan) {
							Map<String, Object> mapResult1 = new HashMap<>();
							Map<String, Object> mapResult2 = new HashMap<>();
							double count1 = 0.0;
							double count2 = 0.0;
							int dataCount1 = 0;
							int dataCount2 = 0;
							for (Map<String, Object> map : rawResult) {
								if (Integer.parseInt(map.get("idProduk").toString()) == idProduk
										&& Integer.parseInt(map.get("idKelas").toString()) == idKelas
										&& Integer.parseInt(map.get("idJenisPelaksana").toString()) == idPelaksana
										&& map.get("tanggal").toString().equals(tanggal)
										&& (Double.valueOf(map.get("diskon").toString()) > 0
												&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
														.valueOf(map.get("statusDiskon").toString()).equals(0)))) {
									if (drKkPerinatologiList.contains(idPegawai)) {
										if ((Arrays.asList(Master.Produk.MONITORING_INTERVENSI)
												.contains(map.get("idProduk"))
												|| map.get("namaProduk").toString().toLowerCase()
														.contains(Master.VISIT))
												&& count1 < 2) {
											count1 = count1 + Double.parseDouble(map.get("count").toString());
										} else if (!Arrays.asList(Master.Produk.MONITORING_INTERVENSI)
												.contains(map.get("idProduk"))
												&& !map.get("namaProduk").toString().toLowerCase()
														.contains(Master.VISIT)) {
											count1 = count1 + Double.parseDouble(map.get("count").toString());
										}
									} else {
										count1 = count1 + Double.parseDouble(map.get("count").toString());
									}
									dataCount1 = dataCount1 + 1;
									if (dataCount1 == 1) {
										mapResult1.putAll(map);
									}
								} else if (Integer.parseInt(map.get("idProduk").toString()) == idProduk
										&& Integer.parseInt(map.get("idKelas").toString()) == idKelas
										&& Integer.parseInt(map.get("idJenisPelaksana").toString()) == idPelaksana
										&& map.get("tanggal").toString().equals(tanggal)) {
									if (drKkPerinatologiList.contains(idPegawai)) {
										if ((Arrays.asList(Master.Produk.MONITORING_INTERVENSI)
												.contains(map.get("idProduk"))
												|| map.get("namaProduk").toString().toLowerCase()
														.contains(Master.VISIT))
												&& count2 < 2) {
											count2 = count2 + Double.parseDouble(map.get("count").toString());
										} else if (!Arrays.asList(Master.Produk.MONITORING_INTERVENSI)
												.contains(map.get("idProduk"))
												&& !map.get("namaProduk").toString().toLowerCase()
														.contains(Master.VISIT)) {
											count2 = count2 + Double.parseDouble(map.get("count").toString());
										}
									} else {
										count2 = count2 + Double.parseDouble(map.get("count").toString());
									}
									dataCount2 = dataCount2 + 1;
									if (dataCount2 == 1) {
										mapResult2.putAll(map);
									}
								}
							}
							if (CommonUtil.isNotNullOrEmpty(mapResult1.get("count"))) {
								mapResult1.put("count", count1);
								countResult.add(mapResult1);
							}
							if (CommonUtil.isNotNullOrEmpty(mapResult2.get("count"))) {
								mapResult2.put("count", count2);
								countResult.add(mapResult2);
							}
						}
					}
				}
			}

			for (Integer idProduk : listProdukId) {
				for (Integer idKelas : listKelasId) {
					for (Integer idPelaksana : listPelaksanaId) {
						Map<String, Object> mapResult1 = new HashMap<>();
						Map<String, Object> mapResult2 = new HashMap<>();
						List<Map<String, Object>> datas1 = new ArrayList<>();
						List<Map<String, Object>> datas2 = new ArrayList<>();
						Double totalTindakan1 = 0.0;
						Double totalTindakan2 = 0.0;
						int counter1 = 0;
						int counter2 = 0;
						boolean isDiskonJasamedis1 = false;
						boolean isDiskonJasamedis2 = false;
						for (Map<String, Object> map : countResult) {
							Map<String, Object> countMap = new HashMap<>();
							if (Integer.parseInt(map.get("idProduk").toString()) == idProduk
									&& Integer.parseInt(map.get("idKelas").toString()) == idKelas
									&& Integer.parseInt(map.get("idJenisPelaksana").toString()) == idPelaksana
									&& (Double.valueOf(map.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
													.valueOf(map.get("statusDiskon").toString()).equals(0)))) {
								countMap.put("count", map.get("count"));
								if (isSatuTarif && CommonUtil.isNotNullOrEmpty(map.get("hargaKelas1"))) {
									countMap.put("harga", map.get("hargaKelas1"));
								} else {
									countMap.put("harga", map.get("harga"));
								}
								countMap.put("tanggal", map.get("tanggal"));
								datas1.add(countMap);
								totalTindakan1 = totalTindakan1 + Double.parseDouble(map.get("count").toString());

								String tgl = map.get("tanggal").toString().substring(8, 10);
								Long count = (new Double(Double.parseDouble(map.get("count").toString()))).longValue();
								mapResult1.put(tgl, count.toString());

								counter1 = counter1 + 1;
								if (counter1 == 1) {
									mapResult1.putAll(map);
								}
							} else if (Integer.parseInt(map.get("idProduk").toString()) == idProduk
									&& Integer.parseInt(map.get("idKelas").toString()) == idKelas
									&& Integer.parseInt(map.get("idJenisPelaksana").toString()) == idPelaksana) {
								countMap.put("count", map.get("count"));
								if (isSatuTarif && CommonUtil.isNotNullOrEmpty(map.get("hargaKelas1"))) {
									countMap.put("harga", map.get("hargaKelas1"));
								} else {
									countMap.put("harga", map.get("harga"));
								}
								countMap.put("tanggal", map.get("tanggal"));
								datas2.add(countMap);
								totalTindakan2 = totalTindakan2 + Double.parseDouble(map.get("count").toString());

								String tgl = map.get("tanggal").toString().substring(8, 10);
								Long count = (new Double(Double.parseDouble(map.get("count").toString()))).longValue();
								mapResult2.put(tgl, count.toString());

								counter2 = counter2 + 1;
								if (counter2 == 1) {
									mapResult2.putAll(map);
								}
							}
						}
						if (CommonUtil.isNotNullOrEmpty(mapResult1.get("count"))) {
							if (isSatuTarif) {
								if (CommonUtil.isNotNullOrEmpty(mapResult1.get("hargaKelas1"))) {
									harga = Double.parseDouble(mapResult1.get("hargaKelas1").toString());
								} else {
									harga = Double.parseDouble(mapResult1.get("harga").toString());
								}
							} else {
								harga = Double.parseDouble(mapResult1.get("harga").toString());
							}

							if (drAnastesiList.contains(idPegawai)) {
								if (idsPenunjangBukanAnestesi.contains(mapResult1.get("idProduk"))) {
									percentage = persenOperator;
								} else if ((Integer) mapResult1
										.get("idJenisPelaksana") == Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA) {
									percentage = persenOperator;
									if (Double.parseDouble(mapResult1.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(mapResult1.get("statusDiskon")) || Integer
													.valueOf(mapResult1.get("statusDiskon").toString()).equals(0))) {
										Double totalDiskonJasamedis = pelayananPasienDetailDao
												.totalDiskonJasamedis(mapResult1.get("noRec").toString());
										if (CommonUtil.isNotNullOrEmpty(totalDiskonJasamedis)
												&& totalDiskonJasamedis > 0.0) {
											isDiskonJasamedis1 = true;
										}
									}
								} else {
									percentage = persenCooperator;
								}
							} else {
								if ((Integer) mapResult1
										.get("idJenisPelaksana") == Master.JenisPetugasPelaksana.ASISTEN_SPESIALIS) {
									percentage = persenCooperator;
								} else {
									percentage = persenOperator;
									if (Double.parseDouble(mapResult1.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(mapResult1.get("statusDiskon")) || Integer
													.valueOf(mapResult1.get("statusDiskon").toString()).equals(0))) {
										Double totalDiskonJasamedis = pelayananPasienDetailDao
												.totalDiskonJasamedis(mapResult1.get("noRec").toString());
										if (CommonUtil.isNotNullOrEmpty(totalDiskonJasamedis)
												&& totalDiskonJasamedis > 0.0) {
											isDiskonJasamedis1 = true;
										}
									}
								}
							}

							percentage = percentage / 100;
							point = getPoinLogbookDokter(harga, percentage, komponenDasar, isDiskonJasamedis1);
							pointQty = point * totalTindakan1.doubleValue();

							tindakanTotal += totalTindakan1.longValue();
							totalPoint += pointQty;

							mapResult1.put("totalTindakan", totalTindakan1.longValue());
							mapResult1.put("tindakanTotal", tindakanTotal);
							mapResult1.put("datas", datas1);
							mapResult1.put("poin", point);
							mapResult1.put("poins", df.format(point));
							mapResult1.put("pointQty", pointQty);
							mapResult1.put("pointQtys", df.format(pointQty));
							mapResult1.put("totalPoin", totalPoint);
							mapResult1.put("totalPoint", df.format(totalPoint));
							mapResult1.put("hargas", CurrencyUtil.getPriceInINA(harga).replace("Rp.", ""));
							mapResult1.put("maxDay", maxday);
							mapResult1.put("isSatuTarif", isSatuTarif);

							result.add(mapResult1);
						}
						if (CommonUtil.isNotNullOrEmpty(mapResult2.get("count"))) {
							if (isSatuTarif) {
								if (CommonUtil.isNotNullOrEmpty(mapResult2.get("hargaKelas1"))) {
									harga = Double.parseDouble(mapResult2.get("hargaKelas1").toString());
								} else {
									harga = Double.parseDouble(mapResult2.get("harga").toString());
								}
							} else {
								harga = Double.parseDouble(mapResult2.get("harga").toString());
							}

							if (drAnastesiList.contains(idPegawai)) {
								if (idsPenunjangBukanAnestesi.contains(mapResult2.get("idProduk"))) {
									percentage = persenOperator;
								} else if ((Integer) mapResult2
										.get("idJenisPelaksana") == Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA) {
									percentage = persenOperator;
									if (Double.parseDouble(mapResult2.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(mapResult2.get("statusDiskon")) || Integer
													.valueOf(mapResult2.get("statusDiskon").toString()).equals(0))) {
										Double totalDiskonJasamedis = pelayananPasienDetailDao
												.totalDiskonJasamedis(mapResult2.get("noRec").toString());
										if (CommonUtil.isNotNullOrEmpty(totalDiskonJasamedis)
												&& totalDiskonJasamedis > 0.0) {
											isDiskonJasamedis2 = true;
										}
									}
								} else {
									percentage = persenCooperator;
								}
							} else {
								if ((Integer) mapResult2
										.get("idJenisPelaksana") == Master.JenisPetugasPelaksana.ASISTEN_SPESIALIS) {
									percentage = persenCooperator;
								} else {
									percentage = persenOperator;
									if (Double.parseDouble(mapResult2.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(mapResult2.get("statusDiskon")) || Integer
													.valueOf(mapResult2.get("statusDiskon").toString()).equals(0))) {
										Double totalDiskonJasamedis = pelayananPasienDetailDao
												.totalDiskonJasamedis(mapResult2.get("noRec").toString());
										if (CommonUtil.isNotNullOrEmpty(totalDiskonJasamedis)
												&& totalDiskonJasamedis > 0.0) {
											isDiskonJasamedis2 = true;
										}
									}
								}
							}

							percentage = percentage / 100;
							point = getPoinLogbookDokter(harga, percentage, komponenDasar, isDiskonJasamedis2);
							pointQty = point * totalTindakan2.doubleValue();

							tindakanTotal += totalTindakan2.longValue();
							totalPoint += pointQty;

							mapResult2.put("totalTindakan", totalTindakan2.longValue());
							mapResult2.put("tindakanTotal", tindakanTotal);
							mapResult2.put("datas", datas2);
							mapResult2.put("poin", point);
							mapResult2.put("poins", df.format(point));
							mapResult2.put("pointQty", pointQty);
							mapResult2.put("pointQtys", df.format(pointQty));
							mapResult2.put("totalPoin", totalPoint);
							mapResult2.put("totalPoint", df.format(totalPoint));
							mapResult2.put("hargas", CurrencyUtil.getPriceInINA(harga).replace("Rp.", ""));
							mapResult2.put("maxDay", maxday);
							mapResult2.put("isSatuTarif", isSatuTarif);

							result.add(mapResult2);
						}
					}
				}
			}
		}

		return result;
	}

	@Override
	public List<Map<String, Object>> getAllTindakanByDokterForfeeForServiceReview(String periode, Integer idPegawai) {
		List<Map<String, Object>> result = new ArrayList<>();
		List<Map<String, Object>> rawResult = new ArrayList<>();
		List<Map<String, Object>> countResult = new ArrayList<>();

		List<Integer> listProdukId = new ArrayList<>();
		List<Integer> listKelasId = new ArrayList<>();
		List<Integer> listDetailJenisProduk = new ArrayList<>();
		List<Integer> listDetailJenisProdukException = new ArrayList<>();
		List<String> listTanggalPelayanan = new ArrayList<>();

		Double harga = 0.0;
		Double point = 0.0;
		Double pointQty = 0.0;
		Double formatPointQty = 0.0;
		Double percentage = 0.0;

		DecimalFormat df = new DecimalFormat("#.##");
		DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

		LocalDateTime PSBBDate = LocalDateTime.of(2020, 9, 14, 0, 0, 0);
		LocalDateTime PSBBEnd = LocalDateTime.parse(GetSettingDataFixed("psbbperiod"), dtf);

		List<Integer> drAnastesiList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_ANESTESI);
		List<Integer> drKsmUmumList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_UMUM);
		List<Integer> laboranRadiologList = mapPegawaiLaboratRadiologiDao.findPegawaiLaboranRadiolog();

		List<Integer> idsRegDJPAdminNonPK = splitDataSettingDatafixed("admin_nonpk");
		List<Integer> idsRegDJPMedisUtama = splitDataSettingDatafixed("medis_utama");
		List<Integer> idsRegDJPPenunjangPA = splitDataSettingDatafixed("penunjang_pa");
		List<Integer> idsRegDJPPenunjangPK = splitDataSettingDatafixed("penunjang_pk");
		List<Integer> idsRegDJPPenunjangRad = splitDataSettingDatafixed("penunjang_radiologi");

		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPA;
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPK;
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangRad;
		} else {
			listDetailJenisProduk = idsRegDJPMedisUtama;
		}

		if (laboranRadiologList.contains(idPegawai)) {
			listDetailJenisProdukException = idsRegDJPAdminNonPK;
			listDetailJenisProdukException.removeAll(listDetailJenisProduk);
		}

		List<Map<String, Object>> listData = revIndekKinerjaDao.getAllTindakanDokter(Master.Kelas.KELAS_SATU, idPegawai,
				Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA, periode);

		List<Integer> idsDokterUmumIGD = splitDataSettingDatafixed("pr_dokter_umum_igd");
		List<Integer> idsPenunjangBukanAnestesi = splitDataSettingDatafixed("pr_penunjang_nonanestesi");
		Double komponenDasar = Double.parseDouble(GetSettingDataFixed("ld_komponen_dasar"));
		Double persenOperator = Double.parseDouble(GetSettingDataFixed("ld_persen_operator"));
		Double persenCooperator = Double.parseDouble(GetSettingDataFixed("ld_persen_cooperator"));

		// LOGIC_RULES_FFS
		if (CommonUtil.isNotNullOrEmpty(listData)) {
			if (pegawaiDao.getPegawaiByKategoryPegawai(Arrays.asList(Master.KategoryPegawai.DOKTER_LUAR))
					.contains(idPegawai)) {
				for (Map<String, Object> map : listData) {
					if (listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))) {
						rawResult.add(map);
					} else if (!listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))
							&& map.get("departemenId").equals(Master.Departemen.IGD)
							&& drKsmUmumList.contains(idPegawai)
							&& idsDokterUmumIGD.contains(Integer.parseInt(map.get("idProduk").toString()))) {
						rawResult.add(map);
					} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProdukException)
							&& listDetailJenisProdukException
									.contains(Integer.parseInt(map.get("detailId").toString()))) {
						rawResult.add(map);
					} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProduk)
							&& listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))) {
						rawResult.add(map);
					}
				}
			} else {
				for (Map<String, Object> map : listData) {
					if (listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))) {
						if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
							Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
							String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
							String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
							LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
							LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
							LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

							String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
									+ map.get("jamMasuk").toString().substring(3) + ":00";
							LocalTime timeMasuk = LocalTime.parse(jamMasuk);
							LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

							String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
									+ map.get("jamPulang").toString().substring(3) + ":00";
							LocalTime timePulang = LocalTime.parse(jamPulang);
							LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

							String jamPulangPSBB = "";
							LocalTime timePulangPSBB = LocalTime.now();
							LocalDateTime datePulangPSBB = LocalDateTime.now();
							if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
								jamPulangPSBB = "14:00:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
								jamPulangPSBB = "14:30:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else {
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
							}

							if (map.get("namaShift").toString().contains("Malam")) {
								datePulang = datePulang.plusDays(1);
							}

							if (!Master.KelompokPasien.BPJS
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
								if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
										&& map.get("namaShift").toString().equals("Non Shift")
										&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
										&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
										&& (dateTimePelayanan.isBefore(PSBBEnd)
												|| dateTimePelayanan.isEqual(PSBBEnd))) {
									if ((dateTimePelayanan.isBefore(dateMasuk)
											|| dateTimePelayanan.isEqual(datePulangPSBB)
											|| dateTimePelayanan.isAfter(datePulangPSBB))) {
										rawResult.add(map);
									}
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& (dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulang)
												|| dateTimePelayanan.isAfter(datePulang))) {
									rawResult.add(map);
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
												.contains(Integer.parseInt(map.get("idKelas").toString()))
										&& !Arrays.stream(Master.KONSUL_VISIT)
												.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
										&& (dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulang)
												|| dateTimePelayanan.isAfter(datePulang))) {
									rawResult.add(map);
								}
							}
						} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))) {
							if (!Master.KelompokPasien.BPJS
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
								if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
										.contains(Integer.parseInt(map.get("departemenId").toString()))) {
									rawResult.add(map);
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
												.contains(Integer.parseInt(map.get("idKelas").toString()))) {
									rawResult.add(map);
								}
							}
						}
					} else if (!listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))
							&& map.get("departemenId").equals(Master.Departemen.IGD)
							&& drKsmUmumList.contains(idPegawai)
							&& idsDokterUmumIGD.contains(Integer.parseInt(map.get("idProduk").toString()))) {
						if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
							Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
							String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
							String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
							LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
							LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
							LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

							String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
									+ map.get("jamMasuk").toString().substring(3) + ":00";
							LocalTime timeMasuk = LocalTime.parse(jamMasuk);
							LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

							String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
									+ map.get("jamPulang").toString().substring(3) + ":00";
							LocalTime timePulang = LocalTime.parse(jamPulang);
							LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

							String jamPulangPSBB = "";
							LocalTime timePulangPSBB = LocalTime.now();
							LocalDateTime datePulangPSBB = LocalDateTime.now();
							if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
								jamPulangPSBB = "14:00:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
								jamPulangPSBB = "14:30:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else {
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
							}

							if (map.get("namaShift").toString().contains("Malam")) {
								datePulang = datePulang.plusDays(1);
							}

							if (!Master.KelompokPasien.BPJS
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
								if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
										&& map.get("namaShift").toString().equals("Non Shift")
										&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
										&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
										&& (dateTimePelayanan.isBefore(PSBBEnd)
												|| dateTimePelayanan.isEqual(PSBBEnd))) {
									if ((dateTimePelayanan.isBefore(dateMasuk)
											|| dateTimePelayanan.isEqual(datePulangPSBB)
											|| dateTimePelayanan.isAfter(datePulangPSBB))) {
										rawResult.add(map);
									}
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& (dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulang)
												|| dateTimePelayanan.isAfter(datePulang))) {
									rawResult.add(map);
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
												.contains(Integer.parseInt(map.get("idKelas").toString()))
										&& !Arrays.stream(Master.KONSUL_VISIT)
												.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
										&& (dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulang)
												|| dateTimePelayanan.isAfter(datePulang))) {
									rawResult.add(map);
								}
							}
						} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))) {
							if (!Master.KelompokPasien.BPJS
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
								if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
										.contains(Integer.parseInt(map.get("departemenId").toString()))) {
									rawResult.add(map);
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
												.contains(Integer.parseInt(map.get("idKelas").toString()))) {
									rawResult.add(map);
								}
							}
						}
					} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProdukException)
							&& listDetailJenisProdukException
									.contains(Integer.parseInt(map.get("detailId").toString()))) {
						if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
							Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
							String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
							String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
							LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
							LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
							LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

							String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
									+ map.get("jamMasuk").toString().substring(3) + ":00";
							LocalTime timeMasuk = LocalTime.parse(jamMasuk);
							LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

							String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
									+ map.get("jamPulang").toString().substring(3) + ":00";
							LocalTime timePulang = LocalTime.parse(jamPulang);
							LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

							String jamPulangPSBB = "";
							LocalTime timePulangPSBB = LocalTime.now();
							LocalDateTime datePulangPSBB = LocalDateTime.now();
							if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
								jamPulangPSBB = "14:00:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
								jamPulangPSBB = "14:30:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else {
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
							}

							if (map.get("namaShift").toString().contains("Malam")) {
								datePulang = datePulang.plusDays(1);
							}

							if (!Master.KelompokPasien.BPJS
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
								if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
										&& map.get("namaShift").toString().equals("Non Shift")
										&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
										&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
										&& (dateTimePelayanan.isBefore(PSBBEnd)
												|| dateTimePelayanan.isEqual(PSBBEnd))) {
									if ((dateTimePelayanan.isBefore(dateMasuk)
											|| dateTimePelayanan.isEqual(datePulangPSBB)
											|| dateTimePelayanan.isAfter(datePulangPSBB))) {
										rawResult.add(map);
									}
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& (dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulang)
												|| dateTimePelayanan.isAfter(datePulang))) {
									rawResult.add(map);
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
												.contains(Integer.parseInt(map.get("idKelas").toString()))
										&& !Arrays.stream(Master.KONSUL_VISIT)
												.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
										&& (dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulang)
												|| dateTimePelayanan.isAfter(datePulang))) {
									rawResult.add(map);
								}
							}
						} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))) {
							if (!Master.KelompokPasien.BPJS
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
								if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
										.contains(Integer.parseInt(map.get("departemenId").toString()))) {
									rawResult.add(map);
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
												.contains(Integer.parseInt(map.get("idKelas").toString()))) {
									rawResult.add(map);
								}
							}
						}
					}
				}
			}
		}

		if (CommonUtil.isNotNullOrEmpty(rawResult)) {
			for (Map<String, Object> map : rawResult) {
				if (!Arrays.asList(Master.JenisPetugasPelaksana.DOKTER_ANASTESI_OR_ASISTEN_SPESIALIS)
						.contains(Integer.parseInt(map.get("idJenisPelaksana").toString()))) {
					map.put("idJenisPelaksana", Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA);
				}
				if (!listProdukId.contains(Integer.parseInt(map.get("idProduk").toString()))) {
					listProdukId.add(Integer.parseInt(map.get("idProduk").toString()));
				}
				if (!listKelasId.contains(Integer.parseInt(map.get("idKelas").toString()))) {
					listKelasId.add(Integer.parseInt(map.get("idKelas").toString()));
				}
				if (!listTanggalPelayanan.contains(map.get("tanggal").toString())) {
					listTanggalPelayanan.add(map.get("tanggal").toString());
				}
			}

			Collections.sort(listKelasId, Collections.reverseOrder());
			for (Integer idProduk : listProdukId) {
				for (Integer idKelas : listKelasId) {
					for (String tanggal : listTanggalPelayanan) {
						Map<String, Object> mapResult = new HashMap<>();
						double count = 0.0;
						int dataCount = 0;
						for (Map<String, Object> map : rawResult) {
							if (Integer.parseInt(map.get("idProduk").toString()) == idProduk
									&& Integer.parseInt(map.get("idKelas").toString()) == idKelas
									&& map.get("tanggal").toString().equals(tanggal)) {
								count = count + Double.parseDouble(map.get("count").toString());
								dataCount = dataCount + 1;
								if (dataCount == 1) {
									mapResult.putAll(map);
								}
							}
						}
						if (CommonUtil.isNotNullOrEmpty(mapResult.get("count"))) {
							mapResult.put("count", count);
							countResult.add(mapResult);
						}
					}

				}
			}

			for (Integer idProduk : listProdukId) {
				for (Integer idKelas : listKelasId) {
					Map<String, Object> mapResult = new HashMap<>();
					List<Map<String, Object>> datas = new ArrayList<>();
					Double totalTindakan = 0.0;
					int counter = 0;
					for (Map<String, Object> map : countResult) {
						Map<String, Object> countMap = new HashMap<>();
						if (Integer.parseInt(map.get("idProduk").toString()) == idProduk
								&& Integer.parseInt(map.get("idKelas").toString()) == idKelas) {
							countMap.put("count", map.get("count"));
							if (CommonUtil.isNotNullOrEmpty(map.get("hargaKelas1"))) {
								countMap.put("harga", map.get("hargaKelas1"));
							} else {
								countMap.put("harga", map.get("harga"));
							}
							countMap.put("tanggal", map.get("tanggal"));
							datas.add(countMap);
							totalTindakan = totalTindakan + Double.parseDouble(map.get("count").toString());
							counter = counter + 1;
							if (counter == 1) {
								mapResult.putAll(map);
							}
						}
					}
					if (CommonUtil.isNotNullOrEmpty(mapResult.get("count"))) {
						if (Master.LogbookDokter.IS_TARIF_SATU_HARGA) {
							if (CommonUtil.isNotNullOrEmpty(mapResult.get("hargaKelas1"))) {
								harga = Double.parseDouble(mapResult.get("hargaKelas1").toString());
							} else {
								harga = Double.parseDouble(mapResult.get("harga").toString());
							}
						} else {
							harga = Double.parseDouble(mapResult.get("harga").toString());
						}

						if (drAnastesiList.contains(idPegawai)) {
							if (idsPenunjangBukanAnestesi.contains(mapResult.get("idProduk"))) {
								percentage = persenOperator;
							} else if ((Integer) mapResult
									.get("idJenisPelaksana") == Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA) {
								percentage = persenOperator;
							} else {
								percentage = persenCooperator;
							}
						} else {
							if ((Integer) mapResult
									.get("idJenisPelaksana") == Master.JenisPetugasPelaksana.ASISTEN_SPESIALIS) {
								percentage = persenCooperator;
							} else {
								percentage = persenOperator;
							}
						}

						percentage = percentage / 100;
						point = getPoin(harga, percentage, komponenDasar);
						pointQty = point * totalTindakan.doubleValue();
						formatPointQty = Double.parseDouble(df.format(pointQty));

						mapResult.put("totalTindakan", totalTindakan.longValue());
						mapResult.put("datas", datas);
						mapResult.put("poin", point);
						mapResult.put("pointQty", formatPointQty);

						result.add(mapResult);
					}
				}
			}
		}

		return result;
	}

	@Override
	public List<Map<String, Object>> findPatientDetailForEveryTindakanReview(Integer idProduk, Integer idKelas,
			Integer idPegawai, String tgl, Boolean ffs, Double diskon, Integer statusDiskon) {
		List<Map<String, Object>> result = new ArrayList<>();
		List<Map<String, Object>> listData = new ArrayList<>();

		List<Integer> listDetailJenisProduk = new ArrayList<>();
		List<Integer> listDetailJenisProdukException = new ArrayList<>();

		Chronology iso = ISOChronology.getInstance();
		Chronology hijri = IslamicChronology.getInstance();

		String month = tgl.substring(0, 7);

		DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

		LocalDateTime PSBBDate = LocalDateTime.of(2020, 9, 14, 0, 0, 0);
		LocalDateTime PSBBEnd = LocalDateTime.parse(GetSettingDataFixed("psbbperiod"), dtf);

		List<Integer> laboranRadiologList = mapPegawaiLaboratRadiologiDao.findPegawaiLaboranRadiolog();
		List<Integer> drKsmUmumList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_UMUM);
		List<Integer> drKkPediatrikGDList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PEDIATRIK_GD);
		List<Integer> drKkPerinatologiList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PERINATOLOGI);

		List<Integer> idsRegDJPAdminNonPK = splitDataSettingDatafixed("admin_nonpk");
		List<Integer> idsRegDJPMedisUtama = splitDataSettingDatafixed("medis_utama");
		List<Integer> idsRegDJPPenunjangPA = splitDataSettingDatafixed("penunjang_pa");
		List<Integer> idsRegDJPPenunjangPK = splitDataSettingDatafixed("penunjang_pk");
		List<Integer> idsRegDJPPenunjangRad = splitDataSettingDatafixed("penunjang_radiologi");

		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPA;
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPK;
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangRad;
		} else {
			listDetailJenisProduk = idsRegDJPMedisUtama;
		}

		if (laboranRadiologList.contains(idPegawai)) {
			listDetailJenisProdukException = idsRegDJPAdminNonPK;
			listDetailJenisProdukException.removeAll(listDetailJenisProduk);
		}

		if (CommonUtil.isNotNullOrEmpty(tgl) && tgl.equals(month)) {
			listData = revIndekKinerjaDao.getDetailPasienTindakanDokterPerPeriode(Master.Kelas.KELAS_SATU, idKelas,
					idPegawai, idProduk, Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA, tgl);
		} else {
			listData = revIndekKinerjaDao.getDetailPasienTindakanDokter(Master.Kelas.KELAS_SATU, idKelas, idPegawai,
					idProduk, Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA, tgl);
		}

		List<Integer> idsDokterUmumIGD = splitDataSettingDatafixed("pr_dokter_umum_igd");
		List<Integer> idsDokterPediatrikGD = splitDataSettingDatafixed("pr_dokter_pediatrik_gd");
		List<Integer> idsDokterPerinatologi = splitDataSettingDatafixed("pr_dokter_perinatologi");

		if (!ffs) {
			if (CommonUtil.isNotNullOrEmpty(listData)) {
				for (Map<String, Object> map : listData) {
					if (drKkPediatrikGDList.contains(map.get("idPegawai"))) {
						if (idsDokterPediatrikGD.contains(map.get("idProduk"))) {
							result.add(map);
						} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
							Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
							String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
							String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
							LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
							LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
							LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

							String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
									+ map.get("jamMasuk").toString().substring(3) + ":00";
							LocalTime timeMasuk = LocalTime.parse(jamMasuk);
							LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

							String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
									+ map.get("jamPulang").toString().substring(3) + ":00";
							LocalTime timePulang = LocalTime.parse(jamPulang);
							LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

							if (map.get("namaShift").toString().contains("Malam")) {
								datePulang = datePulang.plusDays(1);
							}

							if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								result.add(map);
							}
						} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
								.contains(Integer.parseInt(map.get("departemenId").toString()))) {
							if (map.get("namaProduk").toString().toLowerCase().contains(Master.VISIT)
									&& map.get("idPegawai").toString().equals(map.get("idDPJP"))) {
								result.add(map);
							}
						}
					} else if (!drKkPediatrikGDList.contains(map.get("idPegawai"))) {
						if (listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))) {
							if (idsRegDJPPenunjangPA.contains(Integer.parseInt(map.get("detailId").toString()))
									|| idsRegDJPPenunjangPK
											.contains(Integer.parseInt(map.get("detailId").toString()))) {
								if (diskon > 0 && (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
									if (Double.valueOf(map.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon"))
													|| Integer.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								} else {
									if (Double.valueOf(map.get("diskon").toString()) == 0
											|| (Double.valueOf(map.get("diskon").toString()) > 0
													&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon")) && !Integer
															.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								}
							} else if (Master.KelompokPasien.BPJS
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
									|| Master.KelompokPasien.KEMENKES
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
									|| Master.KelompokPasien.JAMKESDA
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
								if (diskon > 0 && (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
									if (Double.valueOf(map.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon"))
													|| Integer.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								} else {
									if (Double.valueOf(map.get("diskon").toString()) == 0
											|| (Double.valueOf(map.get("diskon").toString()) > 0
													&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon")) && !Integer
															.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								}
							} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
								Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
								String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
								String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
								LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
								LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
								LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

								String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
										+ map.get("jamMasuk").toString().substring(3) + ":00";
								LocalTime timeMasuk = LocalTime.parse(jamMasuk);
								LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

								String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
										+ map.get("jamPulang").toString().substring(3) + ":00";
								LocalTime timePulang = LocalTime.parse(jamPulang);
								LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

								String jamPulangPSBB = "";
								LocalTime timePulangPSBB = LocalTime.now();
								LocalDateTime datePulangPSBB = LocalDateTime.now();
								if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
									jamPulangPSBB = "14:00:00";
									timePulangPSBB = LocalTime.parse(jamPulangPSBB);
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
								} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
									jamPulangPSBB = "14:30:00";
									timePulangPSBB = LocalTime.parse(jamPulangPSBB);
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
								} else {
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
								}

								if (map.get("namaShift").toString().contains("Malam")) {
									datePulang = datePulang.plusDays(1);
								}

								if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& ((dateTimePelayanan.isEqual(dateMasuk)
												|| dateTimePelayanan.isAfter(dateMasuk))
												&& dateTimePelayanan.isBefore(datePulang))) {
									if (diskon > 0
											&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
										if (Double.valueOf(map.get("diskon").toString()) > 0
												&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
														.valueOf(map.get("statusDiskon").toString()).equals(0))) {
											result.add(map);
										}
									} else {
										if (Double.valueOf(map.get("diskon").toString()) == 0
												|| (Double.valueOf(map.get("diskon").toString()) > 0
														&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
														&& !Integer.valueOf(map.get("statusDiskon").toString())
																.equals(0))) {
											result.add(map);
										}
									}
								} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
										&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
										&& Arrays.stream(Master.KONSUL_VISIT)
												.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
										&& (dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulang)
												|| dateTimePelayanan.isAfter(datePulang))) {
									if (diskon > 0
											&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
										if (Double.valueOf(map.get("diskon").toString()) > 0
												&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
														.valueOf(map.get("statusDiskon").toString()).equals(0))) {
											result.add(map);
										}
									} else {
										if (Double.valueOf(map.get("diskon").toString()) == 0
												|| (Double.valueOf(map.get("diskon").toString()) > 0
														&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
														&& !Integer.valueOf(map.get("statusDiskon").toString())
																.equals(0))) {
											result.add(map);
										}
									}
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& (dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulang)
												|| dateTimePelayanan.isAfter(datePulang))
										&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
												.contains(Integer.parseInt(map.get("idKelas").toString()))) {
									if (diskon > 0
											&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
										if (Double.valueOf(map.get("diskon").toString()) > 0
												&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
														.valueOf(map.get("statusDiskon").toString()).equals(0))) {
											result.add(map);
										}
									} else {
										if (Double.valueOf(map.get("diskon").toString()) == 0
												|| (Double.valueOf(map.get("diskon").toString()) > 0
														&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
														&& !Integer.valueOf(map.get("statusDiskon").toString())
																.equals(0))) {
											result.add(map);
										}
									}
								} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
										&& map.get("namaShift").toString().equals("Non Shift")
										&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
										&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
										&& (dateTimePelayanan.isBefore(PSBBEnd)
												|| dateTimePelayanan.isEqual(PSBBEnd))) {
									if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulangPSBB))) {
										if (diskon > 0
												&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
											if (Double.valueOf(map.get("diskon").toString()) > 0
													&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
															.valueOf(map.get("statusDiskon").toString()).equals(0))) {
												result.add(map);
											}
										} else {
											if (Double.valueOf(map.get("diskon").toString()) == 0
													|| (Double.valueOf(map.get("diskon").toString()) > 0
															&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
															&& !Integer.valueOf(map.get("statusDiskon").toString())
																	.equals(0))) {
												result.add(map);
											}
										}
									}
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& ((dateTimePelayanan.isEqual(dateMasuk)
												|| dateTimePelayanan.isAfter(dateMasuk))
												&& dateTimePelayanan.isBefore(datePulang))) {
									if (diskon > 0
											&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
										if (Double.valueOf(map.get("diskon").toString()) > 0
												&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
														.valueOf(map.get("statusDiskon").toString()).equals(0))) {
											result.add(map);
										}
									} else {
										if (Double.valueOf(map.get("diskon").toString()) == 0
												|| (Double.valueOf(map.get("diskon").toString()) > 0
														&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
														&& !Integer.valueOf(map.get("statusDiskon").toString())
																.equals(0))) {
											result.add(map);
										}
									}
								}
							} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
									&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
											.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
											.contains(Integer.parseInt(map.get("idKelas").toString()))) {
								if (diskon > 0 && (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
									if (Double.valueOf(map.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon"))
													|| Integer.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								} else {
									if (Double.valueOf(map.get("diskon").toString()) == 0
											|| (Double.valueOf(map.get("diskon").toString()) > 0
													&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon")) && !Integer
															.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								}
							}
						} else if (!listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))
								&& map.get("departemenId").equals(Master.Departemen.IGD)
								&& drKsmUmumList.contains(idPegawai)
								&& idsDokterUmumIGD.contains(Integer.parseInt(map.get("idProduk").toString()))) {
							if (Master.KelompokPasien.BPJS
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
									|| Master.KelompokPasien.KEMENKES
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
									|| Master.KelompokPasien.JAMKESDA
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
								if (diskon > 0 && (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
									if (Double.valueOf(map.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon"))
													|| Integer.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								} else {
									if (Double.valueOf(map.get("diskon").toString()) == 0
											|| (Double.valueOf(map.get("diskon").toString()) > 0
													&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon")) && !Integer
															.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								}
							} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
								Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
								String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
								String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
								LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
								LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
								LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

								String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
										+ map.get("jamMasuk").toString().substring(3) + ":00";
								LocalTime timeMasuk = LocalTime.parse(jamMasuk);
								LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

								String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
										+ map.get("jamPulang").toString().substring(3) + ":00";
								LocalTime timePulang = LocalTime.parse(jamPulang);
								LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

								String jamPulangPSBB = "";
								LocalTime timePulangPSBB = LocalTime.now();
								LocalDateTime datePulangPSBB = LocalDateTime.now();
								if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
									jamPulangPSBB = "14:00:00";
									timePulangPSBB = LocalTime.parse(jamPulangPSBB);
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
								} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
									jamPulangPSBB = "14:30:00";
									timePulangPSBB = LocalTime.parse(jamPulangPSBB);
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
								} else {
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
								}

								if (map.get("namaShift").toString().contains("Malam")) {
									datePulang = datePulang.plusDays(1);
								}

								if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& ((dateTimePelayanan.isEqual(dateMasuk)
												|| dateTimePelayanan.isAfter(dateMasuk))
												&& dateTimePelayanan.isBefore(datePulang))) {
									if (diskon > 0
											&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
										if (Double.valueOf(map.get("diskon").toString()) > 0
												&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
														.valueOf(map.get("statusDiskon").toString()).equals(0))) {
											result.add(map);
										}
									} else {
										if (Double.valueOf(map.get("diskon").toString()) == 0
												|| (Double.valueOf(map.get("diskon").toString()) > 0
														&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
														&& !Integer.valueOf(map.get("statusDiskon").toString())
																.equals(0))) {
											result.add(map);
										}
									}
								} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
										&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
										&& Arrays.stream(Master.KONSUL_VISIT)
												.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
										&& (dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulang)
												|| dateTimePelayanan.isAfter(datePulang))) {
									if (diskon > 0
											&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
										if (Double.valueOf(map.get("diskon").toString()) > 0
												&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
														.valueOf(map.get("statusDiskon").toString()).equals(0))) {
											result.add(map);
										}
									} else {
										if (Double.valueOf(map.get("diskon").toString()) == 0
												|| (Double.valueOf(map.get("diskon").toString()) > 0
														&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
														&& !Integer.valueOf(map.get("statusDiskon").toString())
																.equals(0))) {
											result.add(map);
										}
									}
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& (dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulang)
												|| dateTimePelayanan.isAfter(datePulang))
										&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
												.contains(Integer.parseInt(map.get("idKelas").toString()))) {
									if (diskon > 0
											&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
										if (Double.valueOf(map.get("diskon").toString()) > 0
												&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
														.valueOf(map.get("statusDiskon").toString()).equals(0))) {
											result.add(map);
										}
									} else {
										if (Double.valueOf(map.get("diskon").toString()) == 0
												|| (Double.valueOf(map.get("diskon").toString()) > 0
														&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
														&& !Integer.valueOf(map.get("statusDiskon").toString())
																.equals(0))) {
											result.add(map);
										}
									}
								} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
										&& map.get("namaShift").toString().equals("Non Shift")
										&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
										&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
										&& (dateTimePelayanan.isBefore(PSBBEnd)
												|| dateTimePelayanan.isEqual(PSBBEnd))) {
									if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulangPSBB))) {
										if (diskon > 0
												&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
											if (Double.valueOf(map.get("diskon").toString()) > 0
													&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
															.valueOf(map.get("statusDiskon").toString()).equals(0))) {
												result.add(map);
											}
										} else {
											if (Double.valueOf(map.get("diskon").toString()) == 0
													|| (Double.valueOf(map.get("diskon").toString()) > 0
															&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
															&& !Integer.valueOf(map.get("statusDiskon").toString())
																	.equals(0))) {
												result.add(map);
											}
										}
									}
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& ((dateTimePelayanan.isEqual(dateMasuk)
												|| dateTimePelayanan.isAfter(dateMasuk))
												&& dateTimePelayanan.isBefore(datePulang))) {
									if (diskon > 0
											&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
										if (Double.valueOf(map.get("diskon").toString()) > 0
												&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
														.valueOf(map.get("statusDiskon").toString()).equals(0))) {
											result.add(map);
										}
									} else {
										if (Double.valueOf(map.get("diskon").toString()) == 0
												|| (Double.valueOf(map.get("diskon").toString()) > 0
														&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
														&& !Integer.valueOf(map.get("statusDiskon").toString())
																.equals(0))) {
											result.add(map);
										}
									}
								}
							} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
									&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
											.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
											.contains(Integer.parseInt(map.get("idKelas").toString()))) {
								if (diskon > 0 && (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
									if (Double.valueOf(map.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon"))
													|| Integer.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								} else {
									if (Double.valueOf(map.get("diskon").toString()) == 0
											|| (Double.valueOf(map.get("diskon").toString()) > 0
													&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon")) && !Integer
															.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								}
							}
						} else if (!listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))
								&& drKkPerinatologiList.contains(idPegawai)
								&& idsDokterPerinatologi.contains(Integer.parseInt(map.get("idProduk").toString()))) {
							if (Master.KelompokPasien.BPJS
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
									|| Master.KelompokPasien.KEMENKES
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
									|| Master.KelompokPasien.JAMKESDA
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
								if (diskon > 0 && (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
									if (Double.valueOf(map.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon"))
													|| Integer.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								} else {
									if (Double.valueOf(map.get("diskon").toString()) == 0
											|| (Double.valueOf(map.get("diskon").toString()) > 0
													&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon")) && !Integer
															.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								}
							} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
								Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
								String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
								String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
								LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
								LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
								LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

								String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
										+ map.get("jamMasuk").toString().substring(3) + ":00";
								LocalTime timeMasuk = LocalTime.parse(jamMasuk);
								LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

								String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
										+ map.get("jamPulang").toString().substring(3) + ":00";
								LocalTime timePulang = LocalTime.parse(jamPulang);
								LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

								String jamPulangPSBB = "";
								LocalTime timePulangPSBB = LocalTime.now();
								LocalDateTime datePulangPSBB = LocalDateTime.now();
								if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
									jamPulangPSBB = "14:00:00";
									timePulangPSBB = LocalTime.parse(jamPulangPSBB);
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
								} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
									jamPulangPSBB = "14:30:00";
									timePulangPSBB = LocalTime.parse(jamPulangPSBB);
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
								} else {
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
								}

								if (map.get("namaShift").toString().contains("Malam")) {
									datePulang = datePulang.plusDays(1);
								}

								if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& ((dateTimePelayanan.isEqual(dateMasuk)
												|| dateTimePelayanan.isAfter(dateMasuk))
												&& dateTimePelayanan.isBefore(datePulang))) {
									if (diskon > 0
											&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
										if (Double.valueOf(map.get("diskon").toString()) > 0
												&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
														.valueOf(map.get("statusDiskon").toString()).equals(0))) {
											result.add(map);
										}
									} else {
										if (Double.valueOf(map.get("diskon").toString()) == 0
												|| (Double.valueOf(map.get("diskon").toString()) > 0
														&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
														&& !Integer.valueOf(map.get("statusDiskon").toString())
																.equals(0))) {
											result.add(map);
										}
									}
								} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
										&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
										&& Arrays.stream(Master.KONSUL_VISIT)
												.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
										&& (dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulang)
												|| dateTimePelayanan.isAfter(datePulang))) {
									if (diskon > 0
											&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
										if (Double.valueOf(map.get("diskon").toString()) > 0
												&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
														.valueOf(map.get("statusDiskon").toString()).equals(0))) {
											result.add(map);
										}
									} else {
										if (Double.valueOf(map.get("diskon").toString()) == 0
												|| (Double.valueOf(map.get("diskon").toString()) > 0
														&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
														&& !Integer.valueOf(map.get("statusDiskon").toString())
																.equals(0))) {
											result.add(map);
										}
									}
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& (dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulang)
												|| dateTimePelayanan.isAfter(datePulang))
										&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
												.contains(Integer.parseInt(map.get("idKelas").toString()))) {
									if (diskon > 0
											&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
										if (Double.valueOf(map.get("diskon").toString()) > 0
												&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
														.valueOf(map.get("statusDiskon").toString()).equals(0))) {
											result.add(map);
										}
									} else {
										if (Double.valueOf(map.get("diskon").toString()) == 0
												|| (Double.valueOf(map.get("diskon").toString()) > 0
														&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
														&& !Integer.valueOf(map.get("statusDiskon").toString())
																.equals(0))) {
											result.add(map);
										}
									}
								} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
										&& map.get("namaShift").toString().equals("Non Shift")
										&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
										&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
										&& (dateTimePelayanan.isBefore(PSBBEnd)
												|| dateTimePelayanan.isEqual(PSBBEnd))) {
									if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulangPSBB))) {
										if (diskon > 0
												&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
											if (Double.valueOf(map.get("diskon").toString()) > 0
													&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
															.valueOf(map.get("statusDiskon").toString()).equals(0))) {
												result.add(map);
											}
										} else {
											if (Double.valueOf(map.get("diskon").toString()) == 0
													|| (Double.valueOf(map.get("diskon").toString()) > 0
															&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
															&& !Integer.valueOf(map.get("statusDiskon").toString())
																	.equals(0))) {
												result.add(map);
											}
										}
									}
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& ((dateTimePelayanan.isEqual(dateMasuk)
												|| dateTimePelayanan.isAfter(dateMasuk))
												&& dateTimePelayanan.isBefore(datePulang))) {
									if (diskon > 0
											&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
										if (Double.valueOf(map.get("diskon").toString()) > 0
												&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
														.valueOf(map.get("statusDiskon").toString()).equals(0))) {
											result.add(map);
										}
									} else {
										if (Double.valueOf(map.get("diskon").toString()) == 0
												|| (Double.valueOf(map.get("diskon").toString()) > 0
														&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
														&& !Integer.valueOf(map.get("statusDiskon").toString())
																.equals(0))) {
											result.add(map);
										}
									}
								}
							} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
									&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
											.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
											.contains(Integer.parseInt(map.get("idKelas").toString()))) {
								if (diskon > 0 && (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
									if (Double.valueOf(map.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon"))
													|| Integer.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								} else {
									if (Double.valueOf(map.get("diskon").toString()) == 0
											|| (Double.valueOf(map.get("diskon").toString()) > 0
													&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon")) && !Integer
															.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								}
							}
						} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProdukException)
								&& listDetailJenisProdukException
										.contains(Integer.parseInt(map.get("detailId").toString()))) {
							if (idsRegDJPPenunjangPA.contains(Integer.parseInt(map.get("detailId").toString()))
									|| idsRegDJPPenunjangPK
											.contains(Integer.parseInt(map.get("detailId").toString()))) {
								if (diskon > 0 && (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
									if (Double.valueOf(map.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon"))
													|| Integer.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								} else {
									if (Double.valueOf(map.get("diskon").toString()) == 0
											|| (Double.valueOf(map.get("diskon").toString()) > 0
													&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon")) && !Integer
															.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								}
							} else if (Master.KelompokPasien.BPJS
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
									|| Master.KelompokPasien.KEMENKES
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
									|| Master.KelompokPasien.JAMKESDA
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
								if (diskon > 0 && (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
									if (Double.valueOf(map.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon"))
													|| Integer.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								} else {
									if (Double.valueOf(map.get("diskon").toString()) == 0
											|| (Double.valueOf(map.get("diskon").toString()) > 0
													&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon")) && !Integer
															.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								}
							} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
								Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
								String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
								String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
								LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
								LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
								LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

								String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
										+ map.get("jamMasuk").toString().substring(3) + ":00";
								LocalTime timeMasuk = LocalTime.parse(jamMasuk);
								LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

								String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
										+ map.get("jamPulang").toString().substring(3) + ":00";
								LocalTime timePulang = LocalTime.parse(jamPulang);
								LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

								String jamPulangPSBB = "";
								LocalTime timePulangPSBB = LocalTime.now();
								LocalDateTime datePulangPSBB = LocalDateTime.now();
								if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
									jamPulangPSBB = "14:00:00";
									timePulangPSBB = LocalTime.parse(jamPulangPSBB);
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
								} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
									jamPulangPSBB = "14:30:00";
									timePulangPSBB = LocalTime.parse(jamPulangPSBB);
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
								} else {
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
								}

								if (map.get("namaShift").toString().contains("Malam")) {
									datePulang = datePulang.plusDays(1);
								}

								if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& ((dateTimePelayanan.isEqual(dateMasuk)
												|| dateTimePelayanan.isAfter(dateMasuk))
												&& dateTimePelayanan.isBefore(datePulang))) {
									if (diskon > 0
											&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
										if (Double.valueOf(map.get("diskon").toString()) > 0
												&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
														.valueOf(map.get("statusDiskon").toString()).equals(0))) {
											result.add(map);
										}
									} else {
										if (Double.valueOf(map.get("diskon").toString()) == 0
												|| (Double.valueOf(map.get("diskon").toString()) > 0
														&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
														&& !Integer.valueOf(map.get("statusDiskon").toString())
																.equals(0))) {
											result.add(map);
										}
									}
								} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
										&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
										&& Arrays.stream(Master.KONSUL_VISIT)
												.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
										&& (dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulang)
												|| dateTimePelayanan.isAfter(datePulang))) {
									if (diskon > 0
											&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
										if (Double.valueOf(map.get("diskon").toString()) > 0
												&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
														.valueOf(map.get("statusDiskon").toString()).equals(0))) {
											result.add(map);
										}
									} else {
										if (Double.valueOf(map.get("diskon").toString()) == 0
												|| (Double.valueOf(map.get("diskon").toString()) > 0
														&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
														&& !Integer.valueOf(map.get("statusDiskon").toString())
																.equals(0))) {
											result.add(map);
										}
									}
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& (dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulang)
												|| dateTimePelayanan.isAfter(datePulang))
										&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
												.contains(Integer.parseInt(map.get("idKelas").toString()))) {
									if (diskon > 0
											&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
										if (Double.valueOf(map.get("diskon").toString()) > 0
												&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
														.valueOf(map.get("statusDiskon").toString()).equals(0))) {
											result.add(map);
										}
									} else {
										if (Double.valueOf(map.get("diskon").toString()) == 0
												|| (Double.valueOf(map.get("diskon").toString()) > 0
														&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
														&& !Integer.valueOf(map.get("statusDiskon").toString())
																.equals(0))) {
											result.add(map);
										}
									}
								} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
										&& map.get("namaShift").toString().equals("Non Shift")
										&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
										&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
										&& (dateTimePelayanan.isBefore(PSBBEnd)
												|| dateTimePelayanan.isEqual(PSBBEnd))) {
									if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulangPSBB))) {
										if (diskon > 0
												&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
											if (Double.valueOf(map.get("diskon").toString()) > 0
													&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
															.valueOf(map.get("statusDiskon").toString()).equals(0))) {
												result.add(map);
											}
										} else {
											if (Double.valueOf(map.get("diskon").toString()) == 0
													|| (Double.valueOf(map.get("diskon").toString()) > 0
															&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
															&& !Integer.valueOf(map.get("statusDiskon").toString())
																	.equals(0))) {
												result.add(map);
											}
										}
									}
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& ((dateTimePelayanan.isEqual(dateMasuk)
												|| dateTimePelayanan.isAfter(dateMasuk))
												&& dateTimePelayanan.isBefore(datePulang))) {
									if (diskon > 0
											&& (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
										if (Double.valueOf(map.get("diskon").toString()) > 0
												&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon")) || Integer
														.valueOf(map.get("statusDiskon").toString()).equals(0))) {
											result.add(map);
										}
									} else {
										if (Double.valueOf(map.get("diskon").toString()) == 0
												|| (Double.valueOf(map.get("diskon").toString()) > 0
														&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon"))
														&& !Integer.valueOf(map.get("statusDiskon").toString())
																.equals(0))) {
											result.add(map);
										}
									}
								}
							} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
									&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
											.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
											.contains(Integer.parseInt(map.get("idKelas").toString()))) {
								if (diskon > 0 && (CommonUtil.isNullOrEmpty(statusDiskon) || statusDiskon.equals(0))) {
									if (Double.valueOf(map.get("diskon").toString()) > 0
											&& (CommonUtil.isNullOrEmpty(map.get("statusDiskon"))
													|| Integer.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								} else {
									if (Double.valueOf(map.get("diskon").toString()) == 0
											|| (Double.valueOf(map.get("diskon").toString()) > 0
													&& CommonUtil.isNotNullOrEmpty(map.get("statusDiskon")) && !Integer
															.valueOf(map.get("statusDiskon").toString()).equals(0))) {
										result.add(map);
									}
								}
							}
						}
					}
				}
			}
		} else {
			// FFS : bagian ini sudah tidak dipakai
			if (CommonUtil.isNotNullOrEmpty(listData)) {
				if (pegawaiDao.getPegawaiByKategoryPegawai(Arrays.asList(Master.KategoryPegawai.DOKTER_LUAR))
						.contains(idPegawai)) {
					for (Map<String, Object> map : listData) {
						if (!idsRegDJPPenunjangPA.contains(Integer.parseInt(map.get("detailId").toString()))
								&& !idsRegDJPPenunjangPK.contains(Integer.parseInt(map.get("detailId").toString()))) {
							if (listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))) {
								result.add(map);
							} else if (!listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))
									&& map.get("departemenId").equals(Master.Departemen.IGD)
									&& drKsmUmumList.contains(idPegawai)
									&& idsDokterUmumIGD.contains(Integer.parseInt(map.get("idProduk").toString()))) {
								result.add(map);
							} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProdukException)
									&& listDetailJenisProdukException
											.contains(Integer.parseInt(map.get("detailId").toString()))) {
								result.add(map);
							} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProduk) && listDetailJenisProduk
									.contains(Integer.parseInt(map.get("detailId").toString()))) {
								result.add(map);
							}
						}
					}
				} else {
					for (Map<String, Object> map : listData) {
						if (listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))) {
							if (!idsRegDJPPenunjangPA.contains(Integer.parseInt(map.get("detailId").toString()))
									&& !idsRegDJPPenunjangPK
											.contains(Integer.parseInt(map.get("detailId").toString()))) {
								if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
									Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
									String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
									String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
									LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
									LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
									LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

									String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
											+ map.get("jamMasuk").toString().substring(3) + ":00";
									LocalTime timeMasuk = LocalTime.parse(jamMasuk);
									LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
									if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
										if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.MONDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.TUESDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.THURSDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.FRIDAY)) {
											jamMasuk = "07:00:00";
											timeMasuk = LocalTime.parse(jamMasuk);
											dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
										} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
											jamMasuk = "00:00:00";
											timeMasuk = LocalTime.parse(jamMasuk);
											dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
										}
									}

									String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
											+ map.get("jamPulang").toString().substring(3) + ":00";
									LocalTime timePulang = LocalTime.parse(jamPulang);
									LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);
									if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
										if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.MONDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.TUESDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.THURSDAY)) {
											org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(
													datePelayanan.getYear(), datePelayanan.getMonthValue(),
													datePelayanan.getDayOfMonth(), iso);
											org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
													tglIso.toDateTimeAtStartOfDay(), hijri);
											if (tglHijri.getMonthOfYear() == 9) {
												jamPulang = "14:00:00";
												timePulang = LocalTime.parse(jamPulang);
												datePulang = LocalDateTime.of(datePelayanan, timePulang);
											} else {
												jamPulang = "15:30:00";
												timePulang = LocalTime.parse(jamPulang);
												datePulang = LocalDateTime.of(datePelayanan, timePulang);
											}
										} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.FRIDAY)) {
											org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(
													datePelayanan.getYear(), datePelayanan.getMonthValue(),
													datePelayanan.getDayOfMonth(), iso);
											org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
													tglIso.toDateTimeAtStartOfDay(), hijri);
											if (tglHijri.getMonthOfYear() == 9) {
												jamPulang = "14:30:00";
												timePulang = LocalTime.parse(jamPulang);
												datePulang = LocalDateTime.of(datePelayanan, timePulang);
											} else {
												jamPulang = "16:00:00";
												timePulang = LocalTime.parse(jamPulang);
												datePulang = LocalDateTime.of(datePelayanan, timePulang);
											}
										} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
											jamPulang = "23:59:59";
											timePulang = LocalTime.parse(jamPulang);
											datePulang = LocalDateTime.of(datePelayanan, timePulang);
										}
									}

									String jamPulangPSBB = "";
									LocalTime timePulangPSBB = LocalTime.now();
									LocalDateTime datePulangPSBB = LocalDateTime.now();
									if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
											|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
											|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
											|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
										jamPulangPSBB = "14:00:00";
										timePulangPSBB = LocalTime.parse(jamPulangPSBB);
										datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
									} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
										jamPulangPSBB = "14:30:00";
										timePulangPSBB = LocalTime.parse(jamPulangPSBB);
										datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
									} else {
										datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
									}

									if (map.get("namaShift").toString().contains("Malam")
											&& !map.get("namaShift").toString().contains("Pagi Sore Malam")) {
										datePulang = datePulang.plusDays(1);
									}

									if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
											|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
										if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
											if (!Master.KelompokPasien.BPJS
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
												if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN).contains(
														Integer.parseInt(map.get("departemenId").toString()))) {
													result.add(map);
												} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
														.contains(Integer.parseInt(map.get("departemenId").toString()))
														&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP).contains(
																Integer.parseInt(map.get("idKelas").toString()))) {
													result.add(map);
												}
											}
										} else {
											if (!Master.KelompokPasien.BPJS
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
													&& (dateTimePelayanan.isBefore(dateMasuk)
															|| dateTimePelayanan.isEqual(datePulang)
															|| dateTimePelayanan.isAfter(datePulang))) {
												if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN).contains(
														Integer.parseInt(map.get("departemenId").toString()))) {
													result.add(map);
												} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
														.contains(Integer.parseInt(map.get("departemenId").toString()))
														&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP).contains(
																Integer.parseInt(map.get("idKelas").toString()))
														&& !Arrays.stream(Master.KONSUL_VISIT)
																.anyMatch(map.get("namaProduk").toString()
																		.toLowerCase()::contains)) {
													result.add(map);
												}
											}
										}
									} else {
										if (!Master.KelompokPasien.BPJS
												.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
											if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
													&& map.get("namaShift").toString().equals("Non Shift")
													&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
													&& (dateTimePelayanan.isEqual(PSBBDate)
															|| dateTimePelayanan.isAfter(PSBBDate))
													&& (dateTimePelayanan.isBefore(PSBBEnd)
															|| dateTimePelayanan.isEqual(PSBBEnd))) {
												if (dateTimePelayanan.isBefore(dateMasuk)
														|| dateTimePelayanan.isEqual(datePulangPSBB)
														|| dateTimePelayanan.isAfter(datePulangPSBB)) {
													result.add(map);
												}
											} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
													.contains(Integer.parseInt(map.get("departemenId").toString()))
													&& (dateTimePelayanan.isBefore(dateMasuk)
															|| dateTimePelayanan.isEqual(datePulang)
															|| dateTimePelayanan.isAfter(datePulang))) {
												result.add(map);
											} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
													.contains(Integer.parseInt(map.get("departemenId").toString()))
													&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
															.contains(Integer.parseInt(map.get("idKelas").toString()))
													&& !Arrays.stream(Master.KONSUL_VISIT).anyMatch(
															map.get("namaProduk").toString().toLowerCase()::contains)
													&& (dateTimePelayanan.isBefore(dateMasuk)
															|| dateTimePelayanan.isEqual(datePulang)
															|| dateTimePelayanan.isAfter(datePulang))) {
												result.add(map);
											}
										}
									}
								} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))) {
									if (!Master.KelompokPasien.BPJS
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
										if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
												.contains(Integer.parseInt(map.get("departemenId").toString()))) {
											result.add(map);
										} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
												.contains(Integer.parseInt(map.get("departemenId").toString()))
												&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
														.contains(Integer.parseInt(map.get("idKelas").toString()))) {
											result.add(map);
										}
									}
								}
							}
						} else if (!listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))
								&& map.get("departemenId").equals(Master.Departemen.IGD)
								&& drKsmUmumList.contains(idPegawai)
								&& idsDokterUmumIGD.contains(Integer.parseInt(map.get("idProduk").toString()))) {
							if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
								Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
								String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
								String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
								LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
								LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
								LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

								String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
										+ map.get("jamMasuk").toString().substring(3) + ":00";
								LocalTime timeMasuk = LocalTime.parse(jamMasuk);
								LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
								if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
									if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.MONDAY)
											|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.TUESDAY)
											|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)
											|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.THURSDAY)
											|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.FRIDAY)) {
										jamMasuk = "07:00:00";
										timeMasuk = LocalTime.parse(jamMasuk);
										dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
									} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
											|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
										jamMasuk = "00:00:00";
										timeMasuk = LocalTime.parse(jamMasuk);
										dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
									}
								}

								String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
										+ map.get("jamPulang").toString().substring(3) + ":00";
								LocalTime timePulang = LocalTime.parse(jamPulang);
								LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);
								if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
									if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.MONDAY)
											|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.TUESDAY)
											|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)
											|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.THURSDAY)) {
										org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(
												datePelayanan.getYear(), datePelayanan.getMonthValue(),
												datePelayanan.getDayOfMonth(), iso);
										org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
												tglIso.toDateTimeAtStartOfDay(), hijri);
										if (tglHijri.getMonthOfYear() == 9) {
											jamPulang = "14:00:00";
											timePulang = LocalTime.parse(jamPulang);
											datePulang = LocalDateTime.of(datePelayanan, timePulang);
										} else {
											jamPulang = "15:30:00";
											timePulang = LocalTime.parse(jamPulang);
											datePulang = LocalDateTime.of(datePelayanan, timePulang);
										}
									} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.FRIDAY)) {
										org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(
												datePelayanan.getYear(), datePelayanan.getMonthValue(),
												datePelayanan.getDayOfMonth(), iso);
										org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
												tglIso.toDateTimeAtStartOfDay(), hijri);
										if (tglHijri.getMonthOfYear() == 9) {
											jamPulang = "14:30:00";
											timePulang = LocalTime.parse(jamPulang);
											datePulang = LocalDateTime.of(datePelayanan, timePulang);
										} else {
											jamPulang = "16:00:00";
											timePulang = LocalTime.parse(jamPulang);
											datePulang = LocalDateTime.of(datePelayanan, timePulang);
										}
									} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
											|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
										jamPulang = "23:59:59";
										timePulang = LocalTime.parse(jamPulang);
										datePulang = LocalDateTime.of(datePelayanan, timePulang);
									}
								}

								String jamPulangPSBB = "";
								LocalTime timePulangPSBB = LocalTime.now();
								LocalDateTime datePulangPSBB = LocalDateTime.now();
								if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
									jamPulangPSBB = "14:00:00";
									timePulangPSBB = LocalTime.parse(jamPulangPSBB);
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
								} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
									jamPulangPSBB = "14:30:00";
									timePulangPSBB = LocalTime.parse(jamPulangPSBB);
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
								} else {
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
								}

								if (map.get("namaShift").toString().contains("Malam")
										&& !map.get("namaShift").toString().contains("Pagi Sore Malam")) {
									datePulang = datePulang.plusDays(1);
								}

								if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
									if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
										if (!Master.KelompokPasien.BPJS
												.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
											if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
													.contains(Integer.parseInt(map.get("departemenId").toString()))) {
												result.add(map);
											} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
													.contains(Integer.parseInt(map.get("departemenId").toString()))
													&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP).contains(
															Integer.parseInt(map.get("idKelas").toString()))) {
												result.add(map);
											}
										}
									} else {
										if (!Master.KelompokPasien.BPJS
												.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
												&& (dateTimePelayanan.isBefore(dateMasuk)
														|| dateTimePelayanan.isEqual(datePulang)
														|| dateTimePelayanan.isAfter(datePulang))) {
											if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
													.contains(Integer.parseInt(map.get("departemenId").toString()))) {
												result.add(map);
											} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
													.contains(Integer.parseInt(map.get("departemenId").toString()))
													&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
															.contains(Integer.parseInt(map.get("idKelas").toString()))
													&& !Arrays.stream(Master.KONSUL_VISIT).anyMatch(
															map.get("namaProduk").toString().toLowerCase()::contains)) {
												result.add(map);
											}
										}
									}
								} else {
									if (!Master.KelompokPasien.BPJS
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
										if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
												&& map.get("namaShift").toString().equals("Non Shift")
												&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
												&& (dateTimePelayanan.isEqual(PSBBDate)
														|| dateTimePelayanan.isAfter(PSBBDate))
												&& (dateTimePelayanan.isBefore(PSBBEnd)
														|| dateTimePelayanan.isEqual(PSBBEnd))) {
											if (dateTimePelayanan.isBefore(dateMasuk)
													|| dateTimePelayanan.isEqual(datePulangPSBB)
													|| dateTimePelayanan.isAfter(datePulangPSBB)) {
												result.add(map);
											}
										} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
												.contains(Integer.parseInt(map.get("departemenId").toString()))
												&& (dateTimePelayanan.isBefore(dateMasuk)
														|| dateTimePelayanan.isEqual(datePulang)
														|| dateTimePelayanan.isAfter(datePulang))) {
											result.add(map);
										} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
												.contains(Integer.parseInt(map.get("departemenId").toString()))
												&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
														.contains(Integer.parseInt(map.get("idKelas").toString()))
												&& !Arrays.stream(Master.KONSUL_VISIT).anyMatch(
														map.get("namaProduk").toString().toLowerCase()::contains)
												&& (dateTimePelayanan.isBefore(dateMasuk)
														|| dateTimePelayanan.isEqual(datePulang)
														|| dateTimePelayanan.isAfter(datePulang))) {
											result.add(map);
										}
									}
								}
							} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))) {
								if (!Master.KelompokPasien.BPJS
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
									if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
											.contains(Integer.parseInt(map.get("departemenId").toString()))) {
										result.add(map);
									} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
											.contains(Integer.parseInt(map.get("departemenId").toString()))
											&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
													.contains(Integer.parseInt(map.get("idKelas").toString()))) {
										result.add(map);
									}
								}
							}
						} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProdukException)
								&& listDetailJenisProdukException
										.contains(Integer.parseInt(map.get("detailId").toString()))) {
							if (!idsRegDJPPenunjangPA.contains(Integer.parseInt(map.get("detailId").toString()))
									&& !idsRegDJPPenunjangPK
											.contains(Integer.parseInt(map.get("detailId").toString()))) {
								if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
									Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
									String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
									String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
									LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
									LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
									LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

									String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
											+ map.get("jamMasuk").toString().substring(3) + ":00";
									LocalTime timeMasuk = LocalTime.parse(jamMasuk);
									LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
									if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
										if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.MONDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.TUESDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.THURSDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.FRIDAY)) {
											jamMasuk = "07:00:00";
											timeMasuk = LocalTime.parse(jamMasuk);
											dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
										} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
											jamMasuk = "00:00:00";
											timeMasuk = LocalTime.parse(jamMasuk);
											dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
										}
									}

									String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
											+ map.get("jamPulang").toString().substring(3) + ":00";
									LocalTime timePulang = LocalTime.parse(jamPulang);
									LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);
									if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
										if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.MONDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.TUESDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.THURSDAY)) {
											org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(
													datePelayanan.getYear(), datePelayanan.getMonthValue(),
													datePelayanan.getDayOfMonth(), iso);
											org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
													tglIso.toDateTimeAtStartOfDay(), hijri);
											if (tglHijri.getMonthOfYear() == 9) {
												jamPulang = "14:00:00";
												timePulang = LocalTime.parse(jamPulang);
												datePulang = LocalDateTime.of(datePelayanan, timePulang);
											} else {
												jamPulang = "15:30:00";
												timePulang = LocalTime.parse(jamPulang);
												datePulang = LocalDateTime.of(datePelayanan, timePulang);
											}
										} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.FRIDAY)) {
											org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(
													datePelayanan.getYear(), datePelayanan.getMonthValue(),
													datePelayanan.getDayOfMonth(), iso);
											org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
													tglIso.toDateTimeAtStartOfDay(), hijri);
											if (tglHijri.getMonthOfYear() == 9) {
												jamPulang = "14:30:00";
												timePulang = LocalTime.parse(jamPulang);
												datePulang = LocalDateTime.of(datePelayanan, timePulang);
											} else {
												jamPulang = "16:00:00";
												timePulang = LocalTime.parse(jamPulang);
												datePulang = LocalDateTime.of(datePelayanan, timePulang);
											}
										} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
											jamPulang = "23:59:59";
											timePulang = LocalTime.parse(jamPulang);
											datePulang = LocalDateTime.of(datePelayanan, timePulang);
										}
									}

									String jamPulangPSBB = "";
									LocalTime timePulangPSBB = LocalTime.now();
									LocalDateTime datePulangPSBB = LocalDateTime.now();
									if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
											|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
											|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
											|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
										jamPulangPSBB = "14:00:00";
										timePulangPSBB = LocalTime.parse(jamPulangPSBB);
										datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
									} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
										jamPulangPSBB = "14:30:00";
										timePulangPSBB = LocalTime.parse(jamPulangPSBB);
										datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
									} else {
										datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
									}

									if (map.get("namaShift").toString().contains("Malam")
											&& !map.get("namaShift").toString().contains("Pagi Sore Malam")) {
										datePulang = datePulang.plusDays(1);
									}

									if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
											|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
										if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
											if (!Master.KelompokPasien.BPJS
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
												if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN).contains(
														Integer.parseInt(map.get("departemenId").toString()))) {
													result.add(map);
												} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
														.contains(Integer.parseInt(map.get("departemenId").toString()))
														&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP).contains(
																Integer.parseInt(map.get("idKelas").toString()))) {
													result.add(map);
												}
											}
										} else {
											if (!Master.KelompokPasien.BPJS
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
													&& (dateTimePelayanan.isBefore(dateMasuk)
															|| dateTimePelayanan.isEqual(datePulang)
															|| dateTimePelayanan.isAfter(datePulang))) {
												if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN).contains(
														Integer.parseInt(map.get("departemenId").toString()))) {
													result.add(map);
												} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
														.contains(Integer.parseInt(map.get("departemenId").toString()))
														&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP).contains(
																Integer.parseInt(map.get("idKelas").toString()))
														&& !Arrays.stream(Master.KONSUL_VISIT)
																.anyMatch(map.get("namaProduk").toString()
																		.toLowerCase()::contains)) {
													result.add(map);
												}
											}
										}
									} else {
										if (!Master.KelompokPasien.BPJS
												.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
											if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
													&& map.get("namaShift").toString().equals("Non Shift")
													&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
													&& (dateTimePelayanan.isEqual(PSBBDate)
															|| dateTimePelayanan.isAfter(PSBBDate))
													&& (dateTimePelayanan.isBefore(PSBBEnd)
															|| dateTimePelayanan.isEqual(PSBBEnd))) {
												if (dateTimePelayanan.isBefore(dateMasuk)
														|| dateTimePelayanan.isEqual(datePulangPSBB)
														|| dateTimePelayanan.isAfter(datePulangPSBB)) {
													result.add(map);
												}
											} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
													.contains(Integer.parseInt(map.get("departemenId").toString()))
													&& (dateTimePelayanan.isBefore(dateMasuk)
															|| dateTimePelayanan.isEqual(datePulang)
															|| dateTimePelayanan.isAfter(datePulang))) {
												result.add(map);
											} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
													.contains(Integer.parseInt(map.get("departemenId").toString()))
													&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
															.contains(Integer.parseInt(map.get("idKelas").toString()))
													&& !Arrays.stream(Master.KONSUL_VISIT).anyMatch(
															map.get("namaProduk").toString().toLowerCase()::contains)
													&& (dateTimePelayanan.isBefore(dateMasuk)
															|| dateTimePelayanan.isEqual(datePulang)
															|| dateTimePelayanan.isAfter(datePulang))) {
												result.add(map);
											}
										}
									}
								} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))) {
									if (!Master.KelompokPasien.BPJS
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
										if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
												.contains(Integer.parseInt(map.get("departemenId").toString()))) {
											result.add(map);
										} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
												.contains(Integer.parseInt(map.get("departemenId").toString()))
												&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
														.contains(Integer.parseInt(map.get("idKelas").toString()))) {
											result.add(map);
										}
									}
								}
							}
						}
					}
				}
			}
		}

		return result;
	}

	@Override
	public List<Map<String, Object>> getAllTindakanByDokterReport2Review(String periode, Integer idPegawai) {
		List<Map<String, Object>> result = new ArrayList<>();
		List<Map<String, Object>> rawResult = new ArrayList<>();

		List<Integer> listProdukId = new ArrayList<>();
		List<Integer> listKelasId = new ArrayList<>();
		List<Integer> listDetailJenisProduk = new ArrayList<>();
		List<Integer> listDetailJenisProdukException = new ArrayList<>();
		List<String> listTanggalPelayanan = new ArrayList<>();

		DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

		LocalDateTime PSBBDate = LocalDateTime.of(2020, 9, 14, 0, 0, 0);
		LocalDateTime PSBBEnd = LocalDateTime.parse(GetSettingDataFixed("psbbperiod"), dtf);

		List<Integer> drKsmUmumList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_UMUM);
		List<Integer> laboranRadiologList = mapPegawaiLaboratRadiologiDao.findPegawaiLaboranRadiolog();

		List<Integer> idsRegDJPAdminNonPK = splitDataSettingDatafixed("admin_nonpk");
		List<Integer> idsRegDJPMedisUtama = splitDataSettingDatafixed("medis_utama");
		List<Integer> idsRegDJPPenunjangPA = splitDataSettingDatafixed("penunjang_pa");
		List<Integer> idsRegDJPPenunjangPK = splitDataSettingDatafixed("penunjang_pk");
		List<Integer> idsRegDJPPenunjangRad = splitDataSettingDatafixed("penunjang_radiologi");

		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPA;
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPK;
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangRad;
		} else {
			listDetailJenisProduk = idsRegDJPMedisUtama;
		}

		if (laboranRadiologList.contains(idPegawai)) {
			listDetailJenisProdukException = idsRegDJPAdminNonPK;
			listDetailJenisProdukException.removeAll(listDetailJenisProduk);
		}

		List<Map<String, Object>> listData = revIndekKinerjaDao.getAllTindakanDokterCetak(Master.Kelas.KELAS_SATU,
				idPegawai, Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA, periode);

		List<Integer> idsDokterUmumIGD = splitDataSettingDatafixed("pr_dokter_umum_igd");

		if (CommonUtil.isNotNullOrEmpty(listData)) {
			for (Map<String, Object> map : listData) {
				if (listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))) {
					if (idsRegDJPPenunjangPA.contains(Integer.parseInt(map.get("detailId").toString()))
							|| idsRegDJPPenunjangPK.contains(Integer.parseInt(map.get("detailId").toString()))) {
						rawResult.add(map);
					} else if (Master.KelompokPasien.BPJS
							.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
							|| Master.KelompokPasien.KEMENKES
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
							|| Master.KelompokPasien.JAMKESDA
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
						rawResult.add(map);
					} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
						Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
						String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
						String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
						LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
						LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
						LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

						String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
								+ map.get("jamMasuk").toString().substring(3) + ":00";
						LocalTime timeMasuk = LocalTime.parse(jamMasuk);
						LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

						String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
								+ map.get("jamPulang").toString().substring(3) + ":00";
						LocalTime timePulang = LocalTime.parse(jamPulang);
						LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

						String jamPulangPSBB = "";
						LocalTime timePulangPSBB = LocalTime.now();
						LocalDateTime datePulangPSBB = LocalDateTime.now();
						if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
								|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
								|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
								|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
							jamPulangPSBB = "14:00:00";
							timePulangPSBB = LocalTime.parse(jamPulangPSBB);
							datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
						} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
							jamPulangPSBB = "14:30:00";
							timePulangPSBB = LocalTime.parse(jamPulangPSBB);
							datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
						} else {
							datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
						}

						if (map.get("namaShift").toString().contains("Malam")) {
							datePulang = datePulang.plusDays(1);
						}

						if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulang))) {
							rawResult.add(map);
						} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
								&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
								&& Arrays.stream(Master.KONSUL_VISIT)
										.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
								&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
										|| dateTimePelayanan.isAfter(datePulang))) {
							rawResult.add(map);
						} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
										|| dateTimePelayanan.isAfter(datePulang))
								&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
										.contains(Integer.parseInt(map.get("idKelas").toString()))) {
							rawResult.add(map);
						} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
								&& map.get("namaShift").toString().equals("Non Shift")
								&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
								&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
								&& (dateTimePelayanan.isBefore(PSBBEnd) || dateTimePelayanan.isEqual(PSBBEnd))) {
							if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
									&& dateTimePelayanan.isBefore(datePulangPSBB))) {
								rawResult.add(map);
							}
						} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& (dateTimePelayanan.isBefore(datePulang)))) {
							rawResult.add(map);
						}
					} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
							&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
							&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
									.contains(Integer.parseInt(map.get("idKelas").toString()))) {
						rawResult.add(map);
					}
				} else if (!listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))
						&& map.get("departemenId").equals(Master.Departemen.IGD) && drKsmUmumList.contains(idPegawai)
						&& idsDokterUmumIGD.contains(Integer.parseInt(map.get("idProduk").toString()))) {
					if (Master.KelompokPasien.BPJS.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
							|| Master.KelompokPasien.KEMENKES
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
							|| Master.KelompokPasien.JAMKESDA
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
						rawResult.add(map);
					} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
						Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
						String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
						String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
						LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
						LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
						LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

						String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
								+ map.get("jamMasuk").toString().substring(3) + ":00";
						LocalTime timeMasuk = LocalTime.parse(jamMasuk);
						LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

						String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
								+ map.get("jamPulang").toString().substring(3) + ":00";
						LocalTime timePulang = LocalTime.parse(jamPulang);
						LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

						String jamPulangPSBB = "";
						LocalTime timePulangPSBB = LocalTime.now();
						LocalDateTime datePulangPSBB = LocalDateTime.now();
						if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
								|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
								|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
								|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
							jamPulangPSBB = "14:00:00";
							timePulangPSBB = LocalTime.parse(jamPulangPSBB);
							datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
						} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
							jamPulangPSBB = "14:30:00";
							timePulangPSBB = LocalTime.parse(jamPulangPSBB);
							datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
						} else {
							datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
						}

						if (map.get("namaShift").toString().contains("Malam")) {
							datePulang = datePulang.plusDays(1);
						}

						if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulang))) {
							rawResult.add(map);
						} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
								&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
								&& Arrays.stream(Master.KONSUL_VISIT)
										.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
								&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
										|| dateTimePelayanan.isAfter(datePulang))) {
							rawResult.add(map);
						} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
										|| dateTimePelayanan.isAfter(datePulang))
								&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
										.contains(Integer.parseInt(map.get("idKelas").toString()))) {
							rawResult.add(map);
						} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
								&& map.get("namaShift").toString().equals("Non Shift")
								&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
								&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
								&& (dateTimePelayanan.isBefore(PSBBEnd) || dateTimePelayanan.isEqual(PSBBEnd))) {
							if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
									&& dateTimePelayanan.isBefore(datePulangPSBB))) {
								rawResult.add(map);
							}
						} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulang))) {
							rawResult.add(map);
						}
					} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
							&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
							&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
									.contains(Integer.parseInt(map.get("idKelas").toString()))) {
						rawResult.add(map);
					}
				} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProdukException)
						&& listDetailJenisProdukException.contains(Integer.parseInt(map.get("detailId").toString()))) {
					if (idsRegDJPPenunjangPA.contains(Integer.parseInt(map.get("detailId").toString()))
							|| idsRegDJPPenunjangPK.contains(Integer.parseInt(map.get("detailId").toString()))) {
						rawResult.add(map);
					} else if (Master.KelompokPasien.BPJS
							.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
							|| Master.KelompokPasien.KEMENKES
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
							|| Master.KelompokPasien.JAMKESDA
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
						rawResult.add(map);
					} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
						Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
						String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
						String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
						LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
						LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
						LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

						String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
								+ map.get("jamMasuk").toString().substring(3) + ":00";
						LocalTime timeMasuk = LocalTime.parse(jamMasuk);
						LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

						String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
								+ map.get("jamPulang").toString().substring(3) + ":00";
						LocalTime timePulang = LocalTime.parse(jamPulang);
						LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

						String jamPulangPSBB = "";
						LocalTime timePulangPSBB = LocalTime.now();
						LocalDateTime datePulangPSBB = LocalDateTime.now();
						if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
								|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
								|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
								|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
							jamPulangPSBB = "14:00:00";
							timePulangPSBB = LocalTime.parse(jamPulangPSBB);
							datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
						} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
							jamPulangPSBB = "14:30:00";
							timePulangPSBB = LocalTime.parse(jamPulangPSBB);
							datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
						} else {
							datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
						}

						if (map.get("namaShift").toString().contains("Malam")) {
							datePulang = datePulang.plusDays(1);
						}

						if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulang))) {
							rawResult.add(map);
						} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
								&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
								&& Arrays.stream(Master.KONSUL_VISIT)
										.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
								&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
										|| dateTimePelayanan.isAfter(datePulang))) {
							rawResult.add(map);
						} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
										|| dateTimePelayanan.isAfter(datePulang))
								&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
										.contains(Integer.parseInt(map.get("idKelas").toString()))) {
							rawResult.add(map);
						} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
								&& map.get("namaShift").toString().equals("Non Shift")
								&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
								&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
								&& (dateTimePelayanan.isBefore(PSBBEnd) || dateTimePelayanan.isEqual(PSBBEnd))) {
							if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
									&& dateTimePelayanan.isBefore(datePulangPSBB))) {
								rawResult.add(map);
							}
						} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
								.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulang))) {
							rawResult.add(map);
						}
					} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
							&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
							&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
									.contains(Integer.parseInt(map.get("idKelas").toString()))) {
						rawResult.add(map);
					}
				}
			}
		}

		if (CommonUtil.isNotNullOrEmpty(rawResult)) {
			for (Map<String, Object> map : rawResult) {
				if (!Arrays.asList(Master.JenisPetugasPelaksana.DOKTER_ANASTESI_OR_ASISTEN_SPESIALIS)
						.contains(Integer.parseInt(map.get("idJenisPelaksana").toString()))) {
					map.put("idJenisPelaksana", Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA);
				}
				if (!listProdukId.contains(Integer.parseInt(map.get("idProduk").toString()))) {
					listProdukId.add(Integer.parseInt(map.get("idProduk").toString()));
				}
				if (!listKelasId.contains(Integer.parseInt(map.get("idKelas").toString()))) {
					listKelasId.add(Integer.parseInt(map.get("idKelas").toString()));
				}
				if (!listTanggalPelayanan.contains(map.get("tanggal").toString())) {
					listTanggalPelayanan.add(map.get("tanggal").toString());
				}
			}

			for (String tanggal : listTanggalPelayanan) {
				for (Integer idProduk : listProdukId) {
					for (Integer idKelas : listKelasId) {
						Map<String, Object> mapResult = new HashMap<>();
						double count = 0.0;
						int dataCount = 0;
						for (Map<String, Object> map : rawResult) {
							if (Integer.parseInt(map.get("idProduk").toString()) == idProduk
									&& Integer.parseInt(map.get("idKelas").toString()) == idKelas
									&& map.get("tanggal").toString().equals(tanggal)) {
								count = count + Double.parseDouble(map.get("count").toString());
								dataCount = dataCount + 1;
								if (dataCount == 1) {
									mapResult.putAll(map);
								}
							}
						}
						if (CommonUtil.isNotNullOrEmpty(mapResult.get("count"))) {
							mapResult.put("count", count);
							result.add(mapResult);
						}
					}

				}
			}
		}

		return result;
	}

	@Override
	public List<Map<String, Object>> getAllTindakanByDokterForfeeForServiceReportReview(String periode,
			Integer idPegawai) {
		List<Map<String, Object>> result = new ArrayList<>();
		List<Map<String, Object>> listData = new ArrayList<>();
		List<Map<String, Object>> rawResult = new ArrayList<>();

		List<Integer> listProdukId = new ArrayList<>();
		List<Integer> listKelasId = new ArrayList<>();
		List<Integer> listDetailJenisProduk = new ArrayList<>();
		List<Integer> listDetailJenisProdukException = new ArrayList<>();
		List<String> listTanggalPelayanan = new ArrayList<>();

		Chronology iso = ISOChronology.getInstance();
		Chronology hijri = IslamicChronology.getInstance();

		DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

		LocalDateTime PSBBDate = LocalDateTime.of(2020, 9, 14, 0, 0, 0);
		LocalDateTime PSBBEnd = LocalDateTime.parse(GetSettingDataFixed("psbbperiod"), dtf);

		List<Integer> drKsmUmumList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_UMUM);
		List<Integer> laboranRadiologList = mapPegawaiLaboratRadiologiDao.findPegawaiLaboranRadiolog();

		List<Integer> idsRegDJPAdminNonPK = splitDataSettingDatafixed("admin_nonpk");
		List<Integer> idsRegDJPMedisUtama = splitDataSettingDatafixed("medis_utama");
		List<Integer> idsRegDJPPenunjangPA = splitDataSettingDatafixed("penunjang_pa");
		List<Integer> idsRegDJPPenunjangPK = splitDataSettingDatafixed("penunjang_pk");
		List<Integer> idsRegDJPPenunjangRad = splitDataSettingDatafixed("penunjang_radiologi");

		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPA;
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPK;
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangRad;
		} else {
			listDetailJenisProduk = idsRegDJPMedisUtama;
		}

		if (laboranRadiologList.contains(idPegawai)) {
			listDetailJenisProdukException = idsRegDJPAdminNonPK;
			listDetailJenisProdukException.removeAll(listDetailJenisProduk);
		}

		List<Map<String, Object>> data = revIndekKinerjaDao.getAllTindakanDokterCetak(Master.Kelas.KELAS_SATU,
				idPegawai, Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA, periode);

		List<Integer> idsKonsultasiDokterJaga = splitDataSettingDatafixed("pr_konsultasi_dokter_jaga");

		// RULES_NOTE_SK_FFS_2015_DI_2019
		if (CommonUtil.isNotNullOrEmpty(data)) {
			for (Map<String, Object> map : data) {
				if (!idsRegDJPPenunjangPA.contains(Integer.parseInt(map.get("detailId").toString()))
						&& !idsRegDJPPenunjangPK.contains(Integer.parseInt(map.get("detailId").toString()))) {
					if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
							&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))) {
						if (Arrays.stream(Master.KONSUL_VISIT)
								.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)) {
							if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))) {
								listData.add(map);
							} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))
									&& map.get("namaShift").toString().contains("Pagi Sore Malam")) {
								Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
								String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
								String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
								LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
								LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
								LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

								if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
									listData.add(map);
								}
							}
						}
					} else {
						listData.add(map);
					}
				}
			}
		}

		if (CommonUtil.isNotNullOrEmpty(listData)) {
			if (pegawaiDao.getPegawaiByKategoryPegawai(Arrays.asList(Master.KategoryPegawai.DOKTER_LUAR))
					.contains(idPegawai)) {
				for (Map<String, Object> map : listData) {
					if (listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))) {
						rawResult.add(map);
					} else if (!listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))
							&& map.get("departemenId").equals(Master.Departemen.IGD)
							&& map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
							&& drKsmUmumList.contains(idPegawai)
							&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
						rawResult.add(map);
					} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProdukException)
							&& listDetailJenisProdukException
									.contains(Integer.parseInt(map.get("detailId").toString()))) {
						rawResult.add(map);
					} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProduk)
							&& listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))) {
						rawResult.add(map);
					}
				}
			} else {
				for (Map<String, Object> map : listData) {
					if (listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))) {
						if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
							Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
							String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
							String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
							LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
							LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
							LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

							String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
									+ map.get("jamMasuk").toString().substring(3) + ":00";
							LocalTime timeMasuk = LocalTime.parse(jamMasuk);
							LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
							if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
								if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.MONDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.TUESDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.THURSDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.FRIDAY)) {
									jamMasuk = "07:00:00";
									timeMasuk = LocalTime.parse(jamMasuk);
									dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
								} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
									jamMasuk = "00:00:00";
									timeMasuk = LocalTime.parse(jamMasuk);
									dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
								}
							}

							String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
									+ map.get("jamPulang").toString().substring(3) + ":00";
							LocalTime timePulang = LocalTime.parse(jamPulang);
							LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);
							if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
								if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.MONDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.TUESDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.THURSDAY)) {
									org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(
											datePelayanan.getYear(), datePelayanan.getMonthValue(),
											datePelayanan.getDayOfMonth(), iso);
									org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
											tglIso.toDateTimeAtStartOfDay(), hijri);
									if (tglHijri.getMonthOfYear() == 9) {
										jamPulang = "14:00:00";
										timePulang = LocalTime.parse(jamPulang);
										datePulang = LocalDateTime.of(datePelayanan, timePulang);
									} else {
										jamPulang = "15:30:00";
										timePulang = LocalTime.parse(jamPulang);
										datePulang = LocalDateTime.of(datePelayanan, timePulang);
									}
								} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.FRIDAY)) {
									org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(
											datePelayanan.getYear(), datePelayanan.getMonthValue(),
											datePelayanan.getDayOfMonth(), iso);
									org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
											tglIso.toDateTimeAtStartOfDay(), hijri);
									if (tglHijri.getMonthOfYear() == 9) {
										jamPulang = "14:30:00";
										timePulang = LocalTime.parse(jamPulang);
										datePulang = LocalDateTime.of(datePelayanan, timePulang);
									} else {
										jamPulang = "16:00:00";
										timePulang = LocalTime.parse(jamPulang);
										datePulang = LocalDateTime.of(datePelayanan, timePulang);
									}
								} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
									jamPulang = "23:59:59";
									timePulang = LocalTime.parse(jamPulang);
									datePulang = LocalDateTime.of(datePelayanan, timePulang);
								}
							}

							String jamPulangPSBB = "";
							LocalTime timePulangPSBB = LocalTime.now();
							LocalDateTime datePulangPSBB = LocalDateTime.now();
							if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
								jamPulangPSBB = "14:00:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
								jamPulangPSBB = "14:30:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else {
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
							}

							if (map.get("namaShift").toString().contains("Malam")
									&& !map.get("namaShift").toString().contains("Pagi Sore Malam")) {
								datePulang = datePulang.plusDays(1);
							}

							if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
									|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
								if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
									if (!Master.KelompokPasien.BPJS
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											&& !Master.KelompokPasien.KEMENKES
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											&& !Master.KelompokPasien.JAMKESDA
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
										if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
												.contains(Integer.parseInt(map.get("departemenId").toString()))) {
											if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
													&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
												rawResult.add(map);
											} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
												rawResult.add(map);
											}
										} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
												.contains(Integer.parseInt(map.get("departemenId").toString()))
												&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
														.contains(Integer.parseInt(map.get("idKelas").toString()))) {
											rawResult.add(map);
										}
									}
								} else {
									if (!Master.KelompokPasien.BPJS
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											&& !Master.KelompokPasien.KEMENKES
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											&& !Master.KelompokPasien.JAMKESDA
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											&& (dateTimePelayanan.isBefore(dateMasuk)
													|| dateTimePelayanan.isEqual(datePulang)
													|| dateTimePelayanan.isAfter(datePulang))) {
										if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
												.contains(Integer.parseInt(map.get("departemenId").toString()))) {
											if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
													&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
												rawResult.add(map);
											} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
												rawResult.add(map);
											}
										} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
												.contains(Integer.parseInt(map.get("departemenId").toString()))
												&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
														.contains(Integer.parseInt(map.get("idKelas").toString()))
												&& !Arrays.stream(Master.KONSUL_VISIT).anyMatch(
														map.get("namaProduk").toString().toLowerCase()::contains)) {
											rawResult.add(map);
										}
									}
								}
							} else {
								if (!Master.KelompokPasien.BPJS
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
										&& !Master.KelompokPasien.KEMENKES
												.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
										&& !Master.KelompokPasien.JAMKESDA
												.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
									if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
											&& map.get("namaShift").toString().equals("Non Shift")
											&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
											&& (dateTimePelayanan.isEqual(PSBBDate)
													|| dateTimePelayanan.isAfter(PSBBDate))
											&& (dateTimePelayanan.isBefore(PSBBEnd)
													|| dateTimePelayanan.isEqual(PSBBEnd))) {
										if (dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulangPSBB)
												|| dateTimePelayanan.isAfter(datePulangPSBB)) {
											rawResult.add(map);
										}
									} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
											.contains(Integer.parseInt(map.get("departemenId").toString()))
											&& (dateTimePelayanan.isBefore(dateMasuk)
													|| dateTimePelayanan.isEqual(datePulang)
													|| dateTimePelayanan.isAfter(datePulang))) {
										if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
												&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
											rawResult.add(map);
										} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
											rawResult.add(map);
										}
									} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
											.contains(Integer.parseInt(map.get("departemenId").toString()))
											&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
													.contains(Integer.parseInt(map.get("idKelas").toString()))
											&& !Arrays.stream(Master.KONSUL_VISIT)
													.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
											&& (dateTimePelayanan.isBefore(dateMasuk)
													|| dateTimePelayanan.isEqual(datePulang)
													|| dateTimePelayanan.isAfter(datePulang))) {
										rawResult.add(map);
									}
								}
							}
						} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))) {
							if (!Master.KelompokPasien.BPJS
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
									&& !Master.KelompokPasien.KEMENKES
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
									&& !Master.KelompokPasien.JAMKESDA
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
								if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
										.contains(Integer.parseInt(map.get("departemenId").toString()))) {
									if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
											&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
										rawResult.add(map);
									} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
										rawResult.add(map);
									}
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
												.contains(Integer.parseInt(map.get("idKelas").toString()))) {
									rawResult.add(map);
								}
							}
						}
					} else if (!listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))
							&& map.get("departemenId").equals(Master.Departemen.IGD)
							&& map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
							&& drKsmUmumList.contains(idPegawai)
							&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
						if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
							Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
							String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
							String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
							LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
							LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
							LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

							String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
									+ map.get("jamMasuk").toString().substring(3) + ":00";
							LocalTime timeMasuk = LocalTime.parse(jamMasuk);
							LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
							if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
								if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.MONDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.TUESDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.THURSDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.FRIDAY)) {
									jamMasuk = "07:00:00";
									timeMasuk = LocalTime.parse(jamMasuk);
									dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
								} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
									jamMasuk = "00:00:00";
									timeMasuk = LocalTime.parse(jamMasuk);
									dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
								}
							}

							String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
									+ map.get("jamPulang").toString().substring(3) + ":00";
							LocalTime timePulang = LocalTime.parse(jamPulang);
							LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);
							if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
								if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.MONDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.TUESDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.THURSDAY)) {
									org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(
											datePelayanan.getYear(), datePelayanan.getMonthValue(),
											datePelayanan.getDayOfMonth(), iso);
									org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
											tglIso.toDateTimeAtStartOfDay(), hijri);
									if (tglHijri.getMonthOfYear() == 9) {
										jamPulang = "14:00:00";
										timePulang = LocalTime.parse(jamPulang);
										datePulang = LocalDateTime.of(datePelayanan, timePulang);
									} else {
										jamPulang = "15:30:00";
										timePulang = LocalTime.parse(jamPulang);
										datePulang = LocalDateTime.of(datePelayanan, timePulang);
									}
								} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.FRIDAY)) {
									org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(
											datePelayanan.getYear(), datePelayanan.getMonthValue(),
											datePelayanan.getDayOfMonth(), iso);
									org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
											tglIso.toDateTimeAtStartOfDay(), hijri);
									if (tglHijri.getMonthOfYear() == 9) {
										jamPulang = "14:30:00";
										timePulang = LocalTime.parse(jamPulang);
										datePulang = LocalDateTime.of(datePelayanan, timePulang);
									} else {
										jamPulang = "16:00:00";
										timePulang = LocalTime.parse(jamPulang);
										datePulang = LocalDateTime.of(datePelayanan, timePulang);
									}
								} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
									jamPulang = "23:59:59";
									timePulang = LocalTime.parse(jamPulang);
									datePulang = LocalDateTime.of(datePelayanan, timePulang);
								}
							}

							String jamPulangPSBB = "";
							LocalTime timePulangPSBB = LocalTime.now();
							LocalDateTime datePulangPSBB = LocalDateTime.now();
							if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
								jamPulangPSBB = "14:00:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
								jamPulangPSBB = "14:30:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else {
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
							}

							if (map.get("namaShift").toString().contains("Malam")
									&& !map.get("namaShift").toString().contains("Pagi Sore Malam")) {
								datePulang = datePulang.plusDays(1);
							}

							if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
									|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
								if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
									if (!Master.KelompokPasien.BPJS
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											&& !Master.KelompokPasien.KEMENKES
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											&& !Master.KelompokPasien.JAMKESDA
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
										if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
												.contains(Integer.parseInt(map.get("departemenId").toString()))) {
											if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
													&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
												rawResult.add(map);
											} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
												rawResult.add(map);
											}
										} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
												.contains(Integer.parseInt(map.get("departemenId").toString()))
												&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
														.contains(Integer.parseInt(map.get("idKelas").toString()))) {
											rawResult.add(map);
										}
									}
								} else {
									if (!Master.KelompokPasien.BPJS
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											&& !Master.KelompokPasien.KEMENKES
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											&& !Master.KelompokPasien.JAMKESDA
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											&& (dateTimePelayanan.isBefore(dateMasuk)
													|| dateTimePelayanan.isEqual(datePulang)
													|| dateTimePelayanan.isAfter(datePulang))) {
										if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
												.contains(Integer.parseInt(map.get("departemenId").toString()))) {
											if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
													&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
												rawResult.add(map);
											} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
												rawResult.add(map);
											}
										} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
												.contains(Integer.parseInt(map.get("departemenId").toString()))
												&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
														.contains(Integer.parseInt(map.get("idKelas").toString()))
												&& !Arrays.stream(Master.KONSUL_VISIT).anyMatch(
														map.get("namaProduk").toString().toLowerCase()::contains)) {
											rawResult.add(map);
										}
									}
								}
							} else {
								if (!Master.KelompokPasien.BPJS
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
										&& !Master.KelompokPasien.KEMENKES
												.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
										&& !Master.KelompokPasien.JAMKESDA
												.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
									if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
											&& map.get("namaShift").toString().equals("Non Shift")
											&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
											&& (dateTimePelayanan.isEqual(PSBBDate)
													|| dateTimePelayanan.isAfter(PSBBDate))
											&& (dateTimePelayanan.isBefore(PSBBEnd)
													|| dateTimePelayanan.isEqual(PSBBEnd))) {
										if (dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulangPSBB)
												|| dateTimePelayanan.isAfter(datePulangPSBB)) {
											rawResult.add(map);
										}
									} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
											.contains(Integer.parseInt(map.get("departemenId").toString()))
											&& (dateTimePelayanan.isBefore(dateMasuk)
													|| dateTimePelayanan.isEqual(datePulang)
													|| dateTimePelayanan.isAfter(datePulang))) {
										if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
												&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
											rawResult.add(map);
										} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
											rawResult.add(map);
										}
									} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
											.contains(Integer.parseInt(map.get("departemenId").toString()))
											&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
													.contains(Integer.parseInt(map.get("idKelas").toString()))
											&& !Arrays.stream(Master.KONSUL_VISIT)
													.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
											&& (dateTimePelayanan.isBefore(dateMasuk)
													|| dateTimePelayanan.isEqual(datePulang)
													|| dateTimePelayanan.isAfter(datePulang))) {
										rawResult.add(map);
									}
								}
							}
						} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))) {
							if (!Master.KelompokPasien.BPJS
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
									&& !Master.KelompokPasien.KEMENKES
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
									&& !Master.KelompokPasien.JAMKESDA
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
								if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
										.contains(Integer.parseInt(map.get("departemenId").toString()))) {
									if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
											&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
										rawResult.add(map);
									} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
										rawResult.add(map);
									}
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
												.contains(Integer.parseInt(map.get("idKelas").toString()))) {
									rawResult.add(map);
								}
							}
						}
					} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProdukException)
							&& listDetailJenisProdukException
									.contains(Integer.parseInt(map.get("detailId").toString()))) {
						if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
							Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
							String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
							String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
							LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
							LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
							LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

							String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
									+ map.get("jamMasuk").toString().substring(3) + ":00";
							LocalTime timeMasuk = LocalTime.parse(jamMasuk);
							LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
							if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
								if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.MONDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.TUESDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.THURSDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.FRIDAY)) {
									jamMasuk = "07:00:00";
									timeMasuk = LocalTime.parse(jamMasuk);
									dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
								} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
									jamMasuk = "00:00:00";
									timeMasuk = LocalTime.parse(jamMasuk);
									dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
								}
							}

							String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
									+ map.get("jamPulang").toString().substring(3) + ":00";
							LocalTime timePulang = LocalTime.parse(jamPulang);
							LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);
							if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
								if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.MONDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.TUESDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.THURSDAY)) {
									org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(
											datePelayanan.getYear(), datePelayanan.getMonthValue(),
											datePelayanan.getDayOfMonth(), iso);
									org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
											tglIso.toDateTimeAtStartOfDay(), hijri);
									if (tglHijri.getMonthOfYear() == 9) {
										jamPulang = "14:00:00";
										timePulang = LocalTime.parse(jamPulang);
										datePulang = LocalDateTime.of(datePelayanan, timePulang);
									} else {
										jamPulang = "15:30:00";
										timePulang = LocalTime.parse(jamPulang);
										datePulang = LocalDateTime.of(datePelayanan, timePulang);
									}
								} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.FRIDAY)) {
									org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(
											datePelayanan.getYear(), datePelayanan.getMonthValue(),
											datePelayanan.getDayOfMonth(), iso);
									org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
											tglIso.toDateTimeAtStartOfDay(), hijri);
									if (tglHijri.getMonthOfYear() == 9) {
										jamPulang = "14:30:00";
										timePulang = LocalTime.parse(jamPulang);
										datePulang = LocalDateTime.of(datePelayanan, timePulang);
									} else {
										jamPulang = "16:00:00";
										timePulang = LocalTime.parse(jamPulang);
										datePulang = LocalDateTime.of(datePelayanan, timePulang);
									}
								} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
									jamPulang = "23:59:59";
									timePulang = LocalTime.parse(jamPulang);
									datePulang = LocalDateTime.of(datePelayanan, timePulang);
								}
							}

							String jamPulangPSBB = "";
							LocalTime timePulangPSBB = LocalTime.now();
							LocalDateTime datePulangPSBB = LocalDateTime.now();
							if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
								jamPulangPSBB = "14:00:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
								jamPulangPSBB = "14:30:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else {
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
							}

							if (map.get("namaShift").toString().contains("Malam")
									&& !map.get("namaShift").toString().contains("Pagi Sore Malam")) {
								datePulang = datePulang.plusDays(1);
							}

							if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
									|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
								if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
									if (!Master.KelompokPasien.BPJS
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											&& !Master.KelompokPasien.KEMENKES
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											&& !Master.KelompokPasien.JAMKESDA
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
										if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
												.contains(Integer.parseInt(map.get("departemenId").toString()))) {
											if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
													&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
												rawResult.add(map);
											} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
												rawResult.add(map);
											}
										} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
												.contains(Integer.parseInt(map.get("departemenId").toString()))
												&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
														.contains(Integer.parseInt(map.get("idKelas").toString()))) {
											rawResult.add(map);
										}
									}
								} else {
									if (!Master.KelompokPasien.BPJS
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											&& !Master.KelompokPasien.KEMENKES
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											&& !Master.KelompokPasien.JAMKESDA
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											&& (dateTimePelayanan.isBefore(dateMasuk)
													|| dateTimePelayanan.isEqual(datePulang)
													|| dateTimePelayanan.isAfter(datePulang))) {
										if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
												.contains(Integer.parseInt(map.get("departemenId").toString()))) {
											if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
													&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
												rawResult.add(map);
											} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
												rawResult.add(map);
											}
										} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
												.contains(Integer.parseInt(map.get("departemenId").toString()))
												&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
														.contains(Integer.parseInt(map.get("idKelas").toString()))
												&& !Arrays.stream(Master.KONSUL_VISIT).anyMatch(
														map.get("namaProduk").toString().toLowerCase()::contains)) {
											rawResult.add(map);
										}
									}
								}
							} else {
								if (!Master.KelompokPasien.BPJS
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
										&& !Master.KelompokPasien.KEMENKES
												.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
										&& !Master.KelompokPasien.JAMKESDA
												.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
									if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
											&& map.get("namaShift").toString().equals("Non Shift")
											&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
											&& (dateTimePelayanan.isEqual(PSBBDate)
													|| dateTimePelayanan.isAfter(PSBBDate))
											&& (dateTimePelayanan.isBefore(PSBBEnd)
													|| dateTimePelayanan.isEqual(PSBBEnd))) {
										if (dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulangPSBB)
												|| dateTimePelayanan.isAfter(datePulangPSBB)) {
											rawResult.add(map);
										}
									} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
											.contains(Integer.parseInt(map.get("departemenId").toString()))
											&& (dateTimePelayanan.isBefore(dateMasuk)
													|| dateTimePelayanan.isEqual(datePulang)
													|| dateTimePelayanan.isAfter(datePulang))) {
										if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
												&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
											rawResult.add(map);
										} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
											rawResult.add(map);
										}
									} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
											.contains(Integer.parseInt(map.get("departemenId").toString()))
											&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
													.contains(Integer.parseInt(map.get("idKelas").toString()))
											&& !Arrays.stream(Master.KONSUL_VISIT)
													.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
											&& (dateTimePelayanan.isBefore(dateMasuk)
													|| dateTimePelayanan.isEqual(datePulang)
													|| dateTimePelayanan.isAfter(datePulang))) {
										rawResult.add(map);
									}
								}
							}
						} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))) {
							if (!Master.KelompokPasien.BPJS
									.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
									&& !Master.KelompokPasien.KEMENKES
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
									&& !Master.KelompokPasien.JAMKESDA
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
								if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
										.contains(Integer.parseInt(map.get("departemenId").toString()))) {
									if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
											&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
										rawResult.add(map);
									} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
										rawResult.add(map);
									}
								} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
										&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
												.contains(Integer.parseInt(map.get("idKelas").toString()))) {
									rawResult.add(map);
								}
							}
						}
					}
				}
			}
		}

		if (CommonUtil.isNotNullOrEmpty(rawResult)) {
			for (Map<String, Object> map : rawResult) {
				if (!Arrays.asList(Master.JenisPetugasPelaksana.DOKTER_ANASTESI_OR_ASISTEN_SPESIALIS)
						.contains(Integer.parseInt(map.get("idJenisPelaksana").toString()))) {
					map.put("idJenisPelaksana", Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA);
				}
				if (!listProdukId.contains(Integer.parseInt(map.get("idProduk").toString()))) {
					listProdukId.add(Integer.parseInt(map.get("idProduk").toString()));
				}
				if (!listKelasId.contains(Integer.parseInt(map.get("idKelas").toString()))) {
					listKelasId.add(Integer.parseInt(map.get("idKelas").toString()));
				}
				if (!listTanggalPelayanan.contains(map.get("tanggal").toString())) {
					listTanggalPelayanan.add(map.get("tanggal").toString());
				}
			}

			for (String tanggal : listTanggalPelayanan) {
				for (Integer idProduk : listProdukId) {
					for (Integer idKelas : listKelasId) {
						Map<String, Object> mapResult = new HashMap<>();
						double count = 0.0;
						int dataCount = 0;
						for (Map<String, Object> map : rawResult) {
							if (Integer.parseInt(map.get("idProduk").toString()) == idProduk
									&& Integer.parseInt(map.get("idKelas").toString()) == idKelas
									&& map.get("tanggal").toString().equals(tanggal)) {
								count = count + Double.parseDouble(map.get("count").toString());
								dataCount = dataCount + 1;
								if (dataCount == 1) {
									mapResult.putAll(map);
								}
							}
						}
						if (CommonUtil.isNotNullOrEmpty(mapResult.get("count"))) {
							mapResult.put("count", count);
							result.add(mapResult);
						}
					}

				}
			}
		}

		return result;
	}

	@Override
	public List<Map<String, Object>> getAllTindakanRekapReportReview(String periode, Integer idPegawai) {
		List<Map<String, Object>> result = new ArrayList<>();

		List<Integer> listProdukId = new ArrayList<>();
		List<Integer> listKelasId = new ArrayList<>();
		List<Integer> listDetailJenisProduk = new ArrayList<>();
		List<Integer> listDetailJenisProdukException = new ArrayList<>();

		Chronology iso = ISOChronology.getInstance();
		Chronology hijri = IslamicChronology.getInstance();

		DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

		LocalDateTime PSBBDate = LocalDateTime.of(2020, 9, 14, 0, 0, 0);
		LocalDateTime PSBBEnd = LocalDateTime.parse(GetSettingDataFixed("psbbperiod"), dtf);

		List<Integer> laboranRadiologList = mapPegawaiLaboratRadiologiDao.findPegawaiLaboranRadiolog();
		List<Integer> drKsmUmumList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_UMUM);
		List<Integer> dokterLuar = pegawaiDao
				.getPegawaiByKategoryPegawai(Arrays.asList(Master.KategoryPegawai.DOKTER_LUAR));

		List<Integer> idsRegDJPAdminNonPK = splitDataSettingDatafixed("admin_nonpk");
		List<Integer> idsRegDJPMedisUtama = splitDataSettingDatafixed("medis_utama");
		List<Integer> idsRegDJPPenunjangPA = splitDataSettingDatafixed("penunjang_pa");
		List<Integer> idsRegDJPPenunjangPK = splitDataSettingDatafixed("penunjang_pk");
		List<Integer> idsRegDJPPenunjangRad = splitDataSettingDatafixed("penunjang_radiologi");

		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPA;
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPK;
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangRad;
		} else {
			listDetailJenisProduk = idsRegDJPMedisUtama;
		}

		if (laboranRadiologList.contains(idPegawai)) {
			listDetailJenisProdukException = idsRegDJPAdminNonPK;
			listDetailJenisProdukException.removeAll(listDetailJenisProduk);
		}

		List<Map<String, Object>> listData = revIndekKinerjaDao.getAllTindakanDokter(Master.Kelas.KELAS_SATU, idPegawai,
				Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA, periode);

		List<Integer> idsDokterUmumIGD = splitDataSettingDatafixed("pr_dokter_umum_igd");
		List<Integer> idsKonsultasiDokterJaga = splitDataSettingDatafixed("pr_konsultasi_dokter_jaga");

		if (CommonUtil.isNotNullOrEmpty(listData)) {
			for (Map<String, Object> map : listData) {
				if (!Arrays.asList(Master.JenisPetugasPelaksana.DOKTER_ANASTESI_OR_ASISTEN_SPESIALIS)
						.contains(Integer.parseInt(map.get("idJenisPelaksana").toString()))) {
					map.put("idJenisPelaksana", Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA);
				}
				if (!listProdukId.contains(Integer.parseInt(map.get("idProduk").toString()))) {
					listProdukId.add(Integer.parseInt(map.get("idProduk").toString()));
				}
				if (!listKelasId.contains(Integer.parseInt(map.get("idKelas").toString()))) {
					listKelasId.add(Integer.parseInt(map.get("idKelas").toString()));
				}
			}

			for (Integer idProduk : listProdukId) {
				for (Integer idKelas : listKelasId) {
					long remun = 0L;
					long ffs = 0L;
					long count = 0L;
					int dataCountRemun = 0;
					int dataCountFfs = 0;
					Map<String, Object> mapResult = new HashMap<>();
					for (Map<String, Object> map : listData) {
						if (listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))) {
							if (Integer.parseInt(map.get("idProduk").toString()) == idProduk
									&& Integer.parseInt(map.get("idKelas").toString()) == idKelas) {
								if (!dokterLuar.contains(idPegawai)) {
									if (idsRegDJPPenunjangPA.contains(Integer.parseInt(map.get("detailId").toString()))
											|| idsRegDJPPenunjangPK
													.contains(Integer.parseInt(map.get("detailId").toString()))) {
										remun = remun + (new Double(Double.parseDouble(map.get("count").toString())))
												.longValue();
										dataCountRemun = dataCountRemun + 1;
									} else if (Master.KelompokPasien.BPJS
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											|| Master.KelompokPasien.KEMENKES
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											|| Master.KelompokPasien.JAMKESDA
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
										remun = remun + (new Double(Double.parseDouble(map.get("count").toString())))
												.longValue();
										dataCountRemun = dataCountRemun + 1;
									} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
										Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
										String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd")
												.format(tanggalPelayanan);
										String waktuPelayanan = new SimpleDateFormat("HH:mm:ss")
												.format(tanggalPelayanan);
										LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
										LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
										LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan,
												timePelayanan);

										String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
												+ map.get("jamMasuk").toString().substring(3) + ":00";
										LocalTime timeMasuk = LocalTime.parse(jamMasuk);
										LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
										LocalDateTime dateMasukFfs = LocalDateTime.of(datePelayanan, timeMasuk);
										if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
											if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.MONDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.TUESDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.THURSDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.FRIDAY)) {
												jamMasuk = "07:00:00";
												timeMasuk = LocalTime.parse(jamMasuk);
												dateMasukFfs = LocalDateTime.of(datePelayanan, timeMasuk);
											} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
												jamMasuk = "00:00:00";
												timeMasuk = LocalTime.parse(jamMasuk);
												dateMasukFfs = LocalDateTime.of(datePelayanan, timeMasuk);
											}
										}

										String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
												+ map.get("jamPulang").toString().substring(3) + ":00";
										LocalTime timePulang = LocalTime.parse(jamPulang);
										LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);
										LocalDateTime datePulangFfs = LocalDateTime.of(datePelayanan, timePulang);
										if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
											if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.MONDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.TUESDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.THURSDAY)) {
												org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(
														datePelayanan.getYear(), datePelayanan.getMonthValue(),
														datePelayanan.getDayOfMonth(), iso);
												org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
														tglIso.toDateTimeAtStartOfDay(), hijri);
												if (tglHijri.getMonthOfYear() == 9) {
													jamPulang = "14:00:00";
													timePulang = LocalTime.parse(jamPulang);
													datePulangFfs = LocalDateTime.of(datePelayanan, timePulang);
												} else {
													jamPulang = "15:30:00";
													timePulang = LocalTime.parse(jamPulang);
													datePulangFfs = LocalDateTime.of(datePelayanan, timePulang);
												}
											} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.FRIDAY)) {
												org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(
														datePelayanan.getYear(), datePelayanan.getMonthValue(),
														datePelayanan.getDayOfMonth(), iso);
												org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
														tglIso.toDateTimeAtStartOfDay(), hijri);
												if (tglHijri.getMonthOfYear() == 9) {
													jamPulang = "14:30:00";
													timePulang = LocalTime.parse(jamPulang);
													datePulangFfs = LocalDateTime.of(datePelayanan, timePulang);
												} else {
													jamPulang = "16:00:00";
													timePulang = LocalTime.parse(jamPulang);
													datePulangFfs = LocalDateTime.of(datePelayanan, timePulang);
												}
											} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
												jamPulang = "23:59:59";
												timePulang = LocalTime.parse(jamPulang);
												datePulangFfs = LocalDateTime.of(datePelayanan, timePulang);
											}
										}

										String jamPulangPSBB = "";
										LocalTime timePulangPSBB = LocalTime.now();
										LocalDateTime datePulangPSBB = LocalDateTime.now();
										if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
												|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
												|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
												|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
											jamPulangPSBB = "14:00:00";
											timePulangPSBB = LocalTime.parse(jamPulangPSBB);
											datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
										} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
											jamPulangPSBB = "14:30:00";
											timePulangPSBB = LocalTime.parse(jamPulangPSBB);
											datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
										} else {
											datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
										}

										if (map.get("namaShift").toString().contains("Malam")
												&& !map.get("namaShift").toString().contains("Pagi Sore Malam")) {
											datePulang = datePulang.plusDays(1);
											datePulangFfs = datePulang.plusDays(1);
										}

										if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
												.contains(Integer.parseInt(map.get("departemenId").toString()))
												&& ((dateTimePelayanan.isEqual(dateMasuk)
														|| dateTimePelayanan.isAfter(dateMasuk))
														&& dateTimePelayanan.isBefore(datePulang))) {
											remun = remun
													+ (new Double(Double.parseDouble(map.get("count").toString())))
															.longValue();
											dataCountRemun = dataCountRemun + 1;
										} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
												&& !Arrays.asList(Master.Ruangan.NONRANAP)
														.contains(map.get("ruanganId"))
												&& Arrays.stream(Master.KONSUL_VISIT).anyMatch(
														map.get("namaProduk").toString().toLowerCase()::contains)
												&& (dateTimePelayanan.isBefore(dateMasuk)
														|| dateTimePelayanan.isEqual(datePulang)
														|| dateTimePelayanan.isAfter(datePulang))) {
											remun = remun
													+ (new Double(Double.parseDouble(map.get("count").toString())))
															.longValue();
											dataCountRemun = dataCountRemun + 1;
										} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
												.contains(Integer.parseInt(map.get("departemenId").toString()))
												&& (dateTimePelayanan.isBefore(dateMasuk)
														|| dateTimePelayanan.isEqual(datePulang)
														|| dateTimePelayanan.isAfter(datePulang))
												&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
														.contains(Integer.parseInt(map.get("idKelas").toString()))) {
											remun = remun
													+ (new Double(Double.parseDouble(map.get("count").toString())))
															.longValue();
											dataCountRemun = dataCountRemun + 1;
										} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
												&& map.get("namaShift").toString().equals("Non Shift")
												&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
												&& (dateTimePelayanan.isEqual(PSBBDate)
														|| dateTimePelayanan.isAfter(PSBBDate))
												&& (dateTimePelayanan.isBefore(PSBBEnd)
														|| dateTimePelayanan.isEqual(PSBBEnd))) {
											if (((dateTimePelayanan.isEqual(dateMasuk)
													|| dateTimePelayanan.isAfter(dateMasuk))
													&& dateTimePelayanan.isBefore(datePulangPSBB))) {
												remun = remun
														+ (new Double(Double.parseDouble(map.get("count").toString())))
																.longValue();
												dataCountRemun = dataCountRemun + 1;
											} else if (!Master.KelompokPasien.BPJS
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
													&& !Master.KelompokPasien.KEMENKES.equals(
															Integer.parseInt(map.get("kelompokPasienId").toString()))
													&& !Master.KelompokPasien.JAMKESDA.equals(
															Integer.parseInt(map.get("kelompokPasienId").toString()))) {
												if (!idsRegDJPPenunjangPA
														.contains(Integer.parseInt(map.get("detailId").toString()))
														&& !idsRegDJPPenunjangPK.contains(
																Integer.parseInt(map.get("detailId").toString()))) {
													if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
															&& map.get("namaShift").toString().equals("Non Shift")
															&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
															&& (dateTimePelayanan.isEqual(PSBBDate)
																	|| dateTimePelayanan.isAfter(PSBBDate))
															&& (dateTimePelayanan.isBefore(PSBBEnd)
																	|| dateTimePelayanan.isEqual(PSBBEnd))) {
														if (dateTimePelayanan.isBefore(dateMasuk)
																|| dateTimePelayanan.isEqual(datePulangPSBB)
																|| dateTimePelayanan.isAfter(datePulangPSBB)) {
															ffs = ffs + (new Double(
																	Double.parseDouble(map.get("count").toString())))
																			.longValue();
															dataCountFfs = dataCountFfs + 1;
														}
													}
												}
											}
										} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
												.contains(Integer.parseInt(map.get("departemenId").toString()))
												&& ((dateTimePelayanan.isEqual(dateMasuk)
														|| dateTimePelayanan.isAfter(dateMasuk))
														&& dateTimePelayanan.isBefore(datePulang))) {
											remun = remun
													+ (new Double(Double.parseDouble(map.get("count").toString())))
															.longValue();
											dataCountRemun = dataCountRemun + 1;
										} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
											if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
												if (!Master.KelompokPasien.BPJS.equals(
														Integer.parseInt(map.get("kelompokPasienId").toString()))
														&& !Master.KelompokPasien.KEMENKES.equals(Integer
																.parseInt(map.get("kelompokPasienId").toString()))
														&& !Master.KelompokPasien.JAMKESDA.equals(Integer
																.parseInt(map.get("kelompokPasienId").toString()))) {
													if (!idsRegDJPPenunjangPA
															.contains(Integer.parseInt(map.get("detailId").toString()))
															&& !idsRegDJPPenunjangPK.contains(
																	Integer.parseInt(map.get("detailId").toString()))) {
														if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN).contains(
																Integer.parseInt(map.get("departemenId").toString()))) {
															if (map.get("ruanganId")
																	.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
																	&& idsKonsultasiDokterJaga
																			.contains(map.get("idProduk"))) {
																ffs = ffs + (new Double(Double
																		.parseDouble(map.get("count").toString())))
																				.longValue();
																dataCountFfs = dataCountFfs + 1;
															} else if (!map.get("departemenId")
																	.equals(Master.Departemen.IGD)) {
																ffs = ffs + (new Double(Double
																		.parseDouble(map.get("count").toString())))
																				.longValue();
																dataCountFfs = dataCountFfs + 1;
															}
														} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
																.contains(Integer
																		.parseInt(map.get("departemenId").toString()))
																&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
																		.contains(Integer.parseInt(
																				map.get("idKelas").toString()))) {
															ffs = ffs + (new Double(
																	Double.parseDouble(map.get("count").toString())))
																			.longValue();
															dataCountFfs = dataCountFfs + 1;
														}
													}
												}
											} else {
												if (!Master.KelompokPasien.BPJS.equals(
														Integer.parseInt(map.get("kelompokPasienId").toString()))
														&& !Master.KelompokPasien.KEMENKES.equals(Integer
																.parseInt(map.get("kelompokPasienId").toString()))
														&& !Master.KelompokPasien.JAMKESDA.equals(Integer
																.parseInt(map.get("kelompokPasienId").toString()))
														&& (dateTimePelayanan.isBefore(dateMasukFfs)
																|| dateTimePelayanan.isEqual(datePulangFfs)
																|| dateTimePelayanan.isAfter(datePulangFfs))) {
													if (!idsRegDJPPenunjangPA
															.contains(Integer.parseInt(map.get("detailId").toString()))
															&& !idsRegDJPPenunjangPK.contains(
																	Integer.parseInt(map.get("detailId").toString()))) {
														if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN).contains(
																Integer.parseInt(map.get("departemenId").toString()))) {
															if (map.get("ruanganId")
																	.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
																	&& idsKonsultasiDokterJaga
																			.contains(map.get("idProduk"))) {
																ffs = ffs + (new Double(Double
																		.parseDouble(map.get("count").toString())))
																				.longValue();
																dataCountFfs = dataCountFfs + 1;
															} else if (!map.get("departemenId")
																	.equals(Master.Departemen.IGD)) {
																ffs = ffs + (new Double(Double
																		.parseDouble(map.get("count").toString())))
																				.longValue();
																dataCountFfs = dataCountFfs + 1;
															}
														} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
																.contains(Integer
																		.parseInt(map.get("departemenId").toString()))
																&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP).contains(
																		Integer.parseInt(map.get("idKelas").toString()))
																&& !Arrays.stream(Master.KONSUL_VISIT)
																		.anyMatch(map.get("namaProduk").toString()
																				.toLowerCase()::contains)) {
															ffs = ffs + (new Double(
																	Double.parseDouble(map.get("count").toString())))
																			.longValue();
															dataCountFfs = dataCountFfs + 1;
														}
													}
												}
											}
										} else if (!Master.KelompokPasien.BPJS
												.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
												&& !Master.KelompokPasien.KEMENKES.equals(
														Integer.parseInt(map.get("kelompokPasienId").toString()))
												&& !Master.KelompokPasien.JAMKESDA.equals(
														Integer.parseInt(map.get("kelompokPasienId").toString()))) {
											if (!idsRegDJPPenunjangPA
													.contains(Integer.parseInt(map.get("detailId").toString()))
													&& !idsRegDJPPenunjangPK.contains(
															Integer.parseInt(map.get("detailId").toString()))) {
												if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
														.contains(Integer.parseInt(map.get("departemenId").toString()))
														&& (dateTimePelayanan.isBefore(dateMasukFfs)
																|| dateTimePelayanan.isEqual(datePulangFfs)
																|| dateTimePelayanan.isAfter(datePulangFfs))) {
													if (map.get("ruanganId")
															.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
															&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
														ffs = ffs + (new Double(
																Double.parseDouble(map.get("count").toString())))
																		.longValue();
														dataCountFfs = dataCountFfs + 1;
													} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
														ffs = ffs + (new Double(
																Double.parseDouble(map.get("count").toString())))
																		.longValue();
														dataCountFfs = dataCountFfs + 1;
													}
												} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
														.contains(Integer.parseInt(map.get("departemenId").toString()))
														&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP).contains(
																Integer.parseInt(map.get("idKelas").toString()))
														&& !Arrays.stream(Master.KONSUL_VISIT)
																.anyMatch(map.get("namaProduk").toString()
																		.toLowerCase()::contains)
														&& (dateTimePelayanan.isBefore(dateMasukFfs)
																|| dateTimePelayanan.isEqual(datePulangFfs)
																|| dateTimePelayanan.isAfter(datePulangFfs))) {
													ffs = ffs + (new Double(
															Double.parseDouble(map.get("count").toString())))
																	.longValue();
													dataCountFfs = dataCountFfs + 1;
												}
											}
										}
									} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
											&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
													.contains(Integer.parseInt(map.get("departemenId").toString()))
											&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
													.contains(Integer.parseInt(map.get("idKelas").toString()))) {
										remun = remun + (new Double(Double.parseDouble(map.get("count").toString())))
												.longValue();
										dataCountRemun = dataCountRemun + 1;
									} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))) {
										if (!Master.KelompokPasien.BPJS
												.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
												&& !Master.KelompokPasien.KEMENKES.equals(
														Integer.parseInt(map.get("kelompokPasienId").toString()))
												&& !Master.KelompokPasien.JAMKESDA.equals(
														Integer.parseInt(map.get("kelompokPasienId").toString()))) {
											if (!idsRegDJPPenunjangPA
													.contains(Integer.parseInt(map.get("detailId").toString()))
													&& !idsRegDJPPenunjangPK.contains(
															Integer.parseInt(map.get("detailId").toString()))) {
												if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN).contains(
														Integer.parseInt(map.get("departemenId").toString()))) {
													if (map.get("ruanganId")
															.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
															&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
														ffs = ffs + (new Double(
																Double.parseDouble(map.get("count").toString())))
																		.longValue();
														dataCountFfs = dataCountFfs + 1;
													} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
														ffs = ffs + (new Double(
																Double.parseDouble(map.get("count").toString())))
																		.longValue();
														dataCountFfs = dataCountFfs + 1;
													}
												} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
														.contains(Integer.parseInt(map.get("departemenId").toString()))
														&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP).contains(
																Integer.parseInt(map.get("idKelas").toString()))) {
													ffs = ffs + (new Double(
															Double.parseDouble(map.get("count").toString())))
																	.longValue();
													// RULES_NOTE_SK_2015_DI_2019
													if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
															&& !Arrays.asList(Master.Ruangan.NONRANAP)
																	.contains(map.get("ruanganId"))) {
														if (Arrays.stream(Master.KONSUL_VISIT)
																.anyMatch(map.get("namaProduk").toString()
																		.toLowerCase()::contains)) {
															dataCountFfs = dataCountFfs + 1;
														}
													} else {
														dataCountFfs = dataCountFfs + 1;
													}
												}
											}
										}
									}
								} else if (dokterLuar.contains(idPegawai)) {
									if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
											&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
										ffs = ffs + (new Double(Double.parseDouble(map.get("count").toString())))
												.longValue();
										dataCountFfs = dataCountFfs + 1;
									} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
										ffs = ffs + (new Double(Double.parseDouble(map.get("count").toString())))
												.longValue();
										dataCountFfs = dataCountFfs + 1;
									}
								}

								if ((dataCountRemun == 1 && dataCountFfs == 0)
										|| (dataCountRemun == 0 && dataCountFfs == 1)) {
									mapResult.putAll(map);
								}
							} // endif
							if (CommonUtil.isNotNullOrEmpty(mapResult.get("idProduk"))) {
								count = remun + ffs;
								mapResult.put("remun", remun);
								mapResult.put("ffs", ffs);
								mapResult.put("count", count);
							}
						} else if (!listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))
								&& map.get("departemenId").equals(Master.Departemen.IGD)
								&& drKsmUmumList.contains(idPegawai)
								&& idsDokterUmumIGD.contains(Integer.parseInt(map.get("idProduk").toString()))) {
							if (Integer.parseInt(map.get("idProduk").toString()) == idProduk
									&& Integer.parseInt(map.get("idKelas").toString()) == idKelas) {
								if (!dokterLuar.contains(idPegawai)) {
									if (Master.KelompokPasien.BPJS
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											|| Master.KelompokPasien.KEMENKES
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											|| Master.KelompokPasien.JAMKESDA
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
										remun = remun + (new Double(Double.parseDouble(map.get("count").toString())))
												.longValue();
										dataCountRemun = dataCountRemun + 1;
									} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
										Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
										String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd")
												.format(tanggalPelayanan);
										String waktuPelayanan = new SimpleDateFormat("HH:mm:ss")
												.format(tanggalPelayanan);
										LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
										LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
										LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan,
												timePelayanan);

										String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
												+ map.get("jamMasuk").toString().substring(3) + ":00";
										LocalTime timeMasuk = LocalTime.parse(jamMasuk);
										LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
										LocalDateTime dateMasukFfs = LocalDateTime.of(datePelayanan, timeMasuk);
										if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
											if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.MONDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.TUESDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.THURSDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.FRIDAY)) {
												jamMasuk = "07:00:00";
												timeMasuk = LocalTime.parse(jamMasuk);
												dateMasukFfs = LocalDateTime.of(datePelayanan, timeMasuk);
											} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
												jamMasuk = "00:00:00";
												timeMasuk = LocalTime.parse(jamMasuk);
												dateMasukFfs = LocalDateTime.of(datePelayanan, timeMasuk);
											}
										}

										String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
												+ map.get("jamPulang").toString().substring(3) + ":00";
										LocalTime timePulang = LocalTime.parse(jamPulang);
										LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);
										LocalDateTime datePulangFfs = LocalDateTime.of(datePelayanan, timePulang);
										if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
											if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.MONDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.TUESDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.THURSDAY)) {
												org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(
														datePelayanan.getYear(), datePelayanan.getMonthValue(),
														datePelayanan.getDayOfMonth(), iso);
												org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
														tglIso.toDateTimeAtStartOfDay(), hijri);
												if (tglHijri.getMonthOfYear() == 9) {
													jamPulang = "14:00:00";
													timePulang = LocalTime.parse(jamPulang);
													datePulangFfs = LocalDateTime.of(datePelayanan, timePulang);
												} else {
													jamPulang = "15:30:00";
													timePulang = LocalTime.parse(jamPulang);
													datePulangFfs = LocalDateTime.of(datePelayanan, timePulang);
												}
											} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.FRIDAY)) {
												org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(
														datePelayanan.getYear(), datePelayanan.getMonthValue(),
														datePelayanan.getDayOfMonth(), iso);
												org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
														tglIso.toDateTimeAtStartOfDay(), hijri);
												if (tglHijri.getMonthOfYear() == 9) {
													jamPulang = "14:30:00";
													timePulang = LocalTime.parse(jamPulang);
													datePulangFfs = LocalDateTime.of(datePelayanan, timePulang);
												} else {
													jamPulang = "16:00:00";
													timePulang = LocalTime.parse(jamPulang);
													datePulangFfs = LocalDateTime.of(datePelayanan, timePulang);
												}
											} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
												jamPulang = "23:59:59";
												timePulang = LocalTime.parse(jamPulang);
												datePulangFfs = LocalDateTime.of(datePelayanan, timePulang);
											}
										}

										String jamPulangPSBB = "";
										LocalTime timePulangPSBB = LocalTime.now();
										LocalDateTime datePulangPSBB = LocalDateTime.now();
										if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
												|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
												|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
												|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
											jamPulangPSBB = "14:00:00";
											timePulangPSBB = LocalTime.parse(jamPulangPSBB);
											datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
										} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
											jamPulangPSBB = "14:30:00";
											timePulangPSBB = LocalTime.parse(jamPulangPSBB);
											datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
										} else {
											datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
										}

										if (map.get("namaShift").toString().contains("Malam")
												&& !map.get("namaShift").toString().contains("Pagi Sore Malam")) {
											datePulang = datePulang.plusDays(1);
											datePulangFfs = datePulang.plusDays(1);
										}

										if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
												.contains(Integer.parseInt(map.get("departemenId").toString()))
												&& ((dateTimePelayanan.isEqual(dateMasuk)
														|| dateTimePelayanan.isAfter(dateMasuk))
														&& dateTimePelayanan.isBefore(datePulang))) {
											remun = remun
													+ (new Double(Double.parseDouble(map.get("count").toString())))
															.longValue();
											dataCountRemun = dataCountRemun + 1;
										} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
												&& !Arrays.asList(Master.Ruangan.NONRANAP)
														.contains(map.get("ruanganId"))
												&& Arrays.stream(Master.KONSUL_VISIT).anyMatch(
														map.get("namaProduk").toString().toLowerCase()::contains)
												&& (dateTimePelayanan.isBefore(dateMasuk)
														|| dateTimePelayanan.isEqual(datePulang)
														|| dateTimePelayanan.isAfter(datePulang))) {
											remun = remun
													+ (new Double(Double.parseDouble(map.get("count").toString())))
															.longValue();
											dataCountRemun = dataCountRemun + 1;
										} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
												.contains(Integer.parseInt(map.get("departemenId").toString()))
												&& (dateTimePelayanan.isBefore(dateMasuk)
														|| dateTimePelayanan.isEqual(datePulang)
														|| dateTimePelayanan.isAfter(datePulang))
												&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
														.contains(Integer.parseInt(map.get("idKelas").toString()))) {
											remun = remun
													+ (new Double(Double.parseDouble(map.get("count").toString())))
															.longValue();
											dataCountRemun = dataCountRemun + 1;
										} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
												&& map.get("namaShift").toString().equals("Non Shift")
												&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
												&& (dateTimePelayanan.isEqual(PSBBDate)
														|| dateTimePelayanan.isAfter(PSBBDate))
												&& (dateTimePelayanan.isBefore(PSBBEnd)
														|| dateTimePelayanan.isEqual(PSBBEnd))) {
											if (((dateTimePelayanan.isEqual(dateMasuk)
													|| dateTimePelayanan.isAfter(dateMasuk))
													&& dateTimePelayanan.isBefore(datePulangPSBB))) {
												remun = remun
														+ (new Double(Double.parseDouble(map.get("count").toString())))
																.longValue();
												dataCountRemun = dataCountRemun + 1;
											} else if (!Master.KelompokPasien.BPJS
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
													&& !Master.KelompokPasien.KEMENKES.equals(
															Integer.parseInt(map.get("kelompokPasienId").toString()))
													&& !Master.KelompokPasien.JAMKESDA.equals(
															Integer.parseInt(map.get("kelompokPasienId").toString()))) {
												if (!idsRegDJPPenunjangPA
														.contains(Integer.parseInt(map.get("detailId").toString()))
														&& !idsRegDJPPenunjangPK.contains(
																Integer.parseInt(map.get("detailId").toString()))) {
													if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
															&& map.get("namaShift").toString().equals("Non Shift")
															&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
															&& (dateTimePelayanan.isEqual(PSBBDate)
																	|| dateTimePelayanan.isAfter(PSBBDate))
															&& (dateTimePelayanan.isBefore(PSBBEnd)
																	|| dateTimePelayanan.isEqual(PSBBEnd))) {
														if (dateTimePelayanan.isBefore(dateMasuk)
																|| dateTimePelayanan.isEqual(datePulangPSBB)
																|| dateTimePelayanan.isAfter(datePulangPSBB)) {
															ffs = ffs + (new Double(
																	Double.parseDouble(map.get("count").toString())))
																			.longValue();
															dataCountFfs = dataCountFfs + 1;
														}
													}
												}
											}
										} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
												.contains(Integer.parseInt(map.get("departemenId").toString()))
												&& ((dateTimePelayanan.isEqual(dateMasuk)
														|| dateTimePelayanan.isAfter(dateMasuk))
														&& (dateTimePelayanan.isBefore(datePulang)
																|| dateTimePelayanan.isEqual(datePulang)))) {
											remun = remun
													+ (new Double(Double.parseDouble(map.get("count").toString())))
															.longValue();
											dataCountRemun = dataCountRemun + 1;
										} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
											if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
												if (!Master.KelompokPasien.BPJS.equals(
														Integer.parseInt(map.get("kelompokPasienId").toString()))
														&& !Master.KelompokPasien.KEMENKES.equals(Integer
																.parseInt(map.get("kelompokPasienId").toString()))
														&& !Master.KelompokPasien.JAMKESDA.equals(Integer
																.parseInt(map.get("kelompokPasienId").toString()))) {
													if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN).contains(
															Integer.parseInt(map.get("departemenId").toString()))) {
														if (map.get("ruanganId")
																.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
																&& idsKonsultasiDokterJaga
																		.contains(map.get("idProduk"))) {
															ffs = ffs + (new Double(
																	Double.parseDouble(map.get("count").toString())))
																			.longValue();
															dataCountFfs = dataCountFfs + 1;
														} else if (!map.get("departemenId")
																.equals(Master.Departemen.IGD)) {
															ffs = ffs + (new Double(
																	Double.parseDouble(map.get("count").toString())))
																			.longValue();
															dataCountFfs = dataCountFfs + 1;
														}
													} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
															.contains(Integer
																	.parseInt(map.get("departemenId").toString()))
															&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP).contains(
																	Integer.parseInt(map.get("idKelas").toString()))) {
														ffs = ffs + (new Double(
																Double.parseDouble(map.get("count").toString())))
																		.longValue();
														dataCountFfs = dataCountFfs + 1;
													}
												}
											} else {
												if (!Master.KelompokPasien.BPJS.equals(
														Integer.parseInt(map.get("kelompokPasienId").toString()))
														&& !Master.KelompokPasien.KEMENKES.equals(Integer
																.parseInt(map.get("kelompokPasienId").toString()))
														&& !Master.KelompokPasien.JAMKESDA.equals(Integer
																.parseInt(map.get("kelompokPasienId").toString()))
														&& (dateTimePelayanan.isBefore(dateMasukFfs)
																|| dateTimePelayanan.isEqual(datePulangFfs)
																|| dateTimePelayanan.isAfter(datePulangFfs))) {
													if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN).contains(
															Integer.parseInt(map.get("departemenId").toString()))) {
														if (map.get("ruanganId")
																.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
																&& idsKonsultasiDokterJaga
																		.contains(map.get("idProduk"))) {
															ffs = ffs + (new Double(
																	Double.parseDouble(map.get("count").toString())))
																			.longValue();
															dataCountFfs = dataCountFfs + 1;
														} else if (!map.get("departemenId")
																.equals(Master.Departemen.IGD)) {
															ffs = ffs + (new Double(
																	Double.parseDouble(map.get("count").toString())))
																			.longValue();
															dataCountFfs = dataCountFfs + 1;
														}
													} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
															.contains(Integer
																	.parseInt(map.get("departemenId").toString()))
															&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP).contains(
																	Integer.parseInt(map.get("idKelas").toString()))
															&& !Arrays.stream(Master.KONSUL_VISIT)
																	.anyMatch(map.get("namaProduk").toString()
																			.toLowerCase()::contains)) {
														ffs = ffs + (new Double(
																Double.parseDouble(map.get("count").toString())))
																		.longValue();
														dataCountFfs = dataCountFfs + 1;
													}
												}
											}
										} else if (!Master.KelompokPasien.BPJS
												.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
												&& !Master.KelompokPasien.KEMENKES.equals(
														Integer.parseInt(map.get("kelompokPasienId").toString()))
												&& !Master.KelompokPasien.JAMKESDA.equals(
														Integer.parseInt(map.get("kelompokPasienId").toString()))) {
											if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
													.contains(Integer.parseInt(map.get("departemenId").toString()))
													&& (dateTimePelayanan.isBefore(dateMasukFfs)
															|| dateTimePelayanan.isEqual(datePulangFfs)
															|| dateTimePelayanan.isAfter(datePulangFfs))) {
												if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
														&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
													ffs = ffs + (new Double(
															Double.parseDouble(map.get("count").toString())))
																	.longValue();
													dataCountFfs = dataCountFfs + 1;
												} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
													ffs = ffs + (new Double(
															Double.parseDouble(map.get("count").toString())))
																	.longValue();
													dataCountFfs = dataCountFfs + 1;
												}
											} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
													.contains(Integer.parseInt(map.get("departemenId").toString()))
													&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
															.contains(Integer.parseInt(map.get("idKelas").toString()))
													&& !Arrays.stream(Master.KONSUL_VISIT).anyMatch(
															map.get("namaProduk").toString().toLowerCase()::contains)
													&& (dateTimePelayanan.isBefore(dateMasukFfs)
															|| dateTimePelayanan.isEqual(datePulangFfs)
															|| dateTimePelayanan.isAfter(datePulangFfs))) {
												ffs = ffs
														+ (new Double(Double.parseDouble(map.get("count").toString())))
																.longValue();
												dataCountFfs = dataCountFfs + 1;
											}
										}
									} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
											&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
													.contains(Integer.parseInt(map.get("departemenId").toString()))
											&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
													.contains(Integer.parseInt(map.get("idKelas").toString()))) {
										remun = remun + (new Double(Double.parseDouble(map.get("count").toString())))
												.longValue();
										dataCountRemun = dataCountRemun + 1;
									} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))) {
										if (!Master.KelompokPasien.BPJS
												.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
												&& !Master.KelompokPasien.KEMENKES.equals(
														Integer.parseInt(map.get("kelompokPasienId").toString()))
												&& !Master.KelompokPasien.JAMKESDA.equals(
														Integer.parseInt(map.get("kelompokPasienId").toString()))) {
											if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
													.contains(Integer.parseInt(map.get("departemenId").toString()))) {
												if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
														&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
													ffs = ffs + (new Double(
															Double.parseDouble(map.get("count").toString())))
																	.longValue();
													dataCountFfs = dataCountFfs + 1;
												} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
													ffs = ffs + (new Double(
															Double.parseDouble(map.get("count").toString())))
																	.longValue();
													dataCountFfs = dataCountFfs + 1;
												}
											} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
													.contains(Integer.parseInt(map.get("departemenId").toString()))
													&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP).contains(
															Integer.parseInt(map.get("idKelas").toString()))) {
												ffs = ffs
														+ (new Double(Double.parseDouble(map.get("count").toString())))
																.longValue();
												// RULES_NOTE_SK_2015_DI_2019
												if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
														&& !Arrays.asList(Master.Ruangan.NONRANAP)
																.contains(map.get("ruanganId"))) {
													if (Arrays.stream(Master.KONSUL_VISIT).anyMatch(
															map.get("namaProduk").toString().toLowerCase()::contains)) {
														dataCountFfs = dataCountFfs + 1;
													}
												} else {
													dataCountFfs = dataCountFfs + 1;
												}
											}
										}
									}
								} else if (dokterLuar.contains(idPegawai)) {
									if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
											&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
										ffs = ffs + (new Double(Double.parseDouble(map.get("count").toString())))
												.longValue();
										dataCountFfs = dataCountFfs + 1;
									} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
										ffs = ffs + (new Double(Double.parseDouble(map.get("count").toString())))
												.longValue();
										dataCountFfs = dataCountFfs + 1;
									}
								}

								if ((dataCountRemun == 1 && dataCountFfs == 0)
										|| (dataCountRemun == 0 && dataCountFfs == 1)) {
									mapResult.putAll(map);
								}
							} // endif
							if (CommonUtil.isNotNullOrEmpty(mapResult.get("idProduk"))) {
								count = remun + ffs;
								mapResult.put("remun", remun);
								mapResult.put("ffs", ffs);
								mapResult.put("count", count);
							}
						} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProdukException)
								&& listDetailJenisProdukException
										.contains(Integer.parseInt(map.get("detailId").toString()))) {
							if (Integer.parseInt(map.get("idProduk").toString()) == idProduk
									&& Integer.parseInt(map.get("idKelas").toString()) == idKelas) {
								if (!dokterLuar.contains(idPegawai)) {
									if (idsRegDJPPenunjangPA.contains(Integer.parseInt(map.get("detailId").toString()))
											|| idsRegDJPPenunjangPK
													.contains(Integer.parseInt(map.get("detailId").toString()))) {
										remun = remun + (new Double(Double.parseDouble(map.get("count").toString())))
												.longValue();
										dataCountRemun = dataCountRemun + 1;
									} else if (Master.KelompokPasien.BPJS
											.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											|| Master.KelompokPasien.KEMENKES
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
											|| Master.KelompokPasien.JAMKESDA
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
										remun = remun + (new Double(Double.parseDouble(map.get("count").toString())))
												.longValue();
										dataCountRemun = dataCountRemun + 1;
									} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
										Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
										String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd")
												.format(tanggalPelayanan);
										String waktuPelayanan = new SimpleDateFormat("HH:mm:ss")
												.format(tanggalPelayanan);
										LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
										LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
										LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan,
												timePelayanan);

										String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
												+ map.get("jamMasuk").toString().substring(3) + ":00";
										LocalTime timeMasuk = LocalTime.parse(jamMasuk);
										LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);
										LocalDateTime dateMasukFfs = LocalDateTime.of(datePelayanan, timeMasuk);
										if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
											if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.MONDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.TUESDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.THURSDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.FRIDAY)) {
												jamMasuk = "07:00:00";
												timeMasuk = LocalTime.parse(jamMasuk);
												dateMasukFfs = LocalDateTime.of(datePelayanan, timeMasuk);
											} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
												jamMasuk = "00:00:00";
												timeMasuk = LocalTime.parse(jamMasuk);
												dateMasukFfs = LocalDateTime.of(datePelayanan, timeMasuk);
											}
										}

										String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
												+ map.get("jamPulang").toString().substring(3) + ":00";
										LocalTime timePulang = LocalTime.parse(jamPulang);
										LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);
										LocalDateTime datePulangFfs = LocalDateTime.of(datePelayanan, timePulang);
										if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
											if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.MONDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.TUESDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.THURSDAY)) {
												org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(
														datePelayanan.getYear(), datePelayanan.getMonthValue(),
														datePelayanan.getDayOfMonth(), iso);
												org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
														tglIso.toDateTimeAtStartOfDay(), hijri);
												if (tglHijri.getMonthOfYear() == 9) {
													jamPulang = "14:00:00";
													timePulang = LocalTime.parse(jamPulang);
													datePulangFfs = LocalDateTime.of(datePelayanan, timePulang);
												} else {
													jamPulang = "15:30:00";
													timePulang = LocalTime.parse(jamPulang);
													datePulangFfs = LocalDateTime.of(datePelayanan, timePulang);
												}
											} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.FRIDAY)) {
												org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(
														datePelayanan.getYear(), datePelayanan.getMonthValue(),
														datePelayanan.getDayOfMonth(), iso);
												org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
														tglIso.toDateTimeAtStartOfDay(), hijri);
												if (tglHijri.getMonthOfYear() == 9) {
													jamPulang = "14:30:00";
													timePulang = LocalTime.parse(jamPulang);
													datePulangFfs = LocalDateTime.of(datePelayanan, timePulang);
												} else {
													jamPulang = "16:00:00";
													timePulang = LocalTime.parse(jamPulang);
													datePulangFfs = LocalDateTime.of(datePelayanan, timePulang);
												}
											} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
													|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
												jamPulang = "23:59:59";
												timePulang = LocalTime.parse(jamPulang);
												datePulangFfs = LocalDateTime.of(datePelayanan, timePulang);
											}
										}

										String jamPulangPSBB = "";
										LocalTime timePulangPSBB = LocalTime.now();
										LocalDateTime datePulangPSBB = LocalDateTime.now();
										if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
												|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
												|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
												|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
											jamPulangPSBB = "14:00:00";
											timePulangPSBB = LocalTime.parse(jamPulangPSBB);
											datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
										} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
											jamPulangPSBB = "14:30:00";
											timePulangPSBB = LocalTime.parse(jamPulangPSBB);
											datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
										} else {
											datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
										}

										if (map.get("namaShift").toString().contains("Malam")
												&& !map.get("namaShift").toString().contains("Pagi Sore Malam")) {
											datePulang = datePulang.plusDays(1);
											datePulangFfs = datePulang.plusDays(1);
										}

										if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
												.contains(Integer.parseInt(map.get("departemenId").toString()))
												&& ((dateTimePelayanan.isEqual(dateMasuk)
														|| dateTimePelayanan.isAfter(dateMasuk))
														&& dateTimePelayanan.isBefore(datePulang))) {
											remun = remun
													+ (new Double(Double.parseDouble(map.get("count").toString())))
															.longValue();
											dataCountRemun = dataCountRemun + 1;
										} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
												&& !Arrays.asList(Master.Ruangan.NONRANAP)
														.contains(map.get("ruanganId"))
												&& Arrays.stream(Master.KONSUL_VISIT).anyMatch(
														map.get("namaProduk").toString().toLowerCase()::contains)
												&& (dateTimePelayanan.isBefore(dateMasuk)
														|| dateTimePelayanan.isEqual(datePulang)
														|| dateTimePelayanan.isAfter(datePulang))) {
											remun = remun
													+ (new Double(Double.parseDouble(map.get("count").toString())))
															.longValue();
											dataCountRemun = dataCountRemun + 1;
										} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
												.contains(Integer.parseInt(map.get("departemenId").toString()))
												&& (dateTimePelayanan.isBefore(dateMasuk)
														|| dateTimePelayanan.isEqual(datePulang)
														|| dateTimePelayanan.isAfter(datePulang))
												&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
														.contains(Integer.parseInt(map.get("idKelas").toString()))) {
											remun = remun
													+ (new Double(Double.parseDouble(map.get("count").toString())))
															.longValue();
											dataCountRemun = dataCountRemun + 1;
										} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
												&& map.get("namaShift").toString().equals("Non Shift")
												&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
												&& (dateTimePelayanan.isEqual(PSBBDate)
														|| dateTimePelayanan.isAfter(PSBBDate))
												&& (dateTimePelayanan.isBefore(PSBBEnd)
														|| dateTimePelayanan.isEqual(PSBBEnd))) {
											if (((dateTimePelayanan.isEqual(dateMasuk)
													|| dateTimePelayanan.isAfter(dateMasuk))
													&& dateTimePelayanan.isBefore(datePulangPSBB))) {
												remun = remun
														+ (new Double(Double.parseDouble(map.get("count").toString())))
																.longValue();
												dataCountRemun = dataCountRemun + 1;
											} else if (!Master.KelompokPasien.BPJS
													.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
													&& !Master.KelompokPasien.KEMENKES.equals(
															Integer.parseInt(map.get("kelompokPasienId").toString()))
													&& !Master.KelompokPasien.JAMKESDA.equals(
															Integer.parseInt(map.get("kelompokPasienId").toString()))) {
												if (!idsRegDJPPenunjangPA
														.contains(Integer.parseInt(map.get("detailId").toString()))
														&& !idsRegDJPPenunjangPK.contains(
																Integer.parseInt(map.get("detailId").toString()))) {
													if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
															&& map.get("namaShift").toString().equals("Non Shift")
															&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
															&& (dateTimePelayanan.isEqual(PSBBDate)
																	|| dateTimePelayanan.isAfter(PSBBDate))
															&& (dateTimePelayanan.isBefore(PSBBEnd)
																	|| dateTimePelayanan.isEqual(PSBBEnd))) {
														if (dateTimePelayanan.isBefore(dateMasuk)
																|| dateTimePelayanan.isEqual(datePulangPSBB)
																|| dateTimePelayanan.isAfter(datePulangPSBB)) {
															ffs = ffs + (new Double(
																	Double.parseDouble(map.get("count").toString())))
																			.longValue();
															dataCountFfs = dataCountFfs + 1;
														}
													}
												}
											}
										} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
												.contains(Integer.parseInt(map.get("departemenId").toString()))
												&& ((dateTimePelayanan.isEqual(dateMasuk)
														|| dateTimePelayanan.isAfter(dateMasuk))
														&& dateTimePelayanan.isBefore(datePulang))) {
											remun = remun
													+ (new Double(Double.parseDouble(map.get("count").toString())))
															.longValue();
											dataCountRemun = dataCountRemun + 1;
										} else if (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
												|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
											if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
												if (!Master.KelompokPasien.BPJS.equals(
														Integer.parseInt(map.get("kelompokPasienId").toString()))
														&& !Master.KelompokPasien.KEMENKES.equals(Integer
																.parseInt(map.get("kelompokPasienId").toString()))
														&& !Master.KelompokPasien.JAMKESDA.equals(Integer
																.parseInt(map.get("kelompokPasienId").toString()))) {
													if (!idsRegDJPPenunjangPA
															.contains(Integer.parseInt(map.get("detailId").toString()))
															&& !idsRegDJPPenunjangPK.contains(
																	Integer.parseInt(map.get("detailId").toString()))) {
														if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN).contains(
																Integer.parseInt(map.get("departemenId").toString()))) {
															if (map.get("ruanganId")
																	.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
																	&& idsKonsultasiDokterJaga
																			.contains(map.get("idProduk"))) {
																ffs = ffs + (new Double(Double
																		.parseDouble(map.get("count").toString())))
																				.longValue();
																dataCountFfs = dataCountFfs + 1;
															} else if (!map.get("departemenId")
																	.equals(Master.Departemen.IGD)) {
																ffs = ffs + (new Double(Double
																		.parseDouble(map.get("count").toString())))
																				.longValue();
																dataCountFfs = dataCountFfs + 1;
															}
														} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
																.contains(Integer
																		.parseInt(map.get("departemenId").toString()))
																&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
																		.contains(Integer.parseInt(
																				map.get("idKelas").toString()))) {
															ffs = ffs + (new Double(
																	Double.parseDouble(map.get("count").toString())))
																			.longValue();
															dataCountFfs = dataCountFfs + 1;
														}
													}
												}
											} else {
												if (!Master.KelompokPasien.BPJS.equals(
														Integer.parseInt(map.get("kelompokPasienId").toString()))
														&& !Master.KelompokPasien.KEMENKES.equals(Integer
																.parseInt(map.get("kelompokPasienId").toString()))
														&& !Master.KelompokPasien.JAMKESDA.equals(Integer
																.parseInt(map.get("kelompokPasienId").toString()))
														&& (dateTimePelayanan.isBefore(dateMasukFfs)
																|| dateTimePelayanan.isEqual(datePulangFfs)
																|| dateTimePelayanan.isAfter(datePulangFfs))) {
													if (!idsRegDJPPenunjangPA
															.contains(Integer.parseInt(map.get("detailId").toString()))
															&& !idsRegDJPPenunjangPK.contains(
																	Integer.parseInt(map.get("detailId").toString()))) {
														if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN).contains(
																Integer.parseInt(map.get("departemenId").toString()))) {
															if (map.get("ruanganId")
																	.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
																	&& idsKonsultasiDokterJaga
																			.contains(map.get("idProduk"))) {
																ffs = ffs + (new Double(Double
																		.parseDouble(map.get("count").toString())))
																				.longValue();
																dataCountFfs = dataCountFfs + 1;
															} else if (!map.get("departemenId")
																	.equals(Master.Departemen.IGD)) {
																ffs = ffs + (new Double(Double
																		.parseDouble(map.get("count").toString())))
																				.longValue();
																dataCountFfs = dataCountFfs + 1;
															}
														} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
																.contains(Integer
																		.parseInt(map.get("departemenId").toString()))
																&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP).contains(
																		Integer.parseInt(map.get("idKelas").toString()))
																&& !Arrays.stream(Master.KONSUL_VISIT)
																		.anyMatch(map.get("namaProduk").toString()
																				.toLowerCase()::contains)) {
															ffs = ffs + (new Double(
																	Double.parseDouble(map.get("count").toString())))
																			.longValue();
															dataCountFfs = dataCountFfs + 1;
														}
													}
												}
											}
										} else if (!Master.KelompokPasien.BPJS
												.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
												&& !Master.KelompokPasien.KEMENKES.equals(
														Integer.parseInt(map.get("kelompokPasienId").toString()))
												&& !Master.KelompokPasien.JAMKESDA.equals(
														Integer.parseInt(map.get("kelompokPasienId").toString()))) {
											if (!idsRegDJPPenunjangPA
													.contains(Integer.parseInt(map.get("detailId").toString()))
													&& !idsRegDJPPenunjangPK.contains(
															Integer.parseInt(map.get("detailId").toString()))) {
												if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
														.contains(Integer.parseInt(map.get("departemenId").toString()))
														&& (dateTimePelayanan.isBefore(dateMasukFfs)
																|| dateTimePelayanan.isEqual(datePulangFfs)
																|| dateTimePelayanan.isAfter(datePulangFfs))) {
													if (map.get("ruanganId")
															.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
															&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
														ffs = ffs + (new Double(
																Double.parseDouble(map.get("count").toString())))
																		.longValue();
														dataCountFfs = dataCountFfs + 1;
													} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
														ffs = ffs + (new Double(
																Double.parseDouble(map.get("count").toString())))
																		.longValue();
														dataCountFfs = dataCountFfs + 1;
													}
												} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
														.contains(Integer.parseInt(map.get("departemenId").toString()))
														&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP).contains(
																Integer.parseInt(map.get("idKelas").toString()))
														&& !Arrays.stream(Master.KONSUL_VISIT)
																.anyMatch(map.get("namaProduk").toString()
																		.toLowerCase()::contains)
														&& (dateTimePelayanan.isBefore(dateMasukFfs)
																|| dateTimePelayanan.isEqual(datePulangFfs)
																|| dateTimePelayanan.isAfter(datePulangFfs))) {
													ffs = ffs + (new Double(
															Double.parseDouble(map.get("count").toString())))
																	.longValue();
													dataCountFfs = dataCountFfs + 1;
												}
											}
										}
									} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
											&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
													.contains(Integer.parseInt(map.get("departemenId").toString()))
											&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
													.contains(Integer.parseInt(map.get("idKelas").toString()))) {
										remun = remun + (new Double(Double.parseDouble(map.get("count").toString())))
												.longValue();
										dataCountRemun = dataCountRemun + 1;
									} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))) {
										if (!Master.KelompokPasien.BPJS
												.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
												&& !Master.KelompokPasien.KEMENKES.equals(
														Integer.parseInt(map.get("kelompokPasienId").toString()))
												&& !Master.KelompokPasien.JAMKESDA.equals(
														Integer.parseInt(map.get("kelompokPasienId").toString()))) {
											if (!idsRegDJPPenunjangPA
													.contains(Integer.parseInt(map.get("detailId").toString()))
													&& !idsRegDJPPenunjangPK.contains(
															Integer.parseInt(map.get("detailId").toString()))) {
												if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN).contains(
														Integer.parseInt(map.get("departemenId").toString()))) {
													if (map.get("ruanganId")
															.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
															&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
														ffs = ffs + (new Double(
																Double.parseDouble(map.get("count").toString())))
																		.longValue();
														dataCountFfs = dataCountFfs + 1;
													} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
														ffs = ffs + (new Double(
																Double.parseDouble(map.get("count").toString())))
																		.longValue();
														dataCountFfs = dataCountFfs + 1;
													}
												} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
														.contains(Integer.parseInt(map.get("departemenId").toString()))
														&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP).contains(
																Integer.parseInt(map.get("idKelas").toString()))) {
													ffs = ffs + (new Double(
															Double.parseDouble(map.get("count").toString())))
																	.longValue();
													// RULES_NOTE_SK_2015_DI_2019
													if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
															&& !Arrays.asList(Master.Ruangan.NONRANAP)
																	.contains(map.get("ruanganId"))) {
														if (Arrays.stream(Master.KONSUL_VISIT)
																.anyMatch(map.get("namaProduk").toString()
																		.toLowerCase()::contains)) {
															dataCountFfs = dataCountFfs + 1;
														}
													} else {
														dataCountFfs = dataCountFfs + 1;
													}
												}
											}
										}
									}
								} else if (dokterLuar.contains(idPegawai)) {
									if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
											&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
										ffs = ffs + (new Double(Double.parseDouble(map.get("count").toString())))
												.longValue();
										dataCountFfs = dataCountFfs + 1;
									} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
										ffs = ffs + (new Double(Double.parseDouble(map.get("count").toString())))
												.longValue();
										dataCountFfs = dataCountFfs + 1;
									}
								}

								if ((dataCountRemun == 1 && dataCountFfs == 0)
										|| (dataCountRemun == 0 && dataCountFfs == 1)) {
									mapResult.putAll(map);
								}
							} // endif
							if (CommonUtil.isNotNullOrEmpty(mapResult.get("idProduk"))) {
								count = remun + ffs;
								mapResult.put("remun", remun);
								mapResult.put("ffs", ffs);
								mapResult.put("count", count);
							}
						}
					} // endfor
					if (CommonUtil.isNotNullOrEmpty(mapResult.get("idProduk"))) {
						result.add(mapResult);
					}
				}
			}
		}

		return result;
	}

	@Override
	public List<Map<String, Object>> findPatientDetailForEveryTindakanReview(Integer idPegawai, String tgl,
			Boolean ffs) {
		List<Map<String, Object>> result = new ArrayList<>();
		List<Map<String, Object>> listData = new ArrayList<>();

		List<Integer> listDetailJenisProduk = new ArrayList<>();
		List<Integer> listDetailJenisProdukException = new ArrayList<>();

		String month = tgl.substring(0, 7);

		DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

		LocalDateTime PSBBDate = LocalDateTime.of(2020, 9, 14, 0, 0, 0);
		LocalDateTime PSBBEnd = LocalDateTime.parse(GetSettingDataFixed("psbbperiod"), dtf);

		List<Integer> drKsmUmumList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_UMUM);
		List<Integer> laboranRadiologList = mapPegawaiLaboratRadiologiDao.findPegawaiLaboranRadiolog();

		List<Integer> idsRegDJPAdminNonPK = splitDataSettingDatafixed("admin_nonpk");
		List<Integer> idsRegDJPMedisUtama = splitDataSettingDatafixed("medis_utama");
		List<Integer> idsRegDJPPenunjangPA = splitDataSettingDatafixed("penunjang_pa");
		List<Integer> idsRegDJPPenunjangPK = splitDataSettingDatafixed("penunjang_pk");
		List<Integer> idsRegDJPPenunjangRad = splitDataSettingDatafixed("penunjang_radiologi");

		if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPA;
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPK;
		} else if (pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI).contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangRad;
		} else {
			listDetailJenisProduk = idsRegDJPMedisUtama;
		}

		if (laboranRadiologList.contains(idPegawai)) {
			listDetailJenisProdukException = idsRegDJPAdminNonPK;
			listDetailJenisProdukException.removeAll(listDetailJenisProduk);
		}

		if (CommonUtil.isNotNullOrEmpty(tgl) && tgl.equals(month)) {
			listData = revIndekKinerjaDao.getDetailPasienTindakanDokterPerPeriode(Master.Kelas.KELAS_SATU, idPegawai,
					Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA, tgl);
		} else {
			listData = revIndekKinerjaDao.getDetailPasienTindakanDokter(Master.Kelas.KELAS_SATU, idPegawai,
					Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA, tgl);
		}

		List<Integer> idsDokterUmumIGD = splitDataSettingDatafixed("pr_dokter_umum_igd");

		if (!ffs) {
			if (CommonUtil.isNotNullOrEmpty(listData)) {
				for (Map<String, Object> map : listData) {
					if (listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))) {
						if (idsRegDJPPenunjangPA.contains(Integer.parseInt(map.get("detailId").toString()))
								|| idsRegDJPPenunjangPK.contains(Integer.parseInt(map.get("detailId").toString()))) {
							result.add(map);
						} else if (Master.KelompokPasien.BPJS
								.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.KEMENKES
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.JAMKESDA
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
							result.add(map);
						} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
							Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
							String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
							String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
							LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
							LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
							LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

							String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
									+ map.get("jamMasuk").toString().substring(3) + ":00";
							LocalTime timeMasuk = LocalTime.parse(jamMasuk);
							LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

							String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
									+ map.get("jamPulang").toString().substring(3) + ":00";
							LocalTime timePulang = LocalTime.parse(jamPulang);
							LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

							String jamPulangPSBB = "";
							LocalTime timePulangPSBB = LocalTime.now();
							LocalDateTime datePulangPSBB = LocalDateTime.now();
							if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
								jamPulangPSBB = "14:00:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
								jamPulangPSBB = "14:30:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else {
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
							}

							if (map.get("namaShift").toString().contains("Malam")) {
								datePulang = datePulang.plusDays(1);
							}

							if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								result.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))) {
								result.add(map);
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))
									&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
											.contains(Integer.parseInt(map.get("idKelas").toString()))) {
								result.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
									&& map.get("namaShift").toString().equals("Non Shift")
									&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
									&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
									&& (dateTimePelayanan.isBefore(PSBBEnd) || dateTimePelayanan.isEqual(PSBBEnd))) {
								if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulangPSBB))) {
									result.add(map);
								}
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								result.add(map);
							}
						} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
								&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
										.contains(Integer.parseInt(map.get("idKelas").toString()))) {
							result.add(map);
						}
					} else if (!listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))
							&& map.get("departemenId").equals(Master.Departemen.IGD)
							&& drKsmUmumList.contains(idPegawai)
							&& idsDokterUmumIGD.contains(Integer.parseInt(map.get("idProduk").toString()))) {
						if (Master.KelompokPasien.BPJS.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.KEMENKES
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.JAMKESDA
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
							result.add(map);
						} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
							Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
							String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
							String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
							LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
							LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
							LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

							String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
									+ map.get("jamMasuk").toString().substring(3) + ":00";
							LocalTime timeMasuk = LocalTime.parse(jamMasuk);
							LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

							String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
									+ map.get("jamPulang").toString().substring(3) + ":00";
							LocalTime timePulang = LocalTime.parse(jamPulang);
							LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

							String jamPulangPSBB = "";
							LocalTime timePulangPSBB = LocalTime.now();
							LocalDateTime datePulangPSBB = LocalDateTime.now();
							if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
								jamPulangPSBB = "14:00:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
								jamPulangPSBB = "14:30:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else {
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
							}

							if (map.get("namaShift").toString().contains("Malam")) {
								datePulang = datePulang.plusDays(1);
							}

							if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								result.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))) {
								result.add(map);
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))
									&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
											.contains(Integer.parseInt(map.get("idKelas").toString()))) {
								result.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
									&& map.get("namaShift").toString().equals("Non Shift")
									&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
									&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
									&& (dateTimePelayanan.isBefore(PSBBEnd) || dateTimePelayanan.isEqual(PSBBEnd))) {
								if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulangPSBB))) {
									result.add(map);
								}
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								result.add(map);
							}
						} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
								&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
										.contains(Integer.parseInt(map.get("idKelas").toString()))) {
							result.add(map);
						}
					} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProdukException)
							&& listDetailJenisProdukException
									.contains(Integer.parseInt(map.get("detailId").toString()))) {
						if (Arrays.asList(Master.DetailJenisProduk.PENUNJANG_PATOLOGI_ANATOMI)
								.contains(Integer.parseInt(map.get("detailId").toString()))
								|| Arrays.asList(Master.DetailJenisProduk.PENUNJANG_PATOLOGI_KLINIK)
										.contains(Integer.parseInt(map.get("detailId").toString()))) {
							result.add(map);
						} else if (Master.KelompokPasien.BPJS
								.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.KEMENKES
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))
								|| Master.KelompokPasien.JAMKESDA
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
							result.add(map);
						} else if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
							Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
							String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
							String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
							LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
							LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
							LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

							String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
									+ map.get("jamMasuk").toString().substring(3) + ":00";
							LocalTime timeMasuk = LocalTime.parse(jamMasuk);
							LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

							String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
									+ map.get("jamPulang").toString().substring(3) + ":00";
							LocalTime timePulang = LocalTime.parse(jamPulang);
							LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

							String jamPulangPSBB = "";
							LocalTime timePulangPSBB = LocalTime.now();
							LocalDateTime datePulangPSBB = LocalDateTime.now();
							if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
									|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
								jamPulangPSBB = "14:00:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
								jamPulangPSBB = "14:30:00";
								timePulangPSBB = LocalTime.parse(jamPulangPSBB);
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
							} else {
								datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
							}

							if (map.get("namaShift").toString().contains("Malam")) {
								datePulang = datePulang.plusDays(1);
							}

							if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								result.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& !Arrays.asList(Master.Ruangan.NONRANAP).contains(map.get("ruanganId"))
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))) {
								result.add(map);
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& (dateTimePelayanan.isBefore(dateMasuk) || dateTimePelayanan.isEqual(datePulang)
											|| dateTimePelayanan.isAfter(datePulang))
									&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
											.contains(Integer.parseInt(map.get("idKelas").toString()))) {
								result.add(map);
							} else if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
									&& map.get("namaShift").toString().equals("Non Shift")
									&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
									&& (dateTimePelayanan.isEqual(PSBBDate) || dateTimePelayanan.isAfter(PSBBDate))
									&& (dateTimePelayanan.isBefore(PSBBEnd) || dateTimePelayanan.isEqual(PSBBEnd))) {
								if (((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
										&& dateTimePelayanan.isBefore(datePulangPSBB))) {
									result.add(map);
								}
							} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
									.contains(Integer.parseInt(map.get("departemenId").toString()))
									&& ((dateTimePelayanan.isEqual(dateMasuk) || dateTimePelayanan.isAfter(dateMasuk))
											&& dateTimePelayanan.isBefore(datePulang))) {
								result.add(map);
							}
						} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))
								&& Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
										.contains(Integer.parseInt(map.get("departemenId").toString()))
								&& Arrays.asList(Master.Kelas.KELAS_DUA_TIGA_NONKELAS)
										.contains(Integer.parseInt(map.get("idKelas").toString()))) {
							result.add(map);
						}
					}
				}
			}
		} else {
			// FFS : sudah tidak dipakai
			if (CommonUtil.isNotNullOrEmpty(listData)) {
				if (pegawaiDao.getPegawaiByKategoryPegawai(Arrays.asList(Master.KategoryPegawai.DOKTER_LUAR))
						.contains(idPegawai)) {
					for (Map<String, Object> map : listData) {
						if (listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))) {
							result.add(map);
						} else if (!listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))
								&& map.get("departemenId").equals(Master.Departemen.IGD)
								&& drKsmUmumList.contains(idPegawai)
								&& idsDokterUmumIGD.contains(Integer.parseInt(map.get("idProduk").toString()))) {
							result.add(map);
						} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProdukException)
								&& listDetailJenisProdukException
										.contains(Integer.parseInt(map.get("detailId").toString()))) {
							result.add(map);
						} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProduk)
								&& listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))) {
							result.add(map);
						}
					}
				} else {
					for (Map<String, Object> map : listData) {
						if (listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))) {
							if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
								Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
								String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
								String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
								LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
								LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
								LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

								String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
										+ map.get("jamMasuk").toString().substring(3) + ":00";
								LocalTime timeMasuk = LocalTime.parse(jamMasuk);
								LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

								String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
										+ map.get("jamPulang").toString().substring(3) + ":00";
								LocalTime timePulang = LocalTime.parse(jamPulang);
								LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

								String jamPulangPSBB = "";
								LocalTime timePulangPSBB = LocalTime.now();
								LocalDateTime datePulangPSBB = LocalDateTime.now();
								if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
									jamPulangPSBB = "14:00:00";
									timePulangPSBB = LocalTime.parse(jamPulangPSBB);
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
								} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
									jamPulangPSBB = "14:30:00";
									timePulangPSBB = LocalTime.parse(jamPulangPSBB);
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
								} else {
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
								}

								if (map.get("namaShift").toString().contains("Malam")) {
									datePulang = datePulang.plusDays(1);
								}

								if (!Master.KelompokPasien.BPJS
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
									if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
											&& map.get("namaShift").toString().equals("Non Shift")
											&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
											&& (dateTimePelayanan.isEqual(PSBBDate)
													|| dateTimePelayanan.isAfter(PSBBDate))
											&& (dateTimePelayanan.isBefore(PSBBEnd)
													|| dateTimePelayanan.isEqual(PSBBEnd))
											&& (dateTimePelayanan.isBefore(dateMasuk)
													|| dateTimePelayanan.isEqual(datePulangPSBB)
													|| dateTimePelayanan.isAfter(datePulangPSBB))) {
										result.add(map);
									} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
											.contains(Integer.parseInt(map.get("departemenId").toString()))) {
										if ((dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulang)
												|| dateTimePelayanan.isAfter(datePulang))) {
											result.add(map);
										}
									} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
											.contains(Integer.parseInt(map.get("departemenId").toString()))
											&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
													.contains(Integer.parseInt(map.get("idKelas").toString()))
											&& !Arrays.stream(Master.KONSUL_VISIT)
													.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
											&& (dateTimePelayanan.isBefore(dateMasuk)
													|| dateTimePelayanan.isEqual(datePulang)
													|| dateTimePelayanan.isAfter(datePulang))) {
										result.add(map);
									}
								}
							} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))) {
								if (!Master.KelompokPasien.BPJS
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
									if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
											.contains(Integer.parseInt(map.get("departemenId").toString()))) {
										result.add(map);
									} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
											.contains(Integer.parseInt(map.get("departemenId").toString()))
											&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
													.contains(Integer.parseInt(map.get("idKelas").toString()))) {
										result.add(map);
									}
								}
							}
						} else if (!listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))
								&& map.get("departemenId").equals(Master.Departemen.IGD)
								&& drKsmUmumList.contains(idPegawai)
								&& idsDokterUmumIGD.contains(Integer.parseInt(map.get("idProduk").toString()))) {
							if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
								Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
								String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
								String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
								LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
								LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
								LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

								String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
										+ map.get("jamMasuk").toString().substring(3) + ":00";
								LocalTime timeMasuk = LocalTime.parse(jamMasuk);
								LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

								String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
										+ map.get("jamPulang").toString().substring(3) + ":00";
								LocalTime timePulang = LocalTime.parse(jamPulang);
								LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

								String jamPulangPSBB = "";
								LocalTime timePulangPSBB = LocalTime.now();
								LocalDateTime datePulangPSBB = LocalDateTime.now();
								if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
									jamPulangPSBB = "14:00:00";
									timePulangPSBB = LocalTime.parse(jamPulangPSBB);
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
								} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
									jamPulangPSBB = "14:30:00";
									timePulangPSBB = LocalTime.parse(jamPulangPSBB);
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
								} else {
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
								}

								if (map.get("namaShift").toString().contains("Malam")) {
									datePulang = datePulang.plusDays(1);
								}

								if (!Master.KelompokPasien.BPJS
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
									if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
											&& map.get("namaShift").toString().equals("Non Shift")
											&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
											&& (dateTimePelayanan.isEqual(PSBBDate)
													|| dateTimePelayanan.isAfter(PSBBDate))
											&& (dateTimePelayanan.isBefore(PSBBEnd)
													|| dateTimePelayanan.isEqual(PSBBEnd))) {
										if ((dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulangPSBB)
												|| dateTimePelayanan.isAfter(datePulangPSBB))) {
											result.add(map);
										}
									} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
											.contains(Integer.parseInt(map.get("departemenId").toString()))
											&& (dateTimePelayanan.isBefore(dateMasuk)
													|| dateTimePelayanan.isEqual(datePulang)
													|| dateTimePelayanan.isAfter(datePulang))) {
										result.add(map);
									} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
											.contains(Integer.parseInt(map.get("departemenId").toString()))
											&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
													.contains(Integer.parseInt(map.get("idKelas").toString()))
											&& !Arrays.stream(Master.KONSUL_VISIT)
													.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
											&& (dateTimePelayanan.isBefore(dateMasuk)
													|| dateTimePelayanan.isEqual(datePulang)
													|| dateTimePelayanan.isAfter(datePulang))) {
										result.add(map);
									}
								}
							} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))) {
								if (!Master.KelompokPasien.BPJS
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
									if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
											.contains(Integer.parseInt(map.get("departemenId").toString()))) {
										result.add(map);
									} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
											.contains(Integer.parseInt(map.get("departemenId").toString()))
											&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
													.contains(Integer.parseInt(map.get("idKelas").toString()))) {
										result.add(map);
									}
								}
							}
						} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProdukException)
								&& listDetailJenisProdukException
										.contains(Integer.parseInt(map.get("detailId").toString()))) {
							if (CommonUtil.isNotNullOrEmpty(map.get("jamMasuk"))) {
								Date tanggalPelayanan = (Date) map.get("tanggalPelayanan");
								String tglPelayanan = new SimpleDateFormat("yyyy-MM-dd").format(tanggalPelayanan);
								String waktuPelayanan = new SimpleDateFormat("HH:mm:ss").format(tanggalPelayanan);
								LocalDate datePelayanan = LocalDate.parse(tglPelayanan);
								LocalTime timePelayanan = LocalTime.parse(waktuPelayanan);
								LocalDateTime dateTimePelayanan = LocalDateTime.of(datePelayanan, timePelayanan);

								String jamMasuk = map.get("jamMasuk").toString().substring(0, 2) + ":"
										+ map.get("jamMasuk").toString().substring(3) + ":00";
								LocalTime timeMasuk = LocalTime.parse(jamMasuk);
								LocalDateTime dateMasuk = LocalDateTime.of(datePelayanan, timeMasuk);

								String jamPulang = map.get("jamPulang").toString().substring(0, 2) + ":"
										+ map.get("jamPulang").toString().substring(3) + ":00";
								LocalTime timePulang = LocalTime.parse(jamPulang);
								LocalDateTime datePulang = LocalDateTime.of(datePelayanan, timePulang);

								String jamPulangPSBB = "";
								LocalTime timePulangPSBB = LocalTime.now();
								LocalDateTime datePulangPSBB = LocalDateTime.now();
								if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 1
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 2
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 3
										|| getDayOfWeek((Date) map.get("tanggalPelayanan")) == 4) {
									jamPulangPSBB = "14:00:00";
									timePulangPSBB = LocalTime.parse(jamPulangPSBB);
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
								} else if (getDayOfWeek((Date) map.get("tanggalPelayanan")) == 5) {
									jamPulangPSBB = "14:30:00";
									timePulangPSBB = LocalTime.parse(jamPulangPSBB);
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulangPSBB);
								} else {
									datePulangPSBB = LocalDateTime.of(datePelayanan, timePulang);
								}

								if (map.get("namaShift").toString().contains("Malam")) {
									datePulang = datePulang.plusDays(1);
								}

								if (!Master.KelompokPasien.BPJS
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
									if (map.get("departemenId").equals(Master.Departemen.RAWAT_JALAN)
											&& map.get("namaShift").toString().equals("Non Shift")
											&& CommonUtil.isNotNullOrEmpty(jamPulangPSBB)
											&& (dateTimePelayanan.isEqual(PSBBDate)
													|| dateTimePelayanan.isAfter(PSBBDate))
											&& (dateTimePelayanan.isBefore(PSBBEnd)
													|| dateTimePelayanan.isEqual(PSBBEnd))) {
										if ((dateTimePelayanan.isBefore(dateMasuk)
												|| dateTimePelayanan.isEqual(datePulangPSBB)
												|| dateTimePelayanan.isAfter(datePulangPSBB))) {
											result.add(map);
										}
									} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
											.contains(Integer.parseInt(map.get("departemenId").toString()))
											&& (dateTimePelayanan.isBefore(dateMasuk)
													|| dateTimePelayanan.isEqual(datePulang)
													|| dateTimePelayanan.isAfter(datePulang))) {
										result.add(map);
									} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
											.contains(Integer.parseInt(map.get("departemenId").toString()))
											&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
													.contains(Integer.parseInt(map.get("idKelas").toString()))
											&& !Arrays.stream(Master.KONSUL_VISIT)
													.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
											&& (dateTimePelayanan.isBefore(dateMasuk)
													|| dateTimePelayanan.isEqual(datePulang)
													|| dateTimePelayanan.isAfter(datePulang))) {
										result.add(map);
									}
								}
							} else if (CommonUtil.isNullOrEmpty(map.get("jamMasuk"))) {
								if (!Master.KelompokPasien.BPJS
										.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
									if (Arrays.asList(Master.Departemen.GRUP_RAWAT_JALAN)
											.contains(Integer.parseInt(map.get("departemenId").toString()))) {
										result.add(map);
									} else if (Arrays.asList(Master.Departemen.GRUP_RAWAT_INAP)
											.contains(Integer.parseInt(map.get("departemenId").toString()))
											&& Arrays.asList(Master.Kelas.KELAS_SATU_VIP)
													.contains(Integer.parseInt(map.get("idKelas").toString()))) {
										result.add(map);
									}
								}
							}
						}
					}
				}
			}
		}

		return result;
	}

}