View Javadoc
1   package ca.uhn.hl7v2.examples.sourcegen;
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.HL7Service;
9   import ca.uhn.hl7v2.examples.custommodel.v25.message.ZDT_A01;
10  import ca.uhn.hl7v2.llp.LLPException;
11  import ca.uhn.hl7v2.model.Message;
12  import ca.uhn.hl7v2.parser.CanonicalModelClassFactory;
13  import ca.uhn.hl7v2.parser.ModelClassFactory;
14  
15  public class ExampleUseConfGen {
16  
17  @SuppressWarnings("unused")
18  public static void main(String[] args) throws HL7Exception, IOException, LLPException {
19  // Sending a message
20  
21  {   
22  // Create a new instance of the message and initialize it
23  ZDT_A01ommodel/v25/message/ZDT_A01.html#ZDT_A01">ZDT_A01 outMsg = new ZDT_A01();
24  outMsg.initQuickstart("ZDT", "A01", "T");
25  
26  // .. populate other segments ..
27  // e.g. outMsg.getPID().getPid3_PatientIdentifierList(0).......
28  
29  // Create a hapi context and send the message
30  DefaultHapiContextml#DefaultHapiContext">DefaultHapiContext ctx = new DefaultHapiContext();
31  Connection conn = ctx.newClient("someserver.com", 8888, false);
32  
33  // Send the message
34  Message response = conn.getInitiator().sendAndReceive(outMsg);
35  }
36  
37  
38  DefaultHapiContextml#DefaultHapiContext">DefaultHapiContext ctx = new DefaultHapiContext();
39  ModelClassFactory mcf = new CanonicalModelClassFactory(ZDT_A01.class);
40  ctx.setModelClassFactory(mcf);
41  
42  HL7Service server = ctx.newServer(8888, false);
43  server.start();
44     
45  }
46     
47     
48     
49  }