package thyyxxk.webserver.service.medicaladvice.chaxunfenxi;

import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import thyyxxk.webserver.config.exception.BizException;
import thyyxxk.webserver.config.exception.ExceptionEnum;
import thyyxxk.webserver.dao.his.medicaladvice.chaxunfenxi.ArrearagePatientListDao;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.medicaladvice.medicamanage.chaxunfenxi.ArrearagePatientVO;
import thyyxxk.webserver.utils.AssertUtil;
import thyyxxk.webserver.utils.ResultVoUtil;

import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @Author:lihong
 * @Date: 2023/6/16
 */
@Slf4j
@Service
public class ArrearagePatientListService {
    @Autowired
    private ArrearagePatientListDao dao;

    public ResultVo<List<Map<String,Object>>> queryResponceType() {
      return ResultVoUtil.success(dao.listResponceType());
    }

    public ResultVo<List<ArrearagePatientVO>> queryArrearagePatientVO(ArrearagePatientVO param){
        AssertUtil.isnotBlank(param.getWard(),"科室不能为空");
        if(StrUtil.isBlank(param.getQfdx())){
            param.setQfdx("0");
        }
        if(!NumberUtil.isNumber(param.getQfdx())){
            throw new BizException(ExceptionEnum.INTERNAL_SERVER_ERROR, "欠费底线请输入数字");
        }
        if(StrUtil.isBlank(param.getResponceType())){
            param.setResponceType("%");
        }
        return ResultVoUtil.success(dao.listArrearagePatientVO(param));
    }

}
