package com.jasamedika.medifirst2000.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jasamedika.medifirst2000.dao.RIS_StudyDao;
import com.jasamedika.medifirst2000.entities.RIS_Study;
import com.jasamedika.medifirst2000.service.RIS_StudyService;
import com.jasamedika.medifirst2000.util.CommonUtil;

@Service("RIS_StudyService")
public class RIS_StudyServiceImpl implements RIS_StudyService{

	@Autowired
	private RIS_StudyDao rIS_StudyDao;
	
	@Override
	public Map<String, Object> save(RIS_Study vo) {	
		Map<String, Object> result = new HashMap<>();
		if(CommonUtil.isNotNullOrEmpty(vo)) {
			RIS_Study model = rIS_StudyDao.save(vo);
			result.put("id", model.getSTUDY_KEY());
		}
		return result;
	}

	@Override
	public void delete(RIS_Study vo) {
		if(CommonUtil.isNotNullOrEmpty(vo)) {
			rIS_StudyDao.delete(vo.getSTUDY_KEY());
		}
	}
	
	@Override
	public RIS_Study getOne(RIS_Study vo) {
		RIS_Study result = new RIS_Study();
		if(CommonUtil.isNotNullOrEmpty(vo.getSTUDY_KEY())) {
			result = rIS_StudyDao.findOne(vo.getSTUDY_KEY());
		}
		return result;
	}
	
	@Override
	public List<RIS_Study> getAll() {
		List<RIS_Study> result = new ArrayList<>();
		result = (List<RIS_Study>) rIS_StudyDao.findAll();
		return result;
	}
}
