added it in the patient waiting room
This commit is contained in:
parent
6bd8fda834
commit
2ebd9b7abb
15
.idea/dataSources.xml
generated
Normal file
15
.idea/dataSources.xml
generated
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||||
|
<data-source source="LOCAL" name="DerbyDb" uuid="031a850b-594c-421e-abe6-800a47ea61ed">
|
||||||
|
<driver-ref>derby.embedded</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>org.apache.derby.jdbc.EmbeddedDriver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:derby:DerbyDb</jdbc-url>
|
||||||
|
<jdbc-additional-properties>
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||||
|
</jdbc-additional-properties>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
7
.idea/sqldialects.xml
generated
Normal file
7
.idea/sqldialects.xml
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="SqlDialectMappings">
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/at/ionas999/health/services/DatabaseUtilsBase.java" dialect="GenericSQL" />
|
||||||
|
<file url="PROJECT" dialect="Derby" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@ -1,6 +1,6 @@
|
|||||||
package at.ionas999.health.controller;
|
package at.ionas999.health.controller;
|
||||||
|
|
||||||
import at.ionas999.health.model.WaitingRoom;
|
import at.ionas999.health.repositories.WaitingRoom;
|
||||||
import at.ionas999.observer.ChangeObserver;
|
import at.ionas999.observer.ChangeObserver;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package at.ionas999.health.model;
|
package at.ionas999.health.repositories;
|
||||||
|
|
||||||
|
import at.ionas999.health.model.Patient;
|
||||||
|
import at.ionas999.health.services.PatientService;
|
||||||
import at.ionas999.observer.ChangeObserver;
|
import at.ionas999.observer.ChangeObserver;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -9,6 +11,8 @@ import java.util.List;
|
|||||||
import java.util.PriorityQueue;
|
import java.util.PriorityQueue;
|
||||||
|
|
||||||
public class WaitingRoom {
|
public class WaitingRoom {
|
||||||
|
|
||||||
|
private PatientService patientService;
|
||||||
private final List<ChangeObserver<WaitingRoom>> observers = new ArrayList<>();
|
private final List<ChangeObserver<WaitingRoom>> observers = new ArrayList<>();
|
||||||
private final PriorityQueue<Patient> patients = new PriorityQueue<>();
|
private final PriorityQueue<Patient> patients = new PriorityQueue<>();
|
||||||
private Patient patientUndergoingTreatment = null;
|
private Patient patientUndergoingTreatment = null;
|
||||||
@ -25,11 +29,6 @@ public class WaitingRoom {
|
|||||||
return this.patientUndergoingTreatment;
|
return this.patientUndergoingTreatment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addObserver(ChangeObserver<WaitingRoom> observer) {
|
|
||||||
observers.add(observer);
|
|
||||||
observer.update(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<Patient> getPatients() {
|
public Collection<Patient> getPatients() {
|
||||||
return patients.stream().toList();
|
return patients.stream().toList();
|
||||||
}
|
}
|
||||||
@ -38,14 +37,32 @@ public class WaitingRoom {
|
|||||||
observers.remove(observer);
|
observers.remove(observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WaitingRoom()
|
||||||
|
{
|
||||||
|
patientService = new PatientService();
|
||||||
|
|
||||||
|
this.patients.addAll(this.patientService.GetAllPatients());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addObserver(ChangeObserver<WaitingRoom> observer) {
|
||||||
|
observers.add(observer);
|
||||||
|
observer.update(this);
|
||||||
|
}
|
||||||
|
|
||||||
public void addPatient(String name, LocalDateTime appointment, boolean isEmergency) {
|
public void addPatient(String name, LocalDateTime appointment, boolean isEmergency) {
|
||||||
Patient patient = new Patient(name, appointment, isEmergency);
|
Patient patient = new Patient(name, appointment, isEmergency);
|
||||||
patients.add(patient);
|
patients.add(patient);
|
||||||
|
patientService.AddPatient(patient);
|
||||||
notifyObservers();
|
notifyObservers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void treatNextPatient() {
|
public void treatNextPatient() {
|
||||||
this.patientUndergoingTreatment = patients.poll();
|
this.patientUndergoingTreatment = patients.poll();
|
||||||
|
if(this.patientUndergoingTreatment != null)
|
||||||
|
{
|
||||||
|
this.patientService.DeletePatient(this.patientUndergoingTreatment.getName());
|
||||||
|
}
|
||||||
notifyObservers();
|
notifyObservers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,8 +15,8 @@ public class PatientService extends DatabaseUtilsBase implements TableCreation {
|
|||||||
public void CreateTable(Connection connection) throws SQLException {
|
public void CreateTable(Connection connection) throws SQLException {
|
||||||
String createTableSmt = "CREATE TABLE Patient (\n" +
|
String createTableSmt = "CREATE TABLE Patient (\n" +
|
||||||
" name VARCHAR(255) NOT NULL PRIMARY KEY,\n" +
|
" name VARCHAR(255) NOT NULL PRIMARY KEY,\n" +
|
||||||
" appointment TIMESTAMP NOT NULL,\n" +
|
" appointment TIMESTAMP,\n" +
|
||||||
" isEmergency BOOLEAN NOT NULL\n" +
|
" isEmergency BOOLEAN\n" +
|
||||||
");";
|
");";
|
||||||
connection.createStatement().executeQuery(createTableSmt);
|
connection.createStatement().executeQuery(createTableSmt);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package at.ionas999.health.model;
|
package at.ionas999.health.model;
|
||||||
|
|
||||||
|
|
||||||
|
import at.ionas999.health.repositories.WaitingRoom;
|
||||||
import at.ionas999.observer.ChangeObserver;
|
import at.ionas999.observer.ChangeObserver;
|
||||||
|
|
||||||
public class UpdateObserver implements ChangeObserver<WaitingRoom> {
|
public class UpdateObserver implements ChangeObserver<WaitingRoom> {
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package at.ionas999.health.model;
|
package at.ionas999.health.model;
|
||||||
|
|
||||||
|
import at.ionas999.health.repositories.WaitingRoom;
|
||||||
import at.ionas999.observer.ChangeObserver;
|
import at.ionas999.observer.ChangeObserver;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user