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

import com.google.common.collect.Lists;
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.label.DiagLabel;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName : BEH03007
 * @Description : 待查病例未列出可能性较大诊断
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class BEH03007 extends QCCatalogue {

    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        if (inputInfo.getBeHospitalizedDoc() == null) {
            status.set("0");
            return;
        }
        DiagLabel initialDiagLabel = inputInfo.getBeHospitalizedDoc().getInitialDiagLabel();
        if (initialDiagLabel == null || StringUtil.isBlank(initialDiagLabel.getText())) {
            status.set("0");
            return;
        }

        List<String> diags = Lists.newArrayList(initialDiagLabel.getText().split("\n"));
        String firstDiag = diags.get(0);
        if (!firstDiag.endsWith("待查")) {
            status.set("0");
            return;
        }

        if (diags.size() > 1) {
            status.set("0");
            return;
        }
    }

}