package com.lantone.qc.kernel.catalogue.behospitalized;

import com.lantone.qc.kernel.catalogue.QCCatalogue;
import com.lantone.qc.pub.model.InputInfo;
import com.lantone.qc.pub.model.OutputInfo;
import com.lantone.qc.pub.model.entity.PD;
import com.lantone.qc.pub.model.label.ChiefLabel;
import com.lantone.qc.pub.util.ListUtil;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

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


/**
 * @ClassName : BEH02860
 * @Description :主诉时间应该为阿拉伯数字
 * @Author : 胡敬
 * @Date: 2020-04-29 09:57
 */
@Component
public class BEH02860 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        if (inputInfo.getBeHospitalizedDoc() == null) {
            status.set("0");
            return;
        }
        ChiefLabel chiefLabel = inputInfo.getBeHospitalizedDoc().getChiefLabel();
        if (chiefLabel == null || StringUtil.isBlank(chiefLabel.getText())) {
            status.set("0");
            return;
        }
        List<String> arabicNumList = Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7"
                , "8", "9");
        List<String> containList = Arrays.asList("零", "一", "二", "三", "四", "五", "六", "七"
                , "八", "九", "十", "百", "千");
        List<PD> pds = chiefLabel.getPds();
        if (ListUtil.isNotEmpty(pds)) {
            String name = null, value = null;
            for (PD pd : pds) {
                name = pd.getName();
                value = pd.getValue();
                if (name.contains("半")) {
                    continue;
                }
                for (String num : arabicNumList) {
                    if (StringUtil.isNotBlank(name) && name.contains(num)) {
                        status.set("0");
                        return;
                    }
                }
                for (String word : containList) {
                    if (StringUtil.isNotBlank(value) && value.contains(word)) {
                        return;
                    }
                    if (StringUtil.isNotBlank(name) && name.contains(word)) {
                        return;
                    }
                }
            }
        } else {
            status.set("0");
        }
    }
}
