I'm new to hapi, and am trying to check the ACK response from having sent a
message. The message is received properly, and the response appears well
formed, however when I attempt to parse the ACK message, it's being
interpreted as the type of the original message. (NB: The original message,
as well as the response, are generated by HL7 Soup)

final Message response = initiator.sendAndReceive(message);

// Convert message into most recent version format, since they're backwards
// compatible
final HapiContext versionedContext = new DefaultHapiContext();
final CanonicalModelClassFactory modelClassFactory = new
CanonicalModelClassFactory("2.8.1");
versionedContext.setModelClassFactory(modelClassFactory);
final Message versionedResponse =
versionedContext.getPipeParser().parse(response.toString());
if (!(versionedResponse instanceof ACK)) {
    final String errorMessage = String.format("Response invalid message
type;\n  expected %s\n  found %s:\n%s",
          ACK.class.getName(), versionedResponse.getClass().getName(),
HL7Utils.forPrinting(versionedResponse));
    recordSendAttempt(hl7DestinationInfo, false, errorMessage);
}


results in

Error sending hl7 message with id '8': Response invalid message type;
  expected ca.uhn.hl7v2.model.v281.message.ACK
  found ca.uhn.hl7v2.model.v281.message.MDM_T01:
MSH|^~\&|HL7Soup|Instance2|HL7Soup|Instance1|200911021022||ACK^T01^MDM_T01|64322|P|2.5.1
MSA|AA|64322

Can anyone point out what I'm doing wrong?

Thanks,
Andrew

>
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Reply via email to