we have some data element with option set.
want to set these data element in the program - stage with the default value. so users dont have to choose any time.
what is the best way to have this.
we have some data element with option set.
want to set these data element in the program - stage with the default value. so users dont have to choose any time.
what is the best way to have this.
HI @nanwang,
DId you manage to sort this? If not, I would recommend using program rules to do this for you based on what exactly you need i.e. if the question you want to be prefilled is dependent on another question the user has to fill on the same or different stage. After user selects the option i.e. Age, Sex to calculate the BMI, the BMI field will come prefilled
Let me know what you think about this.
Best,
James.
I have the same question @jomutsani.
Say I have a Yes/No question like this:
Send patient SMS messages?
YES
NO
Can I default one of the options to âselectedâ but let the user change the selection?
Send patient SMS messages?
YES
NO
When I try to do this with Program rules, the radio buttons are greyed out and the user canât edit the selection.
For what itâs worth, this is exactly what the âcheckedâ is for in HTML forms.
<p>Send patient SMS messages?</p>
<input type="radio" id="yes" name="sms" checked>
<label for="yes">YES</label>
<input type="radio" id="no" name="sms">
<label for="no">NO</label>
@dburka Weâve noticed this as well that when you assign values, its kind of two actions in 1; it assigns a value and then makes the Data Element Read Only.
The work that weâve done is to add a && !d2:hasValue() into the expression, referencing the exact data Element that weâre assigning. This makes it so that the value is assigned, and then âreleasedâ if you will from the program rule.
Thank you @Matthew_Boddie! Will give it a shot.
This is very helpful.
Are you able to show how this expression is used inside the program rules?
We have tried so many variations but were unable to reach a working solution.
Here is one of the many options we tried
Thank you for your help
I think youâd want to modify the program rule expression and the action expression to assign the value.
In the program rule expression instead of true, !d2:hasValue(A{YesHasHypertension})
And in the âassign valueâ action expression: âHTN_YESâ (the value to be assigned?)
Hope this works. To be honest, Iâm guessing based on your screenshot but if it doesnât acheive the desired result maybe you could explain further.
Thanks!
Ditto @Gassim ! His explanation is more what I was meaning. Basically that the expression would register as true when there was no data, and once the program rule action fired, the expression would register as false. Thus, the assign value is âreleasedâ, and the value remains but the cell can now be edited.
Hi @Matthew_Boddie , Iâve been taking a crack at this problem and sort of got it to work through a different method. I tried what you and @Gassim suggested, using !d2:hasValue(A{YesHasHypertension}) as a condition, but could not get it to work.
I used an extra âenabler fieldâ that acts like a check.
Iâm using 2 types of fields:
I also used 2 program rules:
Rule 1: When user lands on a screen, it checks whether âenabler fieldâ is empty. If it is, then it auto-fills the original field (ie. Does patient have Diabetes? = Yes).
Rule 2: Checks whether original field, is empty. If it is, it auto-fills âenabler fieldâ (Enabler for autofilling fields = true). Reason: When I tap âxâ on original field to remove the value, it was changing to read-only state. Now because of Rule 2, âenabler fieldâ is filled, Rule 1 does not trigger.
Current challenge:
The issue I am facing now is that I want to hide the âenabler fieldâ from users. But when I set up a program rule to hide that field, the other program rules that depend on the âenabler fieldâ stop working. Do you know if there is a way to hide the âenabler fieldâ but still let it be used by program rules?
Hi there @tonyjoy ! Interesting that the way wasnât functionalâwould be curious on your version and where you are entering.
Iâm imagining that if you had the enabler field as a ProgramRuleVariable only and not as a dataElement in the program, then you could still assign values to it but it wouldnât have to be visible at any point to the end-user. And you should still be able to use the variable in the same way. Does that make sense?
Sorry, let me clarify. Using !d2:hasValue(A{YesHasHypertension}) as a condition worked in that it âreleasedâ the field from being read-only. But when I hit the âxâ to remove the filled value, it goes back to being read-only. Was it the same behaviour on your end?
I am on version 2.40.0.1.
Trying to auto-fill the question âDoes patient have Hypertension?â to âYesâ via Android phone.
Related to your idea: using enabler field as a ProgramRuleVariable only and not as a dataElement in the program. Tried but not working as expected.
As of now, the solution I arrived at looks like this. That extra field can be used as a check to auto-fill any number of fields.
I learnt that using a Program Rule to hide a value field (TEI Attribute or Data element) will also erase the value of that field. There is currently a JIRA ticket to hide sections in enrollment form. Once that JIRA issue is resolved, this solution should work.