package com.lantone.qc.trans.changx;

import com.google.common.collect.Lists;
import com.lantone.qc.pub.model.doc.CrisisInfoDoc;
import com.lantone.qc.pub.model.vo.MedrecVo;
import com.lantone.qc.pub.util.FastJsonUtils;
import com.lantone.qc.trans.ModelDocTrans;

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

/**
 * @Description: 危急值结构化信息
 * @author: rengb
 * @time: 2020/3/19 19:41
 */
public class ChangxCrisisInfoDocTrans extends ModelDocTrans {

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

    private CrisisInfoDoc getCrisisInfoDoc(Map<String, String> content) {
        CrisisInfoDoc crisisInfoDoc = new CrisisInfoDoc();
        crisisInfoDoc.setStructureMap(content);
        crisisInfoDoc.setPageData((Map) content);
        return crisisInfoDoc;
    }

}