package com.lantone.qc.trans.taizhou;

import com.google.common.collect.Lists;
import com.lantone.qc.dbanaly.facade.taizhou.TzXmlUtil;
import com.lantone.qc.pub.model.doc.DeathCaseDiscussDoc;
import com.lantone.qc.pub.model.vo.MedrecVo;
import com.lantone.qc.pub.util.MapUtil;
import com.lantone.qc.trans.ModelDocTrans;
import com.lantone.qc.trans.comsis.OrdinaryAssistant;

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

/**
 * @Description: 死亡病例讨论记录文档生成
 * @author: rengb
 * @time: 2020/3/17 13:22
 */
public class TaiZhouDeathCaseDiscussDocTrans extends ModelDocTrans {

    @Override
    public DeathCaseDiscussDoc extract(MedrecVo medrecVo) {
        Map<String, Object> contentMap = ((List<Map>) medrecVo.getContent().get("content")).get(0);
        String content = contentMap.get("xmlText").toString();
        Map<String, String> sourceMap = TzXmlUtil.getXmlToMapForTZ(content);
        sourceMap.put("mode_id=" + contentMap.get("modeId").toString(), "");
        sourceMap.put("rec_title=" + contentMap.get("recTitle").toString(), "");
        Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(sourceMap, keyContrasts);

        MapUtil.keyAssig(structureMap, "参加讨论人员", "参加人员及职称医生", "参加人员及职称");
        DeathCaseDiscussDoc deathCaseDiscussDoc = new DeathCaseDiscussDoc();
        deathCaseDiscussDoc.setStructureMap(structureMap);
        deathCaseDiscussDoc.setPageData((Map) structureMap);

        return deathCaseDiscussDoc;
    }

    private List<String> keyContrasts = Lists.newArrayList(
            "主持人=讨论主持人",
            "死亡日期=死亡时间",
            "讨论意见=讨论内容",
            "现病史- 发病情况=入院情况",
            "医生=记录医师",
            "本人姓名=姓名",
            "事件日期=讨论时间",
            "当前诊断=死亡诊断",
            "病历日期=记录时间",
            "讨论小结=结论"
    );

}