package cn.sh.stc.sict.theme.hphy.util;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.sh.stc.sict.cloud.common.core.constant.Constant;
import cn.sh.stc.sict.theme.hphy.model.HphyGuideRecord;
import cn.sh.stc.sict.theme.hphy.model.HphyPatientBase;
import cn.sh.stc.sict.theme.hphy.vo.LabelVO;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Slf4j
@UtilityClass
public class GuideUtil {
    public List<LabelVO> getPatientList(HphyPatientBase patient, HphyGuideRecord guide) {
        List<LabelVO> result = new ArrayList<>();
        if (ObjectUtil.isNotNull(patient)) {
            if (StrUtil.isNotBlank(patient.getCurrentAddress())) {
                result.add(new LabelVO(patient.getCurrentAddress(), Constant.BYTE_YES));
            }
            if (StrUtil.isNotBlank(patient.getAge())) {
                result.add(new LabelVO("年龄：" + patient.getAge(), Constant.BYTE_YES));
            }
            if (StrUtil.isNotBlank(patient.getGender())) {
                result.add(new LabelVO("性别：" + patient.getGender(), Constant.BYTE_YES));
            }
//            if(StrUtil.isNotBlank(patient.getCondition())){
//                result.add(new LabelVO(patient.getCondition(), Constant.BYTE_YES));
//            }
//            if(StrUtil.isNotBlank(patient.getDisease())){
//                result.add(new LabelVO(patient.getDisease(), Constant.BYTE_YES));
//            }
        }
        if (ObjectUtil.isNotNull(guide)) {
            if (StrUtil.isNotBlank(guide.getDisease())) {
                String[] split = guide.getDisease().replace(StrUtil.BRACKET_START, "")
                        .replace(StrUtil.BRACKET_END, "")
                        .split(StrUtil.COMMA);
                for (String s : split) {
                    result.add(new LabelVO(StrUtil.trim(s), Constant.BYTE_YES));
                }
            }
        }
        return result;
    }

    public List<String> getPatientDisease(HphyGuideRecord guide) {
        List<String> result = new ArrayList<>();
        if (ObjectUtil.isNotNull(guide)) {
            if (StrUtil.isNotBlank(guide.getDisease())) {
//                String[] split = guide.getDisease().replace(StrUtil.BRACKET_START, "")
//                        .replace(StrUtil.BRACKET_END, "")
//                        .split(StrUtil.COMMA);
//                for (String s : split) {
//                    result.add(StrUtil.trim(s));
//                }

                result = new ArrayList<>(Arrays.asList(guide.getDisease().split(StringPool.SEMICOLON)));
            }
        }

        return result;
    }
}
