package com.lantone.qc.trans.taizhou;

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

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

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

        CrisisValueReportDoc crisisValueReportDoc = new CrisisValueReportDoc();
        crisisValueReportDoc.setStructureMap(structureMap);
        crisisValueReportDoc.setPageData((Map)sourceMap);

        return crisisValueReportDoc;
    }

    private List<String> keyContrasts = Lists.newArrayList(
            "姓名=",
            "病历号=",
            "病历日期=",
            "床号=",
            "临床科室=",
            "病人基本信息=",
            "医生=",
            "内容=",
            "性别="
    );

}