SNOMED Documentation Search
The formal syntax for SNOMED CT expression templates (v1.1.1) is shown below. This syntax is derived by combining:
As explained in 6. SNOMED CT Language Templates, references to the Template Syntax are also added into the Compositional Grammar rules to enable slots to be included within an expression template. Please note that rules that appear in both Compositional Grammar and the Expression Constraint Language (e.g. conceptId and term) are removed from the Expression Constraint Language (by commenting out) to avoid duplication.
; Compositional Grammar v2.3.1 4 with slot references (in blue)
expressionTemplate = ws [ (definitionStatus / tokenReplacementSlot) ws] subExpression ws
subExpression = focusConcept [ws ":" ws refinement]
definitionStatus = equivalentTo / subtypeOf
equivalentTo = "==="
subtypeOf = "<<<"
focusConcept = [templateInformationSlot ws] conceptReference *(ws "+" ws [templateInformationSlot ws] conceptReference)
conceptReference = conceptReplacementSlot / expressionReplacementSlot / ( conceptId [ws "|" ws term ws "|"] )
conceptId = sctId
term = nonwsNonPipe *( *SP nonwsNonPipe )
refinement = (attributeSet / attributeGroup) *( ws ["," ws] attributeGroup )
attributeGroup = [ templateInformationSlot ws ] "{" ws attributeSet ws "}"
attributeSet = attribute *(ws "," ws attribute)
attribute = [ templateInformationSlot ws ] attributeName ws "=" ws attributeValue
attributeName = conceptReference
attributeValue = expressionValue / QM stringValue QM / "#" numericValue / booleanValue / concreteValueReplacementSlot
expressionValue = conceptReference / "(" ws subExpression ws ")"
stringValue = 1*(anyNonEscapedChar / escapedChar)
numericValue = ["-"/"+"] (decimalValue / integerValue)
integerValue = digitNonZero *digit / zero
decimalValue = integerValue "." 1*digit
booleanValue = true / false
true = ("t"/"T") ("r"/"R") ("u"/"U") ("e"/"E")
false = ("f"/"F") ("a"/"A") ("l"/"L") ("s"/"S") ("e"/"E")
sctId = digitNonZero 5*17( digit )
ws = *( SP / HTAB / CR / LF ) ; optional white space
SP = %x20 ; space
HTAB = %x09 ; tab
CR = %x0D ; carriage return
LF = %x0A ; line feed
QM = %x22 ; quotation mark
BS = %x5C ; back slash
digit = %x30-39
zero = %x30
digitNonZero = %x31-39
nonwsNonPipe = %x21-7B / %x7D-7E / UTF8-2 / UTF8-3 / UTF8-4
anyNonEscapedChar = HTAB / CR / LF / %x20-21 / %x23-5B / %x5D-7E / UTF8-2 / UTF8-3 / UTF8-4
escapedChar = BS QM / BS BS
UTF8-2 = %xC2-DF UTF8-tail
UTF8-3 = %xE0 %xA0-BF UTF8-tail / %xE1-EC 2( UTF8-tail ) / %xED %x80-9F UTF8-tail / %xEE-EF 2( UTF8-tail )
UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) / %xF4 %x80-8F 2( UTF8-tail )
UTF8-tail = %x80-BF
; Template Syntax v1.1
templateSlot = templateReplacementSlot templateReplacementSlot / templateInformationSlot
templateReplacementSlot = conceptReplacementSlot / expressionReplacementSlot / tokenReplacementSlot / concreteValueReplacementSlot
conceptReplacementSlot conceptReplacementSlot = "[[" ws ws "+" ws "id" ws [ "(" ws expressionConstraint ws ")" ws] ws conceptReplacement [slotName ws] "]]"
expressionReplacementSlot = "[[" ws "+" ws expressionReplacement [slotName ws] "]]"
expressionReplacementSlot tokenReplacementSlot = "[[" ws ws "+" ws ["scg" ws] [ "(" ws expressionConstraint ws ")" ws] ws tokenReplacement [slotName ws] "]]"
concreteValueReplacementSlot = "[[" ws "+" ws concreteValueReplacement [slotName ws] "]]"tokenReplacementSlot
conceptReplacement = "id" ws [ ["(" ws slotExpressionConstraint ws ")" ws]
expressionReplacement = ["scg" ws] " ws "+" ws "tok" ws ["(" ws slotTokenSet slotExpressionConstraint ws ")" ws] [slotName ws] "]]"
concreteValueReplacementSlot = stringReplacementSlot / integerReplacementSlot / decimalReplacementSlot
tokenReplacement = "tok" ws [ "(" ws slotTokenSet ws ")" ws]
concreteValueReplacement = stringReplacement / integerReplacement / decimalReplacement / booleanReplacement
stringReplacement = "str" ws stringReplacementSlot = "[[" ws "+" ws "str" ws [ "(" ws slotStringSet ws ")" ws] [slotName ws] "]]"integerReplacementSlot = "[[" ws "+" ws "int" ws
integerReplacement = "int" ws [ "(" ws slotIntegerSet ws ")" ws] [slotName ws] "]]"decimalReplacementSlot = "[[" ws "+" ws
decimalReplacement = "dec" ws [ "(" ws slotDecimalSet ws ")" ws]
booleanReplacement = "bool" ws "dec" ws [ "(" ws slotDecimalSet slotBooleanSet ws ")" ws] [slotName ws] "]]"
slotTokenSet = slotToken *(mws slotToken)
slotStringSet = slotString slotStringValue *(mws slotStringslotStringValue)
slotStringValue = QM stringValue QM
slotIntegerSet = ( "#" integerValue slotIntegerValue / slotIntegerRange) *(mws ("#" integerValue slotIntegerValue / slotIntegerRange))
slotDecimalSet = ( "#" decimalValue slotDecimalValue / slotDecimalRange) *(mws ("#" decimalValue slotDecimalValue / slotDecimalRange))
slotBooleanSet = slotBooleanValue *(mws slotBooleanValue)
slotBooleanValue = booleanValue
slotIntegerRange = ( slotIntegerMinimum to to [ slotIntegerMaximum slotIntegerMaximum ] ) / ( to slotIntegerMaximum )
slotIntegerMinimum = [ exclusiveMinimum ] "#" integerValueexclusiveMinimum ] slotIntegerValue
slotIntegerMaximum = [ exclusiveMaximum ] slotIntegerValue
slotIntegerValue = "#" ["-"/"+"] integerValue
slotDecimalRange = ( slotDecimalMinimum to to [ slotDecimalMaximum slotDecimalMaximum ] ) / ( to slotDecimalMaximum )
slotDecimalMinimum = [ exclusiveMinimum ] "#" DecimalValueexclusiveMinimum ] slotDecimalValue
slotDecimalMaximum = [ exclusiveMaximum ] slotDecimalValue
slotDecimalValue = "#" DecimalValue" ["-"/"+"] decimalValue
exclusiveMinimum = ">"
exclusiveMaximum = "<"
slotName = "@" (slotStringValue / nonQuoteStringValue / slotString)
slotToken = definitionStatus / memberOf / constraintOperator / conjunction / disjunction / exclusion / reverseFlag / expressionComparisonOperator / numericComparisonOperator / stringComparisonOperator
slotString = QM stringValue QM
/booleanComparisonOperator
nonQuoteStringValue nonQuoteStringValue = *(%x21 / %x23-26 / %x28%x2A-3F / %x41-5A / %x5C / %x5E-7E) ; string with no ws, quotes, at, at square brackets or square round brackets
templateInformationSlot = "[[" ws slotInformation ws "]]"
slotInformation = [cardinality ws] [slotName ws]
; Expression Constraint Language v1.3 - Note that some rules are commented out because they are repeated in the Compositional Grammar rules above.4
slotExpressionConstraint expressionConstraint = ws ( refinedExpressionConstraint slotRefinedExpressionConstraint / compoundExpressionConstraint slotCompoundExpressionConstraint / dottedExpressionConstraint slotDottedExpressionConstraint / subExpressionConstraint slotSubExpressionConstraint ) ws
refinedExpressionConstraint slotRefinedExpressionConstraint = subExpressionConstraint slotSubExpressionConstraint ws ":" ws eclRefinementslotEclRefinement
compoundExpressionConstraint slotCompoundExpressionConstraint = conjunctionExpressionConstraint slotConjunctionExpressionConstraint / disjunctionExpressionConstraint slotDisjunctionExpressionConstraint / exclusionExpressionConstraintslotExclusionExpressionConstraint
conjunctionExpressionConstraint slotConjunctionExpressionConstraint = subExpressionConstraint slotSubExpressionConstraint 1*(ws conjunction ws subExpressionConstraintslotSubExpressionConstraint)disjunctionExpressionConstraint
slotDisjunctionExpressionConstraint = subExpressionConstraint slotSubExpressionConstraint 1*(ws disjunction ws subExpressionConstraintslotSubExpressionConstraint)
exclusionExpressionConstraint slotExclusionExpressionConstraint = subExpressionConstraint slotSubExpressionConstraint ws exclusion ws subExpressionConstraintslotSubExpressionConstraint
dottedExpressionConstraint slotDottedExpressionConstraint = subExpressionConstraint slotSubExpressionConstraint 1*(ws dottedExpressionAttributeslotDottedExpressionAttribute)
dottedExpressionAttribute slotDottedExpressionAttribute = dot dot ws eclAttributeNameslotEclAttributeName
subExpressionConstraint slotSubExpressionConstraint = [constraintOperator ws] [memberOf ws] (eclFocusConcept slotEclFocusConcept / "(" ws expressionConstraint slotExpressionConstraint ws ")")
eclFocusConcept slotEclFocusConcept = eclConceptReference slotEclConceptReference / wildCard
dot = "."
memberOf = "^"
eclConceptReference slotEclConceptReference = conceptId [ws "|" ws term ws "|"]
; conceptId = sctId
; term = 1*nonwsNonPipe *( 1*SP 1*nonwsNonPipe )
wildCard wildcard = "*"
constraintOperator = childOf / descendantOrSelfOf / descendantOf / parentOf / ancestorOrSelfOf / ancestorOf
descendantOf = "<"
descendantOrSelfOf = "<<"
childOf = "<!"
ancestorOf = ">"
ancestorOrSelfOf = ">>"
parentOf = ">!"
conjunction = (("a"/"A") ("n"/"N") ("d"/"D") mws) / ","
disjunction = ("o"/"O") ("r"/"R") mws
exclusion = ("m"/"M") ("i"/"I") ("n"/"N") ("u"/"U") ("s"/"S") mws
eclRefinement slotEclRefinement = subRefinement slotSubRefinement ws [conjunctionRefinementSet slotConjunctionRefinementSet / disjunctionRefinementSetslotDisjunctionRefinementSet]
conjunctionRefinementSet slotConjunctionRefinementSet = 1*(ws conjunction ws subRefinementslotSubRefinement)
disjunctionRefinementSet slotDisjunctionRefinementSet = 1*(ws disjunction ws subRefinementslotSubRefinement)
subRefinement slotSubRefinement = eclAttributeSet slotEclAttributeSet / eclAttributeGroup slotEclAttributeGroup / "(" ws eclRefinement slotEclRefinement ws ")"
eclAttributeSet slotEclAttributeSet = subAttributeSet slotSubAttributeSet ws [conjunctionAttributeSet slotConjunctionAttributeSet / disjunctionAttributeSetslotDisjunctionAttributeSet]
conjunctionAttributeSet slotConjunctionAttributeSet = 1*(ws conjunction ws subAttributeSetslotSubAttributeSet)
disjunctionAttributeSet slotDisjunctionAttributeSet = 1*(ws disjunction ws subAttributeSetslotSubAttributeSet)
subAttributeSet slotSubAttributeSet = eclAttribute slotEclAttribute / "(" ws eclAttributeSet slotEclAttributeSet ws ")"
eclAttributeGroup slotEclAttributeGroup = ["[" cardinality "]" ws] "{" ws eclAttributeSet slotEclAttributeSet ws "}"
eclAttribute slotEclAttribute = ["[" cardinality "]" ws] [reverseFlag ws] eclAttributeName slotEclAttributeName ws (expressionComparisonOperator ws subExpressionConstraint slotSubExpressionConstraint / numericComparisonOperator ws "#" numericValue (slotIntegerValue /slotDecimalValue) / stringComparisonOperator ws QM stringValue QMws slotStringValue / booleanComparisonOperator ws slotBooleanValue)
cardinality = minValue to maxValue
minValue = nonNegativeIntegerValue
to = ".."
maxValue = nonNegativeIntegerValue / many
many = "*"
reverseFlag = "R"eclAttributeName
slotEclAttributeName = subExpressionConstraintslotSubExpressionConstraint
expressionComparisonOperator = "=" / "!="
numericComparisonOperator = "=" / "!=" / "<=" / "<" / ">=" / ">"
stringComparisonOperator = "=" / "!="; numericValue
booleanComparisonOperator = [ "-=" / "+"] (decimalValue / integerValue)!="
; stringValue = 1*(anyNonEscapedChar / escapedChar)
; integerValue = digitNonZero digitNonZero *digit / zero
; decimalValue = integerValue integerValue "." 1*digit1*digit
; booleanValue = true / false
; true = ("t"/"T") ("r"/"R") ("u"/"U") ("e"/"E")
; false = ("f"/"F") ("a"/"A") ("l"/"L") ("s"/"S") ("e"/"E")
nonNegativeIntegerValue nonNegativeIntegerValue = (digitNonZero *digit ) / zero
; sctId = digitNonZero 5*17( digit )
; ws = *( SP / HTAB / CR / LF / comment ) ; optional white space
mws = 1*( SP / HTAB / CR / LF / comment ) ; mandatory white space
comment = "/*" *(nonStarChar / starWithNonFSlash) "*/"
nonStarChar = SP / HTAB / CR / LF / %x21-29 / %x2B-7E /UTF8-2 / UTF8-3 / UTF8-4
starWithNonFSlash = %x2A nonFSlash
nonFSlash = SP / HTAB / CR / LF / %x21-2E / %x30-7E /UTF8-2 / UTF8-3 / UTF8-4
; SP = %x20 ; space
; HTAB = %x09 ; tab
; CR = %x0D ; carriage return
; LF = %x0A ; line feed
; QM = %x22 ; quotation mark
; BS = %x5C ; back slash
; digit = %x30-39
; zero = %x30
; digitNonZero = %x31-39
; nonwsNonPipe = %x21-7B / %x7D-7E / UTF8-2 / UTF8-3 / UTF8-4
; anyNonEscapedChar = SP / HTAB / CR / LF / %x20-21 / %x23-5B / %x5D-7E / UTF8-2 / UTF8-3 / UTF8-4
; escapedChar = BS QM / BS BS
; UTF8-2 = %xC2-DF UTF8-tail
; UTF8-3 = %xE0 %xA0-BF UTF8-tail / %xE1-EC 2( UTF8-tail ) / %xED %x80-9F UTF8-tail / %xEE-EF 2( UTF8-tail )
; UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) / %xF4 %x80-8F 2( UTF8-tail )
; UTF8-tail = %x80-BF
...