Xlate IF statement anomoly

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Xlate IF statement anomoly

  • Creator
    Topic
  • #51897
    Kevin Crist
    Participant

      I have an xlate where i am trying to get an IF statement to work but am having issues.  we have to figure out the age of the patient and we have that working and we have to compare that to the age of 18 and then do something. So if the age is 23 it should do what we want, which that part works, but if the age is 4 then it still treats it as it is greater than 18. i have attached the IF statement. is there any thing i can change for this? we have had it many ways with no luck.

      Thanks.

    Viewing 6 reply threads
    • Author
      Replies
      • #72170
        Andy Triggs
        Participant

          Try using > instead of gt.

          gt does a string comparison.

          > does a numeric comparison.

        • #72171
          Kevin Crist
          Participant

            Andy thanks for the reply. i have tried the > sign but then nothing works at all

          • #72172
            Andy Triggs
            Participant

              It works for me…

              Example in attachment places 18 in AdmissionMethod. If I change the > to gt, it places 4 in there.

            • #72173
              Jim Kosloskey
              Participant

                Kevin,

                On 5.6 Cloverleaf if I want to do that compare as a string but it will actually be numeric data, then I need to be sure the length of the 2 fields are the same. For example 4 is greater than 18 as a string 04 is not greater than 18 as a string.

                However, if you use the numeric Category for the compare then it should not matter.

                I have tested this in 5.6 and the numeric Category works with a temp variable @age being 4 and compared in the IF Action to =18.

                What release of Cloverleaf are you on?

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

              • #72174
                Kevin Crist
                Participant

                  we are on 5.4.1. i am wondering if this may be our issue somehow.

                • #72175
                  Jim Kosloskey
                  Participant

                    Kevin,

                    Hmmm could be.

                    Try using the STRING gt with =04 and =18 and see if that does not work the way you want.

                    If it does, then I would change the Tcl proc to pad the output to 3 characters (or use another proc to pad the temp variable after it is calculated if you have one) with leading zeros and do the compare against 018.

                    That should synch things up for you. The reason for 3 characters is you could get someone a 100 years old or older (but not likely older than 999).

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

                  • #72176
                    John Mercogliano
                    Participant

                      Kevin,

                       Could you show us how you are setting the age variable and a sample of the data that might populate it.  The only time I’ve had problems with the numeric comparision operators was when cloverleaf was not able to convert the data in the variable to a number.

                      John Mercogliano
                      Semi Retired, contractor
                      Hampton Roads, VA

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