|
@@ -1,21 +1,32 @@
|
|
|
package com.lantone.qc.kernel.util;
|
|
|
|
|
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.google.common.collect.Maps;
|
|
|
+import com.google.common.collect.Sets;
|
|
|
import com.lantone.qc.nlp.participle.cfg.Configuration;
|
|
|
import com.lantone.qc.nlp.participle.cfg.DefaultConfig;
|
|
|
-import com.lantone.qc.security.util.EncrypDES;
|
|
|
+import com.lantone.qc.pub.util.FastJsonUtils;
|
|
|
+import com.lantone.qc.pub.util.FileUtil;
|
|
|
+import com.lantone.qc.trans.comsis.ModuleMappingUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.boot.ApplicationArguments;
|
|
|
import org.springframework.boot.ApplicationRunner;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.util.ResourceUtils;
|
|
|
|
|
|
+import java.io.FileNotFoundException;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
/**
|
|
|
* @ClassName : CacheUtil
|
|
@@ -29,8 +40,12 @@ public class CacheUtil implements ApplicationRunner {
|
|
|
@Autowired
|
|
|
private RedisUtil redisUtil;
|
|
|
|
|
|
+ @Value("${qc.hospital_id}")
|
|
|
+ private String hospitalId;
|
|
|
+
|
|
|
public void run(ApplicationArguments var1) {
|
|
|
try {
|
|
|
+ this.loadModuleMappingInfo();//加载页面模板映射信息
|
|
|
this.putConceptDiagPropertyMap();//疾病相关信息放入缓存 包括疾病是否是慢病、传染病、常见症状、同义词
|
|
|
this.putHospitalDiagMap();//医院疾病信息
|
|
|
this.putHospitalDiagHuaZMap();//医院华卓映射
|
|
@@ -42,13 +57,45 @@ public class CacheUtil implements ApplicationRunner {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 加载页面模板映射信息
|
|
|
+ */
|
|
|
+ private void loadModuleMappingInfo() {
|
|
|
+ List<String> xmlDataTypeHospitalIds = Lists.newArrayList("1", "3");
|
|
|
+ try {
|
|
|
+ String path = ResourceUtils.getURL("classpath:").getPath() + "cache/" + hospitalId + "/module_mapping.json";
|
|
|
+ String mappingMsg = FileUtil.fileRead(path);
|
|
|
+ if (xmlDataTypeHospitalIds.contains(hospitalId)) {
|
|
|
+ Map<String, Long> mapKeysModuleInfoIdMap = (Map) FastJsonUtils.getJsonToMap(mappingMsg);
|
|
|
+ Map<Set<String>, String> xmlDataTypeModuleInfo = Maps.newHashMap();
|
|
|
+
|
|
|
+ for (Map.Entry<String, Long> entry : mapKeysModuleInfoIdMap.entrySet()) {
|
|
|
+ List<String> list = Arrays.asList(entry.getKey().split(","));
|
|
|
+ list.sort(new Comparator<String>() {
|
|
|
+ @Override
|
|
|
+ public int compare(String arg0, String arg1) {
|
|
|
+ return arg0.compareTo(arg1);//这是顺序
|
|
|
+ }
|
|
|
+ });
|
|
|
+ xmlDataTypeModuleInfo.put(Sets.newLinkedHashSet(list), entry.getValue() + "");
|
|
|
+ }
|
|
|
+// mapKeysModuleInfoIdMap.keySet().forEach(mapKeys -> {
|
|
|
+// xmlDataTypeModuleInfo.put(Sets.newLinkedHashSet(Arrays.asList(mapKeys.split(","))), mapKeysModuleInfoIdMap.get(mapKeys) + "");
|
|
|
+// });
|
|
|
+ ModuleMappingUtil.xmlDataTypeModuleInfo = xmlDataTypeModuleInfo;
|
|
|
+ }
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 疾病相关信息放入缓存
|
|
|
* 包括疾病是否是慢病、传染病、常见症状、同义词
|
|
|
*/
|
|
|
public void putConceptDiagPropertyMap() throws Exception {
|
|
|
Configuration configuration = new DefaultConfig();
|
|
|
- List<String> lines = configuration.readTargetFileContents("cache/concept_diag_properties.dict");
|
|
|
+ List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/concept_diag_properties.dict");
|
|
|
|
|
|
Map<String, Map<String, Object>> diagMap = new HashMap<>();
|
|
|
for (String line : lines) {
|
|
@@ -57,14 +104,16 @@ public class CacheUtil implements ApplicationRunner {
|
|
|
List<String> synonymsList = new ArrayList<>();
|
|
|
List<String> symptomsList = new ArrayList<>();
|
|
|
if (StringUtils.isNotEmpty(line_arr[3])) {
|
|
|
+ line_arr[3] = line_arr[3].trim();
|
|
|
synonymsList = java.util.Arrays.asList(line_arr[3].split(","));
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(line_arr[4])) {
|
|
|
+ line_arr[4] = line_arr[4].trim();
|
|
|
symptomsList = java.util.Arrays.asList(line_arr[4].split(","));
|
|
|
}
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("infectious", line_arr[2]);
|
|
|
- map.put("chronic", line_arr[1]);
|
|
|
+ map.put("infectious", line_arr[2].trim());
|
|
|
+ map.put("chronic", line_arr[1].trim());
|
|
|
map.put("synonyms", synonymsList);
|
|
|
map.put("symptoms", symptomsList);
|
|
|
diagMap.put(line_arr[0], map);
|
|
@@ -75,11 +124,12 @@ public class CacheUtil implements ApplicationRunner {
|
|
|
|
|
|
/**
|
|
|
* 医院医生信息
|
|
|
+ *
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void putHospitalDoctorInfoMap() throws Exception {
|
|
|
Configuration configuration = new DefaultConfig();
|
|
|
- List<String> lines = configuration.readTargetFileContents("cache/hospital_doctor_info.dict");
|
|
|
+ List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/hospital_doctor_info.dict");
|
|
|
|
|
|
Map<String, Map<String, Object>> hospitalDoctorMap = new HashMap<>();
|
|
|
for (String line : lines) {
|
|
@@ -101,11 +151,11 @@ public class CacheUtil implements ApplicationRunner {
|
|
|
*/
|
|
|
public void putHospitalDiagMap() throws Exception {
|
|
|
Configuration configuration = new DefaultConfig();
|
|
|
- List<String> lines = configuration.readTargetFileContents("cache/hospital_diag_info.dict");
|
|
|
+ List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/hospital_diag_info.dict");
|
|
|
Map<String, Map<String, String>> hospitalDiagMap = new HashMap<>();
|
|
|
for (String line : lines) {
|
|
|
Map<String, String> detail = new HashMap<>();
|
|
|
- detail.put("name", line);
|
|
|
+ detail.put("name", line.trim());
|
|
|
detail.put("icd10", "A001");
|
|
|
hospitalDiagMap.put(line, detail);
|
|
|
}
|
|
@@ -117,11 +167,11 @@ public class CacheUtil implements ApplicationRunner {
|
|
|
*/
|
|
|
public void putHospitalDiagHuaZMap() throws Exception {
|
|
|
Configuration configuration = new DefaultConfig();
|
|
|
- List<String> lines = configuration.readTargetFileContents("cache/hospital_diag_info.dict");
|
|
|
+ List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/hospital_diag_info.dict");
|
|
|
Map<String, Map<String, String>> hospitalDiagMap = new HashMap<>();
|
|
|
for (String line : lines) {
|
|
|
Map<String, String> detail = new HashMap<>();
|
|
|
- detail.put("name", line);
|
|
|
+ detail.put("name", line.trim());
|
|
|
detail.put("icd10", "A001");
|
|
|
hospitalDiagMap.put(line, detail);
|
|
|
}
|
|
@@ -133,22 +183,23 @@ public class CacheUtil implements ApplicationRunner {
|
|
|
*/
|
|
|
public void putLantoneDiagHuaZMap() throws Exception {
|
|
|
Configuration configuration = new DefaultConfig();
|
|
|
- List<String> lines = configuration.readTargetFileContents("cache/hospital_diag_info.dict");
|
|
|
+ List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/hospital_diag_info.dict");
|
|
|
Map<String, Map<String, String>> hospitalDiagMap = new HashMap<>();
|
|
|
for (String line : lines) {
|
|
|
Map<String, String> detail = new HashMap<>();
|
|
|
- detail.put("name", line);
|
|
|
+ detail.put("name", line.trim());
|
|
|
detail.put("icd10", "A001");
|
|
|
hospitalDiagMap.put(line, detail);
|
|
|
}
|
|
|
redisUtil.setJsonStringValue(KernelConstants.LANTONE_DIAG_HUAZ_MAP, hospitalDiagMap);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 症状需要部位描述词典放入redis缓存
|
|
|
*/
|
|
|
public void putClinicBodyPartMap() throws Exception {
|
|
|
Configuration configuration = new DefaultConfig();
|
|
|
- List<String> lines = configuration.readTargetFileContents("cache/concept_clinic_bodypart_properties.dict");
|
|
|
+ List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/concept_clinic_bodypart_properties.dict");
|
|
|
List<String> clinicBodyPartList = new ArrayList<>();
|
|
|
for (String line : lines) {
|
|
|
clinicBodyPartList.add(line);
|