Skip to content

Managing Patient Attributes

Adam Kalachman edited this page Mar 18, 2015 · 1 revision

Summary

Patient attributes represent demographic and logistic information about a patient (age, race, gender, location, etc.). To make a change (add, edit, delete) to a patient attribute, it needs to be changed in OpenMRS, the Buendia server module, and the Buendia client. This document describes the necessary steps to make these changes.

Managing Attributes in OpenMRS

For up-to-date instructions on managing attribute definitions in OpenMRS, see: https://wiki.openmrs.org/display/docs/Managing+Person+Attribute+Types

Managing Attributes in the Buendia Server Module

Patients in the Buendia server module are managed by openmrs.projectbuendia.webservices.rest.PatientResource. Instructions below all refer to code within this class.

Deleting or Editing an Attribute Definition

  1. Remove/edit the code that manages the attribute from jsonToPatient(SimpleObject)

  2. Remove/edit the code that manages the attribute from applyEdits(Patient, SimpleObject)

  3. Remove/edit the code that manages the attribute from patientToJson(Patient)

  4. Remove/edit the attribute from JSON property names at the top of the class

Adding an Attribute Definition

  1. Add an entry for the new attribute in JSON property names at the top of the class

  2. In jsonToPatient(SimpleObject), look for the new JSON property, and operate on the Patient object, if necessary. For custom attributes, change the attribute value by calling DbUtil.setPersonAttributeValue(Patient, PersonAttributeType, String). For an example, look in setLocation(Patient, String).

  3. In patientToJson(Patient), add an entry for the new attribute. To retrieve the attribute value, call DbUtil.getPersonAttributeValue(Person, PersonAttributeType).

  4. In applyEdits(Patient, SimpleObject), add a case for the new attribute and update the patient the same way as in step (2).

Managing Attributes in the Buendia Client

Removing or Editing an Attribute Definition

  1. Remove or edit all references to the attribute in data/app/AppPatient (the client's Patient model), as well as any code that depends on it

  2. Remove or edit all references to the attribute in data/app/AppPatientDelta (the client's Patient model for patient changes), as well as any code that depends on it

  3. Remove or edit all references to the attribute in sync/SyncAdapter

  4. Remove or edit all references to the attribute in net/model/Patient (the server's Patient model)

  5. Find the corresponding attribute in sync/providers/Contracts#PatientColumns, and remove or edit all references to it and all code that depends on it

  6. Remove or edit all references to the attribute in sync/PatientDatabase

  7. Update the version number of the database in sync/PatientDatabase, so that the database will be flushed and recreated after the application is updated

  8. Update test cases for any modified classes

Adding an Attribute Definition

  1. In sync/providers/Contracts#PatientColumns, add a column for the new attribute

  2. In sync/PatientDatabase, add a column for the new attribute in SQL_CREATE_ENTRIES

  3. Update the version number of the database in sync/PatientDatabase, so that the database will be flushed and recreated after the application is updated

  4. In net/model/Patient (the server's Patient model), add:

a. A field for the new attribute

b. An entry for the attribute in toString()

c. An entry for the attribute in writeFrom(Patient)

  1. In sync/SyncAdapter, handle the new patient attribute wherever attributes are processed in updatePatientData(SyncResult)

  2. In data/app/AppPatient (the client's Patient model), add:

a. A field for the new attribute

b. A field and setter for the new attribute in Builder

c. An entry for the attribute in fromNet(Patient)

d. An entry for the attribute in toContentValues()

  1. In data/app/AppPatientDelta (the client's Patient model for patient changes), add:

a. A field for the new attribute

b. An entry for the attribute in toJson(JSONObject)

c. An entry for the attribute in toContentValues()

  1. In data/app/converters/AppPatientConverter, call the setter for the new attribute in AppPatient.Builder

a. Update relevant UI components as necessary

b. To display the attribute in the patient list, make changes in ui/PatientListTypedCursorAdapter

c. To display the attribute in the patient chart, make changes in ui/PatientChartActivity

d. To make the attribute settable during patient creation, make changes in both ui/PatientCreationController and ui/PatientCreationActivity

e. Update test cases for any modified classes

Clone this wiki locally