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.DeathCaseDiscussDoc;
import com.lantone.qc.pub.model.doc.DeathRecordDoc;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @ClassName : FIRP0195
 * @Description :离院方式选择错误
 * @Author : 胡敬
 * @Date: 2020-06-03 16:54
 */
@Component
public class FIRP0195 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        /*FirstPageRecordDoc firstPageRecordDoc = inputInfo.getFirstPageRecordDoc();*/
        DeathRecordDoc deathRecordDoc = inputInfo.getDeathRecordDoc();
        DeathCaseDiscussDoc deathCaseDiscussDoc = inputInfo.getDeathCaseDiscussDoc();
        /* List<ThreeLevelWardDoc> threeLevelWardDocs = inputInfo.getThreeLevelWardDocs();*/
        if (inputInfo.getFirstPageRecordDoc() == null) {
            return;
        }
        Map<String, String> firstpageStructureMap = inputInfo.getFirstPageRecordDoc().getStructureMap();
        String outWay = firstpageStructureMap.get(Content.outWay);
        if (StringUtil.isBlank(outWay)) {
            return;
        }
        String wardOutWay;
        if (deathRecordDoc != null || deathCaseDiscussDoc != null) {
            wardOutWay = "死亡";
            if (!match(outWay, wardOutWay)) {
                status.set("-1");
            }
        }

        /*
        if (threeLevelWardDocs.size() > 0) {
            List<ThreeLevelWardDoc> allDoctorWradDocs = threeLevelWardDocs.get(0).getAllDoctorWradDocs();
            ThreeLevelWardDoc lastWardDoc = allDoctorWradDocs.get(allDoctorWradDocs.size() - 1);
            List<ThreeLevelWardLabel> threeLevelWardLabels = lastWardDoc.getThreeLevelWardLabel();
            if (threeLevelWardLabels.size() > 0) {
                ThreeLevelWardLabel threeLevelWardLabel = threeLevelWardLabels.get(0);
                if (threeLevelWardLabel != null) {
                    wardOutWay = threeLevelWardLabel.getDischargeMode();
                    if (StringUtil.isNotBlank(wardOutWay)) {
                        if (!match(outWay, wardOutWay)) {
                            status.set("-1");
                        }
                    }
                }
            }
        }
         */


    }

    private boolean match(String str1, String str2) {
        return str1.equals(str2) || str1.contains(str2) || str2.contains(str1);
    }
}