xlate – selecting the first instance of a repeating value

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf xlate – selecting the first instance of a repeating value

  • Creator
    Topic
  • #52233
    Tom Arrowsmith
    Participant

      I am working on a physician update interface (sending system is Morrisey’s MSOW) that presents a challenge to me – I have identified, with the help of users on this forum, some potential solutions that would involve customization by Morrisey of their HL7 out – and which, of course, would involve cost to us.

      Before I pursue that I want to check with this forum to see if anyone could tell me if it’s possible to identify the first instance within the repetitions in the field that contained a value which subsequent repetitions may also contain.

      Here’s an example of the STF-10 which lists phone numbers for the practitioner:

      |703) 359-8640^^CO~VSA^^^^^^(703) 359-8640^^CO~VSA^^^^^^(703) 359-8640^^CO~VSA^^^^^^(703) 359-8640^^CO~VSA^^^^^^(703) 359-8640^^CO~VSA^^^^^^(703) 359-8640^^CO~^^^^^^(703) 359-8640^^CO~^^^^^^(703) 359-8640^^CO~^^^^^^(703) 591-6104^^CF~VSA^^^^^^(703)259-6333^^CF~VSA^^^^^^(703) 259-6333^^CF~VSA^^^^^^(703) 591-6105^^CF~VSA^^^^^^(703) 591-6105^^CF~VSA^^^^^^(703) 591-6105^^CF~^^^^^^(703) 591-6104^^CF~^^^^^^(703) 591-6104^^CF~^^^^^^(703)620-4374&U^703-0000&U^CH~^^^^^^83708^^CP|

      The MSOW spec states that the Office numbers will be identified as “CO” and the Fax numbers will be identified as “CF”. The spec also states that the first occurance of the “CO” value will be the “primary” office phone number and then will follow any number of other repetitions with a “CO” value. Then, the first occurance of a “CF” value would be the primary fax number – followed by any number of other repetitions with a “CF” identifier.

      The problem is that each practitioner may have a different number of office phone numbers and/or fax numbers – so it will never be possible to identify a discreet iteration instance that the fax number will come in – plus the “CF” identifier is not unique.

      So my question is this: Is there a way, while iterating, to find the “first” (and only the first) instance of the “CF” identifier and then be able to copy that phone number to a well deserved home in the outbound message?

      If there is, please let me know.

      If there is not, we will pay extra money to get a unique identifier to appear where we need it.

      Thanks!

      Tom Arrowsmith

    Viewing 3 reply threads
    • Author
      Replies
      • #73514
        David Harrison
        Participant

          Just a thought, and I haven

        • #73515
          Keith McLeod
          Participant

            You could do something like append the CO value to a list after the first iteration and then use depending on your version of cloverleaf use a statement like:

            set your_list {ZZ} —Before Iterate

            lappend your_list value — after iterate

            if {![lcontains $list $value]} {

            copy $value to your special place

            }

            Just an idea of where you copy only if not found in your_list.

          • #73516
            Robert Kersemakers
            Participant

              Or you can initialize a variable and inside the iteration check whether the variable is still initial AND subfield 3 is equal ‘CF’. If so: fill the variable with phone number, so the variable is no longer initial.

              After the iteration, the variable will be filled with the phone number of the first CF-occurrence, or it will still be initial if there is no CF.

              If you would like to consider performance, you could take the complete field as input. Then with tcl split the field on ‘~’ and do a FOREACH on the list of occurrences. Split each occurrence on ‘^’ and check if subfield 3 is ‘CF’. If so: put the phone number into a variable and do a BREAK to abort the FOREACH.

              Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

            • #73517
              Tom Rioux
              Participant

                My question is that if all you want out of that long string is just the first CF, why iterate if you don’t have to.   See if this will work for you:

                set sft10 [lindex $xlateInVals 0]

                set sft_flds [split $sft10 ~]

                set first_CF [lsearch -regexp -inline $rep {(CF)$}]

                **This should give you your first CF:  ^^^^^^(703) 591-6104^^CF**

                Then split on the caret and grab your fax number:

                set faxnum [lindex [split $first_CF ^] 6]

                Hope this helps…

                Tom Rioux

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