package com.yihu.wlyy.web.doctor.record;

import com.yihu.wlyy.service.third.jw.JwSmjkService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
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.ResponseBody;

/**
 *
 * @author HZY
 * @vsrsion 1.0
 * Created at 2016/10/17.
 */
@Controller
@RequestMapping(value = "/wlyy_service/patient_inspection", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端- 居民检查/检验记录")
public class InspectionController extends BaseController {

    @Autowired
    private JwSmjkService jwSmjkService;

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取检查/检验列表", produces = "application/json", notes = "获取检查/检验列表")
    public String inspectionList(
            @ApiParam(name = "strSSID", value = "健康卡号",defaultValue = "A0601003595X")
            @RequestParam(value = "strSSID") String strSSID,
            @ApiParam(name = "startNum", value = "需要获取的起始行数",defaultValue = "0")
            @RequestParam(value = "startNum") String startNum,
            @ApiParam(name = "endNum", value = "需要获取的结束的行数",defaultValue = "10")
            @RequestParam(value = "endNum") String endNum) {
        try {
            //TODO 检查/检验报告接口
            String result = jwSmjkService.getInspectionAndChecking(strSSID, startNum, endNum);
            if (result.startsWith("error")) {
                return write(200, result, "data", new JSONArray().toString());
            }
            return write(200, "获取检查/检验记录成功！", "data", result);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取检查/检验记录异常！");
        }
    }

}
