package com.fs.app.controller;

import cn.hutool.core.bean.BeanUtil;
import com.fs.app.facade.Hospital580FacadeService;
import com.fs.hospital580.vo.MedicineSyncVo;
import com.fs.hospital580.vo.RefusePrescriptionVo;
import com.fs.hospital580.vo.ReviewPrescriptionVo;
import com.fs.hospital580.vo.req.Prescription580Req;
import lombok.extern.slf4j.Slf4j;
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;

/**
 * 580医院回调接口
 */
@RestController
@RequestMapping("/hospital580/sync")
@Slf4j
public class Hospital580CallbackController {

    @Autowired
    private Hospital580FacadeService hospital580FacadeService;

    /**
     * 4.14 同步药品信息接口回调
     */
    @PostMapping("/medicine")
    public void medicineSync(@RequestBody Object vo) {
        MedicineSyncVo req = BeanUtil.toBean(vo, MedicineSyncVo.class);
        hospital580FacadeService.medicineSync(req);
    }

    /**
     * 4.10 处方推送接口
     */
    @PostMapping("/prescription")
    public void prescription(@RequestBody Object vo) {
        Prescription580Req req = BeanUtil.toBean(vo, Prescription580Req.class);
        hospital580FacadeService.prescription(req);
    }
    /**
     * 4.15 医生拒绝开方推送接口
     */
    @PostMapping("/refusePrescription")
    public void refusePrescription(@RequestBody Object vo) {
        RefusePrescriptionVo req = BeanUtil.toBean(vo, RefusePrescriptionVo.class);
        hospital580FacadeService.refusePrescription(req);
    }

    /**
     * 4.13 处方药师审核
     */
    @PostMapping("/reviewPrescription")
    public void reviewPrescription(@RequestBody Object vo) {
        ReviewPrescriptionVo req = BeanUtil.toBean(vo, ReviewPrescriptionVo.class);
        hospital580FacadeService.reviewPrescription(req);
    }
}
