package com.jasamedika.medifirst2000.service.impl;

import java.util.Date;
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.PapPernapasanConverter;
import com.jasamedika.medifirst2000.dao.PapPernapasanDao;
import com.jasamedika.medifirst2000.entities.PapPernapasan;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PapPernapasanService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.vo.PapPernapasanVO;

/**
 * Implement class for PAPPernapasanService
 * 
 * @author Askur
 */
@Service("PAPPernapasanService")
public class PapPernapasanServiceImpl implements PapPernapasanService {
	@Autowired
	private PapPernapasanDao papPernapasanDao;
	@Autowired
	private PapPernapasanConverter papPernapasanConverter;
	
	@Override
	public Map<String,Object> addPernapasan(PapPernapasanVO vo) throws JpaSystemException, ServiceVOException {
		Map<String,Object> result=new HashMap<String,Object>();
		PapPernapasan model=papPernapasanConverter.transferVOToModel(vo, new PapPernapasan());
		PapPernapasan resultModel=papPernapasanDao.save(model);
		if(CommonUtil.isNotNullOrEmpty(resultModel)){
			result.put("papPernapasan", resultModel);
		}		
		return result;
	}

	@Override
	public Map<String,Object> updatePernapasan(PapPernapasanVO vo) throws JpaSystemException, ServiceVOException {
		Map<String,Object> result=new HashMap<String,Object>();
		PapPernapasan model=papPernapasanConverter.transferVOToModel(vo, new PapPernapasan());
		PapPernapasan resultModel=papPernapasanDao.save(model);
		if(CommonUtil.isNotNullOrEmpty(resultModel)){
			result.put("papPernapasan", resultModel);
			result.put("dataFound", true);
		}else{
			result.put("dataFound", false);
		}
		return result;
	}

	@Override
	public Map<String,Object> findByNoCmAndTglInput(String noCm, Date tglInput) {
		Map<String,Object> result=new HashMap<String,Object>();
		PapPernapasan resultModel=papPernapasanDao.findPapPernapasanByNoCmAndTglInput(noCm, tglInput);
		if(CommonUtil.isNotNullOrEmpty(resultModel)){
			result.put("papPernapasan", resultModel);
			result.put("dataFound", true);
		}else{
			result.put("dataFound", false);
		}
		return result;
	}

	@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 List findAll() throws JpaSystemException {
		return null;
	}

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

}
