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.Operation;
import com.lantone.qc.pub.util.ListUtil;
import com.lantone.qc.pub.util.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @Description: 手术史未填写
 * @author: rengb
 * @time: 2020/3/10 14:02
 */
@Component
public class BEH0025 extends QCCatalogue {

    @Override
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        if(inputInfo.getBeHospitalizedDoc() == null){
            status.set("0");
            return;
        }
        List<Operation> operations = inputInfo.getBeHospitalizedDoc().getPastLabel().getOperations();
        if (ListUtil.isNotEmpty(operations)) {
            if (operations.stream().map(i -> i.getName()).filter(i -> StringUtil.isNotBlank(i)).count() > 0) {
                status.set("0");
                return;
            }
        }
        //规则硬匹配
        if (inputInfo.getBeHospitalizedDoc().getPastLabel().getText().contains("手术")) {
            status.set("0");
            return;
        }
        //台州结构化
        Map<String, String> structureMap_beh = inputInfo.getBeHospitalizedDoc().getStructureMap();
        if(StringUtils.isNotEmpty(structureMap_beh.get("手术外伤史"))){
            status.set("0");
            return;
        }
    }

}