package com.jasamedika.medifirst2000.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

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

import com.jasamedika.medifirst2000.converter.PeranHubunganConverter;
import com.jasamedika.medifirst2000.dao.AntrianPasienDiPeriksaDao;
import com.jasamedika.medifirst2000.dao.PeranHubunganDao;
import com.jasamedika.medifirst2000.entities.AntrianPasienDiPeriksa;
import com.jasamedika.medifirst2000.entities.PeranHubungan;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PeranHubunganService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.vo.PeranHubunganVO;

/**
 * Implement class for PeranHubunganService
 * 
 * @author Askur
 */
@Service("PeranHubunganService")
public class PeranHubunganServiceImpl implements PeranHubunganService {
	@Autowired
	private PeranHubunganDao peranHubunganDao;
	@Autowired
	private AntrianPasienDiPeriksaDao antrianPasienDiPeriksaDao;
	@Autowired
	private PeranHubunganConverter peranHubunganConverter;
	
	@Override
	public Map<String,Object> addPeranHubungan(PeranHubunganVO vo) throws JpaSystemException, ServiceVOException {
		Map<String,Object> result=new HashMap<String,Object>();
		PeranHubungan model=peranHubunganConverter.transferVOToModel(vo, new PeranHubungan());
		AntrianPasienDiPeriksa pasienDaftar = antrianPasienDiPeriksaDao.findByNoRec(vo.getPasienDaftar().getNoRec());
		model.setPasienDaftar(pasienDaftar);
		PeranHubungan resultModel=peranHubunganDao.save(model);
		if(CommonUtil.isNotNullOrEmpty(resultModel)){
			result.put("PeranHubungan", resultModel.getNoRec());
		}
		return result;
	}

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


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

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

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

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

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


}
