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?



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.


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