package com.lantone.web.med;

import com.lantone.dto.med.IndexBatchDTO;
import com.lantone.dto.med.KllisDetailDTO;
import com.diagbot.dto.RespDTO;
import com.lantone.facade.med.KlConceptFacade;
import com.lantone.vo.med.ConceptVO;
import com.lantone.vo.med.FilterVO;
import com.lantone.vo.med.IndexByApprovalVO;
import com.lantone.vo.med.KllisDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @Author:zhaops
 * @time: 2020/8/12 16:45
 */
@RestController
@RequestMapping("/retrieval")
@Api(value = "术语检索相关API", tags = { "术语检索相关API" })
@SuppressWarnings("unchecked")
public class RetrievalController {

    @Autowired
    private KlConceptFacade klConceptFacade;


    @ApiOperation(value = "术语批量查询[zhaops]",
            notes = "type： 类型：1-化验大项、2-化验小项、3-辅检、4-诊断、5-药品、6-手术和操作、7-科室、8-输血、10-量表、11-护理、12-中医诊断、13-中医证候、14-麻醉、15-药品剂型、16-给药途径<br>" +
                    "ids： 术语id列表<br>" +
                    "names： 术语列表<br>" +
                    "source： 数据来源：-1-id匹配、1-标准词、2-同义词、3-编码、4-历史数据、5-相似词、99-数据迁移<br>")
    @PostMapping("/getConceptNames")
    public RespDTO<List<IndexBatchDTO>> getConceptNames(@Valid @RequestBody ConceptVO conceptVO) {
        List<IndexBatchDTO> data = klConceptFacade.getConceptNames(conceptVO);
        return RespDTO.onSuc(data);
    }

    @ApiOperation(value = "化验小项术语批量查询获取范围[gaodm]",
            notes = "names： 术语列表<br>")
    @PostMapping("/getLisDetaisByNames")
    public RespDTO<Map<String, KllisDetailDTO>> getLisDetaisByNames(@RequestBody KllisDetailVO kllisDetailVO) {
        return RespDTO.onSuc(klConceptFacade.getLisDetaisByNamesFac(kllisDetailVO));
    }

    @ApiOperation(value = "术语关联医学术语检索[zhaops]",
            notes = "inputStr： 检索内容<br>")
    @PostMapping("/filter")
    public RespDTO<List<IndexBatchDTO>> filter(@Valid @RequestBody FilterVO filterVO) {
        List<IndexBatchDTO> data = klConceptFacade.filter(filterVO);
        return RespDTO.onSuc(data);
    }

    /**
     * @param indexByApprovalVO
     * @return
     */
    @ApiOperation(value = "术语关联医学术语检索[zhaops]",
            notes = "approvalList： 国药准字列表<br>")
    @PostMapping("/indexByApproval")
    public RespDTO<List<IndexBatchDTO>> indexByApproval(@Valid @RequestBody IndexByApprovalVO indexByApprovalVO) {
        List<IndexBatchDTO> data = klConceptFacade.indexByApproval(indexByApprovalVO);
        return RespDTO.onSuc(data);
    }
}