#24 UI Veraltete Medikamenten addiert
Some checks failed
Quality Check / Linting Check (push) Failing after 12s
Quality Check / Javadoc Check (push) Successful in 21s

This commit is contained in:
Dorian Nemec 2024-05-20 09:29:17 +02:00
parent c7ed5f5100
commit b85022aa49
6 changed files with 212 additions and 7 deletions

View file

@ -48,6 +48,12 @@ public class MainWindowController {
private AnchorPane medicationPage;
@FXML
private Tab medicationTab;
@FXML
private TabPane medicationTabPane;
@FXML
private AnchorPane deprecatedMedicationPage;
@FXML
private Tab deprecatedMedicationTab;
/**
@ -63,11 +69,13 @@ public class MainWindowController {
nurseTab.setOnSelectionChanged(event -> loadNursePage());
medicationTab.setOnSelectionChanged(event -> loadMedicationPage());
nurseTabPane.getSelectionModel().select(activeNurseTab);
activeNurseTab.setOnSelectionChanged(event -> loadActiveNursePage());
lockedNurseTab.setOnSelectionChanged(event -> loadLockedNursePage());
medicationTab.setOnSelectionChanged(event -> loadMedicationPage());
deprecatedMedicationTab.setOnSelectionChanged(event -> loadDeprecatedMedicationPage());
nurseTabPane.getSelectionModel().select(activeNurseTab);
medicationTabPane.getSelectionModel().select(medicationTab);
}
/**
@ -173,4 +181,19 @@ public class MainWindowController {
exception.printStackTrace();
}
}
private void loadDeprecatedMedicationPage(){
try {
BorderPane deprecatedMedicationPane = FXMLLoader.load(
Objects.requireNonNull(Main.class.getResource("/de/hitec/nhplus/medication/DeprecatedMedicationView.fxml"))
);
deprecatedMedicationPage.getChildren().setAll(deprecatedMedicationPane);
AnchorPane.setTopAnchor(deprecatedMedicationPane, 0d);
AnchorPane.setBottomAnchor(deprecatedMedicationPane, 0d);
AnchorPane.setLeftAnchor(deprecatedMedicationPane, 0d);
AnchorPane.setRightAnchor(deprecatedMedicationPane, 0d);
} catch (IOException exception) {
exception.printStackTrace();
}
}
}

View file

@ -0,0 +1,79 @@
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.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;
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;
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
private MedicationDao dao;
@FXML
public void initialize() {
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.dao = DaoFactory.getInstance().createMedicationDAO();
try {
this.medications.setAll(dao.readAll());
} catch (SQLException exception) {
exception.printStackTrace();
}
}
}

View file

@ -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;
@ -23,6 +24,7 @@ public class Medication {
private final SimpleStringProperty possibleSideEffects;
private final SimpleStringProperty administrationMethod;
private final SimpleIntegerProperty currentStock;
private final SimpleBooleanProperty isDeprecated;
/**
* This constructor allows instantiating a {@link Medication} object,
@ -45,6 +47,7 @@ public class Medication {
this.possibleSideEffects = new SimpleStringProperty(possibleSideEffects);
this.administrationMethod = new SimpleStringProperty(administrationMethod);
this.currentStock = new SimpleIntegerProperty(currentStock);
this.isDeprecated = new SimpleBooleanProperty(false);
}
/**
@ -57,7 +60,8 @@ public class Medication {
List<Ingredient> ingredients,
String possibleSideEffects,
String administrationMethod,
int currentStock
int currentStock,
boolean isDepreacted
) {
this.id = new SimpleIntegerProperty(id);
this.name = new SimpleStringProperty(name);
@ -66,6 +70,7 @@ public class Medication {
this.possibleSideEffects = new SimpleStringProperty(possibleSideEffects);
this.administrationMethod = new SimpleStringProperty(administrationMethod);
this.currentStock = new SimpleIntegerProperty(currentStock);
this.isDeprecated = new SimpleBooleanProperty(isDepreacted);
}
public int getId() {
@ -84,6 +89,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);
}

View file

@ -103,7 +103,8 @@ public class MedicationDao implements Dao<Medication> {
new ArrayList<>(),
result.getString(4),
result.getString(5),
result.getInt(6)
result.getInt(6),
result.getBoolean(7)
);
medications.add(medication);
}
@ -191,7 +192,8 @@ public class MedicationDao implements Dao<Medication> {
List.of(),
result.getString(4),
result.getString(5),
result.getInt(6)
result.getInt(6),
result.getBoolean(7)
);
List<Ingredient> ingredients = new ArrayList<>();

View file

@ -26,6 +26,13 @@
</TabPane>
</Tab>
<Tab fx:id="medicationTab" text="Medikamente">
<TabPane fx:id="medicationTabPane" tabClosingPolicy="UNAVAILABLE">
<Tab fx:id="allMedicationTab" text="Medikamente">
<AnchorPane fx:id="medicationPage"/>
</Tab>
<Tab fx:id="deprecatedMedicationTab" text="Veraltete Medikamente">
<AnchorPane fx:id="deprecatedMedicationPage"/>
</Tab>
</TabPane>
</Tab>
</TabPane>

View file

@ -0,0 +1,77 @@
<?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="buttonDelete"
mnemonicParsing="false"
prefWidth="90.0"
text="Löschen"
/>
-->
</HBox>
</right>
</BorderPane>
</bottom>
</BorderPane>