Parcourir la source

Setzen von StationsHistorie Eintraegen in die DB.

testBranch
Nils Dittberner il y a 10 ans
Parent
révision
28fc8df69d
2 fichiers modifiés avec 72 ajouts et 11 suppressions
  1. +44
    -1
      src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java
  2. +28
    -10
      src/main/java/de/uniluebeck/mi/projmi6/model/StationsHistorie.java

+ 44
- 1
src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java Voir le fichier

@@ -97,7 +97,7 @@ public class DBHandler {
"`LetzterBearbeiter`," +
"`Ersteller`)" +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
private static final String UPDATE_UNTERSUCHUNG = "UPDATE `untersuchung`" +
private static final String UPDATE_UNTERSUCHUNG = "UPDATE `untersuchung` " +
"SET `DurchfuehrenderArzt`=?," +
"`FallID`=?," +
"`OPSCode`=?," +
@@ -122,6 +122,21 @@ public class DBHandler {
"INNER JOIN fall f ON s.fallid = f.fallid " +
"INNER JOIN patient p ON f.patientid = p.id " +
"WHERE s.station = ?";
private static final String INSERT_STATHISTENTRY = "INSERT INTO `stationshistorie`" +
"(`Aufnahmedatum`," +
"`Entlassungsdatum`," +
"`FallID`," +
"`LetzterBearbeiter`," +
"`Station`," +
"`Ersteller`)" +
"VALUES (?, ?, ?, ?, ?, ?)";
private static final String UPDATE_STATHISTENTRY = "UPDATE `stationshistorie` " +
"SET `Aufnahmedatum`=?," +
"`Entlassungsdatum`=?," +
"`FallID`=?," +
"`LetzterBearbeiter`=?," +
"`Station`=? " +
"WHERE `StatHistID`=?";

/**
* Gibt alle {@link Patient} aus der DB zurueck.
@@ -308,6 +323,34 @@ public class DBHandler {
return historie;
}

public static void setStationsHistorie(StationsHistorie hist, boolean isUpdate) throws SQLException {
PreparedStatement statement;
if (isUpdate) {
statement = MySqlConnectionFactory.getConnection().prepareStatement(UPDATE_STATHISTENTRY);
} else {
statement = MySqlConnectionFactory.getConnection().prepareStatement(INSERT_STATHISTENTRY);
}

if (hist.getAufnahmeDatum() != null) {
statement.setTimestamp(1, Timestamp.valueOf(hist.getAufnahmeDatum())); // `Aufnahmedatum`
}
if (hist.getEntlassungsDatum() != null) {
statement.setTimestamp(2, Timestamp.valueOf(hist.getEntlassungsDatum())); // `Entlassungsdatum`
}
statement.setInt(3, hist.getFallID()); // `FallID`
statement.setInt(4, hist.getBearbeiter()); // `LetzterBearbeiter`
statement.setString(5, hist.getStationKey()); // `Station`


if (isUpdate) {
statement.setInt(6, hist.getStatHistID()); // `StatHistID`
statement.executeUpdate();
} else {
statement.setInt(6, hist.getErsteller()); // `Ersteller`
statement.execute();
}
}

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



+ 28
- 10
src/main/java/de/uniluebeck/mi/projmi6/model/StationsHistorie.java Voir le fichier

@@ -12,33 +12,35 @@ public class StationsHistorie extends Version {
private SimpleObjectProperty<LocalDateTime> aufnahmeDatum = new SimpleObjectProperty<>(this, "aufnahmeDatum");
private SimpleObjectProperty<LocalDateTime> entlassungsDatum = new SimpleObjectProperty<>(this, "entlassungsDatum");
private Fall fall;
private int fallID; // platte Objektstruktur!
private Station station;
private String stationKey; // platte Objektstruktur!
private SimpleIntegerProperty StatHistID = new SimpleIntegerProperty(this, "stathistid");

public LocalDateTime getAufnahmeDatum() {
return aufnahmeDatum.get();
}

public SimpleObjectProperty<LocalDateTime> aufnahmeDatumProperty() {
return aufnahmeDatum;
}

public void setAufnahmeDatum(LocalDateTime aufnahmeDatum) {
this.aufnahmeDatum.set(aufnahmeDatum);
}

public LocalDateTime getEntlassungsDatum() {
return entlassungsDatum.get();
public SimpleObjectProperty<LocalDateTime> aufnahmeDatumProperty() {
return aufnahmeDatum;
}

public SimpleObjectProperty<LocalDateTime> entlassungsDatumProperty() {
return entlassungsDatum;
public LocalDateTime getEntlassungsDatum() {
return entlassungsDatum.get();
}

public void setEntlassungsDatum(LocalDateTime entlassungsDatum) {
this.entlassungsDatum.set(entlassungsDatum);
}

public SimpleObjectProperty<LocalDateTime> entlassungsDatumProperty() {
return entlassungsDatum;
}

public Fall getFall() {
return fall;
}
@@ -59,11 +61,27 @@ public class StationsHistorie extends Version {
return StatHistID.get();
}

public void setStatHistID(int statHistID) {
this.StatHistID.set(statHistID);
}

public SimpleIntegerProperty statHistIDProperty() {
return StatHistID;
}

public void setStatHistID(int statHistID) {
this.StatHistID.set(statHistID);
public int getFallID() {
return fallID;
}

public void setFallID(int fallID) {
this.fallID = fallID;
}

public String getStationKey() {
return stationKey;
}

public void setStationKey(String stationKey) {
this.stationKey = stationKey;
}
}

Chargement…
Annuler
Enregistrer