From 60b3d587ea1b8406af5a6ddc2ab40bcc43335bec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20S=C3=A4ume?= Date: Sat, 4 May 2024 09:11:37 +0200 Subject: [PATCH] #22: Setup Medication Model MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Dominik Säume --- .../hitec/nhplus/medication/Medication.java | 149 ++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 src/main/java/de/hitec/nhplus/medication/Medication.java diff --git a/src/main/java/de/hitec/nhplus/medication/Medication.java b/src/main/java/de/hitec/nhplus/medication/Medication.java new file mode 100644 index 0000000..8ad6f9e --- /dev/null +++ b/src/main/java/de/hitec/nhplus/medication/Medication.java @@ -0,0 +1,149 @@ +package de.hitec.nhplus.medication; + +import javafx.beans.property.SimpleIntegerProperty; +import javafx.beans.property.SimpleListProperty; +import javafx.beans.property.SimpleStringProperty; +import javafx.collections.ObservableList; + +import java.util.StringJoiner; +import java.util.stream.Collectors; + +public class Medication { + private SimpleIntegerProperty id; + private final SimpleStringProperty name; + private final SimpleStringProperty manufacturer; + private final SimpleListProperty ingredients; + private final SimpleStringProperty possibleSideEffects; + private final SimpleStringProperty administrationMethod; + private final SimpleIntegerProperty currentStock; + + public Medication( + String name, + String manufacturer, + ObservableList ingredients, + String possibleSideEffects, + String administrationMethod, + int currentStock + ) { + this.name = new SimpleStringProperty(name); + this.manufacturer = new SimpleStringProperty(manufacturer); + this.ingredients = new SimpleListProperty<>(ingredients); + this.possibleSideEffects = new SimpleStringProperty(possibleSideEffects); + this.administrationMethod = new SimpleStringProperty(administrationMethod); + this.currentStock = new SimpleIntegerProperty(currentStock); + } + + public Medication( + int id, + String name, + String manufacturer, + ObservableList ingredients, + String possibleSideEffects, + String administrationMethod, + int currentStock + ) { + this.id = new SimpleIntegerProperty(id); + this.name = new SimpleStringProperty(name); + this.manufacturer = new SimpleStringProperty(manufacturer); + this.ingredients = new SimpleListProperty<>(ingredients); + this.possibleSideEffects = new SimpleStringProperty(possibleSideEffects); + this.administrationMethod = new SimpleStringProperty(administrationMethod); + this.currentStock = new SimpleIntegerProperty(currentStock); + } + + public int getId() { + return id.get(); + } + + public SimpleIntegerProperty idProperty() { + return id; + } + + public String getName() { + return name.get(); + } + + public SimpleStringProperty nameProperty() { + return name; + } + + public void setName(String name) { + this.name.set(name); + } + + public String getManufacturer() { + return manufacturer.get(); + } + + public SimpleStringProperty manufacturerProperty() { + return manufacturer; + } + + public void setManufacturer(String manufacturer) { + this.manufacturer.set(manufacturer); + } + + public ObservableList getIngredients() { + return ingredients.get(); + } + + public SimpleListProperty ingredientsProperty() { + return ingredients; + } + + public void setIngredients(ObservableList ingredients) { + this.ingredients.set(ingredients); + } + + public String getPossibleSideEffects() { + return possibleSideEffects.get(); + } + + public SimpleStringProperty possibleSideEffectsProperty() { + return possibleSideEffects; + } + + public void setPossibleSideEffects(String possibleSideEffects) { + this.possibleSideEffects.set(possibleSideEffects); + } + + public String getAdministrationMethod() { + return administrationMethod.get(); + } + + public SimpleStringProperty administrationMethodProperty() { + return administrationMethod; + } + + public void setAdministrationMethod(String administrationMethod) { + this.administrationMethod.set(administrationMethod); + } + + public int getCurrentStock() { + return currentStock.get(); + } + + public SimpleIntegerProperty currentStockProperty() { + return currentStock; + } + + public void setCurrentStock(int currentStock) { + this.currentStock.set(currentStock); + } + + @Override + public String toString() { + return new StringJoiner(System.lineSeparator()) + .add("MEDICATION") + .add("ID: " + this.getId()) + .add("Name: " + this.getName()) + .add("Manufacturer: " + this.getManufacturer()) + .add("Ingredients: " + this.getIngredients() + .stream() + .collect(Collectors.joining(", ", "[", "]"))) + .add("Possible Side Effects: " + this.getPossibleSideEffects()) + .add("Administration Method: " + this.getAdministrationMethod()) + .add("Current Stock: " + this.getCurrentStock()) + .toString(); + } +}