package com.jasamedika.medifirst2000.service.impl;

import java.util.ArrayList;
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.PapImunisasiDetailConverter;
import com.jasamedika.medifirst2000.converter.TidurIstirahatConverter;
import com.jasamedika.medifirst2000.dao.AntrianPasienDiPeriksaDao;
import com.jasamedika.medifirst2000.dao.TidurIstirahatDao;
import com.jasamedika.medifirst2000.dao.PasienDao;
import com.jasamedika.medifirst2000.entities.AntrianPasienDiPeriksa;
import com.jasamedika.medifirst2000.entities.PapImunisasiDetail;
import com.jasamedika.medifirst2000.entities.TidurIstirahat;
import com.jasamedika.medifirst2000.entities.Pasien;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.TidurIstirahatService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.vo.PapImunisasiDetailVO;
import com.jasamedika.medifirst2000.vo.TidurIstirahatVO;

/**
 * Implement class for TidurIstirahatService
 * 
 * @author Askur
 */
@Service("TidurIstirahatService")
public class TidurIstirahatServiceImpl implements TidurIstirahatService {
	@Autowired
	private TidurIstirahatDao tidurIstirahatDao;
	@Autowired
	private AntrianPasienDiPeriksaDao antrianPasienDiPeriksaDao;
	@Autowired
	private TidurIstirahatConverter tidurIstirahatConverter;
	
	@Override
	public Map<String,Object> addTidurIstirahat(TidurIstirahatVO vo) throws JpaSystemException, ServiceVOException {
		Map<String,Object> result=new HashMap<String,Object>();
		TidurIstirahat model=tidurIstirahatConverter.transferVOToModel(vo, new TidurIstirahat());
		AntrianPasienDiPeriksa pasienDaftar = antrianPasienDiPeriksaDao.findByNoRec(vo.getPasienDaftar().getNoRec());
		model.setPasienDaftar(pasienDaftar);
		TidurIstirahat resultModel=tidurIstirahatDao.save(model);
		if(CommonUtil.isNotNullOrEmpty(resultModel)){
			result.put("tidurIstirahat", resultModel.getNoRec());
		}
		return result;
	}

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


}
