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

import com.lantone.qc.kernel.catalogue.QCCatalogue;
import com.lantone.qc.kernel.util.CatalogueUtil;
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.entity.Diag;
import com.lantone.qc.pub.util.ListUtil;
import org.springframework.stereotype.Component;

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

/**
 * @ClassName : FIRP0175
 * @Description :主要诊断与出院小结不一致
 * @Author : 胡敬
 * @Date: 2020-03-18 16:17
 */
@Component
public class FIRP0175 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getFirstPageRecordDoc() != null && inputInfo.getFirstPageRecordDoc().getStructureMap() != null
                && inputInfo.getLeaveHospitalDoc() != null && inputInfo.getLeaveHospitalDoc().getLeaveDiagLabel() != null) {
            Map<String, Object> firstpageStructureMap = inputInfo.getFirstPageRecordDoc().getStructureExtMap();
            //病案首页出院诊断
            List<Map<String, String>> dischargeDiag = (List) firstpageStructureMap.get(Content.dischargeDiag);
            //出院小结诊断
            List<Diag> leaveDiags = inputInfo.getLeaveHospitalDoc().getLeaveDiagLabel().getDiags();
            if (ListUtil.isEmpty(dischargeDiag) || ListUtil.isEmpty(leaveDiags)) {
                return;
            }
            String firstpageleaveDiag = dischargeDiag.get(0).get(Content.diagnoseName);
            String leaveDiag = leaveDiags.get(0).getName();
            if (!CatalogueUtil.compareToken(firstpageleaveDiag, leaveDiag)) {
                status.set("-1");
            }
        }
    }
}