SNOMED Documentation Search


 Other Documents
Skip to end of metadata
Go to start of metadata

Current Version - Under Revision

The two examples given below show the creation of a tree view from a small sample hierarchy .

The principals used can be extended to any size or depth of hierarchy .

Example 1: Show all descendants of Concept "A" in a tree view

Table 47. Example Relationships

 

 

sourceId

typeId

destinationId

B

|is a|

A

C

|is a|

A

D

|is a|

B

E

|is a|

B

E

|is a|

C

C

|is a|

F

We must process each concept in the hierarchy , starting at 'A'. Add a tree node for 'A', and then query to get the children of 'A'. Process each child recursively, i.e. add a node to the tree view for the child , then query for its children , etc.

Table 48. Child nodes

 

 

Node

Child Node

1

2

1

5

2

3

2

4

5

4

5

6

Table 49. Concept to node cross reference

 

Node

Concept Identifier

1

A

2

B

3

D

4

E

5

C

6

E

7

F

Now we have tree nodes and their children for each Concept . If the nodes have been added to a Windows tree view component , display will be automatic. If a text-based display is being used then the nodes can be output to the screen using the indent style display. Note that the Concept 'E' appears in the tree view twice, under each of its parents.

Figure 48. Tree view of sample hierarchy - descendants of "A"

Example 2 - Show all ancestors of Concept "E"

In order to construct the tree view, we must start from the top down, so we must create a temporary view of the hierarchy before we can add nodes to the tree view. Query to get the parents of 'E'. Process each parent recursively, i.e. add an entry to the temporary table, stating that 'E' |is a| child of each of its parents, then query to get its parent, etc. When the top of the tree is reached, a record is kept of the top-level concept , since this will be the starting point for building the tree view.

Table 50. Temporary view of the hierarchy

 

 

Concept

Child Concept

B

E

C

E

A

B

A

C

We can now use the temporary table information to build the tree view from the top down. Starting at A, add a node to the tree view. Work recursively from the information in the temporary view of the hierarchy to add the descendants of 'A' into the tree view.

Figure 49. Tree view of sample hierarchy - ancestors of "E"


Feedback