← Back to team overview

dhis2-users team mailing list archive

Help with a program rule

 

Hi all (again)! :)

I have a challenging task for whoever is interested. I find it quite difficult working with the functions in program rules expression, especially learning from the user manual.

I am trying to execute the following rule:
If the fifth character of Client ID (text attribute) is equal to '2', the Sex (Option set attribute) should be equal to 'Female'. This is an example of client ID: 111121111.

This is what I think:

1)      I need to extract the fifth character and evaluate whether it equals '2'. I am using d2:substring(text, start-char-num, end-char-num)
This is my expression d2:substring(A{Client ID}, 5, 5) == '2'


2)      I need to push 'Female' option to the Sex attribute. I am not sure how to do that from the program rule actions. I tried:

a)       Assign value to Sex attribute - expression is 'Female'

b)      Assign value to Sex attribute - expression is A{Sex} == 'Female'

None of the combinations 1) + 2a) OR 1) + 2b) worked, regretfully.

Does any of you know or can figure out how this might work?

Regards,

Georgi



Georgi Chakarov, CIA | georgi@xxxxxxxxxxxxxxxxxxx<mailto:georgi@xxxxxxxxxxxxxxxxxxx> | +1-647-478-5634 x 104 | LogicalOutcomes c/o Centre for Social Innovation, 720 Bathurst Street, Toronto Canada M5S 2R4 | You may unsubscribe from receiving commercial electronic messages from LogicalOutcomes by emailing info@xxxxxxxxxxxxxxxxxxx<mailto:info@xxxxxxxxxxxxxxxxxxx>


Follow ups