diff --git a/Tests/Medication/PrescriptionTest.cs b/Tests/Medication/PrescriptionTest.cs index a164919..4686085 100755 --- a/Tests/Medication/PrescriptionTest.cs +++ b/Tests/Medication/PrescriptionTest.cs @@ -102,5 +102,14 @@ namespace Tests.Medication Assert.AreEqual("0", list[1].Night); Assert.AreEqual("neu", list[1].Comment); } + + [Test] + public void PrescriptionWithoutTypicalDosing() + { + Prescription p = Prescription.FromLine("Eusaprim forte\t alle zwei Tage"); + Assert.AreEqual("Eusaprim forte", p.Drug); + Assert.AreEqual("alle zwei Tage", p.Comment); + Assert.AreEqual("Eusaprim forte\talle zwei Tage", p.ToString(), "ToString"); + } } } diff --git a/zaaReloaded2/Medication/Prescription.cs b/zaaReloaded2/Medication/Prescription.cs index d3f4b9d..2a3f7d3 100755 --- a/zaaReloaded2/Medication/Prescription.cs +++ b/zaaReloaded2/Medication/Prescription.cs @@ -157,14 +157,18 @@ namespace zaaReloaded2.Medication } if (!String.IsNullOrEmpty(Comment)) { - s += " " + Comment.Trim(); + if (!s.EndsWith("\t")) + { + s += " "; + } + s += Comment; } return s; } #endregion - #region Constructor + #region Constructors public Prescription() { } @@ -190,18 +194,18 @@ namespace zaaReloaded2.Medication #region Fields private const string DOSE_GROUP = "dose"; - private const string DOSE = @"(\d\s+1/[234]|[\u00bd\u2153\u00bc]|\d+)"; + private const string DOSE = @"(\d\s+1/[234]|(\d\s?)?[\u00bd\u2153\u00bc]|\d+)"; private const string SPACER = @"(\s*[-\u2012\u2013\u2014]+\s*)"; // Enclose entire regular expression in parentheses so we can use it // to split a line and capture the delimiter. private static readonly Regex lineRegex = new Regex( - @"((?[^\t]+)\s+" + + @"(((?[^\t]+)\s+" + @"(?" + DOSE + @")" + SPACER + @"(?" + DOSE + @")" + SPACER + @"(?" + DOSE + @")" + @"(" + SPACER + @"(?" + DOSE + @"))?" + - @"( +(?[^\t]+))?\s*)"); + @"( +(?[^\t]+))?)|((?[^\t]+)( +|\t+)(?[^\t]+)))"); private static readonly Regex spaceRegex = new Regex(@"\s+");