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.NilaiNilaiConverter;
import com.jasamedika.medifirst2000.dao.AntrianPasienDiPeriksaDao;
import com.jasamedika.medifirst2000.dao.NilaiNilaiDao;
import com.jasamedika.medifirst2000.entities.AntrianPasienDiPeriksa;
import com.jasamedika.medifirst2000.entities.NilaiNilai;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.NilaiNilaiService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.vo.NilaiNilaiVO;

/**
 * Implement class for NilaiNilaiService
 * 
 * @author Askur
 */
@Service("NilaiNilaiService")
public class NilaiNilaiServiceImpl implements NilaiNilaiService {
	@Autowired
	private NilaiNilaiDao nilaiNilaiDao;
	@Autowired
	private AntrianPasienDiPeriksaDao antrianPasienDiPeriksaDao;
	@Autowired
	private NilaiNilaiConverter nilaiNilaiConverter;
	
	@Override
	public Map<String,Object> addNilaiNilai(NilaiNilaiVO vo) throws JpaSystemException, ServiceVOException {
		Map<String,Object> result=new HashMap<String,Object>();
		NilaiNilai model=nilaiNilaiConverter.transferVOToModel(vo, new NilaiNilai());
		AntrianPasienDiPeriksa pasienDaftar = antrianPasienDiPeriksaDao.findByNoRec(vo.getPasienDaftar().getNoRec());
		model.setPasienDaftar(pasienDaftar);
		NilaiNilai resultModel=nilaiNilaiDao.save(model);
		if(CommonUtil.isNotNullOrEmpty(resultModel)){
			result.put("NilaiNilai", resultModel.getNoRec());
		}
		return result;
	}

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


}
