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

import java.util.List;

/**
 * @Description: 外伤史描述不完整
 * @author: rengb
 * @time: 2020/3/10 14:02
 */
@Component
public class BEH0037 extends QCCatalogue {

    @Override
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getBeHospitalizedDoc() == null) {
            return;
        }
        PastLabel pastLabel = inputInfo.getBeHospitalizedDoc().getPastLabel();
        if (pastLabel == null) {
            return;
        }
        List<Wound> wounds = pastLabel.getWounds();
        if (ListUtil.isEmpty(wounds)) {
            return;
        }
        for (Wound wound : wounds) {
            if (wound == null || StringUtil.isBlank(wound.getName())) {
                continue;
            }
            if ((wound.getNegative() == null || StringUtil.isBlank(wound.getNegative().getName()))
                    && (wound.getPd() == null || StringUtil.isBlank(wound.getPd().getName()))
                    && (wound.getBodyPart() == null || StringUtil.isBlank(wound.getBodyPart().getName()))
                    && (wound.getDegree() == null || StringUtil.isBlank(wound.getDegree().getName()))
                    && (wound.getTreat() == null || StringUtil.isBlank(wound.getTreat().getName()))
                    && (wound.getOperation() == null || StringUtil.isBlank(wound.getOperation().getName()))) {
                info.set(info.get() + wound.getName() + " ");
            }
        }
        //硬规则匹配
        String pastLabelText = pastLabel.getText();
        if (StringUtil.isNotBlank(pastLabelText) && pastLabelText.contains("外伤")) {
            status.set("0");
            return;
        }
        if (StringUtil.isNotBlank(info.get())) {
            status.set("-1");
        }
    }

}