package com.lantone.qc.trans.taizhou;

import com.google.common.collect.Lists;
import com.lantone.qc.pub.model.doc.FirstCourseRecordDoc;
import com.lantone.qc.pub.model.vo.MedrecVo;
import com.lantone.qc.pub.util.MapUtil;
import com.lantone.qc.trans.ModelDocTrans;
import com.lantone.qc.trans.comsis.ModelDocGenerate;
import com.lantone.qc.trans.comsis.OrdinaryAssistant;
import com.lantone.qc.trans.taizhou.util.TzXmlUtil;

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

/**
 * @Description: 首次病程录文档生成
 * @author: rengb
 * @time: 2020/3/17 13:25
 */
public class TaiZhouFirstCourseRecordDocTrans extends ModelDocTrans {

    @Override
    public FirstCourseRecordDoc extract(MedrecVo medrecVo) {
        String content = ((List<String>) medrecVo.getContent().get("content")).get(0);

        Map<String, String> sourceMap = TzXmlUtil.getXmlToMapForTZWithReplace(content); // xml原始数据给华卓
        Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(sourceMap, keyContrasts);
        // 病例特点=主诉+现病史-发病情况+专科检查+实验室检查+影像学检查+辅助检查结果+呼吸+脉搏+体温+血压
        structureMap.put("病例特点", MapUtil.getSelectString(structureMap, Arrays.asList(
                "主诉",
                "现病史-发病情况",
                "专科检查",
                "实验室检查",
                "影像学检查",
                "辅助检查结果",
                "呼吸",
                "脉搏",
                "体温",
                "血压"
            ))
        );
        // 诊断依据=性别+年龄+主诉+现病史-发病情况+专科检查+实验室检查+影像学检查+辅助检查结果+呼吸+脉搏+体温+血压
        structureMap.put("诊断依据", MapUtil.getSelectString(structureMap, Arrays.asList(
                "性别",
                "年龄",
                "主诉",
                "现病史-发病情况",
                "专科检查",
                "实验室检查",
                "影像学检查",
                "辅助检查结果",
                "呼吸",
                "脉搏",
                "体温",
                "血压"
                ))
        );
        // 诊疗计划=检查计划+治疗计划和措施
        structureMap.put("诊疗计划", MapUtil.getSelectString(structureMap, Arrays.asList(
                "检查计划",
                "治疗计划和措施"
                ))
        );

        // 诊疗计划
        FirstCourseRecordDoc firstCourseRecordDoc = ModelDocGenerate.firstCourseRecordDocGen(structureMap);
        firstCourseRecordDoc.setPageData((Map)sourceMap);
        return firstCourseRecordDoc;
    }

    private List<String> keyContrasts = Lists.newArrayList(
            "初步诊断=初步诊断",
            "鉴别诊断=鉴别诊断",
            "医生=记录医师",
            "病历日期=记录时间"
            );

}