package com.diagbot.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.diagbot.dto.AverageStatisticsDTO;
import com.diagbot.dto.AverageStatisticsFeeDTO;
import com.diagbot.entity.HomePage;
import com.diagbot.mapper.HomePageMapper;
import com.diagbot.service.HomePageService;
import com.diagbot.vo.FilterPageByAverageVO;
import com.diagbot.vo.FilterPageVO;
import com.diagbot.vo.FilterVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhoutg
 * @since 2020-04-13
 */
@Service
public class HomePageServiceImpl extends ServiceImpl<HomePageMapper, HomePage> implements HomePageService {

    /**
     * 按科室统计平均住院天数
     *
     * @param filterVO
     * @return
     */
    @Override
    public List<AverageStatisticsDTO> getAverageDayNum(FilterVO filterVO) {
        return baseMapper.getAverageDayNum(filterVO);
    }

    /**
     * 按科室统计平均费用
     *
     * @param filterVO
     * @return
     */
    @Override
    public List<AverageStatisticsDTO> getAverageFee(FilterVO filterVO) {
        return baseMapper.getAverageFee(filterVO);
    }

    /**
     * 按科室统计平均住院天数（分页）
     *
     * @param filterPageByAverageVO
     * @return
     */
    @Override
    public IPage<AverageStatisticsDTO> getAverageDayNumPage(@Param("filterPageByAverageVO") FilterPageByAverageVO filterPageByAverageVO) {
        return baseMapper.getAverageDayNumPage(filterPageByAverageVO);
    }

    /**
     * 按科室统计平均费用（分页）
     *
     * @param filterPageByAverageVO
     * @return
     */
    public IPage<AverageStatisticsFeeDTO> getAverageFeePage(@Param("filterPageByAverageVO") FilterPageByAverageVO filterPageByAverageVO) {
        return baseMapper.getAverageFeePage(filterPageByAverageVO);
    }

    /**
     * 根据病案首页编码、医院编码、病人住院ID-批量更新
     * @param list
     */
    public void updateBatchByKey(List<HomePage> list){
        this.baseMapper.updateBatchByKey(list);
    }
}
