Commit 9644d718 authored by Janita Lillevik Røyseth's avatar Janita Lillevik Røyseth
Browse files

Code is documented. Cleaned up redundant fields and methods. Switched birthday...

Code is documented. Cleaned up redundant fields and methods. Switched birthday field in patientinfo to social security.
parent ded9bbad
Pipeline #133253 failed with stages
in 27 seconds
......@@ -7,7 +7,9 @@ import java.util.List;
/**
* Represents a patients careplan. Contains the specified type
* of care in the plan and list over the relevant tasks in the careplan.
* of care in the plan. Holds on list over the tasks associated with
* this type of care, and a list over journal entries associated with
* this type of care.
*
* @author gruppe 5
* @version 24.04.2021
......@@ -157,6 +159,13 @@ public class Careplan {
return this.tasks;
}
/**
* Returns a list over tasks in this careplan with the deadline of
* the given time of day.
*
* @param timeOfDay the time of day of the tasks to find.
* @return list over tasks in this careplan to be done at the specified time of day.
*/
public List<TodoTask> getTasksByTimeOfDay(String timeOfDay) {
List<TodoTask> tasksByTimeOfDay = new ArrayList<>();
for (TodoTask task : tasks) {
......@@ -167,10 +176,20 @@ public class Careplan {
return tasksByTimeOfDay;
}
/**
* Adds a journal entry to the journal.
*
* @param journalEntry the entry to be added to the journal.
*/
public void addJournalEntry(JournalEntry journalEntry) {
this.journal.add(journalEntry);
}
/**
* Returns the journal(list) that cointains the journal entries.
*
* @return journal(list) that contains the journal entries.
*/
public List<JournalEntry> getJournal() {
return this.journal;
}
......
......@@ -55,6 +55,7 @@ public class Contact {
/**
* Sets this contact persons phonenumber.
*
* @param phonenumber phonenumber to be set to this contact person.
*/
public void setPhonenumber(String phonenumber) {
......
package edu.ntnu.idata1002.prosjekt2021.model;
import java.time.Clock;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
......@@ -28,7 +27,6 @@ public class JournalEntry {
* @param usersName the name of the user who made the entry.
*/
public JournalEntry(String journalEntry, String usersName) {
//Clock clock = Clock.systemUTC();
this.entryTime = LocalDateTime.now();
this.journalEntry = journalEntry;
this.usersName = usersName;
......
package edu.ntnu.idata1002.prosjekt2021.model;
/**
* For implementing testdata.
* Class used for implementing the test data to the application.
*/
public class Model {
......
......@@ -12,23 +12,41 @@ import edu.ntnu.idata1002.prosjekt2021.exceptions.RemoveException;
* @version 23.04.2021
*/
public class Section {
/**
* The name of this section.
*/
private String sectionName;
/**
* List over postalcodes this section covers.
*/
private ArrayList<Integer> postalCode;
/**
* List over patients in this section.
*/
private ArrayList<Patient> patients;
/**
* List over nurses working in this section.
*/
private ArrayList<Nurse> nurses;
/**
* Creates a instance of a section.
* Creates a instance of Section.
*
* @param sectionName name of a section.
* @param sectionName name of the section.
*/
public Section(String sectionName){
if(sectionName == null){
sectionName = "";
}
if(sectionName.isBlank()){
throw new IllegalArgumentException("Section number cannot be empty or null");
}
this.sectionName = sectionName;
this.patients = new ArrayList<>();
this.nurses = new ArrayList<>();
......@@ -36,9 +54,9 @@ public class Section {
}
/**
* Returns section name.
* Returns this section name.
*
* @return section name.
* @return this section name.
*/
public String getSectionName() {
......@@ -46,9 +64,9 @@ public class Section {
}
/**
* Returns post numbers covered by a section.
* Returns postcodes covered by a section.
*
* @return post numbers covered by a section.
* @return postcodes covered by a section.
*/
public ArrayList<Integer> getPostalCode() {
return postalCode;
......@@ -57,16 +75,16 @@ public class Section {
/**
* Sets new section name.
*
* @param sectionName new section name.
* @param sectionName the new section name to be set.
*/
public void setSectionName(String sectionName) {
this.sectionName = sectionName;
}
/**
* Sets a list of new post numbers to a section.
* Sets a list of new postcodes to a section.
*
* @param postalCode new post numbers to a section.
* @param postalCode new postcode to a section.
*/
public void setPostalCode(ArrayList<Integer> postalCode) {
this.postalCode = postalCode;
......@@ -92,9 +110,9 @@ public class Section {
}
/**
* Adding a new nurse to a list of nurses.
* Adding a given nurse to a list of nurses.
*
* @param nurse a new nurse.
* @param nurse the nurse to be added to the list of nurses..
*/
public void addNurse(Nurse nurse) throws IllegalArgumentException{
if(nurse == null){
......@@ -135,26 +153,6 @@ public class Section {
}
}
/**
* Iterates over the list of paitents. Finds the patient with the given
* socialsecurity number and returns their careplan list. If no match is found, null
* is returned.
*
* @param socialSecurity the socialsecurity of the patient to look for their careplans.
* @return list of careplans to the mathching patient, null if no match is found.
*/
public List<Careplan> getPatientsCareplansBySocialSecurty(String socialSecurity) {
List<Careplan> patientsCareplans = null;
for(Patient patient : this.patients) {
if(patient.getSocialSecurityNumber().equals(socialSecurity)) {
patientsCareplans = patient.getCareplans();
}
}
return patientsCareplans;
}
/**
* Returns a list with all the patients.
*
......
......@@ -9,45 +9,48 @@ import edu.ntnu.idata1002.prosjekt2021.exceptions.RemoveException;
* @author gruppe 5
* @version 18.03.2021
*/
public class SectionList
{
public class SectionList {
/**
* List over sections in this sectiolist.
*/
private ArrayList<Section> sections;
public SectionList()
{
/**
* Creates a new instance of sectionlist.
*/
public SectionList() {
this.sections = new ArrayList();
}
/**
* Adds a new section to the section list.
*
* @param section
* @param section section to be added to the section list.
*/
public void addSection(Section section)
{
if(section == null){
public void addSection(Section section) {
if( section == null ){
throw new IllegalArgumentException("Sorry, the section cannot be null");
}
if(this.sections.contains(section)){
if (this.sections.contains( section )) {
throw new IllegalArgumentException("The section you are trying to add is already in the list");
}
else{
this.sections.add(section);
} else {
this.sections.add( section );
}
}
/**
* Removes a section from the section list.
*
* @param section
* @throws RemoveException
* @param section section to be removed from the section list.
* @throws RemoveException if the section did not get removed.
*/
public void removeSection(Section section) throws RemoveException {
if(sections.contains(section)){
this.sections.remove(section);
}
else{
throw new RemoveException("The section did not get removed");
if (sections.contains( section )) {
this.sections.remove( section );
} else {
throw new RemoveException( "The section did not get removed" );
}
}
......@@ -67,6 +70,7 @@ public class SectionList
sectionFound = section;
}
}
return sectionFound;
}
......@@ -75,8 +79,7 @@ public class SectionList
*
* @return a list with all the sections.
*/
public ArrayList<Section> getSections()
{
public ArrayList<Section> getSections() {
return this.sections;
}
}
......@@ -3,15 +3,22 @@ package edu.ntnu.idata1002.prosjekt2021.model;
import javafx.scene.control.CheckBox;
/**
* Represents a task. Holds a description, deadline by "time of day"
* and a boolean value for being finished.
* Represents a task. Holds a checkbox and a specified time of day for
* the tasks "deadline".
*
* @author gruppe5
* @version 24.04.2021
*/
public class TodoTask {
/**
* The checkbox belonging to this todotask.
*/
private CheckBox checkBox;
/**
* The time of the when this todotask should be done.
*/
private String timeOfDay;
/**
......@@ -25,27 +32,48 @@ public class TodoTask {
this.timeOfDay = timeOfDay;
}
/**
* Returns the checkbox this todotask holds on.
*
* @return checkbox this todotask holds on.
*/
public CheckBox getCheckbox() {
return this.checkBox;
}
/**
* Sets the description of the todotask.
*
* @param description description of the todotask to be set.
*/
public void setDescription(String description) {
this.checkBox.setText(description);
}
/**
* Returns the time of day when this todotask should be done.
*
* @return time of day when this todotask should be done.
*/
public String getTimeOfDay() {
return this.timeOfDay;
}
/**
* Sets the time of day when this todotask should be done.
*
* @param timeOfDay time of day this todotask should be done.
*/
public void setTimeOfDay(String timeOfDay) {
this.timeOfDay = timeOfDay;
}
/**
* Returns if this todotask is done or not.
*
* @return <code>true</code> if the todotask is done.
* <code>false</code> if the todotask is not done.
*/
public boolean isDone() {
return this.checkBox.isSelected();
}
......
......@@ -14,25 +14,31 @@ import edu.ntnu.idata1002.prosjekt2021.ui.views.Main;
import java.io.IOException;
/**
* Represents the controller for the login scene.
*
* @author gruppe5
* @version 28.04.2021
*/
public class LoginController {
/**
* Textfield for the username for logging in.
*/
@FXML
public TextField usernameField;
private TextField usernameField;
/**
* Passwordfield for logging in.
*/
@FXML
public PasswordField passwordField;
private PasswordField passwordField;
/**
* Displays errors with login.
*/
@FXML
public Label errorLabel;
private Label errorLabel;
/**
* Authenticates the user, if the user is authenticated the patientpage will display.
......@@ -42,9 +48,13 @@ public class LoginController {
private void login() {
for(Section section : Model.getInstanceOfSectionList().getSections()) {
for(Nurse nurse : section.getNurses()) {
//Authenticates
if(nurse.getUsername().equals(usernameField.getText()) &&
nurse.getPassword().equals(passwordField.getText())) {
//Hides the errorlabel.
errorLabel.setText("");
Parent root = null;
try {
FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().
......@@ -52,7 +62,7 @@ public class LoginController {
root = loader.load();
PatientPageController controller = loader.getController();
controller.setUserLabel(nurse.getFullName());
controller.setUserPic(nurse.getPicture());
controller.setUserPicture(nurse.getPicture());
Scene scene = new Scene(root);
scene.getStylesheets().add(getClass().getClassLoader().getResource("Stylesheets/application.css").toExternalForm());
Main.getStage().setScene(scene);
......
......@@ -10,9 +10,7 @@ import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
import java.io.IOException;
import java.text.Format;
import java.text.ParseException;
......@@ -55,7 +53,7 @@ public class PatientInfoController {
* Displays the patients birthdate.
*/
@FXML
private Label birthdate;
private Label socialSecurity;
/**
* Displays the patients address.
......@@ -113,24 +111,6 @@ public class PatientInfoController {
*/
private Image usersPicture;
/**
* Sets the patients name in the label for patientname.
*
* @param patientName the patient's name to be set.
*/
public void setPatientName(String patientName) {
this.patientName.setText(patientName);
}
/**
* Sets the patients image in the imageview;
*
* @param patientImage picture of the patient to be displayed.
*/
public void setPatientImage(Image patientImage) {
this.patientImage.setImage(patientImage);
}
/**
* Sets information about the patient in labels and
* text area to be displayed for the user.
......@@ -148,43 +128,20 @@ public class PatientInfoController {
this.emergencyContactPhonenumber.setText(patient.getEmergencyContact().getPhonenumber());
this.generalPractitionerName.setText(patient.getGeneralPractitioner().getFullName());
this.generalPractitionerPhonenumber.setText(patient.getGeneralPractitioner().getPhonenumber());
this.birthdate.setText(getBirthdateFromSocialSecurityNumber(patient));
this.socialSecurity.setText(patient.getSocialSecurityNumber());
this.summaryTextArea.setText(patient.getSummary());
this.additionalInformationTextArea.setText(patient.getAdditionalInformation());
this.diagnosisTextArea.setText(patient.getDiagnosis());
this.careplanLink.setOnMousePressed(mouseEvent -> carePlan(this.stage));
}
/**
* Formats the 6 first digits of the ssn number to a birthdate.
*
*Todo fix formatting.
*
* @param patient the patients whom's birthdate is to be set.
* @return patients birthdate.
*/
public String getBirthdateFromSocialSecurityNumber(Patient patient) {
String ssnSubstring = patient.getSocialSecurityNumber().substring(0, 5);
SimpleDateFormat dateFormat = new SimpleDateFormat("ddMMyy");
String birthdate = null;
try {
Date date = dateFormat.parse(ssnSubstring);
Format formatter = new SimpleDateFormat("dd.MM.yy");
birthdate = formatter.format(date);
} catch (ParseException e) {
}
return birthdate;
}
/**
* Loads the careplan. Closes the given stage.
*
* @param stage the stage to be closed when the careplan is opened.
*/
public void carePlan (Stage stage) {
@FXML
private void carePlan (Stage stage) {
stage.close();
Parent root = null;
try {
......@@ -192,7 +149,6 @@ public class PatientInfoController {
getResource("FXML scenes/CarePlan.fxml"));
root = loader.load();
CarePlanController controller = loader.getController();
controller.setPatient(patient);
controller.setPatientLabel(patient.getFullName());
controller.setUserPic(getUsersPicture());
controller.setUserLabel(getUsersName());
......@@ -222,7 +178,7 @@ public class PatientInfoController {
*
* @return this users full name.
*/
public String getUsersName() {
private String getUsersName() {
return this.usersName;
}
......@@ -240,7 +196,7 @@ public class PatientInfoController {
*
* @return profile picture of this user.
*/
public Image getUsersPicture() {
private Image getUsersPicture() {
return usersPicture;
}
......
......@@ -97,7 +97,7 @@ public class PatientPageController {
*
* @param image the users image.
*/
public void setUserPic(Image image) {
public void setUserPicture(Image image) {
userPic.setImage(image);
userPic.setFitHeight(75.0);
userPic.setFitWidth(75.0);
......@@ -113,7 +113,7 @@ public class PatientPageController {
*
* @return users profile picture.
*/
public Image getUserPic() {
private Image getUserPic() {
return this.userPic.getImage();
}
......@@ -131,7 +131,7 @@ public class PatientPageController {
*
* @return the users full name.
*/
public String getUserLabel() {
private String getUserLabel() {
return this.userLabel.getText();
}
......@@ -140,7 +140,7 @@ public class PatientPageController {
* scene with the loginpage-scene.
*/
@FXML
public void logout() {
private void logout() {
Parent root = null;
try {
root = FXMLLoader.load(getClass().getClassLoader().
......@@ -336,7 +336,6 @@ public class PatientPageController {
getResource("FXML scenes/CarePlan.fxml"));
root = loader.load();
CarePlanController controller = loader.getController();
controller.setPatient(patient);
controller.setPatientLabel(getPatientName(patient));
controller.setUserPic(getUserPic());
controller.setUserLabel(getUserLabel());
......@@ -385,7 +384,7 @@ public class PatientPageController {
* @param patient the patient who's name is to be found.
* @return the name of the patient
*/
public String getPatientName(Patient patient) {
private String getPatientName(Patient patient) {
boolean notFound = true;
String patientName = null;
......@@ -407,7 +406,7 @@ public class PatientPageController {
*