public static void main(String[] args) { try { EVSSearch evsSearch = new EVSSearch(); List<EVSBean> concept = (List<EVSBean>) evsSearch.searchEVS( "gene*" + "", "NCI_Thesaurus", "Include", "" + "Synonym", "term", "All Sources", 100); for (EVSBean b : concept) { System.out.println("-----"); System.out.println(b.getName()); System.out.println(b.getDefinition()); System.out.println(b.getType()); System.out.println(b.getCode()); System.out.println(b.getSource()); System.out.println(b.getDictionary()); System.out.println("-----"); } } catch (Exception e) { e.printStackTrace(); } }
public static List searchEVS( String term, String dtsVocab, String retired, String sSearchInEVS, String sUISearchType, String sMetaSource, int sMetaLimit) throws Exception { String algorithm; String altNameType; String CCode; String prefName = ""; Boolean isRetired = new Boolean(false); Boolean bTrue = new Boolean(true); Boolean bFalse = new Boolean(false); boolean isMetaCodeSearch = false; Boolean codeFoundInThesaurus = new Boolean(false); String source = ""; String definition = ""; List vCon = new ArrayList(); String sDefDefault = "No value exists."; String sDef = ""; String sDefSrc = ""; // List vCon = null; List vMetaDefs = new ArrayList(); // List vMetaDefs = null; if (dtsVocab.equals("Thesaurus/Metathesaurus") || dtsVocab.equals("") || dtsVocab.equals("NCI Thesaurus") || dtsVocab.equals("NCI_Thesaurus")) { dtsVocab = "NCI Thesaurus"; altNameType = "NCI_CONCEPT_CODE"; } // for search Meta by (LOINC) code else if (dtsVocab.equals("Metathesaurus") || sSearchInEVS.equals("Code")) { dtsVocab = "NCI_Thesaurus"; altNameType = "NCI_CONCEPT_CODE"; isMetaCodeSearch = true; sUISearchType = "term"; } // for Meta searches only (no Thes search), like in getSuperConcepts Meta else if (dtsVocab.equals("NCI Metathesaurus")) { altNameType = "UMLS_CUI"; isMetaCodeSearch = false; sUISearchType = "term"; } else altNameType = ""; LexEVSApplicationService evsService = (LexEVSApplicationService) ApplicationServiceProvider.getApplicationService("EvsServiceInfo"); /* if (!sSearchInEVS.equals("Concept Code") || term.equals("")) {*/ Pattern pattern = Pattern.compile("^C\\d{2,8}"); Matcher matcher = pattern.matcher(term); algorithm = getAlgorithm(term); term = cleanTerm(term); int totalReturnCount = 0; try { if (retired.equals( "Include")) // do this if all concepts, including retired, should be included isRetired = new Boolean(false); else { try { ResolvedConceptReferenceList rcrl = searchPrefTerm(evsService, dtsVocab, term, sMetaLimit, algorithm); if (rcrl != null && rcrl.getResolvedConceptReferenceCount() > 0) isRetired = (Boolean) (!rcrl.getResolvedConceptReference(0).getEntity().isIsActive()); } catch (Exception ex) { ex.printStackTrace(); } } if (isRetired.equals(bFalse)) { ResolvedConceptReferenceList concepts = null; // CCode = term; int codesSize = 0; try { if (sSearchInEVS.equals("Concept Code") || matcher.matches()) concepts = searchConceptCode(evsService, dtsVocab, term, sMetaLimit); else concepts = searchPrefTerm(evsService, dtsVocab, term, sMetaLimit, algorithm); codesSize = concepts.getResolvedConceptReferenceCount(); } catch (Exception ex) { System.out.println("Error do_EVSSearch get concept: " + ex.toString()); } if (concepts != null && codesSize > 0) { codeFoundInThesaurus = new Boolean(true); prefName = concepts.getResolvedConceptReference(0).getEntityDescription().getContent(); concepts = new ResolvedConceptReferenceList(); try { concepts = searchPrefTerm(evsService, dtsVocab, prefName, sMetaLimit, algorithm); codesSize = concepts.getResolvedConceptReferenceCount(); } catch (Exception ex) { // ex.printStackTrace(); System.out.println("Error do_EVSSearch DescLogic: " + ex.toString()); } if (concepts != null) { ResolvedConceptReference rcr = new ResolvedConceptReference(); for (int i = 0; i < codesSize; i++) { rcr = concepts.getResolvedConceptReference(i); prefName = rcr.getEntityDescription().getContent(); CCode = rcr.getConceptCode(); Definition[] defs = rcr.getEntity().getDefinition(); if (defs == null) defs = new Definition[0]; sDef = sDefDefault; // "No Value Exists."; sDefSrc = ""; for (int k = 0; k < defs.length; k++) { Definition def = defs[k]; if (def != null) { if (def.getIsPreferred() != null) { sDef = def.getValue().getContent(); if (def.getSourceCount() > 0) sDefSrc = def.getSource(0).getContent(); // get def source } } } EVSBean conBean = new EVSBean(); conBean.setCode(CCode); conBean.setDefinition(sDef); conBean.setDictionary(dtsVocab); conBean.setName(prefName); conBean.setSource(sDefSrc); conBean.setType(altNameType); vCon.add(conBean); totalReturnCount++; if (totalReturnCount >= sMetaLimit) return vCon; } } } } } catch (Exception ex) { System.out.println("Error do_EVSSearch Concept code: " + ex.toString()); } // Search Meta int length = 0; length = term.length(); ResolvedConceptReferenceList concepts = null; if (sSearchInEVS.equals("Concept Code")) concepts = searchConceptCode(evsService, "NCI Metathesaurus", term, sMetaLimit); else if (!sSearchInEVS.equals("Concept Code")) concepts = searchPrefTerm(evsService, "NCI Metathesaurus", term, sMetaLimit, algorithm); if (concepts != null) { ResolvedConceptReference rcr = new ResolvedConceptReference(); for (int i = 0; i < concepts.getResolvedConceptReferenceCount(); i++) { if (totalReturnCount >= sMetaLimit) break; rcr = concepts.getResolvedConceptReference(i); prefName = rcr.getEntityDescription().getContent(); CCode = rcr.getConceptCode(); Definition[] defs = rcr.getEntity().getDefinition(); if (defs == null) defs = new Definition[0]; sDef = sDefDefault; // "No Value Exists."; sDefSrc = ""; for (int k = 0; k < defs.length; k++) { Definition def = defs[k]; if (def != null) { sDef = def.getValue().getContent(); if (def.getSourceCount() > 0) sDefSrc = def.getSource(0).getContent(); // get def source } EVSBean conBean = new EVSBean(); conBean.setCode(CCode); conBean.setDefinition(sDef); conBean.setDictionary("NCI Metathesaurus"); conBean.setName(prefName); conBean.setSource(sDefSrc); conBean.setType("UMLS_CUI"); vCon.add(conBean); totalReturnCount++; if (totalReturnCount >= sMetaLimit) break; } } } evsService = null; System.out.println(vCon.size()); return vCon; }