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.PersepsiKognisiConverter;
import com.jasamedika.medifirst2000.dao.AntrianPasienDiPeriksaDao;
import com.jasamedika.medifirst2000.dao.PersepsiKognisiDao;
import com.jasamedika.medifirst2000.entities.AntrianPasienDiPeriksa;
import com.jasamedika.medifirst2000.entities.PersepsiKognisi;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PersepsiKognisiService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.vo.PersepsiKognisiVO;

/**
 * Implement class for PersepsiKognisiService
 * 
 * @author Askur
 */
@Service("PersepsiKognisiService")
public class PersepsiKognisiServiceImpl implements PersepsiKognisiService {
	@Autowired
	private PersepsiKognisiDao persepsiKognisiDao;
	@Autowired
	private AntrianPasienDiPeriksaDao antrianPasienDiPeriksaDao;
	@Autowired
	private PersepsiKognisiConverter persepsiKognisiConverter;
	
	@Override
	public Map<String,Object> addPersepsiKognisi(PersepsiKognisiVO vo) throws JpaSystemException, ServiceVOException {
		Map<String,Object> result=new HashMap<String,Object>();
		PersepsiKognisi model=persepsiKognisiConverter.transferVOToModel(vo, new PersepsiKognisi());
		AntrianPasienDiPeriksa pasienDaftar = antrianPasienDiPeriksaDao.findByNoRec(vo.getPasienDaftar().getNoRec());
		model.setPasienDaftar(pasienDaftar);
		PersepsiKognisi resultModel=persepsiKognisiDao.save(model);
		if(CommonUtil.isNotNullOrEmpty(resultModel)){
			result.put("persepsiKognisi", resultModel.getNoRec());
		}
		return result;
	}

	@Override
	public List<PersepsiKognisiVO> 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;
	}


}
