Browse Source

杭州七院按照文书创建时间统计规则上传

“wangdsYun 1 year ago
parent
commit
02338cdb01

+ 0 - 573
kernel/src/main/java/com/lantone/qc/kernel/analysis/EZAnalysis.java

@@ -1,573 +0,0 @@
-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;
-    }
-
-}

+ 67 - 0
kernel/src/main/java/com/lantone/qc/kernel/catalogue/hangzhoudiqi/firstcourserecord/FIRC0094.java

@@ -0,0 +1,67 @@
+package com.lantone.qc.kernel.catalogue.hangzhoudiqi.firstcourserecord;
+
+import com.lantone.qc.kernel.catalogue.QCCatalogue;
+import com.lantone.qc.kernel.util.CatalogueUtil;
+import com.lantone.qc.pub.model.InputInfo;
+import com.lantone.qc.pub.model.OutputInfo;
+import com.lantone.qc.pub.model.doc.FirstCourseRecordDoc;
+import com.lantone.qc.pub.model.doc.MedicalRecordInfoDoc;
+import com.lantone.qc.pub.util.StringUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Component;
+
+import java.text.ParseException;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * @ClassName : FIRC0094
+ * @Description :  首次病程未在患者入院8小时内完成(杭州七院文书创建日期版)
+ * @Author : dsYun
+ * @Date: 2024-06-03 17:28
+ */
+@Component
+public class FIRC0094 extends QCCatalogue {
+    public void start(InputInfo inputInfo, OutputInfo outputInfo) throws ParseException {
+        status.set("0");
+        MedicalRecordInfoDoc medicalRecordInfoDoc = inputInfo.getMedicalRecordInfoDoc();
+        FirstCourseRecordDoc firstCourseRecordDoc = inputInfo.getFirstCourseRecordDoc();
+        if (firstCourseRecordDoc != null && medicalRecordInfoDoc != null) {
+            Map<String, String> courseRecordDocStructureMap = firstCourseRecordDoc.getStructureMap();
+            Map<String, String> medicalRecordStructureMap = medicalRecordInfoDoc.getStructureMap();
+            if (courseRecordDocStructureMap != null && medicalRecordStructureMap != null) {
+                String recDate = courseRecordDocStructureMap.get("firstCreateDate");
+                String beDate = medicalRecordStructureMap.get("behospitalDate");
+                if (StringUtils.isNotEmpty(recDate) && StringUtils.isNotEmpty(beDate)) {
+                    Date date_in = StringUtil.parseDateTime(beDate);
+                    Date date_out = StringUtil.parseDateTime(recDate);
+                    if (date_in == null || date_out == null) {
+                        return;
+                    }
+                    boolean firc = CatalogueUtil.compareTime(date_in, date_out, 8 * 60L);
+                    if (firc) {
+                        status.set("-1");
+                    }
+                }
+            }
+        } else {
+            if (medicalRecordInfoDoc != null) {
+                Map<String, String> medicalRecordStructureMap = medicalRecordInfoDoc.getStructureMap();
+                if (medicalRecordStructureMap != null) {
+                    String beDate = medicalRecordStructureMap.get("behospitalDate");
+                    if (StringUtils.isNotEmpty(beDate)) {
+                        Date date_in = StringUtil.parseDateTime(beDate);
+                        Date date_out = new Date();
+                        if (date_in == null) {
+                            return;
+                        }
+                        boolean firc = CatalogueUtil.compareTime(date_in, date_out, 8 * 60L);
+                        if (firc) {
+                            status.set("-1");
+                        }
+                    }
+                }
+            }
+        }
+    }
+}

+ 1 - 1
kernel/src/main/java/com/lantone/qc/kernel/catalogue/hangzhoudiqi/threelevelward/THR0124.java

@@ -29,7 +29,7 @@ public class THR0124 extends QCCatalogue {
             //入院日期
             String admisDate = medicalRecordInfoDoc.getStructureMap().get("behospitalDate");
             //模板创建日期
-            String recDate = beHospitalizedDoc.getStructureMap().get("recDate");
+            String recDate = beHospitalizedDoc.getStructureMap().get("firstCreateDate");
             if (CatalogueUtil.isEmpty(admisDate) || CatalogueUtil.isEmpty(recDate)) {
                 return;
             }

+ 13 - 6
kernel/src/main/java/com/lantone/qc/kernel/catalogue/hangzhoudiqi/threelevelward/THR0129.java

@@ -1,6 +1,5 @@
 package com.lantone.qc.kernel.catalogue.hangzhoudiqi.threelevelward;
 
-import com.google.common.collect.Lists;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.kernel.util.CatalogueUtil;
 import com.lantone.qc.pub.model.InputInfo;
@@ -12,6 +11,7 @@ import com.lantone.qc.pub.util.DateUtil;
 import com.lantone.qc.pub.util.StringUtil;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -25,11 +25,18 @@ public class THR0129 extends QCCatalogue {
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         status.set("0");
         NoticeOfConversationDoc noticeOfConversationDoc = inputInfo.getNoticeOfConversationDoc();
-        for (String notice: noticeOfConversationDoc.getAllNoticeOfConverstartion()) {
-            if(!notice.contains("猝死危险因素评估表") && !notice.contains("自杀危险因素评估表") && !notice.contains("攻击危险评估表")  ){
-                return;
-            }
+        List<String> noticeList = new ArrayList<>();
+        if (noticeOfConversationDoc == null) {
+            return;
+        }
+        for (String notice : noticeOfConversationDoc.getAllNoticeOfConverstartion()) {
+            noticeList.add(notice);
         }
+        if (noticeList.size() > 0 && !noticeList.contains("猝死危险因素评估表") && !noticeList.contains("自杀危险因素评估表")
+                && !noticeList.contains("攻击危险评估表")) {
+            return;
+        }
+
         BeHospitalizedDoc beHospitalizedDoc = inputInfo.getBeHospitalizedDoc();
         MedicalRecordInfoDoc medicalRecordInfoDoc = inputInfo.getMedicalRecordInfoDoc();
         if (beHospitalizedDoc == null || medicalRecordInfoDoc == null) {
@@ -39,7 +46,7 @@ public class THR0129 extends QCCatalogue {
             //入院日期
             String admisDate = medicalRecordInfoDoc.getStructureMap().get("behospitalDate");
             //模板创建日期
-            String recDate = beHospitalizedDoc.getStructureMap().get("recDate");
+            String recDate = beHospitalizedDoc.getStructureMap().get("firstCreateDate");
             if (CatalogueUtil.isEmpty(admisDate) || CatalogueUtil.isEmpty(recDate)) {
                 return;
             }

+ 138 - 0
kernel/src/main/java/com/lantone/qc/kernel/catalogue/hangzhoudiqi/threelevelward/THR0589.java

@@ -0,0 +1,138 @@
+package com.lantone.qc.kernel.catalogue.hangzhoudiqi.threelevelward;
+
+import com.lantone.qc.kernel.catalogue.QCCatalogue;
+import com.lantone.qc.pub.model.InputInfo;
+import com.lantone.qc.pub.model.OutputInfo;
+import com.lantone.qc.pub.model.doc.StagesSummaryDoc;
+import com.lantone.qc.pub.model.doc.ThreeLevelWardDoc;
+import com.lantone.qc.pub.model.doc.operation.OperationDiscussionDoc;
+import com.lantone.qc.pub.model.doc.operation.OperationDoc;
+import com.lantone.qc.pub.model.doc.transferrecord.TransferIntoDoc;
+import com.lantone.qc.pub.model.doc.transferrecord.TransferOutDoc;
+import com.lantone.qc.pub.model.doc.transferrecord.TransferRecordDoc;
+import com.lantone.qc.pub.util.DateUtil;
+import com.lantone.qc.pub.util.StringUtil;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @ClassName : THR0589
+ * @Description : 住院期间连续3天无病程记录(杭州七院文书创建日期版)
+ * @Author : dsYun
+ * @Date: 2024-06-03 14:22
+ */
+@Component
+public class THR0589 extends QCCatalogue {
+    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
+        status.set("0");
+        Date leaveDate = null;
+        if (inputInfo.getMedicalRecordInfoDoc() != null) {
+            Map<String, String> medicalRecordInfoStructureMap = inputInfo.getMedicalRecordInfoDoc().getStructureMap();
+            String leaveHospitalTime = medicalRecordInfoStructureMap.get("leaveHospitalDate");
+            leaveDate = StringUtil.parseDateTime(leaveHospitalTime);
+            if (leaveDate == null) {
+                //                LeaveHospitalDoc leaveHospitalDoc = inputInfo.getLeaveHospitalDoc();
+                //                if (leaveHospitalDoc != null) {
+                //                    leaveDate = StringUtil.parseDateTime(leaveHospitalDoc.getStructureMap().get("出院日期"));
+                //                }
+                leaveDate = new Date();
+            }
+        }
+        //查房记录
+        List<ThreeLevelWardDoc> threeLevelWardDocs = inputInfo.getThreeLevelWardDocs();
+        if (threeLevelWardDocs.size() == 0) {
+            return;
+        }
+        //所有查房记录的日期天
+        List<Date> dateThreeLevelDay = new ArrayList<>();
+        StringBuffer sb = new StringBuffer();
+        //所有的查房记录
+        List<ThreeLevelWardDoc> allDoctorWradDocs = threeLevelWardDocs.get(0).getAllDoctorWradDocs();
+        for (ThreeLevelWardDoc doc : allDoctorWradDocs) {
+            Date threeLevelDate = StringUtil.parseDateTime(doc.getStructureMap().get("recDate"));
+            if (threeLevelDate == null) {
+                continue;
+            }
+            dateThreeLevelDay.add(threeLevelDate);
+        }
+        /******************************************术后首程********************************************************/
+        if (inputInfo.getOperationDocs().size() > 0) {
+            List<String> recordDateList = inputInfo.getOperationDocs().stream().map(OperationDoc::getOperationDiscussionDoc).filter(Objects::nonNull)
+                    .map(OperationDiscussionDoc::getStructureMap).filter(i -> StringUtil.isNotBlank(i.get("recDate")))
+                    .map(i -> i.get("recDate")).collect(Collectors.toList());
+            for (String recordDateStr : recordDateList) {
+                Date recordDate = StringUtil.parseDateTime(recordDateStr);
+                if (recordDate == null) {
+                    continue;
+                }
+                dateThreeLevelDay.add(recordDate);
+            }
+        }
+        /******************************************转入转出********************************************************/
+        if (inputInfo.getTransferRecordDocs() != null) {
+            TransferRecordDoc transferRecordDocs = inputInfo.getTransferRecordDocs();
+            List<String> intoRecordDateList = transferRecordDocs.getTransferIntoDocs()
+                    .stream().map(TransferIntoDoc::getStructureMap).filter(i -> StringUtil.isNotBlank(i.get("recDate")))
+                    .map(i -> i.get("recDate")).collect(Collectors.toList());
+            for (String recordDateStr : intoRecordDateList) {
+                Date recordDate = StringUtil.parseDateTime(recordDateStr);
+                if (recordDate == null) {
+                    continue;
+                }
+                dateThreeLevelDay.add(recordDate);
+            }
+            intoRecordDateList = transferRecordDocs.getTransferOutDocs()
+                    .stream().map(TransferOutDoc::getStructureMap).filter(i -> StringUtil.isNotBlank(i.get("recDate")))
+                    .map(i -> i.get("recDate")).collect(Collectors.toList());
+            for (String recordDateStr : intoRecordDateList) {
+                Date recordDate = StringUtil.parseDateTime(recordDateStr);
+                if (recordDate == null) {
+                    continue;
+                }
+                dateThreeLevelDay.add(recordDate);
+            }
+        }
+        /******************************************阶段小结********************************************************/
+        if (inputInfo.getStagesSummaryDocs().size() > 0) {
+            List<String> intoRecordDateList = inputInfo.getStagesSummaryDocs().stream().map(StagesSummaryDoc::getStructureMap)
+                    .filter(i -> StringUtil.isNotBlank(i.get("recDate")))
+                    .map(i -> i.get("recDate")).collect(Collectors.toList());
+            for (String recordDateStr : intoRecordDateList) {
+                Date recordDate = StringUtil.parseDateTime(recordDateStr);
+                if (recordDate == null) {
+                    continue;
+                }
+                dateThreeLevelDay.add(recordDate);
+            }
+        }
+        dateThreeLevelDay = dateThreeLevelDay.stream().sorted().collect(Collectors.toList());
+        int timeCha = 259200000;
+        //获取连续3天无查房记录的时间
+        for (int i = 0; i < dateThreeLevelDay.size(); i++) {
+            if (i + 1 < dateThreeLevelDay.size()) {
+                if (DateUtil.dateZeroClear(dateThreeLevelDay.get(i + 1)).getTime() - DateUtil.dateZeroClear(dateThreeLevelDay.get(i)).getTime() > timeCha &&
+                        dateThreeLevelDay.get(i + 1).before(leaveDate)) {
+                    infoAppend(sb, dateThreeLevelDay.get(i), dateThreeLevelDay.get(i + 1));
+                }
+            }
+        }
+        if (sb.toString().length() > 0) {
+            status.set("-1");
+            info.set(sb.toString().substring(0, sb.toString().length() - 1));
+        }
+    }
+
+    /**
+     * 拼接提示信息
+     *
+     * @param sb
+     * @param bfDate
+     * @param afDate
+     */
+    private void infoAppend(StringBuffer sb, Date bfDate, Date afDate) {
+        sb.append("(").append(DateUtil.formatDate(bfDate))
+                .append("->").append(DateUtil.formatDate(afDate)).append(")").append("、");
+    }
+}

+ 0 - 43
kernel/src/main/java/com/lantone/qc/kernel/web/controller/EzController.java

@@ -1,43 +0,0 @@
-package com.lantone.qc.kernel.web.controller;
-
-import com.lantone.qc.kernel.analysis.EZAnalysis;
-import com.lantone.qc.pub.model.vo.EzAnalysisVO;
-import com.lantone.qc.pub.res.EzAnalysisDTO;
-import com.lantone.qc.pub.res.Response;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.CrossOrigin;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.List;
-
-/**
- * @ClassName : QCController
- * @Description : 质控总入口
- * @Author : 楼辉荣
- * @Date: 2020-03-03 19:57
- */
-@Slf4j
-@Api(value = "恩泽服务接口")
-@RestController
-@CrossOrigin(origins = "*", maxAge = 3600)
-@RequestMapping(value = "ez")
-public class EzController {
-
-    @Autowired
-    private EZAnalysis ezAnalysis;
-
-    @ApiOperation(value = "恩泽解析接口")
-    @PostMapping("jx")
-    public Response<List<EzAnalysisDTO>> ezAnalysis(@RequestBody EzAnalysisVO ezAnalysisVO) throws Exception {
-        Response response = new Response();
-        response.setData(ezAnalysis.anlysis(ezAnalysisVO));
-        return response;
-    }
-
-}

+ 0 - 518
kernel/src/test/java/com/lantone/qc/kernel/ChangxDataImportApiTest.java

@@ -1,518 +0,0 @@
-package com.lantone.qc.kernel;
-
-import com.lantone.qc.pub.jdbc.MysqlJdbc;
-import com.lantone.qc.pub.util.FastJsonUtils;
-import com.lantone.qc.pub.util.PropertiesUtil;
-import com.lantone.qc.dbanaly.facade.changx.CxXmlUtil;
-import com.lantone.qc.trans.changx.util.CxXmlUtilTemp;
-import com.lantone.qc.dbanaly.facade.taizhou.TzXmlUtil;
-import org.apache.commons.lang3.StringUtils;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.zip.GZIPInputStream;
-
-/**
- * @ClassName : TaizDataImportApiTest
- * @Description :
- * @Author : 楼辉荣
- * @Date: 2020-03-31 19:34
- */
-public class ChangxDataImportApiTest {
-    private static String hospitalId = "1";
-    private static String cid = "changx";
-
-    private Map<String,String> caseMap = new HashMap<>();
-    private List<String> deletePatient = new ArrayList<>();
-
-    private static Map<String, String> tableMap = new HashMap<>();
-
-    private static void initTableMap() {
-        if (cid.equals("changx")) {
-            tableMap.put("BR_INPATIENTINFO", "BR_INPATIENTINFO");//患者信息
-            tableMap.put("MR_MEDICALRECORDS", "MR_MEDICALRECORDS");//病案首页--手术
-            tableMap.put("AR_MEDIRECCLASS", "AR_MEDIRECCLASS");//病案首页--手术
-            tableMap.put("MR_MRCONTENT", "MR_MRCONTENT");//病案首页--手术
-            tableMap.put("GI_USERINFO", "GI_USERINFO"); //医生
-            tableMap.put("HI_DEPTINFO", "HI_DEPTINFO");//科室
-            tableMap.put("BR_RECHOME", "BR_RECHOME");//病案首页
-            tableMap.put("BR_RECDIAGNOSE", "BR_RECDIAGNOSE");//病案首页--出院诊断 门急诊诊断
-            tableMap.put("BR_DOCTADVICE", "BR_DOCTADVICE");//医嘱
-            tableMap.put("BR_RECOPERATION", "BR_RECOPERATION");//病案首页--手术
-        } else if (cid.equals("taizhou")) {
-            tableMap.put("BR_INPATIENTINFO", "BR_INPATIENTINFO_TZ");
-            tableMap.put("GI_USERINFO", "GI_USERINFO_TZ");
-            tableMap.put("HI_DEPTINFO", "HI_DEPTINFO_TZ");
-            tableMap.put("BR_RECHOME", "BR_RECHOME_TZ");
-            tableMap.put("BR_RECDIAGNOSE", "BR_RECDIAGNOSE_TZ");
-            tableMap.put("BR_DOCTADVICE", "BR_DOCTADVICE_TZ");
-            tableMap.put("BR_RECOPERATION", "BR_RECOPERATION_CX");
-        }
-    }
-
-    public static void main(String[] args) {
-//        String patientId = "ZY010000661273";
-//
-        ChangxDataImportApiTest test = new ChangxDataImportApiTest();
-        test.dayevent();
-//        initTableMap();
-//        //模块映射
-//        test.loadModelHospital();
-//        //患者信息
-//        test.insertPatient(test.loadOraclePatients(tableMap.get("BR_INPATIENTINFO"), patientId));
-//        test.insertDoctor(test.loadOracleDoctorInfos(tableMap.get("GI_USERINFO"), tableMap.get("HI_DEPTINFO")));
-
-//        //病人流水号获取    病历号--->id
-//        Map<String, String> patientMap = test.loadPatients(hospitalId, patientId);
-//        //model-->id
-//        Map<String, String> modelMap = test.loadModel();
-//        test.insertPatientText(patientMap, modelMap);
-    }
-
-    private void dayevent() {
-        MysqlJdbc mysqlJdbc = initMysqlJdbc();
-        Connection conn = mysqlJdbc.connect();
-        Statement st = null;
-        ResultSet rs = null;
-        String r1, r2;
-        Map<String, String> map = new HashMap<>();
-        try {
-            st = conn.createStatement();
-            String sql = "select t2.xml_text, t1.behospital_code from med_medical_record t1, med_medical_record_content t2 where t1.rec_id = t2.rec_id and t1.rec_title = '日常病程记录'";
-            rs = st.executeQuery(sql);
-            while (rs.next()) {
-                r1 = rs.getString(1);
-                r2 = rs.getString(2);
-                Map<String, String> xmlNodeValueMap = CxXmlUtil.firstLevelNodeValue(r1);
-                System.out.println(r2 + ":" + xmlNodeValueMap.get("日常病程记录++++文本框"));
-            }
-        } catch (SQLException sqle) {
-            sqle.printStackTrace();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            mysqlJdbc.close(rs, st, conn);
-        }
-    }
-
-    private void insertPatient(List<Patient> patients) {
-        List<Map<String, Object>> list = new ArrayList<>();
-        for (Patient patient : patients) {
-            Map<String, Object> patientMap = new HashMap<>();
-            patientMap.put("case_number", patient.getBrzyid());
-            patientMap.put("hospital_id", hospitalId);
-            list.add(patientMap);
-        }
-        initMysqlJdbc().insert(list, "qc_cases_number", new String[]{"hospital_id", "case_number"});
-    }
-
-    private void insertDoctor(List<Doctor> doctors) {
-        List<Map<String, Object>> list = new ArrayList<>();
-        for (Doctor doctor : doctors) {
-            Map<String, Object> doctorMap = new HashMap<>();
-            doctorMap.put("doctor_id", doctor.getDoctorId());
-            doctorMap.put("doctor_name", doctor.getDoctorName());
-            doctorMap.put("dept_id", doctor.getDeptId());
-            doctorMap.put("dept_name", doctor.getDeptName());
-            doctorMap.put("professor", doctor.getProfessor());
-            list.add(doctorMap);
-        }
-        initMysqlJdbc().insert(list, "qc_doctor_info", new String[]{"doctor_id", "doctor_name", "dept_id", "dept_name", "professor"});
-    }
-
-    private void insertPatientText(Map<String, String> patientMap, Map<String, String> modelMap) {
-        List<Map<String, Object>> list = new ArrayList<>();
-        for (Map.Entry<String, String> entry : patientMap.entrySet()) {
-            List<PatientText> patientTexts = new ArrayList<>();
-            //病人的病案首页内容
-            List<Map<String, Object>> homePageList = DataTest.loadHomePage(hospitalId, tableMap.get("BR_RECHOME"), entry.getKey());
-            if (homePageList == null || homePageList.isEmpty()) { //没病案首页直接不导入
-                deletePatient.add(entry.getKey()); //没病案首页的患者也要删除
-                continue;
-            }
-            Map<String, Object> homePageMap = homePageList.get(0);
-            homePageMap.put("出院诊断", FastJsonUtils.getBeanToJson(DataTest.loadHomePageDiagnose(hospitalId, tableMap.get("BR_RECDIAGNOSE"),"2", entry.getKey())).replaceAll("\"", "'"));
-            homePageMap.put("损伤、中毒外部原因", FastJsonUtils.getBeanToJson(DataTest.loadHomePageDiagnose(hospitalId, tableMap.get("BR_RECDIAGNOSE"),"3", entry.getKey())).replaceAll("\"", "'"));
-            homePageMap.put("病理诊断", FastJsonUtils.getBeanToJson(DataTest.loadHomePageDiagnose(hospitalId, tableMap.get("BR_RECDIAGNOSE"), "4", entry.getKey())).replaceAll("\"", "'"));
-            homePageMap.put("手术信息", FastJsonUtils.getBeanToJson(DataTest.loadHomePageOperation(hospitalId, tableMap.get("BR_RECOPERATION"), tableMap.get("GI_USERINFO"), entry.getKey())).replaceAll("\"", "'"));
-
-            Map<String, Object> firstPageTextMap = new HashMap<>();
-            firstPageTextMap.put("case_number", entry.getKey());
-            firstPageTextMap.put("case_number_id", patientMap.get(entry.getKey()));
-            firstPageTextMap.put("hospital_id", hospitalId);
-            firstPageTextMap.put("mode_id", 6);
-            firstPageTextMap.put("origin_mode", "病案首页");
-            firstPageTextMap.put("origin_text", FastJsonUtils.getBeanToJson(homePageMap));
-            String pagetext = "";
-            for (Map.Entry<String, Object> e : homePageMap.entrySet()) {
-                pagetext = pagetext + "【" + e.getKey() + "】:" + e.getValue().toString() + "\n";
-            }
-            firstPageTextMap.put("text", pagetext);
-            if ("changx".equals(cid)) {
-                patientTexts = loadChangxOraclePatientTexts(entry.getKey());
-            }
-            if ("taizhou".equals(cid)) {
-                patientTexts = loadTaizhouOraclePatientTexts(entry.getKey());
-            }
-            if (patientTexts.size() == 0 || !wholePatientRecord(patientTexts, modelMap)) {
-                continue;
-            }
-            //数据完整后才放入病案首页
-            list.add(firstPageTextMap);
-
-            //病人医嘱信息
-            List<Map<String, Object>> docAdviceMap = DataTest.loadHomePage(hospitalId, tableMap.get("BR_DOCTADVICE"), entry.getKey());
-            for (Map<String, Object> docMap : docAdviceMap) {
-                Map<String, Object> docAdviceTextMap = new HashMap<>();
-                docAdviceTextMap.put("case_number", entry.getKey());
-                docAdviceTextMap.put("case_number_id", patientMap.get(entry.getKey()));
-                docAdviceTextMap.put("hospital_id", hospitalId);
-                docAdviceTextMap.put("mode_id", 8);
-                docAdviceTextMap.put("origin_mode", "医嘱信息");
-                docAdviceTextMap.put("origin_text", FastJsonUtils.getBeanToJson(docMap));
-                pagetext = "";
-                for (Map.Entry<String, Object> e : docMap.entrySet()) {
-                    pagetext = pagetext + "【" + e.getKey() + "】:" + e.getValue().toString() + "\n";
-                }
-                docAdviceTextMap.put("text", pagetext);
-                list.add(docAdviceTextMap);
-            }
-            //病人其他文书信息
-            for (PatientText patientText : patientTexts) {
-                Map<String, Object> patientTextMap = new HashMap<>();
-                patientTextMap.put("case_number", patientText.getBrzyid());
-                patientTextMap.put("case_number_id", patientMap.get(patientText.getBrzyid()));
-                patientTextMap.put("hospital_id", hospitalId);
-                patientTextMap.put("mode_id", modelMap.get(caseMap.get(patientText.getBljlmc())));
-                patientTextMap.put("origin_mode", patientText.getBljlmc());
-                if (patientTextMap.get("mode_id") == null) {
-                    continue;
-                }
-                patientTextMap.put("origin_text", patientText.getBljlnr());
-
-                String text = "";
-                Map<String, String> textMap = new HashMap<>();
-                if ("changx".equals(cid)) {
-                    textMap = CxXmlUtilTemp.beHospitalizedXmlToMap(patientText.getBljlnr(), caseMap.get(patientText.getBljlmc()));
-                }
-                if ("taizhou".equals(cid)) {
-                    textMap = TzXmlUtil.getXmlToMapForTZ(patientText.getBljlnr());
-                }
-                for (Map.Entry<String, String> e : textMap.entrySet()) {
-                    text = text + "【" + e.getKey() + "】:" + e.getValue() + "\n";
-                }
-                patientTextMap.put("text", text);
-                list.add(patientTextMap);
-            }
-        }
-        initMysqlJdbc().insert(list, "qc_model_mapping", new String[]{"case_number", "case_number_id", "origin_text", "mode_id", "text", "origin_mode"});
-
-        deletePatientInfos(deletePatient);
-    }
-
-    /**
-     * 验证数据完整性
-     * @param patientTexts
-     * @param modelMap
-     * @return
-     */
-    private boolean wholePatientRecord(List<PatientText> patientTexts, Map<String, String> modelMap) {
-        Map<String, String> m = new HashMap<>();
-        for (PatientText patientText : patientTexts) {
-            String modelId = modelMap.get(caseMap.get(patientText.getBljlmc()));
-            if (StringUtils.isEmpty(modelId)) {
-                continue;
-            }
-            if (modelId.equals("1") && patientText.getBljlnr().indexOf("<") != 0) {
-                deletePatient.add(patientTexts.get(0).getBrzyid());
-                return false;
-            }
-            m.put(modelId, modelId);
-        }
-        if (m.get("1") != null && m.get("2") != null && m.get("4") != null && (m.get("5") != null || m.get("24") != null)) {
-            return true;
-        } else {
-            deletePatient.add(patientTexts.get(0).getBrzyid());
-        }
-        return false;
-    }
-
-    private List<Patient> loadOraclePatients(String tableName) {
-        return loadOraclePatients(tableName, "");
-    }
-
-    private List<Patient> loadOraclePatients(String tableName, String patientId) {
-        MysqlJdbc mysqlJdbc = initOracleJdbc();
-        Connection conn = mysqlJdbc.connect();
-        Statement st = null;
-        ResultSet rs = null;
-        String r1, r2;
-        List<Patient> patients = new ArrayList<>();
-        try {
-            st = conn.createStatement();
-            String sql = "";
-            if (StringUtils.isNotEmpty(patientId)) {
-                sql = "select BRZYID from " + tableName + " where BRZYID = '" + patientId + "'";
-            } else {
-                sql = "select BRZYID from " + tableName;
-            }
-            rs = st.executeQuery(sql);
-            while (rs.next()) {
-                r1 = rs.getString(1);
-                Patient patient = new Patient();
-                patient.setBrzyid(r1);
-                patients.add(patient);
-            }
-        } catch (SQLException sqle) {
-            sqle.printStackTrace();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            mysqlJdbc.close(rs, st, conn);
-        }
-        return patients;
-    }
-
-    private List<Doctor> loadOracleDoctorInfos(String tableUser, String tableDept) {
-        MysqlJdbc mysqlJdbc = initOracleJdbc();
-        Connection conn = mysqlJdbc.connect();
-        Statement st = null;
-        ResultSet rs = null;
-        List<Doctor> doctors = new ArrayList<>();
-        try {
-            st = conn.createStatement();
-            String sql = "select u.yhrydm, u.yhrymc, u.yhryzc, dept.zzksid, dept.zzksmc from " + tableDept + " dept, " + tableUser + " u where u.zzksid = dept.zzksid";
-            rs = st.executeQuery(sql);
-            while (rs.next()) {
-                Doctor doctor = new Doctor();
-                doctor.setDoctorId(rs.getString(1));
-                doctor.setDoctorName(rs.getString(2));
-                doctor.setProfessor(rs.getString(3));
-                doctor.setDeptId(rs.getString(4));
-                doctor.setDeptName(rs.getString(5));
-                doctors.add(doctor);
-            }
-        } catch (SQLException sqle) {
-            sqle.printStackTrace();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            mysqlJdbc.close(rs, st, conn);
-        }
-        return doctors;
-    }
-
-    private List<PatientText> loadTaizhouOraclePatientTexts(String brzyid) {
-        MysqlJdbc mysqlJdbc = initOracleJdbc();
-        Connection conn = mysqlJdbc.connect();
-        Statement st = null;
-        ResultSet rs = null;
-        String r1, r2, r3;
-        List<PatientText> patientTexts = new ArrayList<>();
-        try {
-            st = conn.createStatement();
-            String sql = "select brzyid,bljlmc,bljlnr from mr_medicalrecords_TZ a " +
-                    "left join mr_mrcontent_TZ b on a.bljlid=b.bljlid " +
-                    "where bljlnr is not null and brzyid = '" + brzyid + "' " +
-                    "order by brzyid";
-            rs = st.executeQuery(sql);
-            while (rs.next()) {
-                r1 = rs.getString(1);
-                r2 = rs.getString(2);
-                r3 = rs.getString(3);
-                PatientText patientText = new PatientText();
-                patientText.setBrzyid(r1);
-                patientText.setBljlmc(r2);
-                patientText.setBljlnr(r3);
-                patientTexts.add(patientText);
-            }
-        } catch (SQLException sqle) {
-            sqle.printStackTrace();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            mysqlJdbc.close(rs, st, conn);
-        }
-        return patientTexts;
-    }
-    private List<PatientText> loadChangxOraclePatientTexts(String brzyid) {
-        MysqlJdbc mysqlJdbc = initOracleJdbc();
-        Connection conn = mysqlJdbc.connect();
-        Statement st = null;
-        ResultSet rs = null;
-        String r1, r2;
-        List<PatientText> patientTexts = new ArrayList<>();
-        try {
-            st = conn.createStatement();
-            String sql = "select a.brzyid,c.bllbmc,b.bljlnr from " + tableMap.get("MR_MEDICALRECORDS") + " a " +
-                    "left join " + tableMap.get("MR_MRCONTENT") + " b on a.bljlid=b.bljlid " +
-                    "left join " + tableMap.get("AR_MEDIRECCLASS") + " c on a.Bllbid = c.bllbid " +
-                    "where bljlnr is not null and brzyid = '" + brzyid + "' and a.bljlmc != '诊断证明书' " +
-                    "order by brzyid";
-            rs = st.executeQuery(sql);
-            while (rs.next()) {
-                r1 = rs.getString(1);
-                r2 = rs.getString(2);
-                java.sql.Blob blob = rs.getBlob(3);
-
-                InputStream in = blob.getBinaryStream();
-
-                GZIPInputStream ginzip = new GZIPInputStream(in);
-
-                ByteArrayOutputStream out = new ByteArrayOutputStream();
-                byte[] buffer = new byte[1024];
-                int offset = -1;
-                while ((offset = ginzip.read(buffer)) != -1) {
-                    out.write(buffer, 0, offset);
-                }
-                String decompressed = out.toString();
-                in.close();
-                out.close();
-                ginzip.close();
-
-                PatientText patientText = new PatientText();
-                patientText.setBrzyid(r1);
-                patientText.setBljlmc(r2);
-                patientText.setBljlnr(decompressed);
-                patientTexts.add(patientText);
-            }
-        } catch (SQLException sqle) {
-            sqle.printStackTrace();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            mysqlJdbc.close(rs, st, conn);
-        }
-        return patientTexts;
-    }
-
-    private Map<String, String> loadPatients(String hospitalId) {
-        return loadPatients(hospitalId, null);
-    }
-
-    private Map<String, String> loadPatients(String hospitalId, String patientId) {
-        MysqlJdbc mysqlJdbc = initMysqlJdbc();
-        Connection conn = mysqlJdbc.connect();
-        Statement st = null;
-        ResultSet rs = null;
-        String r1, r2;
-        Map<String, String> map = new HashMap<>();
-        try {
-            st = conn.createStatement();
-            String sql = "";
-            if (StringUtils.isNotEmpty(patientId)) {
-                sql = "select id, case_number from qc_cases_number where hospital_id = " + hospitalId + " and case_number = '" + patientId + "'";
-            } else {
-                sql = "select id, case_number from qc_cases_number where hospital_id = " + hospitalId;
-            }
-            rs = st.executeQuery(sql);
-            while (rs.next()) {
-                r1 = rs.getString(1);
-                r2 = rs.getString(2);
-                map.put(r2, r1);
-            }
-        } catch (SQLException sqle) {
-            sqle.printStackTrace();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            mysqlJdbc.close(rs, st, conn);
-        }
-        return map;
-    }
-
-    private Map<String, String> loadModel() {
-        MysqlJdbc mysqlJdbc = initMysqlJdbc();
-        Connection conn = mysqlJdbc.connect();
-        Statement st = null;
-        ResultSet rs = null;
-        String r1, r2;
-        Map<String, String> map = new HashMap<>();
-        try {
-            st = conn.createStatement();
-            String sql = "select id, name from qc_mode";
-            rs = st.executeQuery(sql);
-            while (rs.next()) {
-                r1 = rs.getString(1);
-                r2 = rs.getString(2);
-                map.put(r2, r1);
-            }
-        } catch (SQLException sqle) {
-            sqle.printStackTrace();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            mysqlJdbc.close(rs, st, conn);
-        }
-        return map;
-    }
-
-    private void loadModelHospital() {
-        MysqlJdbc mysqlJdbc = initMysqlJdbc();
-        Connection conn = mysqlJdbc.connect();
-        Statement st = null;
-        ResultSet rs = null;
-        String r1, r2;
-        try {
-            st = conn.createStatement();
-            String sql = "select hospital_model_name, stand_model_name from qc_model_hospital where stand_model_name is not null and hospital_id = " + hospitalId;
-            rs = st.executeQuery(sql);
-            while (rs.next()) {
-                r1 = rs.getString(1);
-                r2 = rs.getString(2);
-                caseMap.put(r1, r2);
-            }
-        } catch (SQLException sqle) {
-            sqle.printStackTrace();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            mysqlJdbc.close(rs, st, conn);
-        }
-    }
-
-    private void deletePatientInfos(List<String> caseNumbers) {
-        MysqlJdbc mysqlJdbc = initMysqlJdbc();
-        Connection conn = mysqlJdbc.connect();
-        Statement st = null;
-        ResultSet rs = null;
-        String r1, r2;
-        try {
-            st = conn.createStatement();
-            for (String caseNumber : caseNumbers) {
-                String sql = "delete from qc_cases_number where case_number = '" + caseNumber + "'";
-                st.execute(sql);
-            }
-        } catch (SQLException sqle) {
-            sqle.printStackTrace();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            mysqlJdbc.close(rs, st, conn);
-        }
-    }
-
-    private MysqlJdbc initMysqlJdbc() {
-        PropertiesUtil propertiesUtil = new PropertiesUtil("kernel.properties");
-        MysqlJdbc mysqlJdbc = new MysqlJdbc(propertiesUtil.getProperty("mysql.test.user"),
-                propertiesUtil.getProperty("mysql.test.password"),
-                propertiesUtil.getProperty("mysql.test.url"));
-        return mysqlJdbc;
-    }
-
-    private MysqlJdbc initOracleJdbc() {
-        PropertiesUtil propertiesUtil = new PropertiesUtil("kernel.properties");
-        MysqlJdbc mysqlJdbc = new MysqlJdbc(propertiesUtil.getProperty("oracle.test.user"),
-                propertiesUtil.getProperty("oracle.test.password"),
-                propertiesUtil.getProperty("oracle.test.url"), propertiesUtil.getProperty("oracle.test.driver"));
-        return mysqlJdbc;
-    }
-}

+ 0 - 493
kernel/src/test/java/com/lantone/qc/kernel/TaizDataImportApiTest.java

@@ -1,493 +0,0 @@
-package com.lantone.qc.kernel;
-
-import com.lantone.qc.pub.jdbc.MysqlJdbc;
-import com.lantone.qc.pub.util.FastJsonUtils;
-import com.lantone.qc.pub.util.PropertiesUtil;
-import com.lantone.qc.trans.changx.util.CxXmlUtilTemp;
-import com.lantone.qc.dbanaly.facade.taizhou.TzXmlUtil;
-import org.apache.commons.lang3.StringUtils;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.zip.GZIPInputStream;
-
-/**
- * @ClassName : TaizDataImportApiTest
- * @Description :
- * @Author : 楼辉荣
- * @Date: 2020-03-31 19:34
- */
-public class TaizDataImportApiTest {
-    private static String hospitalId = "3";
-    private static String cid = "taizhou";
-
-    private Map<String,String> caseMap = new HashMap<>();
-    private List<String> deletePatient = new ArrayList<>();
-
-    private static Map<String, String> tableMap = new HashMap<>();
-
-    private static void initTableMap() {
-        if (cid.equals("changx")) {
-            tableMap.put("BR_INPATIENTINFO", "BR_INPATIENTINFO");//患者信息
-            tableMap.put("MR_MEDICALRECORDS", "MR_MEDICALRECORDS");//病案首页--手术
-            tableMap.put("AR_MEDIRECCLASS", "AR_MEDIRECCLASS");//病案首页--手术
-            tableMap.put("MR_MRCONTENT", "MR_MRCONTENT");//病案首页--手术
-            tableMap.put("GI_USERINFO", "GI_USERINFO"); //医生
-            tableMap.put("HI_DEPTINFO", "HI_DEPTINFO");//科室
-            tableMap.put("BR_RECHOME", "BR_RECHOME");//病案首页
-            tableMap.put("BR_RECDIAGNOSE", "BR_RECDIAGNOSE");//病案首页--出院诊断 门急诊诊断
-            tableMap.put("BR_DOCTADVICE", "BR_DOCTADVICE");//医嘱
-            tableMap.put("BR_RECOPERATION", "BR_RECOPERATION");//病案首页--手术
-        } else if (cid.equals("taizhou")) {
-            tableMap.put("BR_INPATIENTINFO", "BR_INPATIENTINFO");//患者信息
-            tableMap.put("MR_MEDICALRECORDS", "MR_MEDICALRECORDS");//病案首页--手术
-            tableMap.put("AR_MEDIRECCLASS", "AR_MEDIRECCLASS");//病案首页--手术
-            tableMap.put("MR_MRCONTENT", "MR_MRCONTENT");//病案首页--手术
-            tableMap.put("GI_USERINFO", "GI_USERINFO"); //医生
-            tableMap.put("HI_DEPTINFO", "HI_DEPTINFO");//科室
-            tableMap.put("BR_RECHOME", "BR_RECHOME");//病案首页
-            tableMap.put("BR_RECDIAGNOSE", "BR_RECDIAGNOSE");//病案首页--出院诊断 门急诊诊断
-            tableMap.put("BR_DOCTADVICE", "BR_DOCTADVICE");//医嘱
-            tableMap.put("BR_RECOPERATION", "BR_RECOPERATION");//病案首页--手术
-        }
-    }
-
-    public static void main(String[] args) {
-        String patientId = "";
-
-        TaizDataImportApiTest test = new TaizDataImportApiTest();
-        initTableMap();
-        //模块映射
-        test.loadModelHospital();
-        //患者信息
-        test.insertPatient(test.loadOraclePatients(tableMap.get("BR_INPATIENTINFO"), patientId));
-//        test.insertDoctor(test.loadOracleDoctorInfos(tableMap.get("GI_USERINFO"), tableMap.get("HI_DEPTINFO")));
-
-        //病人流水号获取    病历号--->id
-        Map<String, String> patientMap = test.loadPatients(hospitalId, patientId);
-        //model-->id
-        Map<String, String> modelMap = test.loadModel();
-        test.insertPatientText(patientMap, modelMap);
-    }
-
-    private void insertPatient(List<Patient> patients) {
-        List<Map<String, Object>> list = new ArrayList<>();
-        for (Patient patient : patients) {
-            Map<String, Object> patientMap = new HashMap<>();
-            patientMap.put("case_number", patient.getBrzyid());
-            patientMap.put("hospital_id", hospitalId);
-            list.add(patientMap);
-        }
-        initMysqlJdbc().insert(list, "qc_cases_number", new String[]{"hospital_id", "case_number"});
-    }
-
-    private void insertDoctor(List<Doctor> doctors) {
-        List<Map<String, Object>> list = new ArrayList<>();
-        for (Doctor doctor : doctors) {
-            Map<String, Object> doctorMap = new HashMap<>();
-            doctorMap.put("doctor_id", doctor.getDoctorId());
-            doctorMap.put("doctor_name", doctor.getDoctorName());
-            doctorMap.put("dept_id", doctor.getDeptId());
-            doctorMap.put("dept_name", doctor.getDeptName());
-            doctorMap.put("professor", doctor.getProfessor());
-            list.add(doctorMap);
-        }
-        initMysqlJdbc().insert(list, "qc_doctor_info", new String[]{"doctor_id", "doctor_name", "dept_id", "dept_name", "professor"});
-    }
-
-    private void insertPatientText(Map<String, String> patientMap, Map<String, String> modelMap) {
-        List<Map<String, Object>> list = new ArrayList<>();
-        for (Map.Entry<String, String> entry : patientMap.entrySet()) {
-            List<PatientText> patientTexts = new ArrayList<>();
-            //病人的病案首页内容
-            List<Map<String, Object>> homePageList = DataTest.loadHomePage(hospitalId, tableMap.get("BR_RECHOME"), entry.getKey());
-            if (homePageList == null || homePageList.isEmpty()) { //没病案首页直接不导入
-                deletePatient.add(entry.getKey()); //没病案首页的患者也要删除
-                continue;
-            }
-            Map<String, Object> homePageMap = homePageList.get(0);
-            homePageMap.put("出院诊断", FastJsonUtils.getBeanToJson(DataTest.loadHomePageDiagnose(hospitalId, tableMap.get("BR_RECDIAGNOSE"),"2", entry.getKey())).replaceAll("\"", "'"));
-            homePageMap.put("损伤、中毒外部原因", FastJsonUtils.getBeanToJson(DataTest.loadHomePageDiagnose(hospitalId, tableMap.get("BR_RECDIAGNOSE"),"3", entry.getKey())).replaceAll("\"", "'"));
-            homePageMap.put("病理诊断", FastJsonUtils.getBeanToJson(DataTest.loadHomePageDiagnose(hospitalId, tableMap.get("BR_RECDIAGNOSE"), "4", entry.getKey())).replaceAll("\"", "'"));
-            homePageMap.put("手术信息", FastJsonUtils.getBeanToJson(DataTest.loadHomePageOperation(hospitalId, tableMap.get("BR_RECOPERATION"), tableMap.get("GI_USERINFO"), entry.getKey())).replaceAll("\"", "'"));
-
-            Map<String, Object> firstPageTextMap = new HashMap<>();
-            firstPageTextMap.put("case_number", entry.getKey());
-            firstPageTextMap.put("case_number_id", patientMap.get(entry.getKey()));
-            firstPageTextMap.put("hospital_id", hospitalId);
-            firstPageTextMap.put("mode_id", 6);
-            firstPageTextMap.put("origin_mode", "病案首页");
-            firstPageTextMap.put("origin_text", FastJsonUtils.getBeanToJson(homePageMap));
-            String pagetext = "";
-            for (Map.Entry<String, Object> e : homePageMap.entrySet()) {
-                pagetext = pagetext + "【" + e.getKey() + "】:" + e.getValue().toString() + "\n";
-            }
-            firstPageTextMap.put("text", pagetext);
-            if ("changx".equals(cid)) {
-                patientTexts = loadChangxOraclePatientTexts(entry.getKey());
-            }
-            if ("taizhou".equals(cid)) {
-                patientTexts = loadTaizhouOraclePatientTexts(entry.getKey());
-            }
-            if (patientTexts.size() == 0 || !wholePatientRecord(patientTexts, modelMap)) {
-                continue;
-            }
-            //数据完整后才放入病案首页
-            list.add(firstPageTextMap);
-
-            //病人医嘱信息
-            List<Map<String, Object>> docAdviceMap = DataTest.loadHomePage(hospitalId, tableMap.get("BR_DOCTADVICE"), entry.getKey());
-            for (Map<String, Object> docMap : docAdviceMap) {
-                Map<String, Object> docAdviceTextMap = new HashMap<>();
-                docAdviceTextMap.put("case_number", entry.getKey());
-                docAdviceTextMap.put("case_number_id", patientMap.get(entry.getKey()));
-                docAdviceTextMap.put("hospital_id", hospitalId);
-                docAdviceTextMap.put("mode_id", 8);
-                docAdviceTextMap.put("origin_mode", "医嘱信息");
-                docAdviceTextMap.put("origin_text", FastJsonUtils.getBeanToJson(docMap));
-                pagetext = "";
-                for (Map.Entry<String, Object> e : docMap.entrySet()) {
-                    pagetext = pagetext + "【" + e.getKey() + "】:" + e.getValue().toString() + "\n";
-                }
-                docAdviceTextMap.put("text", pagetext);
-                list.add(docAdviceTextMap);
-            }
-            //病人其他文书信息
-            for (PatientText patientText : patientTexts) {
-                Map<String, Object> patientTextMap = new HashMap<>();
-                patientTextMap.put("case_number", patientText.getBrzyid());
-                patientTextMap.put("case_number_id", patientMap.get(patientText.getBrzyid()));
-                patientTextMap.put("hospital_id", hospitalId);
-                patientTextMap.put("mode_id", modelMap.get(caseMap.get(patientText.getBljlmc())));
-                patientTextMap.put("origin_mode", patientText.getBljlmc());
-                if (patientTextMap.get("mode_id") == null) {
-                    continue;
-                }
-                patientTextMap.put("origin_text", patientText.getBljlnr());
-
-                String text = "";
-                Map<String, String> textMap = new HashMap<>();
-                if ("changx".equals(cid)) {
-                    textMap = CxXmlUtilTemp.beHospitalizedXmlToMap(patientText.getBljlnr(), caseMap.get(patientText.getBljlmc()));
-                }
-                if ("taizhou".equals(cid)) {
-                    textMap = TzXmlUtil.getXmlToMapForTZ(patientText.getBljlnr());
-                }
-                for (Map.Entry<String, String> e : textMap.entrySet()) {
-                    text = text + "【" + e.getKey() + "】:" + e.getValue() + "\n";
-                }
-                patientTextMap.put("text", text);
-                list.add(patientTextMap);
-            }
-        }
-        initMysqlJdbc().insert(list, "qc_model_mapping", new String[]{"case_number", "case_number_id", "origin_text", "mode_id", "text", "origin_mode"});
-
-        deletePatientInfos(deletePatient);
-    }
-
-    /**
-     * 验证数据完整性
-     * @param patientTexts
-     * @param modelMap
-     * @return
-     */
-    private boolean wholePatientRecord(List<PatientText> patientTexts, Map<String, String> modelMap) {
-        Map<String, String> m = new HashMap<>();
-        for (PatientText patientText : patientTexts) {
-            String modelId = modelMap.get(caseMap.get(patientText.getBljlmc()));
-            if (StringUtils.isEmpty(modelId)) {
-                continue;
-            }
-            if (modelId.equals("1") && patientText.getBljlnr().indexOf("<") != 0) {
-                deletePatient.add(patientTexts.get(0).getBrzyid());
-                return false;
-            }
-            m.put(modelId, modelId);
-        }
-        if (m.get("1") != null && m.get("2") != null && m.get("4") != null && (m.get("5") != null || m.get("24") != null)) {
-            return true;
-        } else {
-            deletePatient.add(patientTexts.get(0).getBrzyid());
-        }
-        return false;
-    }
-
-    private List<Patient> loadOraclePatients(String tableName) {
-        return loadOraclePatients(tableName, "");
-    }
-
-    private List<Patient> loadOraclePatients(String tableName, String patientId) {
-        MysqlJdbc mysqlJdbc = initOracleJdbc();
-        Connection conn = mysqlJdbc.connect();
-        Statement st = null;
-        ResultSet rs = null;
-        String r1, r2;
-        List<Patient> patients = new ArrayList<>();
-        try {
-            st = conn.createStatement();
-            String sql = "";
-            if (StringUtils.isNotEmpty(patientId)) {
-                sql = "select BRZYID from " + tableName + " where BRZYID = '" + patientId + "'";
-            } else {
-                sql = "select BRZYID from " + tableName + " where rownum BETWEEN 0 and 100";
-            }
-            rs = st.executeQuery(sql);
-            while (rs.next()) {
-                r1 = rs.getString(1);
-                Patient patient = new Patient();
-                patient.setBrzyid(r1);
-                patients.add(patient);
-            }
-        } catch (SQLException sqle) {
-            sqle.printStackTrace();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            mysqlJdbc.close(rs, st, conn);
-        }
-        return patients;
-    }
-
-    private List<Doctor> loadOracleDoctorInfos(String tableUser, String tableDept) {
-        MysqlJdbc mysqlJdbc = initOracleJdbc();
-        Connection conn = mysqlJdbc.connect();
-        Statement st = null;
-        ResultSet rs = null;
-        List<Doctor> doctors = new ArrayList<>();
-        try {
-            st = conn.createStatement();
-            String sql = "select u.yhrydm, u.yhrymc, u.yhryzc, dept.zzksid, dept.zzksmc from " + tableDept + " dept, " + tableUser + " u where u.zzksid = dept.zzksid";
-            rs = st.executeQuery(sql);
-            while (rs.next()) {
-                Doctor doctor = new Doctor();
-                doctor.setDoctorId(rs.getString(1));
-                doctor.setDoctorName(rs.getString(2));
-                doctor.setProfessor(rs.getString(3));
-                doctor.setDeptId(rs.getString(4));
-                doctor.setDeptName(rs.getString(5));
-                doctors.add(doctor);
-            }
-        } catch (SQLException sqle) {
-            sqle.printStackTrace();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            mysqlJdbc.close(rs, st, conn);
-        }
-        return doctors;
-    }
-
-    private List<PatientText> loadTaizhouOraclePatientTexts(String brzyid) {
-        MysqlJdbc mysqlJdbc = initOracleJdbc();
-        Connection conn = mysqlJdbc.connect();
-        Statement st = null;
-        ResultSet rs = null;
-        String r1, r2, r3;
-        List<PatientText> patientTexts = new ArrayList<>();
-        try {
-            st = conn.createStatement();
-            String sql = "select brzyid,bljlmc,bljlnr from " + tableMap.get("MR_MEDICALRECORDS") + " a " +
-                    "left join " + tableMap.get("MR_MRCONTENT") + " b on a.bljlid=b.bljlid " +
-                    "where bljlnr is not null and brzyid = '" + brzyid + "' " +
-                    "order by brzyid";
-            rs = st.executeQuery(sql);
-            while (rs.next()) {
-                r1 = rs.getString(1);
-                r2 = rs.getString(2);
-                r3 = rs.getString(3);
-                PatientText patientText = new PatientText();
-                patientText.setBrzyid(r1);
-                patientText.setBljlmc(r2);
-                patientText.setBljlnr(r3);
-                patientTexts.add(patientText);
-            }
-        } catch (SQLException sqle) {
-            sqle.printStackTrace();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            mysqlJdbc.close(rs, st, conn);
-        }
-        return patientTexts;
-    }
-    private List<PatientText> loadChangxOraclePatientTexts(String brzyid) {
-        MysqlJdbc mysqlJdbc = initOracleJdbc();
-        Connection conn = mysqlJdbc.connect();
-        Statement st = null;
-        ResultSet rs = null;
-        String r1, r2;
-        List<PatientText> patientTexts = new ArrayList<>();
-        try {
-            st = conn.createStatement();
-            String sql = "select a.brzyid,c.bllbmc,b.bljlnr from " + tableMap.get("MR_MEDICALRECORDS") + " a " +
-                    "left join " + tableMap.get("MR_MRCONTENT") + " b on a.bljlid=b.bljlid " +
-                    "left join " + tableMap.get("AR_MEDIRECCLASS") + " c on a.Bllbid = c.bllbid " +
-                    "where bljlnr is not null and brzyid = '" + brzyid + "' " +
-                    "order by brzyid";
-            rs = st.executeQuery(sql);
-            while (rs.next()) {
-                r1 = rs.getString(1);
-                r2 = rs.getString(2);
-                java.sql.Blob blob = rs.getBlob(3);
-
-                InputStream in = blob.getBinaryStream();
-
-                GZIPInputStream ginzip = new GZIPInputStream(in);
-
-                ByteArrayOutputStream out = new ByteArrayOutputStream();
-                byte[] buffer = new byte[1024];
-                int offset = -1;
-                while ((offset = ginzip.read(buffer)) != -1) {
-                    out.write(buffer, 0, offset);
-                }
-                String decompressed = out.toString();
-                in.close();
-                out.close();
-                ginzip.close();
-
-                PatientText patientText = new PatientText();
-                patientText.setBrzyid(r1);
-                patientText.setBljlmc(r2);
-                patientText.setBljlnr(decompressed);
-                patientTexts.add(patientText);
-            }
-        } catch (SQLException sqle) {
-            sqle.printStackTrace();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            mysqlJdbc.close(rs, st, conn);
-        }
-        return patientTexts;
-    }
-
-    private Map<String, String> loadPatients(String hospitalId) {
-        return loadPatients(hospitalId, null);
-    }
-
-    private Map<String, String> loadPatients(String hospitalId, String patientId) {
-        MysqlJdbc mysqlJdbc = initMysqlJdbc();
-        Connection conn = mysqlJdbc.connect();
-        Statement st = null;
-        ResultSet rs = null;
-        String r1, r2;
-        Map<String, String> map = new HashMap<>();
-        try {
-            st = conn.createStatement();
-            String sql = "";
-            if (StringUtils.isNotEmpty(patientId)) {
-                sql = "select id, case_number from qc_cases_number where hospital_id = " + hospitalId + " and case_number = '" + patientId + "'";
-            } else {
-                sql = "select id, case_number from qc_cases_number where hospital_id = " + hospitalId;
-            }
-            rs = st.executeQuery(sql);
-            while (rs.next()) {
-                r1 = rs.getString(1);
-                r2 = rs.getString(2);
-                map.put(r2, r1);
-            }
-        } catch (SQLException sqle) {
-            sqle.printStackTrace();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            mysqlJdbc.close(rs, st, conn);
-        }
-        return map;
-    }
-
-    private Map<String, String> loadModel() {
-        MysqlJdbc mysqlJdbc = initMysqlJdbc();
-        Connection conn = mysqlJdbc.connect();
-        Statement st = null;
-        ResultSet rs = null;
-        String r1, r2;
-        Map<String, String> map = new HashMap<>();
-        try {
-            st = conn.createStatement();
-            String sql = "select id, name from qc_mode";
-            rs = st.executeQuery(sql);
-            while (rs.next()) {
-                r1 = rs.getString(1);
-                r2 = rs.getString(2);
-                map.put(r2, r1);
-            }
-        } catch (SQLException sqle) {
-            sqle.printStackTrace();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            mysqlJdbc.close(rs, st, conn);
-        }
-        return map;
-    }
-
-    private void loadModelHospital() {
-        MysqlJdbc mysqlJdbc = initMysqlJdbc();
-        Connection conn = mysqlJdbc.connect();
-        Statement st = null;
-        ResultSet rs = null;
-        String r1, r2;
-        try {
-            st = conn.createStatement();
-            String sql = "select hospital_model_name, stand_model_name from qc_model_hospital where stand_model_name is not null and hospital_id = " + hospitalId;
-            rs = st.executeQuery(sql);
-            while (rs.next()) {
-                r1 = rs.getString(1);
-                r2 = rs.getString(2);
-                caseMap.put(r1, r2);
-            }
-        } catch (SQLException sqle) {
-            sqle.printStackTrace();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            mysqlJdbc.close(rs, st, conn);
-        }
-    }
-
-    private void deletePatientInfos(List<String> caseNumbers) {
-        MysqlJdbc mysqlJdbc = initMysqlJdbc();
-        Connection conn = mysqlJdbc.connect();
-        Statement st = null;
-        ResultSet rs = null;
-        String r1, r2;
-        try {
-            st = conn.createStatement();
-            for (String caseNumber : caseNumbers) {
-                String sql = "delete from qc_cases_number where case_number = '" + caseNumber + "'";
-                st.execute(sql);
-            }
-        } catch (SQLException sqle) {
-            sqle.printStackTrace();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            mysqlJdbc.close(rs, st, conn);
-        }
-    }
-
-    private MysqlJdbc initMysqlJdbc() {
-        PropertiesUtil propertiesUtil = new PropertiesUtil("kernel.properties");
-        MysqlJdbc mysqlJdbc = new MysqlJdbc(propertiesUtil.getProperty("mysql.test.user"),
-                propertiesUtil.getProperty("mysql.test.password"),
-                propertiesUtil.getProperty("mysql.test.url"));
-        return mysqlJdbc;
-    }
-
-    private MysqlJdbc initOracleJdbc() {
-        PropertiesUtil propertiesUtil = new PropertiesUtil("kernel.properties");
-        MysqlJdbc mysqlJdbc = new MysqlJdbc(propertiesUtil.getProperty("oracle.taizhou.user"),
-                propertiesUtil.getProperty("oracle.taizhou.password"),
-                propertiesUtil.getProperty("oracle.taizhou.url"), propertiesUtil.getProperty("oracle.taizhou.driver"));
-        return mysqlJdbc;
-    }
-}

+ 119 - 0
kernel/src/test/java/com/lantone/qc/kernel/medDesTest.java

@@ -0,0 +1,119 @@
+package com.lantone.qc.kernel;
+
+import com.lantone.qc.pub.util.StringUtil;
+import com.lantone.qc.trans.util.http.db.DBUtil;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class medDesTest {
+
+    private final static char EN_MAX = '\u0080';//128
+    private final static int MOVE_NUM = 2;
+    private final static char DE_MAX = EN_MAX + MOVE_NUM;
+
+    public static void main(String[] args) {
+        List<Map<String, String>> xmlMaps = WritXmlSelect();
+        System.out.println(xmlMaps);
+        AcquirePatientName(xmlMaps);
+    }
+
+    //取患者姓名
+    private static void AcquirePatientName(List<Map<String, String>> xmlMaps) {
+        for (Map<String, String> structMap : xmlMaps) {
+            String recId = structMap.get("Id");
+            String libName = structMap.get("libName");
+            if (StringUtil.isNotBlank(libName)) {
+                char[] chars = libName.toCharArray();
+                for (int i = 0; i < chars.length; i++) {
+                    if (DE_MAX < chars[i]) {
+                        chars[i] -= MOVE_NUM;
+                    }
+                }
+
+                System.out.println(recId);
+                System.out.println(new String(chars));
+                ReplaceSensitivity(recId, new String(chars));
+            }
+        }
+    }
+
+
+    private static void ReplaceSensitivity(String recId, String xmlText) {
+        Connection conn = null;
+        Statement stmt = null;
+        ResultSet rs = null;
+        try {
+            conn = DBUtil.getConnection();
+            stmt = conn.createStatement();
+            stmt.executeUpdate("UPDATE kl_library_info_copy SET name='" + xmlText + "'" + "WHERE id='" + recId + "'");
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (rs != null) {
+                    rs.close();
+                    rs = null;
+                }
+                if (stmt != null) {
+                    stmt.close();
+                    stmt = null;
+                }
+                if (conn != null) {
+                    conn.close();
+                    conn = null;
+                }
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    //查询xml文件内容
+    public static List<Map<String, String>> WritXmlSelect() {
+        Connection conn = null;
+        Statement stmt = null;
+        ResultSet rs = null;
+        List<Map<String, String>> resultList = new ArrayList<>();
+        try {
+            conn = DBUtil.getConnection();
+            stmt = conn.createStatement();
+            rs = stmt.executeQuery(
+                    "SELECT id,name FROM kl_library_info_copy");
+            while (rs.next()) {
+                Map<String, String> map = new LinkedHashMap<>();
+                map.put("Id", rs.getString(1));
+                map.put("libName", rs.getString(2));
+                resultList.add(map);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (rs != null) {
+                    rs.close();
+                    rs = null;
+                }
+                if (stmt != null) {
+                    stmt.close();
+                    stmt = null;
+                }
+                if (conn != null) {
+                    conn.close();
+                    conn = null;
+                }
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
+        }
+        return resultList;
+    }
+}

+ 1 - 0
trans/src/main/java/com/lantone/qc/trans/hangzhoudiqi/QiYuanBeHospitalizedDocTrans.java

@@ -53,6 +53,7 @@ public class QiYuanBeHospitalizedDocTrans extends ModelDocTrans {
             sourceMap.put("mode_id=" + contentMap.get("modeId").toString(), "");
             sourceMap.put("rec_title=" + contentMap.get("recTitle").toString(), "");
             sourceMap.put("recDate", contentMap.get("recDate").toString());
+            sourceMap.put("firstCreateDate", contentMap.get("firstCreateDate").toString());
             //职业A+A问题解决
             if (sourceMap.containsKey("职业")) {
                 if (sourceMap.get("职业").split(" ").length > 1) {

+ 1 - 0
trans/src/main/java/com/lantone/qc/trans/hangzhoudiqi/QiYuanFirstCourseRecordDocTrans.java

@@ -70,6 +70,7 @@ public class QiYuanFirstCourseRecordDocTrans extends ModelDocTrans {
             sourceMap.put("mode_id=" + contentMap.get("modeId").toString(), "");
             sourceMap.put("rec_title=" + contentMap.get("recTitle").toString(), "");
             sourceMap.put("recDate", contentMap.get("recDate").toString());
+            sourceMap.put("firstCreateDate", contentMap.get("firstCreateDate").toString());
             structureMap = OrdinaryAssistant.mapKeyContrast(sourceMap, keyContrasts, modeId);
         }