Related to the previous issue, I get an exception when casting down to my
object which extends the MFN_M01 message. I am extending MFN_M01 because this
is specified in the message type field, so I'm unable to avoid it. I am using
the v25 libraries and JDK1.7
Exception in thread "main" java.lang.ClassCastException:
ca.uhn.hl7v2.model.v25.message.MFN_M01 cannot be cast to
com.msh.bgapp.hl7.custommodel.v25.message.PFM
at com.msh.bgapp.hl7.custommodel.v25.message.PFM.main(PFM.java:106)
String HDR="MSH|^~\\&|DSF||Vendor||20150926151426||MFN^M01|610-100672|P|2.5\r"
public class PFM extends MFN_M01 {
private static final long serialVersionUID = -6182782287494872212L;
public PFM(ModelClassFactory theFactory) {
super(theFactory);
init(theFactory);
}
private void init(ModelClassFactory factory) {
try {
this.add(MSH.class, true, false);
this.add(MFI.class, false, false);
this.add(MFE.class, false, false);
} catch(HL7Exception e) {
log.error("Unexpected error creating PFM ,e);
}
}
public MSH getMSH() {
return getTyped("MSH", MSH.class);
}
public ZRQ getZRQ() {
return (ZRQ)getTyped("ZRQ", ZRQ.class);
}
public String getVersion() {
return "2.5";
}
public static void main(String[] args) throws DataTypeException,
HL7Exception, IOException {
String
HDR="MSH|^~\\&|DSF||Vendor||20150926151426||MFN^M01|610-100672|P|2.5\r"
+"MFI|ZBM||UPD|20150917172522|20150917172522|AL\r"
+"MFE|MAD|610-100672|20150917172522|610-100672|CE\r"
ModelClassFactory cmf = new
CustomModelClassFactory("com.msh.bgapp.hl7.custommodel");
@SuppressWarnings("resource")
HapiContext context=new DefaultHapiContext(cmf);
Parser parser = context.getPipeParser();
PFM o=(PFM)parser.parse(HDR);
}
}
------------------------------------------------------------------------------
_______________________________________________
Hl7api-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hl7api-devel