package com.diagbot.facade;

import com.diagbot.dto.DisDTO;
import com.diagbot.dto.DisTypeDTO;
import com.diagbot.enums.DisTypeEnum;
import com.diagbot.service.impl.DisTypeServiceImpl;
import com.diagbot.util.EntityUtil;
import com.diagbot.util.ListUtil;
import org.springframework.stereotype.Component;

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

/**
 * @Description: 诊断类型
 * @author: zhoutg
 * @time: 2018/11/19 13:19
 */
@Component
public class DisTypeFacade extends DisTypeServiceImpl {

    /**
     * 返回诊断类型
     *
     * @return
     */
    public DisTypeDTO getDisTypeFac() {
        DisTypeDTO res = new DisTypeDTO();
        List<DisDTO> data = this.getDisType();
        Map<String, List<DisDTO>> map = EntityUtil.makeEntityListMap(data, "type");
        if (map != null) {
            List<DisDTO> chr = map.get(DisTypeEnum.CHRONIC.getKey()); //放入慢病列表
            if (ListUtil.isNotEmpty(chr)) {
                res.setChronic(chr);
            }
            List<DisDTO> eme = map.get(DisTypeEnum.EMERGENCY.getKey()); //放入急诊列表
            if (ListUtil.isNotEmpty(eme)) {
                res.setEmergency(eme);
            }
        }
        return res;
    }
}
