Extend IsolateInterpretation to use JSON-based rule system#186
Conversation
Co-authored-by: markusrt <299753+markusrt@users.noreply.github.com>
Co-authored-by: markusrt <299753+markusrt@users.noreply.github.com>
markusrt
left a comment
There was a problem hiding this comment.
The build fails:
"D:\a\NRZMHiDB\NRZMHiDB\HaemophilusWeb\HaemophilusWeb.csproj" (default target) (2) ->
(CoreCompile target) ->
D:\a\NRZMHiDB\NRZMHiDB\HaemophilusWeb\Domain\NativeMaterialInterpretationRule.cs(11,16): error CS0246: The type or namespace name 'RealTimePcrResult' could not be found (are you missing a using directive or an assembly reference?) [D:\a\NRZMHiDB\NRZMHiDB\HaemophilusWeb\HaemophilusWeb.csproj]
D:\a\NRZMHiDB\NRZMHiDB\HaemophilusWeb\Domain\MeningoIsolateInterpretation.cs(201,46): error CS0246: The type or namespace name 'MeningoNativeMaterialInterpretationRule' could not be found (are you missing a using directive or an assembly reference?) [D:\a\NRZMHiDB\NRZMHiDB\HaemophilusWeb\HaemophilusWeb.csproj]
D:\a\NRZMHiDB\NRZMHiDB\HaemophilusWeb\Domain\MeningoIsolateInterpretation.cs(215,51): error CS0246: The type or namespace name 'MeningoStemInterpretationRule' could not be found (are you missing a using directive or an assembly reference?) [D:\a\NRZMHiDB\NRZMHiDB\HaemophilusWeb\HaemophilusWeb.csproj]
D:\a\NRZMHiDB\NRZMHiDB\HaemophilusWeb\Domain\MeningoIsolateInterpretation.cs(22,52): error CS0246: The type or namespace name 'MeningoStemInterpretationRule' could not be found (are you missing a using directive or an assembly reference?) [D:\a\NRZMHiDB\NRZMHiDB\HaemophilusWeb\HaemophilusWeb.csproj]
D:\a\NRZMHiDB\NRZMHiDB\HaemophilusWeb\Domain\MeningoIsolateInterpretation.cs(23,52): error CS0246: The type or namespace name 'MeningoNativeMaterialInterpretationRule' could not be found (are you missing a using directive or an assembly reference?) [D:\a\NRZMHiDB\NRZMHiDB\HaemophilusWeb\HaemophilusWeb.csproj]
Co-authored-by: markusrt <299753+markusrt@users.noreply.github.com>
Fixed the build errors in commit 7045f7f by adding the missing Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot the recent commit introduced custom extension to FluentAssertion like this: Please create a similar extension for this pattern: E.g. it should be: The new extension should
Also chain multiple calls on |
…use it Co-authored-by: markusrt <299753+markusrt@users.noreply.github.com>
…oNativeMaterialRule test Co-authored-by: markusrt <299753+markusrt@users.noreply.github.com>
... Added the interpretation.Should().BePreliminary()
.And.ContainReportLine("Das Ergebnis spricht für einen unbekapselten Haemophilus influenzae")
.And.ContainReportLine("Blut oder Liquor ist nach §7 IfSG meldepflichtig")
.And.ContainReportLine("Meldekategorie dieses Befundes: Haemophilus influenzae, unbekapselt."); |
Co-authored-by: markusrt <299753+markusrt@users.noreply.github.com>
| interpretation.Should().BePreliminary() | ||
| .And.ContainReportLine("Das Ergebnis spricht für einen unbekapselten Haemophilus influenzae") | ||
| .And.ContainReportLine("Blut oder Liquor ist nach §7 IfSG meldepflichtig") | ||
| .And.ContainReportLine("Meldekategorie dieses Befundes: Haemophilus influenzae, unbekapselt."); |
There was a problem hiding this comment.
@copilot this change should also be applied to MeningoIsolateInterpretationTests
There was a problem hiding this comment.
Applied the same ContainReportLine/NotContainReportLine pattern to MeningoIsolateInterpretationTests.cs (88 occurrences), with .And chaining for consecutive assertions on the same subject. Also added NotContainReportLine to InterpretationResultAssertion for the NotContain patterns present in the meningo tests. Committed in a3ca192 and 1acd241.
…xtensions
Replace verbose FluentAssertions patterns with cleaner extension methods:
- Replace Result.Report.Should().Contain(s => s.Contains("...")) with
Result.Should().ContainReportLine("...")
- Replace Result.Report.Should().NotContain(s => s.Contains("...")) with
Result.Should().NotContainReportLine("...")
- Consolidate consecutive calls on the same Result using .And chaining
- Handle multi-line lambda patterns (string on next line, ternary expressions)
- Preserve Report.Should().BeEmpty() patterns unchanged
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…gitignore Co-authored-by: markusrt <299753+markusrt@users.noreply.github.com>
Done - see individual comment replies for details. |
|
|



This PR extends the
IsolateInterpretationclass to support a JSON-based rule system similar to the existingMeningoIsolateInterpretation, while maintaining full backward compatibility with the existing hardcoded interpretation logic.Changes Made
1. Renamed Existing Meningo Rules
StemInterpretationRule.cs→MeningoStemInterpretationRule.csNativeMaterialInterpretationRule.cs→MeningoNativeMaterialInterpretationRule.csMeningoIsolateInterpretation.cs2. Created New Rule System for Haemophilus
StemInterpretationRule.csandNativeMaterialInterpretationRule.csthat work withIsolate.csproperties instead ofMeningoIsolate.csHaemoStemRules.json- Sample rule for Serotype B detectionHaemoNativeMaterialRules.json- Sample rule for molecular typingHaemoTypingTemplates.json- Typing output templates3. Extended IsolateInterpretation Logic
The
IsolateInterpretation.Interpret()method now:4. Added
ContainReportLineandNotContainReportLineFluentAssertions ExtensionsAdded new methods to
InterpretationResultAssertionthat:ContainReportLine: checks thatReportis not null and the collection contains a line matching the expected substringNotContainReportLine: checks thatReportis not null and the collection does not contain a line matching the given substring.AndchainingThis enables concise test assertions like:
These extensions are applied throughout both
IsolateInterpretationTestsandMeningoIsolateInterpretationTests, replacing all verboseReport.Should().Contain(s => s.Contains("..."))andReport.Should().NotContain(s => s.Contains("..."))patterns with the cleaner fluent API, using.Andchaining for consecutive assertions on the same subject.5. Comprehensive Testing
Added unit tests that verify:
Example Usage
The new rule system automatically detects Haemophilus influenzae Serotype B:
Architecture
The implementation reuses the proven rule engine pattern from
MeningoIsolateInterpretation:This approach provides a maintainable and extensible foundation for adding new interpretation rules without code changes.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.