title: Setting fields on a new HL7 Message wrapped in Terser
body: <p>When attempting to use ca.uhn.hl7v2.util.Terser to set empty fields on a given specific subclass of ca.uhn.hl7v2.model.Message (in this case ca.uhn.hl7v2.model.v251.message.ORU_R01), I receive no error messages during the .each{} closure and afterwards the message object has no fields populated.</p>
  
  <p>hl7Map is populated on class instantiation, with  values like: 
  def hl7Map= [ "HL7MessageFields":['PID-3-1':"internal order map key",
                  'PID-3-4':"internal order map key",etc.]]</p>
  
  <p>Code below:</p>
  
  <p>def buildHL7Message(order){</p>
  
  <pre><code>    def date = new Date()
      def format = new SimpleDateFormat(hl7Map["dateFormat"]).format(date)
  
      //Set date on the Message Header Object
      hl7Map["MSH"]["-7"]= format
  
      def message = (context.getModelClassFactory().getMessageClass(hl7Map["MessageInstantiationMap"]["messageType"],
                                                                      hl7Map["MessageInstantiationMap"]["version"],
                                                                      true) as Class).newInstance()
      Terser terser = new Terser(message)
  
      hl7Map["HL7MessageFields"].each{
          terser.set(it.key, order[it.value])
      }
  
      println message
  
      return message
  </code></pre>
  
  <p>}</p>
  
  <p>The end of method results in no output and error logged about encoding, MSH-1 is a required field, pipe delminator but is empty. If the code above uses message.initQuickstart("ORU", "R01", "T"), only the default initQuickstart fields are populated.</p>
  
  <p>If hl7Map["HL7MessageFields"] contains a 'it.key' that is not a valid Group/Segment field, an error is logged by terser that it failed to find the value, the above code with a properly formatted map does not cause an error.</p>
  
  <p>Can anyone help explain why I am not receiving errors yet my message is empty, and help me to populate the message with the appropriate terser.set(params)?</p>