package com.fs.app.controller;

import com.fs.common.core.domain.R;
import com.fs.his.param.FsDiagnosisFillDParam;
import com.fs.his.param.FsDiagnosisListDParam;
import com.fs.his.service.IFsFirstDiagnosisService;
import com.fs.his.vo.FsDiagnosisListDVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/app/diagnosis")
public class DiagnosisController extends AppBaseController{

    @Autowired
    private IFsFirstDiagnosisService diagnosisService;

    @GetMapping("/getDiagnosisList")
    public R getDiagnosisList(FsDiagnosisListDParam param){
        param.setDoctorId(Long.parseLong(getDoctorId()));
        PageHelper.startPage(param.getPageNum(), param.getPageSize());
        List<FsDiagnosisListDVO> diagnosisList = diagnosisService.getDiagnosisList(param);
        PageInfo<FsDiagnosisListDVO> pageInfo = new PageInfo<>(diagnosisList);
        return R.ok().put("data", pageInfo);
    }

    @PutMapping("/fill")
    public R fill(@RequestBody FsDiagnosisFillDParam param){
        param.setDoctorId(Long.parseLong(getDoctorId()));
        return diagnosisService.fill(param);
    }

    @GetMapping("/{id}")
    public R detail(@PathVariable("id") Long id){
        return R.ok().put("data", diagnosisService.selectFsFirstDiagnosisById(id));
    }
}
