1
2
3
4
5
6
7
8
9
10
11
12
13
14 package uk.nhs.interoperability.client.samples.notification;
15
16 import uk.nhs.interoperability.infrastructure.ITKAddressImpl;
17 import uk.nhs.interoperability.infrastructure.ITKIdentity;
18 import uk.nhs.interoperability.infrastructure.ITKIdentityImpl;
19 import uk.nhs.interoperability.infrastructure.ITKMessageProperties;
20 import uk.nhs.interoperability.infrastructure.ITKMessagePropertiesImpl;
21 import uk.nhs.interoperability.infrastructure.ITKMessagingException;
22 import uk.nhs.interoperability.payload.ITKMessage;
23 import uk.nhs.interoperability.payload.SimpleMessage;
24 import uk.nhs.interoperability.source.ITKMessageSender;
25 import uk.nhs.interoperability.source.ITKMessageSenderImpl;
26 import uk.nhs.interoperability.util.Logger;
27
28
29
30
31
32
33
34 public class NotificationSender {
35
36
37 private static final String NOTIFICATIONSTORE = "urn:nhs-uk:addressing:ods:TESTORGS:NOTIFICATIONSTORE";
38
39
40 private static final String ORGID = "urn:nhs-uk:identity:ods:TESTORGS:ORGA";
41
42
43 private static final ITKIdentity AUDITID = new ITKIdentityImpl(ORGID);
44
45
46 private static final String FROMADDRESS = "urn:nhs-uk:addressing:ods:R59:oncology";
47
48
49 private static final String NOTIFICATION_SERVICENAME = "urn:nhs-itk:services:201005:SendEventNotification-v1-0";
50
51
52 private static final String NOTIFICATION_PROFILEID = "urn:nhs-en:profile:EventNotification-v1-0";
53
54
55
56
57
58
59 public static void main(String[] args) {
60
61 NotificationSender appA = new NotificationSender();
62 appA.sendNotificationMessage();
63
64 }
65
66
67
68
69 private void sendNotificationMessage(){
70 Logger.trace("*** NotificationSender: Starting sendNotificationMessage");
71
72
73 ITKMessage msg = new SimpleMessage();
74 Notification n = new Notification();
75 n.setMessageId("NOTIFICATIONTEST");
76 n.setEffectiveTime("20121127151500+0000");
77 n.setDateOfBirth("20020831");
78 n.setSenderOrg("Organisation1");
79 n.setRecipientOrg("Organisation2");
80 n.setRecipientAddress("Leeds, LS1 4HY");
81 n.setPatientName("Joe Bloggs");
82 n.setPatientAddress("Cleckheaton, BD19 3RH");
83 n.setNHSNumber("1234556789");
84 n.setEventTypeCode("01");
85 n.setEventTypeDesc("DocumentEvent");
86 n.setContactName("Fred Bloggs");
87 n.setContactAddress("Bradford, BD1 1HY");
88 n.setContactOrg("Organisation3");
89 msg.setBusinessPayload(n.serialise());
90
91
92 ITKMessageProperties mp = new ITKMessagePropertiesImpl();
93 mp.setAuditIdentity(AUDITID);
94 mp.setFromAddress(new ITKAddressImpl(FROMADDRESS));
95 mp.setToAddress(new ITKAddressImpl(NOTIFICATIONSTORE));
96 mp.setServiceId(NOTIFICATION_SERVICENAME);
97
98 mp.setBusinessPayloadId("NOTIFICATION");
99 mp.setProfileId(NOTIFICATION_PROFILEID);
100
101
102 msg.setMessageProperties(mp);
103
104
105 ITKMessageSender sender = new ITKMessageSenderImpl();
106
107 try {
108
109 sender.sendAsync(msg);
110
111 Logger.trace("Notification Sender sent message");
112
113 } catch (ITKMessagingException e) {
114 Logger.error("Error Sending ITK Message",e);
115 }
116
117 Logger.trace("*** Notification Sender: Ending sendNotificationMessage");
118 }
119
120 }