package com.lantone.qc.trans.taizhou;

import com.google.common.collect.Lists;
import com.lantone.qc.pub.model.doc.PathologyShipDoc;
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.trans.taizhou.util.TzXmlUtil;

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

/**
 * @ClassName : PathologyShipDocTrans
 * @Description : 病理检验送检单
 * @Author : 楼辉荣
 * @Date: 2020-04-19 17:49
 */
public class TaiZhouPathologyShipDocTrans extends ModelDocTrans {
    @Override
    public List<PathologyShipDoc> extract(MedrecVo medrecVo) {
        List<PathologyShipDoc> retList = Lists.newArrayList();
        List<String> contents = (List) medrecVo.getContent().get("content");
        contents.forEach(content -> {
            retList.add(getPathologyShipDoc(content));
        });
        return retList;
    }

    private PathologyShipDoc getPathologyShipDoc(String content) {
        Map<String, String> sourceMap = TzXmlUtil.getXmlToMapForTZ(content);
        Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(TzXmlUtil.getXmlToMapForTZ(content), keyContrasts);

        PathologyShipDoc pathologyShipDoc = new PathologyShipDoc();
        pathologyShipDoc.setStructureMap(structureMap);
        pathologyShipDoc.setPageData((Map)sourceMap);
        return pathologyShipDoc;
    }

    private List<String> keyContrasts = Lists.newArrayList("检验标本=送检标本名称");
}