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.Diag;
import com.lantone.qc.pub.model.label.ChiefLabel;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.Iterator;
import java.util.List;


/**
 * @ClassName : BEH0010
 * @Description : 主诉中出现诊断名称（病理确诊：如肿瘤疾病、再入院除外）
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class BEH0010 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) {
            status.set("0");
            return;
        }
        List<Diag> diags = chiefLabel.getDiags();
        if (diags != null && diags.size() > 0) {
            Iterator<Diag> diagIterator = diags.iterator();
            while (diagIterator.hasNext()) {
                Diag diag = diagIterator.next();
                String diagName = diag.getHospitalDiagName();
                if (diagName.contains("癌") || diagName.contains("瘤") || diagName.contains("复诊") || diagName.contains("术后")) {
                    diagIterator.remove();
                }
            }
        }
        if (diags != null && diags.size() > 0) {
            status.set("-1");
            for (Diag diag : diags) {
                if (StringUtils.isEmpty(info.get())) {
                    info.set(diag.getName());
                } else {
                    info.set(info.get() + "," + diag.getName());
                }
            }
        }

    }
}