Is there a way to dynamically update an observation form field based on a change in another?

Is there a way to dynamically update an observation form field based on a change in another field?

A use-case is the PHQ-9 form (attached): as each question gets answered, the Total Score needs to be updated.

Thanks, Dominic

PHQ-9.pdf (39.9 KB)

Hi Dominic, Yes, there is a way in Bahmni to dynamically update an observation form field based on other inputs. It’s being used for calculations like EDD from LMP and BMI from Height & Weight. You can have a look at how it works in Obstetrics form on demo.mybahmni.org To understand how to set it up, please refer to the wiki page Auto-Calculation of Observations. Implementer has to write the calculations in a groovy script. The calculations happen at server side. So the user has to save the form before the field is calculated and shown on UI.

2 Likes

Hi @arjun,

I am looking for a way to update fields client side.

I have implemented auto-calculations of BMI using Groovy scripts, but even in that case it would be nice to have a read-only BMI field updated on the client after weight and height are entered.

Bahmni already seems to allow some client side updating of fields, such as enabling/disabling controls for Chief Complaint data.

Can setting form fields on the client be considered for future versions?

Thanks, Dominic

+1 for this feature @dsurrao

I would also really like to be able to read and write obs values, client-side, using a JavaScript function, similar to what can be achieved in formConditions.js.

(This is possible in OpenMRS Reference Application and this is very useful)

We would be happy to see this planned for the next Bahmni release.

3 Likes