-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPatientController.java
More file actions
141 lines (98 loc) · 3.36 KB
/
PatientController.java
File metadata and controls
141 lines (98 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package healthcareLook;
import java.io.EOFException;
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Optional;
import java.util.ResourceBundle;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.control.Tooltip;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
/*
* NO PROBLEMS...
* The purpose of this window is to find a patient or go to the next window
* which will make a new patient.
*/
public class PatientController implements Initializable{
@FXML
TextField iDFinder;
@FXML
Button newPatient;
@FXML
Label ssConfirmation;
@FXML
Label lNameConfirmation;
@FXML
Label addConfirmation;
@FXML
Label fNameConfirmation;
@FXML
Label confirmOrError;
@FXML
Button submitPatient;
Optional<ButtonType> result;
@FXML
ImageView errorImage;
Alert testAlert = new Alert(AlertType.CONFIRMATION);
Alert problemAlert = new Alert(AlertType.WARNING);
Tooltip errortip;
int patientConfirm;
int quitClick;
int patientid;
Patient patientHolder;
//This check is for when I do not want letters or symbols.
public boolean getLetterCount(String s) {
Pattern p = Pattern.compile("[^0-9]");
Matcher m = p.matcher(s);
boolean b = m.find();
return b;
}
@Override
public void initialize(URL location, ResourceBundle resources) {
/*This button is for confirming if the information gathered is correct or not.
* If it is correct then the data will be inserted into another window.
*/
submitPatient.setOnAction(e->{
if(iDFinder.getText().trim().equals("")){
errorImage.setVisible(true);
errortip.install(errorImage, new Tooltip("Please enter your patient ID"));
}
else if(getLetterCount(iDFinder.getText().trim())){
errorImage.setVisible(true);
errortip.install(errorImage, new Tooltip("Please enter your patient ID"));
}
else if(DatabaseWork.IDCheckPatient(iDFinder.getText().trim())){
// System.out.println("Data retrieved!");
testAlert.setTitle("Patient Login Result");
testAlert.setHeaderText("Is this your information?");
patientHolder = (DatabaseWork.IDPatientConfirmation(iDFinder.getText().trim()));
testAlert.setContentText("First Name: " + patientHolder.getfName() + "\nLast Name: " + patientHolder.getlName() + "\nSocial Security Number: " + patientHolder.getSsn());
result = testAlert.showAndWait();
if(result.get() == ButtonType.OK){
PatientFinderMain.setID(iDFinder.getText().trim());
PatientFinderMain.stageClose();
}
}
//IF the id number was not found in the database.
else{
problemAlert.setTitle("Patient Login Result");
problemAlert.setHeaderText("Warning!");
problemAlert.setContentText("ID NUMBER NOT FOUND");
problemAlert.showAndWait();
}
});
}
}