Can I use Yes/No valueType for a boolean

I am creating an attribute in the maintenance app with a boolean type but the boolean option is not included in the list of value types

The closest option I see is Yes/No, so I want to ask if it is equivalent of boolean

For example if I select Yes, will I see the response as true a boolean value or YES a string?

@jetisco4u yes this is possible , you can consider use of option sets.

1 Like

Thanks for the response but I want to know if I Can use Yes/No valueType for a boolean

1 Like

Hi @jetisco4u I would recommend that you not use an option set for this purpose. The reason is that it is currently much more straightforward to use a either a Yes/No or even better a “Yes only” data element type, since these will be able to work out of the box with DHIS2 analytics. Aggregation of option sets is a bit trickier.

So yes, if you need a a Boolean, either a Yes/no or “Yes only” will work. The advantage with the “Yes only” type is that users just need to click it to indicate a yes, which saves time with data entry.

Best regards,
Jason

2 Likes

Thanks for checking in, when you say ‘option set’ what do you mean please? Do you mean like using a Select component for ‘Yes’ or ‘No’?

My main question is if I use the Yes or No option, will the response come as a boolean true or false or as string Yes or No?

1 Like

Ah, I see now you are talking about “Attributes” and not the actual data element value type. Got it.
There is no “Boolean” type for attributes in DHIS2. If you are going to do something with this attribute on an external system, then you will need to use one of the existing types like “Yes/No”. You could use an option set with options “Yes/No”, but these will be just text. So, it sort of really depends on what you need.

Unlike for data elements, you cannot really do any analytics in DHIS2 with attributes, so it does not matter as much but it still feels duplicative to me to create another option set with “Yes/No”.

Regards
Jason

1 Like

Yes, the response will be returned as a string with a ‘Yes’ (for “Yes only”) or ‘No’ (for ‘Yes/No’). However, my best guess is that you are handling this response using the API; therefore, I suggest using the Code field for the value true which will be easier to handle:

Does that solve the issue? :slight_smile:

1 Like

Thanks that is what I want to know, I will convert the value to boolean where necessary

1 Like

Good to know! Please mark the post as solved if it is. :grin::pray: Thanks!