Hi Mark,

MSH-9 is slightly misformatted - this causes HAPI to skip creating the MSH
segment and therefore no MFN_M15 but a ca.uhn.hl7v2.model.GenericMessage$V25
is created and you get the ClassCastException.

Simply replace |MFN^M15^MFN M15| with |MFN^M15^MFN_M15| (note the underscore
instead of the space) and everything works.

cheers
Christian


Mark_Huang wrote:
> 
> I am new to HAPI API, and try to get the repetitions of MF_INV_ITEM of
> MFN_M15 message.
> 
> 1. Message: 
> MSH|^~\\&|TestSendingSystem||||201001011539||MFN^M15^MFN
> M15|Ctl#0001||2.5|123
> SFT|GA Public Health^^1
> MFI|Identifier1^identifier the coded element||2|||1
> MFE|0
> IIM|Mask^Mask used for protection|Mask V2|Lot 001||||||||20100120|300
> MFE|1
> IIM|Mask^Mask used for protection2|Mask V22|Lot 003||||||||20100120|280
> 
> 2. Code:
> 
> Parser p = new PipeParser();
> Message hapiMsg = p.parse(msg);
> 
> ///// Testing message type and event trigger --------------- 
> System.out.println(hapiMsg.getMessageType().getMessageCode().getValue());  
> // display: MFN 
> System.out.println(hapiMsg.getMessageType().getTriggerEvent().getValue());   
> // display: M15 
> ///// End ------------------------------------------------- 
> 
> MFN_M15 m15 = (MFN_M15) hapiMsg;    //FAILED HERE: ClassCastException
> 
> int totalRepeats = m15.getMF_INV_ITEMReps() 
> 
> Exception in thread "main" java.lang.ClassCastException:
> ca.uhn.hl7v2.model.GenericMessage$V25 cannot be cast to
> ca.uhn.hl7v2.model.v25.message.MFN_M15
> 
> I am planning to get the repetitions by calling
> MFN_M15.getMF_INV_ITEMReps() method, but unfortunately I failed during the
> converting from hapiMsg to MFN_M15 message.
> 
> Any suggestion on this?
> 
> Thanks,
> 
> Mark
> 

-- 
View this message in context: 
http://old.nabble.com/HELP%3A-how-to-get-the-number-of-repetitions-for-MFN_M15-tp28682339p28831081.html
Sent from the hl7api-devel mailing list archive at Nabble.com.


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Hl7api-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Reply via email to