software/test/performance/src/org/LexGrid/LexBIG/example/FindUMLSContextsForCUI.java
/**
	 * Recursively display each context that the code participates in with
	 * additional information.
	 * @param rcr
	 * @param lbSvc
	 * @param scheme
	 * @param csvt
	 * @throws LBException
	 */
Recursively display each context that the code participates in with
additional information.
Recursively display each context that the code participates in with additional information .
protected void printContext(ResolvedConceptReference rcr, EVSApplicationService lbSvc, String scheme, CodingSchemeVersionOrTag csvt)
			throws LBException
	{
		Concept ce = rcr.getReferencedEntry();
		int hcdsFound = 0;
		for (int i = 0; i < ce.getPresentationCount(); i++) {
			Presentation pres = ce.getPresentation(i);
			PropertyQualifier[] quals = pres.getPropertyQualifier();
			for (int q = 0; q < quals.length; q++) {
				PropertyQualifier qual = quals[q];
				if (qual.getPropertyQualifierId().equalsIgnoreCase("HCD")) {
					String hcd = qual.getContent();
					Util.displayMessage("");
					Util.displayMessage("HCD: " + hcd);
					hcdsFound++;
					CodedNodeSet hcdConceptMatch = lbSvc.getCodingSchemeConcepts(scheme, csvt);
					hcdConceptMatch.restrictToProperties(
							null, 
							new PropertyType[] {PropertyType.PRESENTATION}, 
							null, 
							null, 
							ConvenienceMethods.createNameAndValueList("HCD", hcd) 
							);
					CodedNodeGraph hcdGraph = lbSvc.getNodeGraph(scheme, csvt, "UMLS_Relations");
					CodedNodeGraph hcdTargeted = hcdGraph.restrictToTargetCodes(hcdConceptMatch);
					hcdTargeted.restrictToAssociations(
							ConvenienceMethods.createNameAndValueList(hierAssocNames_),
							ConvenienceMethods.createNameAndValueList("HCD", hcd));
					ResolvedConceptReference[] links = hcdTargeted.resolveAsList(
							null, 
							true, 
							false, 
							Integer.MAX_VALUE, 
							-1, 
							null, 
							new PropertyType[] {PropertyType.PRESENTATION}, 
							null, 
							500 
							).getResolvedConceptReference();
					for (int j = 0; j < links.length; j++) {
						ResolvedConceptReference link = links[j];
						StringBuffer sb = new StringBuffer(getItemText(link, hcd));
						printAssociationList(sb, hcd, link.getSourceOf(), 0, true);
						printAssociationList(sb, hcd, link.getTargetOf(), 0, false);
						Util.displayMessage(sb.toString());
					}
				}
			}
		}
		if (hcdsFound == 0) {
			Util.displayMessage("No hierarchical tags (HCD properties) found.");
			return;
		}
	}
protected void printContext ( ResolvedConceptReference rcr , EVSApplicationService lbSvc , String scheme , CodingSchemeVersionOrTag csvt ) throws LBException { Concept ce = rcr . getReferencedEntry ( ) ; int hcdsFound = 0 ; for ( int i = 0 ; i < ce . getPresentationCount ( ) ; i ++ ) { Presentation pres = ce . getPresentation ( i ) ; PropertyQualifier [ ] quals = pres . getPropertyQualifier ( ) ; for ( int q = 0 ; q < quals . length ; q ++ ) { PropertyQualifier qual = quals [ q ] ; if ( qual . getPropertyQualifierId ( ) . equalsIgnoreCase ( "HCD" ) ) { String hcd = qual . getContent ( ) ; Util . displayMessage ( "" ) ; Util . displayMessage ( "HCD: " + hcd ) ; hcdsFound ++ ; CodedNodeSet hcdConceptMatch = lbSvc . getCodingSchemeConcepts ( scheme , csvt ) ; hcdConceptMatch . restrictToProperties ( null , new PropertyType [ ] { PropertyType . PRESENTATION } , null , null , ConvenienceMethods . createNameAndValueList ( "HCD" , hcd ) ) ; CodedNodeGraph hcdGraph = lbSvc . getNodeGraph ( scheme , csvt , "UMLS_Relations" ) ; CodedNodeGraph hcdTargeted = hcdGraph . restrictToTargetCodes ( hcdConceptMatch ) ; hcdTargeted . restrictToAssociations ( ConvenienceMethods . createNameAndValueList ( hierAssocNames_ ) , ConvenienceMethods . createNameAndValueList ( "HCD" , hcd ) ) ; ResolvedConceptReference [ ] links = hcdTargeted . resolveAsList ( null , true , false , Integer . MAX_VALUE , - 1 , null , new PropertyType [ ] { PropertyType . PRESENTATION } , null , 500 ) . getResolvedConceptReference ( ) ; for ( int j = 0 ; j < links . length ; j ++ ) { ResolvedConceptReference link = links [ j ] ; StringBuffer sb = new StringBuffer ( getItemText ( link , hcd ) ) ; printAssociationList ( sb , hcd , link . getSourceOf ( ) , 0 , true ) ; printAssociationList ( sb , hcd , link . getTargetOf ( ) , 0 , false ) ; Util . displayMessage ( sb . toString ( ) ) ; } } } } if ( hcdsFound == 0 ) { Util . displayMessage ( "No hierarchical tags (HCD properties) found." ) ; return ; } }
Recursively display each context that the code participates in with
 additional information.
Recursively display each context that the code participates in with additional information .
// Step through the presentations and evaluate any tagged with
 // hcd(s) one by one ...
 // Define a code set for all concepts tagged with the HCD.
 // property names
 // property types
 // source list
 // context list
 // qualifier list
 // Define a code graph for all relations tagged with the HCD.
 // Now restrict the code graph based on the code set (so, exclude
 // nodes that do not contain the desired tag).
 // graph focus
 // resolve forward
 // resolve backward
 // coded entry depth
 // association depth
 // property names
 // property types
 // sort options
 // max to return
 // Resolve and print the chain of terms ...
