/*
 * Copyright ©2023 CJB-CNIT Team. All rights reserved
 */
package com.openhis.web.inhospitalnursestation.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import com.openhis.web.common.dto.PerformInfoDto;
import com.openhis.web.inhospitalnursestation.dto.AdviceExecuteParam;
import org.springframework.web.bind.annotation.*;

import com.core.common.core.domain.R;
import com.openhis.web.inhospitalnursestation.appservice.IAdviceProcessAppService;
import com.openhis.web.inhospitalnursestation.dto.AdmissionPageParam;
import com.openhis.web.inhospitalnursestation.dto.InpatientAdviceParam;

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

/**
 * 护士站医嘱处理 controller
 *
 * @author zwh
 * @date 2025-08-07
 */
@RestController
@RequestMapping("/nurse-station/advice-process")
@Slf4j
@AllArgsConstructor
public class AdviceProcessController {

    @Resource
    private IAdviceProcessAppService adviceProcessAppService;

    /**
     * 住院患者分页列表
     *
     * @param admissionPageParam 查询条件
     * @param pageNo 当前页码
     * @param pageSize 查询条数
     * @param searchKey 模糊查询关键字
     * @param request 请求数据
     * @return 住院患者分页列表
     */
    @GetMapping(value = "/inpatient")
    public R<?> getInpatientPage(AdmissionPageParam admissionPageParam,
        @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
        @RequestParam(name = "searchKey", required = false) String searchKey, HttpServletRequest request) {
        return adviceProcessAppService.getInpatientPage(admissionPageParam, pageNo, pageSize, searchKey, request);
    }

    /**
     * 住院患者医嘱查询
     *
     * @param inpatientAdviceParam 查询条件
     * @param pageNo 当前页码
     * @param pageSize 查询条数
     * @return 住院患者医
     */
    @GetMapping(value = "/inpatient-advice")
    public R<?> getInpatientAdvicePage(InpatientAdviceParam inpatientAdviceParam,
        @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        return adviceProcessAppService.getInpatientAdvicePage(inpatientAdviceParam, pageNo, pageSize);
    }

    /**
     * 医嘱校对通过
     *
     * @param performInfoList 医嘱信息集合
     * @return 操作结果
     */
    @PutMapping(value = "/advice-verify")
    public R<?> adviceVerify(@RequestBody List<PerformInfoDto> performInfoList) {
        return adviceProcessAppService.adviceVerify(performInfoList);
    }

    /**
     * 医嘱退回
     *
     * @param performInfoList 医嘱信息集合
     * @return 操作结果
     */
    @PutMapping(value = "/advice-reject")
    public R<?> adviceReject(@RequestBody List<PerformInfoDto> performInfoList) {
        return adviceProcessAppService.adviceReject(performInfoList);
    }

    /**
     * 医嘱执行
     *
     * @param adviceExecuteParam 医嘱执行参数
     * @return 操作结果
     */
    @PostMapping(value = "/advice-execute")
    public R<?> adviceExecute(@RequestBody AdviceExecuteParam adviceExecuteParam) {
        return adviceProcessAppService.adviceExecute(adviceExecuteParam);
    }

    /**
     * 医嘱取消执行
     *
     * @param adviceExecuteParam 取消执行参数
     * @return 操作结果
     */
    @PutMapping(value = "/advice-cancel")
    public R<?> adviceCancel(@RequestBody AdviceExecuteParam adviceExecuteParam) {
        return adviceProcessAppService.adviceCancel(adviceExecuteParam);
    }

    /**
     * 医嘱不执行
     *
     * @param adviceExecuteParam 不执行参数
     * @return 操作结果
     */
    @PutMapping(value = "/advice-void")
    public R<?> adviceVoid(@RequestBody AdviceExecuteParam adviceExecuteParam) {
        return adviceProcessAppService.adviceVoid(adviceExecuteParam);
    }
}
