Just a question around program rules. We would like to create a program rule that would block HIV test result data element in a repeatable program stage once the result is positive. HIV test is done every three months, so if the result is positive, we do not want the users to select any more value for this DE.
You will need to create a program variable that retrieves for the value from the previous event
Then use the variable in the program rule so that it in the condition it checks that the status is positive and then create a program action to hide that field. You might also want to create another action that will assign the value again so it’s not saved empty.
I tested the solution in the DHIS2 Play instance using the “TB program” as a reference, and the setup worked effectively to hide the data element after a positive result while keeping the current instance visible. Below are the detailed steps I followed:
Program Rule Variable Setup
Name: I created a program rule variable named Var_Resultat_TB.
Source Type: I selected “Data element from previous event” as the source type. This ensures that the rule applies based on the outcome of the previous event.
Data Element: The data element chosen was “TB smear microscopy test outcome”. This data element stores the result of the TB smear test.
Program Rule Condition
The condition I used to check if the previous result was positive is as follows:
Explanation: This condition checks if the data element Var_Resultat_TB has a value and if that value is “Positive”. If both conditions are true, the rule is triggered.
Program Rule Action
Action: I added an action to Hide field for the data element “TB smear microscopy test outcome”.
Effect: Once a positive result is detected, this action hides the field for future instances of the stage, preventing any further input or changes to the test result.
Testing in the Play Instance
I tested this configuration by creating multiple events within the “TB program”. After recording a positive result in one event, the field was correctly hidden in subsequent events, ensuring that no further entries could be made.
Screenshots
I’ve attached screenshots showing the configuration of the program rule variable, the condition, and the action for your reference. These should help you replicate the setup in your own instance.
This method worked seamlessly in the Play instance, and I believe it should meet your needs as well. If you have any questions or run into any issues, feel free to reach out, and I’d be happy to assist further.
I have followed your steps and also tested the solution in the play instance. It is working and I now want to replicate it in our instance. I will get back if anything goes wrong.