package com.jasamedika.medifirst2000.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.entities.AsalProduk;
import com.jasamedika.medifirst2000.entities.JenisTarif;
import com.jasamedika.medifirst2000.entities.Kelas;
import com.jasamedika.medifirst2000.entities.KelompokPasien;
import com.jasamedika.medifirst2000.entities.KomponenHarga;
import com.jasamedika.medifirst2000.entities.Produk;
import com.jasamedika.medifirst2000.entities.Ruangan;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AssetService;
import com.jasamedika.medifirst2000.service.PelayananHargaStokDiskonService;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.AssetVO;

@RestController
@RequestMapping("/pelayanan-harga-stok-diskon")
public class PelayananHargaStokDiskonController extends LocaleController<AssetVO> {
	@Autowired
	private PelayananHargaStokDiskonService pelayananHargaStokDiskonService;
	
	private static final Logger LOGGER = LoggerFactory.getLogger(PelayananHargaStokDiskonController.class);
	
	@RequestMapping(value = "/get", method = RequestMethod.GET)
	public ResponseEntity<Map<String,Object>> getData(
			@RequestParam(value = "noRegistrasi", required = false) String noRegistrasi,
			@RequestParam(value = "kelompokPasienId", required = false) Integer kelompokPasienId,
			@RequestParam(value = "produkId", required = false) Integer produkId,
			@RequestParam(value = "asalProdukId", required = false) Integer asalProdukId,
			@RequestParam(value = "kelasId", required = false) Integer kelasId,
			@RequestParam(value = "ruanganId", required = false) Integer ruanganId,
			@RequestParam(value = "komponenHargaId", required = false) Integer komponenHargaId,
			@RequestParam(value = "jenisTarifId", required = false) Integer jenisTarifId,
			@RequestParam(value = "tglPelayanan", required = false) String tglPelayanan,
			@RequestParam(value = "orderStok", required = false) Double orderStok,
			@RequestParam(value = "cito", required = false) Integer cito) {
		Map<String,Object> result = new HashMap<String,Object>();
		KelompokPasien kelompokPasien=new KelompokPasien();
		kelompokPasien.setId(kelompokPasienId);
		Produk produk=new Produk();
		produk.setId(produkId);
		AsalProduk asalProduk=new AsalProduk();
		asalProduk.setId(asalProdukId);
		Kelas kelas=new Kelas();
		kelas.setId(kelasId);
		Ruangan ruangan=new Ruangan();
		ruangan.setId(ruanganId);
		JenisTarif jenisTarif=new JenisTarif();
		jenisTarif.setId(jenisTarifId);		
		result=pelayananHargaStokDiskonService.getHargaNettoStokDiskonBaru(kelompokPasien, produk, asalProduk, kelas, ruangan, jenisTarif, DateUtil.toDate(tglPelayanan),orderStok,cito);
		return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
	}
}
