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.OperationDiscussionDoc;
import com.lantone.qc.pub.model.doc.operation.OperationDoc;
import com.lantone.qc.pub.model.label.OperationDiscussionLabel;
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 OPE0353 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.isEmpty(operationDocs)) {
            return;
        }
        for (OperationDoc operationDoc : operationDocs) {
            OperationDiscussionDoc operationDiscussionDoc = operationDoc.getOperationDiscussionDoc();
            if (operationDiscussionDoc == null) {
                continue;
            }
            //结构化读取手术术后处理措施和注意事项
            if (operationDiscussionDoc.getStructureMap().get("术后处理措施") != null
                    || operationDiscussionDoc.getStructureMap().get("术后注意事项") != null) {
                continue;
            }
            String treatPlan = operationDiscussionDoc.getStructureMap().get("治疗计划和措施");
            OperationDiscussionLabel operationDiscussionLabel = operationDiscussionDoc.getOperationDiscussionLabel();
            String measuresAfterOp = operationDiscussionLabel.getMeasuresAfterOp();
            String attentionAfterOp = operationDiscussionLabel.getAttentionAfterOp();
            if ((StringUtil.isBlank(measuresAfterOp) || measuresAfterOp.length() < 10 || StringUtil.isBlank(attentionAfterOp) || attentionAfterOp.length() < 10)
                    && StringUtil.isBlank(treatPlan)) {
                status.set("-1");
                return;
            }
        }
    }
    //    }

}