From 32d4e8d955ca5f01c4c89a8ad1dd003dae4a4040 Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Fri, 14 Aug 2015 11:22:11 +0200 Subject: [PATCH 01/13] Implement bold font; make tests pass again. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - NEU: Überschriften und pathologische Werte werden fett gedruckt. - FIX: Kleinere Bugfixes. --- Tests/Controller/Elements/ItemsTest.cs | 32 ++++++++++--- Tests/Formatter/DocumentWriterTest.cs | 9 ++++ .../SettingsRepositoryViewModelTest.cs | 7 ++- zaaReloaded2/Formatter/DocumentWriter.cs | 48 ++++++++++++++++++- zaaReloaded2/Formatter/ItemFormatter.cs | 11 +++-- zaaReloaded2/Formatter/TimePointFormatter.cs | 2 +- zaaReloaded2/LabModel/LabItem.cs | 5 +- zaaReloaded2/ViewModels/SettingsViewModel.cs | 2 +- 8 files changed, 100 insertions(+), 16 deletions(-) diff --git a/Tests/Controller/Elements/ItemsTest.cs b/Tests/Controller/Elements/ItemsTest.cs index 8b3b861..cc24ed6 100755 --- a/Tests/Controller/Elements/ItemsTest.cs +++ b/Tests/Controller/Elements/ItemsTest.cs @@ -24,6 +24,7 @@ using Microsoft.Office.Interop.Word; using zaaReloaded2.LabModel; using zaaReloaded2.Formatter; using zaa = zaaReloaded2.Controller.Elements; +using System.Text.RegularExpressions; namespace Tests.Controller.Elements { @@ -62,8 +63,10 @@ namespace Tests.Controller.Elements _formatter.Settings.Elements.Add(new zaa.Items("Na, K, Cl")); _formatter.Run(); string expected = ( - TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + - "Na 133, K 6 (5)\r\r").Replace(Environment.NewLine, "\r"); + StripMarkup( + TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + + "Na 133, K 6 (5)\r\r").Replace(Environment.NewLine, "\r") + ); Assert.AreEqual(expected, _document.Range().Text); } @@ -82,8 +85,10 @@ namespace Tests.Controller.Elements _formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, K, Cl")); _formatter.Run(); string expected = ( - TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + - "Klinische Chemie: Na 133, K 6 (5)\r\r").Replace(Environment.NewLine, "\r"); + StripMarkup( + TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + + "Klinische Chemie: Na 133, K 6 (5)\r\r").Replace(Environment.NewLine, "\r") + ); Assert.AreEqual(expected, _document.Range().Text); } @@ -120,7 +125,9 @@ namespace Tests.Controller.Elements _formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, *")); _formatter.Run(); string expected = ( - TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + + StripMarkup( + TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + ) + "Klinische Chemie: Na 133, Cl 110, K 6\r\r").Replace(Environment.NewLine, "\r"); Assert.AreEqual(expected, _document.Range().Text); } @@ -142,7 +149,9 @@ namespace Tests.Controller.Elements _formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, SU-*")); _formatter.Run(); string expected = ( - TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + + StripMarkup( + TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + )+ "Klinische Chemie: Na 133, SU-Protein 2,8\r\r").Replace(Environment.NewLine, "\r"); Assert.AreEqual(expected, _document.Range().Text); } @@ -164,10 +173,19 @@ namespace Tests.Controller.Elements _formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, SU-*, *")); _formatter.Run(); string expected = ( - TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + + StripMarkup( + TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + ) + "Klinische Chemie: Na 133, SU-Protein 2,8, Cl 110, U-Na 99\r\r") .Replace(Environment.NewLine, "\r"); Assert.AreEqual(expected, _document.Range().Text); } + + static string StripMarkup(string s) + { + return _markupStripper.Replace(s, string.Empty); + } + + static readonly Regex _markupStripper = new Regex(@""); } } diff --git a/Tests/Formatter/DocumentWriterTest.cs b/Tests/Formatter/DocumentWriterTest.cs index f3e201e..74d3075 100755 --- a/Tests/Formatter/DocumentWriterTest.cs +++ b/Tests/Formatter/DocumentWriterTest.cs @@ -21,6 +21,7 @@ using System.Linq; using System.Text; using NUnit.Framework; using zaaReloaded2.Formatter; +using Microsoft.Office.Interop.Word; namespace Tests.Formatter { @@ -95,5 +96,13 @@ namespace Tests.Formatter Assert.IsFalse(_docWriter.HasBufferedText); Assert.AreEqual(String.Empty, _docWriter.ToString()); } + + [Test] + public void TextMarkup() + { + _docWriter.Document = new Document(); + _docWriter.WriteLine("This is not bold. This is bold!"); + _docWriter.Flush(); + } } } diff --git a/Tests/ViewModels/SettingsRepositoryViewModelTest.cs b/Tests/ViewModels/SettingsRepositoryViewModelTest.cs index ff434a1..afa5ddc 100755 --- a/Tests/ViewModels/SettingsRepositoryViewModelTest.cs +++ b/Tests/ViewModels/SettingsRepositoryViewModelTest.cs @@ -65,7 +65,12 @@ namespace Tests.ViewModels Assert.AreNotSame(orig, copy); Assert.AreNotSame(orig.RevealModelObject(), copy.RevealModelObject()); - Assert.AreEqual(String.Format("Kopie von {0}", orig.Name), copy.Name); + Assert.AreEqual( + String.Format( + "Kopie von {0}", + orig.Name.Replace(" (eingebaut)", String.Empty) + ), + copy.Name); Assert.IsTrue(copy.IsSelected); } } diff --git a/zaaReloaded2/Formatter/DocumentWriter.cs b/zaaReloaded2/Formatter/DocumentWriter.cs index 2c11113..e373553 100755 --- a/zaaReloaded2/Formatter/DocumentWriter.cs +++ b/zaaReloaded2/Formatter/DocumentWriter.cs @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Office.Interop.Word; +using System.Text.RegularExpressions; namespace zaaReloaded2.Formatter { @@ -59,6 +60,20 @@ namespace zaaReloaded2.Formatter /// public string ParagraphStyle { get; set; } + /// + /// Returns text without markup from the buffer. + /// + public string Text + { + get + { + if (!HasBufferedText) + throw new InvalidOperationException("This DocumentWriter does not have any text."); + + return _markupRegex.Replace(_buffer.ToString(), String.Empty); + } + } + #endregion #region Constructors @@ -126,7 +141,7 @@ namespace zaaReloaded2.Formatter { s.set_Style(ParagraphStyle); } - s.Range.Text = _buffer.ToString(); + MarkupToDocument(_buffer.ToString()); } if (Parent != null) { @@ -166,9 +181,40 @@ namespace zaaReloaded2.Formatter #endregion + #region Private methods + + /// + /// Parses a string containing markup (e.g., "<b>", "</b>") + /// and writes formatted text to the current Document. + /// + /// + void MarkupToDocument(string text) + { + string[] substrings = _markupRegex.Split(text); + foreach (string substring in substrings) + { + switch (substring) + { + case "": + Document.ActiveWindow.Selection.Font.Bold = 1; + break; + case "": + Document.ActiveWindow.Selection.Font.Bold = 0; + break; + default: + Document.ActiveWindow.Selection.TypeText(substring); + break; + } + } + } + + #endregion + #region Fields StringBuilder _buffer; + // Put pattern in parentheses so they will not be discarded by Regex.Split + static readonly Regex _markupRegex = new Regex(@"()"); #endregion } diff --git a/zaaReloaded2/Formatter/ItemFormatter.cs b/zaaReloaded2/Formatter/ItemFormatter.cs index 17d0bf3..5e198c9 100755 --- a/zaaReloaded2/Formatter/ItemFormatter.cs +++ b/zaaReloaded2/Formatter/ItemFormatter.cs @@ -153,15 +153,20 @@ namespace zaaReloaded2.Formatter string name = IncludeMaterial ? LabItem.QualifiedName : LabItem.Name; - // Insert the formatted text into the document. - formatter.Write( + string output = String.Format( "{0} {1}{2}{3}", name, value, unit, reference - )); + ); + if (!LabItem.IsNormal) + { + output = String.Format("{0}", output); + } + + formatter.Write(output); HasBeenUsed = true; } diff --git a/zaaReloaded2/Formatter/TimePointFormatter.cs b/zaaReloaded2/Formatter/TimePointFormatter.cs index da8b41e..bcdc801 100755 --- a/zaaReloaded2/Formatter/TimePointFormatter.cs +++ b/zaaReloaded2/Formatter/TimePointFormatter.cs @@ -68,7 +68,7 @@ namespace zaaReloaded2.Formatter static string FormatHeader(string text) { - return String.Format("{0}Laborwerte vom {1}:{2}", + return String.Format("{0}Laborwerte vom {1}:{2}", Environment.NewLine, text, Environment.NewLine diff --git a/zaaReloaded2/LabModel/LabItem.cs b/zaaReloaded2/LabModel/LabItem.cs index 3fc6c7e..4ada2c5 100755 --- a/zaaReloaded2/LabModel/LabItem.cs +++ b/zaaReloaded2/LabModel/LabItem.cs @@ -123,7 +123,8 @@ namespace zaaReloaded2.LabModel public bool HasUpperLimit { get; protected set; } /// - /// Is true if is normal. + /// Is true if is normal. Returns true + /// if no limits and no normal value are known. /// public bool IsNormal { @@ -147,7 +148,7 @@ namespace zaaReloaded2.LabModel } else { - return (Value == Normal); + return String.IsNullOrEmpty(Normal) || (Value == Normal); } } } diff --git a/zaaReloaded2/ViewModels/SettingsViewModel.cs b/zaaReloaded2/ViewModels/SettingsViewModel.cs index db33e3f..05af8a2 100755 --- a/zaaReloaded2/ViewModels/SettingsViewModel.cs +++ b/zaaReloaded2/ViewModels/SettingsViewModel.cs @@ -347,7 +347,7 @@ namespace zaaReloaded2.ViewModels picker.ElementChosenMessage.Sent += (sender, args) => { ElementViewModel newVM = args.Content.ViewModel as ElementViewModel; - if (IsTopLevelElement()) + if (LastSelectedElement == null || IsTopLevelElement()) { AddElementViewModel(newVM); } From 7a105d7aad2bce148da2431fea973e347a39fede Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Fri, 14 Aug 2015 16:01:52 +0200 Subject: [PATCH 02/13] Do not include material for explicitly selected items. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - VERÄNDERUNG: Laborwerte, die explizit (also nicht mit "*") ausgewählt werden, werden jetzt ohne vorangestelltes Material-Kürzel eingefügt (z.B. jetzt "Sammelurin: Volumen" anstatt "Sammelurin: SU-Volumen"). --- zaaReloaded2/Controller/Elements/Items.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/zaaReloaded2/Controller/Elements/Items.cs b/zaaReloaded2/Controller/Elements/Items.cs index 151237e..61f403d 100755 --- a/zaaReloaded2/Controller/Elements/Items.cs +++ b/zaaReloaded2/Controller/Elements/Items.cs @@ -199,6 +199,7 @@ namespace zaaReloaded2.Controller.Elements // item with itemName. ItemFormatter i = tpf.ItemFormatters[name]; i.HasBeenUsed = true; + i.IncludeMaterial = false; items.Add(i); } return items; From 863dfa071a2e0bce77b480734c36248e78ef565a Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Fri, 14 Aug 2015 17:04:50 +0200 Subject: [PATCH 03/13] Prevent running the formatter without appropriate selection. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - VERBESSERT: Formatieren läßt sich nicht mehr starten, ohne daß Labor-Text markiert ist. --- zaaReloaded2/Formatter/Formatter.cs | 2 +- .../Formatter/NoLaboratoryDataException.cs | 35 +++++++++++++++++++ zaaReloaded2/Ribbon.cs | 35 ++++++++++++++++--- .../ViewModels/SettingsRepositoryViewModel.cs | 8 ++++- zaaReloaded2/zaaReloaded2.csproj | 1 + 5 files changed, 74 insertions(+), 7 deletions(-) create mode 100755 zaaReloaded2/Formatter/NoLaboratoryDataException.cs diff --git a/zaaReloaded2/Formatter/Formatter.cs b/zaaReloaded2/Formatter/Formatter.cs index 83c2d02..cf62545 100755 --- a/zaaReloaded2/Formatter/Formatter.cs +++ b/zaaReloaded2/Formatter/Formatter.cs @@ -119,7 +119,7 @@ namespace zaaReloaded2.Formatter /// current position of the cursor). public void Run() { - if (!CanRun) throw new InvalidOperationException("No laboratory data to format."); + if (!CanRun) throw new NoLaboratoryDataException("No laboratory data to format."); CreateParagraphStyle(); _secondaryBuffer.ParagraphStyle = zaaReloaded2.Properties.Settings.Default.ParagraphStyleName; diff --git a/zaaReloaded2/Formatter/NoLaboratoryDataException.cs b/zaaReloaded2/Formatter/NoLaboratoryDataException.cs new file mode 100755 index 0000000..df47011 --- /dev/null +++ b/zaaReloaded2/Formatter/NoLaboratoryDataException.cs @@ -0,0 +1,35 @@ +/* NoLaboratoryDataException.cs + * part of zaaReloaded2 + * + * Copyright 2015 Daniel Kraus + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +using System; +using System.Runtime.Serialization; + +namespace zaaReloaded2.Formatter +{ + [Serializable] + class NoLaboratoryDataException : Exception + { + public NoLaboratoryDataException() { } + public NoLaboratoryDataException(string message) : base(message) { } + public NoLaboratoryDataException(string message, + Exception innerException) + : base(message, innerException) { } + public NoLaboratoryDataException(SerializationInfo info, + StreamingContext context) + : base(info, context) { } + } +} diff --git a/zaaReloaded2/Ribbon.cs b/zaaReloaded2/Ribbon.cs index 958e328..a556054 100755 --- a/zaaReloaded2/Ribbon.cs +++ b/zaaReloaded2/Ribbon.cs @@ -31,6 +31,9 @@ using zaaReloaded2.ViewModels; using zaaReloaded2.Importer.ZaaImporter; using zaaReloaded2.Formatter; using zaaReloaded2.Controller; +using Word = Microsoft.Office.Interop.Word; +using Bovender.Mvvm.Actions; +using Bovender.Mvvm.Messaging; // TODO: Follow these steps to enable the Ribbon (XML) item: @@ -79,7 +82,8 @@ namespace zaaReloaded2 public void Ribbon_Load(Office.IRibbonUI ribbonUI) { _ribbon = ribbonUI; - Globals.ThisAddIn.Application.WindowSelectionChange += Application_WindowSelectionChange; + Microsoft.Office.Interop.Word.Application word = Globals.ThisAddIn.Application; + word.WindowSelectionChange += Application_WindowSelectionChange; } /// @@ -152,9 +156,19 @@ namespace zaaReloaded2 } } + /// + /// Returns true if there is at least one paragraph selected. + /// + /// + /// The Selection object in Word is a bit tricky: Its Length property + /// is never 0, because even if no text passage is selected, the character + /// after the cursor is the content of the Selection. + /// public bool CanFormat(Office.IRibbonControl control) { - return Globals.ThisAddIn.Application.Selection.Paragraphs.Count > 0; + Word.Selection s = Globals.ThisAddIn.Application.ActiveWindow.Selection; + return s.Paragraphs.Count > 1 || + (s.Text.Length > 1 && s.Text.EndsWith("\r")); } #endregion @@ -182,12 +196,23 @@ namespace zaaReloaded2 void DoFormat(Settings settings) { ZaaImporter importer = new ZaaImporter(); - importer.Import(Globals.ThisAddIn.Application.Selection.Text); - Formatter.Formatter formatter =new Formatter.Formatter( + importer.Import(Globals.ThisAddIn.Application.ActiveWindow.Selection.Text); + Formatter.Formatter formatter = new Formatter.Formatter( Globals.ThisAddIn.Application.ActiveDocument); formatter.Settings = settings; formatter.Laboratory = importer.Laboratory; - formatter.Run(); + try + { + formatter.Run(); + } + catch (NoLaboratoryDataException) + { + NotificationAction a = new NotificationAction(); + a.Caption = "Formatieren nicht möglich"; + a.Message = "Die aktuelle Markierung scheint keine Labordaten zu enthalten."; + a.OkButtonLabel = "Schließen"; + a.Invoke(); + } } void DoChooseSettings() diff --git a/zaaReloaded2/ViewModels/SettingsRepositoryViewModel.cs b/zaaReloaded2/ViewModels/SettingsRepositoryViewModel.cs index 2c1b155..f96350c 100755 --- a/zaaReloaded2/ViewModels/SettingsRepositoryViewModel.cs +++ b/zaaReloaded2/ViewModels/SettingsRepositoryViewModel.cs @@ -26,6 +26,7 @@ using zaaReloaded2.Controller; using System.Collections.ObjectModel; using System.Runtime.Serialization.Formatters.Soap; using System.IO; +using Microsoft.Office.Interop.Word; namespace zaaReloaded2.ViewModels { @@ -314,7 +315,12 @@ namespace zaaReloaded2.ViewModels bool CanUseSettings() { - return LastSelected != null && LastSelected.IsSelected; + Selection selection = Globals.ThisAddIn.Application.ActiveWindow.Selection; + return LastSelected != null && LastSelected.IsSelected && + ( + selection.Paragraphs.Count > 1 + || (selection.Text.Length > 1 && selection.Text.EndsWith("\r")) + ); } void DoAddSettings() diff --git a/zaaReloaded2/zaaReloaded2.csproj b/zaaReloaded2/zaaReloaded2.csproj index c2c542e..37e1ccc 100755 --- a/zaaReloaded2/zaaReloaded2.csproj +++ b/zaaReloaded2/zaaReloaded2.csproj @@ -213,6 +213,7 @@ + From 91b7aa70e9f70b6ca56b77ec4d130b0a218d6c17 Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Fri, 14 Aug 2015 18:11:58 +0200 Subject: [PATCH 04/13] Update ward style. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - GEÄNDERT: Diff.-BB-Werte im Stations-Stil in Hämatologie-Zeile integriert. --- zaaReloaded2/Defaults/ward.zaaReloaded | 74 ++++++++++++-------------- 1 file changed, 33 insertions(+), 41 deletions(-) diff --git a/zaaReloaded2/Defaults/ward.zaaReloaded b/zaaReloaded2/Defaults/ward.zaaReloaded index fe9677f..540b40e 100755 --- a/zaaReloaded2/Defaults/ward.zaaReloaded +++ b/zaaReloaded2/Defaults/ward.zaaReloaded @@ -3,19 +3,19 @@ 1 -<_a>-1732917544 -<_b>21822 -<_c>16721 -<_d>134 -<_e>250 -<_f>231 -<_g>106 -<_h>44 -<_i>93 -<_j>252 -<_k>234 +<_a>1443045381 +<_b>29162 +<_c>17774 +<_d>182 +<_e>243 +<_f>111 +<_g>227 +<_h>16 +<_i>47 +<_j>142 +<_k>57 -Station neu +Kopie von Standard für Station IfSpecialOrAbnormal 4 @@ -43,7 +43,7 @@ 1 -17 +16 @@ -76,11 +76,9 @@ - - -zaaReloaded2.Controller.Elements.NextColumn +zaaReloaded2.Controller.Elements.NextColumn 4 @@ -89,13 +87,13 @@ 0 -zaaReloaded2.Controller.Elements.SelectLastDay +zaaReloaded2.Controller.Elements.SelectLastDay 4 1 -17 +16 @@ -128,81 +126,75 @@ - - -zaaReloaded2.Controller.Elements.Items +zaaReloaded2.Controller.Elements.Items 4 1 -Klinische Chemie: Na, K, Cl, Mg, Ca, P, CaxP, Alb, Prot, Haptoglobin, LDH, Glukose, Harnsäure +Klinische Chemie: Na, K, Cl, Mg, Ca, P, CaxP, Alb, Prot, Haptoglobin, LDH, Glukose, Harnsäure 1 -Entzündung/Immunsystem: CRP, Pct, C3c, C4, Anti-DNAse B, ASL +Entzündung/Immunsystem: CRP, Pct, C3c, C4, Anti-DNAse B, ASL 1 -Kardiale Marker: CK, CKMB, Trop, NTproBNP +Kardiale Marker: CK, CKMB, Trop, NTproBNP 1 -Niere: Krea, Hst, eGFR (CKD-EPI) +Niere: Krea, Hst, eGFR (CKD-EPI) 1 -Sammelurin: SU-Proteinurie, SU-Alb, SU-CrCl, SU-HstCl, SU-GFR, SU-Natrium, SU-Zeit, SU-Volumen +Sammelurin: SU-Proteinurie, SU-Alb, SU-CrCl, SU-HstCl, SU-GFR, SU-Natrium, SU-Zeit, SU-Volumen 1 -Spot-Urin: U-* +Spot-Urin: U-* 1 -Leber: GOT, GGT, GPT, AP, Bilirubin, CHE +Leber: GOT, GGT, GPT, AP, Bilirubin, CHE 1 -Blutfette: TG, Chol, LDL, HDL, Lp(a) +Blutfette: TG, Chol, LDL, HDL, Lp(a) 1 -Hämatologie: Hb, Hkt, Reti, Leu, Thr, MCV, HbA1c, Retikulozyten, Fragmentozyten +Hämatologie: Hb, Hkt, Reti, Leu, Thr, Ery, Neu, Lym, Mon, Baso, Eos, MCV, HbA1c, Retikulozyten, Fragmentozyten 1 -Gerinnung: Quick, INR, PTT, Fibrinogen, ATIII, Anti-Xa +Gerinnung: Quick, INR, PTT, Fibrinogen, ATIII, Anti-Xa 1 -Diff.-BB: Ery, Neu, Lym, Mon, Baso, Eos +Hormone: iPTH, TSH 1 -Hormone: iPTH, TSH +Medikamente: TAC, CSA, SIR, Vancomycin, Gentamicin, Tobramicin 1 -Medikamente: TAC, CSA, SIR, Vancomycin, Gentamicin, Tobramicin +Eisenhaushalt: Eisen, Ferritin, Transferrin, Tf.-Sätt. 1 -Eisenhaushalt: Eisen, Ferritin, Transferrin, Tf.-Sätt. +BGA: pH, Std.-Bic., BE 1 -BGA: pH, Std.-Bic., BE +Hepatitis-Serologie: Anti-HBs, Anti-HBc 1 -Hepatitis-Serologie: Anti-HBs, Anti-HBc - - -1 -Weitere Werte: * +Weitere Werte: * From d5340d1b3a247276819cb1da5f383d9e3f9aff94 Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Fri, 14 Aug 2015 18:12:34 +0200 Subject: [PATCH 05/13] Fix ElementView. - VERBESSERT: Element-Bearbeitungsfenster. --- zaaReloaded2/Views/ElementView.xaml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/zaaReloaded2/Views/ElementView.xaml b/zaaReloaded2/Views/ElementView.xaml index 3212ec7..4117257 100755 --- a/zaaReloaded2/Views/ElementView.xaml +++ b/zaaReloaded2/Views/ElementView.xaml @@ -21,22 +21,23 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:b="clr-namespace:Bovender.Mvvm.Views.Settings;assembly=Bovender" - SizeToContent="WidthAndHeight" ResizeMode="CanResizeWithGrip" ShowInTaskbar="False" + ResizeMode="CanResizeWithGrip" ShowInTaskbar="False" WindowStyle="ToolWindow" Topmost="True" + Width="280" Height="180" MinWidth="280" MinHeight="180" b:WindowState.CenterScreen="True" b:WindowState.Save="True" Title="Element bearbeiten" > - - /// + /// /// Linking several DocumentWriters permits a cascading work flow /// with several buffers. + /// + /// + /// Markup support: The DocumentWriter supports basic markup to control + /// the text styles in the Word document. + /// + /// + /// <b> and </b> - bold/unbold + /// <style:NAME> - set the paragraph or character style + /// </style> - remove *character* style + /// /// class DocumentWriter { @@ -54,12 +65,6 @@ namespace zaaReloaded2.Formatter /// public bool HasBufferedText { get { return _buffer.Length > 0; } } - /// - /// Gets or sets the desired paragraph style when flushing into - /// a Document. - /// - public string ParagraphStyle { get; set; } - /// /// Returns text without markup from the buffer. /// @@ -137,10 +142,6 @@ namespace zaaReloaded2.Formatter Selection s = Document.ActiveWindow.Selection; s.ClearCharacterDirectFormatting(); s.ClearParagraphDirectFormatting(); - if (!string.IsNullOrEmpty(ParagraphStyle)) - { - s.set_Style(ParagraphStyle); - } MarkupToDocument(_buffer.ToString()); } if (Parent != null) @@ -187,22 +188,33 @@ namespace zaaReloaded2.Formatter /// Parses a string containing markup (e.g., "<b>", "</b>") /// and writes formatted text to the current Document. /// - /// void MarkupToDocument(string text) { string[] substrings = _markupRegex.Split(text); + Selection sel = Document.ActiveWindow.Selection; foreach (string substring in substrings) { switch (substring) { case "": - Document.ActiveWindow.Selection.Font.Bold = 1; + sel.Font.Bold = 1; break; case "": - Document.ActiveWindow.Selection.Font.Bold = 0; + sel.Font.Bold = 0; + break; + case "": + sel.ClearCharacterStyle(); break; default: - Document.ActiveWindow.Selection.TypeText(substring); + Match styleMatch = _styleRegex.Match(substring); + if (styleMatch.Success) + { + sel.set_Style(styleMatch.Groups["style"].Value); + } + else + { + sel.TypeText(substring); + } break; } } @@ -214,7 +226,10 @@ namespace zaaReloaded2.Formatter StringBuilder _buffer; // Put pattern in parentheses so they will not be discarded by Regex.Split - static readonly Regex _markupRegex = new Regex(@"()"); + // The splitting pattern must not contain subgroups! + static readonly Regex _markupRegex = new Regex(@"(<[^>]+>)"); + static readonly Regex _styleRegex = new Regex(@"[^>]+)>"); + #endregion } diff --git a/zaaReloaded2/Formatter/Formatter.cs b/zaaReloaded2/Formatter/Formatter.cs index cf62545..976689a 100755 --- a/zaaReloaded2/Formatter/Formatter.cs +++ b/zaaReloaded2/Formatter/Formatter.cs @@ -121,8 +121,7 @@ namespace zaaReloaded2.Formatter { if (!CanRun) throw new NoLaboratoryDataException("No laboratory data to format."); - CreateParagraphStyle(); - _secondaryBuffer.ParagraphStyle = zaaReloaded2.Properties.Settings.Default.ParagraphStyleName; + CreateStyles(); int current = 0; while (current < Settings.Elements.Count) { @@ -242,9 +241,9 @@ namespace zaaReloaded2.Formatter } /// - /// Creates a zaaReloaded2 paragraph style in the document. + /// Creates a paragraph and character styles in the document. /// - public void CreateParagraphStyle() + public void CreateStyles() { if (Document != null) { @@ -253,19 +252,55 @@ namespace zaaReloaded2.Formatter // paragraph style than by using a try...catch construction. try { - style = Document.Styles[Properties.Settings.Default.ParagraphStyleName]; + style = Document.Styles[Properties.Settings.Default.StyleParagraph]; } catch { - style = Document.Styles.Add(Properties.Settings.Default.ParagraphStyleName); + // Add default paragraph style for laboratory + style = Document.Styles.Add(Properties.Settings.Default.StyleParagraph); style.Font.Size = 10; // pt style.Font.Bold = 0; style.Font.Italic = 0; style.Font.Underline = 0; + style.ParagraphFormat.SpaceAfter = 0; + style.ParagraphFormat.SpaceBefore = 0; style.ParagraphFormat.LeftIndent = 36; // pt style.ParagraphFormat.FirstLineIndent = -36; // pt style.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphJustify; } + + try + { + style = Document.Styles[Properties.Settings.Default.StyleHeader]; + } + catch + { + // Add header paragraph style for laboratory + style = Document.Styles.Add(Properties.Settings.Default.StyleHeader); + style.Font.Size = 10; // pt + style.Font.Bold = 1; + style.Font.Italic = 0; + style.Font.Underline = WdUnderline.wdUnderlineSingle; + style.ParagraphFormat.SpaceAfter = 0; + style.ParagraphFormat.SpaceBefore = 12; + style.ParagraphFormat.LeftIndent = 36; // pt + style.ParagraphFormat.FirstLineIndent = -36; // pt + style.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphJustify; + style.set_NextParagraphStyle(Document.Styles[Properties.Settings.Default.StyleParagraph]); + } + + try + { + style = Document.Styles[Properties.Settings.Default.StyleAbnormal]; + } + catch + { + // Add character style for abnormal parameters + style = Document.Styles.Add( + Properties.Settings.Default.StyleAbnormal, + WdStyleType.wdStyleTypeCharacter); + style.Font.Bold = 1; + } } } diff --git a/zaaReloaded2/Formatter/ItemFormatter.cs b/zaaReloaded2/Formatter/ItemFormatter.cs index 5e198c9..e7dc4dc 100755 --- a/zaaReloaded2/Formatter/ItemFormatter.cs +++ b/zaaReloaded2/Formatter/ItemFormatter.cs @@ -163,7 +163,9 @@ namespace zaaReloaded2.Formatter ); if (!LabItem.IsNormal) { - output = String.Format("{0}", output); + output = String.Format( + "{0}", + output); } formatter.Write(output); diff --git a/zaaReloaded2/Formatter/TimePointFormatter.cs b/zaaReloaded2/Formatter/TimePointFormatter.cs index bcdc801..9cac1bc 100755 --- a/zaaReloaded2/Formatter/TimePointFormatter.cs +++ b/zaaReloaded2/Formatter/TimePointFormatter.cs @@ -68,10 +68,12 @@ namespace zaaReloaded2.Formatter static string FormatHeader(string text) { - return String.Format("{0}Laborwerte vom {1}:{2}", + return String.Format("{0}Laborwerte vom {2}:{3}", Environment.NewLine, + Properties.Settings.Default.StyleHeader, text, - Environment.NewLine + Environment.NewLine, + Properties.Settings.Default.StyleParagraph ); } diff --git a/zaaReloaded2/Properties/Settings.Designer.cs b/zaaReloaded2/Properties/Settings.Designer.cs index bf379f7..66e2b7e 100755 --- a/zaaReloaded2/Properties/Settings.Designer.cs +++ b/zaaReloaded2/Properties/Settings.Designer.cs @@ -250,9 +250,9 @@ namespace zaaReloaded2.Properties { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("zaaReloaded2-Laborwerte")] - public string ParagraphStyleName { + public string StyleParagraph { get { - return ((string)(this["ParagraphStyleName"])); + return ((string)(this["StyleParagraph"])); } } @@ -303,5 +303,23 @@ namespace zaaReloaded2.Properties { this["ImportExportPath"] = value; } } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("zaaReloaded2-Überschrift")] + public string StyleHeader { + get { + return ((string)(this["StyleHeader"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("zaaReloaded2-Pathologisch")] + public string StyleAbnormal { + get { + return ((string)(this["StyleAbnormal"])); + } + } } } diff --git a/zaaReloaded2/Properties/Settings.settings b/zaaReloaded2/Properties/Settings.settings index 45f429b..ecb61c0 100755 --- a/zaaReloaded2/Properties/Settings.settings +++ b/zaaReloaded2/Properties/Settings.settings @@ -74,7 +74,7 @@ 00000000-0000-0000-0000-000000000000 - + zaaReloaded2-Laborwerte @@ -92,5 +92,11 @@ + + zaaReloaded2-Überschrift + + + zaaReloaded2-Pathologisch + \ No newline at end of file diff --git a/zaaReloaded2/app.config b/zaaReloaded2/app.config index 5dc28f4..fd5f598 100755 --- a/zaaReloaded2/app.config +++ b/zaaReloaded2/app.config @@ -92,7 +92,7 @@ Medikamente: TAC, CSA, SIR, Vancomycin, Gentamicin, Tobramicin - + zaaReloaded2-Laborwerte @@ -107,6 +107,12 @@ 1 + + zaaReloaded2-Überschrift + + + zaaReloaded2-Pathologisch + From 2e8c881e1fa3228985bcaf440bfb1843558d839c Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Sat, 15 Aug 2015 20:15:52 +0200 Subject: [PATCH 09/13] Clean up assembly settings. --- zaaReloaded2/Properties/Settings.Designer.cs | 108 ------------------- zaaReloaded2/Properties/Settings.settings | 36 ------- zaaReloaded2/app.config | 36 ------- 3 files changed, 180 deletions(-) diff --git a/zaaReloaded2/Properties/Settings.Designer.cs b/zaaReloaded2/Properties/Settings.Designer.cs index 66e2b7e..d2e1e93 100755 --- a/zaaReloaded2/Properties/Settings.Designer.cs +++ b/zaaReloaded2/Properties/Settings.Designer.cs @@ -127,114 +127,6 @@ namespace zaaReloaded2.Properties { } } - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Klinische Chemie: Na, K, Cl, Mg, Pi, Alb, Prot, LDH, Hsre")] - public string DefaultItemsClinicalChem { - get { - return ((string)(this["DefaultItemsClinicalChem"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Hämatologie: Hb, Hkt, Reti, Leu, Thr, Neu, HbA1c")] - public string DefaultItemsHematology { - get { - return ((string)(this["DefaultItemsHematology"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Gerinnung: Quick, INR, PTT, Fibrinogen, ATIII, Anti-Xa")] - public string DefaultItemsCoagulation { - get { - return ((string)(this["DefaultItemsCoagulation"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Spot-Urin: U-*")] - public string DefaultItemsSpotUrine { - get { - return ((string)(this["DefaultItemsSpotUrine"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Sammelurin: SU-*")] - public string DefaultItemsCollectedUrine { - get { - return ((string)(this["DefaultItemsCollectedUrine"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Weitere Werte: *")] - public string DefaultItemsOther { - get { - return ((string)(this["DefaultItemsOther"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Kardiale Marker: CK, CKMB, Trop, NTproBNP")] - public string DefaultItemsCardio { - get { - return ((string)(this["DefaultItemsCardio"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Blutfette: TG, Chol, LDL, HDL, Lp(a)")] - public string DefaultItemsLipids { - get { - return ((string)(this["DefaultItemsLipids"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Leber: GOT, GGT, GPT, AP, Bili, CHE")] - public string DefaultItemsLiver { - get { - return ((string)(this["DefaultItemsLiver"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Niere: Krea, Hst, eGFR")] - public string DefaultItemsKidney { - get { - return ((string)(this["DefaultItemsKidney"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Entzündung/Immunsystem: CRP, Pct, C3, C4")] - public string DefaultItemsInflammation { - get { - return ((string)(this["DefaultItemsInflammation"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Medikamente: TAC, CSA, SIR, Vancomycin, Gentamicin, Tobramicin")] - public string DefaultItemsDrugs { - get { - return ((string)(this["DefaultItemsDrugs"])); - } - } - [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("00000000-0000-0000-0000-000000000000")] diff --git a/zaaReloaded2/Properties/Settings.settings b/zaaReloaded2/Properties/Settings.settings index ecb61c0..2ca76ce 100755 --- a/zaaReloaded2/Properties/Settings.settings +++ b/zaaReloaded2/Properties/Settings.settings @@ -35,42 +35,6 @@ Standard für NepA - - Klinische Chemie: Na, K, Cl, Mg, Pi, Alb, Prot, LDH, Hsre - - - Hämatologie: Hb, Hkt, Reti, Leu, Thr, Neu, HbA1c - - - Gerinnung: Quick, INR, PTT, Fibrinogen, ATIII, Anti-Xa - - - Spot-Urin: U-* - - - Sammelurin: SU-* - - - Weitere Werte: * - - - Kardiale Marker: CK, CKMB, Trop, NTproBNP - - - Blutfette: TG, Chol, LDL, HDL, Lp(a) - - - Leber: GOT, GGT, GPT, AP, Bili, CHE - - - Niere: Krea, Hst, eGFR - - - Entzündung/Immunsystem: CRP, Pct, C3, C4 - - - Medikamente: TAC, CSA, SIR, Vancomycin, Gentamicin, Tobramicin - 00000000-0000-0000-0000-000000000000 diff --git a/zaaReloaded2/app.config b/zaaReloaded2/app.config index fd5f598..5fcdbc6 100755 --- a/zaaReloaded2/app.config +++ b/zaaReloaded2/app.config @@ -56,42 +56,6 @@ Standard für NepA - - Klinische Chemie: Na, K, Cl, Mg, Pi, Alb, Prot, LDH, Hsre - - - Hämatologie: Hb, Hkt, Reti, Leu, Thr, Neu, HbA1c - - - Gerinnung: Quick, INR, PTT, Fibrinogen, ATIII, Anti-Xa - - - Spot-Urin: U-* - - - Sammelurin: SU-* - - - Weitere Werte: * - - - Kardiale Marker: CK, CKMB, Trop, NTproBNP - - - Blutfette: TG, Chol, LDL, HDL, Lp(a) - - - Leber: GOT, GGT, GPT, AP, Bili, CHE - - - Niere: Krea, Hst, eGFR - - - Entzündung/Immunsystem: CRP, Pct, C3, C4 - - - Medikamente: TAC, CSA, SIR, Vancomycin, Gentamicin, Tobramicin - zaaReloaded2-Laborwerte From 2745ab819c72de1c8bcdef385dc1d98500efb259 Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Sun, 16 Aug 2015 05:17:06 +0200 Subject: [PATCH 10/13] Do not create character style (currently not used). --- zaaReloaded2/Formatter/Formatter.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zaaReloaded2/Formatter/Formatter.cs b/zaaReloaded2/Formatter/Formatter.cs index 976689a..ebedc68 100755 --- a/zaaReloaded2/Formatter/Formatter.cs +++ b/zaaReloaded2/Formatter/Formatter.cs @@ -289,6 +289,7 @@ namespace zaaReloaded2.Formatter style.set_NextParagraphStyle(Document.Styles[Properties.Settings.Default.StyleParagraph]); } + /* try { style = Document.Styles[Properties.Settings.Default.StyleAbnormal]; @@ -301,6 +302,7 @@ namespace zaaReloaded2.Formatter WdStyleType.wdStyleTypeCharacter); style.Font.Bold = 1; } + */ } } From 392de61b7472be4679e09f53764f8e5f3ded1d96 Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Sun, 16 Aug 2015 05:17:24 +0200 Subject: [PATCH 11/13] Omit superfluous newline in output. --- zaaReloaded2/Formatter/TimePointFormatter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zaaReloaded2/Formatter/TimePointFormatter.cs b/zaaReloaded2/Formatter/TimePointFormatter.cs index 9cac1bc..0dccbaf 100755 --- a/zaaReloaded2/Formatter/TimePointFormatter.cs +++ b/zaaReloaded2/Formatter/TimePointFormatter.cs @@ -68,8 +68,8 @@ namespace zaaReloaded2.Formatter static string FormatHeader(string text) { - return String.Format("{0}Laborwerte vom {2}:{3}", - Environment.NewLine, + return String.Format("Laborwerte vom {1}:{2}", + // Environment.NewLine, Properties.Settings.Default.StyleHeader, text, Environment.NewLine, From 221509520debf6eb14e8844d826f548c4f0d4b61 Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Sun, 16 Aug 2015 16:25:53 +0200 Subject: [PATCH 12/13] Fix markup detection DocumentWriter. --- Tests/Formatter/DocumentWriterTest.cs | 6 ++++-- zaaReloaded2/Formatter/DocumentWriter.cs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Tests/Formatter/DocumentWriterTest.cs b/Tests/Formatter/DocumentWriterTest.cs index 74d3075..bb74e46 100755 --- a/Tests/Formatter/DocumentWriterTest.cs +++ b/Tests/Formatter/DocumentWriterTest.cs @@ -100,9 +100,11 @@ namespace Tests.Formatter [Test] public void TextMarkup() { - _docWriter.Document = new Document(); - _docWriter.WriteLine("This is not bold. This is bold!"); + DocumentWriter output = new DocumentWriter(); + _docWriter.Parent = output; + _docWriter.Write("This is not bold. This is bold!\rThis not."); _docWriter.Flush(); + Assert.AreEqual("This is not bold. This is bold!\rThis not.", output.Text); } } } diff --git a/zaaReloaded2/Formatter/DocumentWriter.cs b/zaaReloaded2/Formatter/DocumentWriter.cs index 1b9356b..ad1acfd 100755 --- a/zaaReloaded2/Formatter/DocumentWriter.cs +++ b/zaaReloaded2/Formatter/DocumentWriter.cs @@ -227,7 +227,7 @@ namespace zaaReloaded2.Formatter StringBuilder _buffer; // Put pattern in parentheses so they will not be discarded by Regex.Split // The splitting pattern must not contain subgroups! - static readonly Regex _markupRegex = new Regex(@"(<[^>]+>)"); + static readonly Regex _markupRegex = new Regex(@"(<[^ >]+>)"); static readonly Regex _styleRegex = new Regex(@"[^>]+)>"); From fbcb060f12670b7fe6227be357e495d99e8a20ab Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Sun, 16 Aug 2015 16:33:18 +0200 Subject: [PATCH 13/13] Omit space before units starting with a slash. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - VERBESSERUNG: Einheiten, die mit einem Schrägstrich beginnen, werden nicht mehr mit Leerzeichen vom Wert getrennt. --- zaaReloaded2/Formatter/ItemFormatter.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zaaReloaded2/Formatter/ItemFormatter.cs b/zaaReloaded2/Formatter/ItemFormatter.cs index e7dc4dc..4f6f1d7 100755 --- a/zaaReloaded2/Formatter/ItemFormatter.cs +++ b/zaaReloaded2/Formatter/ItemFormatter.cs @@ -132,7 +132,8 @@ namespace zaaReloaded2.Formatter string unit; if (LabItem.HasUnit) { - unit = String.Format(" {0}", LabItem.Unit); + string space = LabItem.Unit.StartsWith("/") ? String.Empty : " "; + unit = String.Format("{0}{1}", space, LabItem.Unit); } else {