-
Notifications
You must be signed in to change notification settings - Fork 1
/
UpdatePatientServlet.java
282 lines (206 loc) · 11.3 KB
/
UpdatePatientServlet.java
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender;
/**
* Servlet implementation class UpdatePatientServlet
*/
@WebServlet("/UpdatePatientServlet")
public class UpdatePatientServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
ArrayList<String> idDisplay = new ArrayList<String>();
ArrayList<String> idValue = new ArrayList<String>();
ArrayList<String> telecomValue = new ArrayList<String>();
String contactRelationshipCodePrimary;
String contactRelationshipSystemPrimary;
String contactRelationshipNamePrimary;
String contactRelationshipCodeSecondary;
String contactRelationshipSystemSecondary;
String contactRelationshipNameSecondary;
ArrayList<String> contactTelecomSystemPrimary = new ArrayList<String>();
ArrayList<String> contactTelecomValuePrimary = new ArrayList<String>();
ArrayList<String> contactTelecomUsePrimary = new ArrayList<String>();
ArrayList<String> contactTelecomSystemSecondary = new ArrayList<String>();
ArrayList<String> contactTelecomValueSecondary = new ArrayList<String>();
ArrayList<String> contactTelecomUseSecondary = new ArrayList<String>();
ArrayList<String> practitioner = new ArrayList<String>();
/**
* @see HttpServlet#HttpServlet()
*/
public UpdatePatientServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String crudResponse=request.getParameter("crud");
if(crudResponse.equals("delete")) {
String patientId=request.getParameter("id");
System.out.println("patient's id= "+patientId);
response.setContentType("text/html");
request.setAttribute("patientId", patientId);//seems like all the name have to be the same for this to work
//response.sendRedirect("deletePatients.jsp");
try {
request.getRequestDispatcher("/deletePatients.jsp").forward(request, response);
} catch (ServletException e) {
}
}
if(crudResponse.equals("goHome")) {
response.sendRedirect("index.jsp");
}
if(crudResponse.equals("update")) {
idDisplay.clear();
idValue.clear();
telecomValue.clear();
contactRelationshipCodePrimary="";
contactRelationshipSystemPrimary="";
contactRelationshipNamePrimary="";
contactRelationshipCodeSecondary="";
contactRelationshipSystemSecondary="";
contactRelationshipNameSecondary="";
contactTelecomSystemPrimary.clear();
contactTelecomValuePrimary.clear();
contactTelecomUsePrimary.clear();
contactTelecomSystemSecondary.clear();
contactTelecomValueSecondary.clear();
contactTelecomUseSecondary.clear();
practitioner.clear();
//get variables from searchPatient.java
String active=request.getParameter("active");//
String resourceType=request.getParameter("resourceType");//
String patientId=request.getParameter("id");//
String version=request.getParameter("version");//
String lastUpdate=request.getParameter("lastUpdate");//
String language=request.getParameter("language");//
String gender=request.getParameter("gender");//
String birthDate=request.getParameter("birthDate");//
String maritalStatus=request.getParameter("maritalStatus");//
String maritalSystem=request.getParameter("maritalSystem");
String maritalCode=request.getParameter("maritalCode");
String prefix=request.getParameter("prefix");//
String familyName=request.getParameter("familyName");//
String nameUsual=request.getParameter("nameUse");// maybe an array
String nameGiven=request.getParameter("nameGiven");// maybe an array
String street = request.getParameter("street");//
String city = request.getParameter("city");//
String state = request.getParameter("state");//
String postcode = request.getParameter("postcode");//
int idCount = Integer.parseInt(request.getParameter("idCount"));
for(int i=0;i<idCount;i++) {
idValue.add(request.getParameter("idValue"+i));
idDisplay.add(request.getParameter("idDisplay"+i));
}
System.out.println("idValue array = "+idValue);
System.out.println("idDisplay array = "+idDisplay);
if(request.getParameter("homePhone")!="") {
telecomValue.add(0,request.getParameter("homePhone"));
}else telecomValue.add(0,"NULL");
if(request.getParameter("workPhone")!="") {
telecomValue.add(1,request.getParameter("workPhone"));
}else telecomValue.add(1,"NULL");
if(request.getParameter("mobilePhone")!="") {
telecomValue.add(2,request.getParameter("mobilePhone"));
}else telecomValue.add(2,"NULL");
if(request.getParameter("email")!="") {
telecomValue.add(3,request.getParameter("email"));
}else telecomValue.add(3,"NULL");
if(request.getParameter("contactRelationshipCodePrimary")!="") {
contactRelationshipCodePrimary=request.getParameter("contactRelationshipCodePrimary"); //name and code are fixed number
}else contactRelationshipCodePrimary="NULL";
//contactRelationshipSystem.add(request.getParameter("contactRelationshipSystem"+i));
if(request.getParameter("contactRelationshipNamePrimary")!="") {
contactRelationshipNamePrimary=request.getParameter("contactRelationshipNamePrimary");
}else contactRelationshipNamePrimary="NULL";
if(request.getParameter("contactRelationshipCodeSecondary")!="") {
contactRelationshipCodeSecondary=request.getParameter("contactRelationshipCodeSecondary"); //name and code are fixed number
}else contactRelationshipCodeSecondary="NULL";
//contactRelationshipSystem.add(request.getParameter("contactRelationshipSystem"+i));
if(request.getParameter("contactRelationshipNameSecondary")!="") {
contactRelationshipNameSecondary=request.getParameter("contactRelationshipNameSecondary");
}else contactRelationshipNameSecondary="NULL";
if(request.getParameter("contactTelecomSystemPrimary0")!="") {
contactTelecomSystemPrimary.add(0,request.getParameter("contactTelecomSystemPrimary0"));
}else contactTelecomSystemPrimary.add(0,"NULL");
if(request.getParameter("contactTelecomValuePrimary0")!="") {
contactTelecomValuePrimary.add(0,request.getParameter("contactTelecomValuePrimary0"));
}else contactTelecomValuePrimary.add(0,"NULL");
if(request.getParameter("contactTelecomUsePrimary0")!="") {
contactTelecomUsePrimary.add(0,request.getParameter("contactTelecomUsePrimary0"));
}else contactTelecomUsePrimary.add(0,"NULL");
if(request.getParameter("contactTelecomSystemPrimary1")!="") {
contactTelecomSystemPrimary.add(1,request.getParameter("contactTelecomSystemPrimary1"));
}else contactTelecomSystemPrimary.add(1,"NULL");
if(request.getParameter("contactTelecomValuePrimary1")!="") {
contactTelecomValuePrimary.add(1,request.getParameter("contactTelecomValuePrimary1"));
}else contactTelecomValuePrimary.add(1,"NULL");
if(request.getParameter("contactTelecomUsePrimary1")!="") {
contactTelecomUsePrimary.add(1,request.getParameter("contactTelecomUsePrimary1"));
}else contactTelecomUsePrimary.add(1,"NULL");
if(request.getParameter("contactTelecomSystemPrimary2")!="") {
contactTelecomSystemPrimary.add(2,request.getParameter("contactTelecomSystemPrimary2"));
}else contactTelecomSystemPrimary.add(2,"NULL");
if(request.getParameter("contactTelecomValuePrimary2")!="") {
contactTelecomValuePrimary.add(2,request.getParameter("contactTelecomValuePrimary2"));
}else contactTelecomValuePrimary.add(2,"NULL");
if(request.getParameter("contactTelecomUsePrimary2")!="") {
contactTelecomUsePrimary.add(2,request.getParameter("contactTelecomUsePrimary2"));
}else contactTelecomUsePrimary.add(2,"NULL");
if(request.getParameter("contactTelecomSystemSecondary0")!="") {
contactTelecomSystemSecondary.add(0,request.getParameter("contactTelecomSystemSecondary0"));
}else contactTelecomSystemSecondary.add(0,"NULL");
if(request.getParameter("contactTelecomValueSecondary0")!="") {
contactTelecomValueSecondary.add(0,request.getParameter("contactTelecomValueSecondary0"));
}else contactTelecomValueSecondary.add(0,"NULL");
if(request.getParameter("contactTelecomUseSecondary0")!="") {
contactTelecomUseSecondary.add(0,request.getParameter("contactTelecomUseSecondary0"));
}else contactTelecomUseSecondary.add(0,"NULL");
if(request.getParameter("contactTelecomSystemSecondary1")!="") {
contactTelecomSystemSecondary.add(1,request.getParameter("contactTelecomSystemSecondary1"));
}else contactTelecomSystemSecondary.add(1,"NULL");
if(request.getParameter("contactTelecomValueSecondary1")!="") {
contactTelecomValueSecondary.add(1,request.getParameter("contactTelecomValueSecondary1"));
}else contactTelecomValueSecondary.add(1,"NULL");
if(request.getParameter("contactTelecomUseSecondary1")!="") {
contactTelecomUseSecondary.add(1,request.getParameter("contactTelecomUseSecondary1"));
}else contactTelecomUseSecondary.add(1,"NULL");
if(request.getParameter("contactTelecomSystemSecondary2")!="") {
contactTelecomSystemSecondary.add(2,request.getParameter("contactTelecomSystemSecondary2"));
}else contactTelecomSystemSecondary.add(2,"NULL");
if(request.getParameter("contactTelecomValueSecondary2")!="") {
contactTelecomValueSecondary.add(2,request.getParameter("contactTelecomValueSecondary2"));
}else contactTelecomValueSecondary.add(2,"NULL");
if(request.getParameter("contactTelecomUseSecondary2")!="") {
contactTelecomUseSecondary.add(2,request.getParameter("contactTelecomUseSecondary2"));
}else contactTelecomUseSecondary.add(2,"NULL");
int practitionerCount = Integer.parseInt(request.getParameter("practitionerCount"));
for(int i=0;i<practitionerCount;i++) {
practitioner.add(request.getParameter("practitioner"+i));
}
System.out.println("Practitioner array = "+practitioner);
response.setContentType("text/html");
request.setAttribute("message", SearchPatient.message);
//send results to searchPatient.jsp
//request.getRequestDispatcher("/searchPatientResults.jsp").forward(request, response);
SearchPatient.updateAPatient(patientId, active, prefix, familyName, nameGiven, nameUsual,
gender, birthDate, idValue, idDisplay, maritalStatus, practitioner,
street, city, state, postcode, language, telecomValue, contactRelationshipCodePrimary, contactRelationshipSystemPrimary,
contactRelationshipNamePrimary, contactTelecomSystemPrimary, contactTelecomValuePrimary, contactTelecomUsePrimary ,
contactRelationshipCodeSecondary, contactRelationshipSystemSecondary, contactRelationshipNameSecondary,
contactTelecomSystemSecondary, contactTelecomValueSecondary, contactTelecomUseSecondary);
request.getRequestDispatcher("/index.jsp").forward(request, response);
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}