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.doc.BeHospitalizedDoc;
import com.lantone.qc.pub.model.entity.General;
import com.lantone.qc.pub.model.entity.GeneralDesc;
import com.lantone.qc.pub.model.label.PresentLabel;
import com.lantone.qc.pub.util.ListUtil;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * @ClassName : BEH0444
 * @Description :  现病史缺少发病以来精神状态描述
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class BEH0444 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        BeHospitalizedDoc beHospitalizedDoc = inputInfo.getBeHospitalizedDoc();
        if (beHospitalizedDoc == null) {
            status.set("0");
            return;
        }
        PresentLabel presentLabel = beHospitalizedDoc.getPresentLabel();
        if (presentLabel != null) {
            List<String> words = Lists.newArrayList("神志", "神清", "神不清", "意识清", "意识不清", "昏迷","精神","意识");
            String presentLabelText = presentLabel.getText();
            if (StringUtil.isNotBlank(presentLabelText)) {
                for (String word : words) {
                    if (presentLabelText.contains(word)) {
                        status.set("0");
                        return;
                    }
                }
            }
            List<GeneralDesc> generals = presentLabel.getGenerals();
            List<General> gens = presentLabel.getGens();
            if (ListUtil.isEmpty(generals) && ListUtil.isEmpty(gens)) {
                status.set("0");
                return;
            }
            if (ListUtil.isNotEmpty(generals)) {
                for (GeneralDesc general : generals) {
                    for (String word : words) {
                        if (general.getName().contains(word)){
                            status.set("0");
                            return;
                        }
                    }
                }
            }

            if (ListUtil.isNotEmpty(gens)) {
                for (General general : gens) {
                    for (String word : words) {
                        if (general.getName().contains(word)){
                            status.set("0");
                            return;
                        }
                    }
                }
            }
        }
    }
}