implemented design
This commit is contained in:
parent
b3daa4a45e
commit
4af661e44d
@ -1,4 +1,55 @@
|
||||
package at.ionas999.health.controller;
|
||||
|
||||
public class MedicalPracticeController {
|
||||
import at.ionas999.health.model.WaitingRoom;
|
||||
import at.ionas999.observer.ChangeObserver;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.text.Text;
|
||||
|
||||
public class MedicalPracticeController implements ChangeObserver<WaitingRoom> {
|
||||
public DatePicker date;
|
||||
public TextField time;
|
||||
public CheckBox emergency;
|
||||
public Text patientsLeft;
|
||||
public Text treatment;
|
||||
public Text preparation;
|
||||
public Button addPatientButton;
|
||||
public TextField name;
|
||||
public TextArea waitingRoomTextField;
|
||||
public Button nextPatientButton;
|
||||
|
||||
private WaitingRoom waitingRoom;
|
||||
|
||||
public MedicalPracticeController()
|
||||
{
|
||||
this.waitingRoom = new WaitingRoom();
|
||||
this.waitingRoom.addObserver(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(WaitingRoom subject) {
|
||||
if(this.waitingRoomTextField == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
waitingRoomTextField.setText(waitingRoom.getPatients().stream()
|
||||
.reduce("", (s, p) -> s + p + "\n", String::concat));
|
||||
preparation.setText(waitingRoom.getPatientInPreparation() == null ? "" : waitingRoom.getPatientInPreparation().toString());
|
||||
treatment.setText(waitingRoom.getPatientUndergoingTreatment() == null ? "" : waitingRoom.getPatientUndergoingTreatment().toString());
|
||||
patientsLeft.setText(String.valueOf(waitingRoom.getPatientCount()));
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void addPatient() {
|
||||
waitingRoom.addPatient(name.getText(),
|
||||
date.getValue().atTime(Integer.parseInt(time.getText().split(":")[0]),
|
||||
Integer.parseInt(time.getText().split(":")[1])),
|
||||
emergency.isSelected());
|
||||
}
|
||||
|
||||
public void nextPatient(ActionEvent actionEvent) {
|
||||
waitingRoom.treatNextPatient();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import at.ionas999.observer.ChangeObserver;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
@ -29,6 +30,10 @@ public class WaitingRoom {
|
||||
observer.update(this);
|
||||
}
|
||||
|
||||
public Collection<Patient> getPatients() {
|
||||
return patients.stream().toList();
|
||||
}
|
||||
|
||||
public void removeObserver(ChangeObserver<WaitingRoom> observer) {
|
||||
observers.remove(observer);
|
||||
}
|
||||
|
||||
@ -2,6 +2,99 @@
|
||||
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
<?import javafx.scene.control.TextArea?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.control.DatePicker?>
|
||||
<?import javafx.scene.control.CheckBox?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<VBox alignment="CENTER" spacing="10.0" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="at.ionas999.health.controller.MedicalPracticeController">
|
||||
|
||||
<HBox alignment="TOP_CENTER">
|
||||
<Text text="+ Medical Practice +" style="-fx-font-size: 24px; -fx-fill: red;"/>
|
||||
</HBox>
|
||||
<HBox>
|
||||
<VBox style="-fx-padding: 30 10 30 30" minWidth="300">
|
||||
<HBox alignment="CENTER">
|
||||
<Text text="Waiting Room" style="-fx-font-size: 16px"/>
|
||||
</HBox>
|
||||
<HBox>
|
||||
<TextArea editable="false" fx:id="waitingRoomTextField"/>
|
||||
</HBox>
|
||||
</VBox>
|
||||
<VBox style="-fx-padding: 30 10 30 30" minWidth="300" spacing="10">
|
||||
<HBox alignment="CENTER">
|
||||
<Text text="Patient Check-In" style="-fx-font-size: 16px"/>
|
||||
</HBox>
|
||||
<HBox>
|
||||
<VBox spacing="8">
|
||||
<HBox alignment="CENTER_LEFT" minHeight="30" maxHeight="30" style="-fx-padding: 5 5 5 5">
|
||||
<Text>Name:</Text>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER_LEFT" minHeight="30" maxHeight="30" style="-fx-padding: 5 5 5 5">
|
||||
<Text>Date:</Text>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER_LEFT" minHeight="30" maxHeight="30" style="-fx-padding: 5 5 5 5">
|
||||
<Text>Time:</Text>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER_LEFT" minHeight="30" maxHeight="30" style="-fx-padding: 5 5 5 5">
|
||||
<Text>Emergency:</Text>
|
||||
</HBox>
|
||||
</VBox>
|
||||
<VBox spacing="9">
|
||||
<HBox alignment="CENTER" minHeight="30" maxHeight="30" style="-fx-padding: 5 5 5 5;">
|
||||
<TextField fx:id="name" minWidth="150" maxWidth="150"/>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER" minHeight="30" maxHeight="30" style="-fx-padding: 5 5 5 5">
|
||||
<DatePicker fx:id="date" minWidth="150" maxWidth="150"/>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER" minHeight="30" maxHeight="30" style="-fx-padding: 5 5 5 5">
|
||||
<TextField fx:id="time" minWidth="150" maxWidth="150"/>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER" minHeight="30" maxHeight="30" style="-fx-padding: 5 5 5 5">
|
||||
<CheckBox fx:id="emergency"/>
|
||||
</HBox>
|
||||
</VBox>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER">
|
||||
<Button fx:id="addPatientButton" text="Add Patient" onAction="#addPatient"/>
|
||||
</HBox>
|
||||
</VBox>
|
||||
</HBox>
|
||||
<HBox spacing="5" alignment="CENTER">
|
||||
<VBox spacing="7">
|
||||
<HBox alignment="CENTER_RIGHT">
|
||||
<Text>In Preperation:</Text>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER_RIGHT">
|
||||
<Text>Undergoing Treatment:</Text>
|
||||
|
||||
</HBox>
|
||||
<HBox alignment="CENTER_RIGHT">
|
||||
<Text>Patients Left:</Text>
|
||||
|
||||
</HBox>
|
||||
</VBox>
|
||||
<VBox spacing="7">
|
||||
<HBox alignment="CENTER_LEFT">
|
||||
<Text fx:id="preparation"/>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER_LEFT">
|
||||
<Text fx:id="treatment"/>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER_LEFT">
|
||||
|
||||
<Text fx:id="patientsLeft" text="0"/>
|
||||
</HBox>
|
||||
</VBox>
|
||||
|
||||
|
||||
</HBox>
|
||||
<HBox alignment="CENTER">
|
||||
<Button fx:id="nextPatientButton" text="Next Please!" onAction="#nextPatient"/>
|
||||
</HBox>
|
||||
|
||||
</VBox>
|
||||
Loading…
Reference in New Issue
Block a user