/
UUIDs

UUIDs

This page is outdated and no longer receives updates!

As of version OpenMRS v1.5 most objects/tables have a UUID property. This property is automatically filled in for every row and is 99.9% guaranteed to be unique across the universe. The primary reason for uuids is to support the Sync Module and allow for identifying objects that are identical across different OpenMRS installations.

In it's canonical form, a uuid value will be hexadecimal digits in the form of 8chars-4-4-4-12chars (e.g 0febc204-bca1-11de-913d-0010c6dffd0f). Depending on whether mysql or java generates these (see below), the uuid could be in version 1 or version 4 respectively.

The uuid can really be any unique string within the table, but to follow conventions, all OpenMRS uuids should be 36 characters in length and contain no whitespace.  (Ideally, all OpenMRS uuids would be in the canonical form, but the uuids in the MVP dictionary, which were created manually, don't follow the 8chars-4-4-4-12chars convention, though they are all 36 characters in length.)  Certain modules, such as the HTML Form Entry module, operate under the assumption that a uuid is 36 characters long and contains no whitespace, so if you are manually creating uuids for some reason, you should follow this convention.

All uuid columns can hold up to 38 character to accommodate MSSQL server's desire to put a curly brace ({}) at the beginning and end of the 36 chars.

You may hear the term GUID used as a synonym of UUID. GUID is Microsoft's implementation of UUID.

Primary Key Argument

The UUID is used as a normal property of every object instead of a primary key for several reasons:

  1. Using long string uuids reduces performance. Its much faster to use smaller integers for PKs

  2. The uuid is a long ugly 36 character string that would not look good in urls

Initial Column Values

When upgrading a current installation of openmrs, all rows will get a uuid generated for them. If you are using mysql, then openmrs uses the uuid() method during the update to do something like:

UPDATE obs SET uuid = uuid() WHERE uuid is null;

If you are using a DB other than mysql, most likely it also has a function to create a uuid.  If not, then there is a java routine that runs and uses the java implementation of UUID generation. This is considerably slower.

There have been issues with mysql on windows and not getting unique uuids [1] . To find those duplicates, you can run this sql:

UUIDs and the OpenMRS API

Also in OpenMRS 1.5 there came a number of base abstract classes to define common metadata on objects. One of these objects was the OpenmrsObject. If an object extends this class and gets passed through an API method of the form of "save*(OpenmrsObject obj)", then the uuid property is automatically generated and saved along with the object. See API Save Handlers for more information about that magic.

The API uses the Java UUID class randomUUID() generation method (and so will be UUID v4 reference above).

OpenMRS UUIDs

There are some UUIDs shared across all OpenMRS implementations for metadata that are common across all implementations.

Concept Datatype UUIDs

Name

UUID

Name

UUID

Numeric

8d4a4488-c2cc-11de-8d13-0010c6dffd0f

Coded

8d4a48b6-c2cc-11de-8d13-0010c6dffd0f

Text

8d4a4ab4-c2cc-11de-8d13-0010c6dffd0f

N/A

8d4a4c94-c2cc-11de-8d13-0010c6dffd0f

Document

8d4a4e74-c2cc-11de-8d13-0010c6dffd0f

Date

8d4a505e-c2cc-11de-8d13-0010c6dffd0f

Time

8d4a591e-c2cc-11de-8d13-0010c6dffd0f

Datetime

8d4a5af4-c2cc-11de-8d13-0010c6dffd0f

Boolean

8d4a5cca-c2cc-11de-8d13-0010c6dffd0f

Rule

8d4a5e96-c2cc-11de-8d13-0010c6dffd0f

Structured Numeric

8d4a606c-c2cc-11de-8d13-0010c6dffd0f

Complex

8d4a6242-c2cc-11de-8d13-0010c6dffd0f

Role UUIDs

Role

UUID

Role

UUID

Anonyous

774b2af3-6437-4e5a-a310-547554c7c65c

Authenticated

f7fd42ef-880e-40c5-972d-e4ae7c990de2

Provider

8d94f280-c2cc-11de-8d13-0010c6dffd0f

System Developer

8d94f852-c2cc-11de-8d13-0010c6dffd0f

HL7 Source UUIDs

Name

UUID

Name

UUID

LOCAL

8d6b8bb6-c2cc-11de-8d13-0010c6dffd0f

Location UUIDs

Name

UUID

Name

UUID

Unknown Location

8d6c993e-c2cc-11de-8d13-0010c6dffd0f

Patient Identifier UUIDs

Name

UUID

Name

UUID

OpenMRS Identifier

8d793bee-c2cc-11de-8d13-0010c6dffd0f

Old Identification Number

8d79403a-c2cc-11de-8d13-0010c6dffd0f

Concept Class Identifier UUIDs

Name

UUID

Name

UUID

Test

8d4907b2-c2cc-11de-8d13-0010c6dffd0f

Procedure

8d490bf4-c2cc-11de-8d13-0010c6dffd0f

Drug

8d490dfc-c2cc-11de-8d13-0010c6dffd0f

Diagnosis

8d4918b0-c2cc-11de-8d13-0010c6dffd0f

Finding

8d491a9a-c2cc-11de-8d13-0010c6dffd0f

Anatomy

8d491c7a-c2cc-11de-8d13-0010c6dffd0f

Question

8d491e50-c2cc-11de-8d13-0010c6dffd0f

LabSet

8d492026-c2cc-11de-8d13-0010c6dffd0f

MedSet

8d4923b4-c2cc-11de-8d13-0010c6dffd0f

ConvSet