public static NeurologyFormTotals LoadNeurologyFormTotalsFrom(XDocument xmlDocument)
        {
            var totalsXml = xmlDocument.Root.Element("NeurologyFormTotals");

            var neurologyFormTotals = new NeurologyFormTotals
            {
                LeftPrickContainsNt = bool.Parse(totalsXml.Element("LeftPrickContainsNt").Value),
                LeftPrickTotal = GetIntValueFrom(totalsXml.Element("LeftPrickTotal").Value),
                LeftPrickTotalHasImpairmentNotDueToSci = DoesTotalHaveImpairmentNotDueToSci(totalsXml.Element("LeftPrickTotal").Value),
                LeftTouchContainsNt = bool.Parse(totalsXml.Element("LeftTouchContainsNt").Value),
                LeftTouchTotal = GetIntValueFrom(totalsXml.Element("LeftTouchTotal").Value),
                LeftTouchTotalHasImpairmentNotDueToSci = DoesTotalHaveImpairmentNotDueToSci(totalsXml.Element("LeftTouchTotal").Value),
                LeftLowerMotorContainsNt = bool.Parse(totalsXml.Element("LeftLowerMotorContainsNt").Value),
                LeftLowerMotorTotal = GetIntValueFrom(totalsXml.Element("LeftLowerMotorTotal").Value),
                LeftLowerMotorTotalHasImpairmentNotDueToSci = DoesTotalHaveImpairmentNotDueToSci(totalsXml.Element("LeftLowerMotorTotal").Value),
                LeftUpperMotorContainsNt = bool.Parse(totalsXml.Element("LeftUpperMotorContainsNt").Value),
                LeftUpperMotorTotal = GetIntValueFrom(totalsXml.Element("LeftUpperMotorTotal").Value),
                LeftUpperMotorTotalHasImpairmentNotDueToSci = DoesTotalHaveImpairmentNotDueToSci(totalsXml.Element("LeftUpperMotorTotal").Value),
                LowerMotorTotal = GetIntValueFrom(totalsXml.Element("LowerMotorTotal").Value),
                PrickTotal = GetIntValueFrom(totalsXml.Element("PrickTotal").Value),
                RightLowerMotorContainsNt = bool.Parse(totalsXml.Element("RightLowerMotorContainsNt").Value),
                RightLowerMotorTotal = GetIntValueFrom(totalsXml.Element("RightLowerMotorTotal").Value),
                RightLowerMotorTotalHasImpairmentNotDueToSci = DoesTotalHaveImpairmentNotDueToSci(totalsXml.Element("RightLowerMotorTotal").Value),
                RightUpperMotorContainsNt = bool.Parse(totalsXml.Element("RightUpperMotorContainsNt").Value),
                RightUpperMotorTotal = GetIntValueFrom(totalsXml.Element("RightUpperMotorTotal").Value),
                RightUpperMotorTotalHasImpairmentNotDueToSci = DoesTotalHaveImpairmentNotDueToSci(totalsXml.Element("RightUpperMotorTotal").Value),
                RightPrickContainsNt = bool.Parse(totalsXml.Element("RightPrickContainsNt").Value),
                RightPrickTotal = GetIntValueFrom(totalsXml.Element("RightPrickTotal").Value),
                RightPrickTotalHasImpairmentNotDueToSci = DoesTotalHaveImpairmentNotDueToSci(totalsXml.Element("RightPrickTotal").Value),
                RightTouchContainsNt = bool.Parse(totalsXml.Element("RightTouchContainsNt").Value),
                RightTouchTotal = GetIntValueFrom(totalsXml.Element("RightTouchTotal").Value),
                RightTouchTotalHasImpairmentNotDueToSci = DoesTotalHaveImpairmentNotDueToSci(totalsXml.Element("RightTouchTotal").Value),
                TouchTotal = GetIntValueFrom(totalsXml.Element("TouchTotal").Value),
                UpperMotorTotal = GetIntValueFrom(totalsXml.Element("UpperMotorTotal").Value),
            };

            var levelsDictionary = GetLevelsDictionary();

            foreach (var value in totalsXml.Element("RightSensory").Value.Split(',').Select(v => v.Trim()))
                neurologyFormTotals.AddRightSensoryValue(levelsDictionary[value.ToUpper()]);

            foreach (var value in totalsXml.Element("LeftSensory").Value.Split(',').Select(v => v.Trim()))
                neurologyFormTotals.AddLeftSensoryValue(levelsDictionary[value.ToUpper()]);

            foreach (var value in totalsXml.Element("RightMotor").Value.Split(',').Select(v => v.Trim()))
                neurologyFormTotals.AddRightMotorValue(levelsDictionary[value.ToUpper()]);

            foreach (var value in totalsXml.Element("LeftMotor").Value.Split(',').Select(v => v.Trim()))
                neurologyFormTotals.AddLeftMotorValue(levelsDictionary[value.ToUpper()]);

            foreach (var value in totalsXml.Element("NeurologicalLevelOfInjury").Value.Split(',').Select(v => v.Trim()))
                neurologyFormTotals.AddNeurologicalLevelOfInjury(levelsDictionary[value.ToUpper()]);

            foreach (var value in totalsXml.Element("RightSensoryZpp").Value.Split(',').Select(v => v.Trim()))
                if (!string.IsNullOrEmpty(value))
                    neurologyFormTotals.AddRightSensoryZppValue(levelsDictionary[value.ToUpper()]);

            foreach (var value in totalsXml.Element("LeftSensoryZpp").Value.Split(',').Select(v => v.Trim()))
                if (!string.IsNullOrEmpty(value))
                    neurologyFormTotals.AddLeftSensoryZppValue(levelsDictionary[value.ToUpper()]);

            foreach (var value in totalsXml.Element("RightMotorZpp").Value.Split(',').Select(v => v.Trim()))
                if (!string.IsNullOrEmpty(value))
                    neurologyFormTotals.AddRightMotorZppValue(levelsDictionary[value.ToUpper()]);

            foreach (var value in totalsXml.Element("LeftMotorZpp").Value.Split(',').Select(v => v.Trim()))
                if (!string.IsNullOrEmpty(value))
                    neurologyFormTotals.AddLeftMotorZppValue(levelsDictionary[value.ToUpper()]);

            foreach (var value in totalsXml.Element("AsiaImpairmentScale").Value.Split(',').Select(v => v.Trim()))
                neurologyFormTotals.AddAsiaImpairmentScaleValue(value.ToUpper());

            return neurologyFormTotals;
        }
예제 #2
0
        /// <summary>
        /// Returns the results produced by the ISNCSCI Algorithm ir a raw values format.
        /// </summary>
        /// <param name="neurologyForm">Neurology form that has been populated with the values to be used in the algorithm calculations.</param>
        /// <returns>
        /// Totals in raw values format.  The results contain lists with every prossible value for each field.
        /// You can use the resulting object to obtained a summarized version, which uses ranges, by passing the result to the method GetTotalsSummaryFor
        /// </returns>
        public static NeurologyFormTotals GetTotalsFor(NeurologyForm neurologyForm)
        {
            var totals = new NeurologyFormTotals();

            UpdateTotalsWithLevelAt(neurologyForm, totals, neurologyForm.GetLevelWithName("C2"), false, false);

            totals.UpperMotorTotal = totals.RightUpperMotorTotal + totals.LeftUpperMotorTotal;
            totals.LowerMotorTotal = totals.RightLowerMotorTotal + totals.LeftLowerMotorTotal;
            totals.TouchTotal = totals.RightTouchTotal + totals.LeftTouchTotal;
            totals.PrickTotal = totals.RightPrickTotal + totals.LeftPrickTotal;

            var s4_5 = neurologyForm.GetLevelWithName("S4_5");

            var c1 = neurologyForm.GetLevelWithName("C2").Previous;

            if (totals.RightSensoryZppHasOnlySoftValues)
                totals.AddRightSensoryZppValue(c1);

            if (totals.LeftSensoryZppHasOnlySoftValues)
                totals.AddLeftSensoryZppValue(c1);

            if (totals.RightMotorZppHasOnlySoftValues)
                totals.AddRightMotorZppValue(c1);

            if (totals.LeftMotorZppHasOnlySoftValues)
                totals.AddLeftMotorZppValue(c1);

            if (totals.MostRostralRightLevelWithMotorFunction == null)
                totals.MostRostralRightLevelWithMotorFunction = c1;

            if (totals.MostRostralLeftLevelWithMotorFunction == null)
                totals.MostRostralLeftLevelWithMotorFunction = c1;

            if (totals.MostCaudalRightLevelWithMotorFunction == null)
                totals.MostCaudalRightLevelWithMotorFunction = c1;

            if (totals.MostCaudalLeftLevelWithMotorFunction == null)
                totals.MostCaudalLeftLevelWithMotorFunction = c1;

            // [ASIA learning center 2012-11-14] Sensory incomplete: Sacral sparing of sensory function
            var isSensoryIncomplete = neurologyForm.AnalSensation == BinaryObservation.Yes || neurologyForm.AnalSensation == BinaryObservation.NT
                || !"0".Equals(s4_5.RightTouchName) || !"0".Equals(s4_5.LeftTouchName)
                || !"0".Equals(s4_5.RightPrickName) || !"0".Equals(s4_5.LeftPrickName);

            var couldNotHaveMotorFunctionMoreThan3LevelsBelowMotorLevel = CouldNotHaveMotorFunctionMoreThan3LevelsBelowMotorLevel(neurologyForm, totals);

            var couldNotBeMotorIncomplete = (neurologyForm.AnalContraction == BinaryObservation.No || neurologyForm.AnalContraction == BinaryObservation.NT)
                && isSensoryIncomplete && couldNotHaveMotorFunctionMoreThan3LevelsBelowMotorLevel;

            if ((neurologyForm.AnalContraction == BinaryObservation.No || neurologyForm.AnalContraction == BinaryObservation.NT)
                && (neurologyForm.AnalSensation == BinaryObservation.No || neurologyForm.AnalSensation == BinaryObservation.NT)
                && s4_5.RightTouchValue == 0 && !s4_5.RightTouchImpairmentNotDueToSci
                && s4_5.RightPrickValue == 0 && !s4_5.RightPrickImpairmentNotDueToSci
                && s4_5.LeftTouchValue == 0 && !s4_5.LeftTouchImpairmentNotDueToSci
                && s4_5.LeftPrickValue == 0 && !s4_5.LeftPrickImpairmentNotDueToSci)
                totals.AddAsiaImpairmentScaleValue("A");

            if (couldNotBeMotorIncomplete && totals.MostRostralNeurologicalLevelOfInjury.Name != "S4_5")
                totals.AddAsiaImpairmentScaleValue("B");

            //// Not an ASIA E only
            //// AND not an ASIA A only
            if (totals.MostRostralNeurologicalLevelOfInjury.Name != "S4_5"
                && (isSensoryIncomplete || neurologyForm.AnalContraction == BinaryObservation.Yes || neurologyForm.AnalContraction == BinaryObservation.NT))
            {
                bool couldBeAsiaC;
                bool couldBeAsiaD;
                CouldBeAsiaCorD(neurologyForm, totals, out couldBeAsiaC, out couldBeAsiaD);

                if (couldBeAsiaC)
                    totals.AddAsiaImpairmentScaleValue("C");

                if (couldBeAsiaD)
                    totals.AddAsiaImpairmentScaleValue("D");
            }

            if (totals.RightSensoryContains("S4_5") && totals.LeftSensoryContains("S4_5")
                && totals.RightMotorContains("S4_5") && totals.LeftMotorContains("S4_5"))
                totals.AddAsiaImpairmentScaleValue("E");

            return totals;
        }