package com.lantone.qc.kernel.catalogue.operationdiscussion;

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.operation.OperationDoc;
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: 胡敬
 * @time: 2020/3/24 13:28
 */
@Component
public class OPE0352 extends QCCatalogue {
    @Override
    protected void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        //医嘱
        //        List<DoctorAdviceDoc> doctorAdviceDocs = inputInfo.getDoctorAdviceDocs();
        //        if (ListUtil.isEmpty(doctorAdviceDocs)) {
        //            return;
        //        }
        //        boolean isOperativePatient = CatalogueUtil.isOperativePatients(doctorAdviceDocs);
        //        boolean isOperativePatient = true;//是手术患者(暂时默认是)
        //        if (isOperativePatient) {
        List<OperationDoc> operationDocs = inputInfo.getOperationDocs();
        if (operationDocs == null || operationDocs.size() == 0) {
            status.set("0");
            return;
        }
        if (ListUtil.isNotEmpty(operationDocs)) {
            long count = operationDocs.stream().filter(operationDoc -> {
                boolean flag = false;
                if (operationDoc.getOperationDiscussionDoc() != null
                        && operationDoc.getOperationDiscussionDoc().getOperationDiscussionLabel() != null
                        && (StringUtil.isBlank(operationDoc.getOperationDiscussionDoc().getOperationDiscussionLabel().getRiskAfterOp())
                        || operationDoc.getOperationDiscussionDoc().getOperationDiscussionLabel().getRiskAfterOp().length() < 10)
                        && (StringUtil.isBlank(operationDoc.getOperationDiscussionDoc().getStructureMap().get("术后可能出现的并发症及预防措施"))
                        || operationDoc.getOperationDiscussionDoc().getStructureMap().get("术后可能出现的并发症及预防措施").length() < 10)) {
                    flag = true;
                }
                return flag;
            }).count();
            if (count > 0) {
                status.set("-1");
            }
        }
        //        }
    }

}