Adding Person Attribute to existing Patients

What would be the best way to add new attribute values to existing patients. I can map patients with Id and new attribute value.

Should I go ahead and write a script to Update PersonAttributes Table directly with new values. Is there some other way to do this cleanly ?


Hi Mani,

Are you trying to do this in the legacy UI or reference application, or via rest or from your custom module when calling the java API, can you give more details of what exactly you’re trying to accomplish?

Thank you for your time and Sorry for not providing enough information. Let me explain the background,

We have few hundred patient data available in OpenMRS. I have added a new attribute to Person, Say “Household”. I want to populate this attribute for all hundred patient. This Household value is dynamically generated. I have following options,

  • Update the attribute values via REST API, For that, I need to fetch all Patients and iterate through JSONArray.
  • Update MySQL tables with values with help of scripting.

Is there any other option to add attribute to saved Patients? And which is the best way to roll-out updates in OpenMRS?


The path you can take might really come down to how you’re generating the household values, what are you using to auto generate them? If you can generate them through java on the fly or already have where to fetch them you could do it through a module. Of course you can also script up something that sets the values via rest. You could also write SQL if you can feed the auto generated values into your SQL scripts but we strongly discourage directly running sql queries against the DB because you bypass several hooks in the API that do some necessary things for proper functioning of OpenMRS and any installed modules.

Thank you so much @wyclif, It was helpful!