/**
   * Test coding scheme restriction search.
   *
   * @throws Exception the exception
   */
  public void testCodingSchemeRestrictionSearch() throws Exception {
    LexBIGServiceMetadata md = ServiceHolder.instance().getLexBIGService().getServiceMetadata();
    md = md.restrictToValue("English", "LuceneQuery");
    MetadataProperty[] result = md.resolve().getMetadataProperty();

    HashSet<String> temp = new HashSet<String>();
    for (int i = 0; i < result.length; i++) {
      temp.add(result[i].getCodingSchemeURI() + ":" + result[i].getCodingSchemeVersion());
    }

    // should contain this
    assertTrue(temp.contains(THES_URN + ":" + THES_METADATA_VERSION));

    // now do the restriction, and retest.

    md = ServiceHolder.instance().getLexBIGService().getServiceMetadata();
    md = md.restrictToValue("English", "LuceneQuery");
    md =
        md.restrictToCodingScheme(
            Constructors.createAbsoluteCodingSchemeVersionReference(
                THES_URN, THES_METADATA_VERSION));
    result = md.resolve().getMetadataProperty();

    temp = new HashSet<String>();
    for (int i = 0; i < result.length; i++) {
      temp.add(result[i].getCodingSchemeURI() + ":" + result[i].getCodingSchemeVersion());
    }

    // should be more than 1 unique code system.
    assertTrue(temp.size() >= 1);

    // should contain this
    assertTrue(temp.contains(THES_URN + ":" + THES_METADATA_VERSION));
  }
  public void testT1_FNC_11() throws LBException {
    // in LexBig, a role is just an association, so this is traversing
    // associations.

    CodedNodeGraph cng =
        ServiceHolder.instance().getLexBIGService().getNodeGraph(THES_SCHEME, null, null);
    cng.restrictToAssociations(
        Constructors.createNameAndValueList(new String[] {"subClassOf"}), null);

    // role "Anatomy_Kind"
    ResolvedConceptReference[] rcr =
        cng.resolveAsList(
                Constructors.createConceptReference("Anatomy_Kind", THES_SCHEME),
                false,
                true,
                1,
                1,
                null,
                null,
                null,
                0)
            .getResolvedConceptReference();

    // check for some source (down) codes that I know should be there.
    assertTrue(rcr.length == 1);
    assertTrue(rcr[0].getConceptCode().equals("Anatomy_Kind"));

    Association[] a = rcr[0].getTargetOf().getAssociation();
    assertTrue(contains(a, "subClassOf", "Anatomic_Structure_System_or_Substance"));

    // go down one more level from one of the codes.
    ConvenienceMethods cm = new ConvenienceMethods(ServiceHolder.instance().getLexBIGService());
    a =
        new Association[] {
          cm.getAssociationForwardOneLevel(
              "Anatomic_Structure_System_or_Substance",
              "roles",
              "subClassOf",
              THES_SCHEME,
              null,
              false,
              null)
        };

    contains(a, "subClassOf", "C13018");
    contains(a, "subClassOf", "Body_Fluid_or_Substance");
  }
Exemple #3
0
  /**
   * Primary entry point for the program.
   *
   * @throws Exception
   */
  public void run(String[] args) throws Exception {
    synchronized (ResourceManager.instance()) {

      // Parse the command line ...
      CommandLine cl = null;
      Options options = getCommandOptions();
      try {
        cl = new BasicParser().parse(options, args);
      } catch (ParseException e) {
        Util.displayCommandOptions(
            "TagScheme",
            options,
            "TagScheme -u \"urn:oid:2.16.840.1.113883.3.26.1.1\" -v \"05.09e\" -t \"TEST\"",
            e);
        Util.displayMessage(Util.getPromptForSchemeHelp());
        return;
      }

      // Interpret provided values ...
      String urn = cl.getOptionValue("u");
      String ver = cl.getOptionValue("v");
      String tag = cl.getOptionValue("t").trim();
      CodingSchemeSummary css = null;

      // Find in list of registered vocabularies ...
      if (urn != null && ver != null) {
        urn = urn.trim();
        ver = ver.trim();
        LexBIGService lbs = LexBIGServiceImpl.defaultInstance();
        Enumeration<? extends CodingSchemeRendering> schemes =
            lbs.getSupportedCodingSchemes().enumerateCodingSchemeRendering();
        while (schemes.hasMoreElements() && css == null) {
          CodingSchemeSummary summary = schemes.nextElement().getCodingSchemeSummary();
          if (urn.equalsIgnoreCase(summary.getCodingSchemeURI())
              && ver.equalsIgnoreCase(summary.getRepresentsVersion())) css = summary;
        }
      }

      // Found it? If not, prompt...
      if (css == null) {
        if (urn != null || ver != null) {
          Util.displayMessage("No matching coding scheme was found for the given URN or version.");
          Util.displayMessage("");
        }
        css = Util.promptForCodeSystem();
        if (css == null) return;
      }

      // Continue and perform the action ...
      Util.displayTaggedMessage("A matching coding scheme was found ...");
      LexBIGServiceManager lbsm =
          LexBIGServiceImpl.defaultInstance().getServiceManager(new Object());
      lbsm.setVersionTag(Constructors.createAbsoluteCodingSchemeVersionReference(css), tag);
      Util.displayTaggedMessage("Request complete");
    }
  }
  /**
   * Testfor current or obsolete conceptb.
   *
   * @throws LBException the LB exception
   */
  public void testforCurrentOrObsoleteConceptb() throws LBException {

    // same as above, but this time, using the new methods (that aren't deprecated)
    CodedNodeSet cns =
        ServiceHolder.instance().getLexBIGService().getCodingSchemeConcepts(THES_SCHEME, null);
    cns = cns.restrictToStatus(ActiveOption.ACTIVE_ONLY, null);
    cns =
        cns.restrictToCodes(
            Constructors.createConceptReferenceList(new String[] {"C38389"}, THES_SCHEME));
    ResolvedConceptReference[] rcr =
        cns.resolveToList(null, null, null, 0).getResolvedConceptReference();

    assertTrue("1", rcr.length == 0);

    cns = ServiceHolder.instance().getLexBIGService().getCodingSchemeConcepts(THES_SCHEME, null);
    cns = cns.restrictToStatus(ActiveOption.ALL, null);
    cns =
        cns.restrictToCodes(
            Constructors.createConceptReferenceList(new String[] {"C38389"}, THES_SCHEME));
    rcr = cns.resolveToList(null, null, null, 0).getResolvedConceptReference();

    assertTrue("2", rcr.length == 1);

    // same test again - no status restriction
    cns = ServiceHolder.instance().getLexBIGService().getCodingSchemeConcepts(THES_SCHEME, null);
    cns =
        cns.restrictToCodes(
            Constructors.createConceptReferenceList(new String[] {"C38389"}, THES_SCHEME));
    rcr = cns.resolveToList(null, null, null, 0).getResolvedConceptReference();

    assertTrue("3", rcr.length == 1);

    // add a status restriction
    cns = ServiceHolder.instance().getLexBIGService().getCodingSchemeConcepts(THES_SCHEME, null);
    cns =
        cns.restrictToMatchingDesignations(
            "Sex Not Known", SearchDesignationOption.ALL, "exactMatch", null);
    cns = cns.restrictToStatus(ActiveOption.INACTIVE_ONLY, null);
    rcr = cns.resolveToList(null, null, null, 0).getResolvedConceptReference();
    assertTrue("4", rcr.length == 1);

    assertFalse("6", rcr[0].getReferencedEntry().getIsActive().booleanValue());
  }
  /**
   * Test list coding schemes.
   *
   * @throws Exception the exception
   */
  public void testListCodingSchemes() throws Exception {
    LexBIGServiceMetadata md = ServiceHolder.instance().getLexBIGService().getServiceMetadata();
    AbsoluteCodingSchemeVersionReference[] acsvrl =
        md.listCodingSchemes().getAbsoluteCodingSchemeVersionReference();

    assertTrue(acsvrl.length >= 1);
    assertTrue(
        contains(
            acsvrl,
            Constructors.createAbsoluteCodingSchemeVersionReference(
                THES_URN, THES_METADATA_VERSION)));
  }
  public void testT1_FNC_02() throws LBException {

    CodedNodeSet cns =
        ServiceHolder.instance().getLexBIGService().getCodingSchemeConcepts(THES_SCHEME, null);
    cns.restrictToCodes(
        Constructors.createConceptReferenceList(
            new String[] {"Vallecula", "Palate", "Hard_Palate"}, THES_SCHEME));

    // this test is really lacking... but here is how you subset. You can
    // serialize however
    // you want from here...
    assertTrue(cns.resolveToList(null, null, null, 0).getResolvedConceptReference().length == 3);
  }
  /**
   * Test container restriction search.
   *
   * @throws Exception the exception
   */
  public void testContainerRestrictionSearch() throws Exception {
    LexBIGServiceMetadata md = ServiceHolder.instance().getLexBIGService().getServiceMetadata();

    md = md.restrictToValue("OWL-FULL", "LuceneQuery");
    md =
        md.restrictToCodingScheme(
            Constructors.createAbsoluteCodingSchemeVersionReference(
                THES_URN, THES_METADATA_VERSION));

    MetadataProperty[] result = md.resolve().getMetadataProperty();
    assertTrue(result.length >= 1);
    assertTrue(contains(result, THES_URN, THES_METADATA_VERSION, "format", "OWL-FULL"));
  }
  /**
   * Test retrieve most recent versionof concept.
   *
   * @throws LBException the LB exception
   */
  public void testRetrieveMostRecentVersionofConcept() throws LBException {

    // not providing a version number gets you the PRODUCTION (which can be assumed to be the latest
    // good version)

    CodedNodeSet cns =
        ServiceHolder.instance().getLexBIGService().getCodingSchemeConcepts(THES_SCHEME, null);
    cns =
        cns.restrictToCodes(
            Constructors.createConceptReferenceList(new String[] {"C12223"}, THES_SCHEME));

    assertTrue(cns.resolveToList(null, null, null, 0).getResolvedConceptReference().length == 1);
  }
  private Set<CodingSchemeReference> toCodingSchemeReference(
      Iterable<NameOrURI> codeSystemVersions) {
    Set<CodingSchemeReference> returnSet = new HashSet<CodingSchemeReference>();

    for (NameOrURI version : codeSystemVersions) {
      NameVersionPair pair = this.versionNameConverter.fromCts2VersionName(version.getName());

      CodingSchemeReference ref = new CodingSchemeReference();
      ref.setCodingScheme(pair.getName());
      ref.setVersionOrTag(
          Constructors.createCodingSchemeVersionOrTagFromVersion(pair.getVersion()));

      returnSet.add(ref);
    }

    return returnSet;
  }
  /**
   * Test value restriction.
   *
   * @throws Exception the exception
   */
  public void testValueRestriction() throws Exception {
    LexBIGServiceMetadata md = ServiceHolder.instance().getLexBIGService().getServiceMetadata();
    md =
        md.restrictToCodingScheme(
            Constructors.createAbsoluteCodingSchemeVersionReference(
                THES_URN, THES_METADATA_VERSION));
    md = md.restrictToValue(".*core.*", "RegExp");

    MetadataProperty[] result = md.resolve().getMetadataProperty();
    assertTrue(result.length >= 2);
    assertTrue(
        contains(
            result,
            THES_URN,
            THES_METADATA_VERSION,
            "homepage",
            "http://ncicb.nci.nih.gov/core/EVS"));
  }
  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() + "'");
      }
    }
  }