This topic contains 3 replies, has 4 voices, and was last updated by  Jeff Drumm 4 years, 4 months ago.

Making a segment optional programmatically

  • Hello, I am very new to using Iguana and Chameleon. Not sure if this is the right place for this question however I am trying to make a few segments required based on a value in a previous segment. We are using iguana to parse HL7 message into a database. We get messages that are either a charge or a payment. If the message is a charge, we need certain segments required while they are only optional when a payment message comes thru. If anyone can provide me guidance I would appreciate it.

    Is any reason that you need to make those segments required?
    You can always enforce them inside the translator.


    In Chameleon, you can model different types of messages. Each type of message can have different rules about which segments are optional. Each message type is usually defined by some value in one of the fields — typically MSH.9 but you have many options on which fields to use, so you could test for a value in any field. (Read more about message definitions here.)

    When you define message structure syntax rules in the VMD you export from Chameleon, Iguana will automatically generate a list of validation conflicts when you parse the message. You can capture these errors and log them or create some other workflow to handle that message.

    Alternatively, you can create VMDs in Chameleon that enforce no required segments and no particular segment order. Then you can use Lua scripting logic to test validation rules rather than leverage Chameleon validations. Customers will often use this approach when they want to reuse a more generic VMD across all their interfaces.

    You should be able to pursue either strategy and get the job done.

    Casey Trauer,
    Director, Client Education

    I’ll add that, if the intent of the validation is to report validation success or failure back to the sending system, you can use an ACK type of “Translator” to accomplish this.

    In the ACK translator, create the logic to validate the message and build either an ACK or NAK message based on the evaluation. Then call ack.send(arg) with the ACK/NAK message as the argument.

    There’s a great tutorial/reference on ACK/NAK messages here.

    Jeff Drumm ◊ VP and COO ◊ HICG, LLC. ◊


You must be logged in to reply to this topic.