From 947b53cf97cd267f79a3eedf53a26054ed36fa53 Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Mon, 10 Aug 2015 06:55:57 +0200 Subject: [PATCH] Fix material convertsion and units detection. --- Tests/Formatter/FormatterTest.cs | 19 +++++++++++++++++++ zaaReloaded2/Controller/Elements/Items.cs | 4 +++- .../Importer/ZaaImporter/LaurisItem.cs | 11 +++++++---- zaaReloaded2/Thesaurus/Defaults/units.txt | 5 +++-- zaaReloaded2/Thesaurus/Parameters.cs | 17 ++++++++++++----- 5 files changed, 44 insertions(+), 12 deletions(-) diff --git a/Tests/Formatter/FormatterTest.cs b/Tests/Formatter/FormatterTest.cs index 7437d6b..871dab9 100755 --- a/Tests/Formatter/FormatterTest.cs +++ b/Tests/Formatter/FormatterTest.cs @@ -99,6 +99,25 @@ namespace Tests.Formatter _document.Range().Text); } + [Test] + public void FormatSpecialItems() + { + ZaaImporter importer = new ZaaImporter(); + importer.Import( + "Klinische Chemie: glomerul. Filtrationsr. CKD-EP: 36 ml/min /1,73qm; " + + "Sammelmenge (U): 12300 ml; " + ); + Document document = new Document(); + f.Formatter formatter = new f.Formatter(document); + formatter.Laboratory = importer.Laboratory; + formatter.Settings = new zaaReloaded2.Controller.Settings( + new List() { new Items("*") } ); + formatter.Run(); + Assert.AreEqual( + "eGFR (CKD-EPI) 36 ml/min/1,73 m², SU-Volumen 12300 ml\r\r", + document.Range().Text); + } + string GetResourceText(string resource) { try diff --git a/zaaReloaded2/Controller/Elements/Items.cs b/zaaReloaded2/Controller/Elements/Items.cs index b5710da..9baf10a 100755 --- a/zaaReloaded2/Controller/Elements/Items.cs +++ b/zaaReloaded2/Controller/Elements/Items.cs @@ -139,7 +139,6 @@ namespace zaaReloaded2.Controller.Elements { items.AddRange(CollectByName(formatter, itemName)); } - } return items; } @@ -158,6 +157,9 @@ namespace zaaReloaded2.Controller.Elements .Where(i => !i.HasBeenUsed && !i.IsBlacklisted && i.LabItem.QualifiedName.StartsWith(material)) .ToList(); newItems.ForEach(i => i.HasBeenUsed = true); + // Include the material prefix only if this item was collected by a + // general wildcard ("*" rather than "SU-*" etc.). + newItems.ForEach(i => i.IncludeMaterial = String.IsNullOrEmpty(material)); items.AddRange(newItems); } return items; diff --git a/zaaReloaded2/Importer/ZaaImporter/LaurisItem.cs b/zaaReloaded2/Importer/ZaaImporter/LaurisItem.cs index ccff09a..71d7e19 100755 --- a/zaaReloaded2/Importer/ZaaImporter/LaurisItem.cs +++ b/zaaReloaded2/Importer/ZaaImporter/LaurisItem.cs @@ -76,6 +76,7 @@ namespace zaaReloaded2.Importer.ZaaImporter Name = parameterDictionary.GetCanonicalName(OriginalName); AlwaysPrintLimits = parameterDictionary.GetForceReferenceDisplay(OriginalName); IsBlacklisted = parameterDictionary.GetIsBlacklisted(OriginalName); + Material = parameterDictionary.GetMaterial(OriginalName, Material); } if (unitDictionary != null) { @@ -165,10 +166,12 @@ namespace zaaReloaded2.Importer.ZaaImporter } /// - /// Analyses the Lauris name for a material abbreviation. - /// If the parameter does not refer to blood (serum, whole - /// blood, etc.), Lauris appends an abbreviation in parentheses - /// to the parameter name. + /// Parses the original Lauris name for a material abbreviation. + /// This may be misleading in certain cases, e.g. "Sammelmenge (U)" + /// appears to be spot urine ("U"), but is collected urine instead + /// ("SU"). Therefore, in the constructor that takes the thesaurus + /// parameters, the material is looked up in the Parameters thesaurus. + /// ("Sammelmenge (U)" is contained in the Parameters thesaurus.) /// /// /// Gesamt-Eiweiss (SU), Albumin (SU)/die, Gesamt-Eiweiss (PU) diff --git a/zaaReloaded2/Thesaurus/Defaults/units.txt b/zaaReloaded2/Thesaurus/Defaults/units.txt index 51a44d8..8981e90 100755 --- a/zaaReloaded2/Thesaurus/Defaults/units.txt +++ b/zaaReloaded2/Thesaurus/Defaults/units.txt @@ -2,7 +2,8 @@ # ============== ==================== # WICHTIG: Nur direkt austauschbare Einheiten verwenden, # weil (bislang) keine Umrechnung der Werte vorgesehen ist! -"ml/min/ 1,73qm" "ml/min/1,73 m²" +"ml/min /1,73qm" "ml/min/1,73 m²" ng/ml µg/l mmol/l mM -n*1000/µl /nl \ No newline at end of file +n*1000/µl /nl +Bak/µl /µl diff --git a/zaaReloaded2/Thesaurus/Parameters.cs b/zaaReloaded2/Thesaurus/Parameters.cs index e6444f2..981e7d8 100755 --- a/zaaReloaded2/Thesaurus/Parameters.cs +++ b/zaaReloaded2/Thesaurus/Parameters.cs @@ -69,16 +69,23 @@ namespace zaaReloaded2.Thesaurus /// Lauris item name to look up. /// enum; if no material is /// found in the dictionary, the default material "S" (serum) is returned. - public Material GetMaterial(string laurisName) + public Material GetMaterial(string laurisName, Material def) { string textValue = LookUpValue(laurisName, 2); - try + if (String.IsNullOrEmpty(textValue)) { - return MaterialFactory.FromAbbreviation(textValue); + return def; } - catch + else { - return Material.B; + try + { + return MaterialFactory.FromAbbreviation(textValue); + } + catch + { + return Material.B; + } } }