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.orm.jpa.JpaSystemException;
import org.springframework.stereotype.Service;

import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
import com.jasamedika.medifirst2000.dao.BakuMutuDao;
import com.jasamedika.medifirst2000.dao.GolonganDarahRhesusDao;
import com.jasamedika.medifirst2000.entities.BakuMutu;
import com.jasamedika.medifirst2000.entities.GolonganDarah;
import com.jasamedika.medifirst2000.entities.JenisLimbahB3Masuk;
import com.jasamedika.medifirst2000.entities.Rhesus;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.BakuMutuService;
import com.jasamedika.medifirst2000.service.GolonganDarahRhesusService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.util.JsonUtil;
import com.jasamedika.medifirst2000.util.StringUtil;
import com.jasamedika.medifirst2000.vo.BakuMutuVO;
import com.jasamedika.medifirst2000.vo.GolonganDarahRhesusVO;

@Service("GolonganDarahRhesusService")
public class GolonganDarahRhesusServiceImpl implements GolonganDarahRhesusService {
	@Autowired
	private GolonganDarahRhesusDao golonganDarahRhesusDao;
	
	@Override
	public Map<String, Object> findAll() {
		Map<String,Object> result=new HashMap<String,Object>();
		List<String> list=golonganDarahRhesusDao.findGolonganDarahRhesus();
		List<GolonganDarahRhesusVO> listGdr=new ArrayList<GolonganDarahRhesusVO>();
		if(CommonUtil.isNotNullOrEmpty(list)){
			for(String string:list){
				GolonganDarahRhesusVO gdr=new GolonganDarahRhesusVO();
				gdr.setIdGolDarahAndRhesus(string.split(",")[0]);
				gdr.setNameGolDarahAndRhesus(string.split(",")[1]);
				listGdr.add(gdr);
				}
				result.put("golonganDarahRhesus", listGdr);
				result.put("dataFound", true);
		}	else{
			result.put("dataFound", false);
		}		
		return result;
	}
	
}
