Adding Person Attributes to Patient & Person in OpenMRS using FHIR

Adding Person Attributes to Patient & Person in OpenMRS using FHIR

This guide details how to structure and use the OpenMRS Person Attribute extension for Patient and Person resources.

Supported Types

OpenMRS Person Attributes can have different data types. The FHIR module maps these Java types to corresponding FHIR data types within the extension.

OpenMRS Type

FHIR Extension Value Type

java.lang.String

StringType

java.lang.Boolean

BooleanType

org.openmrs.Location

Reference

org.openmrs.Concept

CodeableConcept

Extension Format

All Person Attributes follow a consistent parent-child extension structure. The main extension identifies the block as a Person Attribute, and two nested extensions specify the attribute's type and its value.

The value field in the second nested extension (person-attribute-value) will change its data type (e.g., valueString, valueBoolean, valueReference) depending on the attribute being represented.

Here is the base structure:

{ "url": "http://fhir.openmrs.org/ext/person-attribute", "extension": [{ "url": "http://fhir.openmrs.org/ext/person-attribute-type", "valueString": "Birthplace" }, { "url": "http://fhir.openmrs.org/ext/person-attribute-value", "valueString": "Ahmedabad" }] }

Examples of Person Attribute Extensions

Below are examples for each of the supported types. These extensions would be placed inside the extension array of a Patient or Person resource.

StringType value

{ "url": "http://fhir.openmrs.org/ext/person-attribute", "extension": [{ "url": "http://fhir.openmrs.org/ext/person-attribute-type", "valueString": "Birthplace" }, { "url": "http://fhir.openmrs.org/ext/person-attribute-value", "valueString": "Nairobi" }] }

BooleanType value

{ "url": "http://fhir.openmrs.org/ext/person-attribute", "extension": [{ "url": "http://fhir.openmrs.org/ext/person-attribute-type", "valueString": "Consent for Research" }, { "url": "http://fhir.openmrs.org/ext/person-attribute-value", "valueBoolean": true }] }

Location value

{ "url": "http://fhir.openmrs.org/ext/person-attribute", "extension": [{ "url": "http://fhir.openmrs.org/ext/person-attribute-type", "valueString": "Usual Clinic" }, { "url": "http://fhir.openmrs.org/ext/person-attribute-value", "valueReference": { "reference": "Location/a2a2d6cc-680a-479a-8153-04a8ac121a3f", "display": "Wellbody Clinic" } }] }

Concept value

{ "url": "http://fhir.openmrs.org/ext/person-attribute", "extension": [{ "url": "http://fhir.openmrs.org/ext/person-attribute-type", "valueString": "Occupation" }, { "url": "http://fhir.openmrs.org/ext/person-attribute-value", "valueCodeableConcept": { "coding": [{ "system": "http://snomed.info/sct", "code": "15886004", "display": "Farmer" }], "text": "Farmer" } }] }

Reference

For a deeper understanding of the OpenMRS data model and the role of Person Attributes, please refer to the official guide: