Class NakFactory<AuditDatasetType extends MllpAuditDataset>

java.lang.Object
org.openehealth.ipf.commons.ihe.hl7v2.NakFactory<AuditDatasetType>
Direct Known Subclasses:
QpdAwareNakFactory

public class NakFactory<AuditDatasetType extends MllpAuditDataset> extends Object
Basic ACK and NAK factory for HL7v2-based transactions.
Author:
Dmytro Rud
  • Constructor Details

    • NakFactory

      public NakFactory(Hl7v2TransactionConfiguration<AuditDatasetType> config, boolean useCAckTypeCodes, String defaultNakMsh9)
      Generic constructor.
      Parameters:
      config - Configuration of the transaction served by this factory.
      useCAckTypeCodes - if true, HL7v2 acknowledgement codes CA, CE, CR will be used instead of the default AA, AE, AR.
      defaultNakMsh9 - desired contents of MSH-9 in this transaction's default NAKs.
    • NakFactory

      public NakFactory(Hl7v2TransactionConfiguration<AuditDatasetType> config)
      Short constructor which corresponds to NakFactory(config, false, "ACK").
      Parameters:
      config - Configuration of the transaction served by this factory.
  • Method Details

    • createAck

      public Message createAck(Message originalMessage) throws HL7Exception, IOException
      Generates a transaction-specific HL7v2 ACK response message on the basis of the original HAPI request message.
      Parameters:
      originalMessage - original HAPI request message.
      Throws:
      HL7Exception
      IOException
    • createNak

      public Message createNak(Message originalMessage, HL7Exception exception, AcknowledgmentCode ackTypeCode) throws HL7Exception, IOException
      Generates an HL7v2 NAK response message on the basis of the thrown exception and the original HAPI request message.
      Parameters:
      exception - thrown exception.
      originalMessage - original HAPI request message.
      ackTypeCode - HL7v2 acknowledgement type code.
      Throws:
      HL7Exception
      IOException
    • createNak

      public Message createNak(Message originalMessage, Throwable t) throws HL7Exception, IOException
      Generates an HL7v2 NAK response message on the basis of the thrown exception and the original HAPI request message.
      Parameters:
      t - thrown exception.
      originalMessage - original HAPI request message.
      Throws:
      HL7Exception
      IOException
    • createDefaultNak

      public Message createDefaultNak(HL7Exception e)
      Generates a "default" HL7v2 NAK message on the basis of the thrown exception.
      Parameters:
      e - thrown exception.
    • getHl7Exception

      protected HL7Exception getHl7Exception(Throwable t)
      Returns a HL7v2 exception that corresponds to the given instance of Throwable.
    • getAckTypeCode

      protected AcknowledgmentCode getAckTypeCode(Throwable t)
      Returns a HL7v2 acknowledgement type code that corresponds to the given instance of Throwable.
    • formatErrorMessage

      public static String formatErrorMessage(Throwable t)
      Formats and returns error message of an exception.

      In particular, all line break characters must be removed, otherwise they will break the structure of an HL7 NAK.

      Parameters:
      t - thrown exception.
      Returns:
      formatted error message from the given exception.
    • getConfig

      Returns configuration of the transaction served by this factory.