File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Implementing HL7 messages(HAPI) using restful web services Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Reply locked New topic
Author

Implementing HL7 messages(HAPI) using restful web services

Reshma Khatun
Greenhorn

Joined: Jun 05, 2014
Posts: 3
Hi
Thanks for your prompt response.Actually i want to send and receive HL7 v2 messages(HAPI) over restful web services(Jersey 1.x).But i dont know how to implement it.
I have programs in restful web services to send request and receive response,but when i am trying to merge the HL7 code in my program i am not able to do so.I have referred examples from http://www.mkyong.com/tutorials/jax-rs-tutorials/ and http://hl7api.sourceforge.net/devbyexample.html.
Kindly suggest me some examples.

this is my code
package com.mkyong.rest;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;

@Path("/hello")
public class HelloWorldService {

@GET
@Path("/{param}")
public Response getMsg(@PathParam("param") String msg) {


String output = "Jersey say : " + msg;

return Response.status(200).entity(output).build();

}

}
and this is the web.xml file
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>JAXRSHelloWorldJerseyExample</display-name>

<servlet>
<servlet-name>jersey-serlvet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.mkyong.rest</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>

and i want to merge this HL7 code into my restful web service code:

package ca.uhn.hl7v2.examples;
28
29 import ca.uhn.hl7v2.DefaultHapiContext;
30 import ca.uhn.hl7v2.HL7Exception;
31 import ca.uhn.hl7v2.HapiContext;
32 import ca.uhn.hl7v2.model.v24.message.ADT_A01;
33 import ca.uhn.hl7v2.model.v24.segment.MSH;
34 import ca.uhn.hl7v2.model.v24.segment.PID;
35 import ca.uhn.hl7v2.parser.Parser;
36
37 /**
38 * Example transmitting a message
39 *
40 * @author <a href="mailto:jamesagnew@sourceforge.net">James Agnew</a>
41 * @version $Revision: 1.4 $ updated on $Date: 2009-10-03 15:29:05 $ by $Author: jamesagnew $
42 */
43 public class CreateAMessage
44 {
45
46 /**
47 * @param args
48 * @throws HL7Exception
49 */
50 public static void main(String[] args) throws Exception {
51
52 ADT_A01 adt = new ADT_A01();
53 adt.initQuickstart("ADT", "A01", "P");
54
55 // Populate the MSH Segment
56 MSH mshSegment = adt.getMSH();
57 mshSegment.getSendingApplication().getNamespaceID().setValue("TestSendingSystem");
58 mshSegment.getSequenceNumber().setValue("123");
59
60 // Populate the PID Segment
61 PID pid = adt.getPID();
62 pid.getPatientName(0).getFamilyName().getSurname().setValue("Doe");
63 pid.getPatientName(0).getGivenName().setValue("John");
64 pid.getPatientIdentifierList(0).getID().setValue("123456");
65
66 /*
67 * In a real situation, of course, many more segments and fields would be populated
68 */
69
70 // Now, let's encode the message and look at the output
71 HapiContext context = new DefaultHapiContext();
72 Parser parser = context.getPipeParser();
73 String encodedMessage = parser.encode(adt);
74 System.out.println("Printing ER7 Encoded Message:");
75 System.out.println(encodedMessage);
76
77 /*
78 * Prints:
79 *
80 * MSH|^~\&|TestSendingSystem||||200701011539||ADT^A01^ADT A01||||123
81 * PID|||123456||Doe^John
82 */
83
84 // Next, let's use the XML parser to encode as XML
85 parser = context.getXMLParser();
86 encodedMessage = parser.encode(adt);
87 System.out.println("Printing XML Encoded Message:");
88 System.out.println(encodedMessage);
89
90 /*
91 * Prints:
92 *
93 * <?xml version="1.0" encoding="UTF-8"?>
94 <ADT_A01 xmlns="urn:hl7-org:v2xml">
95 <MSH>
96 <MSH.1>|</MSH.1>
97 <MSH.2>^~\&</MSH.2>
98 <MSH.3>
99 <HD.1>TestSendingSystem</HD.1>
100 </MSH.3>
101 <MSH.7>
102 <TS.1>200701011539</TS.1>
103 </MSH.7>
104 <MSH.9>
105 <MSG.1>ADT</MSG.1>
106 <MSG.2>A01</MSG.2>
107 <MSG.3>ADT A01</MSG.3>
108 </MSH.9>
109 <MSH.13>123</MSH.13>
110 </MSH>
111 <PID>
112 <PID.3>
113 <CX.1>123456</CX.1>
114 </PID.3>
115 <PID.5>
116 <XPN.1>
117 <FN.1>Doe</FN.1>
118 </XPN.1>
119 <XPN.2>John</XPN.2>
120 </PID.5>
121 </PID>
122 </ADT_A01>
123 */
124
125 }
126
127 }


Can you suggest me what i can do to make my program work,also what and all jars are required....

Thanks in advance
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41600
    
  55
It seems you inadvertently created a new topic instead of replying to the original one. I'll close this one; please post this content into the original topic.


Ping & DNS - my free Android networking tools app
 
 
subject: Implementing HL7 messages(HAPI) using restful web services