Help with a program rule

Hi all (again)! J

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’

  1.  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@logicaloutcomes.net | +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@logicaloutcomes.net

Hi there Georgi!
Thanks for the feedback.

It seems you got it almost right except for one little detail on the usage of the substring function.

To get the fifth character you would have to change your expression to:
d2:substring(A{Client ID}, 5, 6) == '2'

There was an error in the doc, so a small update is on the way here:
19.5.6. Reference information: Operators and functions to use in program rule expression <https://docs.dhis2.org/master/en/user/html/dhis2_user_manual_en_full.html#program_rules_operators_functions>

Hope this helps!

Best regards
Markus

···

4. aug. 2017 kl. 17.58 skrev Georgi Chakarov <georgi@logicaloutcomes.net>:

Hi all (again)! J

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@logicaloutcomes.net <mailto:georgi@logicaloutcomes.net> | +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@logicaloutcomes.net <mailto:info@logicaloutcomes.net>

_______________________________________________
Mailing list: https://launchpad.net/~dhis2-users
Post to : dhis2-users@lists.launchpad.net <mailto:dhis2-users@lists.launchpad.net>
Unsubscribe : https://launchpad.net/~dhis2-users
More help : https://help.launchpad.net/ListHelp

Thanks Markus,

I will definitely test this!

Regards,

Georgi

···

From: Markus Bekken [mailto:markus@dhis2.org]

Sent: Tuesday, August 8, 2017 5:40 PM

To: Georgi Chakarov georgi@logicaloutcomes.net

Cc: DHIS Users dhis2-users@lists.launchpad.net; DHIS 2 Developers list dhis2-devs@lists.launchpad.net

Subject: Re: [Dhis2-users] Help with a program rule

Hi there Georgi!

Thanks for the feedback.

It seems you got it almost right except for one little detail on the usage of the substring function.

To get the fifth character you would have to change your expression to:

d2:substring(A{Client ID}, 5, 6) == '2’

There was an error in the doc, so a small update is on the way here:

19.5.6. Reference information: Operators and functions to use in program rule expression

Hope this helps!

Best regards

Markus

  1. aug. 2017 kl. 17.58 skrev Georgi Chakarov georgi@logicaloutcomes.net:

Hi all (again)! J

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’


  1.   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@logicaloutcomes.net | +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@logicaloutcomes.net


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp