Bahmni form conditions for boolean values

Hello @bahmni team and @darius ,

How would you add (skip logic )for concepts with boolean data type? What I would like is: if a user chooses “No” as the answer, then then the next which was grayed out is ungrayed. So far this works if a user chooses “Yes” but I’d like the reverse.

So far I’ve tried to play around with the code but to no success. This is the code:

{code}

‘Bacteriology, Is this result from a laboratory report or an endTB form that was transcribed from a laboratory report?’: function (formName, formFieldValues)

{

    var conceptToEnable = ["Bacteriology, If No, then where?"];
    var conditions = {disable: [], enable: []};
    var conditionConcept = formFieldValues['Bacteriology, Is this result from a laboratory report or an endTB form that was transcribed from a laboratory report?'];
    if (conditionConcept) {
        conditions.disable = conceptToEnable
    } else {
        conditions.enable = conceptToEnable
    }
    return conditions;
    }

{code}

This is how it the UI looks like. When I choose “Yes”, The next question is grayed out. What I what is the next question to be grayed out since the beginning and then when I choose “No” then it is ungrayed.

Selection_342

Thanks, James

1 Like

Hi James,

If i understand your question correctly then the below explanation should help you

In the below figure we have a concept “Previous history of physiotherapy” with three answers as “Yes” “No” and “Unknown”.

If i select “Yes” only then another text field should be shown as the below screenshot

As you can see “Details of previous physiotherapy” question is shown only if i select “Yes” in the previous question

The form condition to achieve this is as pr below figure

Let us know if this was helpful

Regards,

Mohit Dhamdhere

Thank you @mohitdhamdhere, I hope you had a great start of the New Year.

This works if you configure the Yes and No as separate concepts. Have you ever tried the form conditions on a concept that has Boolean as its datatype? My concept is configure as class Misc and datatype Boolean.

Thanks and let me know if you don’t understand my question so that I explain more. I’ll also look into this more.

@jmbabazi under the hood OpenMRS treats Boolean concepts as coded with Yes/No answers, though I’m not sure how this is reflected in Bahmni’s form conditions. I suggest doing a bit of debugging, e.g. by doing console.log(conditionConcept) in your snippet and checking what the values are when you choose Yes and No.

Thanks @darius, Using false works.

    var conditions = {disable: [], enable: []};
    var conditionConcept = formFieldValues['Bacteriology, Is this result from a laboratory report or an endTB form that was transcribed from a laboratory report?'];
    if (conditionConcept == **false**) {
        conditions.enable.push("Bacteriology, If No, then where?")
    } else {
        conditions.disable.push("Bacteriology, If No, then where?")
    }
    return conditions;
    },

Hello @darius,

This feature of enable/disable it works well but when i tried it in a below scenario it gives different results.

I have a drop-down button with two values(surgical doctor and OR staff) on surgical form which has 4 sections. 3 section for surgical doctors and 1 for OR staff. When doctor select surgical doctor it enable 3 sections for doctors and disable all the field in section 4 for OR staff and doctor fills all enabled fields there in the 3 sections. Also when the OR staff select the OR staff drop-down it disable the 3 section for doctors and enable the 4th section for OR staff.

And thanks for this scenario it works like a charm.

The problem raise when a doctor has filled the form and saved the data on a patient for the 3 sections and after the OR staff want to add others information for the same patient in the 4th section for OR staff. They select in the drop-down OR staff, to enable the OR staff section and disable the 3 Surgical doctor sections and the issue is it disable and clean all the data that was filled by doctor before and yet i want that it disable the fields but the data filled by doctors should remain there even after they click on save button .

kindly help.

Mupagasi