|
@@ -5,8 +5,16 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
-import com.lantone.qc.pub.util.FileUtil;
|
|
|
-import com.lantone.qc.pub.util.MapUtil;
|
|
|
+import com.lantone.qc.dbanaly.facade.yiwu.enums.BehospitalWayEnum;
|
|
|
+import com.lantone.qc.dbanaly.facade.yiwu.enums.BloodTypeEnum;
|
|
|
+import com.lantone.qc.dbanaly.facade.yiwu.enums.DiagnoseTypeEnum;
|
|
|
+import com.lantone.qc.dbanaly.facade.yiwu.enums.IsMedAllergyEnum;
|
|
|
+import com.lantone.qc.dbanaly.facade.yiwu.enums.LeaveHospitalTypeEnum;
|
|
|
+import com.lantone.qc.dbanaly.facade.yiwu.enums.MarriageEnum;
|
|
|
+import com.lantone.qc.dbanaly.facade.yiwu.enums.RHEnum;
|
|
|
+import com.lantone.qc.dbanaly.facade.yiwu.enums.SexEnum;
|
|
|
+import com.lantone.qc.dbanaly.facade.yiwu.util.MapUtil;
|
|
|
+import com.lantone.qc.dbanaly.facade.yiwu.util.YWDateUtils;
|
|
|
import com.lantone.qc.pub.util.StringUtil;
|
|
|
import org.dom4j.Document;
|
|
|
import org.dom4j.DocumentHelper;
|
|
@@ -23,6 +31,8 @@ import java.util.Set;
|
|
|
* @time: 2020/3/28 14:23
|
|
|
*/
|
|
|
public class YiWuFirstPageRecordXmlUtil {
|
|
|
+
|
|
|
+ public static final Map<String, String> CITY_MAP = MapUtil.getMap("cityCode.json");
|
|
|
public static Map<String, String> leaveDiagMap = ImmutableMap.<String, String>builder()
|
|
|
.put("出院诊断", "诊断名称")
|
|
|
.put("出院诊断编码", "诊断编码")
|
|
@@ -45,27 +55,23 @@ public class YiWuFirstPageRecordXmlUtil {
|
|
|
.build();
|
|
|
|
|
|
public static Map<String, Object> process(String xml) {
|
|
|
- Map<String, Object> sourceMap = xmlToMap(xml);
|
|
|
- Map<String, Object> structureMap = mapKeyContrast(sourceMap, keyContrasts);
|
|
|
+ Map<String, String> sourceMap = xmlToMap(xml);
|
|
|
+ Map<String, String> structureMap = mapKeyContrast(sourceMap, keyContrasts);
|
|
|
+ Map<String, Object> structureExtMap = Maps.newHashMap();
|
|
|
+ structureExtMap.putAll(structureMap);
|
|
|
JSONArray leaveDiags = new JSONArray();
|
|
|
specialProcess(structureMap, leaveDiagMap, leaveDiags);
|
|
|
- structureMap.put("出院诊断", leaveDiags);
|
|
|
+ structureExtMap.put("出院诊断", leaveDiags);
|
|
|
|
|
|
JSONArray operations = new JSONArray();
|
|
|
specialProcess(structureMap, operationMap, operations);
|
|
|
- structureMap.put("手术信息", operations);
|
|
|
- if (structureMap.containsKey("ID编号")){
|
|
|
- Map<String, Object> idMap = (Map<String, Object>) structureMap.get("ID编号");
|
|
|
- idMap.put("出院诊断", "出院诊断_table3");
|
|
|
- idMap.put("手术信息", "手术信息_table3");
|
|
|
- idMap = mapKeyContrast(idMap, keyContrasts);
|
|
|
- structureMap.put("ID编号",idMap);
|
|
|
- }
|
|
|
- return structureMap;
|
|
|
+ structureExtMap.put("手术信息", operations);
|
|
|
+ structureExtMap = processToValue(structureExtMap);
|
|
|
+ return structureExtMap;
|
|
|
}
|
|
|
|
|
|
- public static Map<String, Object> xmlToMap(String xml) {
|
|
|
- Map<String, Object> map = Maps.newHashMap();
|
|
|
+ public static Map<String, String> xmlToMap(String xml) {
|
|
|
+ Map<String, String> map = Maps.newHashMap();
|
|
|
try {
|
|
|
Document doc = DocumentHelper.parseText(xml);
|
|
|
Element root = (Element) doc.selectSingleNode("//XTextDocument/XElements/Element[@xsi:type='XTextBody']/XElements");
|
|
@@ -119,7 +125,7 @@ public class YiWuFirstPageRecordXmlUtil {
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
- public static void xInputField(Map<String, Object> map, Element xInputFieldElement, String tablePreTxt) {
|
|
|
+ public static void xInputField(Map<String, String> map, Element xInputFieldElement, String tablePreTxt) {
|
|
|
String value = getXInputFieldValue(xInputFieldElement);
|
|
|
if (value == null) {
|
|
|
return;
|
|
@@ -130,17 +136,6 @@ public class YiWuFirstPageRecordXmlUtil {
|
|
|
value = map.get(key) + " " + value;
|
|
|
}
|
|
|
map.put(key, value);
|
|
|
- String id = getXInputFieldId(xInputFieldElement);
|
|
|
- if (StringUtil.isNotBlank(id)) {
|
|
|
- if (!map.containsKey("ID编号")) {
|
|
|
- Map<String, String> idValue = Maps.newHashMap();
|
|
|
- idValue.put(key, id);
|
|
|
- map.put("ID编号", idValue);
|
|
|
- } else {
|
|
|
- //id唯一,所以不用做if判断key是否存在
|
|
|
- ((Map<String, String>) map.get("ID编号")).put(key, id);
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -200,16 +195,6 @@ public class YiWuFirstPageRecordXmlUtil {
|
|
|
return value;
|
|
|
}
|
|
|
|
|
|
- //获取 XInputField 的值
|
|
|
- private static String getXInputFieldId(Element xInputFieldElement) {
|
|
|
- String value = "";
|
|
|
- Element idElement = xInputFieldElement.element("ID");
|
|
|
- if (idElement != null) {
|
|
|
- value = idElement.getTextTrim();
|
|
|
- }
|
|
|
- return value;
|
|
|
- }
|
|
|
-
|
|
|
//获取前面文本信息作为key
|
|
|
private static String getElementPreVal(Element xInputFieldElement) {
|
|
|
String ret = "";
|
|
@@ -229,8 +214,8 @@ public class YiWuFirstPageRecordXmlUtil {
|
|
|
|
|
|
//针对key的一些特殊处理
|
|
|
private static String keyHandle(String key) {
|
|
|
- key = StringUtil.removeBlank(key).replaceAll("[::]", "");
|
|
|
- return key;
|
|
|
+ key = StringUtil.isBlank(key) ? key : key.replaceAll("[\\s\\p{Zs}]", "");
|
|
|
+ return key.replaceAll("[::]", "");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -240,13 +225,13 @@ public class YiWuFirstPageRecordXmlUtil {
|
|
|
* @param keyContrasts
|
|
|
* @return
|
|
|
*/
|
|
|
- public static Map<String, Object> mapKeyContrast(Map<String, Object> sourceMap, List<String> keyContrasts) {
|
|
|
- Map<String, Object> retMap = Maps.newHashMap();
|
|
|
+ public static Map<String, String> mapKeyContrast(Map<String, String> sourceMap, List<String> keyContrasts) {
|
|
|
+ Map<String, String> retMap = Maps.newHashMap();
|
|
|
mapKeyContrastCommon(sourceMap, keyContrasts, retMap);
|
|
|
return retMap;
|
|
|
}
|
|
|
|
|
|
- public static void mapKeyContrastCommon(Map sourceMap, List<String> keyContrasts, Map<String, Object> retMap) {
|
|
|
+ public static void mapKeyContrastCommon(Map sourceMap, List<String> keyContrasts, Map<String, String> retMap) {
|
|
|
Map<String, String> sourceMap_ = MapUtil.copyMap(sourceMap);
|
|
|
String[] arry = null;
|
|
|
String sourceKey = null, targetKey;
|
|
@@ -260,7 +245,7 @@ public class YiWuFirstPageRecordXmlUtil {
|
|
|
targetKey = arry[1];
|
|
|
}
|
|
|
if (StringUtil.isNotBlank(sourceMap_.get(sourceKey))
|
|
|
- && (!retMap.containsKey(targetKey) || StringUtil.isBlank(retMap.get(targetKey).toString()))) {
|
|
|
+ && (!retMap.containsKey(targetKey) || StringUtil.isBlank(retMap.get(targetKey)))) {
|
|
|
retMap.put(targetKey, sourceMap_.get(sourceKey));
|
|
|
}
|
|
|
removeKey.add(sourceKey);
|
|
@@ -282,13 +267,13 @@ public class YiWuFirstPageRecordXmlUtil {
|
|
|
* @param leaveDiagMap
|
|
|
* @param array
|
|
|
*/
|
|
|
- public static void specialProcess(Map<String, Object> structureMap, Map<String, String> leaveDiagMap, JSONArray array) {
|
|
|
+ public static void specialProcess(Map<String, String> structureMap, Map<String, String> leaveDiagMap, JSONArray array) {
|
|
|
JSONObject object;
|
|
|
int num = 0;
|
|
|
try {
|
|
|
for (Map.Entry<String, String> entry : leaveDiagMap.entrySet()) {
|
|
|
if (structureMap.containsKey(entry.getKey())) {
|
|
|
- String value = structureMap.get(entry.getKey()).toString();
|
|
|
+ String value = structureMap.get(entry.getKey());
|
|
|
value = removeUseless(value);
|
|
|
String[] values = value.split(" ");
|
|
|
if (num == 0) {
|
|
@@ -333,7 +318,10 @@ public class YiWuFirstPageRecordXmlUtil {
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
- xmlToMap(FileUtil.fileRead("C:\\Users\\Administrator\\Desktop\\义务\\jiexi\\n5.xml"));
|
|
|
+ // xmlToMap(FileUtil.fileRead("C:\\Users\\Administrator\\Desktop\\义务\\jiexi\\n5.xml"));
|
|
|
+ String xml = "";
|
|
|
+ Map<String, Object> ret = process(xml);
|
|
|
+ System.out.println(ret);
|
|
|
}
|
|
|
|
|
|
private static List<String> keyContrasts = Lists.newArrayList(
|
|
@@ -399,7 +387,7 @@ public class YiWuFirstPageRecordXmlUtil {
|
|
|
"联系电话=现住址电话",
|
|
|
"损伤中毒外部因素=损伤中毒因素",
|
|
|
"诊断类_实验室诊断费=实验室诊断费",
|
|
|
- "年龄=新生儿年龄",
|
|
|
+ "年龄新=新生儿年龄",
|
|
|
"诊断类_临床诊断项目费=临床诊断项目费",
|
|
|
"耗材类_治疗用一次性医用材料费=治疗用一次性医用材料费",
|
|
|
"诊断符合情况_临床与病理=临床与病理",
|
|
@@ -447,4 +435,73 @@ public class YiWuFirstPageRecordXmlUtil {
|
|
|
"工作单位邮政编码=工作单位邮编"
|
|
|
);
|
|
|
|
|
|
+ public static Map<String, Object> processToValue(Map<String, Object> map) {
|
|
|
+
|
|
|
+ String[] provinceList = String.valueOf(map.get("省")).split(" ");
|
|
|
+ String[] cityList = String.valueOf(map.get("市")).split(" ");
|
|
|
+ String[] areaList = String.valueOf(map.get("县")).split(" ");
|
|
|
+ if (StringUtil.isNotEmpty(String.valueOf(map.get("性别")))) {
|
|
|
+ map.put("性别", SexEnum.getName(String.valueOf(map.get("性别"))));
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotEmpty(String.valueOf(map.get("婚姻")))) {
|
|
|
+ map.put("婚姻", MarriageEnum.getName(String.valueOf(map.get("婚姻"))));
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotEmpty(String.valueOf(map.get("入院途径")))) {
|
|
|
+ //入院途径,1:急诊,2:门诊,3:其他医疗机构,9:其他
|
|
|
+ map.put("入院途径", BehospitalWayEnum.getName(String.valueOf(map.get("入院途径")).split(" ")[0]));
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotEmpty(String.valueOf(map.get("血型")))) {
|
|
|
+ map.put("血型", BloodTypeEnum.getName(String.valueOf(map.get("血型"))));
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotEmpty(String.valueOf(map.get("Rh")))) {
|
|
|
+ map.put("Rh", RHEnum.getName(String.valueOf(map.get("Rh"))));
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotEmpty(String.valueOf(map.get("离院方式")))) {
|
|
|
+ map.put("离院方式", LeaveHospitalTypeEnum.getName(String.valueOf(map.get("离院方式"))));
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotEmpty(String.valueOf(map.get("门诊与住院")))) {
|
|
|
+ map.put("门诊与住院", DiagnoseTypeEnum.getName(String.valueOf(map.get("门诊与住院"))));
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotEmpty(String.valueOf(map.get("入院与出院")))) {
|
|
|
+ map.put("入院与出院", DiagnoseTypeEnum.getName(String.valueOf(map.get("入院与出院"))));
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotEmpty(String.valueOf(map.get("术前与术后")))) {
|
|
|
+ map.put("术前与术后", DiagnoseTypeEnum.getName(String.valueOf(map.get("术前与术后"))));
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotEmpty(String.valueOf(map.get("临床与病理")))) {
|
|
|
+ map.put("临床与病理", DiagnoseTypeEnum.getName(String.valueOf(map.get("临床与病理"))));
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotEmpty(String.valueOf(map.get("放射与病理")))) {
|
|
|
+ map.put("放射与病理", DiagnoseTypeEnum.getName(String.valueOf(map.get("放射与病理"))));
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotEmpty(String.valueOf(map.get("药物过敏")))) {
|
|
|
+ map.put("药物过敏", IsMedAllergyEnum.getName(String.valueOf(map.get("药物过敏"))));
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotEmpty(String.valueOf(map.get("三十一天内再住院计划")))) {
|
|
|
+ map.put("三十一天内再住院计划", IsMedAllergyEnum.getName(String.valueOf(map.get("三十一天内再住院计划"))));
|
|
|
+ }
|
|
|
+ if (provinceList.length > 0) {
|
|
|
+ if (provinceList[0].length() > 1) {
|
|
|
+ map.put("出生地", CITY_MAP.get(provinceList[0]) + CITY_MAP.get(cityList[0]) + CITY_MAP.get(areaList[0]));
|
|
|
+ }
|
|
|
+ if (provinceList[1].length() > 1) {
|
|
|
+ map.put("户口地址", CITY_MAP.get(provinceList[1]) + CITY_MAP.get(cityList[1]) + CITY_MAP.get(areaList[1]) + map.get("户口地址其它"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotEmpty(String.valueOf(map.get("籍贯_省")).replaceAll("[\u4e00-\u9fa5]", ""))) {
|
|
|
+ map.put("籍贯", CITY_MAP.get(map.get("籍贯_省")) + CITY_MAP.get(map.get("籍贯_市")));
|
|
|
+ }
|
|
|
+ map.put("现住址", CITY_MAP.get(map.get("现住址_省")) + CITY_MAP.get(map.get("现住址_市")) + CITY_MAP.get(map.get("现住址_县")) + map.get("现住址其它"));
|
|
|
+ if (StringUtil.isEmpty(String.valueOf(map.get("出生日期")).replaceAll("[\u4e00-\u9fa5]", "").trim())) {
|
|
|
+ map.put("出生日期", "");
|
|
|
+ }
|
|
|
+ if (!YWDateUtils.isDate(String.valueOf(map.get("入院时间")), "yyyy年MM月dd日 HH时mm分")) {
|
|
|
+ map.put("入院日期", "");
|
|
|
+ }
|
|
|
+ if (!YWDateUtils.isDate(String.valueOf(map.get("出院时间")), "yyyy年MM月dd日 HH时mm分")) {
|
|
|
+ map.put("出院时间", "");
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
}
|