package com.lantone.qc.trans.ywzxyy.util;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.lantone.qc.dbanaly.facade.ywzxyy.YwzxyyXmlUtil;
import com.lantone.qc.pub.util.MapUtil;
import com.lantone.qc.trans.comsis.CommonAnalysisUtil;
import lombok.extern.slf4j.Slf4j;

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

/**
 * @Description:
 * @author: rengb
 * @time: 2021/1/25 14:04
 */
@Slf4j
public class YwzxyyDifficultCaseDiscussXmlAnalysis implements YwzxyyXmlAnalysis {

    @Override
    public Map<String, String> analysis(String... args) {
        Map<String, String> level1StructureMap = Maps.newHashMap();
        try {
            String xml = args[0];
            String level1Text = YwzxyyXmlUtil.bcXmlAna(xml);
            List<String> level1Titles = CommonAnalysisUtil.sortTitles(Lists.newArrayList("病历记录时间", "病历记录标题", "原始文本", "医师签名", "主持人签名", "上级医师签名"), level1Text);
            CommonAnalysisUtil.cutByTitles(level1Text, level1Titles, 0, level1StructureMap);

            Map<String, String> level2StructureMap = Maps.newHashMap();
            String level2Text = level1StructureMap.get("原始文本");
            List<String> level2Titles = CommonAnalysisUtil.sortTitles(Lists.newArrayList("讨论时间", "地点", "科示教室主持人", "主持人", "参加人员", "主管医师报告病史", "讨论摘要", "主持人总结发言"), level2Text);
            CommonAnalysisUtil.cutByTitles(level2Text, level2Titles, 0, level2StructureMap);
            level1StructureMap.putAll(level2StructureMap);

            MapUtil.keyAssig(level1StructureMap, "记录时间", "病历记录时间");
            MapUtil.keyAssig(level1StructureMap, "记录医生", "医师签名", "记录医师");
            MapUtil.keyAssig(level1StructureMap, "主持人签名", "上级医师签名");
            MapUtil.keyAssig(level1StructureMap, "讨论地点", "地点");
            MapUtil.keyAssig(level1StructureMap, "主持人姓名及专业技术职务", "科示教室主持人", "主持人");
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        return level1StructureMap;
    }

}