Still didn't work for me. After parsing the message, I call getNames() and it
returns all the segments..If I don't parse the message then how would it know
which message structure to use? Below is a sample of what Im doing..
Here is my method
parser = new GenericParser() ;
hapiMessage = parser.parse(adt1);
public String[] getSegments() throws HL7Exception{
return ((ca.uhn.hl7v2.model.Message)hapiMessage).getNames();
}
My message
String adt1 = MSH|||||||||
PID||||||||||||||||||||||||||||||
PV1||||||||||||||||||||||||||||||||||||
GT1||||||||||||||||||||||||||||||||||||||
________________________________
From: VIOT Yves [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 13, 2008 4:09 AM
To: Lansdale Redmond
Cc: clarksonpj; hl7api-devel@lists.sourceforge.net
Subject: Re: [HAPI-devel] How to check if a segmen tis present in a message
That's very stange because it works very well for me...
Do you apply the getNames() on a
ca.uhn.hl7v2.model.Message
or on a
for example : ca.uhn.hl7v2.model.v25.message.ADT_A09
Maybe, as the message structure is known, in the second one, it returns the
segments that should be found in the message, but in the first the structure is
unknown so it can just return what's really in the message. Try a cast to a
"Message" you'll see...
Lansdale Redmond a écrit :
Thanks..but getNames() returns all the segments that should exists in the
message..not what is currently present in the message. Calling getNames on an
ADT message returned the following structures
MSH,EVN,PID,,PD1NK1,PV1,PV2,DB1,OBX,AL1,DG1,DRG,PR1ROL,GT1,IN1IN2IN3,ACC,UB1,UB2
and my message only had MSH and PID.
________________________________
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of VIOT Yves
Sent: Friday, May 09, 2008 5:05 AM
To: clarksonpj
Cc: hl7api-devel@lists.sourceforge.net
Subject: Re: [HAPI-devel] How to check if a segmen tis present in a message
Hi,
One way, but perhaps not the best (???), could be this:
String[] segNames = hapiMessage.getNames();
Then jsut browse your string array to find if your seg exists
Hope it helps
Bye
clarksonpj a écrit :
Great question, I would also like to know if there is a way of doing this.
Right now I need to check each element for null.
Lansdale Redmond wrote:
How can I check if a segment is present in a message..when I do the
following code it always returns a value then if I read a field the vlue
is null..very similar to if it was there...how do you know the
difference
PID seg = (PID) hapiMessage.get("PID");
if ( seg == null)
return false;
else
return true;
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hl7api-devel
:-)
--
Yves VIOT
C.S.I.S.
130 rue Eugene POTTIER
35200 RENNES
Mail :[EMAIL PROTECTED]
T(Direct) :0952-170-963 (non surtaxé)
T(Siège) :02-23-35-43-55
F(Siège) :02-23-35-43-56
________________
CONFIDENTIALITE : Ce message et les éventuelles pièces attachées sont
confidentiels. Si vous n'êtes pas dans la liste des destinataires, veuillez
informer l'expéditeur immédiatement et ne pas divulguer le contenu à une tierce
personne, ne pas l'utiliser pour quelque raison que ce soit, ne pas stocker ou
copier l'information qu'il contient sur un quelconque support.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hl7api-devel