Compare commits
9 commits
e184950622
...
b61100f3f9
Author | SHA1 | Date | |
---|---|---|---|
b61100f3f9 | |||
97373930ec | |||
a437b00921 | |||
efea16e5b1 | |||
|
db572dfa95 | ||
|
02232cd27f | ||
|
e584e220a5 | ||
|
9fac5b34a3 | ||
|
6300509873 |
13 changed files with 465 additions and 39 deletions
|
@ -1,5 +1,11 @@
|
|||
package de.hitec.nhplus.fixtures;
|
||||
|
||||
import de.hitec.nhplus.Main;
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.medication.Ingredient;
|
||||
import de.hitec.nhplus.medication.Medication;
|
||||
import de.hitec.nhplus.medication.database.MedicationDao;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.Connection;
|
||||
|
@ -132,20 +138,22 @@ public class MedicationFixture implements Fixture<Medication> {
|
|||
120,
|
||||
new ArrayList<>()
|
||||
));
|
||||
medications.add(new Medication(
|
||||
"Levothyroxin",
|
||||
"Sandoz",
|
||||
List.of(
|
||||
levothyroxinnatrium,
|
||||
laktose,
|
||||
staerke,
|
||||
akaziengummi
|
||||
),
|
||||
"Herzrasen, Gewichtsverlust",
|
||||
"Oral",
|
||||
90,
|
||||
new ArrayList<>()
|
||||
));
|
||||
Medication deprecatedMedication = new Medication(
|
||||
"Levothyroxin",
|
||||
"Sandoz",
|
||||
List.of(
|
||||
levothyroxinnatrium,
|
||||
laktose,
|
||||
staerke,
|
||||
akaziengummi
|
||||
),
|
||||
"Herzrasen, Gewichtsverlust",
|
||||
"Oral",
|
||||
90,
|
||||
new ArrayList<>()
|
||||
);
|
||||
deprecatedMedication.setIsDeprecated(true);
|
||||
medications.add(deprecatedMedication);
|
||||
medications.add(new Medication(
|
||||
"Warfarin",
|
||||
"Apotex Inc.",
|
||||
|
|
|
@ -80,10 +80,16 @@ public class MainWindowController {
|
|||
Permissions.MANAGEMENT | Permissions.OWNER
|
||||
)
|
||||
));
|
||||
tabManager.setupTab(mainTabPane, new TabStruct(
|
||||
"Medikamente",
|
||||
"/de/hitec/nhplus/medication/AllMedicationView.fxml",
|
||||
Permissions.MANAGEMENT
|
||||
tabManager.setupSubTabPane(mainTabPane, "Medikamente", Permissions.MANAGEMENT, List.of(
|
||||
new TabStruct(
|
||||
"Medikamente",
|
||||
"/de/hitec/nhplus/medication/AllMedicationView.fxml",
|
||||
Permissions.MANAGEMENT
|
||||
), new TabStruct(
|
||||
"Veraltete Medikamente",
|
||||
"/de/hitec/nhplus/medication/DeprecatedMedicationView.fxml",
|
||||
Permissions.MANAGEMENT
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ import java.util.stream.Collectors;
|
|||
|
||||
import de.hitec.nhplus.Main;
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.login.Permissions;
|
||||
import de.hitec.nhplus.main.MainWindowController;
|
||||
import de.hitec.nhplus.medication.database.MedicationDao;
|
||||
import de.hitec.nhplus.nurse.Nurse;
|
||||
import de.hitec.nhplus.patient.Patient;
|
||||
|
@ -15,9 +17,11 @@ import de.hitec.nhplus.treatment.TreatmentModalController;
|
|||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.SelectionModel;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
|
@ -50,9 +54,16 @@ public class AllMedicationController {
|
|||
private TableColumn<Medication, Integer> columnCurrentStock;
|
||||
@FXML
|
||||
public TableColumn<Medication, String> columnAlternativeMedication;
|
||||
@FXML
|
||||
public Button buttonChangeAvailable;
|
||||
@FXML
|
||||
public Button buttonAdd;
|
||||
@FXML
|
||||
public Button buttonDelete;
|
||||
|
||||
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
|
||||
private MedicationDao dao;
|
||||
private boolean hasEditPermissions;
|
||||
|
||||
public MedicationDao getDao() {
|
||||
return dao;
|
||||
|
@ -63,7 +74,10 @@ public class AllMedicationController {
|
|||
*/
|
||||
@FXML
|
||||
public void initialize() {
|
||||
readAllAndShowInTableView();
|
||||
int editPermissions = Permissions.MANAGEMENT | Permissions.OWNER;
|
||||
int userPermissions = MainWindowController.getInstance().getUser().getPermissions();
|
||||
hasEditPermissions = (userPermissions & editPermissions) != 0;
|
||||
this.readAllAndShowInTableView();
|
||||
|
||||
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
||||
this.columnName.setCellValueFactory(new PropertyValueFactory<>("name"));
|
||||
|
@ -104,6 +118,13 @@ public class AllMedicationController {
|
|||
);
|
||||
|
||||
this.tableView.setItems(this.medications);
|
||||
|
||||
if (!hasEditPermissions) {
|
||||
this.buttonAdd.setDisable(true);
|
||||
this.buttonDelete.setDisable(true);
|
||||
this.buttonChangeAvailable.setDisable(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,7 +133,7 @@ public class AllMedicationController {
|
|||
public void readAllAndShowInTableView() {
|
||||
this.dao = DaoFactory.getInstance().createMedicationDAO();
|
||||
try {
|
||||
this.medications.setAll(dao.readAll());
|
||||
this.medications.setAll(dao.readAllAvailable());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
@ -142,6 +163,38 @@ public class AllMedicationController {
|
|||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void handleChangeAvailable() {
|
||||
Medication selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||
if (selectedItem == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
selectedItem.setIsDeprecated(true);
|
||||
this.dao.update(selectedItem);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
this.readAllAndShowInTableView();
|
||||
}
|
||||
|
||||
|
||||
@FXML
|
||||
public void handleDelete() {
|
||||
Medication selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||
if (selectedItem == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
this.dao.delete(selectedItem.getId());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
this.readAllAndShowInTableView();
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to create a {@link MedicationModalController MedicationModal}.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
package de.hitec.nhplus.medication;
|
||||
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.medication.database.MedicationDao;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The controller for viewing all deprecated {@link Medication}s.
|
||||
*
|
||||
* @author Armin Ribic
|
||||
* @author Dorian Nemec
|
||||
*/
|
||||
public class DeprecatedMedicationController {
|
||||
@FXML
|
||||
private TableView<Medication> tableView;
|
||||
@FXML
|
||||
private TableColumn<Medication, Integer> columnId;
|
||||
@FXML
|
||||
private TableColumn<Medication, String> columnName;
|
||||
@FXML
|
||||
private TableColumn<Medication, String> columnManufacturer;
|
||||
@FXML
|
||||
private TableColumn<Medication, String> columnIngredient;
|
||||
@FXML
|
||||
private TableColumn<Medication, String> columnPossibleSideEffects;
|
||||
@FXML
|
||||
private TableColumn<Medication, String> columnAdministrationMethod;
|
||||
@FXML
|
||||
private TableColumn<Medication, Integer> columnCurrentStock;
|
||||
@FXML
|
||||
public Button buttonChangeAvailable;
|
||||
|
||||
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
|
||||
private MedicationDao dao;
|
||||
|
||||
/**
|
||||
* Initialization method that is called after the binding of all the fields.
|
||||
*/
|
||||
public void initialize() {
|
||||
this.readAllAndShowInTableView();
|
||||
|
||||
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
||||
this.columnName.setCellValueFactory(new PropertyValueFactory<>("name"));
|
||||
this.columnManufacturer.setCellValueFactory(new PropertyValueFactory<>("manufacturer"));
|
||||
this.columnIngredient.setCellValueFactory(
|
||||
cellData -> {
|
||||
Medication medication = cellData.getValue();
|
||||
List<Ingredient> ingredients = medication.getIngredients();
|
||||
if (ingredients.isEmpty()) {
|
||||
return new SimpleStringProperty("");
|
||||
}
|
||||
|
||||
return new SimpleStringProperty(
|
||||
ingredients
|
||||
.stream()
|
||||
.map(ingredient -> ingredient.getName())
|
||||
.collect(Collectors.joining("\n"))
|
||||
);
|
||||
});
|
||||
this.columnPossibleSideEffects.setCellValueFactory(new PropertyValueFactory<>("possibleSideEffects"));
|
||||
this.columnAdministrationMethod.setCellValueFactory(new PropertyValueFactory<>("administrationMethod"));
|
||||
this.columnCurrentStock.setCellValueFactory(new PropertyValueFactory<>("currentStock"));
|
||||
|
||||
this.tableView.setItems(this.medications);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to read all data and set it to the table view.
|
||||
*/
|
||||
public void readAllAndShowInTableView() {
|
||||
this.medications.clear();
|
||||
this.dao = DaoFactory.getInstance().createMedicationDAO();
|
||||
try {
|
||||
this.medications.setAll(this.dao.readAllDeprecated());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void handleChangeAvailable() {
|
||||
Medication selectedItem = tableView.getSelectionModel().getSelectedItem();
|
||||
if (selectedItem == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
selectedItem.setIsDeprecated(false);
|
||||
this.dao.update(selectedItem);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
this.readAllAndShowInTableView();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package de.hitec.nhplus.medication;
|
||||
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleListProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
@ -24,6 +25,7 @@ public class Medication {
|
|||
private SimpleStringProperty administrationMethod;
|
||||
private SimpleIntegerProperty currentStock;
|
||||
private SimpleListProperty<Medication> alternativeMedication;
|
||||
private SimpleBooleanProperty isDeprecated;
|
||||
|
||||
/**
|
||||
* This constructor allows instantiating a {@link Medication} object,
|
||||
|
@ -48,6 +50,7 @@ public class Medication {
|
|||
this.administrationMethod = new SimpleStringProperty(administrationMethod);
|
||||
this.currentStock = new SimpleIntegerProperty(currentStock);
|
||||
this.alternativeMedication = new SimpleListProperty<>(FXCollections.observableArrayList(alternativeMedication));
|
||||
this.isDeprecated = new SimpleBooleanProperty(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,7 +64,8 @@ public class Medication {
|
|||
String possibleSideEffects,
|
||||
String administrationMethod,
|
||||
int currentStock,
|
||||
List<Medication> alternativeMedication
|
||||
List<Medication> alternativeMedication,
|
||||
boolean isDeprecated
|
||||
) {
|
||||
this.id = new SimpleIntegerProperty(id);
|
||||
this.name = new SimpleStringProperty(name);
|
||||
|
@ -71,6 +75,7 @@ public class Medication {
|
|||
this.administrationMethod = new SimpleStringProperty(administrationMethod);
|
||||
this.currentStock = new SimpleIntegerProperty(currentStock);
|
||||
this.alternativeMedication = new SimpleListProperty<>(FXCollections.observableArrayList(alternativeMedication));
|
||||
this.isDeprecated = new SimpleBooleanProperty(isDeprecated);
|
||||
}
|
||||
|
||||
public void replace(Medication medication){
|
||||
|
@ -85,6 +90,7 @@ public class Medication {
|
|||
this.administrationMethod = medication.administrationMethodProperty();
|
||||
this.currentStock = medication.currentStockProperty();
|
||||
this.alternativeMedication = medication.alternativeMedicationProperty();
|
||||
this.isDeprecated = medication.isDeprecatedProperty();
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
|
@ -103,6 +109,18 @@ public class Medication {
|
|||
return name;
|
||||
}
|
||||
|
||||
public boolean isDeprecated() {
|
||||
return isDeprecated.get();
|
||||
}
|
||||
|
||||
public SimpleBooleanProperty isDeprecatedProperty() {
|
||||
return isDeprecated;
|
||||
}
|
||||
|
||||
public void setIsDeprecated(boolean isDeprecated) {
|
||||
this.isDeprecated.set(isDeprecated);
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name.set(name);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ public class MedicationModalController {
|
|||
@FXML
|
||||
public ListView<Medication> listViewAlternativeMedication;
|
||||
|
||||
|
||||
private Stage stage;
|
||||
private Medication medication;
|
||||
private final ObservableList<Ingredient> ingredients = FXCollections.observableArrayList();
|
||||
|
|
|
@ -29,8 +29,8 @@ public class MedicationDao implements Dao<Medication> {
|
|||
connection.setAutoCommit(false); //Switch to Manual Commit, to do an SQL Transaction
|
||||
final String medicationSQL = """
|
||||
INSERT INTO medication
|
||||
(name, manufacturer, possibleSideEffects, administrationMethod, currentStock)
|
||||
VALUES (?, ?, ?, ?, ?);
|
||||
(name, manufacturer, possibleSideEffects, administrationMethod, currentStock, isDeprecated)
|
||||
VALUES (?, ?, ?, ?, ?, ?);
|
||||
""";
|
||||
PreparedStatement medicationStatement = this.connection.prepareStatement(medicationSQL);
|
||||
medicationStatement.setString(1, medication.getName());
|
||||
|
@ -38,6 +38,7 @@ public class MedicationDao implements Dao<Medication> {
|
|||
medicationStatement.setString(3, medication.getPossibleSideEffects());
|
||||
medicationStatement.setString(4, medication.getAdministrationMethod());
|
||||
medicationStatement.setInt(5, medication.getCurrentStock());
|
||||
medicationStatement.setBoolean(6, medication.isDeprecated());
|
||||
medicationStatement.execute();
|
||||
|
||||
ResultSet generatedKeys = connection.createStatement().executeQuery("SELECT last_insert_rowid()");
|
||||
|
@ -110,20 +111,157 @@ public class MedicationDao implements Dao<Medication> {
|
|||
result.getString(4),
|
||||
result.getString(5),
|
||||
result.getInt(6),
|
||||
new ArrayList<>()
|
||||
new ArrayList<>(),
|
||||
result.getBoolean(7)
|
||||
);
|
||||
medications.put(currentMedicationId, medication);
|
||||
}
|
||||
|
||||
List<Ingredient> ingredients = ingredientMap.computeIfAbsent(currentMedicationId, k -> new ArrayList<>());
|
||||
String ingredientName = result.getString(7);
|
||||
String ingredientName = result.getString(8);
|
||||
if (ingredientName != null && !latIngredient.equals(ingredientName)) {
|
||||
ingredients.add(new Ingredient(ingredientName));
|
||||
latIngredient = ingredientName;
|
||||
}
|
||||
|
||||
Set<Integer> alternatives = alternativesMap.computeIfAbsent(currentMedicationId, k -> new HashSet<>());
|
||||
int alternativeId = result.getInt(8);
|
||||
int alternativeId = result.getInt(9);
|
||||
if (alternativeId != 0) {
|
||||
alternatives.add(alternativeId);
|
||||
}
|
||||
|
||||
lastMedicationId = currentMedicationId;
|
||||
}
|
||||
for (Medication medication : medications.values()) {
|
||||
List<Ingredient> ingredients = ingredientMap.get(medication.getId());
|
||||
if (ingredients.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
medication.setIngredients(ingredientMap.get(medication.getId()));
|
||||
Set<Integer> alternativeIds = alternativesMap.get(medication.getId());
|
||||
List<Medication> alternatives = new ArrayList<>();
|
||||
for (Integer alternativeId : alternativeIds) {
|
||||
alternatives.add(medications.get(alternativeId));
|
||||
}
|
||||
medication.setAlternativeMedication(alternatives);
|
||||
}
|
||||
|
||||
return medications.values().stream().toList();
|
||||
}
|
||||
|
||||
public List<Medication> readAllAvailable() throws SQLException {
|
||||
final String SQL = """
|
||||
SELECT medication.*, medication_ingredient.name, medication_alternative.alternativeId
|
||||
FROM medication
|
||||
LEFT JOIN
|
||||
medication_ingredient ON medication.id = medication_ingredient.id
|
||||
LEFT JOIN
|
||||
medication_alternative ON medication.id = medication_alternative.id
|
||||
WHERE medication.isDeprecated = false
|
||||
""";
|
||||
ResultSet result = connection.prepareStatement(SQL).executeQuery();
|
||||
|
||||
Map<Integer, Medication> medications = new HashMap<>();
|
||||
Map<Integer, List<Ingredient>> ingredientMap = new HashMap<>();
|
||||
Map<Integer, Set<Integer>> alternativesMap = new HashMap<>();
|
||||
|
||||
int currentMedicationId;
|
||||
int lastMedicationId = -1;
|
||||
String latIngredient = "";
|
||||
while (result.next()) {
|
||||
currentMedicationId = result.getInt(1);
|
||||
if (currentMedicationId != lastMedicationId) {
|
||||
Medication medication = new Medication(
|
||||
result.getInt(1),
|
||||
result.getString(2),
|
||||
result.getString(3),
|
||||
new ArrayList<>(),
|
||||
result.getString(4),
|
||||
result.getString(5),
|
||||
result.getInt(6),
|
||||
new ArrayList<>(),
|
||||
result.getBoolean(7)
|
||||
);
|
||||
medications.put(currentMedicationId, medication);
|
||||
}
|
||||
|
||||
List<Ingredient> ingredients = ingredientMap.computeIfAbsent(currentMedicationId, k -> new ArrayList<>());
|
||||
String ingredientName = result.getString(8);
|
||||
if (ingredientName != null && !latIngredient.equals(ingredientName)) {
|
||||
ingredients.add(new Ingredient(ingredientName));
|
||||
latIngredient = ingredientName;
|
||||
}
|
||||
|
||||
Set<Integer> alternatives = alternativesMap.computeIfAbsent(currentMedicationId, k -> new HashSet<>());
|
||||
int alternativeId = result.getInt(9);
|
||||
if (alternativeId != 0) {
|
||||
alternatives.add(alternativeId);
|
||||
}
|
||||
|
||||
lastMedicationId = currentMedicationId;
|
||||
}
|
||||
for (Medication medication : medications.values()) {
|
||||
List<Ingredient> ingredients = ingredientMap.get(medication.getId());
|
||||
if (ingredients.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
medication.setIngredients(ingredientMap.get(medication.getId()));
|
||||
Set<Integer> alternativeIds = alternativesMap.get(medication.getId());
|
||||
List<Medication> alternatives = new ArrayList<>();
|
||||
for (Integer alternativeId : alternativeIds) {
|
||||
alternatives.add(medications.get(alternativeId));
|
||||
}
|
||||
medication.setAlternativeMedication(alternatives);
|
||||
}
|
||||
|
||||
return medications.values().stream().toList();
|
||||
}
|
||||
|
||||
public List<Medication> readAllDeprecated() throws SQLException {
|
||||
final String SQL = """
|
||||
SELECT medication.*, medication_ingredient.name, medication_alternative.alternativeId
|
||||
FROM medication
|
||||
LEFT JOIN
|
||||
medication_ingredient ON medication.id = medication_ingredient.id
|
||||
LEFT JOIN
|
||||
medication_alternative ON medication.id = medication_alternative.id
|
||||
WHERE medication.isDeprecated = true
|
||||
""";
|
||||
ResultSet result = connection.prepareStatement(SQL).executeQuery();
|
||||
|
||||
Map<Integer, Medication> medications = new HashMap<>();
|
||||
Map<Integer, List<Ingredient>> ingredientMap = new HashMap<>();
|
||||
Map<Integer, Set<Integer>> alternativesMap = new HashMap<>();
|
||||
|
||||
int currentMedicationId;
|
||||
int lastMedicationId = -1;
|
||||
String latIngredient = "";
|
||||
while (result.next()) {
|
||||
currentMedicationId = result.getInt(1);
|
||||
if (currentMedicationId != lastMedicationId) {
|
||||
Medication medication = new Medication(
|
||||
result.getInt(1),
|
||||
result.getString(2),
|
||||
result.getString(3),
|
||||
new ArrayList<>(),
|
||||
result.getString(4),
|
||||
result.getString(5),
|
||||
result.getInt(6),
|
||||
new ArrayList<>(),
|
||||
result.getBoolean(7)
|
||||
);
|
||||
medications.put(currentMedicationId, medication);
|
||||
}
|
||||
|
||||
List<Ingredient> ingredients = ingredientMap.computeIfAbsent(currentMedicationId, k -> new ArrayList<>());
|
||||
String ingredientName = result.getString(8);
|
||||
if (ingredientName != null && !latIngredient.equals(ingredientName)) {
|
||||
ingredients.add(new Ingredient(ingredientName));
|
||||
latIngredient = ingredientName;
|
||||
}
|
||||
|
||||
Set<Integer> alternatives = alternativesMap.computeIfAbsent(currentMedicationId, k -> new HashSet<>());
|
||||
int alternativeId = result.getInt(9);
|
||||
if (alternativeId != 0) {
|
||||
alternatives.add(alternativeId);
|
||||
}
|
||||
|
@ -155,7 +293,8 @@ public class MedicationDao implements Dao<Medication> {
|
|||
manufacturer = ?,
|
||||
possibleSideEffects = ?,
|
||||
administrationMethod = ?,
|
||||
currentStock = ?
|
||||
currentStock = ?,
|
||||
isDeprecated = ?
|
||||
WHERE id = ?
|
||||
""";
|
||||
PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
|
||||
|
@ -164,7 +303,8 @@ public class MedicationDao implements Dao<Medication> {
|
|||
preparedStatement.setString(3, medication.getPossibleSideEffects());
|
||||
preparedStatement.setString(4, medication.getAdministrationMethod());
|
||||
preparedStatement.setInt(5, medication.getCurrentStock());
|
||||
preparedStatement.setInt(6, medication.getId());
|
||||
preparedStatement.setBoolean(6, medication.isDeprecated());
|
||||
preparedStatement.setInt(7, medication.getId());
|
||||
preparedStatement.executeUpdate();
|
||||
|
||||
final String ingredientDeleteSQL = """
|
||||
|
@ -249,17 +389,18 @@ public class MedicationDao implements Dao<Medication> {
|
|||
result.getString(4),
|
||||
result.getString(5),
|
||||
result.getInt(6),
|
||||
new ArrayList<>()
|
||||
new ArrayList<>(),
|
||||
result.getBoolean(7)
|
||||
);
|
||||
|
||||
List<Ingredient> ingredients = new ArrayList<>();
|
||||
List<Medication> alternatives = new ArrayList<>();
|
||||
while (result.next()) {
|
||||
String ingredientName = result.getString(7);
|
||||
String ingredientName = result.getString(8);
|
||||
if (ingredientName != null) {
|
||||
ingredients.add(new Ingredient(ingredientName));
|
||||
}
|
||||
int alternativeId = result.getInt(8);
|
||||
int alternativeId = result.getInt(9);
|
||||
if (alternativeId != 0) {
|
||||
ResultSet alternativeResult = getReadStatement(alternativeId).executeQuery();
|
||||
Medication alternativeMedication = new Medication(
|
||||
|
@ -270,7 +411,8 @@ public class MedicationDao implements Dao<Medication> {
|
|||
alternativeResult.getString(4),
|
||||
alternativeResult.getString(5),
|
||||
alternativeResult.getInt(6),
|
||||
new ArrayList<>()
|
||||
new ArrayList<>(),
|
||||
alternativeResult.getBoolean(7)
|
||||
);
|
||||
alternatives.add(alternativeMedication);
|
||||
}
|
||||
|
@ -279,6 +421,5 @@ public class MedicationDao implements Dao<Medication> {
|
|||
medication.setAlternativeMedication(alternatives);
|
||||
return medication;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,6 +112,4 @@ public class NurseDao extends DaoImp<Nurse> {
|
|||
statement.setInt(1, id);
|
||||
return statement;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public class AllTreatmentController {
|
|||
*/
|
||||
@FXML
|
||||
public void initialize() {
|
||||
readAllAndShowInTableView();
|
||||
|
||||
comboBoxPatientSelection.setItems(patientSelection);
|
||||
comboBoxPatientSelection.getSelectionModel().select("alle");
|
||||
|
||||
|
@ -112,7 +112,7 @@ public class AllTreatmentController {
|
|||
);
|
||||
|
||||
this.createComboBoxData();
|
||||
|
||||
readAllAndShowInTableView();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -312,6 +312,8 @@ public class AllTreatmentController {
|
|||
@FXML
|
||||
public void handleLock(){
|
||||
Treatment selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||
LocalDate today = LocalDate.now();
|
||||
|
||||
if (selectedItem == null){
|
||||
return;
|
||||
}
|
||||
|
@ -322,6 +324,13 @@ public class AllTreatmentController {
|
|||
}catch (SQLException exception){
|
||||
exception.printStackTrace();
|
||||
}
|
||||
if (selectedItem.calculateDeleteDate().isBefore(today) || selectedItem.calculateDeleteDate().equals(today)){
|
||||
try {
|
||||
dao.delete(selectedItem.getId());
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
readAllAndShowInTableView();
|
||||
}
|
||||
|
||||
|
|
|
@ -78,8 +78,16 @@
|
|||
fx:id="buttonDelete"
|
||||
mnemonicParsing="false"
|
||||
prefWidth="90.0"
|
||||
onAction="#handleDelete"
|
||||
text="Löschen"
|
||||
/>
|
||||
<Button
|
||||
fx:id="buttonChangeAvailable"
|
||||
mnemonicParsing="false"
|
||||
onAction="#handleChangeAvailable"
|
||||
prefWidth="155.0"
|
||||
text="Veraltet-Status ändern"
|
||||
/>
|
||||
</HBox>
|
||||
</right>
|
||||
</BorderPane>
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.BorderPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<BorderPane xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="de.hitec.nhplus.medication.DeprecatedMedicationController"
|
||||
>
|
||||
<padding>
|
||||
<Insets top="8" left="8" right="8" bottom="8"/>
|
||||
</padding>
|
||||
<center>
|
||||
<TableView fx:id="tableView">
|
||||
<columns>
|
||||
<TableColumn
|
||||
fx:id="columnId"
|
||||
minWidth="40.0"
|
||||
text="ID"
|
||||
/>
|
||||
<TableColumn
|
||||
fx:id="columnName"
|
||||
minWidth="140.0"
|
||||
text="Name"
|
||||
/>
|
||||
<TableColumn
|
||||
fx:id="columnManufacturer"
|
||||
minWidth="140.0"
|
||||
text="Hersteller"
|
||||
/>
|
||||
<TableColumn
|
||||
fx:id="columnIngredient"
|
||||
minWidth="140.0"
|
||||
text="Inhaltsstoffe"
|
||||
/>
|
||||
<TableColumn
|
||||
fx:id="columnPossibleSideEffects"
|
||||
minWidth="200.0"
|
||||
text="Mögliche Nebenwirkungen"
|
||||
/>
|
||||
<TableColumn
|
||||
fx:id="columnAdministrationMethod"
|
||||
minWidth="180.0"
|
||||
text="Verabreichungsmethode"
|
||||
/>
|
||||
<TableColumn
|
||||
fx:id="columnCurrentStock"
|
||||
minWidth="100.0"
|
||||
text="Lagerbestand"
|
||||
/>
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
|
||||
</columnResizePolicy>
|
||||
</TableView>
|
||||
</center>
|
||||
<bottom>
|
||||
<BorderPane>
|
||||
<BorderPane.margin>
|
||||
<Insets top="8.0"/>
|
||||
</BorderPane.margin>
|
||||
<right>
|
||||
<HBox spacing="8.0">
|
||||
<Button
|
||||
fx:id="buttonChangeAvailable"
|
||||
mnemonicParsing="false"
|
||||
prefWidth="155.0"
|
||||
onAction="#handleChangeAvailable"
|
||||
text="Veraltet-Status ändern"
|
||||
/>
|
||||
</HBox>
|
||||
</right>
|
||||
</BorderPane>
|
||||
</bottom>
|
||||
</BorderPane>
|
|
@ -5,5 +5,6 @@ CREATE TABLE medication
|
|||
manufacturer TEXT NOT NULL,
|
||||
possibleSideEffects TEXT NOT NULL,
|
||||
administrationMethod TEXT NOT NULL,
|
||||
currentStock INTEGER NOT NULL
|
||||
currentStock INTEGER NOT NULL,
|
||||
isDeprecated BOOLEAN NOT NULL DEFAULT false
|
||||
)
|
|
@ -78,7 +78,6 @@
|
|||
onAction="#handleDelete"
|
||||
prefWidth="90.0"
|
||||
text="Löschen"
|
||||
|
||||
/>
|
||||
</HBox>
|
||||
</right>
|
||||
|
|
Loading…
Reference in a new issue