|
|
|
@@ -3,6 +3,7 @@ package de.uniluebeck.mi.projmi6.db; |
|
|
|
import de.uniluebeck.mi.projmi6.model.*; |
|
|
|
|
|
|
|
import java.sql.*; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
@@ -137,6 +138,12 @@ public class DBHandler { |
|
|
|
"`LetzterBearbeiter`=?," + |
|
|
|
"`Station`=? " + |
|
|
|
"WHERE `StatHistID`=?"; |
|
|
|
private static final String SELECT_LAST_HL7ENTRIES = "SELECT * FROM `hl7_nachrichten` limit ?"; |
|
|
|
private static final String INSERT_HL7NACHRICHT = "INSERT INTO `hl7_nachrichten` " + |
|
|
|
"(`hl7msg`," + |
|
|
|
"`timestamp`," + |
|
|
|
"`source`) " + |
|
|
|
"VALUES (?, ?, ?)"; |
|
|
|
|
|
|
|
/** |
|
|
|
* Gibt alle {@link Patient} aus der DB zurueck. |
|
|
|
@@ -768,4 +775,36 @@ public class DBHandler { |
|
|
|
setVersionInformation(kasse, rs); |
|
|
|
return kasse; |
|
|
|
} |
|
|
|
|
|
|
|
public static void setHL7Nachricht(String hl7msg, LocalDateTime timestamp, String source) throws SQLException { |
|
|
|
PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(INSERT_HL7NACHRICHT); |
|
|
|
statement.setString(1, hl7msg); |
|
|
|
statement.setTimestamp(2, Timestamp.valueOf(timestamp)); |
|
|
|
statement.setString(3, source); |
|
|
|
statement.execute(); |
|
|
|
} |
|
|
|
|
|
|
|
public static List<HL7LogEntry> getLastHL7LogEntries() throws SQLException { |
|
|
|
return getLastHL7LogEntries(30); |
|
|
|
} |
|
|
|
|
|
|
|
public static List<HL7LogEntry> getLastHL7LogEntries(int last) throws SQLException { |
|
|
|
PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_LAST_HL7ENTRIES); |
|
|
|
statement.setInt(1, last); |
|
|
|
ResultSet rs = statement.executeQuery(); |
|
|
|
|
|
|
|
List<HL7LogEntry> hl7entries = new ArrayList<>(); |
|
|
|
while (rs.next()) { |
|
|
|
hl7entries.add(getHL7LogEntry(rs)); |
|
|
|
} |
|
|
|
return hl7entries; |
|
|
|
} |
|
|
|
|
|
|
|
private static HL7LogEntry getHL7LogEntry(ResultSet rs) throws SQLException { |
|
|
|
HL7LogEntry entry = new HL7LogEntry(rs.getInt("msgid")); |
|
|
|
entry.setMessage(rs.getString("hl7msg")); |
|
|
|
entry.setTimestamp(rs.getTimestamp("timestamp").toLocalDateTime()); |
|
|
|
entry.setSource(rs.getString("source")); |
|
|
|
return entry; |
|
|
|
} |
|
|
|
} |