Error when using split and lindex commands

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Error when using split and lindex commands

  • Creator
    Topic
  • #52352
    John Calhoun
    Participant

      I’m sending in the following field to a preproc in a translation:

      ^^^MRILUSPWWO^MRI- Lumbar Spine W/ & W/O Contrast

      My tcl is trying to split the fifth subfield on the dash (-) and return the “MRI”:

      set xlateOutVals [lindex [split $xlateInVals -] 0]

      But I’m getting the following error when trying to pull the index of 0:

      MESSAGE 1

      [0:TEST] QDX_Tcl_SplitList({MRI) failed: unmatched open brace in list

      Internal XPM Tcl error

      erroCode: NONE

      errorInfo:

      can’t unset “Hl7FieldsLoaded(2)”: no such element in array

         while executing

      “unset Hl7FieldsLoaded($iokey) “

      If I change the index to 1 instead of 0, it works and pulls the word “Lumbar”.

      Any ideas?

    Viewing 1 reply thread
    • Author
      Replies
      • #73889
        Jim Kosloskey
        Participant

          John,

          I think you have your lindex out of place.

          Try this:

          set xlateOutVals [lreplace $xlateOutVals 0 0 [split [lindex $xlateInVals 0] -] ]

          You need to extract the list element from xlateInVals inside the split.

          Also note I used an lreplace which may or may not fit in your case but the point is that xlateOutVals is also a list and should be treated as such.

          But you have another issue and that is the text from the inbound component could have a sub-component separator in it. I say could because I don’t see the MH-2. If the & is in the MSH-2 field, then the component being seen by your proc is incomplete in the first element (it will end at the space before the &).

          Also be aware the split produces lists (in this case 2) from the string and the xlateOutVals is a list which now will have 2 elements I think so that may not give you what you want if you are putting out one component (which is likely).

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

        • #73890
          John Calhoun
          Participant

            That fixed it!  Thanks!!!

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