Exemplo n.º 1
0
        public void WhenCalculateResistanceBadgeWithLowerBoundaryBiggerThenSusceptibleButSusceptibleIsUnrealisticSmall_ResultIsIntermediate()
        {
            var component  = CreateSut();
            var sut        = component.Instance;
            var breakPoint = new MockClinicalBreakpointService.MockClinicalBreakPoint()
            {
                AntifungalAgent          = AntifungalAgent.Flucytosine,
                MicBreakpointSusceptible = 0.001f,
                MicBreakpointResistent   = 100f,
                Species = Species.CandidaParapsilosis,
            };

            _mockClinicalBreakpointService.AddBreakpoint(100000, breakPoint);
            var sensitivityTest = new AntimicrobialSensitivityTestRequest
            {
                ClinicalBreakpointId           = 100000,
                AntifungalAgent                = AntifungalAgent.Flucytosine,
                MinimumInhibitoryConcentration = _mockMicStepsService.StepsByTestingMethodAndAgent(SpeciesTestingMethod.Vitek, AntifungalAgent.Flucytosine).First().Value
            };

            sut.SentinelEntry.AntimicrobialSensitivityTests.Add(sensitivityTest);

            var badge = sut.ResistanceBadge(sensitivityTest);

            badge.Should().Be("bg-warning");
            sensitivityTest.Resistance.Should().Be(Resistance.Intermediate);
        }
Exemplo n.º 2
0
        internal string DuplicateClass(AntimicrobialSensitivityTestRequest sensitivityTest)
        {
            var isDuplicate = SentinelEntry.AntimicrobialSensitivityTests.Count(
                s => s.AntifungalAgent == sensitivityTest.AntifungalAgent &&
                s.Standard == sensitivityTest.Standard &&
                s.TestingMethod == sensitivityTest.TestingMethod) > 1;

            return(isDuplicate ? "duplicate-sensitivity-test" : "");
        }
Exemplo n.º 3
0
        internal IEnumerable <MicStep> MicSteps(AntimicrobialSensitivityTestRequest sensitivityTest)
        {
            var matchingSteps = MicStepsService.StepsByTestingMethodAndAgent(sensitivityTest.TestingMethod, sensitivityTest.AntifungalAgent);

            if (sensitivityTest.MinimumInhibitoryConcentration.HasValue && matchingSteps.Any() && matchingSteps.All(s => !s.Value.Equals(sensitivityTest.MinimumInhibitoryConcentration)))
            {
                sensitivityTest.MinimumInhibitoryConcentration = matchingSteps.First().Value;
            }
            return(matchingSteps);
        }
Exemplo n.º 4
0
        //TODO move resistance evaluation to a pure business logic class
        internal string ResistanceBadge(AntimicrobialSensitivityTestRequest sensitivityTest)
        {
            Logger.LogInformation("Resistance update");
            var breakpoint = AllBreakpoints.FirstOrDefault(b => b.Id == sensitivityTest.ClinicalBreakpointId);

            if (breakpoint?.MicBreakpointResistent == null || !breakpoint.MicBreakpointSusceptible.HasValue)
            {
                if (breakpoint == null)
                {
                    Logger.LogWarning($"No breakpoint found for {sensitivityTest.TestingMethod}/{sensitivityTest.AntifungalAgent} where id is {sensitivityTest.ClinicalBreakpointId}");
                }
                else
                {
                    Logger.LogInformation($"Breakpoints {breakpoint.Id} (resistant/susceptible) values are not complete ({breakpoint.MicBreakpointResistent}/{breakpoint.MicBreakpointSusceptible})");
                }
                sensitivityTest.Resistance = Resistance.NotDetermined;
                return("bg-info");
            }

            var selectedStep = MicStepsService.StepsByTestingMethodAndAgent(sensitivityTest.TestingMethod, sensitivityTest.AntifungalAgent)
                               .FirstOrDefault(s => s.Value.Equals(sensitivityTest.MinimumInhibitoryConcentration));

            if (selectedStep != null && Math.Abs(breakpoint.MicBreakpointSusceptible.Value - EucastExtraLowSusceptibleValueToAlwaysGetIntermediate) > 0.001f)
            {
                if (selectedStep.LowerBoundary && sensitivityTest.MinimumInhibitoryConcentration > breakpoint.MicBreakpointSusceptible ||
                    selectedStep.UpperBoundary && sensitivityTest.MinimumInhibitoryConcentration < breakpoint.MicBreakpointResistent)
                {
                    sensitivityTest.Resistance = Resistance.NotEvaluable;
                    return("bg-info");
                }
            }


            Logger.LogInformation($"Found breakpoint for {sensitivityTest.TestingMethod}/{sensitivityTest.AntifungalAgent} where id is {sensitivityTest.ClinicalBreakpointId}: {breakpoint.Title}");

            var mic = sensitivityTest.MinimumInhibitoryConcentration;

            if (IsResistantAccordingToEucastDefinition(mic, breakpoint))
            {
                sensitivityTest.Resistance = Resistance.Resistant;
                return("bg-danger");
            }
            if (IsResistantAccordingToClsiDefinition(mic, breakpoint))
            {
                sensitivityTest.Resistance = Resistance.Resistant;
                return("bg-danger");
            }
            if (IsSusceptibleAccordingToBothDefinitions(mic, breakpoint))
            {
                sensitivityTest.Resistance = Resistance.Susceptible;
                return("bg-success");
            }
            sensitivityTest.Resistance = Resistance.Intermediate;
            return("bg-warning");
        }
Exemplo n.º 5
0
        public void WhenCalculateResistanceBadgeWhereBreakpointHasNoMics_ResultsInNotDetermined()
        {
            var component       = CreateSut();
            var sut             = component.Instance;
            var sensitivityTest = new AntimicrobialSensitivityTestRequest
            {
                ClinicalBreakpointId           = 1234567,
                MinimumInhibitoryConcentration = 0.25f
            };

            sut.SentinelEntry.AntimicrobialSensitivityTests.Add(sensitivityTest);

            var badge = sut.ResistanceBadge(sensitivityTest);

            badge.Should().Be("bg-info");
            sensitivityTest.Resistance.Should().Be(Resistance.NotDetermined);
        }
Exemplo n.º 6
0
        public void WhenNoApplicableBreakpoint_SensitivityIsSetToNotDetermined()
        {
            var sensitivityTest = new AntimicrobialSensitivityTestRequest
            {
                AntifungalAgent = AntifungalAgent.Fluorouracil,
                Standard        = BrothMicrodilutionStandard.Eucast,
                Resistance      = Resistance.Susceptible
            };
            var component = CreateSut();
            var sut       = component.Instance;

            sut.SentinelEntry.IdentifiedSpecies = Species.CandidaTropicalis;

            sut.ApplicableBreakpoints(sensitivityTest);

            sensitivityTest.Resistance.Should().Be(Resistance.NotDetermined);
        }
Exemplo n.º 7
0
        public void WhenApplicableBreakpoints_OnlyValidOnesAreReturned()
        {
            var sensitivityTest = new AntimicrobialSensitivityTestRequest
            {
                AntifungalAgent = AntifungalAgent.Micafungin,
                Standard        = BrothMicrodilutionStandard.Eucast
            };
            var component = CreateSut();
            var sut       = component.Instance;

            sut.SentinelEntry.IdentifiedSpecies = Species.CandidaAlbicans;

            var breakpoints = sut.ApplicableBreakpoints(sensitivityTest).ToList();

            breakpoints.Should().HaveCount(1);
            breakpoints.Should().OnlyContain(
                b => b.AntifungalAgent == AntifungalAgent.Micafungin && b.Standard == BrothMicrodilutionStandard.Eucast);
        }
Exemplo n.º 8
0
        public void WhenCalculateResistanceBadgeWithNoMatchingBreakpoint_ResultsInNotDetermined()
        {
            var component = CreateSut();
            var sut       = component.Instance;

            sut.SentinelEntry.IdentifiedSpecies = Species.CandidaAlbicans;
            var firstBreakpoint = sut.AllBreakpoints.First(b =>
                                                           !b.MicBreakpointResistent.HasValue && !b.MicBreakpointSusceptible.HasValue);
            var sensitivityTest = new AntimicrobialSensitivityTestRequest
            {
                ClinicalBreakpointId           = firstBreakpoint.Id,
                MinimumInhibitoryConcentration = 0.25f
            };

            sut.SentinelEntry.AntimicrobialSensitivityTests.Add(sensitivityTest);

            var badge = sut.ResistanceBadge(sensitivityTest);

            badge.Should().Be("bg-info");
            sensitivityTest.Resistance.Should().Be(Resistance.NotDetermined);
        }
Exemplo n.º 9
0
        internal IEnumerable <ClinicalBreakpoint> ApplicableBreakpoints(AntimicrobialSensitivityTestRequest sensitivityTest)
        {
            var antifungalAgent       = sensitivityTest.AntifungalAgent;
            var applicableBreakpoints = AllBreakpoints.Where(b =>
                                                             b.AntifungalAgent == antifungalAgent &&
                                                             b.Species == SentinelEntry.IdentifiedSpecies &&
                                                             b.Standard == sensitivityTest.Standard).ToList();

            if (applicableBreakpoints.All(b => b.Id != sensitivityTest.ClinicalBreakpointId))
            {
                Logger.LogInformation($"Update test {sensitivityTest.AntifungalAgent} to breakpoint id {applicableBreakpoints.FirstOrDefault()?.Id}");
                sensitivityTest.ClinicalBreakpointId = applicableBreakpoints.FirstOrDefault()?.Id;
            }

            Logger.LogInformation($"Found {applicableBreakpoints.Count} applicable breakpoints for {antifungalAgent} and {SentinelEntry.IdentifiedSpecies}");

            if (!applicableBreakpoints.Any())
            {
                sensitivityTest.Resistance = Resistance.NotDetermined;
            }
            return(applicableBreakpoints);
        }
Exemplo n.º 10
0
        public void WhenCalculateResistanceBadge_UsesBreakpointValuesWithClsiBoundaryConditions(float deltaToResistance, string expectedBadge, Resistance expectedResistance)
        {
            var component = CreateSut();
            var sut       = component.Instance;

            sut.SentinelEntry.IdentifiedSpecies = Species.CandidaGlabrata;
            var breakpoint = sut.AllBreakpoints.Single(b =>
                                                       b.AntifungalAgent == AntifungalAgent.Caspofungin &&
                                                       b.Species == Species.CandidaGlabrata &&
                                                       b.Standard == BrothMicrodilutionStandard.Clsi &&
                                                       b.Version == "M60 2019");
            var sensitivityTest = new AntimicrobialSensitivityTestRequest
            {
                ClinicalBreakpointId           = breakpoint.Id,
                MinimumInhibitoryConcentration = breakpoint.MicBreakpointResistent.Value + deltaToResistance
            };

            sut.SentinelEntry.AntimicrobialSensitivityTests.Add(sensitivityTest);

            var badge = sut.ResistanceBadge(sensitivityTest);

            badge.Should().Be(expectedBadge);
            sensitivityTest.Resistance.Should().Be(expectedResistance);
        }
Exemplo n.º 11
0
        public void WhenCalculateResistanceBadge_UsesBreakpointValuesWithEucastBoundaryConditions(float deltaToResistance, string expectedBadge, Resistance expectedResistance)
        {
            var component = CreateSut();
            var sut       = component.Instance;

            sut.SentinelEntry.IdentifiedSpecies = Species.CandidaAlbicans;
            var firstBreakpoint = sut.AllBreakpoints.Single(b =>
                                                            b.AntifungalAgent == AntifungalAgent.Voriconazole &&
                                                            b.Species == Species.CandidaDubliniensis &&
                                                            b.Standard == BrothMicrodilutionStandard.Eucast &&
                                                            b.Version == "10.0");
            var sensitivityTest = new AntimicrobialSensitivityTestRequest
            {
                ClinicalBreakpointId           = firstBreakpoint.Id,
                MinimumInhibitoryConcentration = firstBreakpoint.MicBreakpointResistent.Value + deltaToResistance
            };

            sut.SentinelEntry.AntimicrobialSensitivityTests.Add(sensitivityTest);

            var badge = sut.ResistanceBadge(sensitivityTest);

            badge.Should().Be(expectedBadge);
            sensitivityTest.Resistance.Should().Be(expectedResistance);
        }
Exemplo n.º 12
0
 internal void RemoveAntimicrobialSensitivityTest(AntimicrobialSensitivityTestRequest sensitivityTest)
 {
     SentinelEntry.AntimicrobialSensitivityTests.Remove(sensitivityTest);
 }
Exemplo n.º 13
0
 private void AddAntimicrobialSensitivityTest(AntimicrobialSensitivityTestRequest sensitivityTest)
 {
     SentinelEntry.AntimicrobialSensitivityTests.Add(sensitivityTest);
     sensitivityTest.ClinicalBreakpointId = ApplicableBreakpoints(sensitivityTest).FirstOrDefault()?.Id;
 }