package com.jasamedika.medifirst2000.controller;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.service.GenericViewService;
import com.jasamedika.medifirst2000.vo.GenericViewVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.OK;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;

/**
 * Controller class for Pengakjian Awal Gawat Darurat Business
 * 
 * @author Askur
 */
@RestController
@RequestMapping("/genericView")
@JsonIgnoreProperties(ignoreUnknown = true)
public class GenericViewController extends LocaleController<GenericViewVO> {

	@Autowired
	private GenericViewService<GenericViewVO> papGenericViewService;

	@RequestMapping(value = "/StatusAdaTidakAda", method = GET, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
	public ResponseEntity<List<GenericViewVO>> findAdaTidakAda(HttpServletRequest request) {
		List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("yaTidak");
		return getJsonResponse(list, OK);
	}

	@RequestMapping(value = "/StatusRegulerIrreguler", method = GET, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
	public ResponseEntity<List<GenericViewVO>> findByRegulerIrreguler(HttpServletRequest request) {
		List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("regulerIrreguler");
		return getJsonResponse(list, OK);
	}

	@RequestMapping(value = "/StatusNormalTidakNormal", method = GET, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
	public ResponseEntity<List<GenericViewVO>> findByNormalTidakNormal(HttpServletRequest request) {
		List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("normalTidakNormal");
		return getJsonResponse(list, OK);
	}

	@RequestMapping(value = "/DataAlatBantuNafas", method = GET, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
	public ResponseEntity<List<GenericViewVO>> findByAlatBantuNafas(HttpServletRequest request) {
		List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("alatBantuNafas");
		return getJsonResponse(list, OK);
	}

}
