public void testStageUrethra()
        {
            TnmStagingData data = new TnmStagingData();

            data.setInput(TnmInput.PRIMARY_SITE, "C680");
            data.setInput(TnmInput.HISTOLOGY, "8000");
            data.setInput(TnmInput.BEHAVIOR, "3");
            data.setInput(TnmInput.DX_YEAR, "2016");
            data.setInput(TnmInput.RX_SUMM_SURGERY, "2");
            data.setInput(TnmInput.RX_SUMM_RADIATION, "4");
            data.setInput(TnmInput.REGIONAL_NODES_POSITIVE, "02");
            data.setInput(TnmInput.CLIN_T, "c0");
            data.setInput(TnmInput.CLIN_N, "c1");
            data.setInput(TnmInput.CLIN_M, "c0");
            data.setInput(TnmInput.PATH_T, "p0");
            data.setInput(TnmInput.PATH_N, "p1");
            data.setInput(TnmInput.PATH_M, "p1");

            // perform the staging
            _STAGING.stage(data);

            Assert.AreEqual(StagingData.Result.STAGED, data.getResult());
            Assert.AreEqual("urethra", data.getSchemaId());
            Assert.AreEqual(0, data.getErrors().Count);
            Assert.AreEqual(25, data.getPath().Count);
            Assert.AreEqual(10, data.getOutput().Count);

            // check outputs
            Assert.AreEqual(TnmVersion.LATEST.getVersion(), data.getOutput(TnmOutput.DERIVED_VERSION));
            Assert.AreEqual("3", data.getOutput(TnmOutput.CLIN_STAGE_GROUP));
            Assert.AreEqual("4", data.getOutput(TnmOutput.PATH_STAGE_GROUP));
            Assert.AreEqual("4", data.getOutput(TnmOutput.COMBINED_STAGE_GROUP));
            Assert.AreEqual("c0", data.getOutput(TnmOutput.COMBINED_T));
            Assert.AreEqual("1", data.getOutput(TnmOutput.SOURCE_T));
            Assert.AreEqual("c1", data.getOutput(TnmOutput.COMBINED_N));
            Assert.AreEqual("1", data.getOutput(TnmOutput.SOURCE_N));
            Assert.AreEqual("p1", data.getOutput(TnmOutput.COMBINED_M));
            Assert.AreEqual("2", data.getOutput(TnmOutput.SOURCE_M));
        }
Beispiel #2
0
        public static void MultiTask_TaskCompute(int id, Object task_data)
        {
            MultiTask_DataObj thisDataObj = (MultiTask_DataObj)task_data;

            try
            {
                // load up inputs
                TnmStagingData data = new TnmStagingData();
                foreach (KeyValuePair <TnmInput, String> kp in thisDataObj.mInputValues)
                {
                    data.setInput(kp.Key, kp.Value);
                }

                // save the expected outputs
                Dictionary <String, String> output = new Dictionary <String, String>(100, StringComparer.Ordinal);
                String sKeyValue = "";
                foreach (KeyValuePair <TnmOutput, String> entry in thisDataObj.mOutputValues)
                {
                    sKeyValue         = entry.Key.toString();
                    output[sKeyValue] = entry.Value;
                }


                // run collaborative stage; if no schema found, set the output to empty
                SchemaLookup lookup = new SchemaLookup(data.getInput(TnmInput.PRIMARY_SITE), data.getInput(TnmInput.HISTOLOGY));
                lookup.setInput(TnmStagingData.SEX_KEY, data.getInput(TnmInput.SEX));
                lookup.setInput(TnmStagingData.SSF25_KEY, data.getInput(TnmInput.SSF25));
                List <StagingSchema> schemas = mMultiTask_Staging.lookupSchema(lookup);

                if (schemas.Count == 1)
                {
                    mMultiTask_Staging.stage(data);
                }
                else
                {
                    Dictionary <String, String> outResult = new Dictionary <String, String>(2, StringComparer.Ordinal);
                    outResult["schema_id"] = "<invalid>";

                    data.setOutput(outResult);
                }

                List <String> mismatches = new List <String>();

                // compare results
                if (!thisDataObj.mbJSONFormat)
                {
                    String sNewResultStr = "";
                    String sOldResultStr = thisDataObj.msExpectedResult.Trim();
                    if (data.getResult() == StagingData.Result.STAGED)
                    {
                        sNewResultStr = "STAGED";
                    }
                    else if (data.getResult() == StagingData.Result.FAILED_MISSING_SITE_OR_HISTOLOGY)
                    {
                        sNewResultStr = "FAILED_MISSING_SITE_OR_HISTOLOGY";
                    }
                    else if (data.getResult() == StagingData.Result.FAILED_NO_MATCHING_SCHEMA)
                    {
                        sNewResultStr = "FAILED_NO_MATCHING_SCHEMA";
                    }
                    else if (data.getResult() == StagingData.Result.FAILED_MULITPLE_MATCHING_SCHEMAS)
                    {
                        sNewResultStr = "FAILED_MULITPLE_MATCHING_SCHEMAS";
                    }
                    else if (data.getResult() == StagingData.Result.FAILED_INVALID_YEAR_DX)
                    {
                        sNewResultStr = "FAILED_INVALID_YEAR_DX";
                    }
                    else if (data.getResult() == StagingData.Result.FAILED_INVALID_INPUT)
                    {
                        sNewResultStr = "FAILED_INVALID_INPUT";
                    }

                    if (sNewResultStr != sOldResultStr)
                    {
                        mismatches.Add("   " + thisDataObj.miLineNum + " --> Result: EXPECTED '" + sOldResultStr + "' ACTUAL: '" + sNewResultStr + "'");
                    }
                }

                // compare output
                foreach (KeyValuePair <String, String> entry in output)
                {
                    String expected = "";
                    output.TryGetValue(entry.Key, out expected);
                    if (expected == null)
                    {
                        expected = "";
                    }
                    expected = expected.Trim();

                    String actual = "";
                    data.getOutput().TryGetValue(entry.Key, out actual);
                    if (actual == null)
                    {
                        actual = "";
                    }
                    actual = actual.Trim();

                    if (expected != actual)
                    {
                        mismatches.Add("   " + thisDataObj.miLineNum + " --> " + entry.Key + ": EXPECTED '" + expected + "' ACTUAL: '" + actual + "'");
                    }
                }

                if (mismatches.Count != 0)
                {
                    String sSchemaIDValue = data.getSchemaId();


                    IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " --> [" + sSchemaIDValue + "] Mismatches in " + thisDataObj.msFileName);
                    foreach (String mismatch in mismatches)
                    {
                        IntegrationUtils.WritelineToLog(mismatch);
                    }
                    IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " *** RESULT: " + data.getResult());
                    IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " --> Input: " + IntegrationUtils.convertInputMap(data.getInput()));
                    IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " --> Output: " + IntegrationUtils.convertInputMap(data.getOutput()));
                    if (data.getErrors().Count > 0)
                    {
                        IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " --> ERRORS: ");
                        foreach (Error e in data.getErrors())
                        {
                            IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " --> (" + e.getTable() + ": " + e.getMessage() + ") ");
                        }
                    }

                    Interlocked.Increment(ref miMultiTask_FailedCases);
                }
            }
            catch (Exception e)
            {
                IntegrationUtils.WritelineToLog("   " + thisDataObj.miLineNum + " --> Exception processing " + thisDataObj.msFileName + " : " + e.Message);
                Interlocked.Increment(ref miMultiTask_FailedCases);
            }

            Interlocked.Increment(ref miMultiTask_ThreadProcessedCases);
        }