+ inboundHeader.getName() + ")");
// make ACK of correct version
Class<? extends Message> clazz = null;
try {
Message inbound = inboundHeader.getMessage();
Parser p = inbound.getParser();
ModelClassFactory mcf = p != null ? p.getFactory() : new DefaultModelClassFactory();
String version = inbound.getVersion();
if (version == null)
version = "2.4"; // TODO: This should be set dynamically based on available HL7 version
clazz = mcf.getMessageClass("ACK", version, false);
Message out = clazz.newInstance();
Terser terser = new Terser(out);
// populate outbound MSH using data from inbound message ...
Segment outHeader = (Segment) out.get("MSH");
fillResponseHeader(inboundHeader, outHeader);
terser.set("/MSH-9-1", "ACK");
terser.set("/MSH-9-2", Terser.get(inboundHeader, 9, 0, 2, 1));
terser.set("/MSH-12", Terser.get(inboundHeader, 12, 0, 1, 1));