Skip to content

lookupSchema

Chuck May edited this page Apr 14, 2015 · 9 revisions

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

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

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

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

// valid combinations that do not require a discriminator
lookup = staging.lookupSchema(new CsSchemaLookup("C629", "9231", ""));
Assert.assertEquals(1, lookup.size());
Assert.assertEquals("testis", lookup.get(0).getId());
Assert.assertEquals(Integer.valueOf(122), lookup.get(0).getSchemaNum());
lookup = staging.lookupSchema(new CsSchemaLookup("C629", "9231", null));
Assert.assertEquals(1, lookup.size());
Assert.assertEquals("testis", lookup.get(0).getId());
Assert.assertEquals(Integer.valueOf(122), lookup.get(0).getSchemaNum());

// valid combination that requires a discriminator but is not supplied one
lookup = staging.lookupSchema(new CsSchemaLookup("C111", "8200"));
Assert.assertEquals(2, lookup.size());
for (StagingSchema schema : lookup)
    Assert.assertEquals(Sets.newHashSet("ssf25"), schema.getSchemaDiscriminators());

// valid combination that requires discriminator and a good discriminator is 
// supplied
lookup = staging.lookupSchema(new CsSchemaLookup("C111", "8200", "010"));
Assert.assertEquals(1, lookup.size());
for (StagingSchema schema : lookup)
    Assert.assertEquals(Sets.newHashSet("ssf25"), schema.getSchemaDiscriminators());
Assert.assertEquals("nasopharynx", lookup.get(0).getId());
Assert.assertEquals(Integer.valueOf(34), lookup.get(0).getSchemaNum());

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

// test searching on only site
lookup = staging.lookupSchema(new CsSchemaLookup("C401", null, null));
Assert.assertEquals(5, lookup.size());

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