Help – repeating field ~ question

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Help – repeating field ~ question

  • Creator
    Topic
  • #54334
    Shu Chen
    Participant

      hi clovertech,

      I need to do some logic for PID:3 repeating field and wondering if it could be done in xlate or not.

      if the first repeating field is empty, I need shift entire field value up or remove the the first repeating field

      input value :

      PID:3|~AA^^^^MR~BB^^^^PI~CC^^^ON^HCN|

      expected value:

      PID:3|AA^^^^MR~BB^^^^PI~CC^^^ON^HCN|

      my current irerate setup

      thank you for your help !!!!!!!!!!!

    Viewing 6 reply threads
    • Author
      Replies
      • #81045
        Jim Kosloskey
        Participant

          You will need to utilize your own counter for the outbound (use something like %f99). Before your IF initialize the %f99 to 0 using a COPY Action:

          =0 –> $%f99

          With an IF Action check to see if a component you know is always populated if a field repetition is populated is equal to null. Check only the first repetition.

          If the result is true –

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

        • #81046
          Robert Kersemakers
          Participant

            Hi Shue/Jim,

            While Jim’s solution will definitely work, I am wondering if it wouldn’t be easier/quicker to do this with a bit of tcl.

            COPY 1(0).0(0).PID(0).#3 -> 1(0).0(0).PID(0).#3

            Code:

            lassign $xlateInVals field
            # split field on ~
            set subfields [split $fields ~]
            # remove the first subfield if empty
            if {![string length [lindex $subfields 0]] > 0} {
             lvarpop subfields 0
            }
            # rejoin the subfields to one field
            set field [join $subfields ~]
            set xlateOutVals [list $field]

            Haven’t tested this, but it should work.

            Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

          • #81047
            Shu Chen
            Participant

              hi jim and robert.

              thanks for you reply. worked great!!!!

            • #81048
              Anonymous

                Robert, have you used that COPY to get all of the repeats into xlateInVals? I have tried, but I only get the first one. At least that’s what happens with the Test Tool.

                I haven’t been able to pass all of the PID:3 repeats into a PRE proc. PATHCOPY will move them all from Input to Output, but that doesn’t allow me to use a PRE proc.

                Thanks

              • #81049
                Robert Kersemakers
                Participant

                  Hi David,

                  As said, I hadn’t tested this. But now I got curious and did a small test and you are right: it doesn’t work.

                  With PATHCOPY, you can’t use a piece of tcl code.

                  COPY 1(0).0(0).PID(0).#3 will only give you the first iteration and COPY 1(0).0(0).PID(0).#3(0) will also give the first iteration. So with a COPY you can never have all iterations.

                  So I was wrong: you will need to iterate through all iterations as Jim explained. Although I wonder why with 1(0).0(0).PID(0).#3 you only get the first iteration…

                  Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

                • #81050
                  Anonymous

                    Thanks, I’ve been trying to figure out how to do this for a long time, and I was hoping you had unlocked the mystery.

                  • #81051
                    Terry Kellum
                    Participant

                      I do something similar, but realizing that the same interpreter is used for the XLATE TCL Fragments, I put the split values in an array.  In later translate items, I can use TCL to query that array for the correct values.  (AN, MR, Etc.)

                      If you use variables in TCL like this, it’s IMPERATIVE to set those variables to nothing at the start of your translate.

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