-
Notifications
You must be signed in to change notification settings - Fork 1
/
UpdatePractitionerServlet.java
161 lines (111 loc) · 4.89 KB
/
UpdatePractitionerServlet.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
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("/UpdatePractitionerServlet")
public class UpdatePractitionerServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
ArrayList<String> idDisplay = new ArrayList<String>();
ArrayList<String> idValue = new ArrayList<String>();
ArrayList<String> idSystem = new ArrayList<String>();
ArrayList<String> telecomValue = new ArrayList<String>();
ArrayList<String> qualification = new ArrayList<String>();
/**
* @see HttpServlet#HttpServlet()
*/
public UpdatePractitionerServlet() {
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 practitionerId=request.getParameter("id");
System.out.println("patient's id= "+practitionerId);
response.setContentType("text/html");
request.setAttribute("practitionerId", practitionerId);//seems like all the name have to be the same for this to work
//response.sendRedirect("deletePatients.jsp");
try {
request.getRequestDispatcher("/deletePractitioner.jsp").forward(request, response);
} catch (ServletException e) {
}
}
if(crudResponse.equals("goHome")) {
response.sendRedirect("index.jsp");
}
if(crudResponse.equals("update")) {
idDisplay.clear();
idValue.clear();
idSystem.clear();
qualification.clear();
telecomValue.clear();
//get variables from searchPatient.java
String active=request.getParameter("active");//
String resourceType=request.getParameter("resourceType");//
String practitionerId=request.getParameter("id");//
String version=request.getParameter("version");//
String lastUpdate=request.getParameter("lastUpdate");//
String language=request.getParameter("language");//
String gender=request.getParameter("gender");//
String prefix=request.getParameter("prefix");//
String familyName=request.getParameter("familyName");//
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 qualificationCount = Integer.parseInt(request.getParameter("qualificationCount"));
for(int i=0;i<qualificationCount;i++) {
qualification.add(request.getParameter("qualification"+i));
}
int idCount = Integer.parseInt(request.getParameter("idCount"));
for(int i=0;i<idCount;i++) {
// if(request.getParameter("idValue"+i)!="") {
idValue.add(request.getParameter("idValue"+i));
//}else {}
//if(request.getParameter("idDisplay"+i)!="") {
idDisplay.add(request.getParameter("idDisplay"+i));
// }else {}
//if(request.getParameter("idSystem"+i)!="") {
idSystem.add(request.getParameter("idSystem"+i));
// }else {}
}
System.out.println("idValue array = "+idValue);
System.out.println("idDisplay array = "+idDisplay);
if(request.getParameter("workPhone")!="") {
telecomValue.add(0,request.getParameter("workPhone"));
}else telecomValue.add(0,"NULL");
if(request.getParameter("email")!="") {
telecomValue.add(1,request.getParameter("email"));
}else telecomValue.add(1,"NULL");
if(request.getParameter("mobilePhone")!="") {
telecomValue.add(2,request.getParameter("mobilePhone"));
}else telecomValue.add(2,"NULL");
System.out.println("update servlet array telecom value = "+telecomValue);
response.setContentType("text/html");
request.setAttribute("message", SearchPatient.message);
//send results to searchPatient.jsp
//request.getRequestDispatcher("/searchPatientResults.jsp").forward(request, response);
SearchPatient.updateAPractitioner(practitionerId, active, prefix, familyName, nameGiven,
gender,idValue, idDisplay, street, city, state, postcode, language, telecomValue,qualification);
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);
}
}