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

import org.springframework.web.bind.annotation.*;

import com.core.common.core.domain.R;
import com.openhis.web.jlau.appservice.IReviewPrescriptionRecordsAppService;
import com.openhis.web.jlau.dto.ReviewPrescriptionRecordsDto;

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

/**
 * 农大审方记录 controller
 */
@RestController
@RequestMapping("/jlau/review-prescription-records")
@Slf4j
@AllArgsConstructor
public class ReviewPrescriptionRecordsController {

    private final IReviewPrescriptionRecordsAppService iReviewPrescriptionRecordsAppService;

    /**
     * 审核处方
     * 
     * @param reviewPrescriptionRecordsDto 审方记录dto
     * @return 结果
     */
    @PostMapping(value = "/review-prescription")
    public R<?> reviewPrescription(@RequestBody ReviewPrescriptionRecordsDto reviewPrescriptionRecordsDto) {
        return iReviewPrescriptionRecordsAppService.reviewPrescription(reviewPrescriptionRecordsDto);
    }

    /**
     * 通过处方号查询审方记录
     * 
     * @param prescriptionNo 处方号
     * @return 审方记录
     */
    @GetMapping(value = "/review-by-prescription-no")
    public R<?> getReviewByPrescriptionNo(@RequestParam(value = "prescriptionNo") String prescriptionNo) {
        return iReviewPrescriptionRecordsAppService.getReviewByPrescriptionNo(prescriptionNo);
    }

    /**
     * 通过就诊id查询审方记录
     *
     * @param encounterId 就诊id
     * @return 审方记录
     */
    @GetMapping(value = "/review-by-encounter")
    public R<?> getReviewByEncounterId(@RequestParam(value = "encounterId") Long encounterId) {
        return iReviewPrescriptionRecordsAppService.getReviewByEncounterId(encounterId);
    }

}
