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 , and the third slot (named "Method") is a placeholder for the

	[[+ (<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:

then the following expression would be generated.

	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   known to be present in the family member, while the second slot (named "Relationship") is a placeholder for the   of this .

	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

Then the following family history expressions would be generated.

	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| }


	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| }


	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  , and the third slot (named "Method") is a placeholder for the 

	[[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  value and exactly one  value should be used.

The following input data satisfies these cardinality constraints.

Procedure SMgroup BodySite Method

1

2

1

If the slots are populated with the values above, then the following expressions would be generated.

	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| }


	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.

	[[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 , exactly one , exactly one  and exactly one .  The value of the   in each AFgroup is an expression, may optionally be refined using a single relationship group named "SSgroup". Each SSgroup optionally has one  and optionally has one . Based on these cardinality constraints, the input data shown in  would be valid.


Valid Input Data for Example 2


Condition AF group Finding Severity Site Relationship Time Context

1


2



1

1




If the slots are populated with the values above, then the following expressions would be generated.

	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| }


	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| }


   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.