package com.jasamedika.medifirst2000.service.impl;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.apache.commons.lang.time.DurationFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;

import com.jasamedika.medifirst2000.constants.Master;
import com.jasamedika.medifirst2000.dao.HistoriUsulanRincianKegiatanDao;
import com.jasamedika.medifirst2000.dao.IkiDanRemunerasiDao;
import com.jasamedika.medifirst2000.dao.JabatanDao;
import com.jasamedika.medifirst2000.dao.JenisLimbahB3MasukDao;
import com.jasamedika.medifirst2000.dao.KalenderDao;
import com.jasamedika.medifirst2000.dao.LimbahB3KeluarDao;
import com.jasamedika.medifirst2000.dao.MapPegawaiJabatanToUnitKerjaDao;
import com.jasamedika.medifirst2000.dao.MonitoringAbsenDao;
import com.jasamedika.medifirst2000.dao.NilaiIndexKinerjaIndividuDao;
import com.jasamedika.medifirst2000.dao.PegawaiDao;
import com.jasamedika.medifirst2000.dao.PegawaiHistoriRekapIndexDao;
import com.jasamedika.medifirst2000.dao.PencatatanSuhuMesinDao;
import com.jasamedika.medifirst2000.dao.PlanningPegawaiStatusDao;
import com.jasamedika.medifirst2000.dao.ReportingDao;
import com.jasamedika.medifirst2000.dao.SettingDataFixedDao;
import com.jasamedika.medifirst2000.dao.StatusPegawaiDao;
import com.jasamedika.medifirst2000.dao.UnitKerjaDao;
import com.jasamedika.medifirst2000.dao.custom.LimbahB3MasukDaoCustom;
import com.jasamedika.medifirst2000.dao.custom.ReportPelayananDaoCustom;
import com.jasamedika.medifirst2000.dto.BuktiPenerimaanBarangDto;
import com.jasamedika.medifirst2000.dto.HPSDto;
import com.jasamedika.medifirst2000.dto.HeadDto;
import com.jasamedika.medifirst2000.dto.HeadKasirDto;
import com.jasamedika.medifirst2000.dto.KartuPengendaliDto;
import com.jasamedika.medifirst2000.dto.KartuPulangPasienDto;
import com.jasamedika.medifirst2000.dto.KwitansiDto;
import com.jasamedika.medifirst2000.dto.LampiranSPPHDto;
import com.jasamedika.medifirst2000.dto.RekapPendapatanHarianPoliklinikDto;
import com.jasamedika.medifirst2000.dto.SuratPesananSementaraDto;
import com.jasamedika.medifirst2000.entities.Jabatan;
import com.jasamedika.medifirst2000.entities.JenisLimbahB3Masuk;
import com.jasamedika.medifirst2000.entities.LoginUser;
import com.jasamedika.medifirst2000.entities.PegawaiHistoriRekapIndex;
import com.jasamedika.medifirst2000.entities.PlanningPegawaiStatus;
import com.jasamedika.medifirst2000.entities.StatusPegawai;
import com.jasamedika.medifirst2000.entities.UnitKerjaPegawai;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.LoginUserService;
import com.jasamedika.medifirst2000.service.MonitoringAbsenService;
import com.jasamedika.medifirst2000.service.PegawaiService;
import com.jasamedika.medifirst2000.service.PengkajianAwalTransaksiService;
import com.jasamedika.medifirst2000.service.PermohonanStatusPegawaiService;
import com.jasamedika.medifirst2000.service.ReportService;
import com.jasamedika.medifirst2000.util.AgeCalculator;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.util.CurrencyUtil;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.vo.PasienVO;

@Service("ReportService")
public class ReportServiceImpl extends BaseVoServiceImpl implements ReportService {

	@Autowired
	private IkiDanRemunerasiDao ikiDanRemunerasiDao;

	@Autowired
	private ReportPelayananDaoCustom reportPelayananDaoCustom;

	@Autowired
	private PlanningPegawaiStatusDao planningPegawaiStatusDao;

	@Autowired
	private SettingDataFixedDao settingDataFixedDao;

	@Autowired
	private NilaiIndexKinerjaIndividuDao nilaiIndexKinerjaIndividuDao;

	@Autowired
	private PengkajianAwalTransaksiService pengkajianAwalTransaksiService;

	@Autowired
	private PegawaiHistoriRekapIndexDao pegawaiHistoriRekapIndexDao;

	@Autowired
	private ReportingDao reportingDao;

	@Autowired
	private PegawaiDao pegawaiDao;

	@Autowired
	private LoginUserService loginUserService;

	@Autowired
	private PegawaiService pegawaiService;

	@Autowired
	private MonitoringAbsenDao monitoringAbsenDao;

	@Autowired
	private MonitoringAbsenService monitoringAbsenService;

	@Autowired
	private PermohonanStatusPegawaiService permohonanStatusPegawaiService;

	@Autowired
	private StatusPegawaiDao statusPegawaiDao;

	@Autowired
	private LimbahB3MasukDaoCustom limbahB3MasukDaoCustom;

	@Autowired
	private LimbahB3KeluarDao limbahB3KeluarDao;

	@Autowired
	private JenisLimbahB3MasukDao jenisLimbahB3MasukDao;

	@Autowired
	private JabatanDao jabatanDao;

	@Autowired
	private PencatatanSuhuMesinDao pencatatanSuhuMesinDao;

	@Autowired
	private KalenderDao kalenderDao;

	@Autowired
	private MapPegawaiJabatanToUnitKerjaDao mapPegawaiJabatanToUnitKerjaDao;

	@Autowired
	private UnitKerjaDao unitKerjaDao;

	@Autowired
	private HistoriUsulanRincianKegiatanDao historiUsulanRincianKegiatanDao;

	private static final String[] INDONESIAN_WEEK = new String[] { "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu",
			"Minggu" };

	@Override
	public PasienVO add(PasienVO vo) throws JpaSystemException, ServiceVOException {
		return null;
	}

	@Override
	public PasienVO update(PasienVO vo) throws JpaSystemException, ServiceVOException {
		return null;
	}

	@Override
	public Boolean delete(Integer key) throws JpaSystemException {
		return null;
	}

	@Override
	public PasienVO findById(Integer key) throws JpaSystemException {
		return null;
	}

	@Override
	public List<PasienVO> findAll() throws JpaSystemException {
		return null;
	}

	@Override
	public Map<String, Object> findAllWithPageAndLimitAndSortByAndDirectionParameter(Integer page, Integer limit,
			String sort, String dir) {
		return null;
	}

	@Override
	public KwitansiDto generateKwitansi(String noKwitansi, String token) {

		String url = getUrlService();
		final String uri = url + "kasir/print-kwitansi/" + noKwitansi;

		/*
		 * RestTemplate template = new RestTemplate(); KwitansiDto kwitansiDto =
		 * template.getForObject(uri, KwitansiDto.class); return kwitansiDto;
		 */

		RestTemplate template = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		headers.setContentType(MediaType.APPLICATION_JSON);
		headers.set("X-AUTH-TOKEN", token);
		HttpEntity<KwitansiDto> httpEntity = new HttpEntity<KwitansiDto>(headers);
		ResponseEntity<KwitansiDto> data = template.exchange(uri, HttpMethod.GET, httpEntity, KwitansiDto.class);

		return data.getBody();
	}

	@Override
	public KartuPulangPasienDto generateKartuPasienPulang(String noRegistrasi, String token) {
		String url = getUrlService();
		final String uri = url + "tatarekening/cetak-pasien-pulang/" + noRegistrasi;

		RestTemplate template = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		headers.setContentType(MediaType.APPLICATION_JSON);
		headers.set("X-AUTH-TOKEN", token);
		HttpEntity<KartuPulangPasienDto> httpEntity = new HttpEntity<KartuPulangPasienDto>(headers);
		ResponseEntity<KartuPulangPasienDto> data = template.exchange(uri, HttpMethod.GET, httpEntity,
				KartuPulangPasienDto.class);

		return data.getBody();
	}

	@Override
	public List<RekapPendapatanHarianPoliklinikDto> generateRekapPendapatanHarianPoliklinik(String noRegistrasi) {
		return null;
	}

	@Override
	public KartuPengendaliDto generateKartuPengendali(String noRec) {
		String url = getUrlServiceSarPras();
		final String uri = url + "report/report-kartu-pengendali/?noRec=" + noRec;

		RestTemplate template = new RestTemplate();
		KartuPengendaliDto kartuPengendaliDto = template.getForObject(uri, KartuPengendaliDto.class);
		return kartuPengendaliDto;
	}

	@Override
	public HPSDto generateHPS(String noRec) {
		String url = getUrlServiceSarPras();
		final String uri = url + "report/report-hps/?noRec=" + noRec;

		RestTemplate template = new RestTemplate();
		HPSDto hPSDto = template.getForObject(uri, HPSDto.class);
		return hPSDto;
	}

	@Override
	public SuratPesananSementaraDto generateSPS(String noRecKartuPengendaliId, Integer supplierId) {
		String url = getUrlServiceSarPras();
		final String uri = url + "report/report-sps/?noRecKartuPengendaliId=" + noRecKartuPengendaliId + "&supplierId="
				+ supplierId;

		RestTemplate template = new RestTemplate();
		SuratPesananSementaraDto sPSDto = template.getForObject(uri, SuratPesananSementaraDto.class);
		return sPSDto;
	}

	@Override
	public LampiranSPPHDto generateLampiranSPPH(String noRec) {
		String url = getUrlServiceSarPras();
		final String uri = url + "report/report-spph/?noRec=" + noRec;

		RestTemplate template = new RestTemplate();
		LampiranSPPHDto dto = template.getForObject(uri, LampiranSPPHDto.class);
		return dto;
	}

	@Override
	public HeadKasirDto generateBilling(String noRegistrasi, String token) {
		String url = getUrlService();
		final String uri = url + "tatarekening/cetak-detail-tagihan/" + noRegistrasi;
		// HeadKasirDto model = new HeadKasirDto();
		/*
		 * RestTemplate template = new RestTemplate(); HeadKasirDto headKasirDto
		 * = template.getForObject(uri, HeadKasirDto.class);
		 * if(CommonUtil.isNullOrEmpty(headKasirDto)) { System.out.println(
		 * "null gan"); } return headKasirDto;
		 */
		try {
			RestTemplate template = new RestTemplate();
			HttpHeaders headers = new HttpHeaders();
			headers.setContentType(MediaType.APPLICATION_JSON);
			headers.set("X-AUTH-TOKEN", token);
			HttpEntity<HeadKasirDto> httpEntity = new HttpEntity<HeadKasirDto>(headers);
			ResponseEntity<HeadKasirDto> data = template.exchange(uri, HttpMethod.GET, httpEntity, HeadKasirDto.class);
			return data.getBody();
		} catch (Exception e) {
			return null;
		}
	}

	@Override
	public BuktiPenerimaanBarangDto generateBuktiPenerimaan(String noRec) {

		String url = getUrlServiceSarPras();
		final String uri = url + "report-logistik/report-penerimaan-barang/?noRec=" + noRec;

		RestTemplate template = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		headers.setContentType(MediaType.APPLICATION_JSON);
		headers.set("X-AUTH-TOKEN",
				"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ0b3RvLndpc251In0.sLuqDN6gc1eiOdxgQyEQnYAQvqaaxCxRuOIpXgBW5NRLoP4Q52fu3YuW-FylY8WEbextxHzcu79Egkldyvadyg");
		HttpEntity<BuktiPenerimaanBarangDto> httpEntity = new HttpEntity<BuktiPenerimaanBarangDto>(headers);
		// BuktiPenerimaanBarangDto buktiPenerimaanBarangDto =
		// template.getForObject(uri,httpEntity.getHeaders()
		// ,BuktiPenerimaanBarangDto.class);
		ResponseEntity<BuktiPenerimaanBarangDto> data = template.exchange(uri, HttpMethod.GET, httpEntity,
				BuktiPenerimaanBarangDto.class);

		return data.getBody();
	}

	@Override
	public BuktiPenerimaanBarangDto generateBuktiPengeluaranBarang(String noRec) {
		String url = getUrlServiceSarPras();
		final String uri = url + "report-logistik/report-mutasiBarang-barang/?noRec=" + noRec;

		RestTemplate template = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		headers.setContentType(MediaType.APPLICATION_JSON);
		headers.set("X-AUTH-TOKEN",
				"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ0b3RvLndpc251In0.sLuqDN6gc1eiOdxgQyEQnYAQvqaaxCxRuOIpXgBW5NRLoP4Q52fu3YuW-FylY8WEbextxHzcu79Egkldyvadyg");
		HttpEntity<BuktiPenerimaanBarangDto> httpEntity = new HttpEntity<BuktiPenerimaanBarangDto>(headers);
		// BuktiPenerimaanBarangDto buktiPenerimaanBarangDto =
		// template.getForObject(uri,httpEntity.getHeaders()
		// ,BuktiPenerimaanBarangDto.class);
		ResponseEntity<BuktiPenerimaanBarangDto> data = template.exchange(uri, HttpMethod.GET, httpEntity,
				BuktiPenerimaanBarangDto.class);

		return data.getBody();
	}

	@Override
	public HeadDto generateQRCode(String noRec) {

		String url = getUrlServiceSarPras();
		final String uri = url + "report-logistik/cetak-qr-code/?noRec=" + noRec + "&isPersediaan=true";

		RestTemplate template = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		headers.setContentType(MediaType.APPLICATION_JSON);
		headers.set("X-AUTH-TOKEN",
				"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ0b3RvLndpc251In0.sLuqDN6gc1eiOdxgQyEQnYAQvqaaxCxRuOIpXgBW5NRLoP4Q52fu3YuW-FylY8WEbextxHzcu79Egkldyvadyg");
		HttpEntity<HeadDto> httpEntity = new HttpEntity<HeadDto>(headers);
		// BuktiPenerimaanBarangDto buktiPenerimaanBarangDto =
		// template.getForObject(uri,httpEntity.getHeaders()
		// ,BuktiPenerimaanBarangDto.class);
		ResponseEntity<HeadDto> data = template.exchange(uri, HttpMethod.GET, httpEntity, HeadDto.class);

		return data.getBody();
	}

	@Override
	public HeadDto generateQRCodeAset(String noRec) {
		String url = getUrlServiceSarPras();
		final String uri = url + "report-logistik/cetak-qr-code/?noRec=" + noRec + "&isPersediaan=false";

		RestTemplate template = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		headers.setContentType(MediaType.APPLICATION_JSON);
		headers.set("X-AUTH-TOKEN",
				"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ0b3RvLndpc251In0.sLuqDN6gc1eiOdxgQyEQnYAQvqaaxCxRuOIpXgBW5NRLoP4Q52fu3YuW-FylY8WEbextxHzcu79Egkldyvadyg");
		HttpEntity<HeadDto> httpEntity = new HttpEntity<HeadDto>(headers);
		// BuktiPenerimaanBarangDto buktiPenerimaanBarangDto =
		// template.getForObject(uri,httpEntity.getHeaders()
		// ,BuktiPenerimaanBarangDto.class);
		ResponseEntity<HeadDto> data = template.exchange(uri, HttpMethod.GET, httpEntity, HeadDto.class);

		return data.getBody();
	}

	@Override
	@Transactional
	public Map<String, Object> generateSlipPenghasilan(Integer idPegawai, String periode) {
		String[] bulanArray = DateUtil.INDONESIAN_MONTH;
		String[] splitData = periode.split("-");
		String paramBulan = bulanArray[Integer.parseInt(splitData[1].replace("0", "")) - 1];
		Integer paramTahun = Integer.parseInt(splitData[0]);

		String date = periode + "-01";
		int enDate = monitoringAbsenService.iterateDate(date);
		Map<String, Object> pirDanIku = ikiDanRemunerasiDao.getPirDanIku();
		Double indeksKehadiran = ikiDanRemunerasiDao.getIndeksKehadiran(date, idPegawai);

		Map<String, Object> monitoring = monitoringAbsenService.jumlahKehadiran(null, null, idPegawai, date,
				periode + "-" + enDate);
		Map<String, Object> result = pegawaiService.findPegawaiByIdCustom(idPegawai);
		Map<String, Object> evaluasi = ikiDanRemunerasiDao.getEvaluasiJabatan(idPegawai);
		if (CommonUtil.isNotNullOrEmpty(monitoring)) {
			Long kelebihanJamKerja = (Long) monitoring.get("jumlahKelebihanJamKerja");
			Integer menit = kelebihanJamKerja.intValue() % 60;
			Integer jam = kelebihanJamKerja.intValue() / 60;
			result.put("kelebihanJamkerja", jam + "." + menit);
			result.put("jumlahHariKerja", ((Integer) monitoring.get("jumlahHariKerja")).toString());
		}
		if (CommonUtil.isNotNullOrEmpty(evaluasi)) {
			result.put("grade", evaluasi.get("grade"));
			result.put("nilaiJabatan", evaluasi.get("nilaiJabatan"));
		}
		if (CommonUtil.isNotNullOrEmpty(indeksKehadiran)) {
			result.put("indeksKehadiran", indeksKehadiran.toString());
		}
		if (CommonUtil.isNotNullOrEmpty(pirDanIku.get("pir"))) {
			result.put("pir", pirDanIku.get("pir"));
		}
		if (CommonUtil.isNotNullOrEmpty(pirDanIku.get("iku"))) {
			result.put("iku", pirDanIku.get("iku"));
		}
		Map<String, Object> indexKinerjaIndividu = ikiDanRemunerasiDao.getTotalIndexKinerjaIndividu(idPegawai, periode);
		if (CommonUtil.isNotNullOrEmpty(indexKinerjaIndividu)) {
			result.put("iki", ((Double) indexKinerjaIndividu.get("totalIKI")).toString());
		}
		result.put("periode", paramBulan + " / " + paramTahun);
		return result;
	}

	@Override
	public List<Map<String, Object>> generateLapRekapitulasiKehadiran(Integer idRuangan, String startDate,
			String endDate) {
		List<Integer> listIdPegawaiFilter = new ArrayList<>();
		Map<String, Object> temp = new HashMap<String, Object>();
		List<Map<String, Object>> listkehadiran = new ArrayList<Map<String, Object>>();

		List<Integer> listIdPegawai = monitoringAbsenDao.findPegawaiAktifDanKaryawanByUnitKerja(idRuangan);
		for (Integer id : listIdPegawai) {
			if (!listIdPegawaiFilter.contains(id)) {
				listIdPegawaiFilter.add(id);
			}
		}

		for (Integer idPegawai : listIdPegawaiFilter) {
			temp = monitoringAbsenService.rekapitulasiKehadiranByPegawai(idPegawai, startDate, endDate);
			if (CommonUtil.isNotNullOrEmpty(temp)) {
				listkehadiran.add(temp);
			}

		}
		return listkehadiran;
	}

	@Override
	public Map<String, Object> generateRekapitulasiStok(Integer kelompokProdukId, Integer produkId,
			Integer asalProdukId, Integer ruanganId, Integer jenisProdukId) {
		// Map<String, Object> result = new HashMap<String, Object>();
		String url = getUrlServiceSarPras();
		final String uri = url + "stok-produk-global/cetak-list-stok?kelompokProdukId=" + kelompokProdukId
				+ "&jenisProdukId=" + jenisProdukId + "&ruanganId=" + ruanganId + "&produkId=" + produkId
				+ "&asalProdukId=" + asalProdukId;

		RestTemplate template = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		headers.setContentType(MediaType.APPLICATION_JSON);
		headers.set("X-AUTH-TOKEN",
				"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ0b3RvLndpc251In0.sLuqDN6gc1eiOdxgQyEQnYAQvqaaxCxRuOIpXgBW5NRLoP4Q52fu3YuW-FylY8WEbextxHzcu79Egkldyvadyg");
		HttpEntity<Map<String, Object>> httpEntity = new HttpEntity<Map<String, Object>>(headers);
		// BuktiPenerimaanBarangDto buktiPenerimaanBarangDto =
		// template.getForObject(uri,httpEntity.getHeaders()
		// ,BuktiPenerimaanBarangDto.class);
		ResponseEntity<Map<String, Object>> data = template.exchange(uri, HttpMethod.GET, httpEntity,
				new ParameterizedTypeReference<Map<String, Object>>() {
				});

		return data.getBody();
	}

	@Override
	public Map<String, Object> generateSPMRS(String noRegistrasi) {
		Map<String, Object> result = new HashMap<String, Object>();
		// List<String> diagnosa = new ArrayList<String>();
		result = reportingDao.findSPMRS(noRegistrasi);
		if (CommonUtil.isNullOrEmpty(result)) {
			result = new HashMap<String, Object>();
		}
		List<String> diagnosa = reportingDao.findDiagnosa(noRegistrasi);
		String diagnosis = "";
		int index = 0;
		for (String diagnose : diagnosa) {
			diagnosis += diagnose;
			index++;
			if (diagnosa.size() > index) {
				diagnosis += ", ";
			}
		}
		result.put("diagnosa", diagnosis);
		return result;
	}

	@Override
	public Map<String, Object> generateSasaranMutuPoliklinik(String startDate, String endDate, Integer ruanganId,
			Integer dokterId) {
		Map<String, Object> result = new HashMap<String, Object>();
		List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
		List<Map<String, Object>> listData = new ArrayList<Map<String, Object>>();
		if (CommonUtil.isNotNullOrEmpty(startDate) && CommonUtil.isNotNullOrEmpty(endDate)) {
			data = reportingDao.FindSasaranMutuByPeriode(startDate, endDate);
			String Date = startDate + " sd " + endDate;
			result.put("tanggal", Date);
		} else if (CommonUtil.isNotNullOrEmpty(ruanganId)) {
			data = reportingDao.FindSasaranMutuByKlinik(ruanganId);
		} else if (CommonUtil.isNotNullOrEmpty(dokterId)) {
			data = reportingDao.FindSasaranMutuByDokter(dokterId);
		}

		for (Map<String, Object> temp : data) {
			Date tglDipanggilSuster = (Date) temp.get("tglDipanggilSuster");
			Date tglDipanggilDokter = (Date) temp.get("tglDipanggilDokter");
			Long selisih = reduceTime(tglDipanggilSuster, tglDipanggilDokter);
			temp.put("selisih", selisih);
			temp.put("datang", new SimpleDateFormat("HH.mm").format(tglDipanggilSuster));
			temp.put("periksa", new SimpleDateFormat("HH.mm").format(tglDipanggilDokter));
			listData.add(temp);
		}

		result.put("data", listData);
		return result;
	}

	public Long reduceTime(Date startDate, Date endDate) {
		// SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH.mm");
		Long diffMinutes = (long) 0;
		if (CommonUtil.isNotNullOrEmpty(endDate) && CommonUtil.isNotNullOrEmpty(startDate)) {
			if (endDate.getTime() > startDate.getTime()) {
				Long diff = endDate.getTime() - startDate.getTime();
				diffMinutes = diff / (60 * 1000) % 60;
				Long diffHours = diff / (60 * 60 * 1000) % 24;
				Long diffDays = diff / (24 * 60 * 60 * 1000);
				if (CommonUtil.isNotNullOrEmpty(diffHours)) {
					diffMinutes += diffHours * 60;
					if (CommonUtil.isNotNullOrEmpty(diffDays)) {
						diffMinutes += diffDays * 60 * 24;
					}
				}
			}
		}

		return diffMinutes;
	}

	public Map<String, Object> skriningNyeriNeonatus(Map<String, Object> result, String noRecPengkajian) {
		// Skrining nyeri -> id = 77
		// ekspresiWajah
		Map<String, Object> data = pengkajianAwalTransaksiService.loadPengkajianBaru(78, noRecPengkajian);
		Map<String, Object> ekspresiWajah = (Map<String, Object>) data.get("pengkajianAwal");

		if (CommonUtil.isNotNullOrEmpty(ekspresiWajah.get("value"))) {
			String ekspresiWajahValue = (String) ekspresiWajah.get("value");
			Map<String, Object> ekspresiWajahChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(ekspresiWajahValue), noRecPengkajian).get("pengkajianAwal");
			result.put("ekspresiWajah", ekspresiWajahChild.get("nama"));
			result.put("ekspresiWajahValue", ekspresiWajahChild.get("descNilai"));
		}

		// tangisan
		Map<String, Object> tangisan = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(81, noRecPengkajian).get("pengkajianAwal");
		if (CommonUtil.isNotNullOrEmpty(tangisan.get("value"))) {
			String tangisanValue = (String) tangisan.get("value");
			Map<String, Object> tangisanChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(tangisanValue), noRecPengkajian).get("pengkajianAwal");
			result.put("tangisan", tangisanChild.get("nama"));
			result.put("tangisanValue", tangisanChild.get("descNilai"));
		}

		// pola nafas
		Map<String, Object> polaNafas = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(85, noRecPengkajian).get("pengkajianAwal");
		if (CommonUtil.isNotNullOrEmpty(polaNafas.get("value"))) {
			String polaNafasValue = (String) polaNafas.get("value");
			Map<String, Object> polaNafasChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(polaNafasValue), noRecPengkajian).get("pengkajianAwal");
			result.put("polaNafas", polaNafasChild.get("nama"));
			result.put("polaNafasValue", polaNafasChild.get("descNilai"));
		}

		// Tangan
		Map<String, Object> tangan = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(88, noRecPengkajian).get("pengkajianAwal");
		if (CommonUtil.isNotNullOrEmpty(tangan.get("value"))) {
			String tanganValue = (String) tangan.get("value");
			Map<String, Object> tanganChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(tanganValue), noRecPengkajian).get("pengkajianAwal");
			result.put("tangan", tanganChild.get("nama"));
			result.put("tanganValue", tanganChild.get("descNilai"));
		}

		// kaki
		Map<String, Object> kaki = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(91, noRecPengkajian).get("pengkajianAwal");
		if (CommonUtil.isNotNullOrEmpty(kaki.get("value"))) {
			String kakiValue = (String) kaki.get("value");
			Map<String, Object> kakiChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(kakiValue), noRecPengkajian).get("pengkajianAwal");
			result.put("kaki", kakiChild.get("nama"));
			result.put("kakiValue", kakiChild.get("descNilai"));
		}

		// kesadaran
		Map<String, Object> kesadaran = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(94, noRecPengkajian).get("pengkajianAwal");
		if (CommonUtil.isNotNullOrEmpty(kesadaran.get("value"))) {
			String kesadaranValue = (String) kesadaran.get("value");
			Map<String, Object> kesadaranChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(kesadaranValue), noRecPengkajian).get("pengkajianAwal");
			result.put("kesadaran", kesadaranChild.get("nama"));
			result.put("kesadaranValue", kesadaranChild.get("descNilai"));
		}
		// totalSkor
		Map<String, Object> totalSkor = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(97, noRecPengkajian).get("pengkajianAwal");
		result.put("totalSkor", totalSkor.get("nama"));
		result.put("totalSkorValue", totalSkor.get("descNilai"));
		return result;
	}

	public Map<String, Object> diagnosisKeperawatan(Map<String, Object> result, String noRec) {
		// diagnosis keperawatan
		List<Map<String, Object>> diagnosisKeperawatan = reportingDao.findDiagnosaKeperawatanByNoRec(noRec);
		String diagnosaKeperawatan = "";
		int no = 0;
		if (CommonUtil.isNotNullOrEmpty(diagnosisKeperawatan)) {
			for (Map<String, Object> temp : diagnosisKeperawatan) {
				no++;
				diagnosaKeperawatan += "     " + no + "          "
						+ (temp.get("tglDitemukan") != null ? temp.get("tglDitemukan") : "          ")
						+ "                    "
						+ (temp.get("tglTeratasi") != null ? temp.get("tglTeratasi") : "                           ")
						+ "               " + temp.get("diagnosa") + "\n";
			}
		}
		result.put("diagnosaKeperawatan", diagnosaKeperawatan);
		return result;
	}

	public Map<String, Object> kebutuhanEdukasi(Map<String, Object> result, String noRecPengkajian) {
		// kebutuhan edukasi
		// hambatanPembelajaran
		Map<String, Object> hambatanPembelajaran = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(676, noRecPengkajian).get("pengkajianAwal");
		String hambatanPembelajarans = "";
		for (Map<String, Object> hambatan : (List<Map<String, Object>>) hambatanPembelajaran.get("detail")) {
			if (CommonUtil.isNotNullOrEmpty(hambatan.get("value"))) {
				hambatanPembelajarans += "\n- " + (String) hambatan.get("nama");
			}

		}
		result.put("hambatan", hambatanPembelajaran.get("nama") + hambatanPembelajarans);

		// edukasi
		Map<String, Object> edukasiYangDiperlukan = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(685, noRecPengkajian).get("pengkajianAwal");
		String edukasi = "";
		for (Map<String, Object> edu : (List<Map<String, Object>>) edukasiYangDiperlukan.get("detail")) {
			if (CommonUtil.isNotNullOrEmpty(edu.get("value"))) {
				edukasi += "\n- " + (String) edu.get("nama");
			}

		}
		result.put("edukasi", edukasiYangDiperlukan.get("nama") + edukasi);
		return result;
	}

	public Map<String, Object> tandaVital(Map<String, Object> result, String noRec) {
		// tandaVital-alergi-skriningGizi
		Map<String, Object> tandaVital = reportingDao.findTandaVitalNeonatus(noRec);
		if (CommonUtil.isNotNullOrEmpty(tandaVital)) {
			String suhu = tandaVital.get("suhu") != null ? ((String) tandaVital.get("suhu")) : "";
			String nadi = tandaVital.get("nadi") != null ? ((String) tandaVital.get("nadi")) : "";
			String pernapasan = tandaVital.get("pernapasan") != null ? ((String) tandaVital.get("pernapasan")) : "";
			String tekananDarah = tandaVital.get("tekananDarah") != null ? ((String) tandaVital.get("tekananDarah"))
					: "";
			String tandaTandaVital = "Suhu : " + suhu + " �C     Nadi : " + nadi + " x/menit     Pernapasan : "
					+ pernapasan + " x/menit     Tekanan Darah : " + tekananDarah + " mmHg";
			result.put("tandaVital", tandaTandaVital);

			Boolean alergi = tandaVital.get("alergi") != null ? ((Boolean) tandaVital.get("alergi")) : false;
			if (alergi) {
				result.put("alergi", "Ya");
			} else {
				result.put("alergi", "Tidak");
			}

			String bb = tandaVital.get("beratBadan") != null ? ((String) tandaVital.get("beratBadan")) : "";
			String pb = tandaVital.get("tinggiBadan") != null ? ((String) tandaVital.get("tinggiBadan")) : "";
			String lingkarKepala = tandaVital.get("lingkarkepala") != null ? ((String) tandaVital.get("lingkarkepala"))
					: "";
			String statusGizi = tandaVital.get("statusGizi") != null ? ((String) tandaVital.get("statusGizi")) : "";
			String skriningGizi = "BB : " + bb + " kg     PB : " + pb + " cm     Lingkar Kepala : " + lingkarKepala
					+ " cm    Status Gizi : " + statusGizi;
			result.put("skriningGizi", skriningGizi);
		}
		return result;
	}

	public Map<String, Object> skriningKekhususan(Map<String, Object> result, String noRecPengkajian) {
		// SKRINING KEKHUSUSAN
		String skriningKekhususan = "";
		String skriningKekhususanValue = "";
		// batuk
		Map<String, Object> batuk = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(324, noRecPengkajian).get("pengkajianAwal");
		skriningKekhususan += "\n" + batuk.get("nama");
		if (CommonUtil.isNotNullOrEmpty(batuk.get("value"))) {
			String batukValue = (String) batuk.get("value");
			Map<String, Object> batukChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(batukValue), noRecPengkajian).get("pengkajianAwal");
			skriningKekhususanValue += "\n: " + batukChild.get("nama");
		} else {
			skriningKekhususanValue += "\n: " + "Tidak";
		}

		// lendir
		Map<String, Object> lendir = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(327, noRecPengkajian).get("pengkajianAwal");
		skriningKekhususan += "\n" + "Lendir";
		if (CommonUtil.isNotNullOrEmpty(lendir.get("value"))) {
			String lendirValue = (String) lendir.get("value");
			Map<String, Object> lendirChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(lendirValue), noRecPengkajian).get("pengkajianAwal");
			skriningKekhususanValue += "\n: " + lendirChild.get("nama");
		} else {
			skriningKekhususanValue += "\n: " + "Tidak";
		}

		// sesak
		Map<String, Object> sesak = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(330, noRecPengkajian).get("pengkajianAwal");
		skriningKekhususan += "\n" + sesak.get("nama");
		if (CommonUtil.isNotNullOrEmpty(sesak.get("value"))) {
			String sesakValue = (String) sesak.get("value");
			Map<String, Object> sesakChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(sesakValue), noRecPengkajian).get("pengkajianAwal");
			skriningKekhususanValue += "\n: " + sesakChild.get("nama");
		} else {
			skriningKekhususanValue += "\n: " + "Tidak";
		}

		// muntah
		Map<String, Object> muntah = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(333, noRecPengkajian).get("pengkajianAwal");
		skriningKekhususan += "\n" + muntah.get("nama");
		if (CommonUtil.isNotNullOrEmpty(muntah.get("value"))) {
			String muntahValue = (String) muntah.get("value");
			Map<String, Object> muntahChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(muntahValue), noRecPengkajian).get("pengkajianAwal");
			skriningKekhususanValue += "\n: " + muntahChild.get("nama");
		} else {
			skriningKekhususanValue += "\n: " + "Tidak";
		}

		// diare
		Map<String, Object> diare = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(336, noRecPengkajian).get("pengkajianAwal");
		skriningKekhususan += "\n" + diare.get("nama");
		if (CommonUtil.isNotNullOrEmpty(diare.get("value"))) {
			String diareValue = (String) diare.get("value");
			Map<String, Object> diareChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(diareValue), noRecPengkajian).get("pengkajianAwal");
			skriningKekhususanValue += "\n: " + diareChild.get("nama");
		} else {
			skriningKekhususanValue += "\n: " + "Tidak";
		}

		// kejang
		Map<String, Object> kejang = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(339, noRecPengkajian).get("pengkajianAwal");
		skriningKekhususan += "\n" + kejang.get("nama");
		if (CommonUtil.isNotNullOrEmpty(kejang.get("value"))) {
			String kejangValue = (String) kejang.get("value");
			Map<String, Object> kejangChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(kejangValue), noRecPengkajian).get("pengkajianAwal");
			skriningKekhususanValue += "\n: " + kejangChild.get("nama");
		} else {
			skriningKekhususanValue += "\n: " + "Tidak";
		}

		// ikterik
		Map<String, Object> ikterik = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(342, noRecPengkajian).get("pengkajianAwal");
		skriningKekhususan += "\n" + ikterik.get("nama");
		if (CommonUtil.isNotNullOrEmpty(ikterik.get("value"))) {
			String ikterikValue = (String) ikterik.get("value");
			Map<String, Object> ikterikChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(ikterikValue), noRecPengkajian).get("pengkajianAwal");
			skriningKekhususanValue += "\n: " + ikterikChild.get("nama");
		} else {
			skriningKekhususanValue += "\n: " + "Tidak";
		}
		// pucat
		Map<String, Object> pucat = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(345, noRecPengkajian).get("pengkajianAwal");
		skriningKekhususan += "\n" + pucat.get("nama");
		if (CommonUtil.isNotNullOrEmpty(pucat.get("value"))) {
			String pucatValue = (String) pucat.get("value");
			Map<String, Object> pucatChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(pucatValue), noRecPengkajian).get("pengkajianAwal");
			skriningKekhususanValue += "\n: " + pucatChild.get("nama");
		} else {
			skriningKekhususanValue += "\n: " + "Tidak";
		}
		// pendarahan
		Map<String, Object> pendarahan = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(348, noRecPengkajian).get("pengkajianAwal");
		skriningKekhususan += "\n" + pendarahan.get("nama");
		if (CommonUtil.isNotNullOrEmpty(pendarahan.get("value"))) {
			String pendarahanValue = (String) pendarahan.get("value");
			Map<String, Object> pendarahanChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(pendarahanValue), noRecPengkajian).get("pengkajianAwal");
			skriningKekhususanValue += "\n: " + pendarahanChild.get("nama");
		} else {
			skriningKekhususanValue += "\n: " + "Tidak";
		}
		// memar
		Map<String, Object> memar = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(351, noRecPengkajian).get("pengkajianAwal");
		skriningKekhususan += "\n" + memar.get("nama");
		if (CommonUtil.isNotNullOrEmpty(memar.get("value"))) {
			String memarValue = (String) memar.get("value");
			Map<String, Object> memarChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(memarValue), noRecPengkajian).get("pengkajianAwal");
			skriningKekhususanValue += "\n: " + memarChild.get("nama");
		} else {
			skriningKekhususanValue += "\n: " + "Tidak";
		}
		result.put("skriningKekhususan", skriningKekhususan);
		result.put("skriningKekhususanValue", skriningKekhususanValue);
		return result;
	}

	public Map<String, Object> skriningNyeriAnakDewasa(Map<String, Object> result, String noRecPengkajian) {
		// SkriningNyeriAnak
		String skriningNyeri = "";
		Map<String, Object> rasaNyeri = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(99, noRecPengkajian).get("pengkajianAwal");
		skriningNyeri += "1. " + rasaNyeri.get("nama") + " : ";
		if (CommonUtil.isNotNullOrEmpty(rasaNyeri.get("value"))) {
			String batukValue = (String) rasaNyeri.get("value");
			Map<String, Object> rasaNyeriChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(batukValue), noRecPengkajian).get("pengkajianAwal");
			skriningNyeri += rasaNyeriChild.get("nama");
		} else {
			skriningNyeri += "Tidak";
		}
		Map<String, Object> lokasi = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(103, noRecPengkajian).get("pengkajianAwal");
		skriningNyeri += "     Lokasi : " + (lokasi.get("value") != null ? lokasi.get("value") : "");

		Map<String, Object> frekuensi = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(104, noRecPengkajian).get("pengkajianAwal");
		skriningNyeri += "     Frekuensi : " + (frekuensi.get("value") != null ? frekuensi.get("value") : "");

		Map<String, Object> durasi = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(105, noRecPengkajian).get("pengkajianAwal");
		skriningNyeri += "     Durasi : " + (durasi.get("value") != null ? durasi.get("value") : "");

		Map<String, Object> skorNyeri = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(702, noRecPengkajian).get("pengkajianAwal");
		skriningNyeri += "\n2. Skor Nyeri : ";
		if (CommonUtil.isNotNullOrEmpty(skorNyeri.get("value"))) {
			String skorNyeriValue = (String) skorNyeri.get("value");
			Map<String, Object> skorNyeriChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(skorNyeriValue), noRecPengkajian).get("pengkajianAwal");
			skriningNyeri += " " + (skorNyeriChild.get("descNilai") != null ? skorNyeriChild.get("descNilai") : "");
		}

		Map<String, Object> tipeNyeri = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(107, noRecPengkajian).get("pengkajianAwal");
		skriningNyeri += "\n3. " + tipeNyeri.get("nama") + " : ";
		if (CommonUtil.isNotNullOrEmpty(tipeNyeri.get("value"))) {
			String batukValue = (String) tipeNyeri.get("value");
			Map<String, Object> tipeNyeriChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(batukValue), noRecPengkajian).get("pengkajianAwal");
			skriningNyeri += tipeNyeriChild.get("nama");
		}

		Map<String, Object> karakteristikNyeri = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(110, noRecPengkajian).get("pengkajianAwal");
		skriningNyeri += "\n4. " + karakteristikNyeri.get("nama") + " : ";
		if (CommonUtil.isNotNullOrEmpty(karakteristikNyeri.get("value"))) {
			String batukValue = (String) karakteristikNyeri.get("value");
			Map<String, Object> karakteristikNyeriChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(batukValue), noRecPengkajian).get("pengkajianAwal");
			skriningNyeri += karakteristikNyeriChild.get("nama");
		}

		Map<String, Object> nyeriMempengaruhi = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(118, noRecPengkajian).get("pengkajianAwal");
		skriningNyeri += "\n5. " + nyeriMempengaruhi.get("nama") + " : ";
		for (Map<String, Object> data : (List<Map<String, Object>>) nyeriMempengaruhi.get("detail")) {
			if ((data.get("value") + "").equals("true")) {
				skriningNyeri += data.get("nama") + "   ";
			}
		}

		String penilaianNyeri = "";
		String penilaianNyeriValue = "";
		Integer jumlahNilai = 0;
		Map<String, Object> kategori = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(125, noRecPengkajian).get("pengkajianAwal");
		for (Map<String, Object> kategoriChild : (List<Map<String, Object>>) kategori.get("detail")) {
			Map<String, Object> temp = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(kategoriChild.get("id") + ""), noRecPengkajian)
					.get("pengkajianAwal");
			penilaianNyeri += " - " + temp.get("nama") + "\n";
			if (CommonUtil.isNotNullOrEmpty(temp.get("value"))) {
				Map<String, Object> tempChild = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(Integer.valueOf(temp.get("value") + ""), noRecPengkajian)
						.get("pengkajianAwal");
				penilaianNyeri += "   " + tempChild.get("nama") + "\n";
				penilaianNyeriValue += "\n  " + tempChild.get("descNilai") + "\n";
				jumlahNilai += Integer.valueOf(tempChild.get("descNilai") + "");
			}
		}

		result.put("skriningNyeri", skriningNyeri);
		result.put("penilaianNyeri", penilaianNyeri);
		result.put("penilaianNyeriValue", penilaianNyeriValue);
		result.put("jumlahNilai", jumlahNilai.toString());
		return result;
	}

	public Map<String, Object> klinik(Map<String, Object> result, String noRecPengkajian) {
		// klinik
		String klinikBedah = "";
		String klinikBedahValue = "";
		Map<String, Object> bedah = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(494, noRecPengkajian).get("pengkajianAwal");
		for (Map<String, Object> temp : (List<Map<String, Object>>) bedah.get("detail")) {
			klinikBedah += temp.get("nama") + "\n";
			if (CommonUtil.isNotNullOrEmpty(temp.get("value"))) {
				Map<String, Object> tempChild = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(Integer.valueOf(temp.get("value") + ""), noRecPengkajian)
						.get("pengkajianAwal");
				klinikBedahValue += " : " + tempChild.get("nama") + "\n";
			} else {
				klinikBedahValue += " : Tidak" + "\n";
			}
		}
		String klinikKulit = "";
		String klinikKulitValue = "";
		Map<String, Object> kulit = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(504, noRecPengkajian).get("pengkajianAwal");
		for (Map<String, Object> temp : (List<Map<String, Object>>) kulit.get("detail")) {
			klinikKulit += temp.get("nama") + "\n";
			if (CommonUtil.isNotNullOrEmpty(temp.get("value"))) {
				Map<String, Object> tempChild = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(Integer.valueOf(temp.get("value") + ""), noRecPengkajian)
						.get("pengkajianAwal");
				klinikKulitValue += " : " + tempChild.get("nama") + "\n";
			} else {
				klinikKulitValue += " : Tidak" + "\n";
			}
		}

		String klinikMata = "";
		String klinikMataValue = "";
		Map<String, Object> mata = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(516, noRecPengkajian).get("pengkajianAwal");
		for (Map<String, Object> temp : (List<Map<String, Object>>) mata.get("detail")) {
			klinikMata += temp.get("nama") + "\n";
			if (CommonUtil.isNotNullOrEmpty(temp.get("value"))) {
				Map<String, Object> tempChild = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(Integer.valueOf(temp.get("value") + ""), noRecPengkajian)
						.get("pengkajianAwal");
				klinikMataValue += " : " + tempChild.get("nama") + "\n";
			} else {
				klinikMataValue += " : Tidak" + "\n";
			}
		}

		String klinikNeurologi = "";
		String klinikNeurologiValue = "";
		Map<String, Object> neurologi = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(529, noRecPengkajian).get("pengkajianAwal");
		for (Map<String, Object> temp : (List<Map<String, Object>>) neurologi.get("detail")) {
			klinikNeurologi += temp.get("nama") + "\n";
			if (CommonUtil.isNotNullOrEmpty(temp.get("value"))) {
				Map<String, Object> tempChild = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(Integer.valueOf(temp.get("value") + ""), noRecPengkajian)
						.get("pengkajianAwal");
				klinikNeurologiValue += " : " + tempChild.get("nama") + "\n";
			} else {
				klinikNeurologiValue += " : Tidak" + "\n";
			}
		}
		String klinikLaktasi = "";
		String klinikLaktasiValue = "";
		Map<String, Object> laktasi = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(539, noRecPengkajian).get("pengkajianAwal");
		for (Map<String, Object> temp : (List<Map<String, Object>>) laktasi.get("detail")) {
			klinikLaktasi += temp.get("nama") + "\n";
			if (CommonUtil.isNotNullOrEmpty(temp.get("value"))) {
				Map<String, Object> tempChild = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(Integer.valueOf(temp.get("value") + ""), noRecPengkajian)
						.get("pengkajianAwal");
				klinikLaktasiValue += " : " + tempChild.get("nama") + "\n";
			} else {
				klinikLaktasiValue += " : " + "\n";
			}
		}
		String klinikTHT = "";
		String klinikTHTValue = "";
		Map<String, Object> tht = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(565, noRecPengkajian).get("pengkajianAwal");
		for (Map<String, Object> temp : (List<Map<String, Object>>) tht.get("detail")) {
			klinikTHT += temp.get("nama") + "\n";
			if (CommonUtil.isNotNullOrEmpty(temp.get("value"))) {
				Map<String, Object> tempChild = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(Integer.valueOf(temp.get("value") + ""), noRecPengkajian)
						.get("pengkajianAwal");
				klinikTHTValue += " : " + tempChild.get("nama") + "\n";
			} else {
				klinikTHTValue += " : " + "\n";
			}
		}
		result.put("klinikBedah", klinikBedah);
		result.put("klinikBedahValue", klinikBedahValue);
		result.put("klinikKulit", klinikKulit);
		result.put("klinikMata", klinikMata);
		result.put("klinikNeurologi", klinikNeurologi);
		result.put("klinikLaktasi", klinikLaktasi);
		result.put("klinikTHT", klinikTHT);
		result.put("klinikKulitValue", klinikKulitValue);
		result.put("klinikMataValue", klinikMataValue);
		result.put("klinikNeurologiValue", klinikNeurologiValue);
		result.put("klinikLaktasiValue", klinikLaktasiValue);
		result.put("klinikTHTValue", klinikTHTValue);

		return result;
	}

	public Map<String, Object> statusFungsional(Map<String, Object> result, String noRecPengkajian) {
		// statusFungsional
		Map<String, Object> statusFungsional = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(242, noRecPengkajian).get("pengkajianAwal");
		String statusFungsi = "";
		for (Map<String, Object> status : (List<Map<String, Object>>) statusFungsional.get("detail")) {

			if (CommonUtil.isNotNullOrEmpty(status.get("value")) && (int) status.get("id") != 246) {
				statusFungsi += "- " + (String) status.get("nama");
				statusFungsi += " : " + (String) status.get("value") + "\n";
			}
		}
		statusFungsi += "Aktivitas sehari-hari : ";
		Map<String, Object> aktivitas = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(246, noRecPengkajian).get("pengkajianAwal");
		if (CommonUtil.isNotNullOrEmpty(aktivitas.get("value"))) {
			statusFungsi += ((Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(aktivitas.get("value") + ""), noRecPengkajian)
					.get("pengkajianAwal")).get("nama");
		}
		result.put("statusFungsional", statusFungsi);
		return result;
	}

	public List<Map<String, Object>> sortedMap(List<Map<String, Object>> list) {
		List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
		List<Map<String, String>> listMap = new ArrayList<Map<String, String>>();
		List<Map<String, String>> listMap1 = new ArrayList<Map<String, String>>();
		// convert into Map<String,String>
		for (Map<String, Object> temp : list) {
			Map<String, String> newMap = new HashMap<String, String>();
			for (Map.Entry<String, Object> entry : temp.entrySet()) {
				if (entry.getValue() instanceof String) {
					newMap.put(entry.getKey(), entry.getValue().toString());
				}
			}
			listMap.add(newMap);
		}
		// compare map
		Comparator<Map<String, String>> mapComparator = new Comparator<Map<String, String>>() {
			public int compare(Map<String, String> m1, Map<String, String> m2) {
				return m1.get("id").compareTo(m2.get("id"));
			}
		};

		Collections.sort(listMap, mapComparator);

		// convert into Map<String,String>
		for (Map<String, String> tempMap : listMap) {
			Map<String, Object> newMap = new HashMap<String, Object>();
			newMap.putAll(tempMap);
			result.add(newMap);
		}
		return result;
	}

	public Map<String, Object> resikoJatuh(Map<String, Object> result, String noRecPengkajian) {
		// PenilaianResikoJatuh
		String resikoJatuh = "";
		Map<String, Object> penilaianResikoJatuh = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(148, noRecPengkajian).get("pengkajianAwal");
		if (CommonUtil.isNotNullOrEmpty(penilaianResikoJatuh.get("value"))) {
			resikoJatuh = ((Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(penilaianResikoJatuh.get("value") + ""), noRecPengkajian)
					.get("pengkajianAwal")).get("nama") + "";
		}
		Map<String, Object> pernahJatuh = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(152, noRecPengkajian).get("pengkajianAwal");
		resikoJatuh += "\n1. " + pernahJatuh.get("nama") + " : ";
		if (CommonUtil.isNotNullOrEmpty(pernahJatuh.get("value"))) {
			String pernahJatuhValue = (String) pernahJatuh.get("value");
			Map<String, Object> pernahJatuhChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(pernahJatuhValue), noRecPengkajian).get("pengkajianAwal");
			resikoJatuh += pernahJatuhChild.get("nama");
		} else {
			resikoJatuh += "Tidak";
		}

		Map<String, Object> alatBantu = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(155, noRecPengkajian).get("pengkajianAwal");
		resikoJatuh += "\n2. " + alatBantu.get("nama") + " : ";
		if (CommonUtil.isNotNullOrEmpty(alatBantu.get("value"))) {
			String alatBantuValue = (String) alatBantu.get("value");
			Map<String, Object> alatBantuChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(alatBantuValue), noRecPengkajian).get("pengkajianAwal");
			resikoJatuh += alatBantuChild.get("nama");
		} else {
			resikoJatuh += "Tidak";
		}
		resikoJatuh += "\n" + ((Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(Integer.valueOf(158), noRecPengkajian).get("pengkajianAwal")).get("nama");
		resikoJatuh += "\n1) " + ((Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(Integer.valueOf(159), noRecPengkajian).get("pengkajianAwal")).get("nama");
		resikoJatuh += "\n2) " + ((Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(Integer.valueOf(160), noRecPengkajian).get("pengkajianAwal")).get("nama");
		result.put("resikoJatuh", resikoJatuh);
		return result;
	}

	public Map<String, Object> psikososial(Map<String, Object> result, String noRecPengkajian) {
		// PENGKAJIAN KEBUTUHAN DASAR

		// PSIKOSOSIAL
		// statusPsikologi
		Map<String, Object> statusPsikologiYangDiperlukan = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(300, noRecPengkajian).get("pengkajianAwal");
		String statusPsikologi = "";
		for (Map<String, Object> status : (List<Map<String, Object>>) statusPsikologiYangDiperlukan.get("detail")) {
			if (CommonUtil.isNotNullOrEmpty(status.get("value"))) {
				statusPsikologi += "\n- " + (String) status.get("nama");
			}

		}
		result.put("statusPsikologi", statusPsikologiYangDiperlukan.get("nama") + statusPsikologi);

		// statusSosial
		Map<String, Object> statusSosialYangDiperlukan = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(308, noRecPengkajian).get("pengkajianAwal");
		String statusSosial = "";
		for (Map<String, Object> status : (List<Map<String, Object>>) statusSosialYangDiperlukan.get("detail")) {
			statusSosial += "\n- " + status.get("nama") + "";
			Map<String, Object> temp = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(status.get("id") + ""), noRecPengkajian).get("pengkajianAwal");
			for (Map<String, Object> tempChild : (List<Map<String, Object>>) temp.get("detail")) {
				if (CommonUtil.isNotNullOrEmpty(tempChild.get("value"))) {
					statusSosial += " : " + (String) status.get("nama");
				}

			}

		}
		result.put("statusSosial", statusSosialYangDiperlukan.get("nama") + statusSosial);
		return result;
	}

	public Map<String, Object> resikoJatuhRawatInap(Map<String, Object> result, String noRecPengkajian) {
		// PenilaianResikoJatuh
		String resikoJatuh = "";
		Map<String, Object> penilaianResikoJatuh = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(148, noRecPengkajian).get("pengkajianAwal");
		if (CommonUtil.isNotNullOrEmpty(penilaianResikoJatuh.get("value"))) {
			resikoJatuh += ((Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(penilaianResikoJatuh.get("value") + ""), noRecPengkajian)
					.get("pengkajianAwal")).get("nama") + "";
		}
		result.put("resikoJatuh", resikoJatuh);

		String parameter = "";
		String kriteria = "";
		String skor = "";
		Integer totalSkor = 0;
		Map<String, Object> param = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(163, noRecPengkajian).get("pengkajianAwal");
		for (Map<String, Object> status : (List<Map<String, Object>>) param.get("detail")) {
			parameter += " - " + status.get("nama") + "\n";

			if (CommonUtil.isNotNullOrEmpty(status.get("value"))) {
				Map<String, Object> paramChild = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(Integer.valueOf(status.get("value") + ""), noRecPengkajian)
						.get("pengkajianAwal");
				kriteria += " " + paramChild.get("nama") + "\n";
				skor += " " + paramChild.get("descNilai") + "\n";
				if ((status.get("nama") + "").length() > 30) {
					kriteria += "\n";
					skor += "\n";
				}
				if ((paramChild.get("nama") + "").length() > 60) {
					parameter += "\n";
					skor += "\n";
				}

				totalSkor += Integer.valueOf("" + paramChild.get("descNilai"));
			}
		}
		result.put("parameter", parameter);
		result.put("kriteria", kriteria);
		result.put("skor", skor);
		result.put("totalSkor", totalSkor.toString());
		return result;
	}

	public Map<String, Object> pengkajianKebutuhanDasarRawatInap(Map<String, Object> result, String noRecPengkajian) {

		String pengkajianKebutuhanDasar = "";
		String pengkajianKebutuhanDasarValue = "";
		Map<String, Object> param = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(713, noRecPengkajian).get("pengkajianAwal");
		for (Map<String, Object> status : (List<Map<String, Object>>) param.get("detail")) {
			pengkajianKebutuhanDasar += " - " + status.get("nama") + "\n";
			if (CommonUtil.isNotNullOrEmpty(status.get("value"))) {
				Map<String, Object> paramChild = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(Integer.valueOf(status.get("value") + ""), noRecPengkajian)
						.get("pengkajianAwal");
				pengkajianKebutuhanDasarValue += " " + paramChild.get("nama")
						+ (paramChild.get("value") != null ? "  " + paramChild.get("value") : "") + "\n";
			} else {
				pengkajianKebutuhanDasarValue += " Tidak ada masalah \n";
			}
		}
		result.put("pengkajianKebutuhanDasar", pengkajianKebutuhanDasar);
		result.put("pengkajianKebutuhanDasarValue", pengkajianKebutuhanDasarValue);
		return result;
	}

	public Map<String, Object> statusFungsionalRawatInap(Map<String, Object> result, String noRecPengkajian) {
		String fungsiStatusFungsional = "";
		String keteranganStatusFungsional = "";
		String skorStatusFungsional = "";
		Integer totalSkorStatusFungsional = 0;
		Integer no = 0;
		String nomor = "";
		Map<String, Object> param = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(251, noRecPengkajian).get("pengkajianAwal");
		for (Map<String, Object> status : (List<Map<String, Object>>) param.get("detail")) {
			no++;
			nomor += no + "\n";
			fungsiStatusFungsional += " " + status.get("nama") + "\n";
			if (CommonUtil.isNotNullOrEmpty(status.get("value"))) {
				Map<String, Object> paramChild = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(Integer.valueOf(status.get("value") + ""), noRecPengkajian)
						.get("pengkajianAwal");
				keteranganStatusFungsional += " " + paramChild.get("nama") + "\n";
				skorStatusFungsional += " " + paramChild.get("descNilai") + "\n";
				totalSkorStatusFungsional += Integer.valueOf("" + paramChild.get("descNilai"));
			}
		}
		result.put("noStatusFungsional", nomor);
		result.put("fungsiStatusFungsional", fungsiStatusFungsional);
		result.put("keteranganStatusFungsional", keteranganStatusFungsional);
		result.put("skorStatusFungsional", skorStatusFungsional);
		result.put("totalSkorStatusFungsional", totalSkorStatusFungsional.toString());
		return result;
	}

	public Map<String, Object> perencanaanPulang(Map<String, Object> result, String noRecPengkajian) {
		// perencanaanPulang
		String komponenPenilaian = "";
		String penilaianValue = "";
		Map<String, Object> perencanaanPulang = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(760, noRecPengkajian).get("pengkajianAwal");
		for (Map<String, Object> data : (List<Map<String, Object>>) perencanaanPulang.get("detail")) {
			komponenPenilaian += " " + data.get("nama") + "\n";
			if (CommonUtil.isNotNullOrEmpty(data.get("value"))) {
				Map<String, Object> dataChild = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(Integer.valueOf(data.get("value") + ""), noRecPengkajian)
						.get("pengkajianAwal");
				penilaianValue += " " + dataChild.get("nama")
						+ (dataChild.get("value") != null ? ", " + dataChild.get("value") : "") + "\n";
			} else {
				penilaianValue += " Tidak\n";
			}
		}
		result.put("komponenPenilaian", komponenPenilaian);
		result.put("penilaianValue", penilaianValue);
		return result;
	}

	public Map<String, Object> pengkajianKebutuhanDasar(Map<String, Object> result, String noRecPengkajian) {
		// pengkajianKebutuhanDasar
		String pengkajianKebutuhanDasar = "";
		String pengkajianKebutuhanDasarValue = "";
		Map<String, Object> perencanaanPulang = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(713, noRecPengkajian).get("pengkajianAwal");
		for (Map<String, Object> data : (List<Map<String, Object>>) perencanaanPulang.get("detail")) {
			pengkajianKebutuhanDasar += " " + data.get("nama") + "\n";
			Map<String, Object> dataChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(data.get("value") + ""), noRecPengkajian).get("pengkajianAwal");
			pengkajianKebutuhanDasarValue += " " + dataChild.get("nama") + ", " + dataChild.get("value") + "\n";
		}
		result.put("pengkajianKebutuhanDasar", pengkajianKebutuhanDasar);
		result.put("pengkajianKebutuhanDasarValue", pengkajianKebutuhanDasarValue);
		return result;
	}

	public Map<String, Object> riwayatKelahiranRawatInap(Map<String, Object> result, String noRecPengkajian) {

		// riwayatKelahiran
		String riwayatKelahiran = "";
		Map<String, Object> riwayatKelahirans = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(356, noRecPengkajian).get("pengkajianAwal");
		if (CommonUtil.isNotNullOrEmpty(riwayatKelahirans.get("value"))) {
			riwayatKelahiran = ((Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(riwayatKelahirans.get("value") + ""), noRecPengkajian)
					.get("pengkajianAwal")).get("nama") + " ";

		}
		result.put("riwayatKelahiran", riwayatKelahiran);

		// riwayatImunisasiDasar
		String riwayatImunisasiDasar = "";
		Map<String, Object> imunisasiDasar = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(359, noRecPengkajian).get("pengkajianAwal");
		if (CommonUtil.isNotNullOrEmpty(imunisasiDasar.get("value"))) {
			riwayatImunisasiDasar = ((Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(imunisasiDasar.get("value") + ""), noRecPengkajian)
					.get("pengkajianAwal")).get("nama") + "";

		}
		result.put("riwayatImunisasiDasar", riwayatImunisasiDasar);

		// riwayatTumbuhKembang
		String riwayatTumbuhKembang = "";
		Map<String, Object> tumbuhKembang = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(363, noRecPengkajian).get("pengkajianAwal");
		for (Map<String, Object> data : (List<Map<String, Object>>) tumbuhKembang.get("detail")) {
			riwayatTumbuhKembang += data.get("nama") + ", usia : "
					+ (data.get("value") != null ? data.get("value") + " bulan" : "") + "          ";
		}
		result.put("riwayatTumbuhKembang", riwayatTumbuhKembang);

		return result;
	}

	public Map<String, Object> skriningKekhususanNeonatus(Map<String, Object> result, String noRecPengkajian) {
		// SKRINING KEKHUSUSAN
		// INFORMASI IBU
		String informasiIbu = "";
		String informasiIbuValue = "";
		Map<String, Object> nama = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(373, noRecPengkajian).get("pengkajianAwal");
		informasiIbu = nama.get("nama") + "";
		informasiIbuValue = ": " + nama.get("value") + "";

		Map<String, Object> ibuDirawat = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(374, noRecPengkajian).get("pengkajianAwal");
		if (CommonUtil.isNotNullOrEmpty(ibuDirawat.get("value"))) {
			String ibuDirawatValue = (String) ibuDirawat.get("value");
			Map<String, Object> ibuDirawatChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(ibuDirawatValue), noRecPengkajian).get("pengkajianAwal");
			informasiIbuValue += "\n: " + ibuDirawatChild.get("nama");
		} else {
			informasiIbuValue += "\n: " + "Tidak";
		}
		informasiIbu = "\n" + ibuDirawat.get("nama") + "";

		Map<String, Object> noCm = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(377, noRecPengkajian).get("pengkajianAwal");
		informasiIbu = "\n" + noCm.get("nama") + "";
		informasiIbuValue = "\n: " + noCm.get("value") + "";

		Map<String, Object> noRm = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(377, noRecPengkajian).get("pengkajianAwal");
		informasiIbu = "\n" + noRm.get("nama") + "";
		informasiIbuValue = "\n: " + noRm.get("value") + "";

		Map<String, Object> ruang = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(378, noRecPengkajian).get("pengkajianAwal");
		informasiIbu = "\n" + ruang.get("nama") + "";
		informasiIbuValue = "\n: " + ruang.get("value") + "";

		Map<String, Object> tglLahir = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(379, noRecPengkajian).get("pengkajianAwal");
		informasiIbu = "\n" + tglLahir.get("nama") + "";
		informasiIbuValue = "\n: " + tglLahir.get("value") + "";

		Map<String, Object> bangsa = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(380, noRecPengkajian).get("pengkajianAwal");
		informasiIbu = "\n" + bangsa.get("nama") + "";
		informasiIbuValue = "\n: " + bangsa.get("value") + "";

		Map<String, Object> agama = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(381, noRecPengkajian).get("pengkajianAwal");
		informasiIbu = "\n" + agama.get("nama") + "";
		informasiIbuValue = "\n: " + agama.get("value") + "";

		Map<String, Object> statusPerkawinan = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(382, noRecPengkajian).get("pengkajianAwal");
		if (CommonUtil.isNotNullOrEmpty(statusPerkawinan.get("value"))) {
			String statusPerkawinanValue = (String) statusPerkawinan.get("value");
			Map<String, Object> statusPerkawinanChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(statusPerkawinanValue), noRecPengkajian).get("pengkajianAwal");
			informasiIbuValue += "\n: " + statusPerkawinanChild.get("nama");
		} else {
			informasiIbuValue += "\n: " + "Tidak";
		}
		informasiIbu = "\n" + statusPerkawinan.get("nama") + "";

		Map<String, Object> ditolongOleh = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(385, noRecPengkajian).get("pengkajianAwal");
		if (CommonUtil.isNotNullOrEmpty(ditolongOleh.get("value"))) {
			String ditolongOlehValue = (String) ditolongOleh.get("value");
			Map<String, Object> ditolongOlehChild = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(ditolongOlehValue), noRecPengkajian).get("pengkajianAwal");
			informasiIbuValue += "\n: " + ditolongOlehChild.get("nama");
		} else {
			informasiIbuValue += "\n: " + "Tidak";
		}
		informasiIbu = "\n" + ditolongOleh.get("nama") + "";

		result.put("informasiIbu", informasiIbu);
		result.put("informasiIbuValue", informasiIbuValue);
		// Riwayat kelahiran Yang Lalu
		Map<String, Object> riwayatKelahiranyangLalu = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(388, noRecPengkajian).get("pengkajianAwal");
		Integer nomor = 0;
		String tglThn = "";
		String sex = "";
		String beratBadanlahir = "";
		String keadaanBayi = "";
		String komplikasi = "";
		String penyakitWaktuHamil = "";
		String jenisPersalinan = "";
		String lainLain = "";
		for (Map<String, Object> riwayatKelahiranyangLaluChild : (List<Map<String, Object>>) riwayatKelahiranyangLalu
				.get("detail")) {
			nomor++;
			if ((Integer) riwayatKelahiranyangLaluChild.get("id") == 390) {
				Map<String, Object> temp = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(390, noRecPengkajian).get("pengkajianAwal");
				tglThn += "\n" + (temp.get("value") != null ? temp.get("value") : "");
			} else if ((Integer) riwayatKelahiranyangLaluChild.get("id") == 391) {
				Map<String, Object> temp = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(391, noRecPengkajian).get("pengkajianAwal");
				sex += "\n" + (temp.get("value") != null ? temp.get("value") : "");
			} else if ((Integer) riwayatKelahiranyangLaluChild.get("id") == 392) {
				Map<String, Object> temp = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(392, noRecPengkajian).get("pengkajianAwal");
				beratBadanlahir += "\n" + (temp.get("value") != null ? temp.get("value") : "");
			} else if ((Integer) riwayatKelahiranyangLaluChild.get("id") == 393) {
				Map<String, Object> temp = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(393, noRecPengkajian).get("pengkajianAwal");
				Map<String, Object> tempChild = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(Integer.valueOf(temp.get("value") + ""), noRecPengkajian)
						.get("pengkajianAwal");
				keadaanBayi += "\n" + (temp.get("value") != null ? temp.get("value") : "");
			} else if ((Integer) riwayatKelahiranyangLaluChild.get("id") == 400) {
				Map<String, Object> temp = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(400, noRecPengkajian).get("pengkajianAwal");
				Map<String, Object> tempChild = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(Integer.valueOf(temp.get("value") + ""), noRecPengkajian)
						.get("pengkajianAwal");
				komplikasi += "\n" + (temp.get("value") != null ? temp.get("value") : "");
			} else if ((Integer) riwayatKelahiranyangLaluChild.get("id") == 406) {
				Map<String, Object> temp = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(406, noRecPengkajian).get("pengkajianAwal");
				Map<String, Object> tempChild = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(Integer.valueOf(temp.get("value") + ""), noRecPengkajian)
						.get("pengkajianAwal");
				penyakitWaktuHamil += "\n" + (temp.get("value") != null ? temp.get("value") : "");
			} else if ((Integer) riwayatKelahiranyangLaluChild.get("id") == 411) {
				Map<String, Object> temp = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(406, noRecPengkajian).get("pengkajianAwal");
				Map<String, Object> tempChild = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(Integer.valueOf(temp.get("value") + ""), noRecPengkajian)
						.get("pengkajianAwal");
				jenisPersalinan += "\n" + (temp.get("value") != null ? temp.get("value") : "");
			} else if ((Integer) riwayatKelahiranyangLaluChild.get("id") == 416) {
				Map<String, Object> temp = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(416, noRecPengkajian).get("pengkajianAwal");
				lainLain += "\n" + (temp.get("value") != null ? temp.get("value") : "");
			}
		}
		result.put("nomor", nomor);
		result.put("tglThn", tglThn);
		result.put("sex", sex);
		result.put("beratBadanlahir", beratBadanlahir);
		result.put("keadaanBayi", keadaanBayi);
		result.put("komplikasi", komplikasi);
		result.put("penyakitWaktuHamil", penyakitWaktuHamil);
		result.put("jenisPersalinan", jenisPersalinan);
		result.put("lainLain", lainLain);
		return result;
	}

	public String conditionalString(String string) {
		if (string.equals("null")) {
			return "";
		} else {
			return string;
		}
	}

	public Map<String, Object> obstetrikDanGinekologi(Map<String, Object> result, String noRecPengkajian) {
		String kawin = "";

		kawin = "Kawin : " + conditionalString(((Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(712, noRecPengkajian).get("pengkajianAwal")).get("value") + "") + " kali";
		kawin += "     Umur kawin pertama : " + conditionalString(((Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(589, noRecPengkajian).get("pengkajianAwal")).get("value") + "") + " tahun";
		kawin += "     Umur kawin kedua : " + conditionalString(((Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(590, noRecPengkajian).get("pengkajianAwal")).get("value") + "") + " tahun";
		Map<String, Object> masihKawin = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(592, noRecPengkajian).get("pengkajianAwal");
		kawin += "\nMasih Kawin : ";
		if (CommonUtil.isNotNullOrEmpty(masihKawin.get("value"))) {
			kawin += "" + conditionalString(((Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(masihKawin.get("value") + ""), noRecPengkajian)
					.get("pengkajianAwal")).get("nama") + "");
		}
		kawin += "     Umur Suami : " + conditionalString(((Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(591, noRecPengkajian).get("pengkajianAwal")).get("value") + "") + " tahun";
		result.put("kawin", kawin);

		String kehamilanYangSekarang = "";
		String kehamilanYangSekarangValue = "";
		kehamilanYangSekarang += "HPPT : " + conditionalString(((Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(606, noRecPengkajian).get("pengkajianAwal")).get("value") + "");
		kehamilanYangSekarang += "     Taksiran Partus : "
				+ conditionalString(((Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(607, noRecPengkajian).get("pengkajianAwal")).get("value") + "");
		Map<String, Object> hiperemesis = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(608, noRecPengkajian).get("pengkajianAwal");
		kehamilanYangSekarang += "\nHiperemesis : ";
		if (CommonUtil.isNotNullOrEmpty(hiperemesis.get("value"))) {
			kehamilanYangSekarangValue += "\n" + conditionalString(((Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(hiperemesis.get("value") + ""), noRecPengkajian)
					.get("pengkajianAwal")).get("nama") + "");
		}

		Map<String, Object> toksemia = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(611, noRecPengkajian).get("pengkajianAwal");
		kehamilanYangSekarang += "\nToksemia : ";
		if (CommonUtil.isNotNullOrEmpty(toksemia.get("value"))) {
			kehamilanYangSekarangValue += "\n" + conditionalString(((Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(toksemia.get("value") + ""), noRecPengkajian)
					.get("pengkajianAwal")).get("nama") + "");
		}

		Map<String, Object> eklampsia = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(614, noRecPengkajian).get("pengkajianAwal");
		kehamilanYangSekarang += "\nEklampsia : ";
		if (CommonUtil.isNotNullOrEmpty(eklampsia.get("value"))) {
			kehamilanYangSekarangValue += "\n" + ((Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(eklampsia.get("value") + ""), noRecPengkajian)
					.get("pengkajianAwal")).get("nama");
		}
		Map<String, Object> perdarahan = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(617, noRecPengkajian).get("pengkajianAwal");
		kehamilanYangSekarang += "\nPerdarahan : ";
		if (CommonUtil.isNotNullOrEmpty(perdarahan.get("value"))) {
			kehamilanYangSekarangValue += "\n" + ((Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(perdarahan.get("value") + ""), noRecPengkajian)
					.get("pengkajianAwal")).get("nama");
		}
		Map<String, Object> kontraksi = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(620, noRecPengkajian).get("pengkajianAwal");
		kehamilanYangSekarang += "\nKontraksi : ";
		if (CommonUtil.isNotNullOrEmpty(kontraksi.get("value"))) {
			kehamilanYangSekarangValue += "\n" + ((Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(kontraksi.get("value") + ""), noRecPengkajian)
					.get("pengkajianAwal")).get("nama");
		}
		Map<String, Object> kPD = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(623, noRecPengkajian).get("pengkajianAwal");
		kehamilanYangSekarang += "\n KPD : ";
		if (CommonUtil.isNotNullOrEmpty(kPD.get("value"))) {
			kehamilanYangSekarangValue += "\n" + ((Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(kPD.get("value") + ""), noRecPengkajian).get("pengkajianAwal"))
							.get("nama");
		}
		Map<String, Object> keluargaBerencana = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(626, noRecPengkajian).get("pengkajianAwal");
		kehamilanYangSekarang += "\nKeluarga Berencana : ";
		if (CommonUtil.isNotNullOrEmpty(keluargaBerencana.get("value"))) {
			kehamilanYangSekarangValue += "\n" + ((Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(keluargaBerencana.get("value") + ""), noRecPengkajian)
					.get("pengkajianAwal")).get("nama");
		}
		result.put("kehamilanYangSekarang", kehamilanYangSekarang);
		result.put("kehamilanYangSekarangValue", kehamilanYangSekarangValue);

		String statusGinekologi = "";
		Map<String, Object> haid = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(630, noRecPengkajian).get("pengkajianAwal");
		statusGinekologi += "Haid : ";
		if (CommonUtil.isNotNullOrEmpty(haid.get("value"))) {
			statusGinekologi += "" + ((Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(haid.get("value") + ""), noRecPengkajian).get("pengkajianAwal"))
							.get("nama");
		}
		statusGinekologi += "     Siklus : " + conditionalString(((Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(633, noRecPengkajian).get("pengkajianAwal")).get("value") + "") + " hari";
		Map<String, Object> jlhDarahHaid = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(634, noRecPengkajian).get("pengkajianAwal");
		statusGinekologi += "\nJumlah Darah Haid : ";
		if (CommonUtil.isNotNullOrEmpty(jlhDarahHaid.get("value"))) {
			statusGinekologi += "" + ((Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(jlhDarahHaid.get("value") + ""), noRecPengkajian)
					.get("pengkajianAwal")).get("nama");
		}
		Map<String, Object> keputihan = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(638, noRecPengkajian).get("pengkajianAwal");
		statusGinekologi += "\nKeputihan : ";
		if (CommonUtil.isNotNullOrEmpty(keputihan.get("value"))) {
			statusGinekologi += "" + ((Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(Integer.valueOf(keputihan.get("value") + ""), noRecPengkajian)
					.get("pengkajianAwal")).get("nama");
		}
		String golDarah = "";
		golDarah += "Istri: " + conditionalString(((Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(643, noRecPengkajian).get("pengkajianAwal")).get("value") + "");
		golDarah += "     Rhesus: " + conditionalString(((Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(644, noRecPengkajian).get("pengkajianAwal")).get("value") + "");
		golDarah += "\nSuami: " + conditionalString(((Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(645, noRecPengkajian).get("pengkajianAwal")).get("value") + "");
		golDarah += "     Rhesus: " + conditionalString(((Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(646, noRecPengkajian).get("pengkajianAwal")).get("value") + "");

		String penyakit = "";
		penyakit += "Penyakit Lain : ";
		Map<String, Object> penyakitLain = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(647, noRecPengkajian).get("pengkajianAwal");
		for (Map<String, Object> data : (List<Map<String, Object>>) penyakitLain.get("detail")) {
			if (CommonUtil.isNotNullOrEmpty(data.get("value"))) {
				penyakit += "" + data.get("nama") + "     ";
			}
		}

		result.put("statusGinekologi", statusGinekologi);
		result.put("golDarah", golDarah);
		result.put("penyakitLain", penyakit);
		return result;
	}

	public Map<String, Object> skriningGiziAnak(Map<String, Object> result, String noRecPengkajian) {
		Map<String, Object> daftarPenyakit = (Map<String, Object>) pengkajianAwalTransaksiService
				.loadPengkajianBaru(16, noRecPengkajian).get("pengkajianAwal");
		String daftarPenyakit1 = "";
		String daftarPenyakit2 = "";
		String daftarPenyakit3 = "";
		int index = 0;
		for (Map<String, Object> data : (List<Map<String, Object>>) daftarPenyakit.get("detail")) {
			index++;
			if (index < 9) {
				daftarPenyakit1 += "- " + data.get("nama") + "\n";
			} else if (index < 14) {
				daftarPenyakit2 += "- " + data.get("nama") + "\n";
				if ((int) data.get("id") == 21) {
					Map<String, Object> daftarPenyakitChild = (Map<String, Object>) pengkajianAwalTransaksiService
							.loadPengkajianBaru(21, noRecPengkajian).get("pengkajianAwal");
					for (Map<String, Object> datas : (List<Map<String, Object>>) daftarPenyakitChild.get("detail")) {
						daftarPenyakit2 += "  " + datas.get("nama") + "\n";
					}
				}
			} else {
				daftarPenyakit3 += "- " + data.get("nama") + "\n";
			}
		}
		String skriningGiziAnakValue = "";
		Integer nlai = 0;

		for (int i = 5; i < 9; i++) {
			Map<String, Object> jawaban = (Map<String, Object>) pengkajianAwalTransaksiService
					.loadPengkajianBaru(i, noRecPengkajian).get("pengkajianAwal");
			if (CommonUtil.isNotNullOrEmpty(jawaban.get("value"))) {
				Map<String, Object> jawabanChild = (Map<String, Object>) pengkajianAwalTransaksiService
						.loadPengkajianBaru(Integer.valueOf(jawaban.get("value") + ""), noRecPengkajian)
						.get("pengkajianAwal");
				skriningGiziAnakValue += jawabanChild.get("nama") + "\n\n\n";
				nlai += Integer.valueOf(jawabanChild.get("descNilai") + "");
			} else {
				skriningGiziAnakValue += "\n\n\n";
			}
		}
		result.put("skriningGiziAnakValue", skriningGiziAnakValue);
		result.put("totalSkriningGiziAnakValue", nlai.toString());
		result.put("daftarPenyakit1", daftarPenyakit1);
		result.put("daftarPenyakit2", daftarPenyakit2);
		result.put("daftarPenyakit3", daftarPenyakit3);
		return result;
	}

	@Override
	public Map<String, Object> pengkajianAwalNeonatusRawatJalan(String kdpap, String noRec) {
		Map<String, Object> result = new HashMap<String, Object>();
		try {
			String noRecPengkajian = reportingDao.findPengkajianAwalByNoRec(kdpap, noRec);
			// String noRec = reportingDao.findNoRecBykdPap(kdpap);
			this.tandaVital(result, noRec);
			this.skriningNyeriNeonatus(result, noRecPengkajian);
			this.kebutuhanEdukasi(result, noRecPengkajian);
			this.skriningKekhususan(result, noRecPengkajian);

			this.diagnosisKeperawatan(result, noRec);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	@Override
	public Map<String, Object> pengkajianAwalNeonatusRawatInap(String kdpap, String noRec) {
		Map<String, Object> result = new HashMap<String, Object>();
		// tandaVital-alergi-skriningGizi
		try {
			String noRecPengkajian = reportingDao.findPengkajianAwalByNoRec(kdpap, noRec);
			// noRec = reportingDao.findNoRecBykdPap(kdpap);
			this.tandaVital(result, noRec);
			this.skriningNyeriNeonatus(result, noRecPengkajian);
			this.kebutuhanEdukasi(result, noRecPengkajian);
			this.psikososial(result, noRecPengkajian);
			this.skriningKekhususanNeonatus(result, noRecPengkajian);
			this.diagnosisKeperawatan(result, noRecPengkajian);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	@Override
	public Map<String, Object> pengkajianAwalAnakRawatJalan(String kdpap, String noRec) {
		Map<String, Object> result = new HashMap<String, Object>();
		try {
			String noRecPengkajian = reportingDao.findPengkajianAwalByNoRec(kdpap, noRec);
			// String noRec = reportingDao.findNoRecBykdPap(kdpap);
			this.tandaVital(result, noRec);
			this.kebutuhanEdukasi(result, noRecPengkajian);
			this.skriningKekhususan(result, noRecPengkajian);
			this.skriningNyeriAnakDewasa(result, noRecPengkajian);
			this.klinik(result, noRecPengkajian);
			this.statusFungsional(result, noRecPengkajian);
			this.diagnosisKeperawatan(result, noRec);
			this.resikoJatuh(result, noRecPengkajian);

		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	@Override
	public Map<String, Object> pengkajianAwalDewasaRawatJalan(String kdpap, String noRec) {
		Map<String, Object> result = new HashMap<String, Object>();
		try {
			String noRecPengkajian = reportingDao.findPengkajianAwalByNoRec(kdpap, noRec);
			// String noRec = reportingDao.findNoRecBykdPap(kdpap);
			this.tandaVital(result, noRec);
			this.skriningNyeriAnakDewasa(result, noRecPengkajian);
			this.resikoJatuh(result, noRecPengkajian);
			this.statusFungsional(result, noRecPengkajian);
			this.kebutuhanEdukasi(result, noRecPengkajian);
			this.klinik(result, noRecPengkajian);
			this.obstetrikDanGinekologi(result, noRecPengkajian);
			this.diagnosisKeperawatan(result, noRec);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	@Override
	public Map<String, Object> resumeMedis(String noRec) {
		Map<String, Object> result = new HashMap<String, Object>();
		try {

			List<String> diagnosisUtamaData = reportingDao.findDiagnosisUtama(noRec);
			String diagnosisUtama = "";
			for (String data : diagnosisUtamaData) {
				diagnosisUtama += data + "\n";
			}

			List<String> diagnosisSekunderData = reportingDao.findDiagnosisSekunder(noRec);
			String diagnosisSekunder = "";
			for (String data : diagnosisSekunderData) {
				diagnosisSekunder += data + "\n";
			}

			tandaVital(result, noRec);
			List<Map<String, Object>> terapiPulang = reportingDao.findDetailTerapiPulang(noRec);
			String namaObat = "";
			String jumlah = "";
			String dosis = "";
			String frekuensi = "";
			String caraPemberian = "";
			for (Map<String, Object> terapi : terapiPulang) {
				namaObat += (terapi.get("namaObat") != null ? " " + terapi.get("namaObat") + "\n" : "\n");
				jumlah += (terapi.get("jumlah") != null ? " " + terapi.get("jumlah") + "\n" : "\n");
				dosis += (terapi.get("dosis") != null ? " " + terapi.get("dosis") + "\n" : "\n");
				frekuensi += (terapi.get("frekuensi") != null ? " " + terapi.get("frekuensi") + "\n" : "\n");
				caraPemberian += (terapi.get("caraPemberian") != null ? " " + terapi.get("caraPemberian") + "\n"
						: "\n");
			}
			result.put("namaObat", namaObat);
			result.put("jumlah", jumlah);
			result.put("dosis", dosis);
			result.put("frekuensi", frekuensi);
			result.put("caraPemberian", caraPemberian);
			Map<String, Object> resumeMedis = reportingDao.findResumeMedis(noRec);
			result.putAll(resumeMedis);
			String terapiPengobatan = "";
			List<String> obats = reportingDao.findListObat(noRec);
			for (String temp : obats) {
				terapiPengobatan += "- " + temp + "\n";
			}
			String tindakanProsedur = "";
			List<String> tindakan = reportingDao.findListTindakan(noRec);
			for (String temp : tindakan) {
				tindakanProsedur += "- " + temp + "\n";
			}
			result.put("terapiPengobatan", terapiPengobatan);
			result.put("diagnosaUtama", diagnosisUtama);
			result.put("diagnosaSekunder", diagnosisSekunder);
			result.put("tindakanProsedur", tindakanProsedur);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	@Override
	public Map<String, Object> pengkajianAwalAnakRawatInap(String kdPap, String noRec) {
		Map<String, Object> result = new HashMap<String, Object>();
		try {
			String noRecPengkajian = reportingDao.findPengkajianAwalByNoRec(kdPap, noRec);
			this.tandaVital(result, noRec);
			this.skriningGiziAnak(result, noRecPengkajian);
			this.skriningNyeriAnakDewasa(result, noRecPengkajian);
			this.resikoJatuhRawatInap(result, noRecPengkajian);
			this.statusFungsionalRawatInap(result, noRecPengkajian);
			this.kebutuhanEdukasi(result, noRecPengkajian);
			this.psikososial(result, noRecPengkajian);
			this.riwayatKelahiranRawatInap(result, noRecPengkajian);
			this.pengkajianKebutuhanDasarRawatInap(result, noRecPengkajian);
			this.diagnosisKeperawatan(result, noRecPengkajian);
			this.perencanaanPulang(result, noRecPengkajian);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	@Override
	public Map<String, Object> tracer(String noRegistrasi) {
		Map<String, Object> result = new HashMap<String, Object>();
		LoginUser loginUser = loginUserService.getLoginUser();
		result = reportingDao.findPasienDaftar(noRegistrasi);
		result.put("user", loginUser.getPegawai().getNamaLengkap());
		return result;
	}

	@Override
	public Map<String, Object> labelPasien(String noRegistrasi) {
		Map<String, Object> result = reportingDao.findPasienDaftar(noRegistrasi);
		String jenisKelamin = result.get("jenisKelamin") + "";
		jenisKelamin = jenisKelamin.substring(0, 1);
		result.put("jenisKelamin", jenisKelamin);
		return result;
	}

	@Override
	public Map<String, Object> ringkasanKeluarMasuk(String noRegistrasi) {

		Map<String, Object> result = reportingDao.findPasienDaftar(noRegistrasi);
		List<Map<String, Object>> alamats = reportingDao.findMapPasienByNoCm(result.get("noCm") + "");
		if (CommonUtil.isNotNullOrEmpty(alamats.get(0).get("alamatlengkap"))) {
			result.put("alamatLengkap", alamats.get(0).get("alamatlengkap"));
		}
		List<String> list = reportingDao.findNoRecAntrian(noRegistrasi);
		if (CommonUtil.isNotNullOrEmpty(list)) {
			Map<String, Object> pasien = reportingDao.findPasienByNoRegistrasi(list.get(0));
			List<String> diagnosa = reportingDao.findDiagnosisUtama(list.get(0));
			String umur = AgeCalculator
					.calculateAge2((Date) pasien.get("tanggalRegistrasi"), (Date) pasien.get("tanggalLahir"))
					.toString();
			if (CommonUtil.isNotNullOrEmpty(diagnosa)) {
				result.put("diagnosaMasuk", diagnosa.get(0));
			}
			result.put("umur", umur);
			result.putAll(pasien);
		}
		return result;
	}

	@Override
	public List<Map<String, Object>> generateLapRekapitulasiIndexKehadiran(String periode) {
		List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
		result = nilaiIndexKinerjaIndividuDao.findRekapitulasiIndeksKehadiran(periode);
		return result;
	}

	@Override
	public List<Map<String, Object>> generateSuratPermohonanCuti(String noRec) {
		PlanningPegawaiStatus planningPegawaiStatus = planningPegawaiStatusDao.findOne(noRec);
		return null;
	}

	@Override
	public Map<String, Object> generateLapPermohonanCuti(String noRecPlanning, Integer idJabatan, Integer idAtasan1,
			Integer idAtasan2, Integer idKaRu) {
		Map<String, Object> result = new HashMap<String, Object>();
		// PegawaiHistoriRekapIndex pegawaiHistoriRekapIndex=
		// pegawaiHistoriRekapIndexDao.getPegawaiHistoriRekapIndex(noRecPlanning);

		Map<String, Object> atasan1 = pegawaiDao.findPegawaiById(idAtasan1);
		Map<String, Object> atasan2 = pegawaiDao.findPegawaiById(idAtasan2);
		Map<String, Object> kaRu = pegawaiDao.findPegawaiById(idKaRu);
		if (CommonUtil.isNotNullOrEmpty(atasan1)) {
			result.put("namaAtasan1", atasan1.get("nama"));
			result.put("jabatanAtasan1", atasan1.get("jabatanInternal"));
			result.put("nipAtasan1", atasan1.get("nipPns"));
			if (CommonUtil.isNullOrEmpty(atasan1.get("nipPns"))) {
				result.put("nipAtasan1", atasan1.get("nip"));
			}
		}
		if (CommonUtil.isNotNullOrEmpty(atasan2)) {
			result.put("namaAtasan2", atasan2.get("nama"));
			result.put("jabatanAtasan2", atasan2.get("jabatanInternal"));
			result.put("nipAtasan2", atasan2.get("nipPns"));
			if (CommonUtil.isNullOrEmpty(atasan2.get("nipPns"))) {
				result.put("nipAtasan2", atasan2.get("nip"));
			}
		}
		if (CommonUtil.isNotNullOrEmpty(kaRu)) {
			result.put("kaRu", kaRu.get("nama"));
			result.put("jabatanKaRu", kaRu.get("jabatanInternal"));
			result.put("nipKaRu", kaRu.get("nipPns"));
			if (CommonUtil.isNullOrEmpty(kaRu.get("nipPns"))) {
				result.put("nipKaRu", kaRu.get("nip"));
			}
		}

		PlanningPegawaiStatus planningPegawaiStatus = planningPegawaiStatusDao.findOne(noRecPlanning);

		// Get data statistik seluruh pengajuan cuti
		List<Map<String, Object>> listDataCutiBesar = planningPegawaiStatusDao
				.getListPermohonanStatusByPegawaiAll(planningPegawaiStatus.getPegawai().getId(), "Cuti Besar");
		List<Map<String, Object>> listDataCutiSakit = planningPegawaiStatusDao
				.getListPermohonanStatusByPegawai(planningPegawaiStatus.getPegawai().getId(), "Sakit");
		List<Map<String, Object>> listDataCutiMelahirkan = planningPegawaiStatusDao
				.getListPermohonanStatusByPegawaiAll(planningPegawaiStatus.getPegawai().getId(), "Cuti Melahirkan");
		List<Map<String, Object>> listDataCutiAlasanPenting = planningPegawaiStatusDao
				.getListPermohonanStatusByPegawaiAll(planningPegawaiStatus.getPegawai().getId(), "Cuti Alasan Penting");
		if (CommonUtil.isNotNullOrEmpty(listDataCutiBesar)) {
			Integer sumCutiBesar = new Integer(listDataCutiBesar.size());
			result.put("cutiBesar", sumCutiBesar.toString());
		}
		if (CommonUtil.isNotNullOrEmpty(listDataCutiSakit)) {
			Integer sumSakit = new Integer(listDataCutiSakit.size());
			result.put("cutiSakit", sumSakit.toString());
		}
		if (CommonUtil.isNotNullOrEmpty(listDataCutiMelahirkan)) {
			Integer sumCutiMelahirkan = new Integer(listDataCutiMelahirkan.size());
			result.put("cutiMelahirkan", sumCutiMelahirkan.toString());
		}
		if (CommonUtil.isNotNullOrEmpty(listDataCutiAlasanPenting)) {
			Integer sumCutiAlasanPenting = new Integer(listDataCutiAlasanPenting.size());
			result.put("cutiAlasanPenting", sumCutiAlasanPenting.toString());
		}

		StatusPegawai statusPegawai = statusPegawaiDao.getAll(planningPegawaiStatus.getStatusPegawaiPlanId());

		if (CommonUtil.isNotNullOrEmpty(planningPegawaiStatus)) {
			result.put("statusPegawaiPlanId", planningPegawaiStatus.getStatusPegawaiPlanId().toString());
			if (CommonUtil.isNotNullOrEmpty(planningPegawaiStatus)
					&& (!statusPegawai.getStatusPegawai().equals("Cuti Besar")
							|| !statusPegawai.getStatusPegawai().equals("Cuti Melahirkan"))) {
				result.put("jumlahHari", planningPegawaiStatus.getJumlahHari().toString());
			}
			String tahun = new SimpleDateFormat("yyyy").format(planningPegawaiStatus.getTglPengajuan());
			result.put("tglPengajuan",
					"Jakarta, " + DateUtil.getIndonesianStringDate(planningPegawaiStatus.getTglPengajuan()));

			result.put("today", DateUtil.getIndonesianStringDate(new Date()));
			result.put("alasan", planningPegawaiStatus.getDeskripsiStatusPegawaiPlan());
			List<Map<String, Object>> listTgl = planningPegawaiStatusDao
					.getListTanggalCuti(planningPegawaiStatus.getNoRec());

			if (CommonUtil.isNotNullOrEmpty(listTgl) && (statusPegawai.getStatusPegawai().equals("Cuti Besar")
					|| statusPegawai.getStatusPegawai().equals("Cuti Melahirkan"))) {
				Date tglAwal = (Date) listTgl.get(0).get("tgl");
				Date tglAkhir = (Date) listTgl.get(listTgl.size() - 1).get("tgl");
				long diff = (tglAkhir.getTime() - tglAwal.getTime()) / 86400000;
				result.put("jumlahHari", Long.toString(diff));
			}

			String tgl = "";
			int i = 1;
			Boolean emptyEndDate = true;
			for (Map<String, Object> data : listTgl) {
				if (CommonUtil.isNotNullOrEmpty(listTgl) && (statusPegawai.getStatusPegawai().equals("Cuti Besar")
						|| statusPegawai.getStatusPegawai().equals("Cuti Melahirkan"))) {
					if (i == 1) {
						tgl += new SimpleDateFormat("dd-MM-yyyy").format(data.get("tgl"));
						result.put("startDate",
								new SimpleDateFormat("dd MMMM yyyy", new Locale("in", "ID")).format(data.get("tgl")));
					} else {
						tgl += " - " + new SimpleDateFormat("dd-MM-yyyy").format(data.get("tgl"));
						result.put("endDate",
								new SimpleDateFormat("dd MMMM yyyy", new Locale("in", "ID")).format(data.get("tgl")));
						emptyEndDate = false;
					}
				} else {
					if (i == 1) {
						tgl += new SimpleDateFormat("dd-MM-yyyy").format(data.get("tgl"));
						result.put("startDate",
								new SimpleDateFormat("dd MMMM yyyy", new Locale("in", "ID")).format(data.get("tgl")));
					} else {
						tgl += ", " + new SimpleDateFormat("dd-MM-yyyy").format(data.get("tgl"));
						result.put("endDate",
								new SimpleDateFormat("dd MMMM yyyy", new Locale("in", "ID")).format(data.get("tgl")));
						emptyEndDate = false;
					}
				}
				i++;
			}
			// result.put("endDate", tgl);
			if (emptyEndDate) {
				result.put("endDate", new String(""));
			}

			if (CommonUtil.isNotNullOrEmpty(planningPegawaiStatus.getPegawai())) {
				Map<String, Object> pegawai = pegawaiDao.findPegawaiById(planningPegawaiStatus.getPegawai().getId());
				Jabatan jabatan = jabatanDao.findOne(idJabatan);
				result.put("nama", pegawai.get("nama"));
				result.put("nip", pegawai.get("nipPns"));
				result.put("pangkat", pegawai.get("namaGolongan"));
				result.put("jabatan", jabatan.getNamaJabatan());
				result.put("departemen", pegawai.get("departemen"));
				result.put("alamat", planningPegawaiStatus.getAlamatCuti());
				result.put("idFinger", pegawai.get("idFinger"));
				result.put("noHandphone", planningPegawaiStatus.getNomorTelepon());
				result.put("unitKerja", pegawai.get("unitKerja"));
				result.put("tahun", pegawai.get("tahun"));
				Map<String, Object> cutiTahunan = permohonanStatusPegawaiService
						.getDataCuti(planningPegawaiStatus.getPegawai().getId(), null, 1);
				if (CommonUtil.isNotNullOrEmpty(cutiTahunan)) {
					result.put("cutiTerpakai", cutiTahunan.get("cutiTerpakai"));
					result.put("sisaCuti", cutiTahunan.get("sisaCuti"));
				}
			}
		}
		// permohonanStatusPegawaiService.updateDataCuti(idAtasan1+","+idAtasan2+","+idKaRu+"",
		// noRecPlanning);
		return result;
	}

	@Override
	public Map<String, Object> generateLapPermohonanCuti(String noRecPlanning, Integer idJabatan, Integer idUnitKerja,
			Integer idAtasan1, Integer idAtasan2, Integer idKaRu, Integer idJabatanAtasan1, Integer idJabatanAtasan2,
			String atasanDireksi) {
		Map<String, Object> result = new HashMap<String, Object>();
		// PegawaiHistoriRekapIndex pegawaiHistoriRekapIndex=
		// pegawaiHistoriRekapIndexDao.getPegawaiHistoriRekapIndex(noRecPlanning);

		LocalDateTime now = LocalDateTime.now();
		result.put("tahunIni", String.valueOf(now.getYear()));
		result.put("satuTahunLalu", String.valueOf(now.getYear() - 1));
		result.put("duaTahunLalu", String.valueOf(now.getYear() - 2));

		String labelTtdMenkes = "Menteri Kesehatan Republik Indonesia";
		String menteriKesehatan = settingDataFixedDao.getSettingDataFixed("menteriKesehatan");
		String nipMenkes = null;
		result.put("labelTtdMenkes", labelTtdMenkes);
		result.put("menteriKesehatan", menteriKesehatan);
		result.put("nipMenkes", nipMenkes);

		Map<String, Object> atasan1 = pegawaiDao.findPegawaiById(idAtasan1);
		Map<String, Object> atasan2 = pegawaiDao.findPegawaiById(idAtasan2);
		Map<String, Object> kaRu = pegawaiDao.findPegawaiById(idKaRu);
		Jabatan jabatanAtasan1 = pegawaiDao.findJabatanInternalByIdPegawai(idAtasan1, idJabatanAtasan1);
		Jabatan jabatanAtasan2 = pegawaiDao.findJabatanInternalByIdPegawai(idAtasan2, idJabatanAtasan2);
		if (CommonUtil.isNotNullOrEmpty(atasan1)) {
			result.put("namaAtasan1", atasan1.get("nama"));
			result.put("jabatanAtasan1", jabatanAtasan1.getNamaJabatan());
			result.put("nipAtasan1", atasan1.get("nipPns"));
			if (CommonUtil.isNullOrEmpty(atasan1.get("nipPns"))) {
				result.put("nipAtasan1", atasan1.get("nip"));
			}
		} else if (CommonUtil.isNotNullOrEmpty(atasanDireksi)) {
			result.put("namaAtasan1", atasanDireksi);
		}
		if (CommonUtil.isNotNullOrEmpty(atasan2)) {
			result.put("namaAtasan2", atasan2.get("nama"));
			result.put("jabatanAtasan2", jabatanAtasan2.getNamaJabatan());
			result.put("nipAtasan2", atasan2.get("nipPns"));
			if (CommonUtil.isNullOrEmpty(atasan2.get("nipPns"))) {
				result.put("nipAtasan2", atasan2.get("nip"));
			}
		}
		if (CommonUtil.isNotNullOrEmpty(kaRu)) {
			result.put("kaRu", kaRu.get("nama"));
			result.put("jabatanKaRu", kaRu.get("jabatanInternal"));
			result.put("nipKaRu", kaRu.get("nipPns"));
			if (CommonUtil.isNullOrEmpty(kaRu.get("nipPns"))) {
				result.put("nipKaRu", kaRu.get("nip"));
			}
		}

		PlanningPegawaiStatus planningPegawaiStatus = planningPegawaiStatusDao.findOne(noRecPlanning);
		Map<String, Object> pegawai = pegawaiDao.findPegawaiById(planningPegawaiStatus.getPegawai().getId());

		{
			Integer statusPegawaiId = planningPegawaiStatus.getStatusPegawaiPlanId();
			if (Master.StatusPegawai.CUTI_TAHUNAN == statusPegawaiId
					|| Master.StatusPegawai.CUTI_SAKIT == statusPegawaiId
					|| Master.StatusPegawai.CUTI_MELAHIRKAN == statusPegawaiId) {
				if (Arrays.asList(Master.GolonganPegawai.JF_AHLI_UTAMA).contains(pegawai.get("idGolongan"))) {
					String cutiA1 = settingDataFixedDao.getSettingDataFixed("cutiA1");
					String[] arrCutiA1 = cutiA1.split("_");
					labelTtdMenkes = arrCutiA1[0];
					menteriKesehatan = arrCutiA1[1];
					nipMenkes = arrCutiA1[2];

					result.put("labelTtdMenkes", labelTtdMenkes);
					result.put("menteriKesehatan", menteriKesehatan);
					result.put("nipMenkes", nipMenkes);
				} else {
					String cutiA1 = settingDataFixedDao.getSettingDataFixed("cutiA2");
					String[] arrCutiA1 = cutiA1.split("_");
					labelTtdMenkes = arrCutiA1[0];
					menteriKesehatan = arrCutiA1[1];
					nipMenkes = arrCutiA1[2];

					result.put("labelTtdMenkes", labelTtdMenkes);
					result.put("menteriKesehatan", menteriKesehatan);
					result.put("nipMenkes", nipMenkes);
				}
			} else if (Master.StatusPegawai.CUTI_BESAR == statusPegawaiId
					|| Master.StatusPegawai.CUTI_ALASAN_PENTING == statusPegawaiId) {
				if (Arrays.asList(Master.GolonganPegawai.JF_AHLI_UTAMA).contains(pegawai.get("idGolongan"))) {
					String cutiA1 = settingDataFixedDao.getSettingDataFixed("cutiB1");
					String[] arrCutiA1 = cutiA1.split("_");
					labelTtdMenkes = arrCutiA1[0];
					menteriKesehatan = arrCutiA1[1];
					nipMenkes = null;

					result.put("labelTtdMenkes", labelTtdMenkes);
					result.put("menteriKesehatan", menteriKesehatan);
					result.put("nipMenkes", nipMenkes);
				} else {
					String cutiA1 = settingDataFixedDao.getSettingDataFixed("cutiB2C");
					String[] arrCutiA1 = cutiA1.split("_");
					labelTtdMenkes = arrCutiA1[0];
					menteriKesehatan = arrCutiA1[1];
					nipMenkes = arrCutiA1[2];

					result.put("labelTtdMenkes", labelTtdMenkes);
					result.put("menteriKesehatan", menteriKesehatan);
					result.put("nipMenkes", nipMenkes);
				}
			}
		}

		// Get data statistik seluruh pengajuan cuti
		List<Map<String, Object>> listDataCutiBesar = planningPegawaiStatusDao
				.getListPermohonanStatusByPegawaiAll(planningPegawaiStatus.getPegawai().getId(), "Cuti Besar");
		List<Map<String, Object>> listDataCutiSakit = planningPegawaiStatusDao
				.getListPermohonanStatusByPegawai(planningPegawaiStatus.getPegawai().getId(), "Sakit");
		List<Map<String, Object>> listDataCutiMelahirkan = planningPegawaiStatusDao
				.getListPermohonanStatusByPegawaiAll(planningPegawaiStatus.getPegawai().getId(), "Cuti Melahirkan");
		List<Map<String, Object>> listDataCutiAlasanPenting = planningPegawaiStatusDao
				.getListPermohonanStatusByPegawaiAll(planningPegawaiStatus.getPegawai().getId(), "Cuti Alasan Penting");
		if (CommonUtil.isNotNullOrEmpty(listDataCutiBesar)) {
			Integer sumCutiBesar = new Integer(listDataCutiBesar.size());
			result.put("cutiBesar", sumCutiBesar.toString());
		}
		if (CommonUtil.isNotNullOrEmpty(listDataCutiSakit)) {
			Integer sumSakit = new Integer(listDataCutiSakit.size());
			result.put("cutiSakit", sumSakit.toString());
		}
		if (CommonUtil.isNotNullOrEmpty(listDataCutiMelahirkan)) {
			Integer sumCutiMelahirkan = new Integer(listDataCutiMelahirkan.size());
			result.put("cutiMelahirkan", sumCutiMelahirkan.toString());
		}
		if (CommonUtil.isNotNullOrEmpty(listDataCutiAlasanPenting)) {
			Integer sumCutiAlasanPenting = new Integer(listDataCutiAlasanPenting.size());
			result.put("cutiAlasanPenting", sumCutiAlasanPenting.toString());
		}

		StatusPegawai statusPegawai = statusPegawaiDao.getAll(planningPegawaiStatus.getStatusPegawaiPlanId());

		if (CommonUtil.isNotNullOrEmpty(planningPegawaiStatus)) {
			result.put("statusPegawaiPlanId", planningPegawaiStatus.getStatusPegawaiPlanId().toString());
			result.put("statusPegawai", statusPegawai.getStatusPegawai());
			if (CommonUtil.isNotNullOrEmpty(planningPegawaiStatus)
					&& (!statusPegawai.getStatusPegawai().equals("Cuti Besar")
							|| !statusPegawai.getStatusPegawai().equals("Cuti Melahirkan")
							|| !statusPegawai.getStatusPegawai().equals("Sakit"))) {
				result.put("jumlahHari", planningPegawaiStatus.getJumlahHari().toString());
			}
			String tahun = new SimpleDateFormat("yyyy").format(planningPegawaiStatus.getTglPengajuan());
			result.put("tglPengajuan",
					"Jakarta, " + DateUtil.getIndonesianStringDate(planningPegawaiStatus.getTglPengajuan()));

			result.put("today", DateUtil.getIndonesianStringDate(new Date()));
			result.put("alasan", planningPegawaiStatus.getDeskripsiStatusPegawaiPlan());
			result.put("isCutiLuarNegeri", planningPegawaiStatus.getIsCutiLuarNegeri());
			result.put("isCutiLuarKota", planningPegawaiStatus.getIsCutiLuarKota());
			List<Map<String, Object>> listTgl = planningPegawaiStatusDao
					.getListTanggalCuti(planningPegawaiStatus.getNoRec());

			if (CommonUtil.isNotNullOrEmpty(listTgl)
					&& (statusPegawai.getStatusPegawai().equals("Cuti Besar")
							|| statusPegawai.getStatusPegawai().equals("Cuti Melahirkan")
							|| statusPegawai.getStatusPegawai().equals("Sakit"))
					|| statusPegawai.getStatusPegawai().equals("Cuti Alasan Penting")) {
				Date tglAwal = (Date) listTgl.get(0).get("tgl");
				Date tglAkhir = (Date) listTgl.get(listTgl.size() - 1).get("tgl");
				long diff = (tglAkhir.getTime() - tglAwal.getTime()) / 86400000;
				result.put("jumlahHari", Long.toString(diff + 1));
			}

			String tgl = "";
			int i = 1;
			for (Map<String, Object> data : listTgl) {
				if (CommonUtil.isNotNullOrEmpty(listTgl)
						&& (statusPegawai.getStatusPegawai().equals("Cuti Besar")
								|| statusPegawai.getStatusPegawai().equals("Cuti Melahirkan")
								|| statusPegawai.getStatusPegawai().equals("Sakit"))
						|| statusPegawai.getStatusPegawai().equals("Cuti Alasan Penting")) {
					if (i == 1) {
						tgl += new SimpleDateFormat("dd-MM-yyyy").format(data.get("tgl"));
					} else {
						tgl += " s.d. " + new SimpleDateFormat("dd-MM-yyyy").format(data.get("tgl"));
					}
					i++;
				} else {
					if (i == 1) {
						tgl += new SimpleDateFormat("dd-MM-yyyy").format(data.get("tgl"));
						i++;
					} else {
						tgl += ", " + new SimpleDateFormat("dd-MM-yyyy").format(data.get("tgl"));
						i++;
					}
				}

			}
			result.put("listDate", tgl);
			if (CommonUtil.isNotNullOrEmpty(planningPegawaiStatus.getPegawai())) {
				if (CommonUtil.isNotNullOrEmpty(pegawai.get("tglMasuk"))) {
					result.put("masaKerja", pegawaiService.hitungMasaKerja((Date) pegawai.get("tglMasuk")));
					result.put("tglMasuk", new SimpleDateFormat("dd MMMM yyyy", new Locale("id"))
							.format((Date) pegawai.get("tglMasuk")));
				} else {
					result.put("masaKerja", "-");
					result.put("tglMasuk", "");
				}
				Jabatan jabatan = jabatanDao.findOne(idJabatan);
				UnitKerjaPegawai unitKerja = unitKerjaDao.findOne(idUnitKerja);
				result.put("nama", pegawai.get("nama"));
				result.put("nip", pegawai.get("nipPns"));
				result.put("pangkat", pegawai.get("namaGolongan"));
				if (CommonUtil.isNotNullOrEmpty(pegawai.get("namaPangkat"))
						&& CommonUtil.isNotNullOrEmpty(pegawai.get("namaGolongan"))) {
					result.put("pangkatGol", pegawai.get("namaPangkat") + "/ " + pegawai.get("namaGolongan"));
				}
				result.put("jabatan", jabatan.getNamaJabatan());
				result.put("departemen", pegawai.get("departemen"));
				result.put("alamat", planningPegawaiStatus.getAlamatCuti());
				result.put("idFinger", pegawai.get("idFinger"));
				result.put("noHandphone", planningPegawaiStatus.getNomorTelepon());
				result.put("unitKerja", unitKerja.getName());
				result.put("tahun", pegawai.get("tahun"));
				Map<String, Object> cutiTahunan = permohonanStatusPegawaiService
						.getDataCuti(planningPegawaiStatus.getPegawai().getId(), null, 1);
				if (CommonUtil.isNotNullOrEmpty(cutiTahunan)) {
					result.put("cutiTerpakai", cutiTahunan.get("cutiTerpakaiN"));
					result.put("sisaCuti", cutiTahunan.get("sisaCutiN"));
					result.put("cutiTerpakaiN1", cutiTahunan.get("cutiTerpakaiN1"));
					result.put("sisaCutiN1", cutiTahunan.get("sisaCutiN1"));
					result.put("cutiTerpakaiN2", cutiTahunan.get("cutiTerpakaiN2"));
					result.put("sisaCutiN2", cutiTahunan.get("sisaCutiN2"));
					result.put("cutiTerpakaiB", cutiTahunan.get("cutiTerpakaiB"));
					result.put("sisaCutiB", cutiTahunan.get("sisaCutiB"));
				}
			}
		}
		// permohonanStatusPegawaiService.updateDataCuti(idAtasan1+","+idAtasan2+","+idKaRu+"",
		// noRecPlanning);
		return result;
	}

	@Override
	public Map<String, Object> generateLapPermohonanCuti(String noRecPlanning, String atasan1, String nipPnsAtasan1,
			String jabatanAtasan1, String atasan2, String nipPnsAtasan2, String jabatanAtasan2, Integer idKaRu) {
		Map<String, Object> result = new HashMap<String, Object>();

		String labelTtdMenkes = "Menteri Kesehatan Republik Indonesia";
		String menteriKesehatan = settingDataFixedDao.getSettingDataFixed("menteriKesehatan");
		String nipMenkes = null;
		result.put("labelTtdMenkes", labelTtdMenkes);
		result.put("menteriKesehatan", menteriKesehatan);
		result.put("nipMenkes", nipMenkes);

		// Map<String, Object> atasan1 = pegawaiDao.findPegawaiById(idAtasan1);
		// Map<String, Object> atasan2 = pegawaiDao.findPegawaiById(idAtasan2);
		Map<String, Object> kaRu = pegawaiDao.findPegawaiById(idKaRu);
		// Jabatan jabatanAtasan1 =
		// pegawaiDao.findJabatanInternalByIdPegawai(idAtasan1,
		// idJabatanAtasan1);
		// Jabatan jabatanAtasan2 =
		// pegawaiDao.findJabatanInternalByIdPegawai(idAtasan2,
		// idJabatanAtasan2);
		if (CommonUtil.isNotNullOrEmpty(atasan1)) {
			result.put("namaAtasan1", atasan1);
			result.put("jabatanAtasan1", jabatanAtasan1);
			result.put("nipAtasan1", nipPnsAtasan1);
			// if (CommonUtil.isNullOrEmpty(nipPnsAtasan1)) {
			// result.put("nipAtasan1", nipAtasan1);
			// }
		}
		if (CommonUtil.isNotNullOrEmpty(atasan2)) {
			result.put("namaAtasan2", atasan2);
			result.put("jabatanAtasan2", jabatanAtasan2);
			result.put("nipAtasan2", nipPnsAtasan2);
			// if (CommonUtil.isNullOrEmpty(nipPnsAtasan2)) {
			// result.put("nipAtasan2", nipAtasan2);
			// }
		}
		if (CommonUtil.isNotNullOrEmpty(kaRu)) {
			result.put("kaRu", kaRu.get("nama"));
			result.put("jabatanKaRu", kaRu.get("jabatanInternal"));
			result.put("nipKaRu", kaRu.get("nipPns"));
			if (CommonUtil.isNullOrEmpty(kaRu.get("nipPns"))) {
				result.put("nipKaRu", kaRu.get("nip"));
			}
		}

		PlanningPegawaiStatus planningPegawaiStatus = planningPegawaiStatusDao.findOne(noRecPlanning);
		Map<String, Object> pegawai = pegawaiDao.findPegawaiById(planningPegawaiStatus.getPegawai().getId());

		{
			Integer statusPegawaiId = planningPegawaiStatus.getStatusPegawaiExec().getId();
			if (Master.StatusPegawai.CUTI_TAHUNAN == statusPegawaiId
					|| Master.StatusPegawai.CUTI_SAKIT == statusPegawaiId
					|| Master.StatusPegawai.CUTI_MELAHIRKAN == statusPegawaiId) {
				if (Arrays.asList(Master.GolonganPegawai.JF_AHLI_UTAMA).contains(pegawai.get("idGolongan"))) {
					String cutiA1 = settingDataFixedDao.getSettingDataFixed("cutiA1");
					String[] arrCutiA1 = cutiA1.split("_");
					labelTtdMenkes = arrCutiA1[0];
					menteriKesehatan = arrCutiA1[1];
					nipMenkes = arrCutiA1[2];

					result.put("labelTtdMenkes", labelTtdMenkes);
					result.put("menteriKesehatan", menteriKesehatan);
					result.put("nipMenkes", nipMenkes);
				} else {
					String cutiA1 = settingDataFixedDao.getSettingDataFixed("cutiA2");
					String[] arrCutiA1 = cutiA1.split("_");
					labelTtdMenkes = arrCutiA1[0];
					menteriKesehatan = arrCutiA1[1];
					nipMenkes = arrCutiA1[2];

					result.put("labelTtdMenkes", labelTtdMenkes);
					result.put("menteriKesehatan", menteriKesehatan);
					result.put("nipMenkes", nipMenkes);
				}
			} else if (Master.StatusPegawai.CUTI_BESAR == statusPegawaiId
					|| Master.StatusPegawai.CUTI_ALASAN_PENTING == statusPegawaiId) {
				if (Arrays.asList(Master.GolonganPegawai.JF_AHLI_UTAMA).contains(pegawai.get("idGolongan"))) {
					String cutiA1 = settingDataFixedDao.getSettingDataFixed("cutiB1");
					String[] arrCutiA1 = cutiA1.split("_");
					labelTtdMenkes = arrCutiA1[0];
					menteriKesehatan = arrCutiA1[1];
					nipMenkes = null;

					result.put("labelTtdMenkes", labelTtdMenkes);
					result.put("menteriKesehatan", menteriKesehatan);
					result.put("nipMenkes", nipMenkes);
				} else {
					String cutiA1 = settingDataFixedDao.getSettingDataFixed("cutiB2C");
					String[] arrCutiA1 = cutiA1.split("_");
					labelTtdMenkes = arrCutiA1[0];
					menteriKesehatan = arrCutiA1[1];
					nipMenkes = arrCutiA1[2];

					result.put("labelTtdMenkes", labelTtdMenkes);
					result.put("menteriKesehatan", menteriKesehatan);
					result.put("nipMenkes", nipMenkes);
				}
			}
		}

		// Get data statistik seluruh pengajuan cuti
		List<Map<String, Object>> listDataCutiBesar = planningPegawaiStatusDao
				.getListPermohonanStatusByPegawaiAll(planningPegawaiStatus.getPegawai().getId(), "Cuti Besar");
		List<Map<String, Object>> listDataCutiSakit = planningPegawaiStatusDao
				.getListPermohonanStatusByPegawai(planningPegawaiStatus.getPegawai().getId(), "Sakit");
		List<Map<String, Object>> listDataCutiMelahirkan = planningPegawaiStatusDao
				.getListPermohonanStatusByPegawaiAll(planningPegawaiStatus.getPegawai().getId(), "Cuti Melahirkan");
		List<Map<String, Object>> listDataCutiAlasanPenting = planningPegawaiStatusDao
				.getListPermohonanStatusByPegawaiAll(planningPegawaiStatus.getPegawai().getId(), "Cuti Alasan Penting");
		if (CommonUtil.isNotNullOrEmpty(listDataCutiBesar)) {
			Integer sumCutiBesar = new Integer(listDataCutiBesar.size());
			result.put("cutiBesar", sumCutiBesar.toString());
		}
		if (CommonUtil.isNotNullOrEmpty(listDataCutiSakit)) {
			Integer sumSakit = new Integer(listDataCutiSakit.size());
			result.put("cutiSakit", sumSakit.toString());
		}
		if (CommonUtil.isNotNullOrEmpty(listDataCutiMelahirkan)) {
			Integer sumCutiMelahirkan = new Integer(listDataCutiMelahirkan.size());
			result.put("cutiMelahirkan", sumCutiMelahirkan.toString());
		}
		if (CommonUtil.isNotNullOrEmpty(listDataCutiAlasanPenting)) {
			Integer sumCutiAlasanPenting = new Integer(listDataCutiAlasanPenting.size());
			result.put("cutiAlasanPenting", sumCutiAlasanPenting.toString());
		}

		StatusPegawai statusPegawai = statusPegawaiDao.getAll(planningPegawaiStatus.getStatusPegawaiPlanId());

		if (CommonUtil.isNotNullOrEmpty(planningPegawaiStatus)) {
			result.put("statusPegawaiPlanId", planningPegawaiStatus.getStatusPegawaiPlanId().toString());
			if (CommonUtil.isNotNullOrEmpty(planningPegawaiStatus)
					&& (!statusPegawai.getStatusPegawai().equals("Cuti Besar")
							|| !statusPegawai.getStatusPegawai().equals("Cuti Melahirkan")
							|| !statusPegawai.getStatusPegawai().equals("Sakit"))) {
				result.put("jumlahHari", planningPegawaiStatus.getJumlahHari().toString());
			}
			String tahun = new SimpleDateFormat("yyyy").format(planningPegawaiStatus.getTglPengajuan());
			result.put("tglPengajuan",
					"Jakarta, " + DateUtil.getIndonesianStringDate(planningPegawaiStatus.getTglPengajuan()));

			result.put("today", DateUtil.getIndonesianStringDate(new Date()));
			result.put("alasan", planningPegawaiStatus.getDeskripsiStatusPegawaiPlan());
			result.put("isCutiLuarNegeri", planningPegawaiStatus.getIsCutiLuarNegeri());
			result.put("isCutiLuarKota", planningPegawaiStatus.getIsCutiLuarKota());
			List<Map<String, Object>> listTgl = planningPegawaiStatusDao
					.getListTanggalCuti(planningPegawaiStatus.getNoRec());

			if (CommonUtil.isNotNullOrEmpty(listTgl) && (statusPegawai.getStatusPegawai().equals("Cuti Besar")
					|| statusPegawai.getStatusPegawai().equals("Cuti Melahirkan")
					|| statusPegawai.getStatusPegawai().equals("Sakit"))) {
				Date tglAwal = (Date) listTgl.get(0).get("tgl");
				Date tglAkhir = (Date) listTgl.get(listTgl.size() - 1).get("tgl");
				long diff = (tglAkhir.getTime() - tglAwal.getTime()) / 86400000;
				result.put("jumlahHari", Long.toString(diff + 1));
			}

			String tgl = "";
			int i = 1;
			for (Map<String, Object> data : listTgl) {
				if (CommonUtil.isNotNullOrEmpty(listTgl) && (statusPegawai.getStatusPegawai().equals("Cuti Besar")
						|| statusPegawai.getStatusPegawai().equals("Cuti Melahirkan")
						|| statusPegawai.getStatusPegawai().equals("Sakit"))) {
					if (i == 1) {
						tgl += new SimpleDateFormat("dd-MM-yyyy").format(data.get("tgl"));
					} else {
						tgl += " - " + new SimpleDateFormat("dd-MM-yyyy").format(data.get("tgl"));
					}
					i++;
				} else {
					if (i == 1) {
						tgl += new SimpleDateFormat("dd-MM-yyyy").format(data.get("tgl"));
						i++;
					} else {
						tgl += ", " + new SimpleDateFormat("dd-MM-yyyy").format(data.get("tgl"));
						i++;
					}
				}

			}
			result.put("listDate", tgl);
			if (CommonUtil.isNotNullOrEmpty(planningPegawaiStatus.getPegawai())) {
				result.put("nama", pegawai.get("nama"));
				result.put("nip", pegawai.get("nipPns"));
				result.put("pangkat", pegawai.get("namaGolongan"));
				result.put("jabatan", pegawai.get("jabatanInternal"));
				result.put("departemen", pegawai.get("departemen"));
				result.put("alamat", planningPegawaiStatus.getAlamatCuti());
				result.put("idFinger", pegawai.get("idFinger"));
				result.put("noHandphone", planningPegawaiStatus.getNomorTelepon());
				result.put("unitKerja", pegawai.get("unitKerja"));
				result.put("tahun", pegawai.get("tahun"));
				Map<String, Object> cutiTahunan = permohonanStatusPegawaiService
						.getDataCuti(planningPegawaiStatus.getPegawai().getId(), null, 1);
				if (CommonUtil.isNotNullOrEmpty(cutiTahunan)) {
					result.put("cutiTerpakai", cutiTahunan.get("cutiTerpakaiN"));
					result.put("sisaCuti", cutiTahunan.get("sisaCutiN"));
					result.put("cutiTerpakaiN1", cutiTahunan.get("cutiTerpakaiN1"));
					result.put("sisaCutiN1", cutiTahunan.get("sisaCutiN1"));
					result.put("cutiTerpakaiN2", cutiTahunan.get("cutiTerpakaiN2"));
					result.put("sisaCutiN2", cutiTahunan.get("sisaCutiN2"));
					result.put("cutiTerpakaiB", cutiTahunan.get("cutiTerpakaiB"));
					result.put("sisaCutiB", cutiTahunan.get("sisaCutiB"));
				}
			}
		}
		// permohonanStatusPegawaiService.updateDataCuti(idAtasan1+","+idAtasan2+","+idKaRu+"",
		// noRecPlanning);
		return result;
	}

	@Override
	public Map<String, Object> generateSuratIzinSementara(String noRecPlanning, Integer idJabatan, Integer idUnitKerja,
			Integer idAtasan1, Integer idAtasan2, Integer idKaRu, Integer idJabatanAtasan1, Integer idJabatanAtasan2) {
		Map<String, Object> result = new HashMap<String, Object>();
		// PegawaiHistoriRekapIndex pegawaiHistoriRekapIndex=
		// pegawaiHistoriRekapIndexDao.getPegawaiHistoriRekapIndex(noRecPlanning);
		Map<String, Object> atasan1 = pegawaiDao.findPegawaiById(idAtasan1);
		Map<String, Object> atasan2 = pegawaiDao.findPegawaiById(idAtasan2);
		Map<String, Object> kaRu = pegawaiDao.findPegawaiById(idKaRu);
		Jabatan jabatanAtasan1 = pegawaiDao.findJabatanInternalByIdPegawai(idAtasan1, idJabatanAtasan1);
		Jabatan jabatanAtasan2 = pegawaiDao.findJabatanInternalByIdPegawai(idAtasan2, idJabatanAtasan2);
		if (CommonUtil.isNotNullOrEmpty(atasan1) && CommonUtil.isNotNullOrEmpty(jabatanAtasan1)) {
			result.put("namaAtasan", atasan1.get("nama"));
			result.put("jabatanAtasan", jabatanAtasan1.getNamaJabatan());
			result.put("nipAtasan", atasan1.get("nipPns"));
			if (CommonUtil.isNullOrEmpty(atasan1.get("nipPns"))) {
				result.put("nipAtasan", atasan1.get("nip"));
			}
		}
		if (CommonUtil.isNotNullOrEmpty(atasan2) && CommonUtil.isNotNullOrEmpty(jabatanAtasan2)) {
			result.put("namaAtasan", atasan2.get("nama"));
			result.put("jabatanAtasan", jabatanAtasan2.getNamaJabatan());
			result.put("nipAtasan", atasan2.get("nipPns"));
			if (CommonUtil.isNullOrEmpty(atasan2.get("nipPns"))) {
				result.put("nipAtasan", atasan2.get("nip"));
			}
		}
		if (CommonUtil.isNotNullOrEmpty(kaRu)) {
			result.put("kaRu", kaRu.get("nama"));
			result.put("jabatanKaRu", kaRu.get("jabatanInternal"));
			result.put("nipKaRu", kaRu.get("nipPns"));
			if (CommonUtil.isNullOrEmpty(kaRu.get("nipPns"))) {
				result.put("nipKaRu", kaRu.get("nip"));
			}
		}

		PlanningPegawaiStatus planningPegawaiStatus = planningPegawaiStatusDao.findOne(noRecPlanning);

		// Get data statistik seluruh pengajuan cuti
		List<Map<String, Object>> listDataCutiAlasanPenting = planningPegawaiStatusDao
				.getListPermohonanStatusByPegawaiAll(planningPegawaiStatus.getPegawai().getId(), "Cuti Alasan Penting");
		if (CommonUtil.isNotNullOrEmpty(listDataCutiAlasanPenting)) {
			Integer sumCutiAlasanPenting = new Integer(listDataCutiAlasanPenting.size());
			result.put("cutiAlasanPenting", sumCutiAlasanPenting.toString());
		}

		StatusPegawai statusPegawai = statusPegawaiDao.getAll(planningPegawaiStatus.getStatusPegawaiPlanId());

		if (CommonUtil.isNotNullOrEmpty(planningPegawaiStatus)) {
			result.put("statusPegawaiPlanId", planningPegawaiStatus.getStatusPegawaiPlanId().toString());
			String tahun = new SimpleDateFormat("yyyy").format(planningPegawaiStatus.getTglPengajuan());
			result.put("tglPengajuan",
					"Jakarta, " + DateUtil.getIndonesianStringDate(planningPegawaiStatus.getTglPengajuan()));

			result.put("today", DateUtil.getIndonesianStringDate(new Date()));
			result.put("alasan", planningPegawaiStatus.getDeskripsiStatusPegawaiPlan());
			List<Map<String, Object>> listTgl = planningPegawaiStatusDao
					.getListTanggalCuti(planningPegawaiStatus.getNoRec());

			String tgl = "";
			int i = 0;
			for (Map<String, Object> data : listTgl) {
				if (i == 0) {
					tgl = new SimpleDateFormat("dd MMMM yyyy", new Locale("in", "ID")).format(data.get("tgl"));
					result.put("startDate", tgl);
					i++;
				} else {
					tgl = new SimpleDateFormat("dd MMMM yyyy", new Locale("in", "ID")).format(data.get("tgl"));
					i++;
				}
			}

			if (listTgl.size() == 2) {
				if (new SimpleDateFormat("dd MMMM yyyy", new Locale("in", "ID")).format(listTgl.get(0).get("tgl"))
						.equals(new SimpleDateFormat("dd MMMM yyyy", new Locale("in", "ID"))
								.format(listTgl.get(1).get("tgl")))) {
					result.put("jumlahHari", "1");
				} else {
					long diff = (((Date) listTgl.get(1).get("tgl")).getTime()
							- ((Date) listTgl.get(0).get("tgl")).getTime()) / 86400000;
					result.put("jumlahHari", Long.toString(diff + 1));
				}
			}

			result.put("endDate", tgl);
			result.put("listDate", tgl);
			if (CommonUtil.isNotNullOrEmpty(planningPegawaiStatus.getPegawai())) {
				Map<String, Object> pegawai = pegawaiDao.findPegawaiById(planningPegawaiStatus.getPegawai().getId());
				Jabatan jabatan = jabatanDao.findOne(idJabatan);
				UnitKerjaPegawai unitKerja = unitKerjaDao.findOne(idUnitKerja);
				result.put("namaPegawai", pegawai.get("nama"));
				result.put("nipPegawai", pegawai.get("nipPns"));
				result.put("namaPangkatGolongan", pegawai.get("namaGolongan"));
				result.put("namaJabatan", jabatan.getNamaJabatan());
				result.put("departemen", pegawai.get("departemen"));
				result.put("alamat", planningPegawaiStatus.getAlamatCuti());
				result.put("idFinger", pegawai.get("idFinger"));
				result.put("noHandphone", planningPegawaiStatus.getNomorTelepon());
				result.put("unitKerja", unitKerja.getName());
				result.put("tahun", pegawai.get("tahun"));
				Map<String, Object> cutiTahunan = permohonanStatusPegawaiService
						.getDataCuti(planningPegawaiStatus.getPegawai().getId(), null, 1);
				if (CommonUtil.isNotNullOrEmpty(cutiTahunan)) {
					result.put("cutiTerpakai", cutiTahunan.get("cutiTerpakai"));
					result.put("sisaCuti", cutiTahunan.get("sisaCuti"));
				}
			}
		}
		return result;
	}

	@Override
	public Map<String, Object> generateSuratIzinSementara(String noRecPlanning, Integer idJabatan, Integer idUnitKerja,
			Integer idAtasan1, Integer idJabatanAtasan1) {
		Map<String, Object> result = new HashMap<String, Object>();

		Map<String, Object> atasan1 = pegawaiDao.findPegawaiById(idAtasan1);
		Jabatan jabatanAtasan1 = pegawaiDao.findJabatanInternalByIdPegawai(idAtasan1, idJabatanAtasan1);
		if (CommonUtil.isNotNullOrEmpty(atasan1)) {
			result.put("namaAtasan", atasan1.get("nama"));
			result.put("jabatanAtasan", jabatanAtasan1.getNamaJabatan());
			result.put("nipAtasan", atasan1.get("nipPns"));
			if (CommonUtil.isNullOrEmpty(atasan1.get("nipPns"))) {
				result.put("nipAtasan1", atasan1.get("nip"));
			}
		}

		PlanningPegawaiStatus planningPegawaiStatus = planningPegawaiStatusDao.findOne(noRecPlanning);
		StatusPegawai statusPegawai = statusPegawaiDao.getAll(planningPegawaiStatus.getStatusPegawaiPlanId());
		String nomorSurat = settingDataFixedDao.getSettingDataFixed("nomorSuratIzinSementaraCuti");

		if (CommonUtil.isNotNullOrEmpty(planningPegawaiStatus)) {
			String tahun = new SimpleDateFormat("yyyy").format(planningPegawaiStatus.getTglPengajuan());
			List<Map<String, Object>> listTgl = planningPegawaiStatusDao
					.getListTanggalCuti(planningPegawaiStatus.getNoRec());

			String tgl = "";
			int i = 0;
			for (Map<String, Object> data : listTgl) {
				if (i == 0) {
					tgl = new SimpleDateFormat("dd MMMM yyyy", new Locale("in", "ID")).format(data.get("tgl"));
					result.put("startDate", tgl);
					i++;
				} else {
					tgl = new SimpleDateFormat("dd MMMM yyyy", new Locale("in", "ID")).format(data.get("tgl"));
					i++;
				}
			}
			result.put("jumlahHari", i);
			result.put("endDate", tgl);

			if (CommonUtil.isNotNullOrEmpty(planningPegawaiStatus.getPegawai())) {
				Map<String, Object> pegawai = pegawaiDao.findPegawaiById(planningPegawaiStatus.getPegawai().getId());
				Jabatan jabatan = jabatanDao.findOne(idJabatan);
				UnitKerjaPegawai unitKerja = unitKerjaDao.findOne(idUnitKerja);
				result.put("namaPegawai", pegawai.get("nama"));
				result.put("nipPegawai", pegawai.get("nipPns"));
				if (CommonUtil.isNotNullOrEmpty(pegawai.get("namaPangkat"))
						&& CommonUtil.isNotNullOrEmpty(pegawai.get("namaGolongan"))) {
					result.put("namaPangkatGolongan",
							pegawai.get("namaPangkat").toString() + "/ " + pegawai.get("namaGolongan").toString());
				} else {
					result.put("namaPangkatGolongan", "-/ -");
				}
				result.put("namaJabatan", jabatan.getNamaJabatan());
				result.put("unitKerja", unitKerja.getName());
				if (CommonUtil.isNotNullOrEmpty(statusPegawai)) {
					result.put("jenisCuti", statusPegawai.getStatusPegawai());
				}
				result.put("nomorSurat", nomorSurat);
			}
		}
		return result;
	}

	@Override
	public Map<String, Object> generateSuratTugas(String noRecPlanning, Integer idJabatan, Integer idUnitKerja,
			Integer idAtasan1, Integer idAtasan2, Integer idKaRu, Integer idJabatanAtasan1, Integer idJabatanAtasan2) {
		Map<String, Object> result = new HashMap<String, Object>();
		Map<String, Object> atasan1 = pegawaiDao.findPegawaiById(idAtasan1);
		Map<String, Object> atasan2 = pegawaiDao.findPegawaiById(idAtasan2);
		Map<String, Object> kaRu = pegawaiDao.findPegawaiById(idKaRu);
		Jabatan jabatanAtasan1 = pegawaiDao.findJabatanInternalByIdPegawai(idAtasan1, idJabatanAtasan1);
		Jabatan jabatanAtasan2 = pegawaiDao.findJabatanInternalByIdPegawai(idAtasan2, idJabatanAtasan2);
		if (CommonUtil.isNotNullOrEmpty(atasan1)) {
			result.put("namaAtasan", atasan1.get("nama"));
			result.put("jabatanAtasan", jabatanAtasan1.getNamaJabatan());
			result.put("nipAtasan", atasan1.get("nipPns"));
			if (CommonUtil.isNullOrEmpty(atasan1.get("nipPns"))) {
				result.put("nipAtasan1", atasan1.get("nip"));
			}
		}
		if (CommonUtil.isNotNullOrEmpty(atasan2)) {
			result.put("namaAtasan2", atasan2.get("nama"));
			result.put("jabatanAtasan2", jabatanAtasan2.getNamaJabatan());
			result.put("nipAtasan2", atasan2.get("nipPns"));
			if (CommonUtil.isNullOrEmpty(atasan2.get("nipPns"))) {
				result.put("nipAtasan2", atasan2.get("nip"));
			}
		}
		if (CommonUtil.isNotNullOrEmpty(kaRu)) {
			result.put("kaRu", kaRu.get("nama"));
			result.put("jabatanKaRu", kaRu.get("jabatanInternal"));
			result.put("nipKaRu", kaRu.get("nipPns"));
			if (CommonUtil.isNullOrEmpty(kaRu.get("nipPns"))) {
				result.put("nipKaRu", kaRu.get("nip"));
			}
		}

		PlanningPegawaiStatus planningPegawaiStatus = planningPegawaiStatusDao.findOne(noRecPlanning);

		// Get data statistik seluruh pengajuan cuti
		List<Map<String, Object>> listTugasLuar = planningPegawaiStatusDao
				.getListPermohonanStatusByPegawaiAll(planningPegawaiStatus.getPegawai().getId(), "Tugas Luar");
		if (CommonUtil.isNotNullOrEmpty(listTugasLuar)) {
			Integer sumTugasLuar = new Integer(listTugasLuar.size());
			result.put("tugasLuar", sumTugasLuar.toString());
		}

		StatusPegawai statusPegawai = statusPegawaiDao.getAll(planningPegawaiStatus.getStatusPegawaiPlanId());

		if (CommonUtil.isNotNullOrEmpty(planningPegawaiStatus)) {
			result.put("statusPegawaiPlanId", planningPegawaiStatus.getStatusPegawaiPlanId().toString());
			String tahun = new SimpleDateFormat("yyyy").format(planningPegawaiStatus.getTglPengajuan());
			result.put("tglPengajuan",
					"Jakarta, " + DateUtil.getIndonesianStringDate(planningPegawaiStatus.getTglPengajuan()));

			result.put("today", DateUtil.getIndonesianStringDate(new Date()));
			result.put("alasan", planningPegawaiStatus.getDeskripsiStatusPegawaiPlan());
			result.put("noSuratTugas", planningPegawaiStatus.getNoSuratTugas().toString());
			result.put("noNotaDinas", planningPegawaiStatus.getNoNotaDinas().toString());
			result.put("tglNotaDinas", DateUtil.getIndonesianStringDate(planningPegawaiStatus.getTglNotaDinas()));
			Map<String, Object> pemberiNotaDinas = jabatanDao
					.getJabatanById(planningPegawaiStatus.getJabatanIdPemberiNotaDinas());
			result.put("idJabatanPemberiNotaDinas", (Integer) pemberiNotaDinas.get("id"));
			result.put("jabatanPemberiNotaDinas", pemberiNotaDinas.get("namaJabatan").toString());
			result.put("alamatTugas", planningPegawaiStatus.getAlamatTugas().toString());
			List<Map<String, Object>> listTgl = planningPegawaiStatusDao
					.getListTanggalCuti(planningPegawaiStatus.getNoRec());

			String tgl1 = "";
			String tgl2 = "";
			int i = 1;
			for (Map<String, Object> data : listTgl) {
				if (i == 1) {
					tgl1 = new SimpleDateFormat("dd", new Locale("in", "ID")).format(data.get("tgl"));
					i++;
				} else {
					tgl2 = new SimpleDateFormat("dd MMMM yyyy", new Locale("in", "ID")).format(data.get("tgl"));
					i++;
				}
			}
			result.put("jumlahHari", i);
			result.put("endDate", tgl2);
			result.put("listDate", tgl1 + " - " + tgl2);
			if (CommonUtil.isNotNullOrEmpty(planningPegawaiStatus.getPegawai())) {
				Map<String, Object> pegawai = pegawaiDao.findPegawaiById(planningPegawaiStatus.getPegawai().getId());
				Jabatan jabatan = jabatanDao.findOne(idJabatan);
				UnitKerjaPegawai unitKerja = unitKerjaDao.findOne(idUnitKerja);
				result.put("namaPegawai", pegawai.get("nama"));
				result.put("nipPegawai", pegawai.get("nipPns"));
				result.put("namaPangkatGolongan", pegawai.get("namaGolongan"));
				result.put("namaJabatan", jabatan.getNamaJabatan());
				result.put("departemen", pegawai.get("departemen"));
				result.put("alamat", planningPegawaiStatus.getAlamatCuti());
				result.put("idFinger", pegawai.get("idFinger"));
				result.put("noHandphone", planningPegawaiStatus.getNomorTelepon());
				result.put("unitKerja", unitKerja.getName());
				result.put("tahun", pegawai.get("tahun"));
				Map<String, Object> cutiTahunan = permohonanStatusPegawaiService
						.getDataCuti(planningPegawaiStatus.getPegawai().getId(), null, 1);
				if (CommonUtil.isNotNullOrEmpty(cutiTahunan)) {
					result.put("cutiTerpakai", cutiTahunan.get("cutiTerpakai"));
					result.put("sisaCuti", cutiTahunan.get("sisaCuti"));
				}
			}
		}
		return result;
	}

	@Override
	public Map<String, Object> generateLapSuratIzinCuti(String noRecPlanning, Integer idJabatan, Integer atasanId,
			Integer jabatanAtasanId) {
		Map<String, Object> result = new HashMap<String, Object>();

		PlanningPegawaiStatus planningPegawaiStatus = planningPegawaiStatusDao.findOne(noRecPlanning);

		List<Map<String, Object>> listTgl = null;
		if (CommonUtil.isNotNullOrEmpty(planningPegawaiStatus)) {
			Integer idAtasan1 = 0;
			Integer idAtasan2 = 0;
			Integer kaRu = 0;
			Map<String, Object> dataCuti = this.generateLapPermohonanCuti(noRecPlanning, idJabatan, idAtasan1,
					idAtasan2, kaRu);
			result.putAll(dataCuti);
		}
		PegawaiHistoriRekapIndex pegawaiHistoriRekapIndex = pegawaiHistoriRekapIndexDao
				.getPegawaiHistoriRekapIndex(noRecPlanning);

		if (CommonUtil.isNotNullOrEmpty(pegawaiHistoriRekapIndex)) {
			result.put("jumlahHari", pegawaiHistoriRekapIndex.getNilaiIndex().toString());
		}

		if (CommonUtil.isNotNullOrEmpty(atasanId) && CommonUtil.isNotNullOrEmpty(jabatanAtasanId)) {
			Map<String, Object> atasan = pegawaiDao.findPegawaiById(atasanId, jabatanAtasanId);
			result.put("namaAtasan", atasan.get("nama"));
			result.put("nipAtasan", atasan.get("nipPns"));
			result.put("jabatanAtasan", atasan.get("jabatanInternal"));
		}
		return result;
	}

	@Override
	public Map<String, Object> generateLapPelayanan(String startDate, String endDate, Integer idproduk,
			Integer idRuangan, Integer jenisPasien) {
		String departementRawatJalan = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRawatJalan");
		String departementGawatDarurat = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiGawatDarurat");
		List<Integer> idDep = new ArrayList<Integer>();
		idDep.add(Integer.valueOf(departementRawatJalan));
		idDep.add(Integer.valueOf(departementGawatDarurat));
		List<Map<String, Object>> datass = reportPelayananDaoCustom.getPelayananPasien(startDate.substring(0, 10),
				endDate.substring(0, 10), idproduk, idDep, idRuangan, jenisPasien);
		List<Map<String, Object>> datas = filterTimeStamp(datass, startDate, endDate);
		Map<String, Object> result = new HashMap<String, Object>();
		List<Map<String, Object>> listData = new ArrayList<Map<String, Object>>();
		Double totalAll = 0.0;
		for (Map<String, Object> data : datas) {
			if (CommonUtil.isNotNullOrEmpty(data.get("harga")) && CommonUtil.isNotNullOrEmpty(data.get("count"))) {
				Double count = ((Long) data.get("count")).doubleValue();
				Double total = count * (Double) data.get("harga");
				data.put("total", CurrencyUtil.getPriceInINA(total));
				data.put("harga", CurrencyUtil.getPriceInINA((Double) data.get("harga")));
				totalAll += total;
			} else {
				data.put("total", CurrencyUtil.getPriceInINA(0.0));
				data.put("harga", CurrencyUtil.getPriceInINA(0.0));
			}
			listData.add(data);
		}
		result.put("listData", listData);
		result.put("totalAll", CurrencyUtil.getPriceInINA(totalAll));
		return result;
	}

	@Override
	public Map<String, Object> generateLapPelayananByDokter(String startDate, String endDate, Integer idproduk,
			Integer idRuangan, Integer jenisPasien, Integer idDokter) {
		String id = reportingDao.findIdJenisProdukKarcis();
		String departementRawatJalan = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiRawatJalan");
		String departementGawatDarurat = settingDataFixedDao.getSettingDataFixed("KdDepartemenInstalasiGawatDarurat");
		List<Integer> idDep = new ArrayList<Integer>();
		idDep.add(Integer.valueOf(departementRawatJalan));
		idDep.add(Integer.valueOf(departementGawatDarurat));
		List<Map<String, Object>> datass = reportPelayananDaoCustom.getPelayananPasienByDokter(
				startDate.substring(0, 10), endDate.substring(0, 10), idproduk, idDep, idRuangan, jenisPasien,
				idDokter);
		List<Map<String, Object>> datas = filterTimeStamp(datass, startDate, endDate);
		Map<String, Object> result = new HashMap<String, Object>();
		List<Map<String, Object>> listData = new ArrayList<Map<String, Object>>();
		Double totalAll = 0.0;
		for (Map<String, Object> data : datas) {
			if (CommonUtil.isNotNullOrEmpty(data.get("harga")) && CommonUtil.isNotNullOrEmpty(data.get("count"))) {
				Double count = ((Long) data.get("count")).doubleValue();
				Double total = count * (Double) data.get("harga");
				data.put("total", CurrencyUtil.getPriceInINA(total));
				data.put("harga", CurrencyUtil.getPriceInINA((Double) data.get("harga")));
				totalAll += total;
			} else {
				data.put("total", CurrencyUtil.getPriceInINA(0.0));
				data.put("harga", CurrencyUtil.getPriceInINA(0.0));
			}
			listData.add(data);
		}
		result.put("listData", listData);
		result.put("totalAll", CurrencyUtil.getPriceInINA(totalAll));
		return result;
	}

	@Override
	public Map<String, Object> generateLapPelayananByDokterWithKarcis(String startDate, String endDate,
			Integer idproduk, Integer idRuangan, Integer jenisPasien, Integer idDokter, Integer idDepartemen) {

		Double totalKarcis = 0.0;
		Double totalKonsul = 0.0;
		Double totalTindakan = 0.0;
		Double totalSubTotal = 0.0;
		Double totalDiskon = 0.0;
		Double totalEmbos = 0.0;
		Map<String, Object> result = new HashMap<String, Object>();
		List<Map<String, Object>> listData = new ArrayList<Map<String, Object>>();
		List<String> listNoRec = reportPelayananDaoCustom.getPasienDaftar(startDate.substring(0, 10),
				endDate.substring(0, 10), idproduk, idDepartemen, idRuangan, jenisPasien, idDokter);
		for (String noRec : listNoRec) {
			Double karcis = 0.0;
			Double konsul = 0.0;
			Double tindakan = 0.0;
			Double subTotal = 0.0;
			Double diskon = 0.0;
			Double embos = 0.0;
			String noRecSBM = "";
			Boolean cc = false;
			Boolean pj = false;
			Map<String, Object> temp = new HashMap<String, Object>();
			List<Map<String, Object>> datas = reportPelayananDaoCustom.getPenerimaanKasirByDokter(startDate, endDate,
					idproduk, idDepartemen, idRuangan, jenisPasien, idDokter, noRec);
			// List<Map<String, Object>> datas =filterTimeStamp(datass,
			// startDate, endDate);
			for (Map<String, Object> data : datas) {
				if (CommonUtil.isNotNullOrEmpty(data.get("produkId"))) {
					if ((Integer) data.get("produkId") == 395) {
						if (CommonUtil.isNotNullOrEmpty(data.get("harga"))) {
							karcis += (Double) data.get("harga");
						}

					} else if ((Integer) data.get("produkId") == 10013116) {
						if (CommonUtil.isNotNullOrEmpty(data.get("harga"))) {
							embos += (Double) data.get("harga");
						}

					} else if ((Integer) data.get("idJenisProduk") == 100) {
						if (CommonUtil.isNotNullOrEmpty(data.get("harga"))) {
							konsul += (Double) data.get("harga");
						}

					} else {
						if (CommonUtil.isNotNullOrEmpty(data.get("harga"))) {
							tindakan += (Double) data.get("harga");
						}

					}
				}
				if (CommonUtil.isNotNullOrEmpty(data.get("hargaDiscount"))) {
					diskon += (Double) data.get("hargaDiscount");
				}
				temp.put("noCm", data.get("noCm"));
				temp.put("noRegistrasi", data.get("noRegistrasi"));
				temp.put("namaPasien", data.get("namaPasien"));
				noRecSBM = data.get("noRecSBM") + "";
			}

			Map<String, Object> caraBayar = reportingDao.getCaraBayar(noRecSBM);
			if (CommonUtil.isNotNullOrEmpty(caraBayar)) {
				subTotal = karcis + konsul + tindakan;
				temp.put("karcis", karcis);
				temp.put("karcisS", CurrencyUtil.getPriceInINA(karcis));
				totalKarcis += karcis;
				temp.put("konsul", konsul);
				temp.put("konsulS", CurrencyUtil.getPriceInINA(konsul));
				totalKonsul += konsul;
				temp.put("tindakan", tindakan);
				temp.put("tindakanS", CurrencyUtil.getPriceInINA(tindakan));
				totalTindakan += tindakan;
				temp.put("subTotal", subTotal);
				temp.put("subTotalS", CurrencyUtil.getPriceInINA(subTotal));
				totalSubTotal += subTotal;
				temp.put("diskon", diskon);
				temp.put("diskonS", CurrencyUtil.getPriceInINA(diskon));
				totalDiskon += diskon;
				temp.put("embos", embos);
				temp.put("embosS", CurrencyUtil.getPriceInINA(embos));
				totalEmbos += embos;
				if (CommonUtil.isNotNullOrEmpty(caraBayar.get("id"))) {
					if ((Integer) caraBayar.get("id") == 2) {
						cc = true;
					} else {
						pj = true;
					}
				}
				temp.put("cc", cc);
				temp.put("pj", pj);
				listData.add(temp);
			}
		}
		result.put("listData", listData);
		if (CommonUtil.isNotNullOrEmpty(listData)) {
			result.put("totalKarcis", CurrencyUtil.getPriceInINA(totalKarcis));
			result.put("totalKonsul", CurrencyUtil.getPriceInINA(totalKonsul));
			result.put("totalTindakan", CurrencyUtil.getPriceInINA(totalTindakan));
			result.put("totalSubTotal", CurrencyUtil.getPriceInINA(totalSubTotal));
			result.put("totalDiskon", CurrencyUtil.getPriceInINA(totalDiskon));
			result.put("totalEmbos", CurrencyUtil.getPriceInINA(totalEmbos));
		}
		return result;
	}

	public List<Map<String, Object>> filterTimeStamp(List<Map<String, Object>> datas, String startDate,
			String endDate) {
		List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
		for (Map<String, Object> data : datas) {
			Long start = convertDate(startDate).getTime();
			System.out.println(startDate + "---" + start);
			Long end = convertDate(endDate).getTime();
			System.out.println(endDate + "---" + end);
			Long tanggal = (long) 0;
			if (CommonUtil.isNotNullOrEmpty(data.get("tanggal"))) {
				tanggal = ((Date) data.get("tanggal")).getTime();
				System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm").format((Date) data.get("tanggal")) + "---"
						+ tanggal + "\n" + "---" + data.get("namaPasien"));
				data.put("tglRegistrasi", new SimpleDateFormat("yyyy-MM-dd HH:mm").format((Date) data.get("tanggal")));
			}

			// if((tanggal.after(start) || tanggal.equals(start))&&
			// (tanggal.after(end) || tanggal.equals(end)))
			if ((tanggal >= start) && (tanggal <= end)) {
				result.add(data);
			}
		}
		return result;
	}

	Date convertDate(String date) {
		Date newDate = null;
		if (CommonUtil.isNotNullOrEmpty(date)) {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
			Calendar c = Calendar.getInstance();
			try {
				c.setTime(sdf.parse(date));
				newDate = c.getTime();
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}
		return newDate;
	}

	@Override
	public Map<String, Object> generateJadwalPerUnitKerja(Integer ruangan, Integer tahun, Integer bulan) {
		Map<String, Object> result = new HashMap<String, Object>();
		Map<String, Object> datas = pegawaiService.findPegawaiByRuanganRev2(ruangan, tahun, bulan);
		List<Map<String, Object>> newDatas = new ArrayList<Map<String, Object>>();
		for (Map<String, Object> data : (List<Map<String, Object>>) datas.get("data")) {
			for (Map<String, Object> jadwal : (List<Map<String, Object>>) data.get("jadwal")) {
				Map<String, Object> newData = new HashMap<String, Object>();
				newData.put("namaPegawai", data.get("namaPegawai"));
				Map<String, Object> tanggal = (Map<String, Object>) jadwal.get("tanggal");
				Map<String, Object> shift = (Map<String, Object>) jadwal.get("shift");
				String hari = tanggal.get("namaHari") + "";
				newData.put(tanggal.get("hariKeDlmBulan") + "", hari.substring(0, 1));
				newData.put("tgl", tanggal.get("hariKeDlmBulan") + "");
				result.put("bulan", tanggal.get("namaBulan"));
				newData.put("shift", shift.get("kodeExternal"));
				newDatas.add(newData);
			}
		}
		result.put("datas", newDatas);
		return result;
	}

	@Override
	public Map<String, Object> generatelapLogbookLimbahB3Report(String startDate, String endDate) {
		Map<String, Object> data = new HashMap<String, Object>();
		List<Map<String, Object>> listLogBookLimbahB3 = new ArrayList<Map<String, Object>>();
		List<JenisLimbahB3Masuk> listJenisLimbahB3 = jenisLimbahB3MasukDao.getAllJenisLimbahB3Masuk();
		List<Map<String, Object>> listLimbahB3Masuk = limbahB3MasukDaoCustom.findListByPeriodeV2(startDate, endDate);
		List<Map<String, Object>> listLimbahB3Keluar = limbahB3KeluarDao.getLimbahKeluarV2(startDate, endDate);

		final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
		SimpleDateFormat formatter2 = new SimpleDateFormat("yyyy/MM/dd");
		final String firstInput = startDate;
		final String secondInput = endDate;
		final LocalDate firstDate = LocalDate.parse(firstInput, formatter);
		final LocalDate secondDate = LocalDate.parse(secondInput, formatter);
		final long days = ChronoUnit.DAYS.between(firstDate, secondDate);

		LocalDate next = firstDate.minusDays(1);
		while ((next = next.plusDays(1)).isBefore(secondDate.plusDays(1))) {
			String strNextDate = next.format(formatter);
			Map<String, Object> mergeLimbahB3 = new HashMap<String, Object>();
			// System.out.println(strNextDate);

			for (JenisLimbahB3Masuk jenisLimbahB3 : listJenisLimbahB3) {
				mergeLimbahB3 = new HashMap<String, Object>();
				mergeLimbahB3.put("limbahmasuk", null);
				mergeLimbahB3.put("limbahkeluar", null);
				mergeLimbahB3.put("tanggalPeriode", strNextDate);
				Integer idJenisLimbah2 = jenisLimbahB3.getId();
				boolean isMerge = false;

				for (Map<String, Object> limbahB3Masuk : listLimbahB3Masuk) {
					String tglMasuk = (String) limbahB3Masuk.get("tglstruk");
					Integer idLimbahMasuk = (Integer) limbahB3Masuk.get("idJenisLimbah");
					String namaLimbahMasuk = (String) limbahB3Masuk.get("jenisLimbahB3masuk");
					Integer idJenisLimbah1 = (Integer) limbahB3Masuk.get("idJenisLimbah");
					if (strNextDate.equalsIgnoreCase(tglMasuk) && idJenisLimbah1.compareTo(idJenisLimbah2) == 0) {
						mergeLimbahB3.put("namaLimbahMasuk", namaLimbahMasuk);
						mergeLimbahB3.put("limbahmasuk", limbahB3Masuk);
						isMerge = true;
						break;

					}
				}

				for (Map<String, Object> limbahB3Keluar : listLimbahB3Keluar) {
					String tglKeluar = (String) limbahB3Keluar.get("tanggal");
					Integer idLimbahMasuk = (Integer) limbahB3Keluar.get("idJenisLimbah");
					String namaLimbahMasuk = (String) limbahB3Keluar.get("jenisLimbahB3masuk");
					Integer idJenisLimbah1 = (Integer) limbahB3Keluar.get("idJenisLimbah");
					if (strNextDate.equalsIgnoreCase(tglKeluar) && idJenisLimbah1.compareTo(idJenisLimbah2) == 0) {
						mergeLimbahB3.put("namaLimbahMasuk", namaLimbahMasuk);
						mergeLimbahB3.put("limbahkeluar", limbahB3Keluar);
						isMerge = true;
						break;

					}
				}

				if (isMerge) {
					listLogBookLimbahB3.add(mergeLimbahB3);
				}

			}
		}

		String tglCetak = DateUtil.getIndonesianStringDate(new Date());
		data.put("data", listLogBookLimbahB3);
		data.put("tglCetak", tglCetak);
		try {
			data.put("periode", DateUtil.getIndonesianStringDate(formatter2.parse(startDate)).toUpperCase() + " s/d "
					+ DateUtil.getIndonesianStringDate(formatter2.parse(endDate)).toUpperCase());
		} catch (ParseException e) {
			e.printStackTrace();
		}

		return data;

	}

	@Override
	public Map<String, Object> generateFormulirLaporanKecelakaanKerja(String noRec) {
		Map<String, Object> result = new HashMap<String, Object>();
		List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
		data = reportingDao.generateFormulirLaporanKecelakaanKerja(noRec);

		List<Map<String, Object>> datasource = new ArrayList<Map<String, Object>>();
		for (Map<String, Object> datas : data) {
			int flag = 0;
			if (CommonUtil.isNotNullOrEmpty(datas.get("tglKejadian"))) {
				Date tglKejadian = (Date) datas.get("tglKejadian");
				String hariKejadian = getDayOfWeekString(tglKejadian);
				datas.put("hariKejadian", "Hari " + hariKejadian + " / Tanggal " + DateUtil.formatDate(tglKejadian));
				datas.put("jamKejadian", getJamKejadian(tglKejadian));
			}

			if (CommonUtil.isNotNullOrEmpty(datas.get("identifikasiNorec"))) {
				String identifikasiNorec = (String) datas.get("identifikasiNorec");
				System.out.println("identifikasiNorec = " + identifikasiNorec);
				List<Map<String, Object>> saksi = reportingDao.getSaksi(identifikasiNorec);
				for (Map<String, Object> saksis : saksi) {
					flag = flag + 1;
					if (CommonUtil.isNotNullOrEmpty(saksis.get("namaSaksi"))) {
						if (flag == 1) {
							datas.put("namaSaksi1", (String) saksis.get("namaSaksi"));
							datas.put("namaKontak1", (String) saksis.get("namaKontak"));
						} else if (flag == 2) {
							datas.put("namaSaksi2", (String) saksis.get("namaSaksi"));
							datas.put("namaKontak2", (String) saksis.get("namaKontak"));
						}
					}

				}
			}

			if (CommonUtil.isNotNullOrEmpty(datas.get("biayaPengobatan"))) {
				datas.put("biayaPengobatan", CurrencyUtil.getPriceInINA((Double) datas.get("biayaPengobatan")));
			}
			if (CommonUtil.isNotNullOrEmpty(datas.get("biayaPostKecelakaan"))) {
				datas.put("biayaPostKecelakaan", CurrencyUtil.getPriceInINA((Double) datas.get("biayaPostKecelakaan")));
			}
			if (CommonUtil.isNotNullOrEmpty(datas.get("biayaPemulihan"))) {
				datas.put("biayaPemulihan", CurrencyUtil.getPriceInINA((Double) datas.get("biayaPemulihan")));
			}

			datasource.add(datas);

		}

		String tglCetak = DateUtil.getIndonesianStringDate(new Date());

		result.put("tglCetak", tglCetak);
		result.put("data", datasource);
		return result;
	}

	private String getMonthYearString(Date date) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		return DateUtil.INDONESIAN_MONTH[cal.get(Calendar.MONTH)] + " " + cal.get(Calendar.YEAR);
	}

	private String getDayOfWeekString(Date date) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		return INDONESIAN_WEEK[cal.get(Calendar.DAY_OF_WEEK)];
	}

	private String getJamKejadian(Date date) {
		DateFormat jamKejadian = new SimpleDateFormat("HH:mm:ss");
		return jamKejadian.format(date);
	}

	@Override
	public Map<String, Object> generateRekapitulasiCorrectiveMaintenance(String startDate, String endDate,
			Integer idJenisProduk) {
		Map<String, Object> result = new HashMap<String, Object>();
		List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
		data = reportingDao.generateRekapitulasiCorrectiveMaintenance(startDate, endDate, idJenisProduk);

		List<Map<String, Object>> datasource = new ArrayList<Map<String, Object>>();
		String jenisProduk = "";
		for (Map<String, Object> datas : data) {
			jenisProduk = (String) datas.get("jenisProduk");
			if (CommonUtil.isNotNullOrEmpty(datas.get("noRec"))) {
				Map<String, Object> statusPekerjaan = reportingDao.getStatusPekerjaan((String) datas.get("noRec"));
				if (CommonUtil.isNotNullOrEmpty(statusPekerjaan)) {
					datas.put("statusPekerjaan", (String) statusPekerjaan.get("statusPekerjaan"));
					datas.put("uraianPekerjaan", (String) statusPekerjaan.get("uraianPekerjaan"));
				}
			}

			if (CommonUtil.isNotNullOrEmpty(datas.get("noRec"))) {
				Map<String, Object> sparepart = reportingDao.getOrderSukuCadangbyStrukOrder((String) datas.get("noRec"),
						(Integer) datas.get("idProduk"));
				if (CommonUtil.isNotNullOrEmpty(sparepart)) {
					datas.put("qtyProduk", (Double) sparepart.get("qtyProduk"));
					datas.put("satuanStandar", (String) sparepart.get("satuanStandar"));
				}
			}

			if (CommonUtil.isNotNullOrEmpty(datas.get("tanggalMulai"))
					&& CommonUtil.isNotNullOrEmpty(datas.get("tanggalOrder"))) {
				Date tanggalOrder = (Date) datas.get("tanggalOrder");
				Date tanggalMulai = (Date) datas.get("tanggalMulai");
				Long selisih = reduceTime(tanggalOrder, tanggalMulai) * 60 * 1000;

				datas.put("waktuRespon", DurationFormatUtils.formatDuration(selisih, "HH:mm"));
				datas.put("waktuLapor", new SimpleDateFormat("HH:mm").format(tanggalOrder));
				datas.put("waktuTiba", new SimpleDateFormat("HH:mm").format(tanggalMulai));
			} else {
				datas.put("waktuRespon", "");
				datas.put("waktuLapor", "");
				datas.put("waktuTiba", "");
			}

			if (CommonUtil.isNotNullOrEmpty(datas.get("tanggalMulai"))) {
				datas.put("tanggalMulai", new SimpleDateFormat("dd-MMM-yyyy").format((Date) datas.get("tanggalMulai")));
			} else
				datas.put("tanggalMulai", "");
			if (CommonUtil.isNotNullOrEmpty(datas.get("tanggalSelesai"))) {
				datas.put("tanggalSelesai",
						new SimpleDateFormat("dd-MMM-yyyy").format((Date) datas.get("tanggalSelesai")));
			} else
				datas.put("tanggalSelesai", "");
			if (CommonUtil.isNotNullOrEmpty(datas.get("tanggalRespon"))) {
				datas.put("tanggalRespon",
						new SimpleDateFormat("dd-MMM-yyyy").format((Date) datas.get("tanggalRespon")));
			} else
				datas.put("tanggalRespon", "");
			if (CommonUtil.isNotNullOrEmpty(datas.get("tanggalOrder"))) {
				datas.put("tanggalOrder", new SimpleDateFormat("dd-MMM-yyyy").format((Date) datas.get("tanggalOrder")));
			} else
				datas.put("tanggalOrder", "");

			datasource.add(datas);

		}

		String tglCetak = DateUtil.getIndonesianStringDate(new Date());
		try {
			Date dStartDate = new SimpleDateFormat("MM-dd-yyyy").parse(startDate);
			Date dEndDate = new SimpleDateFormat("MM-dd-yyyy").parse(endDate);

			String periode = new SimpleDateFormat("dd-MMM-yyyy").format(dStartDate) + " s/d "
					+ new SimpleDateFormat("dd-MMM-yyyy").format(dEndDate);
			result.put("periode", periode);
		} catch (ParseException e) {
			e.printStackTrace();
		}

		result.put("tglCetak", tglCetak);
		result.put("jenisProduk", jenisProduk);
		result.put("data", datasource);
		return result;
	}

	@Override
	public Map<String, Object> generateSuratPelimpahanTugas(String noRecPlanning, Integer idPegawaiPelimpah,
			Integer idJabatanPelimpah, Integer idPegawaiDilimpah) {
		Map<String, Object> result = new HashMap<>();

		String tgl = "";

		List<Map<String, Object>> listTglCutiPelimpah = planningPegawaiStatusDao.getListTglCutiPelimpah(noRecPlanning,
				idPegawaiPelimpah);
		Map<String, Object> pegawaiPelimpah = planningPegawaiStatusDao.getDataPelimpah(idPegawaiPelimpah,
				idJabatanPelimpah);
		Map<String, Object> pegawaiDilimpah = planningPegawaiStatusDao.getDataDilimpah(idPegawaiDilimpah);

		result.put("namaPegawaiPelimpah", pegawaiPelimpah.get("namaPegawai").toString());
		result.put("nipPegawaiPelimpah", pegawaiPelimpah.get("nipPegawai").toString());
		result.put("jabatanPegawaiPelimpah", pegawaiPelimpah.get("jabatanPegawai").toString());
		result.put("namaAtasanLangsungPegawaiPelimpah", pegawaiPelimpah.get("namaAtasanLangsung").toString());
		result.put("nipAtasanLangsungPegawaiPelimpah", pegawaiPelimpah.get("nipAtasanLangsung").toString());
		result.put("namaPegawaiDilimpah", pegawaiDilimpah.get("namaPegawai").toString());
		result.put("nipPegawaiDilimpah", pegawaiDilimpah.get("nipPegawai").toString());
		result.put("pangkatPegawaiDilimpah", pegawaiDilimpah.get("pangkatPegawai").toString());
		result.put("golonganPegawaiDilimpah", pegawaiDilimpah.get("golonganPegawai").toString());
		result.put("jabatanPegawaiDilimpah", pegawaiDilimpah.get("jabatanPegawai").toString());
		int i = 1;
		for (Map<String, Object> map : listTglCutiPelimpah) {
			if (i == 1) {
				tgl += new SimpleDateFormat("dd MMMM yyyy", new Locale("in", "ID")).format((Date) map.get("tglCuti"));
				i++;
			} else if (listTglCutiPelimpah.size() == 2) {
				tgl += " dan " + new SimpleDateFormat("dd MMMM yyyy", new Locale("in", "ID"))
						.format((Date) map.get("tglCuti"));
				i++;
			} else if (listTglCutiPelimpah.size() == i && listTglCutiPelimpah.size() != 2) {
				tgl += ", dan " + new SimpleDateFormat("dd MMMM yyyy", new Locale("in", "ID"))
						.format((Date) map.get("tglCuti"));
				i++;
			} else {
				tgl += ", " + new SimpleDateFormat("dd MMMM yyyy", new Locale("in", "ID"))
						.format((Date) map.get("tglCuti"));
				i++;
			}
		}
		result.put("tglCutiPegawaiPelimpah", tgl);

		return result;
	}

	@Override
	public Map<String, Object> generateReportPencatatanSuhuMesin(Integer idMesin, Integer idMappingMesin,
			String tglCatSuhuMesin, Integer idSupervisor) {
		Map<String, Object> result = pencatatanSuhuMesinDao.getReportPencatatanSuhuMesin(idMesin, idMappingMesin,
				tglCatSuhuMesin);
		Map<String, Object> supervisor = pegawaiDao.findPegawaiById(idSupervisor);
		Map<String, Object> pegMonitorSterilisasi = pegawaiDao.getKepalaPegawai("Monitoring Sterilisasi");
		result.put("idSupervisor", supervisor.get("idPegawai"));
		result.put("namaSupervisor", supervisor.get("nama"));
		result.put("idJabSupervisor", supervisor.get("idJabatanInternal"));
		result.put("namaJabSupervisor", supervisor.get("jabatanInternal"));
		result.put("idPegMonSterilisasi", pegMonitorSterilisasi.get("idPegawai"));
		result.put("namaPegMonSterilisasi", pegMonitorSterilisasi.get("namaPegawai"));
		return result;
	}

	@Override
	public List<Map<String, Object>> generateReportGrafikSuhuMesin(Integer idMesin, Integer idMappingMesin,
			String tglCatSuhuMesin) {
		List<Map<String, Object>> result = pencatatanSuhuMesinDao.getReportGrafikSuhuMesin(idMesin, idMappingMesin,
				tglCatSuhuMesin);
		return result;
	}

	@Override
	public Map<String, Object> findDataCetakLuarNegeri(String norec) {
		Map<String, Object> result = new HashMap<>();

		List<Date> listTglPeriode = new ArrayList<>();

		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		SimpleDateFormat ina = new SimpleDateFormat("dd/MM/yyyy");

		int countTglCuti = 0;

		List<Map<String, Object>> dataRaw = planningPegawaiStatusDao.getCetakCutiLuarNegeri(norec);
		for (Map<String, Object> map : dataRaw) {
			listTglPeriode.add((Date) map.get("tglCuti"));
			countTglCuti += 1;
			if (countTglCuti == 1) {
				result.putAll(map);
			}
		}
		Collections.sort(listTglPeriode);
		if (Arrays.asList(Master.StatusPegawai.PERIODIK_PENGAJUAN_KETIDAKHADIRAN).contains(result.get("idPlanning"))
				&& countTglCuti == 2) {
			List<Date> listDetailTglPeriode = kalenderDao
					.getDateFromPeriodicParameter(sdf.format(listTglPeriode.get(0)), sdf.format(listTglPeriode.get(1)));
			Collections.sort(listDetailTglPeriode);
			result.put("lamaCuti", listDetailTglPeriode.size());
			result.put("detailTgl", "sejak tanggal " + ina.format(listDetailTglPeriode.get(0)) + " s.d. "
					+ ina.format(listDetailTglPeriode.get(listDetailTglPeriode.size() - 1)));
		} else if (countTglCuti == 1) {
			result.put("lamaCuti", listTglPeriode.size());
			result.put("detailTgl", "tanggal " + ina.format(listTglPeriode.get(0)));
		} else if (countTglCuti >= 2) {
			result.put("lamaCuti", listTglPeriode.size());
			result.put("detailTgl", "sejak tanggal " + ina.format(listTglPeriode.get(0)) + " s.d. "
					+ ina.format(listTglPeriode.get(listTglPeriode.size() - 1)));
		}

		Map<String, Object> dataDirut = new HashMap<>();
		dataDirut = mapPegawaiJabatanToUnitKerjaDao.getDirekturUtama(Master.Jabatan.DIRUT_STRUKTURAL);
		if (CommonUtil.isNotNullOrEmpty(dataDirut)) {
			result.putAll(dataDirut);
		} else {
			dataDirut = mapPegawaiJabatanToUnitKerjaDao.getDirekturUtama(Master.Jabatan.DIRUT_INTERNAL);
			if (CommonUtil.isNotNullOrEmpty(dataDirut)) {
				result.putAll(dataDirut);
			} else {
				dataDirut = mapPegawaiJabatanToUnitKerjaDao.getDirekturUtama(Master.Jabatan.DIRUT_PLH);
				if (CommonUtil.isNotNullOrEmpty(dataDirut)) {
					result.putAll(dataDirut);
				}
			}
		}

		return result;
	}

	@Override
	public List<Map<String, Object>> getHistoriUsulanRincianKegiatan(Integer idPelaksanaanTugas,
			Integer idRincianKegiatan) {
		List<Map<String, Object>> result = historiUsulanRincianKegiatanDao.getHistori(idPelaksanaanTugas,
				idRincianKegiatan);

		return result;
	}

}
