NTE Segments & Appending a value

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf NTE Segments & Appending a value

  • Creator
    Topic
  • #52955
    Femina Jaffer
    Participant

      Hello Clovertechers…

      I am in need of your assitance again..  This one has been quite a challenge for me.

      I have an incoming ORM message with NTE’s and multiple notes.  I need to append a value to each NTE segment in the first part of the NTE 3 field based on a condition – for example if TEMP is found more then once do the following.  

      See Example below incoming and outgoing message.

      Incoming Message looks like this..

      NTE|1||TEMP: Room Temperature

      NTE|2||SOURCE: Hand

      NTE|3||NOTES: First

      NTE|4||SPECIMEN SITE: Thumb

      NTE|5||TEMP: Room Temperature

      NTE|6||SOURCE: Hand

      NTE|7||NOTES: Second

      NTE|8||SPECIMEN SITE: dorsal hand

      NTE|9||TEMP: Room Temperature

      NTE|10||SOURCE: Hand

      NTE|11||NOTES: Third

      NTE|12||SPECIMEN SITE: middle hand

      Should look like this:

      NTE|1||TEMP1: Room Temperature

      NTE|2||SOURCE1: Hand

      NTE|3||NOTES1: First

      NTE|4||SPECIMEN SITE1: Thumb

      NTE|5||TEMP2: Room Temperature

      NTE|6||SOURCE2: Hand

      NTE|7||NOTES2: Second

      NTE|8||SPECIMEN SITE2: dorsal hand

      NTE|9||TEMP3: Room Temperature

      NTE|10||SOURCE3: Hand

      NTE|11||NOTES3: Third

      NTE|12||SPECIMEN SITE3: middle hand

      Thank you,

      Femina

    Viewing 3 reply threads
    • Author
      Replies
      • #76050
        Eric Fortenberry
        Participant

          You should be able to use an array in TCL to keep up with the current counter for each label in your NTE segments.

          Try this.

          https://gist.github.com/1879725

        • #76051
          Jim Kosloskey
          Participant

            Femina,

            If TEMP only occurs once is it OK for the single TEMP to be changed to TEMP1, etc.?

            Can there be other values besides the values you show or is there always at least one TEMP?

            Most of this probably can be done within an Xlate with little Tcl – depending on the answers to the above questions.

            email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 60 years IT – old fart.

          • #76052
            Femina Jaffer
            Participant

              Thank you Eric!  Your script did the job.  A little challenging for me as I had not used the array{} in tcl until now, didn’t even know it exisited.

              Thanks again!

              Jim,

              Thank you too!  I still would like to know how this could have been done in the xlate.  Yes, you can number the first TEMP found to TEMP1.

              Thanks again all of you!

            • #76053
              Robert Kersemakers
              Participant

                Assuming there is always a TEMP at the start of a repetition (you need to know when a group starts), you can do it like this in an Xlate:

                Code:

                Set a variable (@counter) to zero
                Iterate through your NTE segments
                 Check if the first part of NTE-3 is TEMP; if so: increase @counter
                 Add @counter to the first part of NTE-3 and write it to outbound message

                That should do it.

                Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

            Viewing 3 reply threads
            • The forum ‘Cloverleaf’ is closed to new topics and replies.