package com.lantone.qc.kernel.analysis;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
import com.lantone.qc.kernel.client.CRFServiceClient;
import com.lantone.qc.kernel.client.SimilarityServiceClient;
import com.lantone.qc.kernel.structure.ai.BeHospitalizedAI;
import com.lantone.qc.pub.model.InputInfo;
import com.lantone.qc.pub.model.doc.BeHospitalizedDoc;
import com.lantone.qc.pub.model.doc.MedicalRecordInfoDoc;
import com.lantone.qc.pub.model.entity.*;
import com.lantone.qc.pub.model.label.PastLabel;
import com.lantone.qc.pub.model.label.PresentLabel;
import com.lantone.qc.pub.model.vo.EzAnalysisVO;
import com.lantone.qc.pub.res.EzAnalysisDTO;
import com.lantone.qc.pub.util.ListUtil;
import com.lantone.qc.pub.util.StringUtil;
import com.lantone.qc.trans.beilun.util.ez.EzXmlAnalysis;
import com.lantone.qc.trans.comsis.OrdinaryAssistant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

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

/**
 * @ClassName : QCAnalysis
 * @Description : 质控业务处理总入口
 * @Author : 楼辉荣
 * @Date: 2020-03-04 11:48
 */
@Slf4j
@Component
public class EZAnalysis {
    @Autowired
    CRFServiceClient crfServiceClient;
    @Autowired
    private SpecialStorageUtil specialStorageUtil;
    @Autowired
    SimilarityServiceClient similarityServiceClient;

    public static String bom(String result) {
        if (null != result && !"".equals(result)) {
            if (result.indexOf("<") != -1 && result.lastIndexOf(">") != -1 && result.lastIndexOf(">") > result.indexOf("<")) {
                result = result.substring(result.indexOf("<"), result.lastIndexOf(">") + 1);
            }
        }
        return result;
    }

    public Map<String, Object> anlysis(EzAnalysisVO ezAnalysisVO) throws Exception {
        Map<String, Object> output = Maps.newHashMap();
        List<EzAnalysisDTO> details = Lists.newArrayList();
        //        ezAnalysisVO.setXml(bom(FileUtil.fileRead("C:\\Users\\Administrator\\Desktop\\恩泽\\eztest.txt")));
        Map<String, String> sourceMap = EzXmlAnalysis.analysisEk(ezAnalysisVO.getDeptName(), ezAnalysisVO.getXml());
        InputInfo inputInfo = ai(sourceMap);
        structHandle(inputInfo, sourceMap);
        Map<String, String> structMap = OrdinaryAssistant.mapKeyContrast(sourceMap, keyContrasts);
        structMap.put("接诊医师签名", structMap.get("初步诊断签名"));
        Map<String, String> keyMaps = getKmaps();
        kys.forEach(ky -> {
            EzAnalysisDTO ezAnalysisDTO = new EzAnalysisDTO();
            ezAnalysisDTO.setCode(keyMaps.get(ky));
            ezAnalysisDTO.setModelName(ky);
            ezAnalysisDTO.setModelValue(modelValueHandle(structMap.get(ky)));
            details.add(ezAnalysisDTO);
        });
        output.put("data", details);
        Map<String, String> structureMap = Maps.newHashMap();
        getStructureMap(structMap, structureMap, details, Lists.newArrayList("主诉", "现病史", "既往史", "个人史", "婚育史"));
        output.put("structureMap", structureMap);
        return output;
    }

    private void getStructureMap(Map<String, String> structMap, Map<String, String> structureMap, List<EzAnalysisDTO> details, List<String> keys) {
        keys.forEach(i -> structureMap.put(i, structMap.get(i)));
        StringBuffer sbf = new StringBuffer();
        String physicalExam = "";
        for (EzAnalysisDTO i : details) {
            if (i.getModelName().contains("体格检查")) {
                if (i.getModelName().contains("（")) {
                    sbf.append(i.getModelName().split("--")[1].split("（")[0]);
                } else {
                    sbf.append(i.getModelName().split("--")[1]);
                }
                sbf.append("：").append(i.getModelValue());
                if (i.getModelValue().length() == 0 || i.getModelValue().charAt(i.getModelValue().length() - 1) != '。') {
                    sbf.append("，");
                }
            }
        }
        if (sbf.toString().length() > 0 && sbf.toString().charAt(sbf.toString().length() - 1) == '，') {
            physicalExam = sbf.toString().substring(0, sbf.toString().length() - 1);
        } else {
            physicalExam = sbf.toString();
        }
        structureMap.put("体格检查", physicalExam);
    }

    private String modelValueHandle(String modelValue) {
        if (modelValue == null) {
            return "";
        }
        if (modelValue.endsWith(",") || modelValue.endsWith("，") || modelValue.endsWith("、")
                || modelValue.endsWith("（") || modelValue.endsWith("(") || modelValue.endsWith("）")
                || modelValue.endsWith(")") || modelValue.endsWith("/")) {
            modelValue = modelValue.substring(0, modelValue.length() - 1);
        }
        return modelValue;
    }

    private void structHandle(InputInfo inputInfo, Map<String, String> structMap) {
        diagsHandle(inputInfo, structMap);
        diagInfectiouseHandle(inputInfo, structMap);
        vaccinateHandle(inputInfo, structMap);
        operationHandle(inputInfo, structMap);
        bloodTransfusionHandle(inputInfo, structMap);
        allergyDescHandle(inputInfo, structMap);
        generalDescHandle(inputInfo, structMap);
    }

    private void diagsHandle(InputInfo inputInfo, Map<String, String> map) {
        StringBuffer sbf = new StringBuffer();
        PastLabel pastLabel = inputInfo.getBeHospitalizedDoc().getPastLabel();
        List<Diag> diags = pastLabel.getDiags();
        List<Wound> wounds = pastLabel.getWounds();
        if (ListUtil.isNotEmpty(diags)) {
            diags.stream()
                    .filter(i -> i != null && StringUtil.isNotBlank(i.getHospitalDiagName()) && (i.getNegative() == null || StringUtil.isBlank(i.getNegative().getName())))
                    .forEach(i -> {
                        sbf.append(i.getHospitalDiagName()).append("，");
                    });
            diags.stream()
                    .filter(i -> i != null && StringUtil.isNotBlank(i.getHospitalDiagName()) && i.getNegative() != null && StringUtil.isNotBlank(i.getNegative().getName()))
                    .forEach(i -> {
                        sbf.append(i.getNegative().getName()).append(i.getHospitalDiagName()).append("，");
                    });
        }
        if (ListUtil.isNotEmpty(wounds)) {
            wounds.stream()
                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && (i.getNegative() == null || StringUtil.isBlank(i.getNegative().getName())))
                    .forEach(i -> {
                        sbf.append(i.getName()).append("，");
                    });
            wounds.stream()
                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && i.getNegative() != null && StringUtil.isNotBlank(i.getNegative().getName()))
                    .forEach(i -> {
                        sbf.append(i.getNegative().getName()).append(i.getName()).append("，");
                    });
        }
        map.put("疾病史（含外伤）", sbf.toString());
    }

    private void diagInfectiouseHandle(InputInfo inputInfo, Map<String, String> map) {
        StringBuffer sbf = new StringBuffer();
        PastLabel pastLabel = inputInfo.getBeHospitalizedDoc().getPastLabel();
        List<DiagInfectious> diagInfectiouses = pastLabel.getDiagInfectiouses();
        if (ListUtil.isNotEmpty(diagInfectiouses)) {
            diagInfectiouses.stream()
                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && (i.getNegative() == null || StringUtil.isBlank(i.getNegative().getName())))
                    .forEach(i -> {
                        sbf.append(i.getName()).append("，");
                    });
            diagInfectiouses.stream()
                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && i.getNegative() != null && StringUtil.isNotBlank(i.getNegative().getName()))
                    .forEach(i -> {
                        sbf.append(i.getNegative().getName()).append(i.getName()).append("，");
                    });
        }
        map.put("患者传染性标志", sbf.toString());
        map.put("传染病史", sbf.toString());
    }

    private void vaccinateHandle(InputInfo inputInfo, Map<String, String> map) {
        String yfjzx = map.get("预防接种史");
        if (StringUtil.isBlank(yfjzx)) {
            yfjzx = "";
        } else if (!(yfjzx.endsWith(",") || yfjzx.endsWith("，") || yfjzx.endsWith(".") || yfjzx.endsWith("。") || yfjzx.endsWith("、"))) {
            yfjzx += "。";
        }
        StringBuffer sbf = new StringBuffer();
        PastLabel pastLabel = inputInfo.getBeHospitalizedDoc().getPastLabel();
        List<Vaccinate> vaccinates = pastLabel.getVaccinates();
        if (ListUtil.isNotEmpty(vaccinates)) {
            vaccinates.stream()
                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && (i.getNegative() == null || StringUtil.isBlank(i.getNegative().getName())))
                    .forEach(i -> {
                        sbf.append(i.getName()).append("，");
                    });
            vaccinates.stream()
                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && i.getNegative() != null && StringUtil.isNotBlank(i.getNegative().getName()))
                    .forEach(i -> {
                        sbf.append(i.getNegative().getName()).append(i.getName()).append("，");
                    });
        }
        if (sbf.length() > 0) {
            map.put("预防接种史", yfjzx + sbf.toString());
        }
    }

    private void operationHandle(InputInfo inputInfo, Map<String, String> map) {
        StringBuffer sbf = new StringBuffer();
        PastLabel pastLabel = inputInfo.getBeHospitalizedDoc().getPastLabel();
        List<Operation> operations = pastLabel.getOperations();
        if (ListUtil.isNotEmpty(operations)) {
            operations.stream()
                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && (i.getNegative() == null || StringUtil.isBlank(i.getNegative().getName())))
                    .forEach(i -> {
                        sbf.append(i.getName()).append("，");
                    });
            operations.stream()
                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && i.getNegative() != null && StringUtil.isNotBlank(i.getNegative().getName()))
                    .forEach(i -> {
                        sbf.append(i.getNegative().getName()).append(i.getName()).append("，");
                    });
        }
        map.put("手术史", sbf.toString());
    }

    private void bloodTransfusionHandle(InputInfo inputInfo, Map<String, String> map) {
        StringBuffer sbf = new StringBuffer();
        PastLabel pastLabel = inputInfo.getBeHospitalizedDoc().getPastLabel();
        List<BloodTransfusion> bloodTransfusions = pastLabel.getBloodTransfusions();
        if (ListUtil.isNotEmpty(bloodTransfusions)) {
            bloodTransfusions.stream()
                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && (i.getNegative() == null || StringUtil.isBlank(i.getNegative().getName())))
                    .forEach(i -> {
                        sbf.append(i.getName()).append("，");
                    });
            bloodTransfusions.stream()
                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && i.getNegative() != null && StringUtil.isNotBlank(i.getNegative().getName()))
                    .forEach(i -> {
                        sbf.append(i.getNegative().getName()).append(i.getName()).append("，");
                    });
        }
        map.put("输血史", sbf.toString());
    }

    private void allergyDescHandle(InputInfo inputInfo, Map<String, String> map) {
        StringBuffer sbf = new StringBuffer();
        PastLabel pastLabel = inputInfo.getBeHospitalizedDoc().getPastLabel();
        List<Allergy> allergies = pastLabel.getAllergies();
        if (ListUtil.isNotEmpty(allergies)) {
            allergies.stream()
                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && (i.getNegative() == null || StringUtil.isBlank(i.getNegative().getName())))
                    .forEach(i -> {
                        if (i.getAllergyFood() != null && StringUtil.isNotBlank(i.getAllergyFood().getName())) {
                            sbf.append(i.getAllergyFood().getName()).append(i.getName()).append("，");
                        }
                    });
            allergies.stream()
                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && i.getNegative() != null && StringUtil.isNotBlank(i.getNegative().getName()))
                    .forEach(i -> {
                        if (i.getAllergyFood() != null && StringUtil.isNotBlank(i.getAllergyFood().getName())) {
                            sbf.append(i.getNegative().getName()).append(i.getAllergyFood().getName()).append(i.getName()).append("，");
                        }
                    });
            allergies.stream()
                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && (i.getNegative() == null || StringUtil.isBlank(i.getNegative().getName())))
                    .forEach(i -> {
                        if (i.getAllergyMedicine() != null && StringUtil.isNotBlank(i.getAllergyMedicine().getName())) {
                            sbf.append(i.getAllergyMedicine().getName()).append(i.getName()).append("，");
                        }
                    });
            allergies.stream()
                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && i.getNegative() != null && StringUtil.isNotBlank(i.getNegative().getName()))
                    .forEach(i -> {
                        if (i.getAllergyMedicine() != null && StringUtil.isNotBlank(i.getAllergyMedicine().getName())) {
                            sbf.append(i.getNegative().getName()).append(i.getAllergyMedicine().getName()).append(i.getName()).append("，");
                        }
                    });
        }
        map.put("过敏史", sbf.toString());
    }

    private void generalDescHandle(InputInfo inputInfo, Map<String, String> map) {
        StringBuffer sbf = new StringBuffer();
        PresentLabel presentLabel = inputInfo.getBeHospitalizedDoc().getPresentLabel();
        List<String> list = Lists.newArrayList();
        List<String> neList = Lists.newArrayList();
        List<General> gens = presentLabel.getGens();
        List<GeneralDesc> generals = presentLabel.getGenerals();
        if (ListUtil.isNotEmpty(generals)) {
            String preStr = map.get("现病史");
            int index = -1;
            for (GeneralDesc general : generals) {
                index++;
                if (general == null || StringUtil.isBlank(general.getName())) {
                    continue;
                }
                String genstr = "";
                if (index < gens.size()) {
                    genstr = gens.get(index).getName();
                }
                if (general.getNegative() != null && StringUtil.isNotBlank(general.getNegative().getName())) {
                    neList.add(general.getNegative().getName() + general.getName() + genstr);
                } else {
                    list.add(general.getName() + genstr);
                }
            }
            list.forEach(i -> {
                sbf.append(i).append("，");
            });
            neList.forEach(i -> {
                sbf.append(i).append("，");
            });
            preStr.replaceAll(sbf.toString(), "");
        }
        map.put("一般健康状况标志", sbf.toString());
    }

    private InputInfo ai(Map<String, String> sourceMap) {
        InputInfo inputInfo = new InputInfo();
        inputInfo.setUseCrfCache(false);
        MedicalRecordInfoDoc medicalRecordInfoDoc = new MedicalRecordInfoDoc();
        medicalRecordInfoDoc.getStructureMap().put("behospitalCode", System.currentTimeMillis() + "");
        inputInfo.setMedicalRecordInfoDoc(medicalRecordInfoDoc);
        BeHospitalizedDoc beHospitalizedDoc = new BeHospitalizedDoc();
        PresentLabel presentLabel = new PresentLabel();
        presentLabel.setText(sourceMap.get("现病史"));
        beHospitalizedDoc.setPresentLabel(presentLabel);
        PastLabel pastLabel = new PastLabel();
        pastLabel.setText(sourceMap.get("既往史"));
        beHospitalizedDoc.setPastLabel(pastLabel);
        inputInfo.setBeHospitalizedDoc(beHospitalizedDoc);
        BeHospitalizedAI beHospitalizedAI = new BeHospitalizedAI();
        beHospitalizedAI.medrec(inputInfo, crfServiceClient);
        return inputInfo;
    }

    private List<String> keyContrasts = Lists.newArrayList(
            "体温=体格检查--体温（℃）",
            "脉搏=体格检查--脉率（次/min）",
            "呼吸=体格检查--呼吸频率（次/min）",
            "收缩压=体格检查--收缩压（mmHg）",
            "舒张压=体格检查--舒张压（mmHg）",
            "身高=体格检查--身高（cm）",
            "体重=体格检查--体重（kg）",
            "一般情况=体格检查--一般状况检查结果",
            "皮肤黏膜=体格检查--皮肤和黏膜检查结果",
            "浅表淋巴结=体格检查--全身浅表淋巴结检查结果",
            "头部及其器官=体格检查--头部及其器官检查结果",
            "颈部=体格检查--颈部检查结果",
            "胸部=体格检查--胸部检查结果",
            "腹部=体格检查--腹部检查结果",
            "肛门及直肠=体格检查--肛门指诊检查结果描述",
            "外生殖器=体格检查--外生殖器检查结果",
            "脊柱=体格检查--脊柱检查结果",
            "四肢=体格检查--四肢检查结果",
            "神经系统=体格检查--神经系统检查结果",
            "专科检查=专科情况",
            "辅助检查=辅助检查结果",
            "初步诊断=初步诊断-西医诊断名称",
            "初步诊断签名日期=初步诊断日期",
            "修正诊断=修正诊断-西医诊断名称",
            "修正诊断签名日期=修正诊断日期",
            "补充诊断=补充诊断名称",
            "补充诊断签名日期=补充诊断日期",
            "姓名=患者姓名",
            "性别=性别代码",
            "年龄岁=年龄（岁）",
            "年龄月=年龄（月）",
            "民族=民族",
            "婚姻状况=婚姻状况代码",
            "职业=职业类别代码",
            "新入院时间=入院日期时间",
            "病史陈述者=病史陈述者姓名",
            "主诉=主诉",
            "现病史=现病史",
            "预防接种史=预防接种史",
            "手术史=手术史",
            "输血史=输血史",
            "过敏史=过敏史",
            "个人史=个人史",
            "婚育史=婚育史",
            "月经史=月经史",
            "家族史=家族史"
    );

    private List<String> kmaps = Lists.newArrayList(
            "DE01.00.014.00=住院号",
            "DE08.10.054.00=病区名称",
            "DE08.10.026.00=科室名称",
            "DE01.00.019.00=病房号",
            "DE01.00.026.00=病床号",
            "DE02.01.039.00=患者姓名",
            "DE02.01.040.00=性别代码",
            "DE02.01.026.00=年龄（岁）",
            "DE02.01.032.00=年龄（月）",
            "DE02.01.025.00=民族",
            "DE02.01.018.00=婚姻状况代码",
            "DE02.01.009.01=地址-省（自治区、直辖市）",
            "DE02.01.009.02=地址-市（地区、州）",
            "DE02.01.009.03=地址-县（区）",
            "DE02.01.009.04=地址-乡（镇、街道办事处）",
            "DE02.01.009.05=地址-村（街、路、弄等）",
            "DE02.01.009.06=地址-门牌号码",
            "DE02.01.052.00=职业类别代码",
            "DE06.00.092.00=入院日期时间",
            "DE02.01.039.00=病史陈述者姓名",
            "DE02.10.024.00=陈述者与患者的关系代码",
            "DE05.10.143.00=陈述内容可靠标志",
            "DE04.01.119.00=主诉",
            "DE02.10.071.00=现病史",
            "DE05.10.031.00=一般健康状况标志",
            "DE02.10.026.00=疾病史（含外伤）",
            "DE05.10.119.00=患者传染性标志",
            "DE02.10.008.00=传染病史",
            "DE02.10.101.00=预防接种史",
            "DE02.10.061.00=手术史",
            "DE02.10.100.00=输血史",
            "DE02.10.022.00=过敏史",
            "DE02.10.097.00=个人史",
            "DE02.10.098.00=婚育史",
            "DE02.10.102.00=月经史",
            "DE02.10.103.00=家族史",
            "DE04.10.186.00=体格检查--体温（℃）",
            "DE04.10.118.00=体格检查--脉率（次/min）",
            "DE04.10.081.00=体格检查--呼吸频率（次/min）",
            "DE04.10.174.00=体格检查--收缩压（mmHg）",
            "DE04.10.176.00=体格检查--舒张压（mmHg）",
            "DE04.10.167.00=体格检查--身高（cm）",
            "DE04.10.188.00=体格检查--体重（kg）",
            "DE04.10.219.00=体格检查--一般状况检查结果",
            "DE04.10.126.00=体格检查--皮肤和黏膜检查结果",
            "DE04.10.114.00=体格检查--全身浅表淋巴结检查结果",
            "DE04.10.261.00=体格检查--头部及其器官检查结果",
            "DE04.10.255.00=体格检查--颈部检查结果",
            "DE04.10.263.00=体格检查--胸部检查结果",
            "DE04.10.046.00=体格检查--腹部检查结果",
            "DE04.10.065.00=体格检查--肛门指诊检查结果描述",
            "DE04.10.195.00=体格检查--外生殖器检查结果",
            "DE04.10.093.00=体格检查--脊柱检查结果",
            "DE04.10.179.00=体格检查--四肢检查结果",
            "DE05.10.149.00=体格检查--神经系统检查结果",
            "DE08.10.061.00=专科情况",
            "DE04.30.009.00=辅助检查结果",
            "DE02.10.028.00=中医“四诊”观察结果",
            "DE06.00.300.00=治则治法",
            "DE05.01.025.00=初步诊断-西医诊断名称",
            "DE05.01.024.00=初步诊断-西医诊断编码",
            "DE05.10.172.00=初步诊断-中医病名名称",
            "DE05.10.130.00=初步诊断-中医病名代码",
            "DE05.10.172.00=初步诊断-中医证候名称",
            "DE05.10.130.00=初步诊断-中医证候代码",
            "DE05.01.058.00=初步诊断日期",
            "DE05.01.025.00=修正诊断-西医诊断名称",
            "DE05.01.024.00=修正诊断-西医诊断编码",
            "DE05.10.172.00=修正诊断-中医病名名称",
            "DE05.10.130.00=修正诊断-中医病名代码",
            "DE05.10.172.00=修正诊断-中医证候名称",
            "DE05.10.130.00=修正诊断-中医证候代码",
            "DE05.01.058.00=修正诊断日期",
            "DE05.01.025.00=确定诊断-西医诊断名称",
            "DE05.01.024.00=确定诊断-西医诊断编码",
            "DE05.10.172.00=确定诊断-中医病名名称",
            "DE05.10.130.00=确定诊断-中医病名代码",
            "DE05.10.172.00=确定诊断-中医证候名称",
            "DE05.10.130.00=确定诊断-中医证候代码",
            "DE05.01.058.00=确定诊断日期",
            "DE05.01.025.00=补充诊断名称",
            "DE05.01.024.00=补充诊断编码",
            "DE05.01.058.00=补充诊断日期",
            "DE05.01.080.00=入院诊断顺位",
            "DE02.01.039.00=接诊医师签名",
            "DE02.01.039.00=住院医师签名",
            "DE02.01.039.00=主治医师签名",
            "DE02.01.039.00=主任医师签名"
    );

    private List<String> kys = Lists.newArrayList(
            "住院号",
            "病区名称",
            "科室名称",
            "病房号",
            "病床号",
            "患者姓名",
            "性别代码",
            "年龄（岁）",
            "年龄（月）",
            "民族",
            "婚姻状况代码",
            "地址-省（自治区、直辖市）",
            "地址-市（地区、州）",
            "地址-县（区）",
            "地址-乡（镇、街道办事处）",
            "地址-村（街、路、弄等）",
            "地址-门牌号码",
            "职业类别代码",
            "入院日期时间",
            "病史陈述者姓名",
            "陈述者与患者的关系代码",
            "陈述内容可靠标志",
            "主诉",
            "现病史",
            "一般健康状况标志",
            "疾病史（含外伤）",
            "患者传染性标志",
            "传染病史",
            "预防接种史",
            "手术史",
            "输血史",
            "过敏史",
            "个人史",
            "婚育史",
            "月经史",
            "家族史",
            "体格检查--体温（℃）",
            "体格检查--脉率（次/min）",
            "体格检查--呼吸频率（次/min）",
            "体格检查--收缩压（mmHg）",
            "体格检查--舒张压（mmHg）",
            "体格检查--身高（cm）",
            "体格检查--体重（kg）",
            "体格检查--一般状况检查结果",
            "体格检查--皮肤和黏膜检查结果",
            "体格检查--全身浅表淋巴结检查结果",
            "体格检查--头部及其器官检查结果",
            "体格检查--颈部检查结果",
            "体格检查--胸部检查结果",
            "体格检查--腹部检查结果",
            "体格检查--肛门指诊检查结果描述",
            "体格检查--外生殖器检查结果",
            "体格检查--脊柱检查结果",
            "体格检查--四肢检查结果",
            "体格检查--神经系统检查结果",
            "专科情况",
            "辅助检查结果",
            "中医“四诊”观察结果",
            "治则治法",
            "初步诊断-西医诊断名称",
            "初步诊断-西医诊断编码",
            "初步诊断-中医病名名称",
            "初步诊断-中医病名代码",
            "初步诊断-中医证候名称",
            "初步诊断-中医证候代码",
            "初步诊断日期",
            "修正诊断-西医诊断名称",
            "修正诊断-西医诊断编码",
            "修正诊断-中医病名名称",
            "修正诊断-中医病名代码",
            "修正诊断-中医证候名称",
            "修正诊断-中医证候代码",
            "修正诊断日期",
            "确定诊断-西医诊断名称",
            "确定诊断-西医诊断编码",
            "确定诊断-中医病名名称",
            "确定诊断-中医病名代码",
            "确定诊断-中医证候名称",
            "确定诊断-中医证候代码",
            "确定诊断日期",
            "补充诊断名称",
            "补充诊断编码",
            "补充诊断日期",
            "入院诊断顺位",
            "接诊医师签名",
            "住院医师签名",
            "主治医师签名",
            "主任医师签名"
    );

    private Map<String, String> getKmaps() {
        Map<String, String> map = Maps.newLinkedHashMap();
        kmaps.forEach(kmap -> {
            String[] arry = kmap.split("=");
            map.put(arry[1], arry[0]);
        });
        return map;
    }

}