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.springframework.stereotype.Component;

import java.util.List;

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

    @Override
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if(inputInfo.getBeHospitalizedDoc() == null){
            return;
        }
        List<Operation> operations = inputInfo.getBeHospitalizedDoc().getPastLabel().getOperations();
        if (ListUtil.isEmpty(operations)) {
            return;
        }
        for (Operation operation : operations) {
            if (operation == null || StringUtil.isBlank(operation.getName())) {
                continue;
            }
            if ("手术史".equals(operation.getName()) || "手术".equals(operation.getName()) || "手术治疗".equals(operation.getName())) {
                continue;
            }
            if ((operation.getNegative() == null || StringUtil.isBlank(operation.getNegative().getName()))
                    && (operation.getPd() == null || StringUtil.isBlank(operation.getPd().getName()))
                    && (operation.getOperationResult() == null || StringUtil.isBlank(operation.getOperationResult().getName()))
                    && (operation.getDiag() == null || StringUtil.isBlank(operation.getDiag().getName()))) {
                info.set(info.get() + operation.getName() + " ");
            }
        }
        if (StringUtil.isNotBlank(info.get())) {
            status.set("-1");
        }
    }

}