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.PD;
import com.lantone.qc.pub.model.label.PresentLabel;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * @ClassName : BEH0018
 * @Description :现病史症状缺少近期时间描述
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class BEH0018 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        if (inputInfo.getBeHospitalizedDoc() == null) {
            status.set("0");
            return;
        }
        PresentLabel presentLabel = inputInfo.getBeHospitalizedDoc().getPresentLabel();
        List<PD> pds = presentLabel.getPds();
        if (pds != null && pds.size() > 0) {
            for (PD pd : pds) {
                String pdName = pd.getName();
                if (StringUtil.isNotBlank(pdName)) {
                    if (pdName.contains("天") || pdName.contains("周") || pdName.contains("月")
                            || pdName.contains("时") || pdName.contains("秒") || pdName.contains("半年")
                            || pdName.contains("日") || pdName.contains("今") || pdName.contains("余年")
                            || pdName.contains("年") || pdName.contains("分") || isDate(pdName)) {
                        status.set("0");
                        break;
                    }
                }
            }
        }

    }

    private boolean isDate(String pdName) {
        String regex = "[0-9]{4}.?[0-9]{2}.?[0-9]{2}";
        return pdName.matches(regex);
    }
}

