/* DanielsStyle.cs * part of zaaReloaded2 * * Copyright 2015-2017 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.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Office.Interop.Word; using System.Text.RegularExpressions; namespace zaaReloaded2.Formatter { /// /// Makes design changes and edits especially for Daniel Kraus. /// static class DanielsStyle { public static void Apply(Document document, Selection selection) { FixWords(document); FormatDiagnoses(selection); FixSalutation(document); } static void FormatDiagnoses(Selection selection) { Range r = selection.Range; r.ListFormat.RemoveNumbers(); r.Bold = 0; r.Italic = 0; r.Underline = WdUnderline.wdUnderlineNone; r.Font.Size = 10; Paragraphs p = r.Paragraphs; p.Alignment = WdParagraphAlignment.wdAlignParagraphLeft; p.FirstLineIndent = -45; p.LeftIndent = 45; p.LineSpacingRule = WdLineSpacing.wdLineSpaceSingle; p.SpaceAfter = 0; p.SpaceBefore = 0; if (p[p.Count].Range.Text.StartsWith("Aktuell")) { p[p.Count].Range.Bold = 1; } } static void FixWords(Document document) { Find find = document.Range().Find; find.Execute2007(FindText: "Körperlicher Untersuchungsbefund", ReplaceWith: "Körperl. Untersuchung", Replace: WdReplace.wdReplaceAll); find.Execute2007(FindText: "Dr.D.Kraus", ReplaceWith: "Dr. D. Kraus", Replace: WdReplace.wdReplaceAll); find.Execute2007(FindText: "Z. n.", ReplaceWith: "Z.n.", Replace: WdReplace.wdReplaceAll); find.Execute2007(FindText: "Zust. n.", ReplaceWith: "Z.n.", Replace: WdReplace.wdReplaceAll); find.Execute2007(FindText: "Zust.n.", ReplaceWith: "Z.n.", Replace: WdReplace.wdReplaceAll); find.Execute2007(FindText: "Assistent der Klinik", ReplaceWith: "Internist/Nephrologe", Replace: WdReplace.wdReplaceAll); find.Execute2007(FindText: "Professor Dr.", ReplaceWith: "Prof. Dr.", Replace: WdReplace.wdReplaceAll); find.Execute2007(FindText: "mmHg", ReplaceWith: "mm Hg", Replace: WdReplace.wdReplaceAll); find.Execute2007(FindText: "RR ", ReplaceWith: "", Replace: WdReplace.wdReplaceAll, MatchCase: true, MatchWholeWord: true); find.Execute2007(FindText: "HF ", ReplaceWith: "", Replace: WdReplace.wdReplaceAll, MatchCase: true, MatchWholeWord: true); find.Execute2007(FindText: "TAC-Spiegel", ReplaceWith: "Tacrolimus-Talspiegel", Replace: WdReplace.wdReplaceAll); find.Execute2007(FindText: "ammelruin", ReplaceWith: "ammelurin", Replace: WdReplace.wdReplaceAll, MatchWholeWord: false); find.Execute2007(FindText: "4-7", ReplaceWith: "4 bis 7", Replace: WdReplace.wdReplaceAll); find.Execute2007(FindText: "5-8", ReplaceWith: "5 bis 8", Replace: WdReplace.wdReplaceAll); find.Execute2007(FindText: "8-10", ReplaceWith: "8 bis 10", Replace: WdReplace.wdReplaceAll); find.Execute2007(FindText: "4 - 7", ReplaceWith: "4 bis 7", Replace: WdReplace.wdReplaceAll); find.Execute2007(FindText: "5 - 8", ReplaceWith: "5 bis 8", Replace: WdReplace.wdReplaceAll); find.Execute2007(FindText: "8 - 10", ReplaceWith: "8 bis 10", Replace: WdReplace.wdReplaceAll); } static void FixSalutation(Document document) { Regex sal = new Regex(@"^Mit.*?Grüßen\r"); Regex med = new Regex(@"^((Häusl|Empf).*?Medikat)|^Therapieempf"); foreach (Paragraph p in document.Paragraphs) { if (sal.IsMatch(p.Range.Text)) p.Range.Text = "Mit freundlichen, kollegialen Grüßen,\r"; if (med.IsMatch(p.Range.Text)) p.Range.Text = "Aktuelle Medikation:\r"; } } } }