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

import com.lantone.qc.kernel.catalogue.QCCatalogue;
import com.lantone.qc.kernel.util.CatalogueUtil;
import com.lantone.qc.pub.model.InputInfo;
import com.lantone.qc.pub.model.OutputInfo;
import com.lantone.qc.pub.model.doc.consultation.ConsultationDoc;
import com.lantone.qc.pub.model.doc.consultation.ConsultationResultsDoc;
import com.lantone.qc.pub.model.doc.operation.OperationDoc;
import com.lantone.qc.pub.model.doc.operation.OperationRecordDoc;
import org.springframework.stereotype.Component;

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

/**
 * @ClassName : OPE0645
 * @Description : 未记录术中耗材情况
 * @Author : 胡敬
 * @Date: 2020-03-30 10:10
 */
@Component
public class OPE0645 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
//        boolean isOperativePatient = true;//是手术患者(暂时默认是)
//        if (isOperativePatient) {
            List<OperationDoc> operationDocs = inputInfo.getOperationDocs();
        if(operationDocs == null || operationDocs.size() == 0){
            status.set("0");
            return;
        }
            if (operationDocs.size() == 0) {
                return;
            }
            for (OperationDoc operationDoc : operationDocs) {
                OperationRecordDoc operationRecordDoc = operationDoc.getOperationRecordDoc();
                if (operationRecordDoc == null) {
                    continue;
                }
                Map<String, String> operationRecordStructureMap = operationRecordDoc.getStructureMap();
                String operationDuringStr = operationRecordStructureMap.get("手术经过及处理（包括患者的体位、切口处理、病灶所见及手术步骤等）");
                if (CatalogueUtil.isEmpty(operationDuringStr)) {
                    continue;
                }
                String intraoperativeConsumables = operationDuringStr.substring(operationDuringStr.indexOf("术中耗材") + 1);
                if (CatalogueUtil.isEmpty(intraoperativeConsumables)) {
                    status.set("-1");
                    return;
                }
            }
//        }
    }
}