1 package ca.uhn.hl7v2.examples.hoh;
2
3 import java.io.IOException;
4
5 import ca.uhn.hl7v2.DefaultHapiContext;
6 import ca.uhn.hl7v2.HL7Exception;
7 import ca.uhn.hl7v2.app.Connection;
8 import ca.uhn.hl7v2.app.DefaultApplication;
9 import ca.uhn.hl7v2.app.SimpleServer;
10 import ca.uhn.hl7v2.hoh.llp.Hl7OverHttpLowerLayerProtocol;
11 import ca.uhn.hl7v2.hoh.util.ServerRoleEnum;
12 import ca.uhn.hl7v2.llp.LLPException;
13 import ca.uhn.hl7v2.llp.LowerLayerProtocol;
14 import ca.uhn.hl7v2.model.Message;
15 import ca.uhn.hl7v2.model.v25.message.ADT_A01;
16 import ca.uhn.hl7v2.parser.PipeParser;
17
18 public class HohLlpExample {
19
20 public void receiveMessage() {
21
22
23
24
25
26
27
28
29 LowerLayerProtocol llp;
30 llp = new Hl7OverHttpLowerLayerProtocol(ServerRoleEnum.SERVER);
31
32
33
34
35
36
37
38 PipeParser parser = PipeParser.getInstanceWithNoValidation();
39 int port = 8080;
40 SimpleServertml#SimpleServer">SimpleServer server = new SimpleServer(port, llp, parser);
41
42
43
44 server.registerApplication("*", "*", new DefaultApplication());
45 server.start();
46
47
48
49 }
50
51 @SuppressWarnings("unused")
52 public void sendMessage() throws HL7Exception, IOException, LLPException {
53
54
55
56
57
58
59
60
61 DefaultHapiContextml#DefaultHapiContext">DefaultHapiContext ctx = new DefaultHapiContext();
62
63
64 LowerLayerProtocol llp = new Hl7OverHttpLowerLayerProtocol(ServerRoleEnum.CLIENT);
65 ctx.setLowerLayerProtocol(llp);
66
67
68 String host = "localhost";
69 int port = 8080;
70 boolean tls = false;
71 Connection connection = ctx.newClient(host, port, tls);
72
73
74 ADT_A01age/ADT_A01.html#ADT_A01">ADT_A01 message = new ADT_A01();
75 message.initQuickstart("ADT", "A01", "P");
76
77
78
79 Message response = connection.getInitiator().sendAndReceive(message);
80
81
82 }
83
84 }