1
2
3
4
5
6
7
8
9
10
11
12
13
14 package uk.nhs.interoperability.client.samples.cda;
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
35 public class CDASenderWithAck {
36
37
38 private static final String APPB = "urn:nhs-uk:addressing:ods:TESTORGS:APPB";
39
40
41 private static final String ORGID = "urn:nhs-uk:identity:ods:TESTORGS:ORGA";
42
43
44 private static final ITKIdentity AUDITID = new ITKIdentityImpl(ORGID);
45
46
47 private static final String FROMADDRESS = "urn:nhs-uk:addressing:ods:R59:oncology";
48
49
50 private static final String NON_CODED_CDA = "urn:nhs-itk:services:201005:SendCDADocument-v2-0";
51
52
53 private static final String NCDA_PROFILEID = "urn:nhs-en:profile:nonCodedCDADocument-v2-0";
54
55
56
57
58
59
60 public static void main(String[] args) {
61
62 CDASenderWithAck appA = new CDASenderWithAck();
63 appA.sendCDAMessage();
64
65 }
66
67
68
69
70 private void sendCDAMessage(){
71 Logger.trace("*** CDASender: Starting sendCDAMessage");
72
73
74 ITKMessage msg = new SimpleMessage();
75 NonCodedCDA req = new NonCodedCDA();
76 req.setNHSNumber("1234556789");
77 req.setDateOfBirth("20020831");
78 req.setPresentationText("HELLO WORLD doc 5");
79 msg.setBusinessPayload(req.serialise());
80
81
82 ITKMessageProperties mp = new ITKMessagePropertiesImpl();
83 mp.setAuditIdentity(AUDITID);
84 mp.setFromAddress(new ITKAddressImpl(FROMADDRESS));
85 mp.setToAddress(new ITKAddressImpl(APPB));
86 mp.setServiceId(NON_CODED_CDA);
87
88 mp.setBusinessPayloadId("HW5");
89 mp.setProfileId(NCDA_PROFILEID);
90
91 mp.addHandlingSpecification(ITKMessageProperties.BUSINESS_ACK_HANDLING_SPECIFICATION_KEY, "true");
92
93
94 msg.setMessageProperties(mp);
95
96
97 ITKMessageSender sender = new ITKMessageSenderImpl();
98
99 try {
100
101 sender.sendAsync(msg);
102
103 Logger.trace("CDASender sent message");
104
105 } catch (ITKMessagingException e) {
106 Logger.error("Error Sending ITK Message",e);
107 }
108
109 Logger.trace("*** CDASender: Ending sendCDAMessage");
110 }
111
112 }