package com.fs.hospital.service.impl;

import java.util.List;

import com.alibaba.fastjson.JSON;
import com.fs.common.core.domain.R;
import com.fs.common.utils.DateUtils;
import com.fs.hospital.domain.HospitalPatient;
import com.fs.hospital.param.HospitalInspectOrderParam;
import com.fs.hospital.vo.HospitalInspectOrderVO;
import com.fs.voice.utils.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fs.hospital.mapper.HospitalInspectOrderMapper;
import com.fs.hospital.domain.HospitalInspectOrder;
import com.fs.hospital.service.IHospitalInspectOrderService;

/**
 * 检查单Service业务层处理
 *
 * @author fs
 * @date 2024-03-26
 */
@Service
public class HospitalInspectOrderServiceImpl implements IHospitalInspectOrderService
{
    @Autowired
    private HospitalInspectOrderMapper hospitalInspectOrderMapper;

    /**
     * 查询检查单
     *
     * @param orderId 检查单主键
     * @return 检查单
     */
    @Override
    public R selectHospitalInspectOrderVOByOrderId(Long orderId)
    {

        HospitalInspectOrderVO hospitalInspectOrderVO = hospitalInspectOrderMapper.selectHospitalInspectOrderVOByOrderId(orderId);
        return R.ok().put("order",hospitalInspectOrderVO);
    }

    /**
     * 查询检查单列表
     *
     * @param param 检查单参数
     * @return 检查单
     */
    @Override
    public List<HospitalInspectOrderVO> selectHospitalInspectOrderListVO(HospitalInspectOrderParam param) {

        return hospitalInspectOrderMapper.selectHospitalInspectOrderListVO(param);
    }


    /**
     * 修改检查单
     *
     * @param hospitalInspectOrder 检查单
     * @return 结果
     */
    @Override
    public int updateHospitalInspectOrder(HospitalInspectOrder hospitalInspectOrder)
    {
        hospitalInspectOrder.setUpdateTime(DateUtils.getNowDate());
        hospitalInspectOrder.setStatus(2);
        //当图片地址为""时，制为null。
        if (StringUtil.strIsNullOrEmpty(hospitalInspectOrder.getImages())){
            hospitalInspectOrder.setImages(null);
        }
        return hospitalInspectOrderMapper.updateHospitalInspectOrder(hospitalInspectOrder);
    }


}
