Need to check field for alpha characters

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Need to check field for alpha characters

  • Creator
    Topic
  • #52408
    Bonnie Giesler
    Participant

      I’m doing an xlate for lab charges and need to handle the transaction different if PID:3 is a combination of alpha and numeric.  I have tried to do a string match in various formats (more than likely my issue) and map to a temp variable.  

      This is what I have at the moment in xlt:

      set xlateOutVals [string match {[A-Z]} $xlateInVals]

      This is an example of the field. PID:3 can be a combination of any alpha character.  

      0(0).PID(0)  :  >|||NCHG-3||HOUSECONTROL^THREE||19400304|M||||||||||0|< Is there an advanced search for this for site because I sure have a hard time finding anything and I’m sure this is an issue because I’m new to tcl Thanks in advance!

    Viewing 10 reply threads
    • Author
      Replies
      • #74080
        James Cobane
        Participant

          Bonnie,

          You can use the ‘string is’ command to see if a string is of a particular class ( i.e. string is digit ‘12345’ ).  If you check for ‘is digit’ and the string fails, then you know it contains non-numeric characters.

          Hope this helps.

          Jim Cobane

          Henry Ford Health

        • #74081
          Jim Kosloskey
          Participant

            Bonnie,

            Unfortunately the Search we have is what we have.

            A new version of the forum software has been promised but yet to materialize.

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

          • #74082
            Bonnie Giesler
            Participant

              I’ll give string is a try.  

              Jim K.

              I am just whining-appreciate the forum and all the help!

            • #74083
              Jim Kosloskey
              Participant

                Bonnie,

                I know – we all want to see the forum updated  🙂

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

              • #74084
                Jeff Dinsmore
                Participant

                  If you’re using “string is integer”, be aware that it will match true for an empty string unless you use the -strict option.

                  string is integer “”

                  returns 1.

                  string is integer -strict “”

                  returns 0.

                  Jeff Dinsmore
                  Chesapeake Regional Healthcare

                • #74085
                  Bonnie Giesler
                  Participant

                    I ended up using this as inline :  xlateOutVals [string is digit $xlateInVals] to a temp field instead of integer -strict.  

                    When 010001132 was being evaluated with integer -strict it was false and getting a 0 and so the message was processing like a message with this value in PID:3  NCHG-3.

                    Thanks again for everyone’s help.  Wish I would have asked sooner.

                  • #74086
                    Jim Kosloskey
                    Participant

                      Bonnie,

                      You might want to do somehting like this:

                      set xlateOutVals [lreplace $xlateOutVals 0 0  [string is digit [lindex $xlateInVals 0]]

                      This way you are treating both xlateInVals and xlateOutVals as lists which is what they are.

                      The lreplace is only one way of treating xlateOutVals as a list depending on your need other methods may work as well or better.

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

                    • #74087
                      Bonnie Giesler
                      Participant

                        Kind of figured some one would/should indicate the list thing.  I know this is a stupid question (which speaks to my lack of tcl) but what is the purpose of the 0 0 and 0 in this script.  

                        set xlateOutVals [lreplace $xlateOutVals 0 0 [string is digit [lindex $xlateInVals 0]]

                      • #74088
                        Jim Kosloskey
                        Participant

                          lreplace requires that you tell it the starting and ending indexes of the list to replace.

                          In this case the assumption is your Destination panel of the Xlate Action (which is where xlateOutVals references) only contains one list element. Being that lists are zero based referenced (the first element is indexed as 0 (zero)) that particular lreplace usage is saying replace beginning at the first element (0) and end at the first element (0).

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

                        • #74089
                          Bonnie Giesler
                          Participant

                            Never mind.  Got it.

                          • #74090
                            Bonnie Giesler
                            Participant

                              Thanks for the explanation.. it just takes some of us longer.

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