Overview
In addition to the simple examples shown on the previous pages, more advanced expression templates can also be used. On this page we show some examples of expression constraints with multiple replacement slots, multiple cardinality constraints and slot co-dependency constraints.
Multiple Replacement Slots
In many situations, it is useful for an expression template to contain more than one replacement slot. Below are some examples.
Example 1
The following expression template uses three replacement slots to generate an expression that represents a type of procedure. The first slot (named "Procedure") is a placeholder for the focus concept, while the second slot (named "BodySite") is a placeholder for the
Concept |
---|
ShowParts | term |
---|
t | 405813007 |Procedure site - Direct| |
---|
|
, and the third slot (named "Method") is a placeholder for the
Concept |
---|
ShowParts | term |
---|
t | 260686004 |Method| |
---|
|
.
Scg expression |
---|
Border | ridge |
---|
ShowFormat | block |
---|
|
[[+ (<71388002 |Procedure|) @Procedure]]:
{ 405813007 |Procedure site - direct| = [[+ (<91723000 |Anatomical structure|) @BodySite]],
260686004 |Method| = [[+ (<129264002 |Action (qualifier value)|) @Method]] } |
If the slots are populated with the values:
- Procedure =
Concept |
---|
t | 387713003 |Surgical procedure| |
---|
|
- BodySite =
Concept |
---|
t | 66754008 |Appendix structure| |
---|
|
- Method =
Concept |
---|
t | 129304002 |Excision - action| |
---|
|
then the following expression would be generated.
Scg expression |
---|
Border | ridge |
---|
ShowFormat | block |
---|
|
387713003 |Surgical procedure|:
{ 405813007 |Procedure site - direct| = 66754008 |Appendix structure|,
260686004 |Method| = 129304002 |Excision - action| } |
Example 2
Another example of an expression template with multiple slots is shown below. This expression template is used to generate expressions that represent the family history of a patient. The template contains two slots - the first slot (named "Finding") is a placeholder for the Concept |
---|
ShowParts | term |
---|
t | 404684003 |Clinical finding| |
---|
|
known to be present in the family member, while the second slot (named "Relationship") is a placeholder for the Concept |
---|
ShowParts | term |
---|
t | 408732007 |Subject relationship context| |
---|
|
of this Concept |
---|
ShowParts | term |
---|
t | 404684003 |Clinical finding| |
---|
|
.
Scg expression |
---|
Border | ridge |
---|
ShowFormat | block |
---|
|
243796009 |Situation with explicit context|:
{ 246090004 |Associated finding| = [[+id (< 404684003 |Clinical finding|) @Finding]],
408731000 |Temporal context| = 410511007 |Current or past (actual)|,
408729009 |Finding context| = 410515003 |Known present|,
408732007 |Subject relationship context| = [[+id (<< 444148008 |Person in family of subject|) @Relationship]] } |
If the following input data is provided (in which each row represents a separate expression):
Finding | Relationship |
---|
| Concept |
---|
t | 444244000 |Maternal grandmother of subject| |
---|
|
|
Concept |
---|
t | 57809008 |Myocardial disease| |
---|
|
| Concept |
---|
t | 444292000 |Paternal grandfather of subject| |
---|
|
|
Concept |
---|
t | 46635009 |Diabetes mellitus type 1| |
---|
|
| Concept |
---|
t | 444301002 |Mother of subject| |
---|
|
|
Then the following family history expressions would be generated.
Scg expression |
---|
Border | ridge |
---|
ShowFormat | block |
---|
|
243796009 |Situation with explicit context|:
{ 246090004 |Associated finding| = 93870000 |Liver cancer|,
408731000 |Temporal context| = 410511007 |Current or past (actual)|,
408729009 |Finding context| = 410515003 |Known present|,
408732007 |Subject relationship context| = 444244000 |Maternal grandmother of subject| } |
Scg expression |
---|
Border | ridge |
---|
ShowFormat | block |
---|
|
243796009 |Situation with explicit context|:
{ 246090004 |Associated finding| = 57809008 |Myocardial disease|,
408731000 |Temporal context| = 410511007 |Current or past (actual)|,
408729009 |Finding context| = 410515003 |Known present|,
408732007 |Subject relationship context| = 444292000 |Paternal grandfather of subject| } |
Scg expression |
---|
Border | ridge |
---|
ShowFormat | block |
---|
|
243796009 |Situation with explicit context|:
{ 246090004 |Associated finding| = 46635009 |Diabetes mellitus type 1|,
408731000 |Temporal context| = 410511007 |Current or past (actual)|,
408729009 |Finding context| = 410515003 |Known present|,
408732007 |Subject relationship context| = 444301002 |Mother of subject| } |
Multiple Cardinality Constraints
Expression templates may also use more than one cardinality constraint to indicate the repeatability of different parts of the expression. Below are some examples.
Example 1
The following expression template uses three replacement slots to generate an expression that represents a type of procedure. The first slot (named "Procedure") is a placeholder for the focus concept, while the second slot (named "BodySite") is a placeholder for the
Concept |
---|
ShowParts | term |
---|
t | 405813007 |Procedure site - Direct| |
---|
|
, and the third slot (named "Method") is a placeholder for the
Concept |
---|
ShowParts | term |
---|
t | 260686004 |Method| |
---|
|
.
Scg expression |
---|
Border | ridge |
---|
ShowFormat | block |
---|
|
[[1..1]] [[+ (<71388002 |Procedure|) @Procedure]] :
[[ 1..2 @SMgroup]] { [[1..1]] 405813007 |Procedure site - direct| = [[+ (<91723000 |Anatomical structure|) @BodySite]],
[[1..1]] 260686004 |Method| = [[+ (<129264002 |Action (qualifier value)|) @Method]] } |
The first cardinality constraint (i.e. 1..1 ) indicates that exactly one value should be populated in the Procedure slot. The second cardinality constraint (i.e. 1..2 ) indicates that it is valid to include either 1 or 2 relationship groups in the resulting expression. The last two cardinality constraints, that appear inside the relationship group, (i.e. 1..1 ) indicate that in each instance of a relationship group, exactly one
Concept |
---|
ShowParts | term |
---|
t | 405813007 |Procedure site - direct| |
---|
|
value and exactly one
Concept |
---|
ShowParts | term |
---|
t | 260686004 |Method| |
---|
|
value should be used.
The following input data satisfies these cardinality constraints.
Procedure | SMgroup | BodySite | Method |
---|
Concept |
---|
t | 387713003 |Surgical procedure| |
---|
|
| 1 | Concept |
---|
t | 28273000 |Bile duct structure| |
---|
|
| Concept |
---|
t | 281615006 |Exploration - action| |
---|
|
|
2 | Concept |
---|
t | 28231008 |Gallbladder structure| |
---|
|
| Concept |
---|
t | 129304002 |Excision - action| |
---|
|
|
Concept |
---|
t | 387713003 |Surgical procedure| |
---|
|
| 1 | Concept |
---|
t | 66754008 |Appendix structure| |
---|
|
| Concept |
---|
t | 129304002 |Excision - action| |
---|
|
|
If the slots are populated with the values above, then the following expressions would be generated.
Scg expression |
---|
Border | ridge |
---|
ShowFormat | block |
---|
|
387713003 |Surgical procedure|:
{ 405813007 |Procedure site - direct| = 28273000 |Bile duct structure|, 260686004 |Method| = 281615006 |Exploration - action| },
{ 405813007 |Procedure site - direct| = 28231008 |Gallbladder structure|, 260686004 |Method| = 129304002 |Excision - action| } |
Scg expression |
---|
Border | ridge |
---|
ShowFormat | block |
---|
|
387713003 |Surgical procedure|:
{ 405813007 |Procedure site - direct| = 66754008 |Appendix structure|, 260686004 |Method| = 129304002 |Excision - action| } |
Example 2
Another example of an expression template with multiple cardinality constraints is shown below. This expression template is used to generate expressions that represent a clinical finding with explicit context.
Scg expression |
---|
Border | ridge |
---|
ShowFormat | block |
---|
|
[[1..1]] [[+id (<< 413350009 |Finding with explicit context|) @Condition]]:
[[ 1..2 @AFgroup ]] { [[1..1]] 246090004 |Associated finding| = ( [[+id (<< 404684003 |Clinical finding|) @Finding]]:
[[0..1 @SSgroup]] { [[0..1]] 246112005 |Severity| = [[+id (< 272141005 |Severities|) @Severity]],
[[0..1]] 363698007 |Finding site| = [[+id (< 91723000 |Anatomical structure|) @Site]] } ),
[[1..1]] 408732007 |Subject relationship context| = [[+id (< 444148008 |Person in family of subject|) @Relationship]],
[[1..1]] 408731000 |Temporal context| = [[+id (< 410510008 |Temporal context value|) @Time]],
[[1..1]] 408729009 |Finding context| = [[+id (< 410514004 |Finding context value|) @Context]] } |
The first cardinality constraint (i.e. 1..1 ) indicates that exactly one value should be populated in the Condition slot. The second cardinality constraint (i.e. 1..2 ) indicates that it is valid to include either 1 or 2 relationship groups (named "AFgroup") in the resulting expression. Each AFgroup relationship group must have exactly one
Concept |
---|
ShowParts | term |
---|
t | 246090004 |Associated finding| |
---|
|
, exactly one
Concept |
---|
ShowParts | term |
---|
t | 408732007 |Subject relationship context| |
---|
|
, exactly one
Concept |
---|
ShowParts | term |
---|
t | 408731000 |Temporal context| |
---|
|
and exactly one
Concept |
---|
ShowParts | term |
---|
t | 408729009 |Finding context| |
---|
|
. The value of the
Concept |
---|
ShowParts | term |
---|
t | 246090004 |Associated finding| |
---|
|
in each
AFgroup is an expression, may optionally be refined using a single relationship group named "SSgroup". Each
SSgroup optionally has one
Concept |
---|
ShowParts | term |
---|
t | 246112005 |Severity| |
---|
|
and optionally has one
Concept |
---|
ShowParts | term |
---|
t | 363698007 |Finding site| |
---|
|
. Based on these cardinality constraints, the input data shown in
Caption reference |
---|
CapRefId | valid-input-example-2 |
---|
CapRefType | Table |
---|
|
would be valid.
PDF: Landscape |
---|
Caption label |
---|
CapId | valid-input-example-2 |
---|
CapType | Table |
---|
| Valid Input Data for Example 2 |
Condition | AF group | Finding | Severity | Site | Relationship | Time | Context |
---|
Concept |
---|
LineBreak | true |
---|
t | 243796009 |Situation with explicit context| |
---|
|
| 1 | Concept |
---|
LineBreak | true |
---|
t | 56265001 |Heart disease| |
---|
|
| Concept |
---|
LineBreak | true |
---|
t | 24484000 |Severe| |
---|
|
|
| Concept |
---|
LineBreak | true |
---|
t | 444292000 |Paternal grandfather of subject| |
---|
|
| Concept |
---|
LineBreak | true |
---|
t | 410512000 |Current or specified time| |
---|
|
| Concept |
---|
LineBreak | true |
---|
t | 410515003 |Known present| |
---|
|
| 2 | Concept |
---|
LineBreak | true |
---|
t | 22298006 |Myocardial infarction| |
---|
|
|
| | Concept |
---|
LineBreak | true |
---|
t | 444292000 |Paternal grandfather of subject| |
---|
|
| Concept |
---|
LineBreak | true |
---|
t | 410589000 |All times past| |
---|
|
| Concept |
---|
LineBreak | true |
---|
t | 410516002 |Known absent| |
---|
|
| Concept |
---|
LineBreak | true |
---|
t | 57177007 |Family history with explicit context| |
---|
|
| 1 | Concept |
---|
LineBreak | true |
---|
t | 363346000 |Cancer| |
---|
|
| Concept |
---|
LineBreak | true |
---|
t | 6736007 |Moderate| |
---|
|
| Concept |
---|
LineBreak | true |
---|
t | 76752008 |Breast structure| |
---|
|
| Concept |
---|
LineBreak | true |
---|
t | 444244000 |Maternal grandmother of subject| |
---|
|
| Concept |
---|
LineBreak | true |
---|
t | 410512000 |Current or specified time| |
---|
|
| Concept |
---|
LineBreak | true |
---|
t | 410515003 |Known present| |
---|
|
| Concept |
---|
LineBreak | true |
---|
t | 160303001 |FH: Diabetes mellitus| |
---|
|
| 1 | Concept |
---|
LineBreak | true |
---|
t | 46635009 |Diabetes mellitus type 1| |
---|
|
|
|
| Concept |
---|
LineBreak | true |
---|
t | 444301002 |Mother of subject| |
---|
|
| Concept |
---|
LineBreak | true |
---|
t | 410512000 |Current or specified time| |
---|
|
| Concept |
---|
LineBreak | true |
---|
t | 410515003 |Known present| |
---|
|
|
|
If the slots are populated with the values above, then the following expressions would be generated.
Scg expression |
---|
Border | ridge |
---|
ShowFormat | block |
---|
|
243796009 |Situation with explicit context|:
{ 246090004 |Associated finding| = (56265001 |Heart disease|: {246112005 |Severity| = 24484000 |Severe|}),
408732007 |Subject relationship context| = 444292000 |Paternal grandfather of subject|,
408731000 |Temporal context| = 410511007 |Current or past (actual)|,
408729009 |Finding context| = 410515003 |Known present| },
{ 246090004 |Associated finding| = 22298006 |Myocardial infarction|,
408732007 |Subject relationship context| = 444292000 |Paternal grandfather of subject|,
408731000 |Temporal context| = 410589000 |All times past|,
408729009 |Finding context| = 410516002 |Known absent| } |
Scg expression |
---|
Border | ridge |
---|
ShowFormat | block |
---|
|
57177007 |Family history with explicit context|:
{ 246090004 |Associated finding| = ( 363346000 |Cancer|:
{ 246112005 |Severity| = 6736007 |Moderate|, 363698007 |Finding site| = 76752008 |Breast structure| } ),
408732007 |Subject relationship context| = 444244000 |Maternal grandmother of subject|,
40873100 |Temporal context| = 410511007 |Current or past (actual)|,
408729009 |Finding context| = 410515003 |Known present| } |
Scg expression |
---|
Border | ridge |
---|
ShowFormat | block |
---|
|
160303001 |FH: Diabetes mellitus|:
{ 246090004 |Associated finding| = 46635009 |Diabetes mellitus type 1|,
40873100 |Temporal context| = 410511007 |Current or past (actual)|,
408729009 |Finding context| = 410515003 |Known present|,
408732007 |Subject relationship context| = 444301002 |Mother of subject| } |
Please note that when part of an expression is repeated, connectors (e.g. a comma) must be added between the parts during processing. Similarly, when part of an expression is absent then clean up is required (e.g. to remove commas and brackets). For more information on these processing steps, please refer to 7.2. Template Processing.