package com.yihu.figure.controller.data;

import com.yihu.figure.controller.BaseController;
import com.yihu.figure.service.data.DataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
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;

/**
 * Created by chenweida on 2017/3/6.
 */

@RestController
@RequestMapping(value = "/data", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "数据爬取")
public class DataController extends BaseController {
    @Autowired
    private DataService dataService;

    /**
     * 根据健康卡号抓取数据某个病人的全部就诊事件列表接口
     * /smjk/GetResidentEventListJson
     *
     * @param strSSID 健康卡号
     * @return
     */
    @ApiOperation(value = "根据健康卡号抓取数据某个病人的全部就诊事件")
    @RequestMapping(value = "getResidentEventListJson", method = RequestMethod.GET)
    public String getResidentEventListJson(
            @ApiParam(name = "strSSID", value = "健康卡号", required = true) @RequestParam(value = "strSSID", required = true) String strSSID) {
        try {
            String data = dataService.getResidentEventListJson(strSSID);
            return data;
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    /**
     * 根据健康卡号抓取数据某个病人的全部检查检验事件
     * /smjk/GetResidentEventListJson
     *
     * @param strSSID 健康卡号
     * @return
     */
    @ApiOperation(value = "根据健康卡号抓取数据某个病人的全部检查检验事件")
    @RequestMapping(value = "GetRecordListByCatalogcodesJson", method = RequestMethod.GET)
    public String GetRecordListByCatalogcodesJson(
            @ApiParam(name = "strSSID", value = "健康卡号", required = true) @RequestParam(value = "strSSID", required = true) String strSSID) {
        try {
            String data = dataService.GetRecordListByCatalogcodesJson(strSSID);
            return data;
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
}
