|
@@ -3,6 +3,8 @@ package com.lantone.qc.kernel;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONException;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.lantone.qc.kernel.model.ImportDiag;
|
|
|
+import com.lantone.qc.pub.util.FastJsonUtils;
|
|
|
import com.lantone.qc.pub.util.PropertiesUtil;
|
|
|
|
|
|
import java.sql.*;
|
|
@@ -19,27 +21,13 @@ public class DataTest {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public static List<Map<String, String>> loadHomePage(String tableName, String patientId) {
|
|
|
+ public static List<Map<String, Object>> loadHomePage(String tableName, String patientId) {
|
|
|
Connection conn = null;
|
|
|
Statement stmt = null;
|
|
|
ResultSet rs = null;
|
|
|
- List<Map<String, String>> resultList = null;
|
|
|
+ List<Map<String, Object>> resultList = null;
|
|
|
try {
|
|
|
- PropertiesUtil propertiesUtil = new PropertiesUtil("kernel.properties");
|
|
|
- Class.forName(propertiesUtil.getProperty("oracle.test.driver"));
|
|
|
-
|
|
|
- Properties props = new Properties();
|
|
|
- String url = propertiesUtil.getProperty("oracle.test.url");
|
|
|
- // 127.0.0.1是本机地址,1521是Oracle默认连接端口,DATABASE_NAME为实例名(SID)
|
|
|
- String user = propertiesUtil.getProperty("oracle.test.user");// 用户系统默认的账户名
|
|
|
- String password = propertiesUtil.getProperty("oracle.test.password");// 你安装时选设置的密码
|
|
|
- props.put("user", user);
|
|
|
- props.put("password", password);
|
|
|
- props.put("defaultRowPrefetch", "15");
|
|
|
- props.put("remarksReporting", "true");
|
|
|
- //默认情况下不允许用dba身份连接数据库,通过property设置以实现dba连接
|
|
|
- conn = DriverManager.getConnection(url, props);
|
|
|
- System.out.println("connection succeed!");
|
|
|
+ conn = getConnection();
|
|
|
stmt = conn.createStatement();
|
|
|
|
|
|
DatabaseMetaData dmd = conn.getMetaData();
|
|
@@ -53,8 +41,6 @@ public class DataTest {
|
|
|
|
|
|
rs = stmt.executeQuery("select * from " + tableName + " where brzyid = '" + patientId + "'");
|
|
|
resultList = resultSetToJson(rs, colMap);
|
|
|
- } catch (SQLException ex) {
|
|
|
- ex.printStackTrace();
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
} finally {
|
|
@@ -78,14 +64,112 @@ public class DataTest {
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
- public static List<Map<String, String>> resultSetToJson(ResultSet rs, Map<String, String> map) throws SQLException, JSONException {
|
|
|
+ public static List<Map<String, String>> loadHomePageDiagnose(String tableName, String zdlbdm, String patientId) {
|
|
|
+ Connection conn = null;
|
|
|
+ Statement stmt = null;
|
|
|
+ ResultSet rs = null;
|
|
|
+ List<Map<String, String>> resultList = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ conn = getConnection();
|
|
|
+ stmt = conn.createStatement();
|
|
|
+ if (zdlbdm.equals("1")) {
|
|
|
+ zdlbdm = "'门诊诊断'";
|
|
|
+ } else if (zdlbdm.equals("2")) {
|
|
|
+ zdlbdm = "'主要诊断','其他诊断'";
|
|
|
+ } else if (zdlbdm.equals("3")) {
|
|
|
+ zdlbdm = "'损伤中毒诊断'";
|
|
|
+ } else if (zdlbdm.equals("4")) {
|
|
|
+ zdlbdm = "'病理诊断'";
|
|
|
+ }
|
|
|
+ rs = stmt.executeQuery("select zdjbmc, icdm from " + tableName + " where zdlbdm in (" + zdlbdm + ") and basyid = '" + patientId + "' order by zdlbdm desc");
|
|
|
+ while (rs.next()) {
|
|
|
+ Map<String, String> map = new LinkedHashMap<>();
|
|
|
+ map.put("诊断名称", rs.getString(1));
|
|
|
+ map.put("诊断编码", 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static List<Map<String, String>> loadHomePageOperation(String tableNameOperation, String tableNameUser, String patientId) {
|
|
|
+ Connection conn = null;
|
|
|
+ Statement stmt = null;
|
|
|
+ ResultSet rs = null;
|
|
|
+ List<Map<String, String>> resultList = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ conn = getConnection();
|
|
|
+ stmt = conn.createStatement();
|
|
|
+ rs = stmt.executeQuery("SELECT r.BASYID, r.brssxh, r.BRSSRQ, r.BRSSMC, SSDMID, r.QKDJDM, r.YHDJDM, SSYSID, \n" +
|
|
|
+ "U1.YHRYMC, r.YZHSID, u3.yhrymc, r.MZYSID, u2.yhrymc, r.MZFFMC FROM " + tableNameOperation + " r\n" +
|
|
|
+ "left join " + tableNameUser + " u1 on r.SSYSID = u1.YHRYDM\n" +
|
|
|
+ "left join " + tableNameUser + " u2 on r.mzysid = u2.YHRYDM\n" +
|
|
|
+ "left join " + tableNameUser + " u3 on r.yzhsid = u3.YHRYDM\n" +
|
|
|
+ "where r.BASYID = '" + patientId + "' " +
|
|
|
+ "order by r.BASYID, r.brssxh");
|
|
|
+ while (rs.next()) {
|
|
|
+ Map<String, String> map = new LinkedHashMap<>();
|
|
|
+ map.put("手术日期", rs.getString(3));
|
|
|
+ map.put("手术名称", rs.getString(4));
|
|
|
+ map.put("手术编码", rs.getString(5));
|
|
|
+ map.put("切口等级", rs.getString(6));
|
|
|
+ map.put("愈合等级", rs.getString(7));
|
|
|
+ map.put("术者", rs.getString(9));
|
|
|
+ map.put("一助", rs.getString(11));
|
|
|
+ map.put("麻醉医师", rs.getString(13));
|
|
|
+ map.put("麻醉方式", rs.getString(14));
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static List<Map<String, Object>> resultSetToJson(ResultSet rs, Map<String, String> map) throws SQLException, JSONException {
|
|
|
// 获取列数
|
|
|
ResultSetMetaData metaData = (ResultSetMetaData) rs.getMetaData();
|
|
|
int columnCount = metaData.getColumnCount();
|
|
|
- List<Map<String, String>> resultList = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
while (rs.next()) {
|
|
|
// 遍历ResultSet中的每条数据
|
|
|
- Map<String, String> result = new LinkedHashMap<>();
|
|
|
+ Map<String, Object> result = new LinkedHashMap<>();
|
|
|
// 遍历每一列
|
|
|
for (int i = 1; i <= columnCount; i++) {
|
|
|
String columnName = metaData.getColumnLabel(i);
|
|
@@ -97,4 +181,22 @@ public class DataTest {
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
+ private static Connection getConnection() throws Exception {
|
|
|
+ PropertiesUtil propertiesUtil = new PropertiesUtil("kernel.properties");
|
|
|
+ Class.forName(propertiesUtil.getProperty("oracle.test.driver"));
|
|
|
+
|
|
|
+ Properties props = new Properties();
|
|
|
+ String url = propertiesUtil.getProperty("oracle.test.url");
|
|
|
+ // 127.0.0.1是本机地址,1521是Oracle默认连接端口,DATABASE_NAME为实例名(SID)
|
|
|
+ String user = propertiesUtil.getProperty("oracle.test.user");// 用户系统默认的账户名
|
|
|
+ String password = propertiesUtil.getProperty("oracle.test.password");// 你安装时选设置的密码
|
|
|
+ props.put("user", user);
|
|
|
+ props.put("password", password);
|
|
|
+ props.put("defaultRowPrefetch", "15");
|
|
|
+ props.put("remarksReporting", "true");
|
|
|
+ //默认情况下不允许用dba身份连接数据库,通过property设置以实现dba连接
|
|
|
+ Connection conn = DriverManager.getConnection(url, props);
|
|
|
+ return conn;
|
|
|
+ }
|
|
|
+
|
|
|
}
|