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

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

import java.text.ParseException;
import java.util.List;
import java.util.Map;

/**
 * @Description: 术前讨论记录无拟行术式
 * @author: rengb
 * @time: 2020/3/23 15:09
 */
@Component
public class PRE0330 extends QCCatalogue {

    @Override
    protected void start(InputInfo inputInfo, OutputInfo outputInfo) throws ParseException {
        status.set("0");
        List<OperationDoc> operationDocs = inputInfo.getOperationDocs();
        if (operationDocs == null || operationDocs.size() == 0) {
            return;
        }
        for (OperationDoc operationDoc : operationDocs) {
            if (operationDoc.getPreoperativeDiscussionDoc() != null) {
                Map<String, String> structureMap = operationDoc.getPreoperativeDiscussionDoc().getStructureMap();
                if(structureMap != null
                        && structureMap.get("拟施手术方式名称及可能的变更与禁忌症") != null){
                    return;
                }
                if (StringUtil.isEmpty(structureMap.get("拟行术式")) && StringUtil.isEmpty(structureMap.get("可能的变更"))) {
                    status.set("-1");
                }
            }
        }
    }
}