package com.diagbot.facade.his;

import com.diagbot.dto.RespDTO;
import com.diagbot.util.PushFeedbackConn;
import com.diagbot.util.StringUtil;
import com.diagbot.vo.his.FeedbackHosVO;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

@Component
@Slf4j
public class FeedbackHosFacade {

    PushFeedbackConn conn=new PushFeedbackConn();

    public RespDTO pushFeedback(FeedbackHosVO feedbackHosVO){
        try{
            if(StringUtil.isEmpty(feedbackHosVO.getBehospitalCode())){
                return RespDTO.onError("病历号为空");
            }else if(feedbackHosVO.getId()==null){
                return RespDTO.onError("病历反馈缺陷ID为空");
            }
            //其他情况新增
            conn.setQcMessAge(feedbackHosVO);

            return RespDTO.onSuc("推送缺陷反馈完成！");
        }catch (Exception e){
            log.error("=======推送缺陷反馈失败，请联系维护人员==========="+e.getMessage(),new Throwable());
            return RespDTO.onError("推送缺陷反馈失败，请联系维护人员！！！");
        }
    }

    public RespDTO updateFeedback(FeedbackHosVO feedbackHosVO){
        try{
            if(StringUtil.isEmpty(feedbackHosVO.getBehospitalCode())){
                return RespDTO.onError("病历号为空");
            }else if(feedbackHosVO.getId()==null){
                return RespDTO.onError("病历反馈缺陷ID为空");
            }
            //修改
            conn.UpdateQcMessAge(feedbackHosVO);
            return RespDTO.onSuc("推送缺陷反馈完成！");
        }catch (Exception e){
            log.error("=======推送缺陷反馈失败，请联系维护人员==========="+e.getMessage(),new Throwable());
            return RespDTO.onError("推送缺陷反馈失败，请联系维护人员！！！");
        }
    }

    public RespDTO deleteFeedback(FeedbackHosVO feedbackHosVO){
        try{
            if(StringUtil.isEmpty(feedbackHosVO.getBehospitalCode())){
                return RespDTO.onError("病历号为空");
            }else if(feedbackHosVO.getId()==null){
                return RespDTO.onError("病历反馈缺陷ID为空");
            }

            //his那边物理删除
            conn.DeleteQcMessAge(feedbackHosVO);
            return RespDTO.onSuc("推送缺陷反馈完成！");
        }catch (Exception e){
            log.error("=======推送缺陷反馈失败，请联系维护人员==========="+e.getMessage(),new Throwable());
            return RespDTO.onError("推送缺陷反馈失败，请联系维护人员！！！");
        }
    }

    public RespDTO<List<FeedbackHosVO>> statusQuery(FeedbackHosVO feedbackHosVO){
        try{
            //List<FeedbackHosVO>
            List<FeedbackHosVO> statusList=conn.statusQuery(feedbackHosVO);
            return RespDTO.onSuc(statusList);
        }catch (Exception e){
            return RespDTO.onError("获取状态异常！！");
        }

    }
}
