package com.lantone.qc.trans.taizhou;

import com.google.common.collect.Lists;
import com.lantone.qc.pub.model.doc.ClinicalBloodDoc;
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;

/**
 * @Description: 输血/血制品病程记录文档生成
 * @author: rengb
 * @time: 2020/3/17 13:21
 */
public class TaiZhouClinicalBloodDocTrans extends ModelDocTrans {

    @Override
    public List<ClinicalBloodDoc> extract(MedrecVo medrecVo) {
        List<ClinicalBloodDoc> retList = Lists.newArrayList();
        List<String> contents = (List) medrecVo.getContent().get("content");
        contents.forEach(content -> {
            retList.add(getClinicalBloodDoc(content));
        });
        return retList;
    }

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

        ClinicalBloodDoc clinicalBloodDoc = new ClinicalBloodDoc();
        clinicalBloodDoc.setStructureMap(structureMap);
        clinicalBloodDoc.setPageData((Map) sourceMap);
        return clinicalBloodDoc;
    }

    private List<String> keyContrasts = Lists.newArrayList(
            "医生=记录医师",
            "结束时间=输注结束",
            "开始时间=输注开始",
            "内容=输注后效果评价"
    );

}