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

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

import java.util.List;
import java.util.regex.Pattern;


/**
 * @ClassName : BEH02860
 * @Description :主诉时间应该为阿拉伯数字
 * @Author : 胡敬
 * @Date: 2020-04-29 09:57
 */
@Component
public class BEH02860 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getBeHospitalizedDoc() == null) {
            return;
        }
        ChiefLabel chiefLabel = inputInfo.getBeHospitalizedDoc().getChiefLabel();
        if (chiefLabel == null) {
            return;
        }
        String regex = "[零一二三四五六七八九十百千]";
        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;
                }
                if (value != null && Pattern.matches(regex, value)) {
                    status.set("-1");
                    return;
                }
                if (name != null && Pattern.matches(regex, name)) {
                    status.set("-1");
                    return;
                }
            }
        }
    }
}