Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Olav Dagestad Eikrem
Mappe2.01
Commits
c7bc7367
Commit
c7bc7367
authored
May 04, 2021
by
Olav Dagestad Eikrem
Browse files
Pasient (Patient) class and test class added
parent
1d3d5a42
Changes
18
Hide whitespace changes
Inline
Side-by-side
src/main/java/mappe/del2/hospital/Pasient.java
0 → 100644
View file @
c7bc7367
package
mappe.del2.hospital
;
import
java.util.Objects
;
public
class
Pasient
{
private
String
firstName
;
private
String
lastName
;
private
String
socialSecurityNumber
;
private
String
diagnosis
;
private
String
generalPractitioner
;
public
Pasient
(
String
firstName
,
String
lastName
,
String
generalPractitioner
,
String
socialSecurityNumber
)
throws
Exception
{
if
(
socialSecurityNumber
.
length
()
!=
11
||
socialSecurityNumber
.
contains
(
"[a-zA-Z]"
))
{
throw
new
Exception
(
"SSN error"
);
}
else
{
this
.
firstName
=
firstName
;
this
.
lastName
=
lastName
;
this
.
generalPractitioner
=
generalPractitioner
;
this
.
socialSecurityNumber
=
socialSecurityNumber
;
diagnosis
=
""
;
}
}
public
String
getFirstName
()
{
return
firstName
;
}
public
void
setFirstName
(
String
firstName
)
{
this
.
firstName
=
firstName
;
}
public
String
getLastName
()
{
return
lastName
;
}
public
void
setLastName
(
String
lastName
)
{
this
.
lastName
=
lastName
;
}
public
String
getSocialSecurityNumber
()
{
return
socialSecurityNumber
;
}
public
void
setSocialSecurityNumber
(
String
socialSecurityNumber
)
{
this
.
socialSecurityNumber
=
socialSecurityNumber
;
}
public
String
getDiagnosis
()
{
return
diagnosis
;
}
public
void
setDiagnosis
(
String
diagnosis
)
{
this
.
diagnosis
=
diagnosis
;
}
public
String
getGeneralPractitioner
()
{
return
generalPractitioner
;
}
public
void
setGeneralPractitioner
(
String
generalPractitioner
)
{
this
.
generalPractitioner
=
generalPractitioner
;
}
@Override
public
String
toString
()
{
return
"Pasient{"
+
"firstName='"
+
firstName
+
'\''
+
", lastName='"
+
lastName
+
'\''
+
", socialSecurityNumber='"
+
socialSecurityNumber
+
'\''
+
", diagnosis='"
+
diagnosis
+
'\''
+
", generalPractitioner='"
+
generalPractitioner
+
'\''
+
'}'
;
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
Pasient
pasient
=
(
Pasient
)
o
;
return
socialSecurityNumber
.
equals
(
pasient
.
socialSecurityNumber
);
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
socialSecurityNumber
);
}
}
src/test/java/mappe/del2/hospital/PasientTest.java
0 → 100644
View file @
c7bc7367
package
mappe.del2.hospital
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.Test
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
class
PasientTest
{
@Test
@DisplayName
(
"Test pasient creation"
)
void
pasientCreationTests
()
throws
Exception
{
Pasient
p
=
new
Pasient
(
"Test"
,
"Patient"
,
"Doctor who"
,
"12345678910"
);
assertEquals
(
"Test"
,
p
.
getFirstName
());
assertEquals
(
"Patient"
,
p
.
getLastName
());
assertEquals
(
"Doctor who"
,
p
.
getGeneralPractitioner
());
assertEquals
(
"12345678910"
,
p
.
getSocialSecurityNumber
());
assertEquals
(
""
,
p
.
getDiagnosis
());
}
@Test
@DisplayName
(
"Exeption thrown if SSN shorter than 11 characters"
)
void
pasientCreationTestFailSsnToShort
(){
Exception
e
=
assertThrows
(
Exception
.
class
,
()
->{
new
Pasient
(
"Test"
,
"Patient"
,
"Doctor who"
,
"1234567891"
);
});
String
expected
=
"SSN error"
;
String
actual
=
e
.
getMessage
();
assertTrue
(
actual
.
contains
(
expected
));
}
@Test
@DisplayName
(
"Exeption thrown if SSN longer than 11 characters"
)
void
pasientCreationTestFailSsnToLong
(){
Exception
e
=
assertThrows
(
Exception
.
class
,
()
->{
new
Pasient
(
"Test"
,
"Patient"
,
"Doctor who"
,
"123456789101"
);
});
String
expected
=
"SSN error"
;
String
actual
=
e
.
getMessage
();
assertTrue
(
actual
.
contains
(
expected
));
}
@Test
@DisplayName
(
"Exeption thrown if SSN contains only letters"
)
void
pasientCreationTestFailSsnContainsOnlyLetters
(){
Exception
e
=
assertThrows
(
Exception
.
class
,
()
->{
new
Pasient
(
"Test"
,
"Patient"
,
"Doctor who"
,
"abcdefghijk"
);
});
String
expected
=
"SSN error"
;
String
actual
=
e
.
getMessage
();
assertTrue
(
actual
.
contains
(
expected
));
}
@Test
@DisplayName
(
"Exeption thrown if SSN contains one letter"
)
void
pasientCreationTestFailSsnContainsOneLetter
(){
Exception
e
=
assertThrows
(
Exception
.
class
,
()
->{
new
Pasient
(
"Test"
,
"Patient"
,
"Doctor who"
,
"1234567891a"
);
});
String
expected
=
"SSN error"
;
String
actual
=
e
.
getMessage
();
assertTrue
(
actual
.
contains
(
expected
));
}
}
\ No newline at end of file
target/classes/DeleteConfirmation.fxml
0 → 100644
View file @
c7bc7367
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<AnchorPane
prefHeight=
"200.0"
prefWidth=
"350.0"
xmlns=
"http://javafx.com/javafx/11.0.1"
xmlns:fx=
"http://javafx.com/fxml/1"
fx:controller=
"mappe.del2.GUI.controllers.DeleteConfirmationController"
>
<children>
<Button
layoutX=
"142.0"
layoutY=
"88.0"
mnemonicParsing=
"false"
onAction=
"#deletePatient"
prefWidth=
"70.0"
text=
"Ok"
AnchorPane.bottomAnchor=
"15.0"
AnchorPane.rightAnchor=
"100.0"
/>
<Button
layoutX=
"229.0"
layoutY=
"88.0"
mnemonicParsing=
"false"
onAction=
"#closeWindow"
prefWidth=
"70.0"
text=
"Cancel"
AnchorPane.bottomAnchor=
"15.0"
AnchorPane.rightAnchor=
"20.0"
/>
<ImageView
fitHeight=
"80.0"
fitWidth=
"80.0"
layoutX=
"180.0"
layoutY=
"36.0"
pickOnBounds=
"true"
preserveRatio=
"true"
AnchorPane.rightAnchor=
"20.0"
AnchorPane.topAnchor=
"20.0"
>
<image>
<Image
url=
"@icons/garbage.png"
/>
</image></ImageView>
<Separator
layoutX=
"14.0"
layoutY=
"107.0"
prefWidth=
"200.0"
AnchorPane.leftAnchor=
"0.0"
AnchorPane.rightAnchor=
"0.0"
AnchorPane.topAnchor=
"120.0"
/>
<Label
layoutX=
"21.0"
layoutY=
"133.0"
text=
"Are you sure you would like to delete this item?"
AnchorPane.bottomAnchor=
"50.0"
AnchorPane.leftAnchor=
"20.0"
/>
<Label
layoutX=
"20.0"
layoutY=
"34.0"
text=
"Delete confirmation"
AnchorPane.leftAnchor=
"20.0"
AnchorPane.topAnchor=
"30.0"
/>
<Label
fx:id=
"information"
layoutX=
"30.0"
layoutY=
"44.0"
text=
"Customer information"
AnchorPane.leftAnchor=
"20.0"
AnchorPane.topAnchor=
"60.0"
/>
</children>
</AnchorPane>
target/classes/InformationDialog.fxml
0 → 100644
View file @
c7bc7367
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<AnchorPane
prefHeight=
"200.0"
prefWidth=
"350.0"
xmlns=
"http://javafx.com/javafx/11.0.1"
xmlns:fx=
"http://javafx.com/fxml/1"
fx:controller=
"mappe.del2.GUI.controllers.InformationDialog"
>
<children>
<Button
layoutX=
"168.0"
layoutY=
"86.0"
mnemonicParsing=
"false"
onAction=
"#closeWindow"
prefWidth=
"70.0"
text=
"OK"
AnchorPane.bottomAnchor=
"15.0"
AnchorPane.rightAnchor=
"20.0"
/>
<ImageView
fitHeight=
"50.0"
fitWidth=
"50.0"
layoutX=
"190.0"
layoutY=
"46.0"
pickOnBounds=
"true"
preserveRatio=
"true"
AnchorPane.rightAnchor=
"20.0"
AnchorPane.topAnchor=
"20.0"
>
<image>
<Image
url=
"@icons/book.png"
/>
</image>
</ImageView>
<Separator
layoutY=
"85.0"
prefWidth=
"200.0"
AnchorPane.leftAnchor=
"0.0"
AnchorPane.rightAnchor=
"0.0"
AnchorPane.topAnchor=
"85.0"
/>
<Label
layoutX=
"14.0"
layoutY=
"100.0"
text=
"Application created by"
AnchorPane.bottomAnchor=
"85.0"
AnchorPane.leftAnchor=
"14.0"
/>
<Label
layoutX=
"19.0"
layoutY=
"52.0"
text=
"v0.1-SNAPSHOT"
AnchorPane.leftAnchor=
"19.0"
AnchorPane.topAnchor=
"52.0"
/>
<Label
layoutX=
"31.0"
layoutY=
"78.0"
text=
"Patient Register"
AnchorPane.leftAnchor=
"20.0"
AnchorPane.topAnchor=
"30.0"
/>
<Label
layoutX=
"14.0"
layoutY=
"124.0"
text=
"olavdei.edu.ntnu.idatx2001"
AnchorPane.bottomAnchor=
"65.0"
AnchorPane.leftAnchor=
"15.0"
/>
<Label
layoutX=
"25.0"
layoutY=
"128.0"
text=
"04.2021"
AnchorPane.bottomAnchor=
"45.0"
AnchorPane.leftAnchor=
"15.0"
/>
</children>
</AnchorPane>
target/classes/NewPatientDetails.fxml
0 → 100644
View file @
c7bc7367
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane
prefHeight=
"200.0"
prefWidth=
"350.0"
xmlns=
"http://javafx.com/javafx/11.0.1"
xmlns:fx=
"http://javafx.com/fxml/1"
fx:controller=
"mappe.del2.GUI.controllers.NewPatientDetails"
>
<children>
<Button
layoutX=
"189.0"
layoutY=
"161.0"
mnemonicParsing=
"false"
onAction=
"#addPatient"
prefWidth=
"70.0"
text=
"Ok"
AnchorPane.bottomAnchor=
"15.0"
AnchorPane.rightAnchor=
"100.0"
/>
<Button
layoutX=
"234.0"
layoutY=
"161.0"
mnemonicParsing=
"false"
onAction=
"#closeWindow"
prefWidth=
"70.0"
text=
"Cancel"
AnchorPane.bottomAnchor=
"15.0"
AnchorPane.rightAnchor=
"20.0"
/>
<Label
layoutX=
"14.0"
layoutY=
"115.0"
text=
"Social security number:"
AnchorPane.leftAnchor=
"20.0"
/>
<Label
layoutX=
"65.0"
layoutY=
"79.0"
text=
"Last name:"
AnchorPane.leftAnchor=
"20.0"
/>
<Label
layoutX=
"65.0"
layoutY=
"41.0"
text=
"First name:"
AnchorPane.leftAnchor=
"20.0"
/>
<TextField
fx:id=
"firstNameField"
layoutX=
"175.0"
layoutY=
"38.0"
prefWidth=
"150.0"
AnchorPane.rightAnchor=
"20.0"
/>
<TextField
fx:id=
"lastNameField"
layoutX=
"175.0"
layoutY=
"76.0"
prefWidth=
"150.0"
AnchorPane.rightAnchor=
"20.0"
/>
<TextField
fx:id=
"ssnTextField"
layoutX=
"175.0"
layoutY=
"112.0"
prefWidth=
"150.0"
AnchorPane.rightAnchor=
"20.0"
/>
</children>
</AnchorPane>
target/classes/PatientRegister.fxml
0 → 100644
View file @
c7bc7367
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane
prefHeight=
"400.0"
prefWidth=
"600.0"
xmlns=
"http://javafx.com/javafx/11.0.1"
xmlns:fx=
"http://javafx.com/fxml/1"
fx:controller=
"mappe.del2.GUI.controllers.PatientRegister"
>
<children>
<MenuBar
AnchorPane.leftAnchor=
"0.0"
AnchorPane.rightAnchor=
"0.0"
>
<menus>
<Menu
mnemonicParsing=
"false"
text=
"File"
>
<items>
<MenuItem
mnemonicParsing=
"false"
onAction=
"#importFromCSV"
text=
"Import from .CSV"
/>
<MenuItem
mnemonicParsing=
"false"
onAction=
"#exportToCSV"
text=
"Export to .CSV"
/>
<SeparatorMenuItem
disable=
"true"
mnemonicParsing=
"false"
/>
<MenuItem
mnemonicParsing=
"false"
onAction=
"#quit"
text=
"Exit"
/>
</items>
</Menu>
<Menu
mnemonicParsing=
"false"
text=
"Edit"
>
<items>
<MenuItem
mnemonicParsing=
"false"
onAction=
"#addPatient"
text=
"Add new patient"
/>
<MenuItem
mnemonicParsing=
"false"
onAction=
"#editSelectedPatient"
text=
"Edit selected patient"
/>
<MenuItem
mnemonicParsing=
"false"
onAction=
"#removeSelectedPatient"
text=
"Remove selected patient"
/>
</items>
</Menu>
<Menu
mnemonicParsing=
"false"
text=
"Help"
>
<items>
<MenuItem
mnemonicParsing=
"false"
onAction=
"#aboutWindow"
text=
"About"
/>
</items>
</Menu>
</menus>
</MenuBar>
<Button
layoutX=
"14.0"
layoutY=
"57.0"
mnemonicParsing=
"false"
onAction=
"#addPatient"
prefHeight=
"60.0"
prefWidth=
"60.0"
text=
"Add"
AnchorPane.leftAnchor=
"10.0"
AnchorPane.topAnchor=
"40.0"
/>
<Button
layoutX=
"73.0"
layoutY=
"57.0"
mnemonicParsing=
"false"
onAction=
"#removeSelectedPatient"
prefHeight=
"60.0"
prefWidth=
"60.0"
text=
"Remove"
AnchorPane.leftAnchor=
"80.0"
AnchorPane.topAnchor=
"40.0"
/>
<Button
layoutX=
"136.0"
layoutY=
"57.0"
mnemonicParsing=
"false"
onAction=
"#editSelectedPatient"
prefHeight=
"60.0"
prefWidth=
"60.0"
text=
"Edit"
AnchorPane.leftAnchor=
"150.0"
AnchorPane.topAnchor=
"40.0"
/>
<TableView
fx:id=
"tableView"
prefHeight=
"255.0"
prefWidth=
"600.0"
AnchorPane.bottomAnchor=
"25.0"
AnchorPane.leftAnchor=
"0.0"
AnchorPane.rightAnchor=
"0.0"
AnchorPane.topAnchor=
"110.0"
>
<columns>
<TableColumn
fx:id=
"firstNameColumn"
prefWidth=
"206.0"
text=
"First name"
/>
<TableColumn
fx:id=
"lastNameColumn"
minWidth=
"7.0"
prefWidth=
"193.0"
text=
"Last name"
/>
<TableColumn
fx:id=
"ssnColumn"
prefWidth=
"200.0"
text=
"Social security number"
/>
</columns>
</TableView>
<Label
layoutX=
"14.0"
layoutY=
"378.0"
text=
"Status"
/>
</children>
</AnchorPane>
target/classes/icons/avatar.png
0 → 100644
View file @
c7bc7367
8.66 KB
target/classes/icons/book.png
0 → 100644
View file @
c7bc7367
6.52 KB
target/classes/icons/cancel.png
0 → 100644
View file @
c7bc7367
10.3 KB
target/classes/icons/copy.png
0 → 100644
View file @
c7bc7367
4 KB
target/classes/icons/download-1.png
0 → 100644
View file @
c7bc7367
4.89 KB
target/classes/icons/download.png
0 → 100644
View file @
c7bc7367
7.85 KB
target/classes/icons/folder.png
0 → 100644
View file @
c7bc7367
4.82 KB
target/classes/icons/garbage.png
0 → 100644
View file @
c7bc7367
4.99 KB
target/classes/icons/upload-1.png
0 → 100644
View file @
c7bc7367
4.65 KB
target/classes/mappe/del2/hospital/Pasient.class
0 → 100644
View file @
c7bc7367
File added
target/classes/module-info.class
0 → 100644
View file @
c7bc7367
File added
target/test-classes/mappe/del2/hospital/PasientTest.class
0 → 100644
View file @
c7bc7367
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment