FindEntity

Find all entities that satisfy the specified constraints. The format and properties that are retrieved for the found entities can be specified using the results block.

Parameters

  • [optional] class: name of entity class.
  • [optional] _ref: reference to be used within the transaction.
  • [optional] unique: Indicates whether a single object is expected to satisfy the constraints.

Blocks

Details

If the class is skipped, entities of any class that satisfy the constraints will be returned.

At least one of results or _ref must be specified. If neither is specified, the command is render useless, and will return an error.

If the constraints block is skipped, all entities with the given class are returned.

Examples

Find an entity of class “Visit” where its “start_year” property is on or after 1990, and retrieve other properties of the visit:

[ {
    "FindEntity": {
        "class": "Visit",
        "constraints" : {
            "start_year": [ ">=", 1990 ],
        },
        "results": {
            "list": ["start_year", "end_year", "billing_id"]
        }
    }
} ]

Find the entities of the class “Visit” where its “start_year” property is on or after 1990 that are associated with a “Patient” with a “unique_id” equal to 4325, and retrieve other properties of the visit:

[ {
    "FindEntity": {
        "class": "Patient",
        "_ref": 1,
        "unique": true,     // Make sure we only find a single patient.
        "constraints" {
            "unique_id": ["==", 4325]
        }
        // There is no need to specify a "results" block,
        // because we just use a reference to the found entity
    }
}, {
    "FindEntity": {
        "class": "Visit",
        "constraints" : {
            "start_year": [ ">=", 1990 ],
        },
        "link": {
            "ref": 1,
            "direction": "in",
            "class": "PatientMadeVisit",
        },
        "results": {
            "list": ["start_year", "end_year", "billing_id"]
        }
    }
} ]