@Override
  public AnonymousEntityDescription convertTo(
      ResolvedConceptReference source, AnonymousEntityDescription target) {
    if (StringUtils.isBlank(source.getCode()) || StringUtils.isBlank(source.getCodeNamespace())) {
      return target;
    }
    CodingScheme cs =
        codingSchemeService.getCodingSchemeByUriAndVersion(
            source.getCodingSchemeURI(), source.getCodingSchemeVersion());

    for (org.LexGrid.concepts.Comment c : source.getEntity().getComment()) {
      org.cts2.core.Comment comment = this.baseDozerBeanMapper.map(c, org.cts2.core.Comment.class);

      // process supported mappings
      if (cs != null) {
        if (comment.getFormat() != null && !StringUtils.isEmpty(comment.getFormat().getContent())) {
          SupportedDataType supportedDataType =
              DaoUtility.getURIMap(cs, SupportedDataType.class, comment.getFormat().getContent());
          if (supportedDataType != null) comment.getFormat().setMeaning(supportedDataType.getUri());
        }

        if (comment.getLanguage() != null
            && !StringUtils.isEmpty(comment.getLanguage().getContent())) {
          SupportedLanguage supportedLanguage =
              DaoUtility.getURIMap(cs, SupportedLanguage.class, comment.getLanguage().getContent());
          if (supportedLanguage != null)
            comment.getLanguage().setMeaning(supportedLanguage.getUri());
        }
      }
      target.addNote(comment);
    }
    return target;
  }
  /**
   * Resolve the Iterator
   *
   * @param iterator
   * @param maxToReturn
   * @param code
   * @return
   */
  public Vector<Entity> resolveIterator(
      ResolvedConceptReferencesIterator iterator, int maxToReturn, String code) {

    Vector<Entity> v = new Vector<Entity>();

    if (iterator == null) {
      _logger.warn("No match.");
      return v;
    }
    try {
      int iteration = 0;
      while (iterator.hasNext()) {
        iteration++;
        iterator = iterator.scroll(maxToReturn);
        ResolvedConceptReferenceList rcrl = iterator.getNext();
        ResolvedConceptReference[] rcra = rcrl.getResolvedConceptReference();
        for (int i = 0; i < rcra.length; i++) {
          ResolvedConceptReference rcr = rcra[i];
          Entity ce = rcr.getReferencedEntry();
          if (code == null) {
            v.add(ce);
          } else {
            if (ce.getEntityCode().compareTo(code) != 0) v.add(ce);
          }
        }
      }
    } catch (Exception e) {
      _logger.warn(e.getMessage());
    }
    return v;
  }
Exemplo n.º 3
0
 /** Force a refresh of all names assigned to graph nodes. */
 @SuppressWarnings("unchecked")
 void refreshNodeNames(boolean showCode, boolean abbreviate) {
   for (Iterator<Tuple> tuples = getNodes().tuples(); tuples.hasNext(); ) {
     Tuple t = tuples.next();
     ResolvedConceptReference rcr = (ResolvedConceptReference) t.get("RCR");
     if (rcr != null) {
       String code = showCode ? rcr.getConceptCode() : null;
       String desc =
           rcr.getEntityDescription() != null ? rcr.getEntityDescription().getContent() : null;
       t.set("name", getNodeName(code, desc, abbreviate, "\n"));
     }
   }
 }
  private boolean compareResolvedConceptReferenceList(
      ResolvedConceptReferenceList list1, ResolvedConceptReferenceList list2) {
    ResolvedConceptReference[] rcr1 = list1.getResolvedConceptReference();
    ResolvedConceptReference[] rcr2 = list2.getResolvedConceptReference();

    boolean found = false;
    for (int i = 0; i < rcr1.length; i++) {
      ResolvedConceptReference ref = rcr1[i];
      String searchCode = ref.getConceptCode();
      for (int j = 0; j < rcr2.length; j++) {
        ResolvedConceptReference searchRef = rcr2[j];
        String foundCode = searchRef.getConceptCode();
        if (searchCode.equals(foundCode)) {
          found = true;
        }
      }
    }
    return found;
  }
Exemplo n.º 5
0
  /*
   * (non-Javadoc)
   *
   * @see prefuse.data.Graph#addNode()
   */
  public Node addNode(ResolvedConceptReference rcr, boolean showCode) {
    // Limit length for nodes other than the focus item
    // to allow more items in same horizontal space.
    String code = showCode ? rcr.getConceptCode() : null;
    String desc =
        rcr.getEntityDescription() != null ? rcr.getEntityDescription().getContent() : null;
    String nodeName = getNodeName(code, desc, false, "\n");

    if (allNodes.containsKey(nodeName)) {
      return allNodes.get(nodeName);
    } else {
      Node newNode = addNode();

      newNode.setString("name", nodeName);
      newNode.set("RCR", rcr);
      allNodes.put(nodeName, newNode);
      return newNode;
    }
  }
Exemplo n.º 6
0
  public void run() throws LBException {
    ValueSetDefinition vsd = Util.promptForValueSetDefinition(message);
    if (vsd != null) {
      AbsoluteCodingSchemeVersionReferenceList acsvList = null;
      Util.displayMessage("Now select Code System to use to resolve Value Set Definition");
      CodingSchemeSummary css = Util.promptForCodeSystem();
      if (css != null) {
        acsvList = new AbsoluteCodingSchemeVersionReferenceList();
        acsvList.addAbsoluteCodingSchemeVersionReference(
            Constructors.createAbsoluteCodingSchemeVersionReference(
                css.getCodingSchemeURI(), css.getRepresentsVersion()));
      }

      LexEVSValueSetDefinitionServices vsdServ =
          LexEVSValueSetDefinitionServicesImpl.defaultInstance();
      ResolvedValueSetDefinition rVSD = null;
      try {
        rVSD =
            vsdServ.resolveValueSetDefinition(
                new URI(vsd.getValueSetDefinitionURI()), null, acsvList, null, null);
      } catch (URISyntaxException e) {
        e.printStackTrace();
      }

      if (rVSD != null) {
        Util.displayMessage(
            "Member of Value Set Definition (" + vsd.getValueSetDefinitionURI() + ") are :");
        ResolvedConceptReferencesIterator conceptItr = rVSD.getResolvedConceptReferenceIterator();
        while (conceptItr.hasNext()) {
          ResolvedConceptReference concept = conceptItr.next();
          Util.displayMessage("Concept code : " + concept.getCode());
          Util.displayMessage("\tCoding Scheme Name...: " + concept.getCodingSchemeName());
          Util.displayMessage("\tCoding Scheme URI....: " + concept.getCodingSchemeURI());
          Util.displayMessage("\tCoding Scheme Version: " + concept.getCodingSchemeVersion());
        }
      } else {
        Util.displayMessage(
            "No members found for Value Set Definition : '" + vsd.getValueSetDefinitionURI() + "'");
      }
    }
  }
  public void testNext() {
    try {
      LexBIGService lbs = ServiceHolder.instance().getLexBIGService();
      CodedNodeSet cns = lbs.getCodingSchemeConcepts("NCI Thesaurus", null);
      cns = cns.restrictToMatchingDesignations("heart", null, "startsWith", null);

      ResolvedConceptReferencesIterator rcrl = cns.resolve(null, null, null, null, false);

      String conceptCode = null;

      while (rcrl.hasNext()) {
        ResolvedConceptReference ref = rcrl.next();
        String currentCode = ref.getConceptCode();
        assertFalse(currentCode.equals(conceptCode));
        conceptCode = currentCode;
      }
    } catch (Exception e) {
      fail("Exception Thrown: " + e.getMessage());
      e.printStackTrace();
    }
  }
 /**
  * Return list of Comments
  *
  * @param ref
  * @return
  */
 public Property[] getCommentValues(ResolvedConceptReference ref) {
   return returnProperties(ref.getReferencedEntry().getComment());
 }
 /**
  * Returns list of Child Concepts
  *
  * @param ref
  * @return
  */
 public Vector<String> getChildConcepts(ResolvedConceptReference ref) throws Exception {
   String code = ref.getCode();
   Vector<String> supconcepts = getAssociatedConcepts(code, false);
   return supconcepts;
 }
Exemplo n.º 10
0
 /**
  * Return list of Definitions
  *
  * @param ref
  * @return
  */
 public Property[] getDefinitionValues(ResolvedConceptReference ref) {
   return returnProperties(ref.getReferencedEntry().getDefinition());
 }
Exemplo n.º 11
0
  public static String getEVSCode(String prefName, String dtsVocab) {
    LexEVSApplicationService evsService = null;

    try {
      evsService =
          (LexEVSApplicationService)
              ApplicationServiceProvider.getApplicationService("EvsServiceInfo");

    } catch (Exception e) {
      throw new RuntimeException(e);
    }

    if (dtsVocab == null) dtsVocab = "";
    String CCode = "";
    if (dtsVocab.equals("Thesaurus/Metathesaurus")
        || dtsVocab.equals("")
        || dtsVocab.equals("NCI Thesaurus")
        || dtsVocab.equals("NCI_Thesaurus")) dtsVocab = "NCI_Thesaurus";
    ResolvedConceptReferenceList codes2 = null;
    int codesSize = 0;

    try {
      CodedNodeSet metaNodes = evsService.getNodeSet("NCI MetaThesaurus", null, null);

      metaNodes =
          metaNodes.restrictToMatchingDesignations(
              prefName, // the text to match
              CodedNodeSet.SearchDesignationOption
                  .PREFERRED_ONLY, // whether to search all designation, only Preferred or only
                                   // Non-Preferred
              "exactMatch", // the match algorithm to use
              null); // the language to match (null matches all)

      metaNodes = metaNodes.restrictToStatus(ActiveOption.ACTIVE_ONLY, null);

      codes2 =
          metaNodes.resolveToList(
              null, // Sorts used to sort results (null means sort by match score)
              null, // PropertyNames to resolve (null resolves all)
              new CodedNodeSet.PropertyType[] {
                PropertyType.DEFINITION, PropertyType.PRESENTATION
              }, // PropertyTypess to resolve (null resolves all)  //PropertyTypess to resolve (null
                 // resolves all)
              10 // cap the number of results returned (-1 resolves all)
              );
      codesSize = codes2.getResolvedConceptReferenceCount();

    } catch (Exception ex) {
      System.err.println("Error do_getEVSCode:resolveToList: " + ex.toString());
      ex.printStackTrace();
    }

    if (codes2 != null) {
      ResolvedConceptReference conceptReference = new ResolvedConceptReference();
      // logger.debug("Got "+codesSize+" results for the do_getEVSCode search using prefName and
      // exactMatch");
      for (int i = 0; i < codesSize; i++) {
        conceptReference = (ResolvedConceptReference) codes2.getResolvedConceptReference(i);
        CCode = (String) conceptReference.getConceptCode();
      }
    }

    evsService = null;
    return CCode;
  }
Exemplo n.º 12
0
  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;
  }