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.BaseConverterImpl;
import com.jasamedika.medifirst2000.dao.KajianSistemDao;
import com.jasamedika.medifirst2000.entities.KajianSistem;
import com.jasamedika.medifirst2000.entities.PraAnestesiDokter;
import com.jasamedika.medifirst2000.entities.StatusYaTidak;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.KajianSistemService;
import com.jasamedika.medifirst2000.service.PasienDaftarService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.vo.KajianSistemVO;
import com.jasamedika.medifirst2000.vo.PraAnestesiDokterVO;
import com.jasamedika.medifirst2000.vo.StatusYaTidakVO;

@Service("kajianSistemService")
public class KajianSistemServiceImpl  implements KajianSistemService {
	
	@Autowired
	private BaseConverterImpl<KajianSistemVO, KajianSistem> kajianSistemConverter;
	
	@Autowired
	private BaseConverterImpl<StatusYaTidakVO, StatusYaTidak> statusYaTidakConverter;
	
	@Autowired
	private BaseConverterImpl<PraAnestesiDokterVO, PraAnestesiDokter> praAnestesiDokterConverter;
		
	@Autowired
	private KajianSistemDao kajianSistemDao;
	
	@Autowired
	private PasienDaftarService pasienDaftarService;
	
	@Override
	public KajianSistemVO add(KajianSistemVO vo) throws JpaSystemException, ServiceVOException {
		return null;
	}

	@Override
	public KajianSistemVO update(KajianSistemVO vo) throws JpaSystemException, ServiceVOException {
		return null;
	}

	@Override
	public Boolean delete(String key) throws JpaSystemException {
		return null;
	}

	@Override
	public KajianSistemVO findById(String key) throws JpaSystemException {
		return null;
	}

	@Override
	public List<KajianSistemVO> findAll() throws JpaSystemException {
		return null;
	}

	@Override
	public Map<String, Object> findAllWithPageAndLimitAndSortByAndDirectionParameter(Integer page, Integer limit,
			String sort, String dir) {
		return null;
	}

	@Override
	public Map<String, Object> saveKajianSistem(KajianSistemVO vo) {
		Map <String, Object> result = new HashMap<String, Object>();
		KajianSistem kajianSistem = kajianSistemConverter.transferVOToModel(vo, new KajianSistem());	
		kajianSistem.setPraAnestesiDokter(praAnestesiDokterConverter.transferVOToModel(vo.getPraAnestesiDokter(), new PraAnestesiDokter()));
		kajianSistem.setHilangnyaGigi(statusYaTidakConverter.transferVOToModel(vo.getHilangnyaGigi(), new StatusYaTidak()));
		kajianSistem.setMobilisasiLeher(statusYaTidakConverter.transferVOToModel(vo.getHilangnyaGigi(), new StatusYaTidak()));
		kajianSistem.setLeherPendek(statusYaTidakConverter.transferVOToModel(vo.getHilangnyaGigi(), new StatusYaTidak()));
		kajianSistem.setBatuk(statusYaTidakConverter.transferVOToModel(vo.getHilangnyaGigi(), new StatusYaTidak()));
		kajianSistem.setSesakNafas(statusYaTidakConverter.transferVOToModel(vo.getHilangnyaGigi(), new StatusYaTidak()));
		kajianSistem.setInfeksi(statusYaTidakConverter.transferVOToModel(vo.getHilangnyaGigi(), new StatusYaTidak()));
		kajianSistem.setSakitDada(statusYaTidakConverter.transferVOToModel(vo.getHilangnyaGigi(), new StatusYaTidak()));
		kajianSistem.setDenyutTdkNormal(statusYaTidakConverter.transferVOToModel(vo.getHilangnyaGigi(), new StatusYaTidak()));
		kajianSistem.setMuntah(statusYaTidakConverter.transferVOToModel(vo.getHilangnyaGigi(), new StatusYaTidak()));
		kajianSistem.setPingsan(statusYaTidakConverter.transferVOToModel(vo.getHilangnyaGigi(), new StatusYaTidak()));
		kajianSistem.setKejang(statusYaTidakConverter.transferVOToModel(vo.getHilangnyaGigi(), new StatusYaTidak()));
		kajianSistem.setHamil(statusYaTidakConverter.transferVOToModel(vo.getHilangnyaGigi(), new StatusYaTidak()));
		kajianSistem.setKelainanTulangBelakang(statusYaTidakConverter.transferVOToModel(vo.getHilangnyaGigi(), new StatusYaTidak()));
		kajianSistem.setStroke(statusYaTidakConverter.transferVOToModel(vo.getHilangnyaGigi(), new StatusYaTidak()));
		kajianSistem.setObesitas(statusYaTidakConverter.transferVOToModel(vo.getHilangnyaGigi(), new StatusYaTidak()));
		KajianSistem resultModel = kajianSistemDao.save(kajianSistem);
		if(CommonUtil.isNotNullOrEmpty(resultModel)){
			result.put("id", resultModel.getNoRec());
			result.put("Keterangan", resultModel.getKeterangan());
		}
		return result;
	}

	@Override
	public Map<String, Object> updateKajianSistem(KajianSistemVO vo) {
		return null;
	}
	
}
