Example #1
0
        public void testLookupOutputs()
        {
            EodSchemaLookup      lookup  = new EodSchemaLookup("C680", "8590");
            List <StagingSchema> lookups = _STAGING.lookupSchema(lookup);

            Assert.AreEqual(2, lookups.Count);

            StagingSchema schema = _STAGING.getSchema(lookups[0].getId());

            Assert.AreEqual("urethra", schema.getId());

            // build list of output keys
            List <StagingSchemaOutput> outputs        = schema.getOutputs();
            HashSet <String>           definedOutputs = new HashSet <String>();

            foreach (StagingSchemaOutput o in outputs)
            {
                definedOutputs.Add(o.getKey());
            }

            // test without context
            Assert.IsTrue(definedOutputs.SetEquals(_STAGING.getOutputs(schema)));

            // test with context
            Assert.IsTrue(definedOutputs.SetEquals(_STAGING.getOutputs(schema, lookup.getInputs())));
        }
Example #2
0
        public void testSchemaSelection()
        {
            // test bad values
            List <StagingSchema> lookup = _STAGING.lookupSchema(new SchemaLookup());

            Assert.AreEqual(0, lookup.Count);

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

            // test valid combinations that do not require a discriminator
            EodSchemaLookup schemaLookup = new EodSchemaLookup("C629", "9231");

            schemaLookup.setInput(EodInput.DISCRIMINATOR_1.toString(), "");
            lookup = _STAGING.lookupSchema(schemaLookup);
            Assert.AreEqual(1, lookup.Count);
            Assert.AreEqual("soft_tissue_other", lookup[0].getId());
            schemaLookup.setInput(EodInput.DISCRIMINATOR_1.toString(), null);
            lookup = _STAGING.lookupSchema(schemaLookup);
            Assert.AreEqual(1, lookup.Count);
            Assert.AreEqual("soft_tissue_other", lookup[0].getId());

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

            HashSet <String> hash1 = null;
            HashSet <String> hash2 = null;

            foreach (StagingSchema schema in lookup)
            {
                hash1 = new HashSet <String>()
                {
                    "discriminator_1", "discriminator_2"
                };
                hash2 = schema.getSchemaDiscriminators();
                Assert.IsTrue(hash1.IsSupersetOf(hash2));
            }

            // test valid combination that requires discriminator and a good discriminator is supplied
            schemaLookup = new EodSchemaLookup("C111", "8200");
            schemaLookup.setInput(EodInput.DISCRIMINATOR_1.toString(), "1");
            lookup = _STAGING.lookupSchema(schemaLookup);
            Assert.AreEqual(1, lookup.Count);
            foreach (StagingSchema schema in lookup)
            {
                hash1 = new HashSet <String>()
                {
                    "discriminator_1", "discriminator_2"
                };
                hash2 = schema.getSchemaDiscriminators();
                Assert.IsTrue(hash1.IsSupersetOf(hash2));

                /*
                 * System.Diagnostics.Trace.WriteLine("==========================================================================");
                 * String s = schema.GetDebugString("Test Schema ");
                 * System.Diagnostics.Trace.WriteLine(s);
                 *
                 * HashSet<String> tables = schema.getInvolvedTables();
                 * StagingTable thisTable;
                 * foreach (String tableName in tables)
                 * {
                 *  System.Diagnostics.Trace.WriteLine("---------------------------------------------------------------------------------");
                 *  thisTable = _STAGING.getTable(tableName);
                 *  s = thisTable.GetDebugString("Table " + tableName + " ");
                 *  System.Diagnostics.Trace.WriteLine(s);
                 *
                 *  List<DecisionEngine.IColumnDefinition> defList = thisTable.getColumnDefinitions();
                 *
                 * }
                 */
            }

            Assert.AreEqual("nasopharynx", lookup[0].getId());
            schemaLookup.setInput(EodInput.DISCRIMINATOR_1.toString(), "2");
            schemaLookup.setInput(EodInput.DISCRIMINATOR_2.toString(), "1");
            lookup = _STAGING.lookupSchema(schemaLookup);
            Assert.AreEqual(1, lookup.Count);
            foreach (StagingSchema schema in lookup)
            {
                hash1 = new HashSet <String>()
                {
                    "discriminator_1", "discriminator_2"
                };
                hash2 = schema.getSchemaDiscriminators();
                Assert.IsTrue(hash1.IsSupersetOf(hash2));
            }
            Assert.AreEqual("oropharynx_p16_neg", lookup[0].getId());

            // test valid combination that requires a discriminator but is supplied a bad disciminator value
            schemaLookup = new EodSchemaLookup("C111", "8200");
            schemaLookup.setInput(EodInput.DISCRIMINATOR_1.toString(), "X");
            lookup = _STAGING.lookupSchema(schemaLookup);
            Assert.AreEqual(0, lookup.Count);

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

            // test searching on only hist
            lookup = _STAGING.lookupSchema(new EodSchemaLookup(null, "9702"));
            Assert.AreEqual(5, lookup.Count);

            // test that searching on only discriminator_1 returns no results
            schemaLookup = new EodSchemaLookup(null, null);
            schemaLookup.setInput(EodInput.DISCRIMINATOR_1.toString(), "1");
            lookup = _STAGING.lookupSchema(schemaLookup);
            Assert.AreEqual(0, lookup.Count);
            schemaLookup = new EodSchemaLookup("", null);
            schemaLookup.setInput(EodInput.DISCRIMINATOR_1.toString(), "1");
            lookup = _STAGING.lookupSchema(schemaLookup);
            Assert.AreEqual(0, lookup.Count);
            schemaLookup = new EodSchemaLookup(null, "");
            schemaLookup.setInput(EodInput.DISCRIMINATOR_1.toString(), "1");
            lookup = _STAGING.lookupSchema(schemaLookup);
            Assert.AreEqual(0, lookup.Count);

            // test lookups based on sex
            schemaLookup = new EodSchemaLookup("C481", "8720");
            lookup       = _STAGING.lookupSchema(schemaLookup);
            Assert.AreEqual(2, lookup.Count);
            schemaLookup.setInput(EodInput.SEX.toString(), "1");
            lookup = _STAGING.lookupSchema(schemaLookup);
            Assert.AreEqual(1, lookup.Count);
            Assert.AreEqual("retroperitoneum", lookup[0].getId());
        }