package com.docus.server.mzzyy.controller;


import com.docus.infrastructure.web.api.CommonResult;
import com.docus.server.rpc.MzZyyLisService;
import com.docus.server.rpc.MzZyyShouMaService;
import com.docus.server.rpc.dto.MzZyyLisExportDto;
import com.docus.server.rpc.dto.MzZyyShouMaMedicalDocumentFileForBase64Dto;
import com.docus.server.rpc.dto.MzZyyShouMaMedicalDocumentInfoDto;
import com.docus.server.rpc.dto.MzZyyShouMaQueryMedicalDocumentInfoDto;
import com.docus.server.rpc.dto.MzZyyTestDto;
import com.docus.server.rpc.enums.MzZyyLisType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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;

/**
 * api测试类
 */
@RestController
@RequestMapping("/mzzyyApi")
@Api(tags = "梅州中医院文件采集接口")
public class MzZyyApiController {
    @Autowired
    private MzZyyLisService mzZyyLisService;
    @Autowired
    private MzZyyShouMaService mzZyyShouMaService;


    /**
     * 测试
     */
    @GetMapping("/lis/getpdftest")
    @ApiOperation("获取lis报告列表接口测试")
    public CommonResult<Object> getpdftest(@RequestParam(name = "jzh") String jzh,
                                           @RequestParam(name = "inpatientNo") String inpatientNo,
                                           @RequestParam(name = "patientType") String patientType) {
        List<MzZyyTestDto> list = mzZyyLisService.getTestFormPdf(jzh, inpatientNo, patientType);
        return CommonResult.success(list);
    }

    /**
     * 补采
     */
    @GetMapping("/lis/base64test")
    @ApiOperation("获取lis报告base64接口测试")
    public CommonResult<Object> base64test(@RequestParam(name = "type") String type,
                                           @RequestParam(name = "machineId") String machineId,
                                           @RequestParam(name = "sampleId") String sampleId,
                                           @RequestParam(name = "testdate") String testdate) {
        MzZyyLisType mzZyyLisType = MzZyyLisType.getLisType(type);
        List<MzZyyLisExportDto> files = mzZyyLisService.exportTestFormPdf(mzZyyLisType, machineId, sampleId, testdate);
        return CommonResult.success(files);
    }


    /**
     * 测试
     */
    @GetMapping("/shouma/getMedicalDocumentFileForBase64Test")
    @ApiOperation("手麻文书base64获取测试")
    public CommonResult<Object> getMedicalDocumentFileForBase64Test(@RequestParam(name = "reportNo") String reportNo) {
        MzZyyShouMaMedicalDocumentFileForBase64Dto fileForBase64 = mzZyyShouMaService.getMedicalDocumentFileForBase64(reportNo);
        return CommonResult.success(fileForBase64);
    }

    /**
     * 测试
     */
    @GetMapping("/shouma/queryMedicalDocumentInfoListTest")
    @ApiOperation("手麻文书信息列表获取测试")
    public CommonResult<Object> queryMedicalDocumentInfoListTest(@RequestParam(name = "jzh") String jzh,
                                                             @RequestParam(name = "hospCode") String hospCode,
                                                             @RequestParam(name = "branchCode") String branchCode) {
        MzZyyShouMaQueryMedicalDocumentInfoDto mzZyyShouMaQueryMedicalDocumentInfoDto = new MzZyyShouMaQueryMedicalDocumentInfoDto();
        mzZyyShouMaQueryMedicalDocumentInfoDto.setHospCode(hospCode);
        mzZyyShouMaQueryMedicalDocumentInfoDto.setBranchCode(branchCode);
        mzZyyShouMaQueryMedicalDocumentInfoDto.setInPatientSeqNo(jzh);
        MzZyyShouMaMedicalDocumentInfoDto mzZyyShouMaMedicalDocumentInfoDto = mzZyyShouMaService.queryMedicalDocumentInfoList(mzZyyShouMaQueryMedicalDocumentInfoDto);
        return CommonResult.success(mzZyyShouMaMedicalDocumentInfoDto);
    }


    public static void main(String[] args) {
        System.out.println(new MzZyyLisExportDto());
    }
}
