package com.openhis.web.datadictionary.controller;

import javax.annotation.Resource;

import com.openhis.web.basedatamanage.dto.LocationAddOrEditDto;
import com.openhis.web.datadictionary.dto.ICDCodeAddDto;
import com.openhis.web.datadictionary.dto.ICDCodeDto;
import com.openhis.web.datadictionary.dto.ICDCodeUpdateDto;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.core.common.core.domain.R;
import com.openhis.web.datadictionary.appservice.ICDCodeService;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping("/base-data-manage/ICD10")
@Slf4j
@AllArgsConstructor
public class ICDCodeController {

    @Resource
    private ICDCodeService iCDCodeService;

    /**
     * 查询icd10
     * @param searchKey
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping("/information-page") // 前端传回来的查询条件
    public R<?> getICDCodePage(@RequestParam(value = "searchKey", defaultValue = "") String searchKey,
        @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        return iCDCodeService.getICDCodePage(searchKey, pageNo, pageSize);
    }

    /**
     * 新增icd10
     * @param icdCodeAddDto
     * @return
     */
    @PostMapping("/add-icd-Information")
    public R<?> ICDInformation(@Validated @RequestBody ICDCodeAddDto icdCodeAddDto) {
        return iCDCodeService.addICDInformation(icdCodeAddDto);
    }

    /**
     * 删除icd10
     * @param glNo
     * @return
     */
    @DeleteMapping("/delete-icd-Information")
    public R<?> deleteICDInformation(@RequestParam String glNo) {
        return iCDCodeService.deleteICDInformation(glNo);
    }

    /**
     * 更新
     * @param icdCodeUpdateDto
     * @return
     */
    @PutMapping("/update-icd-Information")
    public R<?> saveOrUpdateICDInformation(@RequestBody ICDCodeUpdateDto icdCodeUpdateDto){
        return iCDCodeService.saveOrUpdateICDInformation(icdCodeUpdateDto);
    }


}
