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.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 : BEH0075
 * @Description : 类似疾病史未描述
 * @Author : 胡敬
 * @Date: 2020-03-11 17:37
 */
@Component
public class BEH0075 extends QCCatalogue {
    @Override
    protected void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getBeHospitalizedDoc() != null && inputInfo.getBeHospitalizedDoc().getFamilyLabel() != null) {
            FamilyLabel familyLabel = inputInfo.getBeHospitalizedDoc().getFamilyLabel();
            List<Family> families = familyLabel.getFamilies();
            if (ListUtil.isEmpty(families)) {
                return;
            }
            boolean findSimilarDiag = false;
            for (Family family : families) {
                if (family.getSimilarDiag() != null && StringUtil.isNotBlank(family.getSimilarDiag().getName())) {
                    findSimilarDiag = true;
                    break;
                }
            }
            if (!findSimilarDiag){
                status.set("-1");
            }
        }
    }
}