org.LexGrid.LexBIG.example
Class FindUMLSContextsForCUI

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

public class FindUMLSContextsForCUI
extends java.lang.Object

NOTE: This example is intended to run only against code systems representing the entire Metathesaurus. It depends on the presence of concepts based on CUIs and the import of source and hierarchical definitions as property and association qualifiers. These attributes are only populated by the NCI Meta loader. Example displays explicitly asserted source hierarchies (based on import of MRHIER HCD) for a CUI. The program takes a single argument (a UMLS CUI), prompts for the code system to query in the LexGrid repository, and displays the HCD-based context relationships along with other details. Note that this example does not print intra-CUI associations (links that might exist between individual terms on a single concept) or hierarchies not explicitly tagged by HCD. The selected code system must represent the full Metathesaurus.


Nested Class Summary
protected  class FindUMLSContextsForCUI.TreeItem
          Inner class to hold tree items for printout.
 
Constructor Summary
FindUMLSContextsForCUI()
           
 
Method Summary
protected  FindUMLSContextsForCUI.TreeItem[] buildPaths(ResolvedConceptReference rcr, java.lang.String scheme, CodingSchemeVersionOrTag csvt, java.lang.String hcd, CodedNodeSet hcdConceptMatch)
          Build and return a tree item that represents the hierarchical entries for the given concept reference and hierarchical context identifier (HCD).
protected  void buildPathsToLowerNodes(FindUMLSContextsForCUI.TreeItem ti, ResolvedConceptReference rcr, java.lang.String scheme, CodingSchemeVersionOrTag csvt, java.lang.String hcd, CodedNodeSet hcdConceptMatch, java.util.Map<java.lang.String,FindUMLSContextsForCUI.TreeItem> code2Tree)
          Add all hierarchical relationships that start from the referenced concept and move forward in the tree.
protected  void buildPathsToUpperNodes(FindUMLSContextsForCUI.TreeItem ti, ResolvedConceptReference rcr, java.lang.String scheme, CodingSchemeVersionOrTag csvt, java.lang.String hcd, CodedNodeSet hcdConceptMatch, java.util.Map<java.lang.String,FindUMLSContextsForCUI.TreeItem> code2Tree, java.util.Set<FindUMLSContextsForCUI.TreeItem> roots)
          Add all hierarchical relationships that start from the referenced concept and move backward in the tree.
protected  LexBIGServiceConvenienceMethods getConvenienceMethods()
          Returns a cached instance of convenience methods.
protected  java.lang.String getDetailedText(ResolvedConceptReference rcr, java.lang.String hcd, java.lang.String scheme, CodingSchemeVersionOrTag csvt)
          Returns contextual text for the given item in the format [CUI]:[AUI]:[SAB]:[Text].
protected  java.lang.String getDirectionalLabel(java.lang.String scheme, CodingSchemeVersionOrTag csvt, Association assoc, boolean navigatedFwd)
          Returns the label to display for the given association and directional indicator.
protected  java.lang.String getHCDText(ResolvedConceptReference rcr, java.lang.String hcd)
          Returns text for an assigned presentation matching the given context identifier (HCD).
protected  LexBIGService getLexBIGService()
          Returns a cached instance of a LexBIG service.
protected  java.lang.String getSourceText(AssociatedConcept ac)
          Returns a string containing the names of all sources asserted on the association to the concept delimited by '|'.
protected  boolean isValidForHCD(AssociatedConcept ac, java.lang.String hcd)
          Indicates whether the given associated concept contains a qualifier for the given hierarchical context (HCD).
protected  boolean isValidForSAB(AssociatedConcept ac, java.lang.String sab)
          Indicates whether the given associated concept contains a qualifier for the given source abbreviation (SAB).
static void main(java.lang.String[] args)
          Entry point for processing.
protected  ResolvedConceptReference printCode(java.lang.String cui, java.lang.String scheme, CodingSchemeVersionOrTag csvt)
          Display name and description information for the given CUI.
protected  void printContext(ResolvedConceptReference rcr, java.lang.String scheme, CodingSchemeVersionOrTag csvt)
          Recursively display each source-asserted hierarchy that the code participates in, based on tagging by HCD qualifier, with additional information.
protected  void printPath(FindUMLSContextsForCUI.TreeItem ti, java.lang.String focusCode, int depth, java.util.Map<FindUMLSContextsForCUI.TreeItem,java.lang.Integer> item2Depth)
          Prints the given item, recursing to print all children.
 void run(java.lang.String cui)
          Process the provided code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FindUMLSContextsForCUI

public FindUMLSContextsForCUI()
Method Detail

main

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

Parameters:
args -

run

public void run(java.lang.String cui)
         throws LBException
Process the provided code.

Throws:
LBException

printCode

protected ResolvedConceptReference printCode(java.lang.String cui,
                                             java.lang.String scheme,
                                             CodingSchemeVersionOrTag csvt)
                                      throws LBException
Display name and description information for the given CUI.

Returns:
A fully resolved concept reference for the code.
Throws:
LBException

printContext

protected void printContext(ResolvedConceptReference rcr,
                            java.lang.String scheme,
                            CodingSchemeVersionOrTag csvt)
                     throws LBException
Recursively display each source-asserted hierarchy that the code participates in, based on tagging by HCD qualifier, with additional information.

Throws:
LBException

buildPaths

protected FindUMLSContextsForCUI.TreeItem[] buildPaths(ResolvedConceptReference rcr,
                                                       java.lang.String scheme,
                                                       CodingSchemeVersionOrTag csvt,
                                                       java.lang.String hcd,
                                                       CodedNodeSet hcdConceptMatch)
                                                throws LBException
Build and return a tree item that represents the hierarchical entries for the given concept reference and hierarchical context identifier (HCD). The returned tree items will represent the root of resolved paths for printing.

Throws:
LBException

buildPathsToLowerNodes

protected void buildPathsToLowerNodes(FindUMLSContextsForCUI.TreeItem ti,
                                      ResolvedConceptReference rcr,
                                      java.lang.String scheme,
                                      CodingSchemeVersionOrTag csvt,
                                      java.lang.String hcd,
                                      CodedNodeSet hcdConceptMatch,
                                      java.util.Map<java.lang.String,FindUMLSContextsForCUI.TreeItem> code2Tree)
                               throws LBException
Add all hierarchical relationships that start from the referenced concept and move forward in the tree. If the natural flow of relations is thought of moving from tree root to leaves, this method handles downstream processing from parent to child.

Throws:
LBException

buildPathsToUpperNodes

protected void buildPathsToUpperNodes(FindUMLSContextsForCUI.TreeItem ti,
                                      ResolvedConceptReference rcr,
                                      java.lang.String scheme,
                                      CodingSchemeVersionOrTag csvt,
                                      java.lang.String hcd,
                                      CodedNodeSet hcdConceptMatch,
                                      java.util.Map<java.lang.String,FindUMLSContextsForCUI.TreeItem> code2Tree,
                                      java.util.Set<FindUMLSContextsForCUI.TreeItem> roots)
                               throws LBException
Add all hierarchical relationships that start from the referenced concept and move backward in the tree. If the natural flow of relations is thought of moving from tree root to leaves, this method handles upstream processing from child to parent.

Throws:
LBException

getLexBIGService

protected LexBIGService getLexBIGService()
                                  throws LBException
Returns a cached instance of a LexBIG service.

Throws:
LBException

getConvenienceMethods

protected LexBIGServiceConvenienceMethods getConvenienceMethods()
                                                         throws LBException
Returns a cached instance of convenience methods.

Throws:
LBException

getDetailedText

protected java.lang.String getDetailedText(ResolvedConceptReference rcr,
                                           java.lang.String hcd,
                                           java.lang.String scheme,
                                           CodingSchemeVersionOrTag csvt)
                                    throws LBException
Returns contextual text for the given item in the format [CUI]:[AUI]:[SAB]:[Text]. This method iterates through the available presentations to find one qualified to match the specified HCD context.

Throws:
LBException

getDirectionalLabel

protected java.lang.String getDirectionalLabel(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

getHCDText

protected java.lang.String getHCDText(ResolvedConceptReference rcr,
                                      java.lang.String hcd)
Returns text for an assigned presentation matching the given context identifier (HCD). This method iterates through the available presentations to find one qualified to match the specified HCD context.

Parameters:
rcr - Concept resolved from a query.
hcd - The hierarchical context identifier.
Returns:
Text for the first embedded presentation matching the HCD as qualifier; null if not available.

getSourceText

protected java.lang.String getSourceText(AssociatedConcept ac)
Returns a string containing the names of all sources asserted on the association to the concept delimited by '|'.


printPath

protected void printPath(FindUMLSContextsForCUI.TreeItem ti,
                         java.lang.String focusCode,
                         int depth,
                         java.util.Map<FindUMLSContextsForCUI.TreeItem,java.lang.Integer> item2Depth)
Prints the given item, recursing to print all children.


isValidForHCD

protected boolean isValidForHCD(AssociatedConcept ac,
                                java.lang.String hcd)
Indicates whether the given associated concept contains a qualifier for the given hierarchical context (HCD).

Returns:
true if a qualifier exists; false otherwise.

isValidForSAB

protected boolean isValidForSAB(AssociatedConcept ac,
                                java.lang.String sab)
Indicates whether the given associated concept contains a qualifier for the given source abbreviation (SAB).

Returns:
true if a qualifier exists; false otherwise.

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.