package com.diagbot.facade;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.diagbot.dto.*;
import com.diagbot.exception.CommonErrorCode;
import com.diagbot.exception.CommonException;
import com.diagbot.service.impl.MedLisInfoServiceImpl;
import com.diagbot.util.DateUtil;
import com.diagbot.util.SysUserUtils;
import com.diagbot.vo.CheckInfoVO;
import com.diagbot.vo.ExamineInfoVO;
import com.diagbot.vo.ExamineSonInfoVO;
import org.springframework.stereotype.Component;


import com.diagbot.dto.DoctorAdviceDTO;
import org.springframework.stereotype.Component;

import java.text.ParseException;
import java.text.SimpleDateFormat;

/**
 * @Description:
 * @author: cy
 * @time: 2024/9/7 15:48
 */

@Component
public class MedLisInfoFacade extends MedLisInfoServiceImpl {
/**
     * 获取检验信息翻页
     *
     * @param examineInfoVO 获取检验信息入参
     * @return
     */

    public IPage<ExamineInfoDTO> getExaminePage(ExamineInfoVO examineInfoVO) {
        examineInfoVO.setHospitalId(Long.valueOf(SysUserUtils.getCurrentHospitalID()));
        if (null != examineInfoVO.getJyDateStart()) {
            examineInfoVO.setJyDateStart(DateUtil.getFirstTimeOfDay(examineInfoVO.getJyDateStart()));
          }
        if (null != examineInfoVO.getJyDateEnd()) {
            examineInfoVO.setJyDateEnd(DateUtil.getFirstTimeOfDay(DateUtil.addDay(examineInfoVO.getJyDateEnd(), 1)));
        }
        if (null != examineInfoVO.getJyDateStart() && null != examineInfoVO.getJyDateEnd()) {
            if (DateUtil.after(examineInfoVO.getJyDateStart(), examineInfoVO.getJyDateEnd())) {
                throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间必须小于结束时间！");
            }
        }
        return this.getExamineInfo(examineInfoVO);
    }

    /**
     * 获取检验子项信息
     * @param examineSonInfoVO 获取检验子项信息入参
     * @return
     */

    public IPage<ExamineSonInfoDTO> getExamineSonPage(ExamineSonInfoVO examineSonInfoVO)  {
       examineSonInfoVO.setHospitalId(Long.valueOf(SysUserUtils.getCurrentHospitalID()));
        return this.getExamineSonInfo(examineSonInfoVO);
    }

}
