Fix parsing of prescriptions without regular dosing.
This commit is contained in:
parent
92153f6d6c
commit
2296fcfe41
@ -102,5 +102,14 @@ namespace Tests.Medication
|
|||||||
Assert.AreEqual("0", list[1].Night);
|
Assert.AreEqual("0", list[1].Night);
|
||||||
Assert.AreEqual("neu", list[1].Comment);
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,14 +157,18 @@ namespace zaaReloaded2.Medication
|
|||||||
}
|
}
|
||||||
if (!String.IsNullOrEmpty(Comment))
|
if (!String.IsNullOrEmpty(Comment))
|
||||||
{
|
{
|
||||||
s += " " + Comment.Trim();
|
if (!s.EndsWith("\t"))
|
||||||
|
{
|
||||||
|
s += " ";
|
||||||
|
}
|
||||||
|
s += Comment;
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructor
|
#region Constructors
|
||||||
|
|
||||||
public Prescription() { }
|
public Prescription() { }
|
||||||
|
|
||||||
@ -190,18 +194,18 @@ namespace zaaReloaded2.Medication
|
|||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
private const string DOSE_GROUP = "dose";
|
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*)";
|
private const string SPACER = @"(\s*[-\u2012\u2013\u2014]+\s*)";
|
||||||
|
|
||||||
// Enclose entire regular expression in parentheses so we can use it
|
// Enclose entire regular expression in parentheses so we can use it
|
||||||
// to split a line and capture the delimiter.
|
// to split a line and capture the delimiter.
|
||||||
private static readonly Regex lineRegex = new Regex(
|
private static readonly Regex lineRegex = new Regex(
|
||||||
@"((?<drug>[^\t]+)\s+" +
|
@"(((?<drug>[^\t]+)\s+" +
|
||||||
@"(?<dose>" + DOSE + @")" + SPACER +
|
@"(?<dose>" + DOSE + @")" + SPACER +
|
||||||
@"(?<dose>" + DOSE + @")" + SPACER +
|
@"(?<dose>" + DOSE + @")" + SPACER +
|
||||||
@"(?<dose>" + DOSE + @")" +
|
@"(?<dose>" + DOSE + @")" +
|
||||||
@"(" + SPACER + @"(?<dose>" + DOSE + @"))?" +
|
@"(" + SPACER + @"(?<dose>" + DOSE + @"))?" +
|
||||||
@"( +(?<comment>[^\t]+))?\s*)");
|
@"( +(?<comment>[^\t]+))?)|((?<drug>[^\t]+)( +|\t+)(?<comment>[^\t]+)))");
|
||||||
|
|
||||||
private static readonly Regex spaceRegex = new Regex(@"\s+");
|
private static readonly Regex spaceRegex = new Regex(@"\s+");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user