Comparison of two fields of type integer in a xform

I am applying a field patient_referred of type integer to this constraint . >= 0 and . <= ${patient_assessed} in a XForm. When patient_assessed >= 10, all value of patient_referred between 1 - 9 are failing the comparison. Am I missing something?

image

3 Likes

The fields were not actually read as integer so I needed to convert them using int().

Replacing the relevant condition with int(${patient_refered}) >= 0 and int(${patient_refered}) <= int(${patient_assessed}) solved the problem.

3 Likes

Thanks for answering your own question! The clue was that numbers less than 10 worked fine which suggested that it was comparing alphabetically rather than numerically. Good find!

1 Like