package com.docus.server.message.controller;

import com.docus.infrastructure.web.api.CommonResult;
import com.docus.server.message.busservice.SdBusinessService;
import com.docus.server.message.controller.vo.SdRyBloodReportVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author WYBDEV
 */
@Api("顺德人医医院")
@RestController
@Slf4j
@RequestMapping("/hospital/sdRy")
public class SdRyHospitalController {

    @Autowired
    private SdBusinessService sdBusinessService;


    @ApiOperation("确认患者是否重症病人，并标识重症病人状态,住院号+住院次数")
    @GetMapping("/confirmAndupdIcuRecordState")
    public CommonResult<String> confirmAndUpdIcuRecordState(@RequestParam("inpatientNo") String inpatientNo, @RequestParam("admissTimes") Integer admissTimes) {
        log.info("顺德人医，同步患者是否重症病人，住院号:{},住院次数：{}", inpatientNo, admissTimes);
        sdBusinessService.confirmAndUpdIcuRecordState(inpatientNo, admissTimes);
        return CommonResult.success("成功！");
    }


    @ApiOperation("根据病案号查询输血报告单视图")
    @GetMapping("/getBloodView")
    public CommonResult<List<SdRyBloodReportVO>> getBloodView(@RequestParam("inpatientNo") String inpatientNo, @RequestParam("admissTimes") Integer admissTimes) {
        log.info("顺德人医，查询输血报告视图，住院号:{},住院次数：{}", inpatientNo, admissTimes);
        List<SdRyBloodReportVO> vos = sdBusinessService.getBloodView(inpatientNo, admissTimes);
        return CommonResult.success(vos);
    }

    @ApiOperation("根据病案主键，保存患者门诊交叉索引，门诊号")
    @GetMapping("/trInpatientOutPatient")
    public CommonResult<String> trInpatientOutPatient(@RequestParam("patientId") String patientId) {
        log.info("顺德人医，根据病案主键，保存患者门诊交叉索引，门诊号，patientId:{}", patientId);
        sdBusinessService.trInpatientOutPatient(patientId);
        return CommonResult.success("完成");
    }
}
