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.PapGastrointestinalConverter;
import com.jasamedika.medifirst2000.dao.PapGastrointestinalDao;
import com.jasamedika.medifirst2000.entities.PapGastrointestinal;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PapGastrointestinalService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.vo.PapGastrointestinalVO;

/**
 * Implement class for PAPGastrointestinalService
 * 
 * @author Askur
 */
@Service("PAPGastrointestinalService")
public class PapGastrointestinalServiceImpl implements PapGastrointestinalService {
	@Autowired
	private PapGastrointestinalDao papGastrointestinalDao;
	@Autowired
	private PapGastrointestinalConverter papGastrointestinalConverter;
	
	@Override
	public Map<String,Object> addGastrointestinal(PapGastrointestinalVO vo) throws JpaSystemException, ServiceVOException {
		Map<String,Object> result=new HashMap<String,Object>();
		PapGastrointestinal model=papGastrointestinalConverter.transferVOToModel(vo, new PapGastrointestinal());
		PapGastrointestinal resultModel=papGastrointestinalDao.save(model);
		if(CommonUtil.isNotNullOrEmpty(resultModel)){
			result.put("papGastrointestinal", resultModel);
		}
		return result;
	}

	@Override
	public Map<String,Object> updateGastrointestinal(PapGastrointestinalVO vo) throws JpaSystemException, ServiceVOException {
		Map<String,Object> result=new HashMap<String,Object>();
		PapGastrointestinal model=papGastrointestinalConverter.transferVOToModel(vo, new PapGastrointestinal());
		PapGastrointestinal resultModel=papGastrointestinalDao.save(model);
		if(CommonUtil.isNotNullOrEmpty(resultModel)){
			result.put("papGastrointestinal", 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>();
		PapGastrointestinal resultModel=papGastrointestinalDao.findPapGastrointestinalByNoCmAndTglInput(noCm, tglInput);
		if(CommonUtil.isNotNullOrEmpty(resultModel)){
			result.put("papGastrointestinal", 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;
	}

}
