Getting Started With the Test Panel The easiest way to get HAPI to do something is to give it an HL7 message to parse and display in a user interface. We will start out by using this ACK message below: --------- MSH|^~\&|Fake Sending App|Fake Sending Facility||Fake Receiving Facility|200108151718||ACK^A01^ACK|20|P|2.4| MSA|AA --------- <>: Open the TestPanel application. You must have the JDK installed, and you must have the file "hapi_0.3.jar" (or whatever the latest version is); in the directory from which you run it. If you are using Windows, open the DOS Prompt or Command Window and type this: --------- java -classpath hapi_0.3.jar;xmlParserAPIs.jar;xercesImpl.jar ca.uhn.hl7v2.app.TestPanel --------- You should see this: [images/testpanelblank.jpg] <>: Cut and paste the above ACK message into the "Outbound Message Text" area, then hit the "Parse" button. You should see the parsed ACK message the "Outbound Message Tree" area, like this: [images/testpanelack.jpg] This is much more exciting with a bigger message, but you get the idea. * Something a Little More Involved Now let's try starting up a server and sending a message to it. This time we will use an ADT_A01 message: ----------------- MSH|^~\&|system1|W|system2|UHN|200105231927||ADT^A01^ADT_A01|22139243|P|2.4 EVN|A01|200105231927| PID||9999999999^^|2216506^||Duck^Donald^^^MR.^MR.||19720227|M|||123 Foo ST.^^TORONTO^ON^M6G 3E6^CA^H^~123 Foo ST.^^TORONTO^ON^M6G 3E6^CA^M^|1811|(416)111-1111||E^ ENGLISH|S| PATIENT DID NOT INDICATE|211004554^|||||||||||| PV1|||ZFAST TRACK^WAITING^13|E^EMERGENCY||369^6^13^U EM EMERGENCY DEPARTMENT^ZFAST TRACK WAITING^FT WAIT 13^FTWAIT13^FT WAITING^FTWAIT13|^MOUSE^MICKEY^M^^DR.^MD|||SUR||||||||I|211004554^||||||||||||||||||||W|||||200105231927||||| PV2||F|^R/O APPENDICIAL ABSCESS||||||||||||||||||||||||| IN1|1||001001| OHIP||||||||||||^^^^^|||^^^^^^M^|||||||||||||||||||||||||^^^^^^M^||||| ACC| ----------------- <>: First, start the server. Enter the following command: ----------------- java -classpath hapi_0.3.jar ca.uhn.hl7v2.app.SimpleServer 8888

----------------- When you run the SimpleServer class from the command line, you need to specify a port number on which to receive connections (that's the 8888, above). You should see a message from the server, telling you it has started: [images/simpleserverrunning.gif] <>: Open TestPanel and parse the ADT_A01 message, as above (be sure to do this in a new Command Window because we need the server to keep running). <>: Connect to your SimpleServer server from the TestPanel. You do this by pressing the "Connect" button and entering the host and port of the server as shown below. In this case, the host is "localhost", and the port is "8888". [images/connect.jpg] <>: Highlight the "localhost:8888" connection in the connection list, and press "Send". The ADT_A01 message should be sent to the server, and the response should appear in the "Inbound Message Tree" area. The response message you see is a default message that SimpleServer returns if it receives a message is does not recognize. <>: Press "Encode". The inbound message should be encoded and displayed in the "Inbound Message Text" area. Now the window should look like this: [images/response.jpg] <>: For fun, let's encode the inbound message using the XML encoding. To do this, check the "Use XML" box, then click the "Encode" button again. When "Use XML" is checked, outbound messages are also sent in XML form. This is OK, because SimpleServer will recognize that a message is XML-encoded, and use the appropriate parser. [images/responsexml.jpg] * Where To Go From Here This concludes the gentle introduction. The next step is to start reading the JavaDocs. If you are building an HL7 client (i.e. your code will be sending a message to another server and expecting a response), a good place to start would be ca.uhn.hl7v2.app.Initiator. If you are building an HL7 server (i.e. your code will wait for incoming messages, process them, and respond to them) a good place to start would be either ca.uhn.hl7v2.app.SimpleServer or ca.uhn.hl7v2.app.Responder.