You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
460 lines
19 KiB
460 lines
19 KiB
2 years ago
|
//package com.ynxbd.common.helper.his;
|
||
|
//
|
||
|
//import com.alibaba.fastjson.JSON;
|
||
|
//import com.alibaba.fastjson.JSONArray;
|
||
|
//import com.alibaba.fastjson.JSONObject;
|
||
|
//import com.alibaba.fastjson.TypeReference;
|
||
|
//import com.ynxbd.common.helper.common.ErrorHelper;
|
||
|
//import org.dom4j.Attribute;
|
||
|
//import org.dom4j.Element;
|
||
|
//import org.slf4j.Logger;
|
||
|
//import org.slf4j.LoggerFactory;
|
||
|
//
|
||
|
//import java.math.BigDecimal;
|
||
|
//import java.util.List;
|
||
|
//import java.util.Map;
|
||
|
//
|
||
|
///**
|
||
|
// * HIS响应数据
|
||
|
// *
|
||
|
// * @Author wsq
|
||
|
// * @Date 2020/7/29 13:26
|
||
|
// * @Copyright @ 2020 云南新八达科技有限公司 All rights reserved.
|
||
|
// */
|
||
|
//
|
||
|
//public class HisResult {
|
||
|
// private final static Logger log = LoggerFactory.getLogger(HisResult.class);
|
||
|
//
|
||
|
// // 响应状态码
|
||
|
// private Integer responseCode;
|
||
|
// // 响应信息
|
||
|
// private String responseMessage;
|
||
|
// // HIS响应码
|
||
|
// private String transactionCode;
|
||
|
// // 数据
|
||
|
// private Map<String, Object> dataMap;
|
||
|
//
|
||
|
//
|
||
|
// /**
|
||
|
// * 创建一个异常信息
|
||
|
// *
|
||
|
// * @param message 异常信息
|
||
|
// * @return 模拟his异常信息
|
||
|
// */
|
||
|
// public static HisResult createErrorHisResult(String message) {
|
||
|
// HisResult hisResult = new HisResult();
|
||
|
// hisResult.setResponseCode(500); //
|
||
|
// hisResult.setResponseMessage(message);
|
||
|
// return hisResult;
|
||
|
// }
|
||
|
//
|
||
|
//
|
||
|
// /**
|
||
|
// * 获取DataMap的值 String
|
||
|
// *
|
||
|
// * @param nodeName 节点名称
|
||
|
// * @return nodeVal 节点值
|
||
|
// */
|
||
|
// public String getDataMapString(String nodeName) {
|
||
|
// try {
|
||
|
// Object val = this.dataMap.get(nodeName);
|
||
|
// if (val == null) {
|
||
|
// return null;
|
||
|
// }
|
||
|
// String v = val.toString().trim();
|
||
|
// return "".equals(v) ? null : v;
|
||
|
// } catch (Exception e) {
|
||
|
// ErrorHelper.println(e);
|
||
|
// return null;
|
||
|
// }
|
||
|
// }
|
||
|
//
|
||
|
// /**
|
||
|
// * 获取DataMap的值 BigDecimal
|
||
|
// *
|
||
|
// * @param nodeName 节点名称
|
||
|
// * @return nodeVal 节点值
|
||
|
// */
|
||
|
// public BigDecimal getDataMapBigDecimal(String nodeName) {
|
||
|
// try {
|
||
|
// Object val = this.dataMap.get(nodeName);
|
||
|
// return val == null ? null : new BigDecimal(val.toString());
|
||
|
// } catch (Exception e) {
|
||
|
// ErrorHelper.println(e);
|
||
|
// return null;
|
||
|
// }
|
||
|
// }
|
||
|
//
|
||
|
// /**
|
||
|
// * 获取DataMap的值 Integer
|
||
|
// *
|
||
|
// * @param nodeName 节点名称
|
||
|
// * @return nodeVal 节点值
|
||
|
// */
|
||
|
// public Integer getDataMapInteger(String nodeName) {
|
||
|
// try {
|
||
|
// Object val = this.dataMap.get(nodeName);
|
||
|
// return val == null ? null : Integer.parseInt(val.toString());
|
||
|
// } catch (Exception e) {
|
||
|
// ErrorHelper.println(e);
|
||
|
// return null;
|
||
|
// }
|
||
|
// }
|
||
|
//
|
||
|
// /**
|
||
|
// * 获取DataMap的值 Boolean
|
||
|
// *
|
||
|
// * @param nodeName 节点名称
|
||
|
// * @return nodeVal 节点值
|
||
|
// */
|
||
|
// public Boolean getDataMapBoolean(String nodeName) {
|
||
|
// try {
|
||
|
// Object val = this.dataMap.get(nodeName);
|
||
|
// return val == null ? null : Boolean.parseBoolean(val.toString());
|
||
|
// } catch (Exception e) {
|
||
|
// ErrorHelper.println(e);
|
||
|
// return null;
|
||
|
// }
|
||
|
// }
|
||
|
//
|
||
|
//
|
||
|
// /**
|
||
|
// * 获取DataMap的值 Long
|
||
|
// *
|
||
|
// * @param nodeName 节点名称
|
||
|
// * @return nodeVal 节点值
|
||
|
// */
|
||
|
// public Long getDataMapLong(String nodeName) {
|
||
|
// try {
|
||
|
// Object val = this.dataMap.get(nodeName);
|
||
|
// return val == null ? null : Long.parseLong(val.toString());
|
||
|
// } catch (Exception e) {
|
||
|
// ErrorHelper.println(e);
|
||
|
// return null;
|
||
|
// }
|
||
|
// }
|
||
|
//
|
||
|
//
|
||
|
// /**
|
||
|
// * 获取DataMap的值 Double
|
||
|
// *
|
||
|
// * @param nodeName 节点名称
|
||
|
// * @return nodeVal 节点值
|
||
|
// */
|
||
|
// public Double getDataMapDouble(String nodeName) {
|
||
|
// try {
|
||
|
// Object val = this.dataMap.get(nodeName);
|
||
|
// return val == null ? null : Double.parseDouble(val.toString());
|
||
|
// } catch (Exception e) {
|
||
|
// ErrorHelper.println(e);
|
||
|
// return null;
|
||
|
// }
|
||
|
// }
|
||
|
//
|
||
|
//
|
||
|
// /**
|
||
|
// * 获取根节点包含相同节点数据
|
||
|
// * 如:
|
||
|
// * <roots>
|
||
|
// * # <root>1</root>
|
||
|
// * # <root>2</root>
|
||
|
// * </roots>
|
||
|
// *
|
||
|
// * @param clazz 类型
|
||
|
// * @param rootNode 根节点名
|
||
|
// * @param nodes 子节点名,可变长参数
|
||
|
// * @return 集合
|
||
|
// */
|
||
|
// public <T> List<T> getDataMapList(Class<T> clazz, String rootNode, String... nodes) {
|
||
|
// JSONArray jsonArray = getJsonArray(rootNode, nodes);
|
||
|
// return decodeList(jsonArray.toString(), clazz);
|
||
|
// }
|
||
|
//
|
||
|
//
|
||
|
// /**
|
||
|
// * 获取嵌套多层的JSONArray
|
||
|
// *
|
||
|
// * @param rooNode 根节点
|
||
|
// * @param nodes 子节点,可变长参数
|
||
|
// * @return json数组
|
||
|
// */
|
||
|
// public JSONArray getJsonArray(String rooNode, String... nodes) {
|
||
|
// Object rootObj = this.dataMap.get(rooNode);
|
||
|
// String result = rootObj == null ? JSON.toJSONString(new JSONArray()) : rootObj.toString();
|
||
|
// try {
|
||
|
// JSONArray jsonArray;
|
||
|
// JSONObject jsonObject;
|
||
|
// for (String node : nodes) {
|
||
|
// jsonArray = JSONArray.parseArray(result);
|
||
|
// if (jsonArray == null || jsonArray.size() == 0) {
|
||
|
// return new JSONArray();
|
||
|
// }
|
||
|
// if (jsonArray.size() == 1) { // 如果只有一个值继续处理
|
||
|
// jsonObject = jsonArray.getJSONObject(0);
|
||
|
// result = JSON.toJSONString(jsonObject.getJSONArray(node));
|
||
|
// } else { // 如果有多个值返回当前数组
|
||
|
// result = JSON.toJSONString(jsonArray);
|
||
|
// }
|
||
|
// }
|
||
|
// } catch (Exception e) {
|
||
|
// log.error("JSON数据转换失败");
|
||
|
// ErrorHelper.println(e);
|
||
|
// }
|
||
|
// return JSONArray.parseArray(result);
|
||
|
// }
|
||
|
//
|
||
|
//
|
||
|
// /**
|
||
|
// * JSON树形结构数据向下JSONArray中传递
|
||
|
// *
|
||
|
// * @param jsonArray 根节点
|
||
|
// * @param properties 节点属性,可变长参数
|
||
|
// * @return JSONArray
|
||
|
// */
|
||
|
// public <T> List<T> jsonParentToChild(Class<T> clazz, JSONArray jsonArray, String rootNode, String... properties) {
|
||
|
// JSONArray result = new JSONArray();
|
||
|
// JSONObject jsonObject, childNode;
|
||
|
// JSONArray nodeJsonArr;
|
||
|
// for (int i = 0; i < jsonArray.size(); i++) {
|
||
|
// jsonObject = jsonArray.getJSONObject(i);
|
||
|
// nodeJsonArr = jsonObject.getJSONArray(rootNode);
|
||
|
// for (int j = 0; j < nodeJsonArr.size(); j++) {
|
||
|
// childNode = nodeJsonArr.getJSONObject(j);
|
||
|
// for (String property : properties) {
|
||
|
// for (String key : jsonObject.keySet()) { // 忽略大小写
|
||
|
// if (key.toLowerCase().equals(property.toLowerCase())) {
|
||
|
// property = key;
|
||
|
// break;
|
||
|
// }
|
||
|
// }
|
||
|
// String propertyVal = jsonObject.getString(property);
|
||
|
// childNode.put(property, propertyVal);
|
||
|
// }
|
||
|
// result.add(childNode);
|
||
|
// }
|
||
|
// }
|
||
|
// return decodeList(JSON.toJSONString(result), clazz);
|
||
|
// }
|
||
|
//
|
||
|
//
|
||
|
// /**
|
||
|
// * 获取DataMap为bean
|
||
|
// *
|
||
|
// * @param clazz 类型
|
||
|
// * @return bean
|
||
|
// */
|
||
|
// public <T> T getDataMapBean(Class<T> clazz) {
|
||
|
// return decodeBean(JSONObject.toJSONString(this.dataMap), clazz);
|
||
|
// }
|
||
|
//
|
||
|
// /**
|
||
|
// * 获取DataMap为bean
|
||
|
// *
|
||
|
// * @param clazz 类型
|
||
|
// * @return bean
|
||
|
// */
|
||
|
// public <T> T getDataMapBean(Class<T> clazz, String rooNode, String... nodes) {
|
||
|
// JSONObject jsonObject = getJsonObject(rooNode, nodes);
|
||
|
// if (jsonObject == null) {
|
||
|
// jsonObject = new JSONObject();
|
||
|
// }
|
||
|
// return decodeBean(jsonObject.toJSONString(), clazz);
|
||
|
// }
|
||
|
//
|
||
|
//// /**
|
||
|
//// * 获取DataMap为bean
|
||
|
//// *
|
||
|
//// * @param rooNode 根节点
|
||
|
//// * @param nodes 子节点
|
||
|
//// * @return bean
|
||
|
//// */
|
||
|
//// public JSONObject getDataMapObject(String rooNode, String... nodes) {
|
||
|
//// JSONObject jsonObject = getJsonObject(rooNode, nodes);
|
||
|
//// if (jsonObject == null) {
|
||
|
//// jsonObject = new JSONObject();
|
||
|
//// }
|
||
|
//// return decodeBean(jsonObject.toJSONString());
|
||
|
//// }
|
||
|
//
|
||
|
//
|
||
|
// /**
|
||
|
// * 获取嵌套多层的JSONArray
|
||
|
// *
|
||
|
// * @param rooNode 根节点
|
||
|
// * @param nodes 子节点,可变长参数
|
||
|
// * @return json对象
|
||
|
// */
|
||
|
// public JSONObject getJsonObject(String rooNode, String... nodes) {
|
||
|
// Object rootObj = this.dataMap.get(rooNode);
|
||
|
// String result = rootObj == null ? new JSONObject().toJSONString() : rootObj.toString();
|
||
|
// try {
|
||
|
// JSONArray jsonArray = JSONArray.parseArray(result);
|
||
|
// if (jsonArray == null || jsonArray.size() == 0) {
|
||
|
// return new JSONObject();
|
||
|
// }
|
||
|
//
|
||
|
// JSONObject jsonObject = jsonArray.getJSONObject(0);
|
||
|
// if (jsonObject == null) {
|
||
|
// return new JSONObject();
|
||
|
// }
|
||
|
//
|
||
|
// if (nodes.length == 0) {
|
||
|
// result = jsonObject.toJSONString();
|
||
|
// }
|
||
|
//
|
||
|
// for (String node : nodes) {
|
||
|
// result = jsonObject.getJSONObject(node).toJSONString();
|
||
|
// }
|
||
|
// } catch (Exception e) {
|
||
|
// log.error("JSON数据转换失败");
|
||
|
// ErrorHelper.println(e);
|
||
|
// }
|
||
|
// return JSONObject.parseObject(result);
|
||
|
// }
|
||
|
//
|
||
|
//
|
||
|
// // ---------------------------------------------------------------
|
||
|
//
|
||
|
// /**
|
||
|
// * fastJson反序列化Bean
|
||
|
// *
|
||
|
// * @param json json
|
||
|
// * @param clazz 类型
|
||
|
// * @return bean
|
||
|
// */
|
||
|
// public static <T> T decodeBean(String json, Class<T> clazz) {
|
||
|
// return JSON.parseObject(json, clazz);
|
||
|
// }
|
||
|
//
|
||
|
// /**
|
||
|
// * fastJson反序列化List
|
||
|
// *
|
||
|
// * @param json json
|
||
|
// * @param clazz 类型
|
||
|
// * @return List<T>
|
||
|
// */
|
||
|
// public static <T> List<T> decodeList(String json, Class<T> clazz) {
|
||
|
// return decode(json, new TypeReference<List<T>>(clazz) {
|
||
|
// });
|
||
|
// }
|
||
|
//
|
||
|
//
|
||
|
// /**
|
||
|
// * fastJson反序列化
|
||
|
// *
|
||
|
// * @param json json
|
||
|
// * @param typeReference 类型
|
||
|
// * @return 反序列化后的值
|
||
|
// */
|
||
|
// public static <T> T decode(String json, TypeReference<T> typeReference) {
|
||
|
// try {
|
||
|
// return JSON.parseObject(json, typeReference);
|
||
|
// } catch (Exception e) {
|
||
|
// e.printStackTrace();
|
||
|
// }
|
||
|
// return null;
|
||
|
// }
|
||
|
//
|
||
|
//
|
||
|
// /**
|
||
|
// * 递归-Element转JSONObject
|
||
|
// *
|
||
|
// * @param rootNode 根节点
|
||
|
// * @return JSONObject
|
||
|
// */
|
||
|
// public static JSONObject nodeToJsonObject(Element rootNode) {
|
||
|
// JSONObject result = new JSONObject();
|
||
|
// // 当前节点的名称、文本内容和属性
|
||
|
// for (Attribute attr : rootNode.attributes()) {// 遍历当前节点的所有属性
|
||
|
// result.put(attr.getName(), attr.getValue());
|
||
|
// }
|
||
|
//
|
||
|
// // 递归遍历当前节点所有的子节点
|
||
|
// List<Element> listElement = rootNode.elements();// 所有一级子节点的list
|
||
|
// if (!listElement.isEmpty()) {
|
||
|
// String name, val;
|
||
|
//
|
||
|
// for (Element e : listElement) {// 遍历所有一级子节点
|
||
|
// name = e.getName();
|
||
|
// val = e.getTextTrim();
|
||
|
// if (e.attributes().isEmpty() && e.elements().isEmpty()) // 判断一级节点是否有属性和子节点
|
||
|
// result.put(name, val.equals("") ? null : val); // 沒有则将当前节点作为上级节点的属性对待
|
||
|
// else {
|
||
|
// if (!result.containsKey(e.getName())) { // 判断父节点是否存在该一级节点名称的属性
|
||
|
// result.put(name, new JSONArray());// 没有则创建
|
||
|
// }
|
||
|
// JSONArray jsonArray = (JSONArray) result.get(name);
|
||
|
// jsonArray.add(nodeToJsonObject(e)); // 将该一级节点放入该节点名称的属性对应的值中
|
||
|
// }
|
||
|
// }
|
||
|
// }
|
||
|
// return result;
|
||
|
// }
|
||
|
//
|
||
|
//
|
||
|
//// public static void main(String[] args) {
|
||
|
//// String testXml = "<?xml version=\"1.0\" encoding=\"GB2312\"?><Response><TransactionCode>2001</TransactionCode><ResponseCode>0</ResponseCode><ResponseMessage>成功</ResponseMessage><Dept><Code>0201</Code><Name>急诊科</Name><Intro>全科医疗</Intro><Address>门诊楼</Address></Dept><Dept><Code>0202</Code><Name>院办</Name><Intro>全科医疗</Intro><Address></Address></Dept><Dept><Code>0203</Code><Name>重症医学科</Name><Intro>全科医疗</Intro><Address></Address></Dept><Dept><Code>0205</Code><Name>急诊科(二楼)</Name><Intro>全科医疗</Intro><Address>门诊二楼</Address></Dept><Dept><Code>0206</Code><Name>血液透析室</Name><Intro>全科医疗</Intro><Address>住院部一楼</Address></Dept><Dept><Code>0207</Code><Name>120急救中心</Name><Intro>全科医疗</Intro><Address></Address></Dept><Dept><Code>0301</Code><Name>内二科</Name><Intro>内科</Intro><Address>门诊三楼内科专家(五</Address></Dept><Dept><Code>0304</Code><Name>门诊部(二楼)</Name><Intro>内科</Intro><Address>门诊二楼</Address></Dept><Dept><Code>0305</Code><Name>门诊部(三楼)</Name><Intro>内科</Intro><Address>门诊三楼</Address></Dept><Dept><Code>0306</Code><Name>消化内科</Name><Intro>内科</Intro><Address>门诊三楼内科专家(六</Address></Dept><Dept><Code>0307</Code><Name>心内科</Name><Intro>内科</Intro><Address>住院部五楼医生办公室</Address></Dept><Dept><Code>0308</Code><Name>呼吸科</Name><Intro>内科</Intro><Address>门诊三楼内科专家(六</Address></Dept><Dept><Code>0309</Code><Name>精神心理科</Name><Intro>内科</Intro><Address>门诊三楼内科专家(七</Address></Dept><Dept><Code>0310</Code><Name>内分泌科</Name><Intro>内科</Intro><Address>门诊三楼内科专家(七</Address></Dept><Dept><Code>0311</Code><Name>内一科</Name><Intro>内科</Intro><Address>门诊三楼内科专家(一</Address></Dept><Dept><Code>0312</Code><Name>肾内科</Name><Intro>内科</Intro><Address>门诊三楼内科专家(六</Address></Dept><Dept><Code>0313</Code><Name>神经内科</Name><Intro>内科</Intro><Address>住院部四楼医生办公室</Address></Dept><Dept><Code>0401</Code><Name>外科</Name><Intro>外科</Intro><Address></Address></Dept><Dept><Code>0402</Code><Name>外一科</Name><Intro>外科</Intro><Address>住院部二楼</Address></Dept><Dept><Code>0403</Code><Name>外二科</Name><Intro>外科</Intro><Address>医技综合楼七楼</Address></Dept><Dept><Code>0404</Code><Name>外三科</Name><Intro>外科</Intro><Address>住院部三楼</Address></Dept><Dept><Code>0406</Code><Name>外(皮肤)科门诊</Name><Intro>外科</Intro><Address>门诊二楼</Address></Dept><Dept><Code>0501</Code><Name>妇产科</Name><Intro>妇产科</Intro><Address>门诊二楼</Address></Dept><Dept><Code>0712</Code><Name>儿科</Name><Intro>儿科</Intro><Address>门诊三楼</Address></Dept><Dept><Code>1100</Code><Name>耳鼻咽喉科</Name><Intro>耳鼻咽喉科</Intro><Address>医技综合楼五楼</Address></Dept><Dept><Code>1101</Code><Name>五官科</Name><Intro>耳鼻咽喉科</Intro><Address>医技综合楼五楼</Address></Dept><Dept><Code>1201</Code><Name>口腔科</Name><Intro>口腔科</Intro><Address>门诊三楼</Address></Dept><Dept><Code>1300</Code><Name>皮肤科</Name><Intro>皮肤科</Intro><Address>外科专家诊室</Address></Dept><Dept><Code>1601</Code><Name>抗病毒治疗室</Name><Intro>传染科</Intro><Address></Address></Dept><Dept><Code>1607</Code><Name>感染性疾病科</Name><Intro>传染科</Intro><Address></Address></Dept><Dept><Code>2100</Code><Name>中医康复科</Name><Intro>康复医学科</Intro><Address></Address></Dept><Dept><Code>2101</Code><Name>疼痛科门诊</Name><Intro>康复医学科</Intro><Address>门诊三楼</Address></Dept><Dept><Code>3205</Code><Name>功能科</Name><Intro>医学影象科</Intro><Address></Address></Dept><Dept><Code>5001</Code><Name>中医科</Name><Intro>中医科</Intro><Address></Address></Dept><Dept><Code>5002</Code><Name>中医肛肠科门诊</Name><Intro
|
||
|
//// // 对象封装
|
||
|
//// WsResult wsResult = WsResult.xmlToBean(testXml);
|
||
|
//// System.out.println(wsResult);
|
||
|
//// List<DeptBean> dept = wsResult.getDataMapList("Dept", DeptBean.class);
|
||
|
////
|
||
|
//// for (DeptBean d : dept) {
|
||
|
//// System.out.println(d);
|
||
|
//// }
|
||
|
//// }
|
||
|
//
|
||
|
// public HisResult() {
|
||
|
// }
|
||
|
//
|
||
|
// public HisResult(Integer responseCode, String responseMessage, String transactionCode, Map<String, Object> dataMap) {
|
||
|
// this.responseCode = responseCode;
|
||
|
// this.responseMessage = responseMessage;
|
||
|
// this.transactionCode = transactionCode;
|
||
|
// this.dataMap = dataMap;
|
||
|
// }
|
||
|
//
|
||
|
// public Integer getResponseCode() {
|
||
|
// return responseCode;
|
||
|
// }
|
||
|
//
|
||
|
// public void setResponseCode(Integer responseCode) {
|
||
|
// this.responseCode = responseCode;
|
||
|
// }
|
||
|
//
|
||
|
// public String getResponseMessage() {
|
||
|
// return responseMessage;
|
||
|
// }
|
||
|
//
|
||
|
// public void setResponseMessage(String responseMessage) {
|
||
|
// this.responseMessage = responseMessage;
|
||
|
// }
|
||
|
//
|
||
|
// public String getTransactionCode() {
|
||
|
// return transactionCode;
|
||
|
// }
|
||
|
//
|
||
|
// public void setTransactionCode(String transactionCode) {
|
||
|
// this.transactionCode = transactionCode;
|
||
|
// }
|
||
|
//
|
||
|
// public Map<String, Object> getDataMap() {
|
||
|
// return dataMap;
|
||
|
// }
|
||
|
//
|
||
|
// public void setDataMap(Map<String, Object> dataMap) {
|
||
|
// this.dataMap = dataMap;
|
||
|
// }
|
||
|
//
|
||
|
// @Override
|
||
|
// public String toString() {
|
||
|
// return "WsResult{" +
|
||
|
// "responseCode=" + responseCode +
|
||
|
// ", responseMessage='" + responseMessage + '\'' +
|
||
|
// ", transactionCode='" + transactionCode + '\'' +
|
||
|
// ", dataMap=" + dataMap +
|
||
|
// '}';
|
||
|
// }
|
||
|
//}
|
||
|
//
|