org.LexGrid.LexBIG.example
Class BuildTreeForCode

java.lang.Object
  extended by org.LexGrid.LexBIG.example.BuildTreeForCode

public class BuildTreeForCode
extends java.lang.Object

Attempts to provide a tree, based on a focus code, that includes the following information:

 - All paths from the hierarchy root to one or more focus codes.
 - Immediate children of every node in path to root
 - Indicator to show whether any unexpanded node can be further expanded
 
This example accepts two parameters... The first parameter is required, and must contain at least one code in a comma-delimited list. A tree is produced for each code. Time to produce the tree for each code is printed in milliseconds. In order to factor out costs of startup and shutdown, resolving multiple codes may offer a better overall estimate performance. The second parameter is optional, and can indicate the identifier of a supported hierarchy for the coding scheme to navigate when resolving child nodes. If not provided, "is_a" is assumed. Note: This example is written to handle sources that define the supported hierarchy in a uni-directional fashion. In particular, it does not support the Metathesaurus, which can define hierarchical relationships using both forward and backward navigation. For examples showing techniques to navigate the Metathesaurus, please refer to other examples such as BuildTreeForMetaCodeBySource, ListHierarchyMetaBySource and FindUMLSContextsForCUI.


Nested Class Summary
protected  class BuildTreeForCode.TreeItem
          Inner class to hold tree items for printout.
 
Constructor Summary
BuildTreeForCode()
           
 
Method Summary
protected  void addChildren(BuildTreeForCode.TreeItem ti, LexBIGService lbsvc, LexBIGServiceConvenienceMethods lbscm, java.lang.String scheme, CodingSchemeVersionOrTag csvt, java.lang.String branchRootCode, java.util.Set<java.lang.String> codesToExclude, java.lang.String[] associationsToNavigate, boolean associationsNavigatedFwd)
          Populate child nodes for a single branch of the tree, and indicates whether further expansion (to grandchildren) is possible.
protected  void addPathFromRoot(BuildTreeForCode.TreeItem ti, LexBIGService lbsvc, LexBIGServiceConvenienceMethods lbscm, java.lang.String scheme, CodingSchemeVersionOrTag csvt, Association path, java.lang.String[] associationsToNavigate, boolean associationsNavigatedFwd, java.util.Map<java.lang.String,EntityDescription> codesToDescriptions)
          The given path represents a multi-tier association with associated concepts and targets.
protected  java.lang.String getCodeDescription(LexBIGService lbsvc, java.lang.String scheme, CodingSchemeVersionOrTag csvt, java.lang.String code)
          Returns the entity description for the given code.
protected  java.lang.String getCodeDescription(ResolvedConceptReference ref)
          Returns the entity description for the given resolved concept reference.
protected  java.lang.String getDirectionalLabel(LexBIGServiceConvenienceMethods lbscm, java.lang.String scheme, CodingSchemeVersionOrTag csvt, Association assoc, boolean navigatedFwd)
          Returns the label to display for the given association and directional indicator.
protected  AssociationList getPathsFromRoot(LexBIGService lbsvc, LexBIGServiceConvenienceMethods lbscm, java.lang.String scheme, CodingSchemeVersionOrTag csvt, java.lang.String hierarchyID, java.lang.String focusCode, java.util.Map<java.lang.String,EntityDescription> codesToDescriptions)
          Resolves one or more paths from the hierarchy root to the given code through a list of connected associations defined by the hierarchy.
protected static SupportedHierarchy getSupportedHierarchy(LexBIGService lbsvc, java.lang.String scheme, CodingSchemeVersionOrTag csvt, java.lang.String hierarchyID)
          Returns a description of the hierarchy defined by the given coding scheme and matching the specified ID.
static void main(java.lang.String[] args)
          Entry point for processing.
protected  void printTree(BuildTreeForCode.TreeItem ti, java.lang.String focusCode, int depth)
          Prints the given tree item, recursing through all branches.
protected  AssociationList reverseAssoc(LexBIGService lbsvc, LexBIGServiceConvenienceMethods lbscm, java.lang.String scheme, CodingSchemeVersionOrTag csvt, Association assoc, AssociationList addTo, java.util.Map<java.lang.String,EntityDescription> codeToEntityDescriptionMap)
          Recursive call to reverse order of the given association list, adding results to the given list.
 void run(LexBIGService lbsvc, LexBIGServiceConvenienceMethods lbscm, java.lang.String scheme, CodingSchemeVersionOrTag csvt, SupportedHierarchy hierarchyDefn, java.lang.String focusCode)
          Prints the tree for an individual code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BuildTreeForCode

public BuildTreeForCode()
Method Detail

main

public static void main(java.lang.String[] args)
Entry point for processing.

Parameters:
args -

run

public void run(LexBIGService lbsvc,
                LexBIGServiceConvenienceMethods lbscm,
                java.lang.String scheme,
                CodingSchemeVersionOrTag csvt,
                SupportedHierarchy hierarchyDefn,
                java.lang.String focusCode)
         throws LBException
Prints the tree for an individual code.

Throws:
LBException

addPathFromRoot

protected void addPathFromRoot(BuildTreeForCode.TreeItem ti,
                               LexBIGService lbsvc,
                               LexBIGServiceConvenienceMethods lbscm,
                               java.lang.String scheme,
                               CodingSchemeVersionOrTag csvt,
                               Association path,
                               java.lang.String[] associationsToNavigate,
                               boolean associationsNavigatedFwd,
                               java.util.Map<java.lang.String,EntityDescription> codesToDescriptions)
                        throws LBException
The given path represents a multi-tier association with associated concepts and targets. This method expands the association content and adds results to the given tree item, recursing as necessary to process each level in the path.

Nodes in the association act as the backbone for the display. For each backbone node, additional children are resolved one level deep along with an indication of further expandability.

Throws:
LBException

addChildren

protected void addChildren(BuildTreeForCode.TreeItem ti,
                           LexBIGService lbsvc,
                           LexBIGServiceConvenienceMethods lbscm,
                           java.lang.String scheme,
                           CodingSchemeVersionOrTag csvt,
                           java.lang.String branchRootCode,
                           java.util.Set<java.lang.String> codesToExclude,
                           java.lang.String[] associationsToNavigate,
                           boolean associationsNavigatedFwd)
                    throws LBException
Populate child nodes for a single branch of the tree, and indicates whether further expansion (to grandchildren) is possible.

Throws:
LBException

printTree

protected void printTree(BuildTreeForCode.TreeItem ti,
                         java.lang.String focusCode,
                         int depth)
Prints the given tree item, recursing through all branches.

Parameters:
ti -

getCodeDescription

protected java.lang.String getCodeDescription(LexBIGService lbsvc,
                                              java.lang.String scheme,
                                              CodingSchemeVersionOrTag csvt,
                                              java.lang.String code)
                                       throws LBException
Returns the entity description for the given code.

Throws:
LBException

getCodeDescription

protected java.lang.String getCodeDescription(ResolvedConceptReference ref)
                                       throws LBException
Returns the entity description for the given resolved concept reference.

Throws:
LBException

getDirectionalLabel

protected java.lang.String getDirectionalLabel(LexBIGServiceConvenienceMethods lbscm,
                                               java.lang.String scheme,
                                               CodingSchemeVersionOrTag csvt,
                                               Association assoc,
                                               boolean navigatedFwd)
                                        throws LBException
Returns the label to display for the given association and directional indicator.

Throws:
LBException

getPathsFromRoot

protected AssociationList getPathsFromRoot(LexBIGService lbsvc,
                                           LexBIGServiceConvenienceMethods lbscm,
                                           java.lang.String scheme,
                                           CodingSchemeVersionOrTag csvt,
                                           java.lang.String hierarchyID,
                                           java.lang.String focusCode,
                                           java.util.Map<java.lang.String,EntityDescription> codesToDescriptions)
                                    throws LBException
Resolves one or more paths from the hierarchy root to the given code through a list of connected associations defined by the hierarchy.

Throws:
LBException

getSupportedHierarchy

protected static SupportedHierarchy getSupportedHierarchy(LexBIGService lbsvc,
                                                          java.lang.String scheme,
                                                          CodingSchemeVersionOrTag csvt,
                                                          java.lang.String hierarchyID)
                                                   throws LBException
Returns a description of the hierarchy defined by the given coding scheme and matching the specified ID.

Throws:
LBException

reverseAssoc

protected AssociationList reverseAssoc(LexBIGService lbsvc,
                                       LexBIGServiceConvenienceMethods lbscm,
                                       java.lang.String scheme,
                                       CodingSchemeVersionOrTag csvt,
                                       Association assoc,
                                       AssociationList addTo,
                                       java.util.Map<java.lang.String,EntityDescription> codeToEntityDescriptionMap)
                                throws LBException
Recursive call to reverse order of the given association list, adding results to the given list. In context of this program we use this technique to determine the path from root, starting from the path to root provided by the standard convenience method.

Throws:
LBException

Copyright: (c) 2004-2006 Mayo Foundation for Medical Education and Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the triple-shield Mayo logo are trademarks and service marks of MFMER.