Skip to content

lookupSchema

halla edited this page Nov 2, 2017 · 1 revision

API

public List<StagingSchema> lookupSchema(SchemaLookup lookup)

Description

Look up a schema based on site, histology and an optional set of discriminators.

Staging a case requires first determining the correct schema. Schemas can be looked up based on primary site, histology and optionally one or more discriminators. Each staging algorithm has a SchemaLookup object customized for the specific inputs needed to lookup a schema.

For Collaborative Staging, use the CsSchemaLookup object. Here is a lookup based on site and histology.

CsSchemalookup input = new CsSchemaLookup("C629", "9231");
List<StagingSchema> lookup = staging.lookupSchema(input);

If the call returns a single result, then it was successful and that schema can be used to determine the inputs needed for staging. If it returns more than one result, then it needs one or more discriminators. Information about the required discriminator is included in the list of results. In the Collaborative Staging example, the field ssf25 is always used as the discriminator. Other staging algorithms may use different sets of discriminators that can be determined based on the result.

Examples

TNMStagingCSharp.Src.Staging.Staging staging = TNMStagingCSharp.Src.Staging.Staging.getInstance(CsDataProvider.getInstance(CsVersion.v020550));

// test bad values
List<StagingSchema> lookup = staging.lookupSchema(new SchemaLookup());
Assert.AreEqual(0, lookup.Count);

lookup = staging.lookupSchema(new CsSchemaLookup("XXX", "YYY"));
Assert.AreEqual(0, lookup.Count);

// valid combinations that do not require a discriminator
lookup = _STAGING.lookupSchema(new CsSchemaLookup("C629", "9231", ""));
Assert.AreEqual(1, lookup.Count);
Assert.AreEqual("testis", lookup[0].getId());
Assert.AreEqual(122, lookup[0].getSchemaNum());
lookup = _STAGING.lookupSchema(new CsSchemaLookup("C629", "9231", null));
Assert.AreEqual(1, lookup.Count);
Assert.AreEqual("testis", lookup[0].getId());
Assert.AreEqual(122, lookup[0].getSchemaNum());

// valid combination that requires a discriminator but is not supplied one
lookup = _STAGING.lookupSchema(new CsSchemaLookup("C111", "8200"));
Assert.AreEqual(2, lookup.Count);

HashSet<String> hash1 = null;
HashSet<String> hash2 = null;
foreach (StagingSchema schema in lookup)
{
	hash1 = new HashSet<String>() { "ssf25" };
	hash2 = schema.getSchemaDiscriminators();
	Assert.IsTrue(hash1.SetEquals(hash2));
}


// valid combination that requires discriminator and a good discriminator is supplied
lookup = _STAGING.lookupSchema(new CsSchemaLookup("C111", "8200", "010"));
Assert.AreEqual(1, lookup.Count);
foreach (StagingSchema schema in lookup)
{
	hash1 = new HashSet<String>() { "ssf25" };
  hash2 = schema.getSchemaDiscriminators();
  Assert.IsTrue(hash1.SetEquals(hash2));
}
Assert.AreEqual("nasopharynx", lookup[0].getId());
Assert.AreEqual(34, lookup[0].getSchemaNum());
    

// valid combination that requires a discriminator but is supplied a bad
// disciminator value
lookup = _STAGING.lookupSchema(new CsSchemaLookup("C111", "8200", "999"));
Assert.AreEqual(0, lookup.Count);

// test searching on only site
lookup = _STAGING.lookupSchema(new CsSchemaLookup("C401", null, null));
Assert.AreEqual(5, lookup.Count);

// test searching on only hist
lookup = _STAGING.lookupSchema(new CsSchemaLookup(null, "9702", null));
Assert.AreEqual(2, lookup.Count);
Clone this wiki locally