View Javadoc

1   /*
2      Licensed under the Apache License, Version 2.0 (the "License");
3      you may not use this file except in compliance with the License.
4      You may obtain a copy of the License at
5   
6        http://www.apache.org/licenses/LICENSE-2.0
7   
8      Unless required by applicable law or agreed to in writing, software
9      distributed under the License is distributed on an "AS IS" BASIS,
10     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11     See the License for the specific language governing permissions and
12     limitations under the License.
13  */
14  package uk.nhs.interoperability.client.samples.notification;
15  
16  import java.util.UUID;
17  
18  import uk.nhs.interoperability.transform.TransformManager;
19  
20  /**
21   * The Class Notification.
22   *
23   * @author Adam Hatherly
24   * @since 0.1
25   */
26  public class Notification {
27  
28  	/** The message id. */
29  	String messageId;
30  	
31  	/** The nhs number. */
32  	String nhsNumber;
33  	
34  	/** The date of birth. */
35  	String dateOfBirth;
36  	
37  	/** The sender org. */
38  	String senderOrg;
39  	
40  	/** The recipient org. */
41  	String recipientOrg;
42  	
43  	/** The recipient address. */
44  	String recipientAddress;
45  	
46  	/** The patient name. */
47  	String patientName;
48  	
49  	/** The patient address. */
50  	String patientAddress;
51  	
52  	/** The event type code. */
53  	String eventTypeCode;
54  	
55  	/** The event type desc. */
56  	String eventTypeDesc;
57  	
58  	/** The contact name. */
59  	String contactName;
60  	
61  	/** The effective time. */
62  	String effectiveTime;
63  	
64  	/** The contact address. */
65  	String contactAddress;
66  	
67  	/** The contact org. */
68  	String contactOrg;
69  	
70  	/**
71  	 * Gets the sender org.
72  	 *
73  	 * @return the sender org
74  	 */
75  	public String getSenderOrg() {
76  		return senderOrg;
77  	}
78  	
79  	/**
80  	 * Sets the sender org.
81  	 *
82  	 * @param senderOrg the new sender org
83  	 */
84  	public void setSenderOrg(String senderOrg) {
85  		this.senderOrg = senderOrg;
86  	}
87  	
88  	/**
89  	 * Gets the recipient org.
90  	 *
91  	 * @return the recipient org
92  	 */
93  	public String getRecipientOrg() {
94  		return recipientOrg;
95  	}
96  	
97  	/**
98  	 * Sets the recipient org.
99  	 *
100 	 * @param recipientOrg the new recipient org
101 	 */
102 	public void setRecipientOrg(String recipientOrg) {
103 		this.recipientOrg = recipientOrg;
104 	}
105 	
106 	/**
107 	 * Gets the recipient address.
108 	 *
109 	 * @return the recipient address
110 	 */
111 	public String getRecipientAddress() {
112 		return recipientAddress;
113 	}
114 	
115 	/**
116 	 * Sets the recipient address.
117 	 *
118 	 * @param recipientAddress the new recipient address
119 	 */
120 	public void setRecipientAddress(String recipientAddress) {
121 		this.recipientAddress = recipientAddress;
122 	}
123 	
124 	/**
125 	 * Gets the patient name.
126 	 *
127 	 * @return the patient name
128 	 */
129 	public String getPatientName() {
130 		return patientName;
131 	}
132 	
133 	/**
134 	 * Sets the patient name.
135 	 *
136 	 * @param patientName the new patient name
137 	 */
138 	public void setPatientName(String patientName) {
139 		this.patientName = patientName;
140 	}
141 	
142 	/**
143 	 * Gets the patient address.
144 	 *
145 	 * @return the patient address
146 	 */
147 	public String getPatientAddress() {
148 		return patientAddress;
149 	}
150 	
151 	/**
152 	 * Sets the patient address.
153 	 *
154 	 * @param patientAddress the new patient address
155 	 */
156 	public void setPatientAddress(String patientAddress) {
157 		this.patientAddress = patientAddress;
158 	}
159 	
160 	/**
161 	 * Gets the event type code.
162 	 *
163 	 * @return the event type code
164 	 */
165 	public String getEventTypeCode() {
166 		return eventTypeCode;
167 	}
168 	
169 	/**
170 	 * Sets the event type code.
171 	 *
172 	 * @param eventTypeCode the new event type code
173 	 */
174 	public void setEventTypeCode(String eventTypeCode) {
175 		this.eventTypeCode = eventTypeCode;
176 	}
177 	
178 	/**
179 	 * Gets the event type desc.
180 	 *
181 	 * @return the event type desc
182 	 */
183 	public String getEventTypeDesc() {
184 		return eventTypeDesc;
185 	}
186 	
187 	/**
188 	 * Sets the event type desc.
189 	 *
190 	 * @param eventTypeDesc the new event type desc
191 	 */
192 	public void setEventTypeDesc(String eventTypeDesc) {
193 		this.eventTypeDesc = eventTypeDesc;
194 	}
195 	
196 	/**
197 	 * Gets the contact name.
198 	 *
199 	 * @return the contact name
200 	 */
201 	public String getContactName() {
202 		return contactName;
203 	}
204 	
205 	/**
206 	 * Sets the contact name.
207 	 *
208 	 * @param contactName the new contact name
209 	 */
210 	public void setContactName(String contactName) {
211 		this.contactName = contactName;
212 	}
213 	
214 	/**
215 	 * Gets the effective time.
216 	 *
217 	 * @return the effective time
218 	 */
219 	public String getEffectiveTime() {
220 		return effectiveTime;
221 	}
222 	
223 	/**
224 	 * Sets the effective time.
225 	 *
226 	 * @param effectiveTime the new effective time
227 	 */
228 	public void setEffectiveTime(String effectiveTime) {
229 		this.effectiveTime = effectiveTime;
230 	}
231 	
232 	/**
233 	 * Gets the contact address.
234 	 *
235 	 * @return the contact address
236 	 */
237 	public String getContactAddress() {
238 		return contactAddress;
239 	}
240 	
241 	/**
242 	 * Sets the contact address.
243 	 *
244 	 * @param contactAddress the new contact address
245 	 */
246 	public void setContactAddress(String contactAddress) {
247 		this.contactAddress = contactAddress;
248 	}
249 	
250 	/**
251 	 * Gets the contact org.
252 	 *
253 	 * @return the contact org
254 	 */
255 	public String getContactOrg() {
256 		return contactOrg;
257 	}
258 	
259 	/**
260 	 * Sets the contact org.
261 	 *
262 	 * @param contactOrg the new contact org
263 	 */
264 	public void setContactOrg(String contactOrg) {
265 		this.contactOrg = contactOrg;
266 	}
267 	
268 	/**
269 	 * Sets the message id.
270 	 *
271 	 * @param messageId the new message id
272 	 */
273 	public void setMessageId(String messageId) {
274 		this.messageId = messageId;
275 	}
276 	
277 	/**
278 	 * Gets the message id.
279 	 *
280 	 * @return the message id
281 	 */
282 	public String getMessageId() {
283 		return messageId;
284 	}
285 	
286 	/**
287 	 * Gets the nHS number.
288 	 *
289 	 * @return the nHS number
290 	 */
291 	public String getNHSNumber() {
292 		return nhsNumber;
293 	}
294 	
295 	/**
296 	 * Sets the nHS number.
297 	 *
298 	 * @param nhsNumber the new nHS number
299 	 */
300 	public void setNHSNumber(String nhsNumber) {
301 		this.nhsNumber = nhsNumber;
302 	}
303 	
304 	/**
305 	 * Gets the date of birth.
306 	 *
307 	 * @return the date of birth
308 	 */
309 	public String getDateOfBirth() {
310 		return dateOfBirth;
311 	}
312 	
313 	/**
314 	 * Sets the date of birth.
315 	 *
316 	 * @param dateOfBirth the new date of birth
317 	 */
318 	public void setDateOfBirth(String dateOfBirth) {
319 		this.dateOfBirth = dateOfBirth;
320 	}
321 	
322 	/**
323 	 * Serialise.
324 	 *
325 	 * @return the string
326 	 */
327 	public String serialise(){
328 		String XML = "<Message>";
329 		XML += "<MessageId>"+messageId+"</MessageId>";
330 		
331 		XML += "<EffectiveTime>"+effectiveTime+"</EffectiveTime>";
332 		XML += "<DateOfBirth>"+dateOfBirth+"</DateOfBirth>";
333 		XML += "<SenderOrg>"+senderOrg+"</SenderOrg>";
334 		XML += "<RecipientOrg>"+recipientOrg+"</RecipientOrg>";
335 		XML += "<RecipientAddress>"+recipientAddress+"</RecipientAddress>";
336 		XML += "<PatientName>"+patientName+"</PatientName>";
337 		XML += "<PatientAddress>"+patientAddress+"</PatientAddress>";
338 		XML += "<NHSNumber>"+nhsNumber+"</NHSNumber>";
339 		XML += "<EventTypeCode>"+eventTypeCode+"</EventTypeCode>";
340 		XML += "<EventTypeDesc>"+eventTypeDesc+"</EventTypeDesc>";
341 		XML += "<ContactName>"+contactName+"</ContactName>";
342 		XML += "<ContactAddress>"+contactAddress+"</ContactAddress>";
343 		XML += "<ContactOrg>"+contactOrg+"</ContactOrg>";		
344 		XML += "</Message>";
345 		String serialisedMessage ="";
346 		try {
347 			serialisedMessage = TransformManager.doTransform("ToNotification.xsl", XML);
348 		} catch (Exception e) {
349 			// TODO Auto-generated catch block
350 			e.printStackTrace();
351 		}
352 		return serialisedMessage;
353 	}
354 	
355 	/**
356 	 * Instantiates a new notification.
357 	 */
358 	public Notification(){
359 		UUID messageId = UUID.randomUUID();
360 		this.messageId = messageId.toString().toUpperCase();
361 	}
362 
363 }