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

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * @ClassName : BEH0009
 * @Description :主诉缺少主症状
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class BEH0009 extends QCCatalogue {
    private List<String> containList = Arrays.asList("检查", "术后", "药物", "发现", "误服", "确诊", "经", "异常", "诊断"
            , "示", "超", "伤", "术", "复查", "体检", "血透", "血液透析");

    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        if (inputInfo.getBeHospitalizedDoc() == null) {
            status.set("0");
            return;
        }
        ChiefLabel chiefLabel = inputInfo.getBeHospitalizedDoc().getChiefLabel();
        if (chiefLabel == null) {
            status.set("0");
            return;
        }
        String chiefText = chiefLabel.getText();
        if (StringUtil.isNotBlank(chiefText)) {
            for (String word : containList) {
                if (chiefText.contains(word)) {
                    status.set("0");
                    return;
                }
            }
            List<Clinical> clinicals = chiefLabel.getClinicals();
            if (clinicals != null && clinicals.size() > 0) {
                status.set("0");
                return;
            }
            List<Diag> diags = chiefLabel.getDiags();
            if (diags.size() > 0) {
                status.set("0");
                return;
            }
            if (diags != null && diags.size() > 0) {
                for (Diag diag : diags) {
                    String hospitalDiagName = diag.getHospitalDiagName();
                    if (hospitalDiagName.contains("术后") || hospitalDiagName.contains("癌") ||
                            hospitalDiagName.contains("瘤") || hospitalDiagName.contains("复诊")) {
                        status.set("0");
                        break;
                    }
                }
            }
        } else {
            status.set("0");
        }
    }
}