package com.jasamedika.medifirst2000.service.impl;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
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.Collections;
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.dao.MapPegawaiLaboratRadiologiDao;
import com.jasamedika.medifirst2000.dao.PegawaiDao;
import com.jasamedika.medifirst2000.dao.PendapatanDao;
import com.jasamedika.medifirst2000.service.PendapatanService;
import com.jasamedika.medifirst2000.util.CommonUtil;

/**
 * @author salmanoe
 *
 */
@Service("pendapatanService")
public class PendapatanServiceImpl extends BaseVoServiceImpl implements PendapatanService {

	@Autowired
	private PegawaiDao pegawaiDao;

	@Autowired
	private MapPegawaiLaboratRadiologiDao mapPegawaiLaboratRadiologiDao;

	@Autowired
	private PendapatanDao pendapatanDao;

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

		return day.getValue();
	}

	@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;
	}

	@Override
	public Map<String, Object> getJasaMedisRemun(List<Integer> listDrAnastesi, Integer idJenisPetugasPelaksana,
			Integer idPegawai, Integer idProduk, Integer idKomponenHarga, Double hargaJual, Double hargaDiskon,
			Double count) {
		Map<String, Object> result = new HashMap<>();

		List<Integer> idsPenunjangBukanAnestesi = splitDataSettingDatafixed("pr_penunjang_nonanestesi");
		if (listDrAnastesi.contains(idPegawai)) {
			if (idsPenunjangBukanAnestesi.contains(idProduk)
					&& idJenisPetugasPelaksana.equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)
					&& idKomponenHarga.equals(Master.KomponenHarga.JASA_DOKTER)) {
				result.put("jasaMedis", (hargaJual - hargaDiskon) * count);
				result.put("flagCounter", true);
			} else if (idJenisPetugasPelaksana.equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)
					&& idKomponenHarga.equals(Master.KomponenHarga.JASA_DOKTER)) {
				result.put("jasaMedis", (hargaJual - hargaDiskon) * count);
				result.put("flagCounter", true);
			} else if (idJenisPetugasPelaksana.equals(Master.JenisPetugasPelaksana.DOKTER_ANASTESI)
					&& idKomponenHarga.equals(Master.KomponenHarga.JASA_DOKTER_ANASTESI)) {
				result.put("jasaMedis", (hargaJual - hargaDiskon) * count);
				result.put("flagCounter", true);
			} else {
				result.put("jasaMedis", 0.0);
				result.put("flagCounter", false);
			}
		} else {
			if (idJenisPetugasPelaksana.equals(Master.JenisPetugasPelaksana.ASISTEN_SPESIALIS)
					&& idKomponenHarga.equals(Master.KomponenHarga.JASA_ASISTEN_SPESIALIS)) {
				result.put("jasaMedis", (hargaJual - hargaDiskon) * count);
				result.put("flagCounter", true);
			} else if (idJenisPetugasPelaksana.equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)
					&& idKomponenHarga.equals(Master.KomponenHarga.JASA_DOKTER)) {
				result.put("jasaMedis", (hargaJual - hargaDiskon) * count);
				result.put("flagCounter", true);
			} else {
				result.put("jasaMedis", 0.0);
				result.put("flagCounter", false);
			}
		}

		return result;
	}

	@Override
	public Map<String, Object> getJasaMedisFfs(List<Integer> listDrAnastesi, Integer idJenisPetugasPelaksana,
			Integer idPegawai, Integer idProduk, String namaProduk, Integer idKelompokPasien, Integer idDepartemen,
			Integer idKomponenHarga, Double hargaJual, Double hargaDiskon, Double count) {
		Map<String, Object> result = new HashMap<>();
		
		List<Integer> idsKonsultasiDokterJaga = splitDataSettingDatafixed("pr_konsultasi_dokter_jaga");
		List<Integer> idsPenunjangBukanAnestesi = splitDataSettingDatafixed("pr_penunjang_nonanestesi");

		if (listDrAnastesi.contains(idPegawai)) {
			if (idsPenunjangBukanAnestesi.contains(idProduk)) {
				if (idKomponenHarga.equals(Master.KomponenHarga.JASA_DOKTER)) {
					if (!idKelompokPasien.equals(Master.KelompokPasien.BPJS)
							&& Arrays.stream(Master.KONSUL_VISIT).anyMatch(namaProduk.toLowerCase()::contains)
							&& idDepartemen.equals(Master.Departemen.RAWAT_INAP)
							&& (hargaJual - hargaDiskon) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
						result.put("jasaMedis", Master.FeeForService.HK_02_04_III_558_2015_4_B_1 * count);
						result.put("flagCounter", true);
					} else if (idKelompokPasien.equals(Master.KelompokPasien.BPJS)) {
						result.put("jasaMedis",
								(hargaJual - hargaDiskon) * Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D * count);
						result.put("flagCounter", true);
					} else if (idDepartemen.equals(Master.Departemen.IGD)
							&& idsKonsultasiDokterJaga.contains(idProduk)) {
						result.put("jasaMedis", Master.FeeForService.HK_02_04_III_558_2015_4_C_3 * count);
						result.put("flagCounter", true);
					} else {
						result.put("jasaMedis", (hargaJual - hargaDiskon) * count);
						result.put("flagCounter", true);
					}
				} else {
					result.put("jasaMedis", 0.0);
					result.put("flagCounter", false);
				}
			} else if (idJenisPetugasPelaksana.equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)) {
				if (idKomponenHarga.equals(Master.KomponenHarga.JASA_DOKTER)) {
					if (!idKelompokPasien.equals(Master.KelompokPasien.BPJS)
							&& Arrays.stream(Master.KONSUL_VISIT).anyMatch(namaProduk.toLowerCase()::contains)
							&& idDepartemen.equals(Master.Departemen.RAWAT_INAP)
							&& (hargaJual - hargaDiskon) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
						result.put("jasaMedis", Master.FeeForService.HK_02_04_III_558_2015_4_B_1 * count);
						result.put("flagCounter", true);
					} else if (idKelompokPasien.equals(Master.KelompokPasien.BPJS)) {
						result.put("jasaMedis",
								(hargaJual - hargaDiskon) * Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D * count);
						result.put("flagCounter", true);
					} else if (idDepartemen.equals(Master.Departemen.IGD)
							&& idsKonsultasiDokterJaga.contains(idProduk)) {
						result.put("jasaMedis", Master.FeeForService.HK_02_04_III_558_2015_4_C_3 * count);
						result.put("flagCounter", true);
					} else {
						result.put("jasaMedis", (hargaJual - hargaDiskon) * count);
						result.put("flagCounter", true);
					}
				} else {
					result.put("jasaMedis", 0.0);
					result.put("flagCounter", false);
				}
			} else {
				if (idKomponenHarga.equals(Master.KomponenHarga.JASA_DOKTER_ANASTESI)) {
					if (!idKelompokPasien.equals(Master.KelompokPasien.BPJS)
							&& Arrays.stream(Master.KONSUL_VISIT).anyMatch(namaProduk.toLowerCase()::contains)
							&& idDepartemen.equals(Master.Departemen.RAWAT_INAP)
							&& (hargaJual - hargaDiskon) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
						result.put("jasaMedis", Master.FeeForService.HK_02_04_III_558_2015_4_B_1 * count);
						result.put("flagCounter", true);
					} else if (idKelompokPasien.equals(Master.KelompokPasien.BPJS)) {
						result.put("jasaMedis",
								(hargaJual - hargaDiskon) * Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D * count);
						result.put("flagCounter", true);
					} else if (idDepartemen.equals(Master.Departemen.IGD)
							&& idsKonsultasiDokterJaga.contains(idProduk)) {
						result.put("jasaMedis", Master.FeeForService.HK_02_04_III_558_2015_4_C_3 * count);
						result.put("flagCounter", true);
					} else {
						result.put("jasaMedis", (hargaJual - hargaDiskon) * count);
						result.put("flagCounter", true);
					}
				} else {
					result.put("jasaMedis", 0.0);
					result.put("flagCounter", false);
				}
			}
		} else {
			if (idJenisPetugasPelaksana.equals(Master.JenisPetugasPelaksana.ASISTEN_SPESIALIS)) {
				if (idKomponenHarga.equals(Master.KomponenHarga.JASA_ASISTEN_SPESIALIS)) {
					if (!idKelompokPasien.equals(Master.KelompokPasien.BPJS)
							&& Arrays.stream(Master.KONSUL_VISIT).anyMatch(namaProduk.toLowerCase()::contains)
							&& idDepartemen.equals(Master.Departemen.RAWAT_INAP)
							&& (hargaJual - hargaDiskon) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
						result.put("jasaMedis", Master.FeeForService.HK_02_04_III_558_2015_4_B_1 * count);
						result.put("flagCounter", true);
					} else if (idKelompokPasien.equals(Master.KelompokPasien.BPJS)) {
						result.put("jasaMedis",
								(hargaJual - hargaDiskon) * Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D * count);
						result.put("flagCounter", true);
					} else if (idDepartemen.equals(Master.Departemen.IGD)
							&& idsKonsultasiDokterJaga.contains(idProduk)) {
						result.put("jasaMedis", Master.FeeForService.HK_02_04_III_558_2015_4_C_3 * count);
						result.put("flagCounter", true);
					} else {
						result.put("jasaMedis", (hargaJual - hargaDiskon) * count);
						result.put("flagCounter", true);
					}
				} else {
					result.put("jasaMedis", 0.0);
					result.put("flagCounter", false);
				}
			} else {
				if (idKomponenHarga.equals(Master.KomponenHarga.JASA_DOKTER)) {
					if (!idKelompokPasien.equals(Master.KelompokPasien.BPJS)
							&& Arrays.stream(Master.KONSUL_VISIT).anyMatch(namaProduk.toLowerCase()::contains)
							&& idDepartemen.equals(Master.Departemen.RAWAT_INAP)
							&& (hargaJual - hargaDiskon) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
						result.put("jasaMedis", Master.FeeForService.HK_02_04_III_558_2015_4_B_1 * count);
						result.put("flagCounter", true);
					} else if (idKelompokPasien.equals(Master.KelompokPasien.BPJS)) {
						result.put("jasaMedis",
								(hargaJual - hargaDiskon) * Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D * count);
						result.put("flagCounter", true);
					} else if (idDepartemen.equals(Master.Departemen.IGD)
							&& idsKonsultasiDokterJaga.contains(idProduk)) {
						result.put("jasaMedis", Master.FeeForService.HK_02_04_III_558_2015_4_C_3 * count);
						result.put("flagCounter", true);
					} else {
						result.put("jasaMedis", (hargaJual - hargaDiskon) * count);
						result.put("flagCounter", true);
					}
				} else {
					result.put("jasaMedis", 0.0);
					result.put("flagCounter", false);
				}
			}
		}

		return result;
	}

	@Override
	public List<Map<String, Object>> getFeeForServiceDokter(String periode, Integer idPegawai) {
		List<Map<String, Object>> result = new ArrayList<>();
		List<Map<String, Object>> rawData = new ArrayList<>();
		List<Map<String, Object>> listData = 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<>();

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

		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>> data = pendapatanDao.getPendapatanDokter(idPegawai,
				Arrays.asList(Master.KomponenHarga.JASA_MEDIS), Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA,
				periode);
		
		List<Integer> idsDokterUmumIGD = splitDataSettingDatafixed("pr_dokter_umum_igd");
		List<Integer> idsKonsultasiDokterJaga = splitDataSettingDatafixed("pr_konsultasi_dokter_jaga");
		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"));

		// 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"))) {
								rawData.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)) {
									rawData.add(map);
								}
							}
						}
					} else {
						rawData.add(map);
					}
				}
			}
		}

		// RULES_SK_FFS_2015
		if (CommonUtil.isNotNullOrEmpty(rawData)) {
			for (Map<String, Object> map : rawData) {
				Double jasaMedis = 0.0;
				if (drAnastesiList.contains(idPegawai)) {
					if (idsPenunjangBukanAnestesi.contains(map.get("idProduk"))) {
						if (map.get("idJasa").equals(Master.KomponenHarga.JASA_DOKTER)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							}
							listData.add(map);
						}
					} else if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)) {
						if (map.get("idJasa").equals(Master.KomponenHarga.JASA_DOKTER)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							}
							listData.add(map);
						}
					} else {
						if (map.get("idJasa").equals(Master.KomponenHarga.JASA_DOKTER_ANASTESI)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							}
							listData.add(map);
						}
					}
				} else {
					if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.ASISTEN_SPESIALIS)) {
						if (map.get("idJasa").equals(Master.KomponenHarga.JASA_ASISTEN_SPESIALIS)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							}
							listData.add(map);
						}
					} else {
						if (map.get("idJasa").equals(Master.KomponenHarga.JASA_DOKTER)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							}
							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 (!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 (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
									if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
										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 (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 (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)
							&& 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 (!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 (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
									if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
										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 (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 (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 (!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 (dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SATURDAY)
										|| dateTimePelayanan.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
									if (map.get("namaShift").toString().contains("Pagi Sore Malam")) {
										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 (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 (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());
				}
				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)))) {
									count1 = count1 + Double.parseDouble(map.get("count").toString());
									dataCount1 = dataCount1 + 1;
									if (dataCount1 == 1) {
										map.put("tarifJasa", 0.0);
										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)) {
									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;
						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"));
								countMap.put("harga", map.get("harga"));
								countMap.put("tanggal", map.get("tanggal"));
								datas1.add(countMap);
								totalTindakan1 = totalTindakan1 + 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"));
								countMap.put("harga", map.get("harga"));
								countMap.put("tanggal", map.get("tanggal"));
								datas2.add(countMap);
								totalTindakan2 = totalTindakan2 + Double.parseDouble(map.get("count").toString());
								counter2 = counter2 + 1;
								if (counter2 == 1) {
									mapResult2.putAll(map);
								}
							}
						}
						if (CommonUtil.isNotNullOrEmpty(mapResult1.get("count"))) {
							harga = Double.parseDouble(mapResult1.get("harga").toString());

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

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

							mapResult1.put("totalTindakan", totalTindakan1.longValue());
							mapResult1.put("datas", datas1);
							mapResult1.put("poin", point);
							mapResult1.put("pointQty", formatPointQty);

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

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

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

							mapResult2.put("totalTindakan", totalTindakan2.longValue());
							mapResult2.put("datas", datas2);
							mapResult2.put("poin", point);
							mapResult2.put("pointQty", formatPointQty);

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

		return result;
	}

	@Override
	public List<Map<String, Object>> getDetailFeeForServiceDokter(Integer idProduk, Integer idKelas,
			Integer idKomponenHarga, Integer idPegawai, String tgl, Double diskon, Integer statusDiskon) {
		List<Map<String, Object>> result = new ArrayList<>();
		List<Map<String, Object>> rawData = 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();

		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> laboranRadiologList = mapPegawaiLaboratRadiologiDao.findPegawaiLaboranRadiolog();
		List<Integer> drKsmUmumList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_UMUM);

		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 = pendapatanDao.getDetailPasienFeeForService(idKelas, idPegawai, idProduk,
				idKomponenHarga, Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA, tgl);

		// 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"))) {
								rawData.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)) {
									rawData.add(map);
								}
							}
						}
					} else {
						rawData.add(map);
					}
				}
			}
		}
		
		List<Integer> idsKonsultasiDokterJaga = splitDataSettingDatafixed("pr_konsultasi_dokter_jaga");
		List<Integer> idsPenunjangBukanAnestesi = splitDataSettingDatafixed("pr_penunjang_nonanestesi");

		// RULES_SK_FFS_2015
		if (CommonUtil.isNotNullOrEmpty(rawData)) {
			for (Map<String, Object> map : rawData) {
				double jasaMedis = 0.0;
				if (drAnastesiList.contains(idPegawai)) {
					if (idsPenunjangBukanAnestesi.contains(map.get("idProduk"))) {
						if (idKomponenHarga.equals(Master.KomponenHarga.JASA_DOKTER)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiscount")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiscount").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiscount").toString()))
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							}
							listData.add(map);
						}
					} else if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)) {
						if (idKomponenHarga.equals(Master.KomponenHarga.JASA_DOKTER)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiscount")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiscount").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiscount").toString()))
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							}
							listData.add(map);
						}
					} else {
						if (idKomponenHarga.equals(Master.KomponenHarga.JASA_DOKTER_ANASTESI)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiscount")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiscount").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiscount").toString()))
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							}
							listData.add(map);
						}
					}
				} else {
					if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.ASISTEN_SPESIALIS)) {
						if (idKomponenHarga.equals(Master.KomponenHarga.JASA_ASISTEN_SPESIALIS)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiscount")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiscount").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiscount").toString()))
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							}
							listData.add(map);
						}
					} else {
						if (idKomponenHarga.equals(Master.KomponenHarga.JASA_DOKTER)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiscount")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiscount").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiscount").toString()))
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
							}
							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()))) {
						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)
							&& map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
							&& drKsmUmumList.contains(idPegawai)
							&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
						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 (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(listDetailJenisProduk)
							&& listDetailJenisProduk.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 {
				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 (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))) {
													if (map.get("ruanganId")
															.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
															&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
														result.add(map);
													} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
														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))) {
													if (map.get("ruanganId")
															.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
															&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
														result.add(map);
													} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
														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()))) {
											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()))
											&& (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 (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))) {
													if (map.get("ruanganId")
															.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
															&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
														result.add(map);
													} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
														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))) {
													if (map.get("ruanganId")
															.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
															&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
														result.add(map);
													} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
														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)) {
											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 (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)) {
											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.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))) {
												if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
														&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
													result.add(map);
												} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
													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))) {
												if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
														&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
													result.add(map);
												} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
													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))) {
										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"))) {
							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 (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))) {
											if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
													&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
												result.add(map);
											} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
												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))) {
											if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
													&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
												result.add(map);
											} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
												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()))) {
									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)
							&& 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 (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))) {
													if (map.get("ruanganId")
															.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
															&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
														result.add(map);
													} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
														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))) {
													if (map.get("ruanganId")
															.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
															&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
														result.add(map);
													} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
														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()))) {
											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()))
											&& (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 (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))) {
													if (map.get("ruanganId")
															.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
															&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
														result.add(map);
													} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
														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))) {
													if (map.get("ruanganId")
															.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
															&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
														result.add(map);
													} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
														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)) {
											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 (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)) {
											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.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))) {
												if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
														&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
													result.add(map);
												} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
													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))) {
												if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
														&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
													result.add(map);
												} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
													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))) {
										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"))) {
							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 (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))) {
											if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
													&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
												result.add(map);
											} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
												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))) {
											if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
													&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
												result.add(map);
											} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
												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()))) {
									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 (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 (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))) {
													if (map.get("ruanganId")
															.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
															&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
														result.add(map);
													} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
														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))) {
													if (map.get("ruanganId")
															.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
															&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
														result.add(map);
													} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
														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()))) {
											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()))
											&& (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 (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))) {
													if (map.get("ruanganId")
															.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
															&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
														result.add(map);
													} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
														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))) {
													if (map.get("ruanganId")
															.equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
															&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
														result.add(map);
													} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
														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)) {
											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 (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)) {
											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.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))) {
												if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
														&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
													result.add(map);
												} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
													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))) {
												if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
														&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
													result.add(map);
												} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
													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))) {
										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"))) {
							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 (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))) {
											if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
													&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
												result.add(map);
											} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
												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))) {
											if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
													&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
												result.add(map);
											} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
												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()))) {
									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);
										}
									}
								}
							}
						}
					}
				}
			}
		}

		return result;
	}

	@Override
	public List<Map<String, Object>> getCetakLaporanFeeForServiceDokter(String periode, Integer idPegawai) {
		List<Map<String, Object>> result = new ArrayList<>();
		List<Map<String, Object>> rawData = new ArrayList<>();
		List<Map<String, Object>> listData = 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<>();

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

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

		DecimalFormat df = new DecimalFormat("#.##");
		DecimalFormatSymbols formatRp = new DecimalFormatSymbols();
		formatRp.setCurrencySymbol("Rp");
		formatRp.setMonetaryDecimalSeparator(',');
		formatRp.setGroupingSeparator('.');

		DecimalFormat kursINA = (DecimalFormat) DecimalFormat.getCurrencyInstance();
		kursINA.setDecimalFormatSymbols(formatRp);

		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>> data = pendapatanDao.getPendapatanDokter(idPegawai,
				Arrays.asList(Master.KomponenHarga.JASA_MEDIS), Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA,
				periode);

		// 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"))) {
								rawData.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)) {
									rawData.add(map);
								}
							}
						}
					} else {
						rawData.add(map);
					}
				}
			}
		}
		
		List<Integer> idsKonsultasiDokterJaga = splitDataSettingDatafixed("pr_konsultasi_dokter_jaga");
		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"));

		// RULES_SK_FFS_2015
		if (CommonUtil.isNotNullOrEmpty(rawData)) {
			for (Map<String, Object> map : rawData) {
				Double jasaMedis = 0.0;
				if (drAnastesiList.contains(idPegawai)) {
					if (idsPenunjangBukanAnestesi.contains(map.get("idProduk"))) {
						if (map.get("idJasa").equals(Master.KomponenHarga.JASA_DOKTER)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							}
							listData.add(map);
						}
					} else if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)) {
						if (map.get("idJasa").equals(Master.KomponenHarga.JASA_DOKTER)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							}
							listData.add(map);
						}
					} else {
						if (map.get("idJasa").equals(Master.KomponenHarga.JASA_DOKTER_ANASTESI)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							}
							listData.add(map);
						}
					}
				} else {
					if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.ASISTEN_SPESIALIS)) {
						if (map.get("idJasa").equals(Master.KomponenHarga.JASA_ASISTEN_SPESIALIS)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							}
							listData.add(map);
						}
					} else {
						if (map.get("idJasa").equals(Master.KomponenHarga.JASA_DOKTER)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							}
							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());
				}
				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> mapResult = new HashMap<>();
							double count = 0.0;
							double hargaJual = 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
										&& Integer.parseInt(map.get("idJenisPelaksana").toString()) == idPelaksana
										&& map.get("tanggal").toString().equals(tanggal)) {
									count = count + Double.parseDouble(map.get("count").toString());
									hargaJual = hargaJual + Double.parseDouble(map.get("jasaMedis").toString());
									dataCount = dataCount + 1;
									if (dataCount == 1) {
										mapResult.putAll(map);
									}
								}
							}
							if (CommonUtil.isNotNullOrEmpty(mapResult.get("count"))) {
								mapResult.put("count", count);
								mapResult.put("hargaJual", hargaJual);
								countResult.add(mapResult);
							}
						}
					}
				}
			}

			for (Integer idProduk : listProdukId) {
				for (Integer idKelas : listKelasId) {
					for (Integer idPelaksana : listPelaksanaId) {
						Map<String, Object> mapResult = new HashMap<>();
						List<Map<String, Object>> datas = new ArrayList<>();
						Double totalTindakan = 0.0;
						Double totalHargaJual = 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
									&& Integer.parseInt(map.get("idJenisPelaksana").toString()) == idPelaksana) {
								countMap.put("count", map.get("count"));
								countMap.put("harga", map.get("harga"));
								countMap.put("tanggal", map.get("tanggal"));
								datas.add(countMap);
								totalTindakan = totalTindakan + Double.parseDouble(map.get("count").toString());
								totalHargaJual = totalHargaJual + Double.parseDouble(map.get("hargaJual").toString());
								counter = counter + 1;
								if (counter == 1) {
									mapResult.putAll(map);
								}
							}
						}
						if (CommonUtil.isNotNullOrEmpty(mapResult.get("count"))) {
							harga = Double.parseDouble(mapResult.get("harga").toString());

							if (drAnastesiList.contains(idPegawai)) {
								if (idsPenunjangBukanAnestesi
										.contains(mapResult.get("idProduk"))) {
									percentage = persenOperator;
								} else if (mapResult.get("idJenisPelaksana")
										.equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)) {
									percentage = persenOperator;
								} else {
									percentage = persenCooperator;
								}
							} else {
								if (mapResult.get("idJenisPelaksana")
										.equals(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("jasaMedis", totalHargaJual);
							mapResult.put("jasaMedisStr", kursINA.format(totalHargaJual).toString());
							mapResult.put("datas", datas);
							mapResult.put("poin", point);
							mapResult.put("pointQty", formatPointQty);

							result.add(mapResult);
						}
					}
				}
			}
		}

		return result;
	}

	@Override
	public List<Map<String, Object>> getCetakDetailLaporanFeeForServiceDokter(Integer idPegawai, String bln) {
		List<Map<String, Object>> result = new ArrayList<>();
		List<Map<String, Object>> rawData = 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();

		DecimalFormatSymbols formatRp = new DecimalFormatSymbols();
		formatRp.setCurrencySymbol("Rp");
		formatRp.setMonetaryDecimalSeparator(',');
		formatRp.setGroupingSeparator('.');

		DecimalFormat kursINA = (DecimalFormat) DecimalFormat.getCurrencyInstance();
		kursINA.setDecimalFormatSymbols(formatRp);

		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>> data = pendapatanDao.getCetakDetailPasienDokterPerPeriode(idPegawai,
				Arrays.asList(Master.KomponenHarga.JASA_MEDIS), Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA, bln);

		// 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"))) {
								rawData.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)) {
									rawData.add(map);
								}
							}
						}
					} else {
						rawData.add(map);
					}
				}
			}
		}
		
		List<Integer> idsDokterUmumIGD = splitDataSettingDatafixed("pr_dokter_umum_igd");
		List<Integer> idsKonsultasiDokterJaga = splitDataSettingDatafixed("pr_konsultasi_dokter_jaga");
		List<Integer> idsPenunjangBukanAnestesi = splitDataSettingDatafixed("pr_penunjang_nonanestesi");

		// RULES_SK_FFS_2015
		if (CommonUtil.isNotNullOrEmpty(rawData)) {
			for (Map<String, Object> map : rawData) {
				double jasaMedis = 0.0;
				if (drAnastesiList.contains(idPegawai)) {
					if (idsPenunjangBukanAnestesi.contains(map.get("idProduk"))) {
						if (map.get("idKomponenHarga").equals(Master.KomponenHarga.JASA_DOKTER)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							}
							listData.add(map);
						}
					} else if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)) {
						if (map.get("idKomponenHarga").equals(Master.KomponenHarga.JASA_DOKTER)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							}
							listData.add(map);
						}
					} else {
						if (map.get("idKomponenHarga").equals(Master.KomponenHarga.JASA_DOKTER_ANASTESI)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							}
							listData.add(map);
						}
					}
				} else {
					if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.ASISTEN_SPESIALIS)) {
						if (map.get("idKomponenHarga").equals(Master.KomponenHarga.JASA_ASISTEN_SPESIALIS)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							}
							listData.add(map);
						}
					} else {
						if (map.get("idKomponenHarga").equals(Master.KomponenHarga.JASA_DOKTER)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									&& !map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.KEMENKES)
									|| map.get("kelompokPasienId").equals(Master.KelompokPasien.JAMKESDA)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							}
							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()))) {
						result.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"))) {
						result.add(map);
					} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProdukException)
							&& listDetailJenisProdukException
									.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);
							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"))) {
												result.add(map);
											} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
												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()))
											&& !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"))) {
												result.add(map);
											} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
												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()))
										&& !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))) {
											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))) {
										if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
												&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
											result.add(map);
										} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
											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()))
									&& !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"))) {
										result.add(map);
									} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
										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()))
											&& !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"))) {
												result.add(map);
											} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
												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()))
											&& !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"))) {
												result.add(map);
											} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
												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()))
										&& !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))) {
											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))) {
										if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
												&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
											result.add(map);
										} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
											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()))
									&& !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"))) {
										result.add(map);
									} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
										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);
							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"))) {
												result.add(map);
											} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
												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()))
											&& !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"))) {
												result.add(map);
											} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
												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()))
										&& !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))) {
											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))) {
										if (map.get("ruanganId").equals(Master.Ruangan.KLINIK_FALSE_EMERGENCY)
												&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
											result.add(map);
										} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
											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()))
									&& !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"))) {
										result.add(map);
									} else if (!map.get("departemenId").equals(Master.Departemen.IGD)) {
										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
	@Transactional
	public List<Map<String, Object>> getCetakLaporanPendapatanGroup(String periode, Integer idPegawai,
			Integer idDepartemen, Integer idRuangan, Integer idUnitKerja) {
		List<Map<String, Object>> data = 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<>();

		DecimalFormat df = new DecimalFormat("#.##");
		DecimalFormatSymbols formatRp = new DecimalFormatSymbols();

		formatRp.setCurrencySymbol("Rp");
		formatRp.setMonetaryDecimalSeparator(',');
		formatRp.setGroupingSeparator('.');
		DecimalFormat kursINA = (DecimalFormat) DecimalFormat.getCurrencyInstance();
		kursINA.setDecimalFormatSymbols(formatRp);

		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 formatPointQty = 0.0;
		Double percentage = 0.0;

		List<Integer> drLabKlinik = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK);
		List<Integer> drRadiologi = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI);
		List<Integer> drAnastesiList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_ANESTESI);
		List<Integer> drLabPatologiAnatomi = pegawaiDao
				.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI);
		List<Integer> drKsmUmumList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_UMUM);
		List<Integer> drParuhWaktu = pegawaiDao
				.getPegawaiByKategoryPegawai(Arrays.asList(Master.KategoryPegawai.DOKTER_LUAR));
		List<Integer> laboranRadiologList = mapPegawaiLaboratRadiologiDao.findPegawaiLaboranRadiolog();

		if (CommonUtil.isNotNullOrEmpty(idDepartemen) && CommonUtil.isNullOrEmpty(idRuangan)) {
			data = pendapatanDao.getPendapatanDepartemenDokter(idDepartemen, idPegawai,
					Arrays.asList(Master.KomponenHarga.JASA_MEDIS), Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA,
					periode);
		} else if (CommonUtil.isNotNullOrEmpty(idDepartemen) && CommonUtil.isNotNullOrEmpty(idRuangan)) {
			data = pendapatanDao.getPendapatanRuanganDokter(idDepartemen, idRuangan, idPegawai,
					Arrays.asList(Master.KomponenHarga.JASA_MEDIS), Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA,
					periode);
		} else if (CommonUtil.isNotNullOrEmpty(idUnitKerja)) {
			data = pendapatanDao.getPendapatanDokter(idPegawai, Arrays.asList(Master.KomponenHarga.JASA_MEDIS),
					Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA, periode);
		}

		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 (drLabPatologiAnatomi.contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPA;
		} else if (drLabKlinik.contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPK;
		} else if (drRadiologi.contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangRad;
		} else {
			listDetailJenisProduk = idsRegDJPMedisUtama;
		}

		if (laboranRadiologList.contains(idPegawai)) {
			listDetailJenisProdukException = idsRegDJPAdminNonPK;
			listDetailJenisProdukException.removeAll(listDetailJenisProduk);
		}
		
		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"));

		if (CommonUtil.isNotNullOrEmpty(data)) {
			if (drParuhWaktu.contains(idPegawai)) {
				// RULES_FFS_SK_2018
				for (Map<String, Object> map : data) {
					Map<String, Object> getJasaMedisFfs = getJasaMedisFfs(drAnastesiList,
							Integer.parseInt(map.get("idJenisPelaksana").toString()), idPegawai,
							Integer.parseInt(map.get("idProduk").toString()), map.get("namaProduk").toString(),
							Integer.parseInt(map.get("kelompokPasienId").toString()),
							Integer.parseInt(map.get("departemenId").toString()),
							Integer.parseInt(map.get("idJasa").toString()),
							Double.parseDouble(map.get("hargaJual").toString()),
							Double.parseDouble(map.get("hargaDiskon").toString()),
							Double.parseDouble(map.get("count").toString()));
					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()))) {
							if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
								map.put("jasaMedis", Double.parseDouble(getJasaMedisFfs.get("jasaMedis").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 (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
								map.put("jasaMedis", Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
								rawResult.add(map);
							}
						} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProdukException)
								&& listDetailJenisProdukException
										.contains(Integer.parseInt(map.get("detailId").toString()))) {
							if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
								map.put("jasaMedis", Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
								rawResult.add(map);
							}
						} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProduk)
								&& listDetailJenisProduk.contains(Integer.parseInt(map.get("detailId").toString()))) {
							if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
								map.put("jasaMedis", Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
								rawResult.add(map);
							}
						}
					}
				}
			} else {
				// RULES_REMUN_SK_2018
				for (Map<String, Object> map : data) {
					Map<String, Object> getJasaMedisRemun = getJasaMedisRemun(drAnastesiList,
							Integer.parseInt(map.get("idJenisPelaksana").toString()), idPegawai,
							Integer.parseInt(map.get("idProduk").toString()),
							Integer.parseInt(map.get("idJasa").toString()),
							Double.parseDouble(map.get("hargaJual").toString()),
							Double.parseDouble(map.get("hargaDiskon").toString()),
							Double.parseDouble(map.get("count").toString()));
					Map<String, Object> getJasaMedisFfs = getJasaMedisFfs(drAnastesiList,
							Integer.parseInt(map.get("idJenisPelaksana").toString()), idPegawai,
							Integer.parseInt(map.get("idProduk").toString()), map.get("namaProduk").toString(),
							Integer.parseInt(map.get("kelompokPasienId").toString()),
							Integer.parseInt(map.get("departemenId").toString()),
							Integer.parseInt(map.get("idJasa").toString()),
							Double.parseDouble(map.get("hargaJual").toString()),
							Double.parseDouble(map.get("hargaDiskon").toString()),
							Double.parseDouble(map.get("count").toString()));
					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 (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
								rawResult.add(map);
							}
						} else if (Master.KelompokPasien.BPJS
								.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
							if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").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))) {
								if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									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))) {
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
								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()))) {
								if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").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))) {
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									rawResult.add(map);
								} else
								// RULES_PSBB_ND_2020
								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)) {
											map.put("jasaMedis",
													Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
											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))) {
								if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									rawResult.add(map);
								}
							} else
							// RULES_FFS_SK_2018
							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()))) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").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()))
										&& !Arrays.stream(Master.KONSUL_VISIT)
												.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
										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()))) {
							if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
								rawResult.add(map);
							}
						} else
						// RULES_FFS_SK_2018
						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()))) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").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()))) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").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()))) {
							if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").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))) {
								if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									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))) {
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
								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()))) {
								if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").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))) {
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									rawResult.add(map);
								} else
								// RULES_PSBB_ND_2020
								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)) {
											map.put("jasaMedis",
													Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
											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))) {
								if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									rawResult.add(map);
								}
							} else
							// RULES_FFS_SK_2018
							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()))) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").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()))
										&& !Arrays.stream(Master.KONSUL_VISIT)
												.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
										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()))) {
							if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
								rawResult.add(map);
							}
						} else
						// RULES_FFS_SK_2018
						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()))) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").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()))) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").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()))) {
							if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
								rawResult.add(map);
							}
						} else if (Master.KelompokPasien.BPJS
								.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
							if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").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))) {
								if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									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))) {
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
								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()))) {
								if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").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))) {
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									rawResult.add(map);
								} else
								// RULES_PSBB_ND_2020
								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)) {
											map.put("jasaMedis",
													Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
											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))) {
								if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									rawResult.add(map);
								}
							} else
							// RULES_FFS_SK_2018
							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()))) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").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()))
										&& !Arrays.stream(Master.KONSUL_VISIT)
												.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
										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()))) {
							if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
								rawResult.add(map);
							}
						} else
						// RULES_FFS_SK_2018
						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()))) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").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()))) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").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> mapCollection = new HashMap<>();
							double count = 0.0;
							double tarif = 0.0;
							double hargaJual = 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
										&& Integer.parseInt(map.get("idJenisPelaksana").toString()) == idPelaksana
										&& map.get("tanggal").toString().equals(tanggal)) {
									count = count + Double.parseDouble(map.get("count").toString());
									tarif = tarif + Double.parseDouble(map.get("harga").toString());
									hargaJual = hargaJual + Double.parseDouble(map.get("jasaMedis").toString());
									dataCount = dataCount + 1;
									if (dataCount == 1) {
										mapCollection.putAll(map);
									}
								}
							}
							if (CommonUtil.isNotNullOrEmpty(mapCollection.get("count"))) {
								mapCollection.put("count", count);
								mapCollection.put("tarif", tarif);
								mapCollection.put("hargaJual", hargaJual);
								countResult.add(mapCollection);
							}
						}
					}
				}
			}

			for (Integer idProduk : listProdukId) {
				for (Integer idKelas : listKelasId) {
					for (Integer idPelaksana : listPelaksanaId) {
						Map<String, Object> mapCollection = new HashMap<>();
						List<Map<String, Object>> datas = new ArrayList<>();
						Double totalTindakan = 0.0;
						Double totalHargaJual = 0.0;
						Double totalTarif = 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
									&& Integer.parseInt(map.get("idJenisPelaksana").toString()) == idPelaksana) {
								countMap.put("count", map.get("count"));
								countMap.put("harga", map.get("harga"));
								countMap.put("tanggal", map.get("tanggal"));
								datas.add(countMap);
								totalTindakan = totalTindakan + Double.parseDouble(map.get("count").toString());
								totalHargaJual = totalHargaJual + Double.parseDouble(map.get("hargaJual").toString());
								totalTarif = totalTarif + Double.parseDouble(map.get("tarif").toString());
								counter = counter + 1;
								if (counter == 1) {
									mapCollection.putAll(map);
								}
							}
						}
						if (CommonUtil.isNotNullOrEmpty(mapCollection.get("count"))) {
							harga = Double.parseDouble(mapCollection.get("harga").toString());

							if (drAnastesiList.contains(idPegawai)) {
								if (idsPenunjangBukanAnestesi
										.contains(mapCollection.get("idProduk"))) {
									percentage = persenOperator;
								} else if (mapCollection.get("idJenisPelaksana")
										.equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)) {
									percentage = persenOperator;
								} else {
									percentage = persenCooperator;
								}
							} else {
								if (mapCollection.get("idJenisPelaksana")
										.equals(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));

							mapCollection.put("totalTindakan", totalTindakan.longValue());
							mapCollection.put("tarif", totalTarif);
							mapCollection.put("tarifStr", kursINA.format(totalTarif).toString());
							mapCollection.put("jasaMedis", totalHargaJual);
							mapCollection.put("jasaMedisStr", kursINA.format(totalHargaJual).toString());
							mapCollection.put("datas", datas);
							mapCollection.put("poin", point);
							mapCollection.put("pointQty", formatPointQty);

							result.add(mapCollection);
						}
					}
				}
			}
		}

		return result;
	}

	@Override
	@Transactional
	public List<Map<String, Object>> getCetakDetailLaporanPendapatanGroup(String periode, Integer idPegawai,
			Integer idDepartemen, Integer idRuangan, Integer idUnitKerja) {
		List<Map<String, Object>> data = new ArrayList<>();
		List<Map<String, Object>> result = new ArrayList<>();

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

		DecimalFormatSymbols formatRp = new DecimalFormatSymbols();
		formatRp.setCurrencySymbol("Rp");
		formatRp.setMonetaryDecimalSeparator(',');
		formatRp.setGroupingSeparator('.');

		DecimalFormat kursINA = (DecimalFormat) DecimalFormat.getCurrencyInstance();
		kursINA.setDecimalFormatSymbols(formatRp);

		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> drParuhWaktu = pegawaiDao
				.getPegawaiByKategoryPegawai(Arrays.asList(Master.KategoryPegawai.DOKTER_LUAR));
		List<Integer> laboranRadiologList = mapPegawaiLaboratRadiologiDao.findPegawaiLaboranRadiolog();

		if (CommonUtil.isNotNullOrEmpty(idDepartemen) && CommonUtil.isNullOrEmpty(idRuangan)) {
			data = pendapatanDao.getCetakDetailPasienDokterPerPeriodeDepartemen(idDepartemen, idPegawai,
					Arrays.asList(Master.KomponenHarga.JASA_MEDIS), Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA,
					periode);
		} else if (CommonUtil.isNotNullOrEmpty(idDepartemen) && CommonUtil.isNotNullOrEmpty(idRuangan)) {
			data = pendapatanDao.getCetakDetailPasienDokterPerPeriodeRuangan(idDepartemen, idRuangan, idPegawai,
					Arrays.asList(Master.KomponenHarga.JASA_MEDIS), Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA,
					periode);
		} else if (CommonUtil.isNotNullOrEmpty(idUnitKerja)) {
			data = pendapatanDao.getCetakDetailPasienDokterPerPeriode(idPegawai,
					Arrays.asList(Master.KomponenHarga.JASA_MEDIS), Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA,
					periode);
		}

		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;
		}
		
		List<Integer> idsDokterUmumIGD = splitDataSettingDatafixed("pr_dokter_umum_igd");

		if (CommonUtil.isNotNullOrEmpty(data)) {
			if (drParuhWaktu.contains(idPegawai)) {
				// RULES_FFS_SK_2018
				for (Map<String, Object> map : data) {
					Map<String, Object> getJasaMedisFfs = getJasaMedisFfs(drAnastesiList,
							Integer.parseInt(map.get("idJenisPelaksana").toString()), idPegawai,
							Integer.parseInt(map.get("idProduk").toString()), map.get("namaProduk").toString(),
							Integer.parseInt(map.get("kelompokPasienId").toString()),
							Integer.parseInt(map.get("departemenId").toString()),
							Integer.parseInt(map.get("idKomponenHarga").toString()),
							Double.parseDouble(map.get("hargaJual").toString()),
							Double.parseDouble(map.get("hargaDiskon").toString()),
							Double.parseDouble(map.get("jumlah").toString()));
					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()))) {
							if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
								map.put("jasaMedisStr",
										kursINA.format(Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()))
												.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 (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
								map.put("jasaMedisStr",
										kursINA.format(Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()))
												.toString());
								result.add(map);
							}
						} else if (CommonUtil.isNotNullOrEmpty(listDetailJenisProdukException)
								&& listDetailJenisProdukException
										.contains(Integer.parseInt(map.get("detailId").toString()))) {
							if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
								map.put("jasaMedisStr",
										kursINA.format(Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()))
												.toString());
								result.add(map);
							}
						}
					}
				}
			} else {
				// RULES_REMUN_SK_2018
				for (Map<String, Object> map : data) {
					Map<String, Object> getJasaMedisRemun = getJasaMedisRemun(drAnastesiList,
							Integer.parseInt(map.get("idJenisPelaksana").toString()), idPegawai,
							Integer.parseInt(map.get("idProduk").toString()),
							Integer.parseInt(map.get("idKomponenHarga").toString()),
							Double.parseDouble(map.get("hargaJual").toString()),
							Double.parseDouble(map.get("hargaDiskon").toString()),
							Double.parseDouble(map.get("jumlah").toString()));
					Map<String, Object> getJasaMedisFfs = getJasaMedisFfs(drAnastesiList,
							Integer.parseInt(map.get("idJenisPelaksana").toString()), idPegawai,
							Integer.parseInt(map.get("idProduk").toString()), map.get("namaProduk").toString(),
							Integer.parseInt(map.get("kelompokPasienId").toString()),
							Integer.parseInt(map.get("departemenId").toString()),
							Integer.parseInt(map.get("idKomponenHarga").toString()),
							Double.parseDouble(map.get("hargaJual").toString()),
							Double.parseDouble(map.get("hargaDiskon").toString()),
							Double.parseDouble(map.get("jumlah").toString()));
					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 (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
								map.put("jasaMedisStr",
										kursINA.format(
												Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
												.toString());
								result.add(map);
							}
						} else if (Master.KelompokPasien.BPJS
								.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
							if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
								map.put("jasaMedisStr",
										kursINA.format(
												Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
												.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))) {
								if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
									map.put("tarifStr",
											kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									map.put("jasaMedisStr",
											kursINA.format(
													Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
													.toString());
									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))) {
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
								map.put("jasaMedisStr",
										kursINA.format(
												Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
												.toString());
								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 (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
									map.put("tarifStr",
											kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									map.put("jasaMedisStr",
											kursINA.format(
													Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
													.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))) {
									map.put("tarifStr",
											kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									map.put("jasaMedisStr",
											kursINA.format(
													Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
													.toString());
									result.add(map);
								} else
								// RULES_PSBB_ND_2020
								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)) {
											map.put("tarifStr",
													kursINA.format(Double.parseDouble(map.get("harga").toString()))
															.toString());
											map.put("jasaMedis",
													Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
											map.put("jasaMedisStr",
													kursINA.format(Double
															.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()))
															.toString());
											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 (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
									map.put("tarifStr",
											kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									map.put("jasaMedisStr",
											kursINA.format(
													Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
													.toString());
									result.add(map);
								}
							} else
							// RULES_FFS_SK_2018
							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()))) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("tarifStr", kursINA
												.format(Double.parseDouble(map.get("harga").toString())).toString());
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
										map.put("jasaMedisStr",
												kursINA.format(
														Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()))
														.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)) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("tarifStr", kursINA
												.format(Double.parseDouble(map.get("harga").toString())).toString());
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
										map.put("jasaMedisStr",
												kursINA.format(
														Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()))
														.toString());
										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 (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
								map.put("jasaMedisStr",
										kursINA.format(
												Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
												.toString());
								result.add(map);
							}
						} else
						// RULES_FFS_SK_2018
						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()))) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("tarifStr", kursINA
												.format(Double.parseDouble(map.get("harga").toString())).toString());
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
										map.put("jasaMedisStr",
												kursINA.format(
														Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()))
														.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()))) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("tarifStr", kursINA
												.format(Double.parseDouble(map.get("harga").toString())).toString());
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
										map.put("jasaMedisStr",
												kursINA.format(
														Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()))
														.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()))) {
							if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
								map.put("jasaMedisStr",
										kursINA.format(
												Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
												.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))) {
								if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
									map.put("tarifStr",
											kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									map.put("jasaMedisStr",
											kursINA.format(
													Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
													.toString());
									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))) {
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
								map.put("jasaMedisStr",
										kursINA.format(
												Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
												.toString());
								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 (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
									map.put("tarifStr",
											kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									map.put("jasaMedisStr",
											kursINA.format(
													Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
													.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))) {
									map.put("tarifStr",
											kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									map.put("jasaMedisStr",
											kursINA.format(
													Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
													.toString());
									result.add(map);
								} else
								// RULES_PSBB_ND_2020
								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)) {
											map.put("tarifStr",
													kursINA.format(Double.parseDouble(map.get("harga").toString()))
															.toString());
											map.put("jasaMedis",
													Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
											map.put("jasaMedisStr",
													kursINA.format(Double
															.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()))
															.toString());
											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 (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
									map.put("tarifStr",
											kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									map.put("jasaMedisStr",
											kursINA.format(
													Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
													.toString());
									result.add(map);
								}
							} else
							// RULES_FFS_SK_2018
							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()))) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("tarifStr", kursINA
												.format(Double.parseDouble(map.get("harga").toString())).toString());
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
										map.put("jasaMedisStr",
												kursINA.format(
														Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()))
														.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)) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("tarifStr", kursINA
												.format(Double.parseDouble(map.get("harga").toString())).toString());
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
										map.put("jasaMedisStr",
												kursINA.format(
														Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()))
														.toString());
										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 (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
								map.put("jasaMedisStr",
										kursINA.format(
												Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
												.toString());
								result.add(map);
							}
						} else
						// RULES_FFS_SK_2018
						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()))) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("tarifStr", kursINA
												.format(Double.parseDouble(map.get("harga").toString())).toString());
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
										map.put("jasaMedisStr",
												kursINA.format(
														Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()))
														.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()))) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("tarifStr", kursINA
												.format(Double.parseDouble(map.get("harga").toString())).toString());
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
										map.put("jasaMedisStr",
												kursINA.format(
														Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()))
														.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 (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
								map.put("jasaMedisStr",
										kursINA.format(
												Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
												.toString());
								result.add(map);
							}
						} else if (Master.KelompokPasien.BPJS
								.equals(Integer.parseInt(map.get("kelompokPasienId").toString()))) {
							if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
								map.put("jasaMedisStr",
										kursINA.format(
												Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
												.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))) {
								if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
									map.put("tarifStr",
											kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									map.put("jasaMedisStr",
											kursINA.format(
													Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
													.toString());
									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()))) {
								if (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
									map.put("tarifStr",
											kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									map.put("jasaMedisStr",
											kursINA.format(
													Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
													.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))) {
									map.put("tarifStr",
											kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									map.put("jasaMedisStr",
											kursINA.format(
													Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
													.toString());
									result.add(map);
								} else
								// RULES_PSBB_ND_2020
								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)) {
											map.put("tarifStr",
													kursINA.format(Double.parseDouble(map.get("harga").toString()))
															.toString());
											map.put("jasaMedis",
													Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
											map.put("jasaMedisStr",
													kursINA.format(Double
															.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()))
															.toString());
											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 (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
									map.put("tarifStr",
											kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
									map.put("jasaMedis",
											Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
									map.put("jasaMedisStr",
											kursINA.format(
													Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
													.toString());
									result.add(map);
								}
							} else
							// RULES_FFS_SK_2018
							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()))) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("tarifStr", kursINA
												.format(Double.parseDouble(map.get("harga").toString())).toString());
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
										map.put("jasaMedisStr",
												kursINA.format(
														Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()))
														.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)) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("tarifStr", kursINA
												.format(Double.parseDouble(map.get("harga").toString())).toString());
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
										map.put("jasaMedisStr",
												kursINA.format(
														Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()))
														.toString());
										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 (Boolean.parseBoolean(getJasaMedisRemun.get("flagCounter").toString())) {
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()));
								map.put("jasaMedisStr",
										kursINA.format(
												Double.parseDouble(getJasaMedisRemun.get("jasaMedis").toString()))
												.toString());
								result.add(map);
							}
						} else
						// RULES_FFS_SK_2018
						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()))) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("tarifStr", kursINA
												.format(Double.parseDouble(map.get("harga").toString())).toString());
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
										map.put("jasaMedisStr",
												kursINA.format(
														Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()))
														.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()))) {
									if (Boolean.parseBoolean(getJasaMedisFfs.get("flagCounter").toString())) {
										map.put("tarifStr", kursINA
												.format(Double.parseDouble(map.get("harga").toString())).toString());
										map.put("jasaMedis",
												Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()));
										map.put("jasaMedisStr",
												kursINA.format(
														Double.parseDouble(getJasaMedisFfs.get("jasaMedis").toString()))
														.toString());
										result.add(map);
									}
								}
							}
						}
					}
				}
			}
		}

		return result;
	}

	@Override
	@Transactional
	public List<Map<String, Object>> getCetakLaporanRemunerasiGroup(String periode, Integer idPegawai,
			Integer idDepartemen, Integer idRuangan, Integer idUnitKerja) {
		List<Map<String, Object>> data = new ArrayList<>();
		List<Map<String, Object>> result = new ArrayList<>();
		List<Map<String, Object>> listData = 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("#.##");
		DecimalFormatSymbols formatRp = new DecimalFormatSymbols();

		formatRp.setCurrencySymbol("Rp");
		formatRp.setMonetaryDecimalSeparator(',');
		formatRp.setGroupingSeparator('.');
		DecimalFormat kursINA = (DecimalFormat) DecimalFormat.getCurrencyInstance();
		kursINA.setDecimalFormatSymbols(formatRp);

		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 formatPointQty = 0.0;
		Double percentage = 0.0;

		List<Integer> drLabKlinik = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK);
		List<Integer> drRadiologi = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI);
		List<Integer> drAnastesiList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_ANESTESI);
		List<Integer> drLabPatologiAnatomi = pegawaiDao
				.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI);
		List<Integer> drKsmUmumList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_UMUM);
		List<Integer> laboranRadiologList = mapPegawaiLaboratRadiologiDao.findPegawaiLaboranRadiolog();

		if (CommonUtil.isNotNullOrEmpty(idDepartemen) && CommonUtil.isNullOrEmpty(idRuangan)) {
			data = pendapatanDao.getPendapatanDepartemenDokter(idDepartemen, idPegawai,
					Arrays.asList(Master.KomponenHarga.JASA_MEDIS), Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA,
					periode);
		} else if (CommonUtil.isNotNullOrEmpty(idDepartemen) && CommonUtil.isNotNullOrEmpty(idRuangan)) {
			data = pendapatanDao.getPendapatanRuanganDokter(idDepartemen, idRuangan, idPegawai,
					Arrays.asList(Master.KomponenHarga.JASA_MEDIS), Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA,
					periode);
		} else if (CommonUtil.isNotNullOrEmpty(idUnitKerja)) {
			data = pendapatanDao.getPendapatanDokter(idPegawai, Arrays.asList(Master.KomponenHarga.JASA_MEDIS),
					Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA, periode);
		}

		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 (drLabPatologiAnatomi.contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPA;
		} else if (drLabKlinik.contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPK;
		} else if (drRadiologi.contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangRad;
		} else {
			listDetailJenisProduk = idsRegDJPMedisUtama;
		}

		if (laboranRadiologList.contains(idPegawai)) {
			listDetailJenisProdukException = idsRegDJPAdminNonPK;
			listDetailJenisProdukException.removeAll(listDetailJenisProduk);
		}
		
		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"));

		// GET_JASA_MEDIS
		if (CommonUtil.isNotNullOrEmpty(data)) {
			for (Map<String, Object> map : data) {
				Double jasaMedis = 0.0;
				if (drAnastesiList.contains(idPegawai)) {
					if (idsPenunjangBukanAnestesi.contains(map.get("idProduk"))) {
						if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)
								&& map.get("idJasa").equals(Master.KomponenHarga.JASA_DOKTER)) {
							jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
									- Double.parseDouble(map.get("hargaDiskon").toString()))
									* Double.parseDouble(map.get("count").toString());
							map.put("jasaMedis", jasaMedis);
							listData.add(map);
						}
					} else if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)) {
						if (CommonUtil.isNotNullOrEmpty(map.get("idJasa"))
								&& map.get("idJasa").equals(Master.KomponenHarga.JASA_DOKTER)) {
							jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
									- Double.parseDouble(map.get("hargaDiskon").toString()))
									* Double.parseDouble(map.get("count").toString());
							map.put("jasaMedis", jasaMedis);
							listData.add(map);
						}
					} else {
						if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.DOKTER_ANASTESI)
								&& map.get("idJasa").equals(Master.KomponenHarga.JASA_DOKTER_ANASTESI)) {
							jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
									- Double.parseDouble(map.get("hargaDiskon").toString()))
									* Double.parseDouble(map.get("count").toString());
							map.put("jasaMedis", jasaMedis);
							listData.add(map);
						}
					}
				} else {
					if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.ASISTEN_SPESIALIS)) {
						if (CommonUtil.isNotNullOrEmpty(map.get("idJasa"))
								&& map.get("idJasa").equals(Master.KomponenHarga.JASA_ASISTEN_SPESIALIS)) {
							jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
									- Double.parseDouble(map.get("hargaDiskon").toString()))
									* Double.parseDouble(map.get("count").toString());
							map.put("jasaMedis", jasaMedis);
							listData.add(map);
						}
					} else if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)) {
						if (CommonUtil.isNotNullOrEmpty(map.get("idJasa"))
								&& map.get("idJasa").equals(Master.KomponenHarga.JASA_DOKTER)) {
							jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
									- Double.parseDouble(map.get("hargaDiskon").toString()))
									* Double.parseDouble(map.get("count").toString());
							map.put("jasaMedis", jasaMedis);
							listData.add(map);
						}
					}
				}
			}
		}

		// 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()))) {
						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()))) {
						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()))) {
						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> mapCollection = new HashMap<>();
							double count = 0.0;
							double hargaJual = 0.0;
							double tarif = 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
										&& Integer.parseInt(map.get("idJenisPelaksana").toString()) == idPelaksana
										&& map.get("tanggal").toString().equals(tanggal)) {
									count = count + Double.parseDouble(map.get("count").toString());
									hargaJual = hargaJual + Double.parseDouble(map.get("jasaMedis").toString());
									tarif = tarif + Double.parseDouble(map.get("harga").toString());
									dataCount = dataCount + 1;
									if (dataCount == 1) {
										mapCollection.putAll(map);
									}
								}
							}
							if (CommonUtil.isNotNullOrEmpty(mapCollection.get("count"))) {
								mapCollection.put("count", count);
								mapCollection.put("hargaJual", hargaJual);
								mapCollection.put("tarif", tarif);
								countResult.add(mapCollection);
							}
						}
					}
				}
			}

			for (Integer idProduk : listProdukId) {
				for (Integer idKelas : listKelasId) {
					for (Integer idPelaksana : listPelaksanaId) {
						Map<String, Object> mapCollection = new HashMap<>();
						List<Map<String, Object>> datas = new ArrayList<>();
						Double totalTindakan = 0.0;
						Double totalHargaJual = 0.0;
						Double totalTarif = 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
									&& Integer.parseInt(map.get("idJenisPelaksana").toString()) == idPelaksana) {
								countMap.put("count", map.get("count"));
								countMap.put("harga", map.get("harga"));
								countMap.put("tanggal", map.get("tanggal"));
								datas.add(countMap);
								totalTindakan = totalTindakan + Double.parseDouble(map.get("count").toString());
								totalHargaJual = totalHargaJual + Double.parseDouble(map.get("hargaJual").toString());
								totalTarif = totalTarif + Double.parseDouble(map.get("tarif").toString());
								counter = counter + 1;
								if (counter == 1) {
									mapCollection.putAll(map);
								}
							}
						}
						if (CommonUtil.isNotNullOrEmpty(mapCollection.get("count"))) {
							harga = Double.parseDouble(mapCollection.get("harga").toString());

							if (drAnastesiList.contains(idPegawai)) {
								if (idsPenunjangBukanAnestesi
										.contains(mapCollection.get("idProduk"))) {
									percentage = persenOperator;
								} else if (mapCollection.get("idJenisPelaksana")
										.equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)) {
									percentage = persenOperator;
								} else {
									percentage = persenCooperator;
								}
							} else {
								if (mapCollection.get("idJenisPelaksana")
										.equals(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));

							mapCollection.put("totalTindakan", totalTindakan.longValue());
							mapCollection.put("jasaMedis", totalHargaJual);
							mapCollection.put("jasaMedisStr", kursINA.format(totalHargaJual).toString());
							mapCollection.put("tarif", totalTarif);
							mapCollection.put("tarifStr", kursINA.format(totalTarif).toString());
							mapCollection.put("datas", datas);
							mapCollection.put("poin", point);
							mapCollection.put("pointQty", formatPointQty);

							result.add(mapCollection);
						}
					}
				}
			}
		}

		return result;
	}

	@Override
	@Transactional
	public List<Map<String, Object>> getCetakDetailLaporanRemunerasiGroup(String bln, Integer idPegawai,
			Integer idDepartemen, Integer idRuangan, Integer idUnitKerja) {
		List<Map<String, Object>> data = new ArrayList<>();
		List<Map<String, Object>> result = new ArrayList<>();
		List<Map<String, Object>> listData = new ArrayList<>();

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

		DecimalFormatSymbols formatRp = new DecimalFormatSymbols();
		formatRp.setCurrencySymbol("Rp");
		formatRp.setMonetaryDecimalSeparator(',');
		formatRp.setGroupingSeparator('.');

		DecimalFormat kursINA = (DecimalFormat) DecimalFormat.getCurrencyInstance();
		kursINA.setDecimalFormatSymbols(formatRp);

		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();

		if (CommonUtil.isNotNullOrEmpty(idDepartemen) && CommonUtil.isNullOrEmpty(idRuangan)) {
			data = pendapatanDao.getCetakDetailPasienDokterPerPeriodeDepartemen(idDepartemen, idPegawai,
					Arrays.asList(Master.KomponenHarga.JASA_MEDIS), Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA,
					bln);
		} else if (CommonUtil.isNotNullOrEmpty(idDepartemen) && CommonUtil.isNotNullOrEmpty(idRuangan)) {
			data = pendapatanDao.getCetakDetailPasienDokterPerPeriodeRuangan(idDepartemen, idRuangan, idPegawai,
					Arrays.asList(Master.KomponenHarga.JASA_MEDIS), Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA,
					bln);
		} else if (CommonUtil.isNotNullOrEmpty(idUnitKerja)) {
			data = pendapatanDao.getCetakDetailPasienDokterPerPeriode(idPegawai,
					Arrays.asList(Master.KomponenHarga.JASA_MEDIS), Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA,
					bln);
		}

		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<Integer> idsDokterUmumIGD = splitDataSettingDatafixed("pr_dokter_umum_igd");
		List<Integer> idsPenunjangBukanAnestesi = splitDataSettingDatafixed("pr_penunjang_nonanestesi");

		// GET_JASA_MEDIS
		if (CommonUtil.isNotNullOrEmpty(data)) {
			for (Map<String, Object> map : data) {
				Double jasaMedis = 0.0;
				if (drAnastesiList.contains(idPegawai)) {
					if (idsPenunjangBukanAnestesi.contains(map.get("idProduk"))) {
						if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)
								&& map.get("idKomponenHarga").equals(Master.KomponenHarga.JASA_DOKTER)) {
							jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
									- Double.parseDouble(map.get("hargaDiskon").toString()))
									* Double.parseDouble(map.get("jumlah").toString());
							map.put("tarifStr",
									kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
							map.put("jasaMedis", jasaMedis);
							map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							listData.add(map);
						}
					} else if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)) {
						if (CommonUtil.isNotNullOrEmpty(map.get("idKomponenHarga"))
								&& map.get("idKomponenHarga").equals(Master.KomponenHarga.JASA_DOKTER)) {
							jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
									- Double.parseDouble(map.get("hargaDiskon").toString()))
									* Double.parseDouble(map.get("jumlah").toString());
							map.put("tarifStr",
									kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
							map.put("jasaMedis", jasaMedis);
							map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							listData.add(map);
						}
					} else {
						if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.DOKTER_ANASTESI)
								&& map.get("idKomponenHarga").equals(Master.KomponenHarga.JASA_DOKTER_ANASTESI)) {
							jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
									- Double.parseDouble(map.get("hargaDiskon").toString()))
									* Double.parseDouble(map.get("jumlah").toString());
							map.put("tarifStr",
									kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
							map.put("jasaMedis", jasaMedis);
							map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							listData.add(map);
						}
					}
				} else {
					if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.ASISTEN_SPESIALIS)) {
						if (CommonUtil.isNotNullOrEmpty(map.get("idKomponenHarga"))
								&& map.get("idKomponenHarga").equals(Master.KomponenHarga.JASA_ASISTEN_SPESIALIS)) {
							jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
									- Double.parseDouble(map.get("hargaDiskon").toString()))
									* Double.parseDouble(map.get("jumlah").toString());
							map.put("tarifStr",
									kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
							map.put("jasaMedis", jasaMedis);
							map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							listData.add(map);
						}
					} else if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)) {
						if (CommonUtil.isNotNullOrEmpty(map.get("idKomponenHarga"))
								&& map.get("idKomponenHarga").equals(Master.KomponenHarga.JASA_DOKTER)) {
							jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
									- Double.parseDouble(map.get("hargaDiskon").toString()))
									* Double.parseDouble(map.get("jumlah").toString());
							map.put("tarifStr",
									kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
							map.put("jasaMedis", jasaMedis);
							map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							listData.add(map);
						}
					}
				}
			}
		}

		// 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()))) {
						result.add(map);
					} else if (Master.KelompokPasien.BPJS
							.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()))) {
						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 (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()))) {
						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);
					}
				}
			}
		}

		return result;
	}

	@Override
	@Transactional
	public List<Map<String, Object>> getCetakLaporanFeeForServiceGroup(String periode, Integer idPegawai,
			Integer idDepartemen, Integer idRuangan, Integer idUnitKerja) {
		List<Map<String, Object>> data = new ArrayList<>();
		List<Map<String, Object>> result = new ArrayList<>();
		List<Map<String, Object>> rawData = new ArrayList<>();
		List<Map<String, Object>> listData = 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<>();

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

		DecimalFormat df = new DecimalFormat("#.##");
		DecimalFormatSymbols formatRp = new DecimalFormatSymbols();

		formatRp.setCurrencySymbol("Rp");
		formatRp.setMonetaryDecimalSeparator(',');
		formatRp.setGroupingSeparator('.');
		DecimalFormat kursINA = (DecimalFormat) DecimalFormat.getCurrencyInstance();
		kursINA.setDecimalFormatSymbols(formatRp);

		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 formatPointQty = 0.0;
		Double percentage = 0.0;

		List<Integer> drLabKlinik = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_KLINIK);
		List<Integer> drRadiologi = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_RADIOLOGI);
		List<Integer> drAnastesiList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_ANESTESI);
		List<Integer> drLabPatologiAnatomi = pegawaiDao
				.getDokterByKelompokKerja(Master.SubUnitKerja.KK_PATOLOGI_ANATOMI);
		List<Integer> drParuhWaktu = pegawaiDao
				.getPegawaiByKategoryPegawai(Arrays.asList(Master.KategoryPegawai.DOKTER_LUAR));
		List<Integer> drKsmUmumList = pegawaiDao.getDokterByKelompokKerja(Master.SubUnitKerja.KK_UMUM);
		List<Integer> laboranRadiologList = mapPegawaiLaboratRadiologiDao.findPegawaiLaboranRadiolog();

		if (CommonUtil.isNotNullOrEmpty(idDepartemen) && CommonUtil.isNullOrEmpty(idRuangan)) {
			data = pendapatanDao.getPendapatanDepartemenDokter(idDepartemen, idPegawai,
					Arrays.asList(Master.KomponenHarga.JASA_MEDIS), Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA,
					periode);
		} else if (CommonUtil.isNotNullOrEmpty(idDepartemen) && CommonUtil.isNotNullOrEmpty(idRuangan)) {
			data = pendapatanDao.getPendapatanRuanganDokter(idDepartemen, idRuangan, idPegawai,
					Arrays.asList(Master.KomponenHarga.JASA_MEDIS), Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA,
					periode);
		} else if (CommonUtil.isNotNullOrEmpty(idUnitKerja)) {
			data = pendapatanDao.getPendapatanDokter(idPegawai, Arrays.asList(Master.KomponenHarga.JASA_MEDIS),
					Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA, periode);
		}

		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 (drLabPatologiAnatomi.contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPA;
		} else if (drLabKlinik.contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangPK;
		} else if (drRadiologi.contains(idPegawai)) {
			listDetailJenisProduk = idsRegDJPPenunjangRad;
		} else {
			listDetailJenisProduk = idsRegDJPMedisUtama;
		}

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

		// 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"))) {
								rawData.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)) {
									rawData.add(map);
								}
							}
						}
					} else {
						rawData.add(map);
					}
				}
			}
		}
		
		List<Integer> idsDokterUmumIGD = splitDataSettingDatafixed("pr_dokter_umum_igd");
		List<Integer> idsKonsultasiDokterJaga = splitDataSettingDatafixed("pr_konsultasi_dokter_jaga");
		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"));

		// RULES_SK_FFS_2015
		if (CommonUtil.isNotNullOrEmpty(rawData)) {
			for (Map<String, Object> map : rawData) {
				Double jasaMedis = 0.0;
				if (drAnastesiList.contains(idPegawai)) {
					if (idsPenunjangBukanAnestesi.contains(map.get("idProduk"))) {
						if (map.get("idJasa").equals(Master.KomponenHarga.JASA_DOKTER)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							}
							listData.add(map);
						}
					} else if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)) {
						if (map.get("idJasa").equals(Master.KomponenHarga.JASA_DOKTER)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							}
							listData.add(map);
						}
					} else {
						if (map.get("idJasa").equals(Master.KomponenHarga.JASA_DOKTER_ANASTESI)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							}
							listData.add(map);
						}
					}
				} else {
					if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.ASISTEN_SPESIALIS)) {
						if (map.get("idJasa").equals(Master.KomponenHarga.JASA_ASISTEN_SPESIALIS)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							}
							listData.add(map);
						}
					} else {
						if (map.get("idJasa").equals(Master.KomponenHarga.JASA_DOKTER)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("count").toString());
								map.put("jasaMedis", jasaMedis);
							}
							listData.add(map);
						}
					}
				}
			}
		}

		// RULES_FFS
		if (CommonUtil.isNotNullOrEmpty(listData)) {
			if (drParuhWaktu.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);
							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()))) {
											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()))
											&& (dateTimePelayanan.isBefore(dateMasuk)
													|| dateTimePelayanan.isEqual(datePulang)
													|| dateTimePelayanan.isAfter(datePulang))) {
										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()))
												&& !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()))) {
									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);
							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()))) {
											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()))
											&& (dateTimePelayanan.isBefore(dateMasuk)
													|| dateTimePelayanan.isEqual(datePulang)
													|| dateTimePelayanan.isAfter(datePulang))) {
										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()))
												&& !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()))) {
									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);
							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()))) {
											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()))
											&& (dateTimePelayanan.isBefore(dateMasuk)
													|| dateTimePelayanan.isEqual(datePulang)
													|| dateTimePelayanan.isAfter(datePulang))) {
										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()))
												&& !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()))) {
									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());
				}
				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> mapCollection = new HashMap<>();
							double count = 0.0;
							double hargaJual = 0.0;
							double tarif = 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
										&& Integer.parseInt(map.get("idJenisPelaksana").toString()) == idPelaksana
										&& map.get("tanggal").toString().equals(tanggal)) {
									count = count + Double.parseDouble(map.get("count").toString());
									hargaJual = hargaJual + Double.parseDouble(map.get("jasaMedis").toString());
									tarif = tarif + Double.parseDouble(map.get("harga").toString());
									dataCount = dataCount + 1;
									if (dataCount == 1) {
										mapCollection.putAll(map);
									}
								}
							}
							if (CommonUtil.isNotNullOrEmpty(mapCollection.get("count"))) {
								mapCollection.put("count", count);
								mapCollection.put("hargaJual", hargaJual);
								mapCollection.put("tarif", tarif);
								countResult.add(mapCollection);
							}
						}
					}
				}
			}

			for (Integer idProduk : listProdukId) {
				for (Integer idKelas : listKelasId) {
					for (Integer idPelaksana : listPelaksanaId) {
						Map<String, Object> mapCollection = new HashMap<>();
						List<Map<String, Object>> datas = new ArrayList<>();
						Double totalTindakan = 0.0;
						Double totalHargaJual = 0.0;
						Double totalTarif = 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
									&& Integer.parseInt(map.get("idJenisPelaksana").toString()) == idPelaksana) {
								countMap.put("count", map.get("count"));
								countMap.put("harga", map.get("harga"));
								countMap.put("tanggal", map.get("tanggal"));
								datas.add(countMap);
								totalTindakan = totalTindakan + Double.parseDouble(map.get("count").toString());
								totalHargaJual = totalHargaJual + Double.parseDouble(map.get("hargaJual").toString());
								totalTarif = totalTarif + Double.parseDouble(map.get("tarif").toString());
								counter = counter + 1;
								if (counter == 1) {
									mapCollection.putAll(map);
								}
							}
						}
						if (CommonUtil.isNotNullOrEmpty(mapCollection.get("count"))) {
							harga = Double.parseDouble(mapCollection.get("harga").toString());

							if (drAnastesiList.contains(idPegawai)) {
								if (idsPenunjangBukanAnestesi
										.contains(mapCollection.get("idProduk"))) {
									percentage = persenOperator;
								} else if (mapCollection.get("idJenisPelaksana")
										.equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)) {
									percentage = persenOperator;
								} else {
									percentage = persenCooperator;
								}
							} else {
								if (mapCollection.get("idJenisPelaksana")
										.equals(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));

							mapCollection.put("totalTindakan", totalTindakan.longValue());
							mapCollection.put("jasaMedis", totalHargaJual);
							mapCollection.put("jasaMedisStr", kursINA.format(totalHargaJual).toString());
							mapCollection.put("tarif", totalTarif);
							mapCollection.put("tarifStr", kursINA.format(totalTarif).toString());
							mapCollection.put("datas", datas);
							mapCollection.put("poin", point);
							mapCollection.put("pointQty", formatPointQty);

							result.add(mapCollection);
						}
					}
				}
			}
		}

		return result;
	}

	@Override
	@Transactional
	public List<Map<String, Object>> getCetakDetailLaporanFeeForServiceGroup(String bln, Integer idPegawai,
			Integer idDepartemen, Integer idRuangan, Integer idUnitKerja) {
		List<Map<String, Object>> data = new ArrayList<>();
		List<Map<String, Object>> result = new ArrayList<>();
		List<Map<String, Object>> rawData = 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();

		DecimalFormatSymbols formatRp = new DecimalFormatSymbols();
		formatRp.setCurrencySymbol("Rp");
		formatRp.setMonetaryDecimalSeparator(',');
		formatRp.setGroupingSeparator('.');

		DecimalFormat kursINA = (DecimalFormat) DecimalFormat.getCurrencyInstance();
		kursINA.setDecimalFormatSymbols(formatRp);

		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();

		if (CommonUtil.isNotNullOrEmpty(idDepartemen) && CommonUtil.isNullOrEmpty(idRuangan)) {
			data = pendapatanDao.getCetakDetailPasienDokterPerPeriodeDepartemen(idDepartemen, idPegawai,
					Arrays.asList(Master.KomponenHarga.JASA_MEDIS), Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA,
					bln);
		} else if (CommonUtil.isNotNullOrEmpty(idDepartemen) && CommonUtil.isNotNullOrEmpty(idRuangan)) {
			data = pendapatanDao.getCetakDetailPasienDokterPerPeriodeRuangan(idDepartemen, idRuangan, idPegawai,
					Arrays.asList(Master.KomponenHarga.JASA_MEDIS), Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA,
					bln);
		} else if (CommonUtil.isNotNullOrEmpty(idUnitKerja)) {
			data = pendapatanDao.getCetakDetailPasienDokterPerPeriode(idPegawai,
					Arrays.asList(Master.KomponenHarga.JASA_MEDIS), Master.JenisPetugasPelaksana.PETUGAS_PELAKSANA,
					bln);
		}

		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);
		}

		// 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"))) {
								rawData.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)) {
									rawData.add(map);
								}
							}
						}
					} else {
						rawData.add(map);
					}
				}
			}
		}
		
		List<Integer> idsDokterUmumIGD = splitDataSettingDatafixed("pr_dokter_umum_igd");
		List<Integer> idsKonsultasiDokterJaga = splitDataSettingDatafixed("pr_konsultasi_dokter_jaga");
		List<Integer> idsPenunjangBukanAnestesi = splitDataSettingDatafixed("pr_penunjang_nonanestesi");

		// RULES_SK_FFS_2015
		if (CommonUtil.isNotNullOrEmpty(rawData)) {
			for (Map<String, Object> map : rawData) {
				double jasaMedis = 0.0;
				if (drAnastesiList.contains(idPegawai)) {
					if (idsPenunjangBukanAnestesi.contains(map.get("idProduk"))) {
						if (map.get("idKomponenHarga").equals(Master.KomponenHarga.JASA_DOKTER)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							}
							listData.add(map);
						}
					} else if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.DOKTER_PEMERIKSA)) {
						if (map.get("idKomponenHarga").equals(Master.KomponenHarga.JASA_DOKTER)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							}
							listData.add(map);
						}
					} else {
						if (map.get("idKomponenHarga").equals(Master.KomponenHarga.JASA_DOKTER_ANASTESI)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							}
							listData.add(map);
						}
					}
				} else {
					if (map.get("idJenisPelaksana").equals(Master.JenisPetugasPelaksana.ASISTEN_SPESIALIS)) {
						if (map.get("idKomponenHarga").equals(Master.KomponenHarga.JASA_ASISTEN_SPESIALIS)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							}
							listData.add(map);
						}
					} else {
						if (map.get("idKomponenHarga").equals(Master.KomponenHarga.JASA_DOKTER)) {
							if (!map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)
									&& Arrays.stream(Master.KONSUL_VISIT)
											.anyMatch(map.get("namaProduk").toString().toLowerCase()::contains)
									&& map.get("departemenId").equals(Master.Departemen.RAWAT_INAP)
									&& (Double.parseDouble(map.get("hargaJual").toString())
											- Double.parseDouble(map.get("hargaDiskon")
													.toString())) > Master.FeeForService.HK_02_04_III_558_2015_4_B_1) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_B_1
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("kelompokPasienId").equals(Master.KelompokPasien.BPJS)) {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Master.FeeForService.HK_02_04_III_558_2015_5_B_C_D
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else if (map.get("departemenId").equals(Master.Departemen.IGD)
									&& idsKonsultasiDokterJaga.contains(map.get("idProduk"))) {
								jasaMedis = Master.FeeForService.HK_02_04_III_558_2015_4_C_3
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							} else {
								jasaMedis = (Double.parseDouble(map.get("hargaJual").toString())
										- Double.parseDouble(map.get("hargaDiskon").toString()))
										* Double.parseDouble(map.get("jumlah").toString());
								map.put("tarifStr",
										kursINA.format(Double.parseDouble(map.get("harga").toString())).toString());
								map.put("jasaMedis", jasaMedis);
								map.put("jasaMedisStr", kursINA.format(jasaMedis).toString());
							}
							listData.add(map);
						}
					}
				}
			}
		}

		// 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()))) {
						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 {
				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()))) {
										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 (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;
	}

}
