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 YwzxyyClinicBloodEffectXmlAnalysis 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);
            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;
    }

}