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 java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jasamedika.medifirst2000.vo.StatusMandiriVO;
import com.jasamedika.medifirst2000.entities.StatusMandiri;


import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.StatusKemandirianService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.entities.StatusKemandirian;
import com.jasamedika.medifirst2000.vo.StatusKemandirianVO;
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
import com.jasamedika.medifirst2000.dao.AntrianPasienDiPeriksaDao;
import com.jasamedika.medifirst2000.dao.PasienDaftarDao;
import com.jasamedika.medifirst2000.dao.StatusKemandirianDao;

/**
 * Implement class for StatusKemandirianService
 * 
 * @author Generator
 * @param <T>
 */
@Service("statusKemandirianService")
public class StatusKemandirianServiceImpl extends BaseVoServiceImpl implements StatusKemandirianService 
{
	@Autowired
	private BaseConverterImpl<StatusKemandirianVO,StatusKemandirian>statusKemandirianConverter;
	@Autowired
	private BaseConverterImpl<StatusMandiriVO,StatusMandiri>statusMandiriConverter;

	@Autowired
	private StatusKemandirianDao statusKemandirianDao;
	
	@Autowired
	private PasienDaftarDao pasienDaftarDao;
	@Autowired
	private AntrianPasienDiPeriksaDao antrianPasienDiPeriksaDao;
	@Override
	public Map<String, Object> saveStatusKemandirian(StatusKemandirianVO vo) {
		Map<String, Object> result = new HashMap<String, Object>();
		StatusKemandirian model = new StatusKemandirian();
		model = statusKemandirianConverter.transferVOToModel(vo,model);
		model.setPasien(antrianPasienDiPeriksaDao.finByNoIdAndTglRegistrasi(Short.parseShort("0"), vo.getPasien().getId(), vo.getTglRegistrasi()));
		if (CommonUtil.isNotNullOrEmpty(vo.getEkstremitasAtas()))
		{
				model.setEkstremitasAtas(statusMandiriConverter.transferVOToModel(vo.getEkstremitasAtas(), new StatusMandiri()));
		}
		if (CommonUtil.isNotNullOrEmpty(vo.getBatangTumbuh()))
		{
				model.setBatangTumbuh(statusMandiriConverter.transferVOToModel(vo.getBatangTumbuh(), new StatusMandiri()));
		}
		if (CommonUtil.isNotNullOrEmpty(vo.getEkstremitasBawah()))
		{
				model.setEkstremitasBawah(statusMandiriConverter.transferVOToModel(vo.getEkstremitasBawah(), new StatusMandiri()));
		}
		if (CommonUtil.isNotNullOrEmpty(vo.getMakanan()))
		{
				model.setMakanan(statusMandiriConverter.transferVOToModel(vo.getMakanan(), new StatusMandiri()));
		}
		if (CommonUtil.isNotNullOrEmpty(vo.getJalanKaki()))
		{
				model.setJalanKaki(statusMandiriConverter.transferVOToModel(vo.getJalanKaki(), new StatusMandiri()));
		}
		if (CommonUtil.isNotNullOrEmpty(vo.getKursiRoda()))
		{
				model.setKursiRoda(statusMandiriConverter.transferVOToModel(vo.getKursiRoda(), new StatusMandiri()));
		}
		if (CommonUtil.isNotNullOrEmpty(vo.getBerguling()))
		{
				model.setBerguling(statusMandiriConverter.transferVOToModel(vo.getBerguling(), new StatusMandiri()));
		}
		if (CommonUtil.isNotNullOrEmpty(vo.getDuduk()))
		{
				model.setDuduk(statusMandiriConverter.transferVOToModel(vo.getDuduk(), new StatusMandiri()));
		}
		if (CommonUtil.isNotNullOrEmpty(vo.gethPWajahRambutTangan()))
		{
				model.sethPWajahRambutTangan(statusMandiriConverter.transferVOToModel(vo.gethPWajahRambutTangan(), new StatusMandiri()));
		}
		if (CommonUtil.isNotNullOrEmpty(vo.gethPBatangTubuhDanPerineum()))
		{
				model.sethPBatangTubuhDanPerineum(statusMandiriConverter.transferVOToModel(vo.gethPBatangTubuhDanPerineum(), new StatusMandiri()));
		}
		if (CommonUtil.isNotNullOrEmpty(vo.gethPEkstremitasBawah()))
		{
				model.sethPEkstremitasBawah(statusMandiriConverter.transferVOToModel(vo.gethPEkstremitasBawah(), new StatusMandiri()));
		}
		if (CommonUtil.isNotNullOrEmpty(vo.gethPTraktusDigestivus()))
		{
				model.sethPTraktusDigestivus(statusMandiriConverter.transferVOToModel(vo.gethPTraktusDigestivus(), new StatusMandiri()));
		}
		if (CommonUtil.isNotNullOrEmpty(vo.gethPTraktusUrinarius()))
		{
				model.sethPTraktusUrinarius(statusMandiriConverter.transferVOToModel(vo.gethPTraktusUrinarius(), new StatusMandiri()));
		}		

		StatusKemandirian resultDomain = statusKemandirianDao.save(model);
		if (CommonUtil.isNotNullOrEmpty(resultDomain)) {
			result.put("noRec", resultDomain.getNoRec());
		}

		return result;
	}
}