diff --git a/Tests/Formatter/FormatterTest.cs b/Tests/Formatter/FormatterTest.cs index 871dab9..0df3924 100755 --- a/Tests/Formatter/FormatterTest.cs +++ b/Tests/Formatter/FormatterTest.cs @@ -118,6 +118,23 @@ namespace Tests.Formatter document.Range().Text); } + [Test] + public void FormatCyclosporine() + { + ZaaImporter importer = new ZaaImporter(); + importer.Import( + "(17.09.2015 10:44:00) Cyclosporin-A vor Gabe: 130 µg/l; CK gesamt: 123 [<= 170] U/l; Cholesterin: 211"); + 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("CsA (C0) \"(Ziel-Talspiegel: <> µg/l)\"") }); + formatter.Run(); + Assert.AreEqual( + "Laborwerte vom 17.09.2015 10:44:00:\rCsA (C0) 130 µg/l\r\r", + document.Range().Text); + } + string GetResourceText(string resource) { try diff --git a/zaaReloaded2/Importer/ZaaImporter/LaurisTimePoint.cs b/zaaReloaded2/Importer/ZaaImporter/LaurisTimePoint.cs index 906010b..06b9c6d 100755 --- a/zaaReloaded2/Importer/ZaaImporter/LaurisTimePoint.cs +++ b/zaaReloaded2/Importer/ZaaImporter/LaurisTimePoint.cs @@ -196,11 +196,12 @@ namespace zaaReloaded2.Importer.ZaaImporter void ParseParagraph(string paragraph) { - if (_timeStampRegex.IsMatch(paragraph)) + Match m = _timeStampRegex.Match(paragraph); + if (m.Success) { DateTime dt; if (DateTime.TryParseExact( - _timeStampRegex.Match(paragraph).Groups["datetime"].Value, + m.Groups["datetime"].Value, "dd.MM.yyyy HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces, @@ -208,8 +209,24 @@ namespace zaaReloaded2.Importer.ZaaImporter { TimeStamp = dt; } + + // Put the remainder of the line back to the + // 'paragraph' parameter to deal with exceptional + // lines such as + // "(17.09.2015 10:44:00) Cyclosporin-A vor Gabe: 130 µg/l;" + // We need to add a dummy caption because this is + // the normal format of a paragraph generated from Lauris. + if (m.Groups["tail"].Success) + { + paragraph = "DUMMY CAPTION: " + m.Groups["tail"].Value; + } + else + { + paragraph = String.Empty; + } } - else + + if (!String.IsNullOrEmpty(paragraph)) { LaurisParagraph lp = new LaurisParagraph( paragraph, @@ -236,7 +253,7 @@ namespace zaaReloaded2.Importer.ZaaImporter /// paragraph of a LaurisText. /// static readonly Regex _timeStampRegex = new Regex( - @"^(Labor:?)?\s*\(?\s*(?\d\d\.\d\d\.\d\d\d\d\s+\d\d:\d\d)"); + @"^(Labor:?)?\s*\(?\s*(?\d\d\.\d\d\.\d\d\d\d\s+\d\d:\d\d)(:00\)\s*(?.+)?)?$"); IList _paragraphs; Parameters _parameterDictionary; Units _unitDictionary;