On Tue, Jun 19, 2007 at 05:21:12AM -0700, granger44 wrote:
>
> fer wrote:
> >
> > Hello, I newbie in HAPI.
> >
> > Any example how to read the segment fields and then its components.
> > I want a solution all version compatible.
> >
> >
>
> I too am looking for something to extract segments from a message regardless
> of version. The closest I've come so far is to encode the message into XML
> and then do some XML/XPath parsing. The big downside is that it's two
> transforms so it's not very scalable; if someone has a quicker solution, I'd
> be very interested.
Since in general all versions are backwards compatible, one approach is to
force the version to a recent one and reparse:
Terser terser = new Terser(msg);
if (!terser.get("/MSH-12").equals("2.5")) {
terser.set("/MSH-12", "2.5");
PipeParser pp = new PipeParser();
msg = pp.parse(pp.encode(msg));
}
This may or may not be faster than the XML/XPath approach, but you get
to use the specific message classes this way and hence you get the
static type checking.
Cheers,
Ronald
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Hl7api-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hl7api-devel