Hi Sanjay,
I have the same problem.
ca.uhn.hl7v2.model.Message has no method to get the MSH segment until
you cast it to ADT_A01 ...
I found 3 ways to identify the message type :
* use reflection to invoke getMSH(), again to invoke
getMessageType(), and again for methods getMessageStructure() and
getTriggerEvent().
* use Terser :
Terser t = new Terser(message);
String triggerEvent = t.get("/MSH-9-2");
String messageStructure = t.get("/MSH-9-3");
Then you just need to write a long list of if(
"ADT....".equals(messageStructure) ) .....
* write the long list of if( message instance of ADT_...) ...
Hope it helps
Gabriel
2012/3/15 Sanjay Bhandari <[email protected]>:
> I'm trying to figure out what is the normal way of casting a incoming
> message to the appropriate type.
>
> Specifically, if I register for messages with:
>
> server.registerApplication("*", "*", handler);
>
>
> I see the following:
>
> MSH -> getMESSAGETYPE() -> getMessageType() -> getValue()
>
> Is this what I switch on, and cast? Or is there another preferred way?
>
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> Hl7api-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/hl7api-devel
>
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Hl7api-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hl7api-devel