Object Types

Sub-classing objects

In your data modeling, you may find that you want to define an object class that inherits all properties from another. For example, you might have a generic c_assessment class with properties like c_patient and more specific classes like c_blood_test that has all the properties of c_assessment but also a set of more specific properties like c_blood_type.

To create an object type, you simply add the object type definitions into the objectTypes array of an object's definition. These types will inherit all the properties from the super-class (or super-type).

The properties that define an object type are as follows:

Object Type Properties

Once an object type is defined, the type property becomes required when creating instances of the object. The type property is populated with the name of the object type you are creating.


In this example, we've created the object class c_assessment and set the proper ACL's. We've also added a property to this object that all of this object's types will share: c_patient. This is because all assessments will be made on a particular patient, no matter what kind of assessment it is.

GET /objects/5951719d514ef101000216cf

You'll notice that the objectTypes value in the JSON result above is an empty array. We're going to add a c_blood_test object type to this array.

POST /objects/5951719d514ef101000216cf/objectTypes

Now, the objectTypes array contains the c_blood_test definition we just created.

GET /objects/5951719d514ef101000216cf/objectTypes

We can now create a c_assessment object instance of type c_blood_test:

POST /c_assessments

The resulting instance of c_assessment is of type: c_blood_test and contains both the base property of c_patient and the c_blood_test type property c_blood_type.Request

    "_id": "59517718cfc40501006da501",
    "access": 7,
    "c_blood_type": "Type A",
    "c_patient": {
        "_id": "5771495a1d0c03a53ce83f1a",
        "object": "account",
        "path": "/accounts/5771495a1d0c03a53ce83f1a"
    "created": "2017-06-26T21:05:28.068Z",
    "creator": {
        "_id": "5771495a1d0c03a53ce83f1a",
        "object": "account",
        "path": "/accounts/5771495a1d0c03a53ce83f1a"
    "favorite": false,
    "object": "c_assessment",
    "owner": {
        "_id": "5771495a1d0c03a53ce83f1a",
        "object": "account",
        "path": "/accounts/5771495a1d0c03a53ce83f1a"
    "shared": false,
    "type": "c_blood_test"

Last updated