package com.lantone.qc.trans.taizhou;

import com.google.common.collect.Lists;
import com.lantone.qc.pub.model.doc.StagesSummaryDoc;
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/19 19:41
 */
public class TaiZhouStagesSummaryDocTrans extends ModelDocTrans {

    @Override
    public List<StagesSummaryDoc> extract(MedrecVo medrecVo) {
        List<StagesSummaryDoc> retList = Lists.newArrayList();
        List<Map<String, Object>> contentMaps = (List) medrecVo.getContent().get("content");
        contentMaps.forEach(contentMap -> {
            retList.add(getStagesSummaryDoc(contentMap));
        });
        return retList;
    }

    private StagesSummaryDoc getStagesSummaryDoc(Map<String, Object> contentMap) {
        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);

        StagesSummaryDoc stagesSummaryDoc = new StagesSummaryDoc();
        stagesSummaryDoc.setStructureMap(structureMap);
        stagesSummaryDoc.setPageData((Map) structureMap);

        return stagesSummaryDoc;
    }

    private List<String> keyContrasts = Lists.newArrayList(
            "本人姓名=姓名",
            "现病史- 发病情况=发病情况",
            "体温(耳)=体温耳"
    );

}