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

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

import com.core.common.core.domain.R;
import com.openhis.common.enums.ActivityDefCategory;
import com.openhis.web.regdoctorstation.appservice.IRequestFormManageAppService;
import com.openhis.web.regdoctorstation.dto.RequestFormSaveDto;

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

/**
 * 申请单管理 controller
 */
@RestController
@RequestMapping("/reg-doctorstation/request-form")
@Slf4j
@AllArgsConstructor
public class RequestFormManageController {

    private final IRequestFormManageAppService iRequestFormManageAppService;

    /**
     * 保存检查申请单
     * 
     * @param requestFormSaveDto 申请单保存dto
     * @return 结果
     */
    @PostMapping(value = "/save-check")
    public R<?> saveCheckRequestForm(@RequestBody RequestFormSaveDto requestFormSaveDto) {
        return iRequestFormManageAppService.saveRequestForm(requestFormSaveDto, ActivityDefCategory.TEST.getCode());
    }

    /**
     * 保存检验申请单
     *
     * @param requestFormSaveDto 申请单保存dto
     * @return 结果
     */
    @PostMapping(value = "/save-inspection")
    public R<?> saveInspectionRequestForm(@RequestBody RequestFormSaveDto requestFormSaveDto) {
        return iRequestFormManageAppService.saveRequestForm(requestFormSaveDto, ActivityDefCategory.PROOF.getCode());
    }

    /**
     * 保存输血申请单
     *
     * @param requestFormSaveDto 申请单保存dto
     * @return 结果
     */
    @PostMapping(value = "/save-blood-transfusion")
    public R<?> saveBloodTransfusionRequestForm(@RequestBody RequestFormSaveDto requestFormSaveDto) {
        return iRequestFormManageAppService.saveRequestForm(requestFormSaveDto,
            ActivityDefCategory.METACHYSIS.getCode());
    }

    /**
     * 保存手术申请单
     *
     * @param requestFormSaveDto 申请单保存dto
     * @return 结果
     */
    @PostMapping(value = "/save-surgery")
    public R<?> saveSurgeryRequestForm(@RequestBody RequestFormSaveDto requestFormSaveDto) {
        return iRequestFormManageAppService.saveRequestForm(requestFormSaveDto,
            ActivityDefCategory.PROCEDURE.getCode());
    }

    /**
     * 查询检查申请单
     * 
     * @param encounterId 就诊id
     * @return 检查申请单
     */
    @GetMapping(value = "/get-check")
    public R<?> getCheckRequestForm(@RequestParam Long encounterId) {
        return R.ok(iRequestFormManageAppService.getRequestForm(encounterId, ActivityDefCategory.TEST.getCode()));
    }

    /**
     * 查询检验申请单
     *
     * @param encounterId 就诊id
     * @return 检验申请单
     */
    @GetMapping(value = "/get-inspection")
    public R<?> getInspectionRequestForm(@RequestParam Long encounterId) {
        return R.ok(iRequestFormManageAppService.getRequestForm(encounterId, ActivityDefCategory.PROOF.getCode()));
    }

    /**
     * 查询输血申请单
     *
     * @param encounterId 就诊id
     * @return 输血申请单
     */
    @GetMapping(value = "/get-blood-transfusion")
    public R<?> getBloodTransfusionRequestForm(@RequestParam Long encounterId) {
        return R.ok(iRequestFormManageAppService.getRequestForm(encounterId, ActivityDefCategory.METACHYSIS.getCode()));
    }

    /**
     * 查询手术申请单
     *
     * @param encounterId 就诊id
     * @return 手术申请单
     */
    @GetMapping(value = "/get-surgery")
    public R<?> getSurgeryRequestForm(@RequestParam Long encounterId) {
        return R.ok(iRequestFormManageAppService.getRequestForm(encounterId, ActivityDefCategory.PROCEDURE.getCode()));
    }

}
