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

import com.lantone.qc.kernel.catalogue.QCCatalogue;
import com.lantone.qc.pub.Content;
import com.lantone.qc.pub.model.InputInfo;
import com.lantone.qc.pub.model.OutputInfo;
import com.lantone.qc.pub.model.doc.FirstPageRecordDoc;
import com.lantone.qc.pub.model.doc.operation.OperationDiscussionDoc;
import com.lantone.qc.pub.model.doc.operation.OperationDoc;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

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

/**
 * @ClassName : FIRP0192
 * @Description : 主要手术及操作名称与病程记录不一致
 * @Author : 胡敬
 * @Date: 2020-03-16 20:28
 */
@Component
public class FIRP0192 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        FirstPageRecordDoc firstPageRecordDoc = inputInfo.getFirstPageRecordDoc();
        List<OperationDoc> operationDocs = inputInfo.getOperationDocs();
        if (operationDocs != null && operationDocs.size() > 0) {
            OperationDoc operationDoc = operationDocs.get(0);
            OperationDiscussionDoc operationDiscussionDoc = operationDoc.getOperationDiscussionDoc();
            if (operationDiscussionDoc != null) {
                Map<String, String> docStructureMap = operationDiscussionDoc.getStructureMap();
                Map<String, Object> firstPageRecordDocStructureMap = firstPageRecordDoc.getStructureExtMap();
                String opertaion = docStructureMap.get("手术方式");
                List<Map<String, String>> mapList = (List<Map<String, String>>) firstPageRecordDocStructureMap.get(Content.operative_information);
                if (mapList != null && mapList.size() > 0) {
                    Map<String, String> op = mapList.get(0);
                    String oName = op.get(Content.operative_name);
                    if (StringUtils.isNotEmpty(opertaion) && !opertaion.equals(oName)) {
                        status.set("-1");
                    }
                }
            }
        }
    }
}