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.entity.Family;
import com.lantone.qc.pub.model.label.FamilyLabel;
import com.lantone.qc.pub.util.ListUtil;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName : BEH0074
 * @Description : 两系三代内是否有肿瘤病史未描述
 * @Author : 胡敬
 * @Date: 2020-03-11 17:05
 */
@Component
public class BEH0074 extends QCCatalogue {
    @Override
    protected void start(InputInfo inputInfo, OutputInfo outputInfo) {
        if (inputInfo.getBeHospitalizedDoc() == null) {
            status.set("0");
            return;
        }
        FamilyLabel familyLabel = inputInfo.getBeHospitalizedDoc().getFamilyLabel();
        if (familyLabel == null) {
            status.set("0");
            return;
        }
        String familyText = familyLabel.getText();
        if (StringUtil.isNotBlank(familyText) && (familyText.contains("瘤") || familyText.contains("癌"))) {
            status.set("0");
            return;
        }
        List<Family> families = familyLabel.getFamilies();
        if (ListUtil.isEmpty(families)) {
            status.set("0");
            return;
        }
        for (Family family : families) {
            if (family.getTumour() != null) {
                status.set("0");
                return;
            }
            for (Diag diag : family.getDiags()) {
                if (diag.getNegative() == null &&
                        (diag.getHospitalDiagName().contains("肿瘤") || diag.getHospitalDiagName().contains("癌"))) {
                    status.set("0");
                    return;
                }
            }

        }

    }
}