Adding Information with TCL to a Repeating Field

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Adding Information with TCL to a Repeating Field

  • Creator
    Topic
  • #50185
    Darren Tomlinson
    Participant

    i am attempting to add info into a OBX5.  the field has multiple repetitions.  i am trying to do in in a copy using tcl, but i cannot figure out how to get all the repetitions into the xlate tcl proc at once along with the other fields that i need.  i am doing something like…

    COPY

    source                     destination

    MSH4                       OBX5

    PID3

    OBX5

    i want the result to look something like

    MSH4~random text~PID3~random text~OBX5.0~OBX5.1~random text~OBX5.2

    my problem is i do not know ahead of time how many repetitions of obx5 there will be.

Viewing 1 reply thread
  • Author
    Replies
    • #65140
      Robert Milfajt
      Participant

      If you want to do this via an Xlate, I would suggest something like this:

      Code:


      COPY @null->@text
      ITERATE (over OBX.5 as field with %f1 variable)
              CONCAT @text OBX.5(%f1) =any other text you want -> @text
                      (use ~ as separator)
      CONCAT MSH.4 =random text PID.3 =random text @text -> OBX.5
              (use ~ as separator)

      Otherwise, do it in a post-Xlate or SMS OB TCL proc.

      Hope this helps,

      Robert Milfajt
      Northwestern Medicine
      Chicago, IL

    • #65141
      Jim Kosloskey
      Participant

      Darren,

      To count the number of repetitions in any repeating ele4ment (segment, group, field, list) simply have an ITERATE with a MATH ADD Action inside that adds to your own counter (a temp field @).

      At the end of that ITERATE you have a total of the number of repeating elemnts.

      Yopu can ITERATE over that element set as many times as you need to accomplish your goals.

      To accomplish your specific goal, the knowledge that you can maintain your own iteration counter (say %f99) may help.

      So you could do something like :

      MATH ADD $%f99 =1 —> $%f99

      COPY MSH-4 —> OBX-5(%f99)

      MATH ADD $%f99 =1 —> $%f99

      COPY =random text —> OBX-5(%f99)

      MATH ADD $%f99 =1 —> $%f99

      COPY PID-3 —> OBX-5(%f99)

      MATH ADD $%f99 =1 —> $%f99

      COPY =random text —> OBX-5(%f99)

      I suppose you will use some sort of condition to determine where inside the OBX-5 set to add other data. That would be inside an ITERATE over the OBX-5 field (using something other than %f99 – say %f1 in the ITERATE configuration and in the inbound address path and still using %f99 for the outbound address path remembering to manage your %f99 counter with MATH Actions as appropriate.

      Note the $%xnn (in this case $%f99) is used when you want to directly reference the counter (such as in a MATH ACTION or a COPY Action or a CONCAT Action, etc.). The %xnn (no $ such as %f99) is used within an address path to indicate repetition.

      If you would like more clarification contact me via email.

      email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

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

Forum Statistics

Registered Users
5,126
Forums
28
Topics
9,297
Replies
34,440
Topic Tags
287
Empty Topic Tags
10