Hello Everyone,
I am encountering an issue with program rules in DHIS2.40.4.1. The program rules described below function correctly within the UI but fail during data synchronization from one DHIS2 instance to a parent instance. The error messages are provided at the end of this post.
The errors seem to be related to data type handling. Specifically, the program rules check a value against an empty string (= ''
), which appears to cause issues during synchronization. If I modify the program rule to use !d2:hasValue()
, it works during sync but breaks the UI for users during data entry.
It appears that DHIS2 implements these conditions differently in the UI and during synchronization.
What would be the recommended workaround for this issue?
The program Rule
- (#{ITFC_WAZ_CV} != ‘’ && #{ITFC_WAZ_CV} < -3) || (#{ITFC_WHZ_CV} != ‘’ && #{ITFC_WHZ_CV} < -3)
- (#{ITFC_WAZ_CV} >= -3 && #{ITFC_WAZ_CV} < -2 && (#{ITFC_WHZ_CV} == ‘’ || #{ITFC_WHZ_CV} >= -3)) || (#{ITFC_WHZ_CV} >= -3 && #{ITFC_WHZ_CV} < -2 && (#{ITFC_WAZ_CV} == ‘’ || #{ITFC_WAZ_CV} >= -3))
- (#{ITFC_WAZ_CV} >= -2 && (#{ITFC_WHZ_CV} == ‘’ || #{ITFC_WHZ_CV} >= -2)) || (#{ITFC_WHZ_CV} >= -2 && (#{ITFC_WAZ_CV} == ‘’ || #{ITFC_WAZ_CV} >= -2))
The error
NB. looks like DHIS2 implements this differently in these two modules.
- Rule:
[A.9.7] ITFC - WAZ/WHZ: Assign value to WAZ/WHZ on admission - Case MAM
(ID:yQlnVlbznwR
)- Condition:
((#{ITFC_WAZ_CV} >= -3 && #{ITFC_WAZ_CV} < -2 && (#{ITFC_WHZ_CV} == '' || #{ITFC_WHZ_CV} >= -3)) || (#{ITFC_WHZ_CV} >= -3 && #{ITFC_WHZ_CV} < -2 && (#{ITFC_WAZ_CV} == '' || #{ITFC_WAZ_CV} >= -3)))
- Error:
Failed to coerce value 'null' () to Boolean: empty String in expression: #{ITFC_WAZ_CV} == ''
- (Source:
RuleConditionEvaluator.java [http-nio-8080-exec-147]) IDgln1fiUoEIccnmGlykLwS7VjtPjJV4j1iQT3Qe05nR8=
- Condition:
- Rule:
[A.9.6] ITFC - WAZ/WHZ: Assign value to WAZ/WHZ on admission - Case SAM
(ID:sVgAa8VfNhE
)- Condition:
((#{ITFC_WAZ_CV} != '' && #{ITFC_WAZ_CV} < -3) || (#{ITFC_WHZ_CV} != '' && #{ITFC_WHZ_CV} < -3))
- Error:
Failed to coerce value 'null' () to Boolean: empty String in expression: #{ITFC_WAZ_CV} != ''
- (Source:
RuleConditionEvaluator.java [http-nio-8080-exec-147]) IDgln1fiUoEIccnmGlykLwS7VjtPjJV4j1iQT3Qe05nR8=
- Condition:
- Rule:
[A.9.8] ITFC - WAZ/WHZ: Assign value to WAZ/WHZ on admission - Case Normal nutritional status
(ID:gBe8JNT3Ok4
)- Condition:
((#{ITFC_WAZ_CV} >= -2 && (#{ITFC_WHZ_CV} == '' || #{ITFC_WHZ_CV} >= -2)) || (#{ITFC_WHZ_CV} >= -2 && (#{ITFC_WAZ_CV} == '' || #{ITFC_WAZ_CV} >= -2)))
- Error:
Failed to coerce value 'null' () to Boolean: empty String in expression: #{ITFC_WAZ_CV} == ''
- (Source:
RuleConditionEvaluator.java [http-nio-8080-exec-147]) IDgln1fiUoEIccnmGlykLwS7VjtPjJV4j1iQT3Qe05nR8=
- Condition:
- Rule:
[A.9.9] ITFC - WAZ/WHZ: Assign value Unknown to WAZ/WHZ on admission - Case WAZ and WHZ not available
(ID:w1uTR15Y0Jt
)- Condition:
(#{ITFC_WHZ_CV} == '' && #{ITFC_WAZ_CV} == '')
- Error:
Failed to coerce value 'null' () to Boolean: empty String in expression: #{ITFC_WAZ_CV} == ''
- (Source:
RuleConditionEvaluator.java [http-nio-8080-exec-147]) IDgln1fiUoEIccnmGlykLwS7VjtPjJV4j1iQT3Qe05nR8=
- Condition: