package com.lantone.qc.trans.taizhou;

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

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

/**
 * @Description: 死亡记录文档生成
 * @author: rengb
 * @time: 2020/3/17 13:23
 */
public class TaiZhouDeathRecordDocTrans extends ModelDocTrans {

    @Override
    public DeathRecordDoc 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);

        DeathRecordDoc deathRecordDoc = new DeathRecordDoc();
        deathRecordDoc.setStructureMap(structureMap);
        deathRecordDoc.setPageData((Map) structureMap);

        return deathRecordDoc;
    }

    private List<String> keyContrasts = Lists.newArrayList(
            "当前诊断=死亡诊断",
            "死亡日期=死亡时间",
            "初步诊断=入院诊断",
            "诊治经过=诊疗经过",
            "本人姓名=姓名",
            "现病史- 发病情况=发病情况",
            "病历日期=记录时间",
            "医生=记录医师"
    );

}