Overview
An expression constraint is
A computable rule that is used to define a set of clinical meanings.
Notes
The Expression Constraint Language - Specification and Guide defines the syntax used to represent expression constraints. It also defines the rules for applying constraints specified using expression constraint language (ECL) to SNOMED CT concepts and expressions.
Requirements and Options
Effective use of SNOMED CT requires the ability to constrain searches for concepts in a variety of ways. Subtype constraints and reference set membership constraints are identified as specific service requirements in sections 4.5 Get and Test Concept Subtypes and Supertypes and 4.6 Get and Test Reference Set Membership. Expression constraints can represent combinations of those constraints. They can also include rules that apply to specific aspects of the definition of a concept. For example, limiting concepts to those that are associated with particular body structures.
Expression constraints can be applied for a range of different purposes. In some cases, these may require enumeration of the set of all the concepts that conform to the constraint, while in other cases it may be more appropriate to apply a specific test to an individual concept. The required services are listed in Table 4.7-1.
Service Name and Status | Input | Output |
---|---|---|
Validate an expression constraint RECOMMENDED1 |
|
|
Get all concepts that conform to an expression constraint REQUIRED |
|
|
Test if a specific concept conforms to an expression constraint RECOMMENDED3 |
|
|
Interdependencies
Required By
- Other Services
- Use Cases
Depends On
- 4.1 Select Edition and Version
- 4.2 Get a Concept, Description or Relationship
- 4.3 Get Terms for a Concept
- 4.4 Get Definition of a Concept
- 4.5 Get and Test Concept Subtypes and Supertypes
- 4.6 Get and Test Reference Set Membership
Service Examples
The Snowstorm and FHIR examples are presented in plain text and URL encoded versions. Always use the "Encoded URL" when testing the example service requests. The plain text version is included to aid readability but using this version in a service request may result in errors. These errors result from characters that have to be encoded as they are not permitted in a URL (see IETF RFC1738).
Service Name | API Call4 | Result |
Validate an expression constraint | Not supported as individual service. Limited validation is possible by applying an expression constraint (as shown in next row). | An error message is returned if the expression constraint contains a syntax error. The error message does not indicate the specific cause of the validation error. No error message is shown if a concept identified in the expression constraint is not present in the selective edition or version 7. |
Get all concepts that conform to an expression constraint |
GET [snowstorm]/snomed-ct/[branchPath]/concepts?activeFilter=true&ecl=[expressionConstraint] The two examples are shown first as the expression constraint complete with the terms for each of the concepts. This is followed by the API service calls in which the terms have been removed (as an optional simplification). The constraint has been URL encoded as required for the REST API. Bone fractures with sites that are members of the lateralizable body structure reference set
GET [snowstorm]/MAIN/2020-01-31/concepts?activeFilter=true&ecl=<125605004:363698007=^723264001 Encoded URL GET [snowstorm]/MAIN%2F2020-01-31/concepts?activeFilter=true&ecl=%3C125605004%3A363698007%3D%5E723264001 Bone fractures with sites that are NOT members of the lateralizable body structure reference set
GET [snowstorm]/MAIN/2020-01-31/concepts?activeFilter=true&ecl=<125605004:363698007!=^723264001 Encoded URL GET [snowstorm]/MAIN%2F2020-01-31/concepts?activeFilter=true&ecl=%3C125605004%3A363698007%21%3D%5E723264001 Note that the ECL memberOf function needs to be url encoded. The URL encoding for ^ is %5E | Returns a JSON representation of data related to the concepts that conform to the expression constraint. The data returned for each concept includes:
Also returns the total number of concepts that match the constraint. As some expression constraints are matched by large numbers of concept, this service is paged. Requests parameters include:
With the data from the 2020-01-31 International release
If the expression constraint contains a syntax error, the returned data is an error message. |
Test if a specific concept conforms to an expression constraint | The service used for getting concepts that conform to an expression constraint can be adapted to test whether one or more specific concepts conform to the constraint by simply extending the constraint so it also constrains the results to only include the specified concept(s). Test if fracture of mandible (jaw bone) is a bone fracture with a site that is a member of the lateralizable body structure reference set
GET [snowstorm]/MAIN/2020-01-31/concepts?ecl=(<125605004: 363698007=^723264001) and (263172003) Encoded URL GET [snowstorm]/MAIN%2F2020-01-31/concepts?ecl=%28%3C125605004%3A+363698007%3D%5E723264001%29+and+%28263172003%29 Test if fracture of femur (thigh bone) is a bone fracture with a site that is a member of the lateralizable body structure reference set
GET [snowstorm]/MAIN/2020-01-31/concepts?ecl=(<125605004: 363698007=^723264001) and (71620000) Encoded URL GET [snowstorm]/MAIN%2F2020-01-31/concepts?ecl=%28%3C125605004%3A+363698007%3D%5E723264001%29+and+%2871620000%29 Test if osteomyelitis of femur is a bone fracture with a site that is a member of the lateralizable body structure reference set
GET [snowstorm]/MAIN/2020-01-31/concepts?ecl=(<125605004: 363698007=^723264001) and (1551001) Encoded URL GET [snowstorm]/MAIN%2F2020-01-31/concepts?ecl=%28%3C125605004%3A+363698007%3D%5E723264001%29+and+%281551001%29 | Returns a JSON representation of data related to the concept if it conforms to the expression constraint as described above. When testing a single candidate concept the value of the property total is sufficient to tell whether the candidate concept conforms to the constraint:
|
Test which of a specific set of concepts conform to an expression constraint | The technique used for testing whether a single concept conforms to an expression constraint can also be used to determine which members of a specified set of concepts conform to that constraint. In the case each of the member of the set of candidates is included in the constraint as shown below:
GET [snowstorm]/MAIN/2020-01-31/concepts?ecl=(<125605004: 363698007=^723264001) and (263172003 or 71620000 or 15510011551001 or 37449000) Encoded URL GET [snowstorm]/MAIN%2F2020-01-31/concepts?ecl=%28%3C125605004%3A+363698007%3D%5E723264001%29+and+%28263172003+or+71620000+or+15510011551001+or+37449000%29 | Returns a JSON representation of data related to concepts in the set that conforms to the expression constraint. The example shown returns an array containing data about the following concepts: |
Service Name | API Call5 | Result |
Validate an expression constraint | N/A | Not supported as individual service. Limited validation is possible by applying an expression constraint (as shown in next row). |
Get all concepts that conform to an expression constraint |
GET [fhir]/ValueSet/$expand?url=[versionURI]?fhir_vs=ecl/[expressionConstraint] Bone fractures with sites that are members of the lateralizable body structure reference set
GET [fhir]/ValueSet/$expand?url=http://snomed.info/sct/900000000000207008/version/20200131?fhir_vs=ecl/<125605004: 363698007=^723264001 Encoded URL GET [fhir]/ValueSet/$expand?url=http%3A%2F%2Fsnomed.info%2Fsct%2F900000000000207008%2Fversion%2F20200131%3Ffhir_vs%3Decl%2F%3C125605004%3A%0A363698007%3D%5E723264001 Bone fractures with sites that are NOT members of the lateralizable body structure reference set
GET [fhir]/ValueSet/$expand?url=http://snomed.info/sct/900000000000207008/version/20200131?fhir_vs=ecl/<125605004: 363698007!=^723264001 Encoded URL GET [fhir]/ValueSet/$expand?url=http%3A%2F%2Fsnomed.info%2Fsct%2F900000000000207008%2Fversion%2F20200131%3Ffhir_vs%3Decl%2F%3C125605004%3A%0A363698007%21%3D%5E723264001 | Returns a JSON representation of data about each of the concepts in the specified version that conform to the expression constraint. The data returned for each concept includes:
Also returns the total number of reference set members As some expression constraints are satisfied by many concepts, this service is paged. Requests parameters include:
|
The /ValueSet/$validate-code operation can be used to test whether a concept is included in a specific value set, where the value set is identified as an implicit value set. GET [fhir]/ValueSet/$validate-code?system=http://snomed.info/sct&code=[conceptId]&url=[versionURI]?fhir_vs=ecl/[expressionConstraint] Test if fracture of mandible (jaw bone), 263172003|Fracture of mandible|, is a bone fracture with a site that is a member of the lateralizable body structure reference set. The subset of concepts that are bone fractures with a site that is a member of the lateralizable body structure reference set can be determined by the following expression constraint: The resulting FHIR request:
GET [fhir]/ValueSet/$validate-code?system=http://snomed.info/sct&code=1551001&url=http://snomed.info/sct/900000000000207008/version/20200131?fhir_vs=ecl/<125605004: 363698007=^723264001 Encoded URL GET [fhir]/ValueSet/$validate-code?system=http%3A%2F%2Fsnomed.info%2Fsct&amp;code=1551001&url=http%3A%2F%2Fsnomed.info%2Fsct%2F900000000000207008%2Fversion%2F20200131%3Ffhir_vs%3Decl%2F%3C125605004%3A%0A363698007%3D%5E723264001 Test if fracture of femur (thigh bone), 71620000 |Fracture of femur|, is a bone fracture with a site that is a member of the lateralizable body structure reference set
GET [fhir]/ValueSet/$validate-code?system=http://snomed.info/sct&code=71620000&url=http://snomed.info/sct/900000000000207008/version/20200131?fhir_vs=ecl/<125605004: 363698007=^723264001 Encoded URL GET [fhir]/ValueSet/$validate-code?system=http%3A%2F%2Fsnomed.info%2Fsct&amp;code=71620000&url=http%3A%2F%2Fsnomed.info%2Fsct%2F900000000000207008%2Fversion%2F20200131%3Ffhir_vs%3Decl%2F%3C125605004%3A%0A363698007%3D%5E723264001 |
| |
Test which of a specific set of concepts conform to an expression constraint | The /ValueSet/$validate-code operation only supports testing whether a single concept conforms to an expression constraint. Therefore, to determine which members of a specified set of concepts conform to an expression constraint, a dedication expression constraint needs to be designed to enable this test. In this case, each member of the set of candidates is included in the expression constraint as shown below: ([intensionalDefinition])AND([candidate1] OR [candidate2] OR [candidate3] OR ...[candidateN]) The following general request template will test which of the candidates matches the expression constraint represented in the [intensionalDefinition] GET [fhir]/ValueSet/$expand?system=http://snomed.info/sct&code=[conceptId]&url=[versionURI]?fhir_vs=ecl/[expressionConstraint] Example 5Test which of the following concepts is a bone fracture with a site that is a member of the lateralizable body structure reference set
The resulting FHIR request:
GET [fhir]/ValueSet/$expand?url=http://snomed.info/sct/900000000000207008/version/20200131?fhir_vs=ecl/(<125605004: 363698007=^723264001) and (263172003 or 71620000 or 1551001 or 37449000) Encoded URL GET [fhir]/ValueSet/$expand?url=http%3A%2F%2Fsnomed.info%2Fsct%2F900000000000207008%2Fversion%2F20200131%3Ffhir_vs%3Decl%2F%28%3C125605004%3A%0A363698007%3D%5E723264001%29+and+%28263172003+or+71620000+or+1551001+or+37449000%29 | Returns a JSON representation of data about each of the candidate concepts that conform to the expression constraint. The data returned for each concept includes:
Also returns the total number of concepts satisfying the expression constraint. Note: If none of the candidate concepts which are tested for membership are included in the reference set, the service will return 0 results. The request in Example 5 shows that the following two concepts conform to the expression constraint:
|
Service Name | SQL Query6 | Result |
Validate an expression constraint | Not supported. | |
Get all concepts that conform to an expression constraint | call eclQuery([expressionConstraint]) Examples Bone fractures with sites that are members of the lateralizable body structure reference set call eclQuery("<125605004|Fracture of bone|: 363698007|Finding site| = ^723264001|Lateralizable body structure reference set|") Bone fractures with sites that are members of the lateralizable body structure reference set call eclQuery("<125605004|Fracture of bone|: 363698007|Finding site| = ^723264001|Lateralizable body structure reference set|") | Returns a row of data containing the conceptId and term for each concept that conforms to the constraint. If the expression constraint is invalid, no rows are returned. This and the following service examples can also use the following alternative procedure calls: The procedure eclQueryCount() sets a count output parameter with the number of concepts that match the constraint. call eclQueryCount([expressionConstraint],@count) The procedure eclSelect() returns the concepts that match the constraint in a specified style. Styles include: exp (expression with preferred term), expfsn (expression with FSN), pref (id, preferred term), fsn (id,FSN), allsyn (id,synonym - one row per synonym). call eclSelect([expressionConstraint],[style]) The procedure eclGetIds() outputs the concept identifiers to rows in the table config_resultsets with keyed by by a specified setId. This allows other queries or procedures to access the results. call eclQueryGetIds([expressionConstraint],[setId]) |
Test if a specific concept conforms to an expression constraint | call eclQuery(([expressionConstraint]) and ([conceptId])) for example call eclQuery("(<125605004=^723264001) AND (71620000)") | If the concept conforms to the constraint, this returns a row of data containing that conceptId and its term. If it does not conform no rows are returned. |
Test which of a set of specified concepts conform to an expression constraint | call eclQuery("(<125605004:363698007=^723264001) AND (71620000) or (15510011551001) or (37449000)") | Returns the conceptId and term for concepts in the set that conform to the expression constraint. |
Footnotes
Feedback