package com.jasamedika.medifirst2000.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jasamedika.medifirst2000.vo.JenisGajiVO;
import com.jasamedika.medifirst2000.vo.TahunUmrVO;
import com.jasamedika.medifirst2000.vo.NamaAsuransiVO;

	import com.jasamedika.medifirst2000.entities.JenisGaji;
import com.jasamedika.medifirst2000.entities.TahunUmr;
import com.jasamedika.medifirst2000.entities.NamaAsuransi;


import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PerhitunganPremiBPJSKesehatanService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.entities.PerhitunganPremiBPJSKesehatan;
import com.jasamedika.medifirst2000.vo.PerhitunganPremiBPJSKesehatanVO;
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
import com.jasamedika.medifirst2000.dao.PerhitunganPremiBPJSKesehatanDao;

/**
 * Implement class for PerhitunganPremiBPJSKesehatanService
 * 
 * @author Generator
 * @param <T>
 */
@Service("perhitunganPremiBPJSKesehatanService")
public class PerhitunganPremiBPJSKesehatanServiceImpl extends BaseVoServiceImpl implements PerhitunganPremiBPJSKesehatanService 
{	
	@Autowired
	private BaseConverterImpl<PerhitunganPremiBPJSKesehatanVO,PerhitunganPremiBPJSKesehatan>perhitunganPremiBPJSKesehatanConverter;
	@Autowired
private BaseConverterImpl<JenisGajiVO,JenisGaji>jenisGajiConverter;

@Autowired
private BaseConverterImpl<TahunUmrVO,TahunUmr>tahunUmrConverter;

@Autowired
private BaseConverterImpl<NamaAsuransiVO,NamaAsuransi>namaAsuransiConverter;


	@Autowired
	private PerhitunganPremiBPJSKesehatanDao perhitunganPremiBPJSKesehatanDao;


	@Override
	public Map<String, Object> savePerhitunganPremiBPJSKesehatan(PerhitunganPremiBPJSKesehatanVO vo) {
		Map<String, Object> result = new HashMap<String, Object>();
		PerhitunganPremiBPJSKesehatan model = new PerhitunganPremiBPJSKesehatan();
		model = perhitunganPremiBPJSKesehatanConverter.transferVOToModel(vo,model);
		
		if (CommonUtil.isNotNullOrEmpty(vo.getJenisGaji()))
		{
				model.setJenisGaji(jenisGajiConverter.transferVOToModel(vo.getJenisGaji(), new JenisGaji()));
		}
		if (CommonUtil.isNotNullOrEmpty(vo.getTahunUMR()))
		{
				model.setTahunUMR(tahunUmrConverter.transferVOToModel(vo.getTahunUMR(), new TahunUmr()));
		}
		if (CommonUtil.isNotNullOrEmpty(vo.getNamaAsuransi()))
		{
				model.setNamaAsuransi(namaAsuransiConverter.transferVOToModel(vo.getNamaAsuransi(), new NamaAsuransi()));
		}

		PerhitunganPremiBPJSKesehatan resultDomain = perhitunganPremiBPJSKesehatanDao.save(model);
		if (CommonUtil.isNotNullOrEmpty(resultDomain)) {
			result.put("noRec", resultDomain.getNoRec());
		}

		return result;
	}
}