package com.jasamedika.medifirst2000.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.joda.time.DateTime;
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.converter.AgamaConverter;
import com.jasamedika.medifirst2000.converter.AlamatConverter;
import com.jasamedika.medifirst2000.converter.AntrianPasienDiPeriksaConverter;
import com.jasamedika.medifirst2000.converter.AsalRujukanConverter;
import com.jasamedika.medifirst2000.converter.CaraMasukConverter;
import com.jasamedika.medifirst2000.converter.DetailKamarConverter;
import com.jasamedika.medifirst2000.converter.JenisAlamatConverter;
import com.jasamedika.medifirst2000.converter.JenisKelaminConverter;
import com.jasamedika.medifirst2000.converter.KasusPenyakitConverter;
import com.jasamedika.medifirst2000.converter.KecamatanConverter;
import com.jasamedika.medifirst2000.converter.KelasConverter;
import com.jasamedika.medifirst2000.converter.KelompokPasienConverter;
import com.jasamedika.medifirst2000.converter.KelompokUmurConverter;
import com.jasamedika.medifirst2000.converter.LoginUserConverter;
import com.jasamedika.medifirst2000.converter.LokasiConverter;
import com.jasamedika.medifirst2000.converter.NegaraConverter;
import com.jasamedika.medifirst2000.converter.PasienConverter;
import com.jasamedika.medifirst2000.converter.PasienDaftarConverter;
import com.jasamedika.medifirst2000.converter.PekerjaanConverter;
import com.jasamedika.medifirst2000.converter.PendidikanConverter;
import com.jasamedika.medifirst2000.converter.PropinsiConverter;
import com.jasamedika.medifirst2000.converter.RegistrasiPasienConverter;
import com.jasamedika.medifirst2000.converter.RegistrasiPelayananPasienConverter;
import com.jasamedika.medifirst2000.converter.RekananConverter;
import com.jasamedika.medifirst2000.converter.RuanganConverter;
import com.jasamedika.medifirst2000.converter.StatusPerkawinanConverter;
import com.jasamedika.medifirst2000.converter.TitlePasienConverter;
import com.jasamedika.medifirst2000.dao.RegistrasiPelayananPasienDao;
import com.jasamedika.medifirst2000.dao.PasienDao;
import com.jasamedika.medifirst2000.dao.custom.AntrianPasienDiPeriksaDaoCustom;
import com.jasamedika.medifirst2000.dao.custom.PasienDaoCustom;
import com.jasamedika.medifirst2000.entities.Agama;
import com.jasamedika.medifirst2000.entities.Alamat;
import com.jasamedika.medifirst2000.entities.AntrianPasienDiPeriksa;
import com.jasamedika.medifirst2000.entities.AsalRujukan;
import com.jasamedika.medifirst2000.entities.CaraMasuk;
import com.jasamedika.medifirst2000.entities.DetailKamar;
import com.jasamedika.medifirst2000.entities.JenisAlamat;
import com.jasamedika.medifirst2000.entities.JenisKelamin;
import com.jasamedika.medifirst2000.entities.KasusPenyakit;
import com.jasamedika.medifirst2000.entities.Kecamatan;
import com.jasamedika.medifirst2000.entities.KelompokPasien;
import com.jasamedika.medifirst2000.entities.KelompokUmur;
import com.jasamedika.medifirst2000.entities.LoginUser;
import com.jasamedika.medifirst2000.entities.Lokasi;
import com.jasamedika.medifirst2000.entities.Negara;
import com.jasamedika.medifirst2000.entities.Pasien;
import com.jasamedika.medifirst2000.entities.PasienDaftar;
import com.jasamedika.medifirst2000.entities.Pegawai;
import com.jasamedika.medifirst2000.entities.Pekerjaan;
import com.jasamedika.medifirst2000.entities.Pendidikan;
import com.jasamedika.medifirst2000.entities.Propinsi;
import com.jasamedika.medifirst2000.entities.RegistrasiPelayananPasien;
import com.jasamedika.medifirst2000.entities.Rekanan;
import com.jasamedika.medifirst2000.entities.Ruangan;
import com.jasamedika.medifirst2000.entities.StatusPerkawinan;
import com.jasamedika.medifirst2000.entities.TitlePasien;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PasienService;
import com.jasamedika.medifirst2000.service.RegistrasiMasukRuanganService;
import com.jasamedika.medifirst2000.service.RegistrasiPasienService;
import com.jasamedika.medifirst2000.vo.AgamaVO;
import com.jasamedika.medifirst2000.vo.AlamatVO;
import com.jasamedika.medifirst2000.vo.AntrianPasienDiPeriksaVO;
import com.jasamedika.medifirst2000.vo.JenisAlamatVO;
import com.jasamedika.medifirst2000.vo.JenisKelaminVO;
import com.jasamedika.medifirst2000.vo.KelompokUmurVO;
import com.jasamedika.medifirst2000.vo.NegaraVO;
import com.jasamedika.medifirst2000.vo.PasienVO;
import com.jasamedika.medifirst2000.vo.PekerjaanVO;
import com.jasamedika.medifirst2000.vo.PendidikanVO;
import com.jasamedika.medifirst2000.vo.PropinsiVO;
import com.jasamedika.medifirst2000.vo.RegistrasiMasukRuanganVO;
import com.jasamedika.medifirst2000.vo.RegistrasiPasienVO;
import com.jasamedika.medifirst2000.vo.ReservasiPasienVO;
import com.jasamedika.medifirst2000.vo.StatusPerkawinanVO;
import com.jasamedika.medifirst2000.vo.TitlePasienVO;


/**
 * Implement class for RegistrasiPasienService
 * 
 * @author Askur
 * @param <T>
 */
@Service("registrasiMasukRuanganService")
public class RegistrasiMasukRuanganServiceImpl extends BaseVoServiceImpl implements RegistrasiMasukRuanganService<RegistrasiMasukRuanganVO> {

	@Autowired
	private RegistrasiPelayananPasienDao registrasiPelayananPasienDao;

//	@Autowired
//	private AntrianPasienDiPeriksaDaoCustom antrianPasienDiPeriksaDaoCustom;
	
	@Autowired
	private AntrianPasienDiPeriksaConverter antrianPasienDiPeriksaConverter;
	@Autowired
	private CaraMasukConverter caraMasukConverter;
	@Autowired
	private KasusPenyakitConverter kasusPenyakitConverter;
	@Autowired
	private KelompokPasienConverter kelompokPasienConverter;
	@Autowired
	private RuanganConverter ruanganConverter;
	@Autowired
	private AsalRujukanConverter asalRujukanConverter;
	@Autowired
	private DetailKamarConverter detailKamarConverter;
	@Autowired
	private PasienDaftarConverter pasienDaftarConverter;
	@Autowired
	private PasienConverter pasienConverter;
	
	@Autowired
	private RegistrasiPelayananPasienConverter registrasiPelayananPasienConverter;
	
	@Override
	public List<RegistrasiMasukRuanganVO> getListAntrianPasienDiPeriksa() {
	/*	List<AntrianPasienDiPeriksa> models=antrianPasienDiPeriksaDaoCustom.findAllAntrianPasienDiPeriksa();
		List<AntrianPasienDiPeriksaVO> vos=new ArrayList<AntrianPasienDiPeriksaVO>();
		antrianPasienDiPeriksaConverter.transferListOfModelToListOfVO(models, vos); */
		List<RegistrasiMasukRuanganVO> list=new ArrayList<RegistrasiMasukRuanganVO>();/*
		for(AntrianPasienDiPeriksaVO antrianPasienDiPeriksa:vos){
			RegistrasiMasukRuanganVO registrasiMasukRuangan=new RegistrasiMasukRuanganVO();
			registrasiMasukRuangan.setAntrianPasienDiPeriksa(antrianPasienDiPeriksa);
			registrasiMasukRuangan.setPasienDaftar(antrianPasienDiPeriksa.getPasienDaftar());
			registrasiMasukRuangan.setPasien(antrianPasienDiPeriksa.getPasienDaftar().getPasien());
			
		}*/
		return list;
	}

	@Override
	public RegistrasiMasukRuanganVO add(RegistrasiMasukRuanganVO vo) throws JpaSystemException, ServiceVOException {
		RegistrasiPelayananPasien model=new RegistrasiPelayananPasien();
		registrasiPelayananPasienConverter.transferVOToModel(vo.getRegistrasiPelayananPasien(), model);
	//	model.setCaraMasuk(caraMasukConverter.transferVOToModel(vo.getCaraMasuk(), new CaraMasuk()));
		model.setKasusPenyakit(kasusPenyakitConverter.transferVOToModel(vo.getKasusPenyakit(), new KasusPenyakit()));
		model.setKelompokPasien(kelompokPasienConverter.transferVOToModel(vo.getKelompokPasien(), new KelompokPasien()));
		model.setRuangan(ruanganConverter.transferVOToModel(vo.getRuangan(), new Ruangan()));
		model.setRuanganAsal(ruanganConverter.transferVOToModel(vo.getRuangan(), new Ruangan()));
		model.setAsalRujukan(asalRujukanConverter.transferVOToModel(vo.getAsalRujukan(), new AsalRujukan()));
		//model.setKdKelas(detailKamarConverter.transferVOToModel(vo.getKdKelas(), new DetailKamar()));	
		model.setPasienDaftar(pasienDaftarConverter.transferVOToModel(vo.getPasienDaftar(), new PasienDaftar()));
		//model.setNoCm(pasienConverter.transferVOToModel(vo.getPasien(), new Pasien()));
		model.setStatusPasien((byte)1);
		model.setTglMasuk(new Date());
		RegistrasiPelayananPasien resultModel = registrasiPelayananPasienDao.save(model);
		RegistrasiMasukRuanganVO resultVo=new RegistrasiMasukRuanganVO();

		return resultVo;
	}

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

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

	@Override
	public RegistrasiMasukRuanganVO findById(Integer key) throws JpaSystemException {
		return null;
	}

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

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


}
