This procedure shows how to use a compiled profile (produced by the generator system) to write an application. The compiled profile in this example is based upon an acknowledgement (ACK) message. There are many types of programs that you can write with the code from the compiled profile Java archive. For example, your program could listen for lab results and send a pager message to a physician when a result is abnormal.
1. Open a Java Integrated Development Environment (IDE).
2.
Download the example JAR from http://hl7api.sourceforge.net/docs/profile_example/ack.jar.
Make sure it
is in your classpath.
3. Review the JavaDocs at http://hl7api.sourceforge.net/docs/profile_example/. Look for the class, constructor and method that you require.
4. Call the constructor by entering the following code:
ConformanceMessage_XX msg = new ConformanceMessage_XX();
Note: The
constructor creates an underlying HAPI message object in memory to store the
message. This message object can then
be passed to other portions of the HAPI library for transmission.
5. Retrieve an object reference for the segments and the segment groups by entering the following code:
ConformanceSegment_XX seg =
msg.getSegment_XX( n );
where the n in parentheses is the repetition number, if one
is needed.
6. Retrieve an object reference for a field within a segment by typing the following code:
ConformanceField_XX field = seg.getField_XX( n );
where the n in parentheses is the repetition number, if one
is needed.
7.
Retrieve the code for components within a field by
entering the following code:
ConformanceComponent_XX comp =
field.getComponent_XX( );
8. Retrieve the code for sub-components within a component, if any, by entering the following code:
ConformanceSubComponent_XX subc =
comp.getSubComponent();
You have completed this procedure.