#24 WIP Medication
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 16:34:06 +02:00
parent 6ea6c4d0e6
commit 67b1093661
9 changed files with 16 additions and 17 deletions

Binary file not shown.

View file

@ -117,7 +117,7 @@ public class MedicationFixture implements Fixture<Medication> {
"Unterhautinjektion",
120
));
medications.add(new Medication(
Medication deprecatedMedication = new Medication(
"Levothyroxin",
"Sandoz",
List.of(
@ -129,7 +129,9 @@ public class MedicationFixture implements Fixture<Medication> {
"Herzrasen, Gewichtsverlust",
"Oral",
90
));
);
deprecatedMedication.setIsDeprecated(true);
medications.add(deprecatedMedication);
medications.add(new Medication(
"Warfarin",
"Apotex Inc.",

View file

@ -125,7 +125,7 @@ public class AllMedicationController {
@FXML
public void handleChangeAvailable() {
Medication selectedItem = tableView.getSelectionModel().getSelectedItem();
Medication selectedItem = this.tableView.getSelectionModel().getSelectedItem();
if (selectedItem == null) {
return;
}

View file

@ -38,9 +38,8 @@ public class DeprecatedMedicationController {
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
private MedicationDao dao;
@FXML
public void initialize() {
readAllAndShowInTableView();
this.readAllAndShowInTableView();
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
this.columnName.setCellValueFactory(new PropertyValueFactory<>("name"));
@ -71,9 +70,10 @@ public class DeprecatedMedicationController {
* 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(dao.readAllDeprecated());
this.medications.setAll(this.dao.readAllDeprecated());
} catch (SQLException exception) {
exception.printStackTrace();
}

View file

@ -61,7 +61,7 @@ public class Medication {
String possibleSideEffects,
String administrationMethod,
int currentStock,
boolean isDepreacted
boolean isDeprecated
) {
this.id = new SimpleIntegerProperty(id);
this.name = new SimpleStringProperty(name);
@ -70,7 +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);
this.isDeprecated = new SimpleBooleanProperty(isDeprecated);
}
public int getId() {

View file

@ -86,7 +86,6 @@ public class MedicationDao implements Dao<Medication> {
SELECT medication.*, medication_ingredient.name
FROM medication LEFT JOIN
medication_ingredient ON medication.id = medication_ingredient.id
WHERE medication.isDeprecated = false
""";
ResultSet result = connection.prepareStatement(SQL).executeQuery();
@ -133,8 +132,9 @@ public class MedicationDao implements Dao<Medication> {
final String SQL = """
SELECT medication.*, medication_ingredient.name
FROM medication LEFT JOIN
medication_ingredient ON medication.id = medication_ingredient.id
WHERE medication.isDeprecated = true
medication_ingredient
ON medication.id = medication_ingredient.id
AND medication.isDeprecated = true
""";
ResultSet result = connection.prepareStatement(SQL).executeQuery();
@ -195,8 +195,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(7, medication.isDeprecated());
preparedStatement.setBoolean(6, medication.isDeprecated());
preparedStatement.setInt(7, medication.getId());
preparedStatement.executeUpdate();
final String ingredientDeleteSQL = """

View file

@ -112,6 +112,4 @@ public class NurseDao extends DaoImp<Nurse> {
statement.setInt(1, id);
return statement;
}
}

View file

@ -6,5 +6,5 @@ CREATE TABLE medication
possibleSideEffects TEXT NOT NULL,
administrationMethod TEXT NOT NULL,
currentStock INTEGER NOT NULL,
isDeprecated BOOLEAN NOT NULL DEFAULT FALSE
isDeprecated BOOLEAN NOT NULL DEFAULT false
)

View file

@ -74,7 +74,6 @@
onAction="#handleDelete"
prefWidth="90.0"
text="Löschen"
/>
</HBox>
</right>