Okay... i don't know if it's a side effect but i have personnal classes like ADT_A05_FR which are just a copies with other segment for the French impl. I change the trigger by adding "_FR" on it and then i do an encode/parse and it result a GenericMessage$V25. that's the full design that work for me... (/this._msg is just a /ca.uhn.hl7v2.model.Message/)/

   /PipeParser p = new PipeParser();
   try {
MSH msh = (MSH) //this._msg//.get("MSH"); msh.getMessageType().getMessageStructure().setValue(msh.getMessageType().getMessageStructure().getValue() + "_FR");
                this._msg = p.parse(p.encode(this._msg));
           } catch (DataTypeException e) {
               e.printStackTrace();
           } catch (EncodingNotSupportedException e) {
               e.printStackTrace();
           } catch (HL7Exception e) {
               e.printStackTrace();
           }

/then the message originally an ADT^A31^ADT_A05 becomes a GenericMessage$V25.

You can replace the "_FR" by anything you want, then the parser can parse the message but can't cast it to a known structure so it is cast to an GenericMessage$V25 wich means unknown.
Don't know if i'm clear enough
Hope it helps...

Lansdale Redmond a écrit :

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]> [mailto:[EMAIL PROTECTED] *On Behalf Of *VIOT Yves
*Sent:* Friday, May 09, 2008 5:05 AM
*To:* clarksonpj
*Cc:* hl7api-devel@lists.sourceforge.net <mailto: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 <mailto: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.

--
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

Reply via email to