Commit 38a01ea5 authored by Janita Lillevik Røyseth's avatar Janita Lillevik Røyseth
Browse files

Added journals to the system.

parent ac966ce2
Pipeline #132413 failed with stages
in 53 seconds
......@@ -25,12 +25,18 @@ public class Careplan {
*/
private ArrayList<TodoTask> tasks;
/**
* List over journal entrys in this careplan.
*/
private ArrayList<JournalEntry> journal;
/**
* Creates an instance of careplan.
*/
public Careplan(String typeOfCare){
this.typeOfCare = typeOfCare;
tasks = new ArrayList<>();
journal = new ArrayList<>();
}
/**
......@@ -160,4 +166,12 @@ public class Careplan {
}
return tasksByTimeOfDay;
}
public void addJournalEntry(JournalEntry journalEntry) {
this.journal.add(journalEntry);
}
public List<JournalEntry> getJournal() {
return this.journal;
}
}
package edu.ntnu.idata1002.prosjekt2021.model;
import java.time.Clock;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class JournalEntry {
/**
* The date of when this journal entry was made.
*/
private final LocalDateTime entryTime;
/**
* The user who made the journal entry.
*/
private final String usersName;
/**
* The journal entry.
*/
private final String journalEntry;
/**
* Creates an instance of journal entry.
*
* @param journalEntry the text in the journal entry.
* @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;
}
/**
* Returns the time of the entry.
*
* @return time for when this jorunal entry was created.
*/
public String getEntryTime() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
String formatDateTime = entryTime.format(formatter);
return formatDateTime;
}
/**
* Returns the text in this jounral entry.
*
* @return text in thos journal entry.
*/
public String getJournalEntry() {
return this.journalEntry;
}
/**
* Returns the name of the user who made this journal entry.
*
* @return name of the user who made this journal entry.
*/
public String getUsersName() {
return this.usersName;
}
}
......@@ -4,6 +4,7 @@ import edu.ntnu.idata1002.prosjekt2021.model.*;
import edu.ntnu.idata1002.prosjekt2021.ui.views.*;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
......@@ -11,6 +12,8 @@ import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
import java.io.IOException;
......@@ -18,6 +21,15 @@ import java.util.*;
public class CarePlanController {
public TextArea nutritionJournalField;
public TextArea nutritionJournalList;
public TextArea hygieneJournalList;
public TextArea hygieneJournalField;
public TextArea socialJournalList;
public TextArea socialJournalField;
public TextArea medicationJournalList;
public TextArea medicationJournalField;
/**
* Constant values for how the lists are displayed.
*/
......@@ -343,6 +355,8 @@ public class CarePlanController {
this.patient = patient;
this.setObservableLists();
this.setCareplanTabPane();
this.updateJournalList();
this.setJournalField();
this.infoplanNutrition.getSelectionModel().select(1);
this.infoplanHygiene.getSelectionModel().select(1);
this.infoplanSocial.getSelectionModel().select(1);
......@@ -790,4 +804,85 @@ public class CarePlanController {
tab.selectedProperty().addListener(e -> findLastUsedButton().fire());
}
}
public void updateJournalList() {
this.nutritionJournalList.setFocusTraversable(false);
this.nutritionJournalList.setMouseTransparent(true);
this.hygieneJournalList.setFocusTraversable(false);
this.hygieneJournalList.setMouseTransparent(true);
this.socialJournalList.setFocusTraversable(false);
this.socialJournalList.setMouseTransparent(true);
this.medicationJournalList.setFocusTraversable(false);
this.medicationJournalList.setMouseTransparent(true);
String nutritionJournalListAsString = "";
for (JournalEntry entry : this.patient.findCareplanByTypeOfCare("Ernæring").getJournal()) {
nutritionJournalListAsString += entry.getEntryTime() +" \t" + entry.getUsersName() + " \n" + entry.getJournalEntry() + " \n";
}
this.nutritionJournalList.setText(nutritionJournalListAsString);
String hygieneJournalListAsString = "";
for (JournalEntry entry : this.patient.findCareplanByTypeOfCare("Personlig hygiene").getJournal()) {
hygieneJournalListAsString += entry.getEntryTime() +" \t" + entry.getUsersName() + " \n" + entry.getJournalEntry() + " \n";
}
this.hygieneJournalList.setText(hygieneJournalListAsString);
String socialJournalListAsString = "";
for (JournalEntry entry : this.patient.findCareplanByTypeOfCare("Sosial og aktivitet").getJournal()) {
socialJournalListAsString += entry.getEntryTime() +" \t" + entry.getUsersName() + " \n" + entry.getJournalEntry() + " \n";
}
this.socialJournalList.setText(socialJournalListAsString);
String medicationJournalListAsString = "";
for (JournalEntry entry : this.patient.findCareplanByTypeOfCare("Legemidler").getJournal()) {
medicationJournalListAsString += entry.getEntryTime() +" \t" + entry.getUsersName() + " \n" + entry.getJournalEntry() + " \n";
}
this.medicationJournalList.setText(medicationJournalListAsString);
}
public void setJournalField() {
this.nutritionJournalField.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent key) {
if (key.getCode().equals(KeyCode.ENTER)) {
patient.findCareplanByTypeOfCare("Ernæring").addJournalEntry(new JournalEntry(nutritionJournalField.getText(), getUsersFullName()));
nutritionJournalField.setText("");
updateJournalList();
}
}
});
this.hygieneJournalField.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent key) {
if (key.getCode().equals(KeyCode.ENTER)) {
patient.findCareplanByTypeOfCare("Personlig hygiene").addJournalEntry(new JournalEntry(hygieneJournalField.getText(), getUsersFullName()));
hygieneJournalField.setText("");
updateJournalList();
}
}
});
this.socialJournalField.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent key) {
if (key.getCode().equals(KeyCode.ENTER)) {
patient.findCareplanByTypeOfCare("Sosial og aktivitet").addJournalEntry(new JournalEntry(socialJournalField.getText(), getUsersFullName()));
socialJournalField.setText("");
updateJournalList();
}
}
});
this.medicationJournalField.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent key) {
if (key.getCode().equals(KeyCode.ENTER)) {
patient.findCareplanByTypeOfCare("Legemidler").addJournalEntry(new JournalEntry(medicationJournalField.getText(), getUsersFullName()));
medicationJournalField.setText("");
updateJournalList();
}
}
});
}
}
......@@ -41,6 +41,7 @@
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.ToolBar?>
<?import javafx.scene.image.Image?>
......@@ -286,7 +287,18 @@
<tabs>
<Tab text="Journal">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<VBox layoutX="246.0" layoutY="51.0" prefHeight="200.0" prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets bottom="50.0" left="10.0" right="10.0" top="10.0" />
</padding>
<children>
<TextArea fx:id="nutritionJournalList" editable="false" nodeOrientation="LEFT_TO_RIGHT" prefHeight="306.0" prefWidth="392.0" wrapText="true" />
<TextArea fx:id="nutritionJournalField" nodeOrientation="LEFT_TO_RIGHT" prefHeight="200.0" prefWidth="200.0" promptText="Kommentar" wrapText="true" />
</children>
</VBox>
</children></AnchorPane>
</content>
</Tab>
<Tab text="Info">
......@@ -367,7 +379,18 @@
<tabs>
<Tab text="Journal">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<VBox prefHeight="200.0" prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets bottom="50.0" left="10.0" right="10.0" top="10.0" />
</padding>
<children>
<TextArea fx:id="hygieneJournalList" editable="false" nodeOrientation="LEFT_TO_RIGHT" prefHeight="306.0" prefWidth="392.0" wrapText="true" />
<TextArea fx:id="hygieneJournalField" nodeOrientation="LEFT_TO_RIGHT" prefHeight="200.0" prefWidth="200.0" promptText="Kommentar" wrapText="true" />
</children>
</VBox>
</children></AnchorPane>
</content>
</Tab>
<Tab text="Info">
......@@ -447,7 +470,18 @@
<tabs>
<Tab text="Journal">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<VBox prefHeight="200.0" prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets bottom="50.0" left="10.0" right="10.0" top="10.0" />
</padding>
<children>
<TextArea fx:id="socialJournalList" editable="false" nodeOrientation="LEFT_TO_RIGHT" prefHeight="306.0" prefWidth="392.0" wrapText="true" />
<TextArea fx:id="socialJournalField" nodeOrientation="LEFT_TO_RIGHT" prefHeight="200.0" prefWidth="200.0" promptText="Kommentar" wrapText="true" />
</children>
</VBox>
</children></AnchorPane>
</content>
</Tab>
<Tab text="Info">
......@@ -509,7 +543,18 @@
<tabs>
<Tab text="Journal">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<VBox prefHeight="200.0" prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets bottom="50.0" left="10.0" right="10.0" top="10.0" />
</padding>
<children>
<TextArea fx:id="medicationJournalList" editable="false" nodeOrientation="LEFT_TO_RIGHT" prefHeight="306.0" prefWidth="392.0" wrapText="true" />
<TextArea fx:id="medicationJournalField" nodeOrientation="LEFT_TO_RIGHT" prefHeight="200.0" prefWidth="200.0" promptText="Kommentar" wrapText="true" />
</children>
</VBox>
</children></AnchorPane>
</content>
</Tab>
<Tab text="Info">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment