← Back to team overview

dhis2-devs team mailing list archive

Re: Validation rule with yes/no and number

 

Hello Olav
We had similar issue when we were implementing the Tracer Medicine Form in
the Tz database and we came to resort on having a javascript file to check
the "Yes" and "No" values selected by the users.
I have attached the tracer medicine form and the script for your reference
but just to shade some light on how the form structure and how the script
works.

When the form loads, all columns are disable except the Eligible column.
If User selected "NO" in the Eligible column the remaining column will
remain disabled. If the User selects "YES" the the Available Column is
enable. The same technique is applied to the available column and on the
last column if user chooses the drug is missing for less than a week then
the other options are also disabled limiting him to select multiple option
for the same drug

Cheers


Wilfred F. Senyoni
Computer Science and Engineering Department
College of Information and Communication Technologies
University of Dar es salaam


On Tue, May 6, 2014 at 8:19 AM, Jason Pickering <jason.p.pickering@xxxxxxxxx
> wrote:

> This is sort of like designing a complicated apparatus for a really simple
> problem.
>
> I sort of see the issue, but am not really sure if you mean a "true/false"
> data element as opposed to a yes/no. If you use "Yes only", then the value
> will be non-null only when checked. If so, then the compulsory pair should
> work.
>
> Regards,
> Jason
>
>
>
>
>
> On Mon, May 5, 2014 at 11:26 PM, Olav Poppe <olav.poppe@xxxxxx> wrote:
>
>> Sorry, forgot to reply to your earlier suggestion Jason. Agree that it is
>> no really necessary, but it can be difficult to convince people of that…
>>
>> As for the compulsory pair, I though that would only ensure that there is
>> some value in both fields - but what I need is to ensure that if A is «no»,
>> the B SHOULD be empty - and if a is «yes», it should NOT be empty. Can I do
>> that with a compulsory pair?
>>
>>
>> 5. mai 2014 kl. 15:50 skrev Lars Helge Øverland <larshelge@xxxxxxxxx>:
>>
>> Agree with Jason here.
>>
>> Olav the "compulsory pair" operator for validation rules could be useful
>> here.
>>
>> Lars
>>
>>
>>
>> On Fri, May 2, 2014 at 3:14 PM, Jason Pickering <
>> jason.p.pickering@xxxxxxxxx> wrote:
>>
>>> Not sure if the "Compulsory pair" works for this case, but it should.
>>>
>>> On the other hand, it would seem little point to record Element A, as if
>>> Element B is non-zero, it already indicates that there was a stockout.
>>>
>>> Regards,
>>> Jason
>>>
>>>
>>>
>>> On Fri, May 2, 2014 at 7:39 PM, Olav Poppe <olav.poppe@xxxxxx> wrote:
>>>
>>>> Hi,
>>>> is it possible to create a validation rule with a yes/no data element
>>>> and number type data element?
>>>>
>>>> For example:
>>>> Element A: Was the facility out of stock?
>>>> Element B: If yes, for how many days?
>>>>
>>>> I would like to validate that Element B is only filled if the value for
>>>> Element A is yes. Is this possible?
>>>>
>>>> Regards,
>>>> Olav
>>>>
>>>> _______________________________________________
>>>> Mailing list: https://launchpad.net/~dhis2-devs
>>>> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>>>> Unsubscribe : https://launchpad.net/~dhis2-devs
>>>> More help   : https://help.launchpad.net/ListHelp
>>>>
>>>
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~dhis2-devs
>>> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>>> Unsubscribe : https://launchpad.net/~dhis2-devs
>>> More help   : https://help.launchpad.net/ListHelp
>>>
>>>
>>
>>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-devs
> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-devs
> More help   : https://help.launchpad.net/ListHelp
>
>

Attachment: Tracer Medicine Form.pdf
Description: Adobe PDF document

Attachment: tracer.min.js
Description: JavaScript source


Follow ups

References