Kaynağa Gözat

Laden der Stationshistore.

testBranch
ebeveyn
işleme
ca9823aa16
1 değiştirilmiş dosya ile 32 ekleme ve 0 silme
  1. +32
    -0
      src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java

+ 32
- 0
src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java Dosyayı Görüntüle

@@ -108,6 +108,7 @@ public class DBHandler {
private static final String SELECT_DIAGNOSE_BY_FALLID = "SELECT * FROM `diagnose` WHERE `fallid` = ?";
private static final String SELECT_ALL_KASSEN = "SELECT * FROM `kasse`";
private static final String SELECT_KASSE_BY_KASSENID = "SELECT * FROM `kasse` WHERE `kasse`.`KassenID` = ?";
private static final String SELECT_STATHIST_BY_STATION = "SELECT * FROM `stationshistorie` WHERE `stationshistorie`.`Station` = ?";

/**
* Gibt alle {@link Patient} aus der DB zurueck.
@@ -252,6 +253,37 @@ public class DBHandler {
return station;
}

public static List<StationsHistorie> getStationsHistorieByStation(String station) throws SQLException {
PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_STATHIST_BY_STATION);
statement.setString(1, station);
ResultSet rs = statement.executeQuery();

List<StationsHistorie> historie = new ArrayList<>();
while (rs.next()) {
historie.add(getStationsHistorie(rs));
}

return historie;
}

private static StationsHistorie getStationsHistorie(ResultSet rs) throws SQLException {
StationsHistorie hist = new StationsHistorie();

hist.setStatHistID(rs.getInt("stathistid"));
if (rs.getTimestamp("aufnahmedatum") != null) {
hist.setAufnahmeDatum(rs.getTimestamp("aufnahmedatum").toLocalDateTime());
}
if (rs.getTimestamp("entlassungsdatum") != null) {
hist.setEntlassungsDatum(rs.getTimestamp("entlassungsdatum").toLocalDateTime());
}

// TODO: Muss das jeweils das Objekt sein?
// hist.setFall(null);
// hist.setStation(null);

return hist;
}

public static List<Fall> getFaelleByPatID(int id) throws SQLException {
PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_FAELLE_BY_PATID);
statement.setInt(1, id);


Yükleniyor…
İptal
Kaydet