SuperStructureGen Plugin - Usage

The superstructuregen plugin is used to create a set of HAPI structure classes which combine multiple message structures into a single class.

See the SuperStructures example page for more information on their usage.

Using the Plugin

Usage of the plusing is as follows:

            <!-- The directory to place the generated files in -->
            <!-- The name for the genrated strcuture -->
            <!-- This is the HL7 version to base the superstructure on -->
            And finally, a list of structures to combine. This list
            supports regex, so the following are all valid 
      <!-- Make sure to include the appropriate HAPI version as a dependency -->

Using the Generated Sources

Once you have completed the source generation, you have a set of classes you can use in your application.

The following examples assume you have created a custom structure called "ADT_AXX" and generated classes using the confgen plugin.

Sending Custom Structures

To send messages out using your custom structures:

// Create a new instance of the message and initialize it
ADT_AXX outMsg = new ADT_AXX();
outMsg.initQuickstart("ZDT", "A01", "T");

// .. populate other segments ..
// e.g. outMsg.getPID().getPid3_PatientIdentifierList(0).......

// Create a hapi context and send the message
DefaultHapiContext ctx = new DefaultHapiContext();
Connection conn = ctx.newClient("", 8888, false);

// Send the message
Message response = conn.getInitiator().sendAndReceive(outMsg);

Receiving Custom Structures

The easiest way to receive messages and have them parsed into a custom structure is to use a CanonicalModelClassFactory and configure it to always use your custom structure.

DefaultHapiContext ctx = new DefaultHapiContext();
ModelClassFactory mcf = new CanonicalModelClassFactory(ADT_AXX.class);

HL7Service server = ctx.newServer(8888, false);