package com.fs.app.controller;

import com.fs.app.annotation.Login;
import com.fs.common.core.domain.R;
import com.fs.course.param.DiagnosisConfirmParam;
import com.fs.course.param.FsFirstDiagnosisListUParam;
import com.fs.course.vo.FsFirstDiagnosisListUVO;
import com.fs.his.service.IFsFirstDiagnosisService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api("初诊单接口")
@RestController
@RequestMapping(value="/app/diagnosis")
public class DiagnosisController extends AppBaseController{

    @Autowired
    private IFsFirstDiagnosisService diagnosisService;


    @Login
    @ApiOperation("初诊单列表")
    @GetMapping("/getList")
    public R getList(FsFirstDiagnosisListUParam param) {
        PageHelper.startPage(param.getPageNum(), param.getPageSize());
        param.setUserId(Long.parseLong(getUserId()));
        List<FsFirstDiagnosisListUVO> fsFirstDiagnosisListUVOS = diagnosisService.selectFsFirstDiagnosisListUVO(param);
        PageInfo<FsFirstDiagnosisListUVO> pageInfo = new PageInfo<>(fsFirstDiagnosisListUVOS);
        return R.ok().put("data",pageInfo);
    }


    @ApiOperation("初诊单详情")
    @GetMapping("/getInfo")
    public R getInfo(@RequestParam("id") Long id) {
        FsFirstDiagnosisListUVO info = diagnosisService.getInfo(id);
        return R.ok().put("data",info);
    }

    @ApiOperation("确认初诊单")
    @PostMapping("/confirm")
    public R confirm(@RequestBody DiagnosisConfirmParam param) {
        return diagnosisService.confirm(param);
    }
}
