45 Commits

Author SHA1 Message Date
b1cd1f1a05 Merge branch 'release-2.2.3' 2016-03-30 14:11:57 +02:00
003da0f1b2 Update copyright year on home page. 2016-03-30 14:11:49 +02:00
9a5cc4d9df Update version info file. 2016-03-30 14:11:03 +02:00
15ada1cefd Update VstoAddinInstaller and fix make-installer script. 2016-03-30 14:08:15 +02:00
94efa435f2 Bump version number, write history. 2016-03-30 14:02:33 +02:00
89df2f5e13 Fix host declaration in installer script.
- REPARIERT: Installationsskript hat Add-in nicht aktiviert.
2016-03-30 13:59:43 +02:00
e3e86891b8 Merge branch 'release-2.2.2' into develop 2016-03-29 21:49:54 +02:00
20c0b8a76e Merge branch 'release-2.2.2' 2016-03-29 21:49:22 +02:00
d807472016 Update VstoAddinInstaller. 2016-03-29 21:49:16 +02:00
33c8f48282 Write history. 2016-03-29 21:06:51 +02:00
9bbab2607d Merge branch 'vstoaddininstaller' into develop
- VERBESSERT: Installationsprogramm erkennt jetzt, wenn Word bereits läuft, und bietet an, es zu schließen
2016-03-29 12:21:46 +02:00
15df44a93b Use VstoAddinInstaller to produce version 2.2.2. 2016-03-29 12:21:40 +02:00
67219d0ae5 Add VstoAddinInstaller as submodule. 2016-03-29 10:16:54 +02:00
3f6383b076 Merge branch 'hotfix-2.2.1' into develop 2015-12-03 16:17:22 +01:00
c104568e5b Merge branch 'hotfix-2.2.1' 2015-12-03 16:16:48 +01:00
687ce567e3 Prepare release 2.2.1. 2015-12-03 16:16:42 +01:00
573cd743d1 Fix parsing of single-prescription lines.
- VERBESSERT: 'Alternative' Verordnungen wurden nicht erkannt, wenn in der selben Zeile nicht auch eine 'kanonische' Verordnung stand.
2015-12-03 16:13:53 +01:00
0d4b60096a Fix typo in demo document. 2015-12-03 16:13:34 +01:00
4c147a9764 Fix XmlException (report ID 6a36e38b).
- VERBESSERT: Fehlermeldung "Ein Name darf nicht mit dem Zeichen ' ' beginnen" wurde abgestellt (Fehlernr. 6a36e38b).
2015-12-03 16:12:04 +01:00
d1fa0b797d Merge branch 'release-2.2.0' into develop 2015-12-03 06:12:25 +01:00
2a3ff8c63e Merge branch 'release-2.2.0' 2015-12-03 06:10:35 +01:00
7e79256ffd Prepare release 2.2.0. 2015-12-03 06:10:27 +01:00
1314cb0e4b Merge branch 'medication' into develop
- NEU: Funktion zum Formatieren der Medikationsliste.
2015-12-03 06:08:03 +01:00
d28d51e875 Improve detection of two prescription columns. 2015-12-03 06:03:35 +01:00
86c8a9a1b4 Improve prescription block autodetection. 2015-12-02 21:45:55 +01:00
c3fde7fc28 Add reference levels to immunology in clinic style.
- VERBESSERT: Referenzbereiche zu Immunologie-Vorlage im Ambulanzstil hinzugefügt.
2015-12-02 21:10:47 +01:00
e71e69d4c4 Implement automatic MMF warning. 2015-12-02 17:08:25 +01:00
865e5bff1e Split prescriptions regexes. 2015-12-02 14:20:42 +01:00
2296fcfe41 Fix parsing of prescriptions without regular dosing. 2015-12-02 12:25:30 +01:00
92153f6d6c Import prescriptions by columns. 2015-12-01 21:10:42 +01:00
def5fce235 Fill prescription block by columns, not rows. 2015-12-01 20:51:24 +01:00
6ec282ee68 Improve formatting of prescriptions. 2015-12-01 17:38:44 +01:00
4479efc196 Fix parsing again. 2015-12-01 17:02:31 +01:00
84e298e9ad Fix parsing of drugs with comments. 2015-12-01 14:52:22 +01:00
61f494f10f Fix ribbon command. 2015-11-27 09:52:46 +01:00
21e7d44187 First working version of drugs formatting. 2015-11-26 21:33:10 +01:00
bcbed5bca3 Add prescriptions importer. 2015-11-26 20:02:07 +01:00
c35c73f56a Add multiple prescriptions parsing. 2015-11-26 19:44:33 +01:00
a255349672 Initial Prescription model with factory. 2015-11-26 19:11:25 +01:00
5198fa7358 Add carbohydrate-deficient transferrin.
- VERBESSERT: Kohlehydratdefizientes Transferrin hinzugefügt (als 'CDT') und Ambulanzstil angepaßt.
2015-11-25 20:52:20 +01:00
bed957a5cb Merge branch 'release-2.1.13' into develop 2015-11-12 21:25:16 +01:00
d01bdabf35 Merge branch 'release-2.1.13' 2015-11-12 21:24:56 +01:00
346112b069 Prepare release 2.1.13. 2015-11-12 21:24:38 +01:00
5d1ee1f96e Add pregnancy test and ARQ parameters.
- VERBESSERT: Parameter für Aldosteron, Renin und Schwangerschaftstest einprogrammiert.
2015-11-12 21:22:45 +01:00
3043a07632 Merge branch 'release-2.1.12' into develop 2015-11-04 20:52:49 +01:00
38 changed files with 1145 additions and 803 deletions

1
.gitignore vendored
View File

@ -16,6 +16,7 @@ publish/release/
x64/ x64/
win32/ win32/
[Rr]elease/ [Rr]elease/
[Rr]eleases/
[Dd]debug/ [Dd]debug/
Dist/ Dist/
build/ build/

3
.gitmodules vendored
View File

@ -1,3 +1,6 @@
[submodule "www/PHPMailer"] [submodule "www/PHPMailer"]
path = www/PHPMailer path = www/PHPMailer
url = git@github.com:PHPMailer/PHPMailer.git url = git@github.com:PHPMailer/PHPMailer.git
[submodule "deploy/VstoAddinInstaller"]
path = deploy/VstoAddinInstaller
url = /home/daniel/local/Code/VstoAddinInstaller

View File

@ -1,3 +1,46 @@
Version 2.2.3 (2016-03-30)
========================================================================
- REPARIERT: Installationsskript hat Add-in nicht aktiviert.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 2.2.2 (2016-03-29)
========================================================================
- VERBESSERT: Installationsprogramm erkennt jetzt, wenn Word bereits läuft, und bietet an, es zu schließen
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 2.2.1 (2015-12-03)
========================================================================
- VERBESSERT: 'Alternative' Verordnungen wurden nicht erkannt, wenn in der selben Zeile nicht auch eine 'kanonische' Verordnung stand.
- VERBESSERT: Fehlermeldung "Ein Name darf nicht mit dem Zeichen ' ' beginnen" wurde abgestellt (Fehlernr. 6a36e38b).
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 2.2.0 (2015-12-03)
========================================================================
- NEU: Funktion zum Formatieren der Medikationsliste.
- VERBESSERT: Kohlehydratdefizientes Transferrin hinzugefügt (als 'CDT') und Ambulanzstil angepaßt.
- VERBESSERT: Referenzbereiche zu Immunologie-Vorlage im Ambulanzstil hinzugefügt.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 2.1.13 (2015-11-12)
========================================================================
- VERBESSERT: Parameter für Aldosteron, Renin und Schwangerschaftstest einprogrammiert.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 2.1.12 (2015-11-04) Version 2.1.12 (2015-11-04)
======================================================================== ========================================================================

View File

@ -0,0 +1,45 @@
/* ImporterTest.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.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
namespace Tests.Medication
{
[TestFixture]
class ImporterTest
{
[Test]
public void ImportDrugsTwoColumns()
{
string s =
"Aktuelle Medikation:\r" +
"Advagraf 1 mg 2-0-0 CellCept 500 mg 1-0-1\r" +
"CellCept 250 mg 1-0-1 Decortin 10 mg 1-0-0\r" +
"Beloc-Zok mite 1-0-1 Ramipril 5 mg 0-0-1 (neu)\r" +
"Pantozol 40 mg 0-0-1 Decostriol 0,5 µg 2-0-0\r" +
"Euthyrox 200 µg 1-1-1 (gesteigert) Ossofortin forte 1-0-1\r" +
"Vfend 200 mg 2-0-2 CPS-Pulver 0-1-0\r" +
"Cyklokapron 500 mg 1-1-1 Tamsulosin 0,4 mg 1-0-0 ";
zaaReloaded2.Medication.Importer i = new zaaReloaded2.Medication.Importer(s);
Assert.AreEqual(14, i.Prescriptions.Count);
}
}
}

View File

@ -0,0 +1,128 @@
/* PrescriptionTest.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.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using zaaReloaded2.Medication;
namespace Tests.Medication
{
[TestFixture]
class PrescriptionTest
{
[Test]
[TestCase("Ramipril 5 mg 1-2-3", "Ramipril 5 mg", "1", "2", "3")]
[TestCase("Ramipril 5 mg 1 -2 - 3", "Ramipril 5 mg", "1", "2", "3")]
[TestCase("Ramipril 5 mg 1 - 2 - 3", "Ramipril 5 mg", "1", "2", "3")]
[TestCase("Ramipril 5 mg 1 - 2 - 3", "Ramipril 5 mg", "1", "2", "3")]
[TestCase("Ramipril 5 mg 1 1/2-2-3", "Ramipril 5 mg", "1 1/2", "2", "3")]
[TestCase("Ramipril 5 mg 1 1/2 - 2 - 3", "Ramipril 5 mg", "1 1/2", "2", "3")]
[TestCase("Ramipril 5 mg ½-⅓-¼", "Ramipril 5 mg", "½", "⅓", "¼")]
public void ParseLine(string line, string drug, string morning,
string noon, string evening)
{
Prescription p = Prescription.FromLine(line);
Assert.AreEqual(drug, p.Drug, "Drug should be " + drug);
Assert.AreEqual(morning, p.Morning, "Morning should be " + morning);
Assert.AreEqual(noon, p.Noon, "Noon should be " + noon);
Assert.AreEqual(evening, p.Evening, "Evening should be " + evening);
}
[Test]
public void MultiplePrescriptions()
{
IEnumerable<Prescription> list = Prescription.ManyFromLine(
"Ramipril 5 mg 1-0-0 \t Prograf 1 mg 1-0-1");
Assert.AreEqual(2, list.Count());
Assert.AreEqual("Ramipril 5 mg\t1-0-0", list.First().ToString());
Assert.AreEqual("Prograf 1 mg\t1-0-1", list.Last().ToString());
}
[Test]
[TestCase("Ramipril 5 mg", "1", "0", "0", "0", "Ramipril 5 mg\t1-0-0-0")]
[TestCase("Ramipril 5 mg", "1", "0", "0", "", "Ramipril 5 mg\t1-0-0")]
[TestCase("Ramipril 5 mg", "1", "0", "", "", "Ramipril 5 mg\t1-0")]
[TestCase("Ramipril 5 mg", "1", "", "", "", "Ramipril 5 mg\t1")]
[TestCase("Ramipril 5 mg", "1", "", "0", "0", "Ramipril 5 mg\t1-0-0-0")]
[TestCase("Ramipril 5 mg", "1", "0", "", "0", "Ramipril 5 mg\t1-0-0-0")]
[TestCase("Ramipril 5 mg", "1", "", "", "0", "Ramipril 5 mg\t1-0-0-0")]
[TestCase("Ramipril 5 mg", "", "", "", "", "Ramipril 5 mg\t")]
public void PrescriptionToString(string drug, string morning, string noon,
string evening, string night, string formatted)
{
Prescription p = new Prescription(drug, morning, noon, evening, night);
Assert.AreEqual(formatted, p.ToString());
}
[Test]
public void PrescriptionWithComment()
{
Prescription p = Prescription.FromLine("Ramipril 5 mg 1-0-2 (gesteigert)");
Assert.AreEqual("Ramipril 5 mg", p.Drug);
Assert.AreEqual("1", p.Morning);
Assert.AreEqual("0", p.Noon);
Assert.AreEqual("2", p.Evening);
Assert.AreEqual("(gesteigert)", p.Comment);
Assert.AreEqual("Ramipril 5 mg\t1-0-2 (gesteigert)", p.ToString());
}
[Test]
public void PrescriptionsLineWithComment()
{
IList<Prescription> list = Prescription.ManyFromLine(
"Ramipril 5 mg 1-0-2 (gesteigert) \t Concor 2,5 mg 3-2-1-0 neu");
Assert.AreEqual(2, list.Count);
Assert.AreEqual("Ramipril 5 mg", list[0].Drug);
Assert.AreEqual("1", list[0].Morning);
Assert.AreEqual("0", list[0].Noon);
Assert.AreEqual("2", list[0].Evening);
Assert.AreEqual("", list[0].Night);
Assert.AreEqual("(gesteigert)", list[0].Comment);
Assert.AreEqual("Concor 2,5 mg", list[1].Drug);
Assert.AreEqual("3", list[1].Morning);
Assert.AreEqual("2", list[1].Noon);
Assert.AreEqual("1", list[1].Evening);
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");
}
[Test]
[TestCase("CellCept 500 mg", true)]
[TestCase("Cell CEpt 500 mg", true)]
[TestCase("Myfortic", true)]
[TestCase("Mycophenolatmofetil 500 mg", true)]
[TestCase("Cellophan 5 g", false)]
[TestCase("MMF 500 mg", true)]
public void MmfProperty(string drug, bool isMmf)
{
Prescription p = new Prescription(drug);
Assert.AreEqual(isMmf, p.IsMmf);
}
}
}

View File

@ -83,6 +83,8 @@
<Compile Include="Controller\Comments\CommentPoolTest.cs" /> <Compile Include="Controller\Comments\CommentPoolTest.cs" />
<Compile Include="Controller\Comments\ItemCommentTest.cs" /> <Compile Include="Controller\Comments\ItemCommentTest.cs" />
<Compile Include="Controller\Elements\CloneTest.cs" /> <Compile Include="Controller\Elements\CloneTest.cs" />
<Compile Include="Medication\ImporterTest.cs" />
<Compile Include="Medication\PrescriptionTest.cs" />
<Compile Include="SerializationTest.cs" /> <Compile Include="SerializationTest.cs" />
<Compile Include="Controller\SettingsRepositoryTest.cs" /> <Compile Include="Controller\SettingsRepositoryTest.cs" />
<Compile Include="Controller\SettingsTest.cs" /> <Compile Include="Controller\SettingsTest.cs" />

32
deploy/make-installer.iss Normal file
View File

@ -0,0 +1,32 @@
#expr Exec("C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.com", \
"x:\Code\zaaReloaded2\zaaReloaded2\zaaReloaded2.csproj /Build Release")
#define VERSIONFILE "..\zaaReloaded2\VERSION"
#define PUB_YEARS "2015-2016"
#define TARGET_HOST "word"
#define APP_GUID "{{8520B887-3AB1-422B-AB6B-A265D14FE4E5}"
#define ADDIN_NAME "zaaReloaded"
#define COMPANY "Daniel Kraus (bovender)"
#define DESCRIPTION "Word-Addin, das Lauris-Laborwerte in der Zentralen Arztbriefablage formatiert."
#define HOMEPAGE "http://zaa.nephrowiki.de"
#define REGKEY "zaaReloaded2"
#define SOURCEDIR "..\zaaReloaded2\bin\Release\"
#define VSTOFILE "zaaReloaded2.vsto"
; OUTPUTDIR is the directory where the installer will be saved.
#define OUTPUTDIR "releases\"
#define LOGFILE "ZAARELOADED2-INSTALL-LOG.TXT"
#define SETUPFILESDIR "setup-files\"
#define LICENSE_FILE "license.rtf"
#define INSTALLER_ICO "icon.ico"
#define INSTALLER_IMAGE_LARGE "installbanner.bmp"
#define INSTALLER_IMAGE_SMALL "installbanner-small.bmp"
; If the VstoAddinInstaller files are in a different subdirectory
; than 'VstoAddinInstaller', change the path below.
#include "VstoAddinInstaller\vsto-installer.iss"
; vim: ts=2 sts=2 sw=2 et

View File

Before

Width:  |  Height:  |  Size: 204 KiB

After

Width:  |  Height:  |  Size: 204 KiB

View File

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View File

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

Before

Width:  |  Height:  |  Size: 153 KiB

After

Width:  |  Height:  |  Size: 153 KiB

BIN
gimp/m.xcf Normal file

Binary file not shown.

BIN
gimp/mm.xcf Normal file

Binary file not shown.

View File

@ -1,760 +0,0 @@
; Inno Setup script for zaaReloaded2
; (c) 2015 Daniel Kraus
; Apache License Version 2.0
[Setup]
; #define DEBUG
; Read the semantic and the installer file version from the VERSION file
#define FILE_HANDLE FileOpen("..\zaaReloaded2\VERSION")
#define SEMVER FileRead(FILE_HANDLE)
#define VER FileRead(FILE_HANDLE)
#expr FileClose(FILE_HANDLE)
#define YEAR "2015"
#define DEV "Daniel Kraus"
#define LOGFILE "INST-LOG.TXT"
#define REGKEY "Software\Microsoft\Office\Word\Addins\zaaReloaded2"
#define APPNAME "zaaReloaded"
#define SLOGAN "Word-Addin, das Lauris-Laborwerte in der Zentralen Arztbriefablage formatiert"
#define UNINSTALLDIR "{app}\setup"
#define ADDINNAME "zaaReloaded2"
#define DOTNETSHA1 "58da3d74db353aad03588cbb5cea8234166d8b99"
#define VSTORSHA1 "ad1dcc5325cb31754105c8c783995649e2208571"
#ifndef DEBUG
#define SOURCEDIR "Release"
#define VSTORURL "http://download.microsoft.com/download/2/E/9/2E9D2603-6D1F-4B12-BD37-DB1410B23597/vstor_redist.exe"
#define DOTNETURL "http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe"
; Build the solution with Release configuration
#expr Exec("C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.com", \
"x:\Code\zaaReloaded2\zaaReloaded2\zaaReloaded2.csproj /Build Release")
#else
#define SOURCEDIR "Debug"
#define VSTORURL "http://vhost/vstor_redist.exe"
#define DOTNETURL "http://vhost/dotNetFx40_Full_x86_x64.exe"
#endif
; Specific AppID - NEVER CHANGE THIS!
AppId={{8520B887-3AB1-422B-AB6B-A265D14FE4E5}
; Compiler info
OutputDir=release
#ifndef DEBUG
OutputBaseFilename=zaaReloaded-{#SEMVER}
#else
OutputBaseFilename=zaaReloaded-debug
#endif
Compression=lzma
InternalCompressLevel=max
SolidCompression=true
LicenseFile=setup-files\license.rtf
; Application name, version, etc.
AppName={#APPNAME}
AppVersion={#SEMVER}
AppPublisher={#DEV}
AppCopyright=2008-{#YEAR} {#DEV}
AppComments={#SLOGAN}
VersionInfoDescription={#SLOGAN}
VersionInfoVersion={#VER}
VersionInfoProductVersion={#VER}
VersionInfoTextVersion={#SEMVER}
VersionInfoProductTextVersion={#SEMVER}
AppContact={#DEV}
AppPublisherURL=http://zaa.nephrowiki.de
AppSupportURL=http://zaa.nephrowiki.de
AppUpdatesURL=http://zaa.nephrowiki.de
; Setup wizard
SetupIconFile=setup-files\icon.ico
WizardImageFile=setup-files\installbanner.bmp
WizardSmallImageFile=setup-files\installbanner-small.bmp
ArchitecturesAllowed=x86 x64
ArchitecturesInstallIn64BitMode=x64
DisableProgramGroupPage=true
DisableDirPage=false
DisableReadyPage=false
LanguageDetectionMethod=locale
TimeStampsInUTC=false
PrivilegesRequired=lowest
WizardImageStretch=false
WizardImageBackColor=clWhite
; ChangesAssociations=true
AppendDefaultDirName=false
DefaultDirName={code:SuggestInstallDir}
CreateAppDir=true
CloseApplicationsFilter=*.*
DefaultDialogFontName=Segoe UI
; Uninstall
;UninstallDisplayIcon={#UNINSTALLDIR}\xltoolbox.ico
UninstallFilesDir={#UNINSTALLDIR}
; Inno Downloader Plugin is required for this
; Note that this include directive MUST be located at the end of the [setup]
; section.
#include <idp.iss>
[Languages]
Name: en; MessagesFile: compiler:Default.isl;
Name: de; MessagesFile: compiler:Languages\German.isl;
; Name: Brasileiro; MessagesFile: compiler:Languages\BrazilianPortuguese.isl;
; Name: Portugues; MessagesFile: compiler:Languages\Portuguese.isl;
#include "c:\Program Files (x86)\Inno Download Plugin\Unicode\idplang\german.iss"
[Files]
Source: "..\zaaReloaded2\bin\{#SOURCEDIR}\*"; DestDir: "{app}"; Flags: ignoreversion createallsubdirs recursesubdirs
; Source: "setup-files\xltoolbox.ico"; DestDir: "{#UNINSTALLDIR}"
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Registry]
; Keys for single-user install (HKCU)
Check: not IsMultiUserInstall; ValueName: Description; ValueData: {#SLOGAN}; ValueType: string; Root: HKCU; Subkey: {#REGKEY}; Flags: uninsdeletekey
Check: not IsMultiUserInstall; ValueName: FriendlyName; ValueData: {#APPNAME}; ValueType: string; Root: HKCU; Subkey: {#REGKEY}; Flags: uninsdeletekey
Check: not IsMultiUserInstall; ValueName: LoadBehavior; ValueData: 3; ValueType: dword; Root: HKCU; Subkey: {#REGKEY}; Flags: uninsdeletekey
Check: not IsMultiUserInstall; ValueName: Warmup; ValueData: 1; ValueType: dword; Root: HKCU; Subkey: {#REGKEY}; Flags: uninsdeletekey
Check: not IsMultiUserInstall; ValueName: Manifest; ValueData: file:///{code:ConvertSlash|{app}}/{#ADDINNAME}.vsto|vstolocal; ValueType: string; Root: HKCU; Subkey: {#REGKEY}; Flags: uninsdeletekey
; Same keys again, this time for multi-user install (HKLM)
Check: IsMultiUserInstall; ValueName: Description; ValueData: {#SLOGAN}; ValueType: string; Root: HKLM; Subkey: {#REGKEY}; Flags: uninsdeletekey
Check: IsMultiUserInstall; ValueName: FriendlyName; ValueData: {#APPNAME}; ValueType: string; Root: HKLM; Subkey: {#REGKEY}; Flags: uninsdeletekey
Check: IsMultiUserInstall; ValueName: LoadBehavior; ValueData: 3; ValueType: dword; Root: HKLM; Subkey: {#REGKEY}; Flags: uninsdeletekey
Check: IsMultiUserInstall; ValueName: Warmup; ValueData: 1; ValueType: dword; Root: HKLM; Subkey: {#REGKEY}; Flags: uninsdeletekey
Check: IsMultiUserInstall; ValueName: Manifest; ValueData: file:///{code:ConvertSlash|{app}}/{#ADDINNAME}.vsto|vstolocal; ValueType: string; Root: HKLM; Subkey: {#REGKEY}; Flags: uninsdeletekey
[Run]
; Filename: http://xltoolbox.sourceforge.net/welcome.html; Flags: shellexec nowait; Check: ShowWelcomePageInBrowser
[UninstallRun]
; Filename: http://xltoolbox.sourceforge.net/uninstall.html; Flags: shellexec nowait
[CustomMessages]
; General messages [EN]
en.SingleOrMulti=Single-user or system-wide install
en.SingleOrMultiSubcaption=Install for the current user only or for all users
en.SingleOrMultiDesc=Please indicate the scope of this installation:
en.SingleOrMultiSingle=Single user (only for me)
en.SingleOrMultiAll=All users (system-wide)
en.Word2007Required=zaaReloaded requires Word 2007 or later.
; CannotInstallPage [EN]
en.CannotInstallCaption=Administrator privileges required
en.CannotInstallDesc=You do not have the necessary rights to install additional required runtime files.
en.CannotInstallMsg=Additional runtime files from Microsoft are required to run this add-in. You may continue the installation, but the add-in won't start unless the required runtime files are installed by an administrator. Note: On Windows Vista and newer, right-click the installer file and choose 'Run as administrator'.
en.CannotInstallCont=Continue anyway, although it won't work without the required runtime files
en.CannotInstallAbort=Abort the installation (come back when the admin has installed the files)
; DownloadInfoPage [EN]
en.RequiredCaption=Additional runtime files required
en.RequiredDesc=Additional runtime files for the .NET framework from Microsoft are required in order to run the add-in.
en.RequiredMsg=%d file(s) totalling about %s MiB need to be downloaded from the Microsoft servers. Click 'Next' to start downloading.
; InstallInfoPage [EN]
en.InstallCaption=Runtime files downloaded
en.InstallDesc=The required runtime files are ready to install.
en.InstallMsg=Click 'Next' to beginn the installation.
en.StillNotInstalled=The required additional runtime files are still not installed. Setup cannot continue. You may try again, or abort the add-in installation.
en.DownloadNotValidated=A downloaded file has unexpected content. It may have not been downloaded correctly, or someone might have hampered with it. You may click 'Back' and then 'Next' to download it again.
; General messages [DE]
de.SingleOrMulti=Einzelner oder alle Benutzer
de.SingleOrMultiSubcaption=Geben Sie an, f<>r wen die Installation sein soll
de.SingleOrMultiDesc=Bitte geben Sie an, ob das Addin nur f<>r Sie oder f<>r alle Benutzer installiert werden soll.
de.SingleOrMultiSingle=Ein Benutzer (nur f<>r mich)
de.SingleOrMultiAll=Alle Benutzer (systemweit)
de.Word2007Required=Dieses Addin erfordert mindestens Word 2007.
; "Download required" messages (.NET and VSTOR runtimes) [DE]
de.CannotInstallCaption=Administratorrechte ben<65>tigt
de.CannotInstallDesc=Sie haben nicht die erforderlichen Benutzerrechte, um weitere ben<65>tigte Laufzeitdateien zu installieren.
de.CannotInstallMsg=Sie k<>nnen mit der Installation fortfahren, aber das Addin wird nicht starten, solange die VSTO-Laufzeitdateien nicht von einem Admin installiert wurden. Tipp: Wenn Sie Windows Vista oder neuer verwenden, klicken Sie mit der rechten Maustaste auf die Installationsdatei und w<>hlen "Als Administrator ausf<73>hren".
de.CannotInstallCont=Trotzdem installieren, obwohl es nicht funktionieren wird
de.CannotInstallAbort=Installation abbrechen
; DownloadInfoPage [EN]
de.RequiredCaption=Weitere Laufzeitdateien erforderlich
de.RequiredDesc=Weitere Laufzeitdateien f<>r das .NET-Framework von Microsoft werden ben<65>tigt, um das Addin verwenden zu k<>nnen.
de.RequiredMsg=%d Datei(en) mit ca. %s MiB mu<6D>/m<>ssen von den Microsoft-Servern heruntergeladen werden. Klicken Sie 'Weiter', um den Download zu beginnen.
; InstallInfoPage [EN]
de.InstallCaption=Weitere .NET-Laufzeitdateien heruntergeladen
de.InstallDesc=Die zus<75>tzlichen ben<65>tigten Dateien von Microsoft k<>nnen jetzt installiert werden.
de.InstallMsg=Klicken Sie 'Weiter', um mit der Installation zu beginnen.
de.StillNotInstalled=Die zus<75>tzlichen ben<65>tigten Dateien wurden leider nicht korrekt installiert, so da<64> die Installation nicht fortgesetzt werden kann.
de.DownloadNotValidated=Es wurde unerwarteter Inhalt in einer heruntergeladenen Datei gefunden. Die Installation kann so nicht fortgesetzt werden. Sie k<>nnen aber 'Zur<75>ck' und dann 'Weiter' klicken, um den Download neu zu beginnen.
[Code]
const
maxWord = 24; //< highest Word version number to check for.
var
PageDevelopmentInfo: TInputOptionWizardPage;
PageSingleOrMultiUser: TInputOptionWizardPage;
PageCannotInstall: TInputOptionWizardPage;
PageDownloadInfo: TOutputMsgWizardPage;
PageInstallInfo: TOutputMsgWizardPage;
prerequisitesChecked: boolean;
prerequisitesMet: boolean;
/// Returns the path for the Wow6432Node registry tree if the current operating
/// system is 64-bit, i.e., simulates WOW64 redirection.
function GetWowNode(): string;
begin
if IsWin64 then
begin
result := 'Wow6432Node\';
end
else
begin
result := '';
end;
end;
/// Checks if a given Word version is installed
function IsWordVersionInstalled(version: integer): boolean;
var key: string;
var lookup1, lookup2: boolean;
begin
key := 'Microsoft\Office\' + IntToStr(version) + '.0\Word\InstallRoot';
lookup1 := RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\' + GetWowNode + key);
// If checking for version >= 14.0 ("2010"), which was the first version
// that was produced in both 32-bit and 64-bit, on a 64-bit system we
// also need to check a path without 'Wow6434Node'.
if IsWin64 and (version >= 14) then
begin
lookup2 := RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\' + key);
end;
result := lookup1 or lookup2;
end;
/// Checks if only Word 2007 is installed
function IsOnlyWord2007Installed(): boolean;
var
i: integer;
begin
result := IsWordVersionInstalled(12);
// Iterate through all
for i := 14 to maxWord do
begin
if IsWordVersionInstalled(i) then
begin
result := false;
break;
end;
end;
end;
/// Checks if hotfix KB976477 is installed. This hotfix
/// is required to make Word 2007 recognize add-ins in
/// the HKLM hive as well.
function IsHotfixInstalled(): boolean;
begin
result := RegKeyExists(HKEY_LOCAL_MACHINE,
'SOFTWARE\Microsoft\Windows\Current Version\Uninstall\KB976477');
end;
/// Retrieves the build number of an installed Office version
/// in OutBuild. Returns true if the requested Office version
/// is installed and false if it is not installed.
function GetOfficeBuild(OfficeVersion: integer; var OutBuild: integer): boolean;
var
key: string;
value: string;
build: string;
begin
key := 'SOFTWARE\' + GetWowNode + 'Microsoft\Office\' +
IntToStr(OfficeVersion) + '.0\Common\ProductVersion';
if RegQueryStringValue(HKEY_LOCAL_MACHINE, key, 'LastProduct', value) then
begin
// Office build numbers always have 4 digits, at least as of Feb. 2015;
// from a string '14.0.1234.5000' simply copy 4 characters from the 5th
// position to get the build number. TODO: Make this future-proof.
build := Copy(value, 6, 4);
Log('Found ProductVersion "' + value + '" for queried Office version '
+ IntToStr(OfficeVersion) + ', extracted build number ' + build);
OutBuild := StrToInt(build);
result := true;
end
else
Log('Did not find LastProduct key for Office version ' +
IntToStr(OfficeVersion) + '.0.');
end;
/// Asserts if Office 2007 is installed. Does not check whether other Office
/// versions are concurrently installed.
function IsOffice2007Installed(): boolean;
begin
result := IsWordVersionInstalled(12);
if result then Log('Detected Office 2007.');
end;
/// Asserts if Office 2010 without service pack is installed.
/// For build number, see http://support.microsoft.com/kb/2121559/en-us
function IsOffice2010NoSpInstalled(): boolean;
var
build: integer;
begin
if GetOfficeBuild(14, build) then
begin
result := build = 4763; // 4763 is the original Office 2007 build
if result then
Log('Detected Office 2010 without service pack (v. 14.0, build 4763)')
else
Log('Detected Office 2010, apparently with some service pack (build ' +
IntToStr(build) + ').');
end;
end;
/// Checks if the VSTO runtime is installed. This is relevant if only
/// Word 2007 is installed. Since Office 2010, the CLR is
/// automatically included.
/// The presence of the VSTO runtime is indicated by the presence one of
/// four possible registry keys.
/// See: http://xltoolbox.sf.net/blog/2015/01/net-vsto-add-ins-getting-prerequisites-right
/// HKLM\SOFTWARE\Microsoft\VSTO Runtime Setup\v4R (32-bit)
/// HKLM\SOFTWARE\Wow6432Node\Microsoft\VSTO Runtime Setup\v4R (64-bit)
function IsVstorInstalled(): boolean;
var
software, vstorPath: string;
begin
software := 'SOFTWARE\';
vstorPath := 'Microsoft\VSTO Runtime Setup\v4R';
result := RegKeyExists(HKEY_LOCAL_MACHINE, software + GetWowNode + vstorPath);
end;
/// Checks if the .NET 4.0 (or 4.5) runtime is installed.
/// See https://msdn.microsoft.com/en-us/library/hh925568
function IsNetInstalled(): boolean;
begin
result := RegKeyExists(HKEY_LOCAL_MACHINE,
'SOFTWARE\' + GetWowNode + 'Microsoft\NET Framework Setup\NDP\v4');
end;
/// Asserts if the VSTO runtime for .NET 4.0 redistributable needs to be
/// downloaded and installed.
/// If Office 2010 SP 1 or newer is installed on the system, the VSTOR runtime
/// will be automagically configured as long as the .NET 4.0 runtime is present.
/// Office 2007 and Office 2010 without service pack need the VSTO runtime
/// redistributable. For details, see:
/// http://xltoolbox.sf.net/blog/2015/01/net-vsto-add-ins-getting-prerequisites-right
function NeedToInstallVstor(): boolean;
begin
result := false; // Default for Office 2010 SP1 or newer
if IsOffice2007Installed or IsOffice2010NoSpInstalled then
result := not IsVstorInstalled;
end;
/// Checks if all required prerequisites are met, i.e. if the necessary
/// runtimes are installed on the system
function PrerequisitesAreMet(): boolean;
begin
// Cache check result to avoid multiple registry lookups and log messages
if not prerequisitesChecked then
begin
prerequisitesMet := IsNetInstalled and not NeedToInstallVstor;
prerequisitesChecked := true;
end;
result := prerequisitesMet;
end;
/// Checks if a file exists and has a valid Sha1 sum.
function IsFileValid(file: string; expectedSha1: string): boolean;
var
actualSha1: string;
begin
try
if FileExists(file) then
begin
actualSha1 := GetSHA1OfFile(file);
end;
finally
result := actualSha1 = expectedSha1;
end;
end;
/// Returns the path to the downloaded VSTO runtime installer.
function GetVstorInstallerPath(): string;
begin
result := ExpandConstant('{%temp}\vstor_redist_40.exe');
end;
/// Returns the path to the downloaded .NET runtime installer.
function GetNetInstallerPath(): string;
begin
result := ExpandConstant('{%temp}\dotNetFx40_Full_x86_x64.exe');
end;
/// Checks if the VSTO runtime redistributable setup file has already been
/// downloaded by comparing SHA1 checksums.
function IsVstorDownloaded(): boolean;
begin
result := IsFileValid(GetVstorInstallerPath, '{#VSTORSHA1}');
end;
/// Checks if the .NET runtime setup file has already been
/// downloaded by comparing SHA1 checksums.
function IsNetDownloaded(): boolean;
begin
result := IsFileValid(GetNetInstallerPath, '{#DOTNETSHA1}');
end;
/// Determines if the VSTO runtime needs to be downloaded.
/// This is not the case it the runtime is already installed,
/// or if there is a file with a valid Sha1 sum.
function NeedToDownloadVstor: boolean;
begin
result := NeedToInstallVstor and not IsVstorDownloaded;
end;
/// Determines if the VSTO runtime needs to be downloaded.
/// This is not the case it the runtime is already installed,
/// or if there is a file with a valid Sha1 sum.
function NeedToDownloadNet: boolean;
begin
result := not IsNetInstalled and not IsNetDownloaded;
end;
/// Determines whether or not a system-wide installation
/// is possible. This depends on whether the current user
/// is an administrator, and whether the hotfix KB976477
/// is present on the system if Word 2007 is the only version
/// of Word that is present (without that hotfix, Word
/// 2007 does not load add-ins that are registered in the
/// HKLM hive).
function CanInstallSystemWide(): boolean;
begin
if IsAdminLoggedOn then
begin
if IsOnlyWord2007Installed then
begin
result := IsHotfixInstalled;
end
else
begin
result := true;
end;
end
else
begin
result := false;
end;
end;
procedure CreateSingleOrAllUserPage();
begin
PageSingleOrMultiUser := CreateInputOptionPage(wpLicense,
CustomMessage('SingleOrMulti'), CustomMessage('SingleOrMultiSubcaption'),
CustomMessage('SingleOrMultiDesc'), True, False);
PageSingleOrMultiUser.Add(CustomMessage('SingleOrMultiSingle'));
PageSingleOrMultiUser.Add(CustomMessage('SingleOrMultiAll'));
if CanInstallSystemWide then
begin
PageSingleOrMultiUser.Values[1] := True;
end
else
begin
PageSingleOrMultiUser.Values[0] := True;
end;
end;
procedure CreateCannotInstallPage();
begin
PageCannotInstall := CreateInputOptionPage(wpWelcome,
CustomMessage('CannotInstallCaption'),
CustomMessage('CannotInstallDesc'),
CustomMessage('CannotInstallMsg'), True, False);
PageCannotInstall.Add(CustomMessage('CannotInstallCont'));
PageCannotInstall.Add(CustomMessage('CannotInstallAbort'));
PageCannotInstall.Values[1] := True;
end;
procedure CreateDownloadInfoPage();
var
bytes: Int64;
mib: Single;
size: String;
begin
if idpGetFilesSize(bytes) then
begin
mib := bytes / 1048576;
size := Format('%.1f', [ mib ]);
end
else
begin
size := '[?]'
end;
PageDownloadInfo := CreateOutputMsgPage(PageSingleOrMultiUser.Id,
CustomMessage('RequiredCaption'),
CustomMessage('RequiredDesc'),
Format(CustomMessage('RequiredMsg'), [idpFilesCount, size]));
end;
procedure CreateInstallInfoPage();
begin
PageInstallInfo := CreateOutputMsgPage(PageDownloadInfo.Id,
CustomMessage('InstallCaption'),
CustomMessage('InstallDesc'),
CustomMessage('InstallMsg'));
end;
function InitializeSetup(): boolean;
var
minWordInstalled: boolean;
i: integer;
begin
// Determine if Word 2007 or newer is installed (absolute requirement
// for this VSTO add-in). Word 2007 ist version 12.0.
for i := 12 to maxWord do
begin
minWordInstalled := minWordInstalled or IsWordVersionInstalled(i);
end;
if not minWordInstalled then
begin
result := False;
Log('Informing user that Word 2007 or newer is required.');
MsgBox(CustomMessage('Word2007Required'), mbInformation, MB_OK);
end
else
begin
result := True;
end
end;
procedure InitializeWizard();
begin
// CreateDevelopmentInfoPage;
CreateSingleOrAllUserPage;
if not PrerequisitesAreMet then
begin
Log('Not all prerequisites are met...');
CreateCannotInstallPage;
if NeedToDownloadNet then
begin
Log('Mark {#DOTNETURL} for download.');
idpAddFileSize('{#DOTNETURL}', GetNetInstallerPath, 50449456);
end;
if NeedToDownloadVstor then
begin
Log('Mark {#VSTORURL} for download.');
idpAddFileSize('{#VSTORURL}', GetVstorInstallerPath, 40123576);
end;
CreateDownloadInfoPage;
CreateInstallInfoPage;
idpDownloadAfter(PageDownloadInfo.Id);
end;
end;
function ExecuteNetSetup(): boolean;
var
exitCode: integer;
begin
result := true;
if not IsNetInstalled then
begin
if IsNetDownloaded then
begin
Log('Valid .NET runtime download found, installing.');
Exec(GetNetInstallerPath, '/norestart',
'', SW_SHOW, ewWaitUntilTerminated, exitCode);
BringToFrontAndRestore;
if not IsNetInstalled then
begin
MsgBox(CustomMessage('StillNotInstalled'), mbInformation, MB_OK);
result := False;
end;
end
else
begin
Log('No or invalid .NET runtime download found, will not install.');
MsgBox(CustomMessage('DownloadNotValidated'), mbInformation, MB_OK);
result := False;
end;
end; // not IsNetInstalled
end;
function ExecuteVstorSetup(): boolean;
var
exitCode: integer;
begin
result := true;
if NeedToInstallVstor then
begin
if IsVstorDownloaded then
begin
Log('Valid VSTO runtime download found, installing.');
Exec(GetVstorInstallerPath, '/norestart', '', SW_SHOW,
ewWaitUntilTerminated, exitCode);
BringToFrontAndRestore;
if not IsVstorInstalled then
begin
MsgBox(CustomMessage('StillNotInstalled'), mbInformation, MB_OK);
result := False;
end;
end
else
begin
Log('No or invalid VSTO runtime download found, will not install.');
MsgBox(CustomMessage('DownloadNotValidated'), mbInformation, MB_OK);
result := False;
end;
end; // not IsVstorInstalled
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
result := True;
{
if not WizardSilent then
begin
if CurPageID = PageDevelopmentInfo.Id then
begin
if PageDevelopmentInfo.Values[0] = False then
begin
Log('Requesting user to acknowledge use of a developmental version.');
MsgBox(CustomMessage('DevVerMsgBox'), mbInformation, MB_OK);
result := False;
end;
end;
end;
}
if not PrerequisitesAreMet then
begin
// Abort the installation if any of the runtimes are missing, the user
// is not an administrator, and requested to abort the installation.
if CurPageID = PageCannotInstall.ID then
begin
if PageCannotInstall.Values[1] = true then
begin
WizardForm.Close;
result := False;
end
else
begin
Log('Non-admin user continues although not all required runtimes are installed.');
end;
end;
if CurPageID = PageInstallInfo.ID then
begin
// Return true if installation succeeds (or no installation required)
result := ExecuteNetSetup and ExecuteVstorSetup;
end;
end; // not PrerequisitesAreMet
end;
/// Skips the folder selection, single/multi user, and ready pages for
/// normal users without power privileges.
/// This function also takes care of dynamically determining what wizard
/// pages to install, depending on the current system setup and whether
/// the current user is an administrator.
function ShouldSkipPage(PageID: Integer): Boolean;
begin
result := False;
if not PrerequisitesAreMet then
begin
// The PageDownloadCannotInstall will only have been initialized if
// PrerequisitesAreMet returned false.
if PageID = PageCannotInstall.ID then
begin
// Skip the warning if the user is an admin.
result := IsAdminLoggedOn
if not result then
begin
Log('Warning user that required runtimes cannot be installed due to missing privileges');
end;
end;
if PageID = PageDownloadInfo.ID then
begin
// Skip page informing about downloads if no files need to be downloaded.
result := idpFilesCount = 0;
end;
if PageID = IDPForm.Page.ID then
begin
// Skip downloader plugin if there are no files to download.
result := idpFilesCount = 0;
if not result then
begin
Log('Beginning download of ' + IntToStr(idpFilesCount) + ' file(s).');
end;
end;
end; // not PrerequisitesAreMet
if PageID = PageSingleOrMultiUser.ID then
begin
if IsOnlyWord2007Installed then
begin
Log('Only Word 2007 appears to be installed on this system.');
if IsHotfixInstalled then
begin
Log('Hotfix KB976477 found; can install for all users.');
end
else
begin
Log('Hotfix KB976477 not found; cannot install for all users.');
end;
end
else
begin
Log('Word 2010 or newer found on this system.');
end;
if CanInstallSystemWide then
begin
Log('Offer installation for all users.');
result := False;
end
else
begin
Log('Offer single-user installation only.');
result := True;
end;
end;
if (PageID = wpSelectDir) or (PageID = wpReady) then
begin
// Do not show the pages to select the target directory, and the ready
// page if the user is not an admin.
result := not IsAdminLoggedOn;
end
end;
/// Helper function that evaluates the custom PageSingleOrMultiUser page.
function IsMultiUserInstall(): Boolean;
begin
result := PageSingleOrMultiUser.Values[1];
end;
/// Suggest an initial target directory depending on whether
/// the installer is run with admin privileges.
function SuggestInstallDir(Param: string): string;
var
dir: string;
begin
if CanInstallSystemWide then
begin
dir := ExpandConstant('{pf}');
end
else
begin
dir := ExpandConstant('{userappdata}');
end;
result := AddBackslash(dir) + 'zaaReloaded';
end;
/// Converts backslashes to forward slashes.
function ConvertSlash(Value: string): string;
begin
StringChangeEx(Value, '\', '/', True);
Result := Value;
end;

View File

@ -368,7 +368,7 @@
<footer class="footer"> <footer class="footer">
<p> <p>
&copy; 2015 <a href="http://www.bovender.de">Daniel Kraus</a> &copy; 2015-2016 <a href="http://www.bovender.de">Daniel Kraus</a>
<span class="pull-right"> <span class="pull-right">
Handarbeit mit Handarbeit mit
<a href="http://www.vim.org"> <a href="http://www.vim.org">

View File

@ -1,4 +1,4 @@
2.1.12 2.2.3
http://zaa.nephrowiki.de/downloads/zaaReloaded-$VERSION.exe http://zaa.nephrowiki.de/downloads/zaaReloaded-$VERSION.exe
b6e80b12e7325a9e0fcc0ad75bd1deaf5f6fe966 publish/release/zaaReloaded-2.1.12.exe 077df8d43cf97ef4082cda988393734a825b51cf0e023527cdc5752502c83f03 deploy/releases/zaaReloaded-2.2.3.exe

View File

@ -138,6 +138,47 @@ namespace zaaReloaded2
Globals.ThisAddIn.Application.Selection); Globals.ThisAddIn.Application.Selection);
} }
public static void FormatDrugs(int columns)
{
if (columns < 1 || columns > 2)
{
throw new ArgumentOutOfRangeException("Can only format 1 or 2 columns, not " + columns);
}
// If no "real" selection exists, attempt to auto-detect the drugs section.
// (NB Technically, there is never _no_ selection in a document.)
Word.Window activeWindow = Globals.ThisAddIn.Application.ActiveWindow;
Word.Selection sel = activeWindow.Selection;
if (!(sel.Paragraphs.Count > 1
|| (sel.Text.Length > 1 && sel.Text.EndsWith("\r"))))
{
if (!Medication.Importer.AutoDetect(activeWindow.Document))
{
NotificationAction a = new NotificationAction();
a.Caption = "Formatieren nicht möglich";
a.Message = "Das Dokument scheint keine Medikationsliste zu enthalten.";
a.OkButtonLabel = "Schließen";
a.Invoke();
return;
}
}
Medication.Importer importer = new Medication.Importer(activeWindow.Selection.Text);
Medication.Formatter formatter = new Medication.Formatter(importer.Prescriptions);
switch (columns)
{
case 1:
formatter.FormatOneColumn(activeWindow.Document);
break;
case 2:
formatter.FormatTwoColumns(activeWindow.Document);
break;
default:
break;
}
}
#endregion #endregion
#region Private methods #region Private methods

View File

@ -3,17 +3,17 @@
<a1:Settings id="ref-1" xmlns:a1="http://schemas.microsoft.com/clr/nsassem/zaaReloaded2.Controller/zaaReloaded2%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D6ec8d075a1ab1383"> <a1:Settings id="ref-1" xmlns:a1="http://schemas.microsoft.com/clr/nsassem/zaaReloaded2.Controller/zaaReloaded2%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D6ec8d075a1ab1383">
<Version>2</Version> <Version>2</Version>
<Uid xsi:type="a2:Guid" xmlns:a2="http://schemas.microsoft.com/clr/ns/System"> <Uid xsi:type="a2:Guid" xmlns:a2="http://schemas.microsoft.com/clr/ns/System">
<_a>975892959</_a> <_a>-903942278</_a>
<_b>1621</_b> <_b>-22298</_b>
<_c>18089</_c> <_c>17811</_c>
<_d>190</_d> <_d>139</_d>
<_e>209</_e> <_e>190</_e>
<_f>136</_f> <_f>233</_f>
<_g>9</_g> <_g>83</_g>
<_h>91</_h> <_h>158</_h>
<_i>189</_i> <_i>73</_i>
<_j>67</_j> <_j>21</_j>
<_k>208</_k> <_k>115</_k>
</Uid> </Uid>
<Name id="ref-3">Kopie von Standard für NepA</Name> <Name id="ref-3">Kopie von Standard für NepA</Name>
<ReferenceStyle xsi:type="a3:ReferenceStyle" xmlns:a3="http://schemas.microsoft.com/clr/nsassem/zaaReloaded2.Formatter/zaaReloaded2%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D6ec8d075a1ab1383">IfSpecialItem</ReferenceStyle> <ReferenceStyle xsi:type="a3:ReferenceStyle" xmlns:a3="http://schemas.microsoft.com/clr/nsassem/zaaReloaded2.Formatter/zaaReloaded2%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D6ec8d075a1ab1383">IfSpecialItem</ReferenceStyle>
@ -102,11 +102,11 @@
</a4:Items> </a4:Items>
<a4:Items id="ref-14" xmlns:a4="http://schemas.microsoft.com/clr/nsassem/zaaReloaded2.Controller.Elements/zaaReloaded2%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D6ec8d075a1ab1383"> <a4:Items id="ref-14" xmlns:a4="http://schemas.microsoft.com/clr/nsassem/zaaReloaded2.Controller.Elements/zaaReloaded2%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D6ec8d075a1ab1383">
<Version>2</Version> <Version>2</Version>
<Content id="ref-38">Spot-Urin: U-TPCR, U-ACR, U-Alb, U-Ery, U-Leu, U-Bakt</Content> <Content id="ref-38">Spot-Urin: U-TPCR, U-ACR, U-Alb, U-Ery, U-Leu, U-Bakt, U-Schwangerschaftstest</Content>
</a4:Items> </a4:Items>
<a4:Items id="ref-15" xmlns:a4="http://schemas.microsoft.com/clr/nsassem/zaaReloaded2.Controller.Elements/zaaReloaded2%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D6ec8d075a1ab1383"> <a4:Items id="ref-15" xmlns:a4="http://schemas.microsoft.com/clr/nsassem/zaaReloaded2.Controller.Elements/zaaReloaded2%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D6ec8d075a1ab1383">
<Version>2</Version> <Version>2</Version>
<Content id="ref-39">Leber: GOT, GGT, GPT, AP, Bilirubin, CHE</Content> <Content id="ref-39">Leber: GOT, GGT, GPT, AP, Bilirubin, CHE, CDT</Content>
</a4:Items> </a4:Items>
<a4:Items id="ref-16" xmlns:a4="http://schemas.microsoft.com/clr/nsassem/zaaReloaded2.Controller.Elements/zaaReloaded2%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D6ec8d075a1ab1383"> <a4:Items id="ref-16" xmlns:a4="http://schemas.microsoft.com/clr/nsassem/zaaReloaded2.Controller.Elements/zaaReloaded2%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D6ec8d075a1ab1383">
<Version>2</Version> <Version>2</Version>
@ -130,7 +130,7 @@
</a4:Items> </a4:Items>
<a4:Items id="ref-21" xmlns:a4="http://schemas.microsoft.com/clr/nsassem/zaaReloaded2.Controller.Elements/zaaReloaded2%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D6ec8d075a1ab1383"> <a4:Items id="ref-21" xmlns:a4="http://schemas.microsoft.com/clr/nsassem/zaaReloaded2.Controller.Elements/zaaReloaded2%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D6ec8d075a1ab1383">
<Version>2</Version> <Version>2</Version>
<Content id="ref-45">Hormone: iPTH, TSH, fT3, fT4</Content> <Content id="ref-45">Hormone: iPTH, TSH, fT3, fT4, Aldosteron, Renin, ARQ</Content>
</a4:Items> </a4:Items>
<a4:Items id="ref-22" xmlns:a4="http://schemas.microsoft.com/clr/nsassem/zaaReloaded2.Controller.Elements/zaaReloaded2%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D6ec8d075a1ab1383"> <a4:Items id="ref-22" xmlns:a4="http://schemas.microsoft.com/clr/nsassem/zaaReloaded2.Controller.Elements/zaaReloaded2%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D6ec8d075a1ab1383">
<Version>2</Version> <Version>2</Version>
@ -171,7 +171,7 @@
</a4:CustomText> </a4:CustomText>
<a4:CustomText id="ref-31" xmlns:a4="http://schemas.microsoft.com/clr/nsassem/zaaReloaded2.Controller.Elements/zaaReloaded2%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D6ec8d075a1ab1383"> <a4:CustomText id="ref-31" xmlns:a4="http://schemas.microsoft.com/clr/nsassem/zaaReloaded2.Controller.Elements/zaaReloaded2%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D6ec8d075a1ab1383">
<Version>2</Version> <Version>2</Version>
<Content id="ref-55">Autoantikörper: ANCA (IF), MPO-ANCA (ELISA), PR3-ANCA (ELISA), ANA (IF), AnDNA (ELISA), AnDNA (RIA)</Content> <Content id="ref-55">Autoantikörper: ANCA (IF) 1: (Ref. &#60; 1:40), MPO-ANCA (ELISA) IU/ml (Ref. &#60; 9), PR3-ANCA (ELISA) IU/ml (Ref. &#60; 3,5), ANA (IF), AnDNA (ELISA), AnDNA (RIA)</Content>
</a4:CustomText> </a4:CustomText>
</SOAP-ENV:Body> </SOAP-ENV:Body>
</SOAP-ENV:Envelope> </SOAP-ENV:Envelope>

View File

@ -10,6 +10,8 @@ Albumin Alb S
"Albumin (SU)/die" Alb SU "Albumin (SU)/die" Alb SU
"Albumin - Fraktion" Albumin-Fraktion S --- X "Albumin - Fraktion" Albumin-Fraktion S --- X
"Albumin/Creatinin (PU)" ACR U 0 "Albumin/Creatinin (PU)" ACR U 0
Aldosteron Aldosteron S --- X
Aldosteron-Renin-Quotient ARQ S --- X
"Alk. Phosphatase" AP S 0 "Alk. Phosphatase" AP S 0
"Alpha1-Globulin - Fraktion" a1-Globulin S --- X "Alpha1-Globulin - Fraktion" a1-Globulin S --- X
"Alpha2-Globulin - Fraktion" a2-Globulin S --- X "Alpha2-Globulin - Fraktion" a2-Globulin S --- X
@ -79,6 +81,7 @@ Kalium K S
"Kalium (SU)" K U "Kalium (SU)" K U
"Kalium (SU)/die" K SU "Kalium (SU)/die" K SU
"Ketonkörper (U)" KK U "Ketonkörper (U)" KK U
"kohlenhyd. def. Transferrin" CDT S 1 X
"Komplementfaktor C3c" C3c S --- X "Komplementfaktor C3c" C3c S --- X
"Komplementfaktor C4" C4 S --- X "Komplementfaktor C4" C4 S --- X
"Lactat Dehydrogenase" LDH S "Lactat Dehydrogenase" LDH S
@ -110,10 +113,12 @@ pH pH BGA
"PTH intakt" iPTH S "PTH intakt" iPTH S
PTT PTT Z PTT PTT Z
"Ratio int. norm." INR Z "Ratio int. norm." INR Z
Plasma-Renin-Konzentration Renin S --- X
Retikulozyten Retikulozyten E --- X Retikulozyten Retikulozyten E --- X
"Sammelmenge (U)" Volumen SU "Sammelmenge (U)" Volumen SU
"Sammelzeit (U)" Zeit SU "Sammelzeit (U)" Zeit SU
"Sauerstoffsättigung (art.)" SO2 BGA "Sauerstoffsättigung (art.)" SO2 BGA
"Schwangerschaftstest (U)" Schwangerschaftstest U
Sirolimus SIR S Sirolimus SIR S
"spezifisches Gewicht (U)" "spez. Gew." U "spezifisches Gewicht (U)" "spez. Gew." U
"Standard Bicarbonat" "Std.-Bic." BGA "Standard Bicarbonat" "Std.-Bic." BGA

Binary file not shown.

View File

@ -171,6 +171,14 @@ namespace zaaReloaded2.Formatter
_buffer.AppendLine(text); _buffer.AppendLine(text);
} }
/// <summary>
/// Appends a newline to the buffer.
/// </summary>
public void WriteLine()
{
_buffer.AppendLine();
}
/// <summary> /// <summary>
/// Inserts text at the start of the buffer. /// Inserts text at the start of the buffer.
/// </summary> /// </summary>

View File

@ -142,13 +142,7 @@ namespace zaaReloaded2.Formatter
// Create undo record and styles prior to iterating over the elements // Create undo record and styles prior to iterating over the elements
// because a column switching element might trigger output to the // because a column switching element might trigger output to the
// document. // document.
bool hasAddin = Globals.ThisAddIn != null; Helpers.StartUndo("Laborformatierung");
if (hasAddin)
{
Globals.ThisAddIn.Application.UndoRecord.StartCustomRecord(
String.Format("Laborformatierung ({0})", Properties.Settings.Default.AddinName)
);
}
CreateStyles(); CreateStyles();
int current = 0; int current = 0;
@ -177,10 +171,7 @@ namespace zaaReloaded2.Formatter
} }
_secondaryBuffer.Flush(); _secondaryBuffer.Flush();
if (hasAddin) Helpers.EndUndo();
{
Globals.ThisAddIn.Application.UndoRecord.EndCustomRecord();
}
} }
/// <summary> /// <summary>

69
zaaReloaded2/Helpers.cs Executable file
View File

@ -0,0 +1,69 @@
/* Helpers.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;
namespace zaaReloaded2
{
/// <summary>
/// Common helper methods.
/// </summary>
public static class Helpers
{
/// <summary>
/// Splits a text into paragraphs.
/// </summary>
/// <param name="paragraph">Text to split.</param>
/// <returns>Array of paragraphs in the text.</returns>
/// <remarks>
/// This implementation relies on the fact that the order of
/// splitting strings in C#'s String.Split() method is
/// important; see http://stackoverflow.com/a/8664639/270712
/// </remarks>
public static string[] SplitParagraphs(string text)
{
return text.Split(
new string[] { "\r\n", "\n\r", "\r", "\n" },
StringSplitOptions.RemoveEmptyEntries);
}
/// <summary>
/// Starts a custom undo record.
/// </summary>
/// <param name="message"></param>
public static void StartUndo(string message)
{
if (Globals.ThisAddIn != null)
{
Globals.ThisAddIn.Application.UndoRecord.StartCustomRecord(
String.Format("{0} ({1})", message, Properties.Settings.Default.AddinName)
);
}
}
/// <summary>
/// Ends an undo record.
/// </summary>
public static void EndUndo()
{
if (Globals.ThisAddIn != null)
{
Globals.ThisAddIn.Application.UndoRecord.EndCustomRecord();
}
}
}
}

BIN
zaaReloaded2/Icons/m.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 778 B

BIN
zaaReloaded2/Icons/mm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 723 B

View File

@ -67,12 +67,7 @@ namespace zaaReloaded2.Importer.ZaaImporter
/// <param name="text">ZAA-formatted Lauris output to import.</param> /// <param name="text">ZAA-formatted Lauris output to import.</param>
public void Import(string text) public void Import(string text)
{ {
// Split the text into parargraphs. This implementation relies on the fact string[] paragraphs = Helpers.SplitParagraphs(text);
// that the order or splitting strings in C#'s String.Split() method is
// important; see http://stackoverflow.com/a/8664639/270712
string[] paragraphs = text.Split(
new string[] { "\r\n", "\n\r", "\r", "\n" },
StringSplitOptions.RemoveEmptyEntries);
LaurisTimePoint timePoint = null; LaurisTimePoint timePoint = null;
foreach (string paragraph in paragraphs) foreach (string paragraph in paragraphs)

View File

@ -0,0 +1,210 @@
using Microsoft.Office.Interop.Word;
/* Formatter.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.Collections.Generic;
using System.Linq;
using System.Text;
namespace zaaReloaded2.Medication
{
/// <summary>
/// Formats prescriptions
/// </summary>
public class Formatter
{
#region Properties
public IList<Prescription> Prescriptions { get; set; }
#endregion
#region Constructor
public Formatter() { }
public Formatter(IList<Prescription> prescriptions)
: this()
{
Prescriptions = prescriptions;
}
#endregion
#region Methods
/// <summary>
/// Writes a block of prescriptions with one column to a
/// Word document.
/// </summary>
/// <param name="document"></param>
public void FormatOneColumn(Document document)
{
DoFormat("Medikation einspaltig formatieren",
document,
writer =>
{
foreach (Prescription p in Prescriptions)
{
writer.WriteLine(p.ToString());
}
});
}
/// <summary>
/// Writes a block of prescriptions with two columns to a
/// Word document.
/// </summary>
/// <param name="document"></param>
public void FormatTwoColumns(Document document)
{
DoFormat("Medikation zweispaltig formatieren",
document,
writer =>
{
int half = Prescriptions.Count / 2 + Prescriptions.Count % 2;
for (int i = 0; i < half; i++)
{
writer.Write(Prescriptions[i].ToString());
if (i + half < Prescriptions.Count)
{
writer.Write("\t" + Prescriptions[i + half].ToString());
}
writer.WriteLine();
}
});
}
/// <summary>
/// Creates a table containing all prescriptions and copies it to
/// the clipboard.
/// </summary>
public void CreatePrescriptionsTable()
{
throw new NotImplementedException();
}
#endregion
#region Private methods
void AddDisclaimer(zaaReloaded2.Formatter.DocumentWriter writer)
{
if (HasMMF())
{
writer.WriteLine();
writer.WriteLine("<b>Hinweis: Während und nach Therapie mit Mycophenolsäurederivaten wie CellCept\u00ae " +
"und Myfortic\u00ae müssen Frauen und Männer eine Schwangerschaft sicher verhüten (siehe Rote-Hand-Brief zu " +
"CellCept\u00ae vom 10.11.2015).</b>");
writer.WriteLine();
}
writer.WriteLine("<highlight><b>Bitte Medikation überprüfen!</b></highlight>");
}
/// <summary>
/// Creates a paragraph and character styles in the document.
/// </summary>
void CreateStyles(Document document)
{
if (document != null)
{
Style style;
// Don't see a better way to check for the existence of a particular
// paragraph style than by using a try...catch construction.
try
{
style = document.Styles[Properties.Settings.Default.DrugsParagraph];
}
catch
{
// Add default paragraph style for laboratory
style = document.Styles.Add(Properties.Settings.Default.DrugsParagraph);
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 = 0; // pt
style.ParagraphFormat.FirstLineIndent = 0; // pt
style.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
style.ParagraphFormat.TabStops.ClearAll();
int tabStop = 108; // 108 pt = 2.5 in = 3.8 cm
int halfWay = 227; // 227 pt = 3.15 in = 8 cm
style.ParagraphFormat.TabStops.Add(tabStop);
style.ParagraphFormat.TabStops.Add(halfWay);
style.ParagraphFormat.TabStops.Add(halfWay + tabStop);
}
// try
// {
// style = document.Styles[Properties.Settings.Default.DrugsHeader];
// }
// catch
// {
// // Add header paragraph style for laboratory
// style = document.Styles.Add(Properties.Settings.Default.DrugsHeader);
// 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.DrugsParagraph]);
// }
}
}
/// <summary>
/// Does the heavy lifting in a DRY way.
/// </summary>
void DoFormat(string description, Document document,
Action<zaaReloaded2.Formatter.DocumentWriter> outputAction)
{
if (document == null)
{
throw new ArgumentNullException(
"Cannot format prescriptions because no document was given.");
}
Helpers.StartUndo(description);
zaaReloaded2.Formatter.DocumentWriter writer = new zaaReloaded2.Formatter.DocumentWriter(document);
CreateStyles(document);
writer.Write(String.Format("<style:{0}>", Properties.Settings.Default.DrugsParagraph));
outputAction(writer);
AddDisclaimer(writer);
// writer.Write("</style>"); // causes COM exceptions, needs fix
writer.Flush();
Helpers.EndUndo();
}
/// <summary>
/// Determines whether MMF or MPA is contained in the prescriptions.
/// </summary>
/// <returns>True if MMF or MPA is prescribed.</returns>
bool HasMMF()
{
return Prescriptions.FirstOrDefault(p => p.IsMmf) != null;
}
#endregion
}
}

View File

@ -0,0 +1,208 @@
using Microsoft.Office.Interop.Word;
/* Importer.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.Collections.Generic;
using System.Linq;
using System.Text;
namespace zaaReloaded2.Medication
{
/// <summary>
/// Imports prescriptions from a physician's letter.
/// </summary>
public class Importer
{
#region Static methods
/// <summary>
/// Attempts to automatically detect a block of prescriptions
/// in a document. The document is screened from end to start.
/// The detected block is selected.
/// </summary>
/// <returns>True if a block was detected, false if not.</returns>
/// <remarks>
/// <para>
/// Autodetection works by examining the document paragraph by
/// paragraph, starting at the end of the document. The first
/// block of at least two lines that are identified as prescription
/// lines is selected.
/// </para>
/// <para>
/// It should be noted that every paragraph (a.k.a. line) may
/// be regarded as one of three things:
/// </para>
/// <list type="ol">
/// <item>A typical prescription line (in the form "Ramipril 5 mg 1-0-0")</item>
/// <item>A typical non-prescription text line</item>
/// <item>Something inbetween, e.g. a line with tab stops as in
/// "Ramipril 5 mg \t alle zwei Tage" or in "Prof. B. Oss \t Dr. A. Sistent"
/// </item>
/// </list>
/// <para>
/// It is the third type of line that may cause confusion. If such a line
/// is encountered at the start of a putative block of prescriptions, we
/// therefore enter a "fuzzy" state in the detection algorithm and take
/// it from there, i.e. disregard the block if there are no lines that
/// are clearly prescriptions lines, or accept the block if we do detect
/// adjacent lines with unequivocal prescriptions.
/// </para>
///
/// </remarks>
public static bool AutoDetect(Document document)
{
Paragraph start = null;
Paragraph end = null;
bool insideBlock = false;
bool fuzzy = false;
bool result = false;
int i = document.Paragraphs.Count;
while (i > 1)
{
string line = document.Paragraphs[i].Range.Text;
if (Prescription.IsCanonicalPrescriptionLine(line))
{
// The current line is unequivocally a prescription line:
// If we're not inside a block already, mark the bottom
// of the block.
// If we are inside a block already, make sure to leave
// the 'fuzzy' state because this clearly now is a prescription
// block.
if (insideBlock)
{
fuzzy = false;
}
else
{
end = document.Paragraphs[i];
insideBlock = true;
}
}
else if (Prescription.IsPotentialPrescriptionLine(line))
{
// The current line is a putative prescription line:
// If we're not inside a block already, enter the
// "fuzzy" state.
// If we are inside a block, no special action is
// needed, we can continue with the next paragraph.
if (!insideBlock)
{
fuzzy = true;
insideBlock = true;
end = document.Paragraphs[i];
}
}
else
{
// The current line is not a prescription line:
// If we are currently in a definitive block of prescriptions,
// mark the line below the current line as the start of the block.
// If we're in a putative block, discard the information
// about the bottom end of the block and reset all flags.
if (insideBlock)
{
if (!fuzzy)
{
start = document.Paragraphs[i + 1];
break;
}
else
{
fuzzy = false;
insideBlock = false;
end = null;
}
}
}
i--;
}
if (end != null)
{
// If we don't have a start paragraph,
// but do have an end paragraph, we set the start paragraph to the
// first paragraph of the document.
if (start == null)
{
start = document.Paragraphs[1];
}
document.Range(start.Range.Start, end.Range.End).Select();
result = true;
}
return result;
}
#endregion
#region Properties
public List<Prescription> Prescriptions { get; protected set; }
#endregion
#region Constructor
public Importer() { }
public Importer(string text)
: this()
{
Import(text);
}
#endregion
#region Private methods
protected virtual void Import(string text)
{
List<Prescription> list = new List<Prescription>();
IList<Prescription> addition;
int columns = 1;
string[] lines = Helpers.SplitParagraphs(text);
foreach (string line in lines)
{
if (Prescription.IsPotentialPrescriptionLine(line))
{
addition = Prescription.ManyFromLine(line);
columns = System.Math.Max(columns, addition.Count);
list.AddRange(addition);
}
}
// If the input had several columns, sort the prescriptions by
// column.
// TODO: Make this more generic so it works with 3 or 4 columns as well.
if (columns == 2)
{
var firstCol = list.Where((item, index) => index % 2 == 0);
var secondCol = list.Where((item, index) => index % 2 != 0);
Prescriptions = firstCol.Concat(secondCol).ToList();
}
else
{
Prescriptions = list;
}
}
#endregion
}
}

View File

@ -0,0 +1,273 @@
/* Prescription.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.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace zaaReloaded2.Medication
{
/// <summary>
/// Represents a prescription
/// </summary>
public class Prescription
{
#region Static methods
/// <summary>
/// Determines whether a line contains prescriptions.
/// </summary>
/// <param name="line">Line to inspect.</param>
/// <returns>True if the line contains prescriptions.</returns>
public static bool IsCanonicalPrescriptionLine(string line)
{
return canonicalRegex.IsMatch(line);
}
/// <summary>
/// Determines if a line contains prescriptions, either canonical
/// ones or alternative ones (in the form "Ramipril 5 mg \t alle 2 Tage").
/// </summary>
/// <param name="line">Line to examine.</param>
/// <returns>True if the line potentially contains prescriptions.</returns>
public static bool IsPotentialPrescriptionLine(string line)
{
return unifiedRegex.IsMatch(line);
}
#endregion
#region Factory
/// <summary>
/// Creates a new Prescription object by parsing a line (e.g.,
/// from a physician's letter).
/// </summary>
/// <param name="line">Line to parse</param>
/// <returns>Prescription created from the <paramref name="Line"/></returns>
public static Prescription FromLine(string line)
{
// Replace any runs of whitespace with a single space
// (from http://stackoverflow.com/a/206946/270712)
// line = Regex.Replace(line, @"\s+", " ");
Match m = unifiedRegex.Match(line);
int n = m.Groups[DOSE_GROUP].Captures.Count;
return new Prescription(
spaceRegex.Replace(m.Groups["drug"].Value, " "),
n > 0 ? m.Groups[DOSE_GROUP].Captures[0].Value : String.Empty,
n > 1 ? m.Groups[DOSE_GROUP].Captures[1].Value : String.Empty,
n > 2 ? m.Groups[DOSE_GROUP].Captures[2].Value : String.Empty,
n > 3 ? m.Groups[DOSE_GROUP].Captures[3].Value : String.Empty,
m.Groups["comment"].Value
);
}
/// <summary>
/// Extracts several prescriptions from a given line.
/// </summary>
/// <param name="line">Line that contains several prescriptions.</param>
/// <returns>Enumerable with <see cref="Prescription"/>s.</returns>
public static IList<Prescription> ManyFromLine(string line)
{
// line = Regex.Replace(line, @"\s+", " ");
MatchCollection mc = unifiedRegex.Matches(line);
List<Prescription> list = new List<Prescription>();
foreach (Match m in mc)
{
int n = m.Groups[DOSE_GROUP].Captures.Count;
list.Add(new Prescription(
spaceRegex.Replace(m.Groups["drug"].Value, " "),
n > 0 ? m.Groups[DOSE_GROUP].Captures[0].Value : String.Empty,
n > 1 ? m.Groups[DOSE_GROUP].Captures[1].Value : String.Empty,
n > 2 ? m.Groups[DOSE_GROUP].Captures[2].Value : String.Empty,
n > 3 ? m.Groups[DOSE_GROUP].Captures[3].Value : String.Empty,
m.Groups["comment"].Value
)
);
}
return list;
}
#endregion
#region Properties
public string Drug { get; set; }
public string Morning { get; set; }
public string Noon { get; set; }
public string Evening { get; set; }
public string Night { get; set; }
public string Comment { get; set; }
/// <summary>
/// Determines whether the drug is MMF or a derivative.
/// </summary>
public bool IsMmf
{
get
{
string d = Drug.ToLower();
return
d.StartsWith("mmf") ||
d.StartsWith("cellcept") ||
d.StartsWith("cell cept") ||
d.StartsWith("myfortic") ||
d.StartsWith("mycophenol");
}
}
#endregion
#region Overrides
public override string ToString()
{
string s = Drug + "\t";
if (!String.IsNullOrEmpty(Morning))
{
s += Morning;
}
else
{
if (!(String.IsNullOrEmpty(Noon) && String.IsNullOrEmpty(Evening) &&
String.IsNullOrEmpty(Night)))
{
s += "0";
}
}
if (!String.IsNullOrEmpty(Noon))
{
s += "-" + Noon;
}
else
{
if (!(String.IsNullOrEmpty(Evening) && String.IsNullOrEmpty(Night)))
{
s += "-0";
}
}
if (!String.IsNullOrEmpty(Evening))
{
s += "-" + Evening;
}
else
{
if (!String.IsNullOrEmpty(Night))
{
s += "-0";
}
}
if (!String.IsNullOrEmpty(Night))
{
s += "-" + Night;
}
if (!String.IsNullOrEmpty(Comment))
{
if (!s.EndsWith("\t"))
{
s += " ";
}
s += Comment;
}
return s;
}
#endregion
#region Constructors
public Prescription() { }
public Prescription(string drug)
: this()
{
Drug = drug.Trim();
}
public Prescription(string drug, string morning, string noon,
string evening, string night)
: this(drug)
{
Morning = morning.Trim();
Noon = noon.Trim();
Evening = evening.Trim();
Night = night.Trim();
}
public Prescription(string drug, string morning, string noon,
string evening, string night, string comment)
: this(drug, morning, noon, evening, night)
{
Comment = comment.Trim();
}
#endregion
#region Fields
private const string DOSE_GROUP = "dose";
private const string DOSE = @"(\d\s+1/[234]|(\d\s?)?[\u00bd\u2153\u00bc]|\d+)";
private const string SPACER = @"(\s*[-\u2012\u2013\u2014]+\s*)";
/// <summary>
/// The 'canonical' regex matches a prescription the form "Ramipril 5 mg 1-0-0"
/// with or without trailing comment.
/// </summary>
/// <remarks>
/// Enclose entire regular expression in parentheses so we can use it
/// with or without trailing comment.
/// </remarks>
private const string canonicalPattern =
@"((?<drug>[^\t]+)\s+" +
@"(?<dose>" + DOSE + @")" + SPACER +
@"(?<dose>" + DOSE + @")" + SPACER +
@"(?<dose>" + DOSE + @")" +
@"(" + SPACER + @"(?<dose>" + DOSE + @"))?" +
@"( +(?<comment>[^\t]+))?\s*)";
private static readonly Regex canonicalRegex = new Regex(canonicalPattern);
/// <summary>
/// The 'alternative' regex matches prescriptions that do not contain regular
/// dosing intervals ("1-0-0"), but free-style comments: "Cotrim forte alle 2 Tage".
/// </summary>
/// <remarks>
/// Because this alternative pattern matches other lines as well (e.g. with
/// signature names), it requires special handling.
/// </remarks>
private const string alternativePattern =
@"((?<drug>[^\t]+)( +|\t+)(?<comment>[^\t]+))";
private static readonly Regex alternativeRegex = new Regex(alternativePattern);
private static readonly Regex unifiedRegex = new Regex(
"(" + canonicalPattern + "|" + alternativePattern + ")");
/// <summary>
/// A 'cached', reusable regex to match several whitespace characters.
/// </summary>
private static readonly Regex spaceRegex = new Regex(@"\s+");
#endregion
}
}

View File

@ -276,5 +276,14 @@ namespace zaaReloaded2.Properties {
this["NeedUpgrade"] = value; this["NeedUpgrade"] = value;
} }
} }
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("zaaReloaded2-Medikamente")]
public string DrugsParagraph {
get {
return ((string)(this["DrugsParagraph"]));
}
}
} }
} }

View File

@ -80,5 +80,8 @@
<Setting Name="NeedUpgrade" Type="System.Boolean" Scope="User"> <Setting Name="NeedUpgrade" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value> <Value Profile="(Default)">True</Value>
</Setting> </Setting>
<Setting Name="DrugsParagraph" Type="System.String" Scope="Application">
<Value Profile="(Default)">zaaReloaded2-Medikamente</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -87,7 +87,7 @@ namespace zaaReloaded2
{ {
switch (control.Id) switch (control.Id)
{ {
case "zrlFormat": case "zrlFormatLab":
Commands.Format(); Commands.Format();
break; break;
case "zrlSettings": case "zrlSettings":
@ -105,6 +105,12 @@ namespace zaaReloaded2
case "zrlDemo": case "zrlDemo":
Commands.LoadDemo(); Commands.LoadDemo();
break; break;
case "zrlFormatDrugsOneCol":
Commands.FormatDrugs(1);
break;
case "zrlFormatDrugsTwoCol":
Commands.FormatDrugs(2);
break;
default: default:
throw new InvalidOperationException("No operation defined for " + control.Id); throw new InvalidOperationException("No operation defined for " + control.Id);
} }
@ -150,6 +156,11 @@ namespace zaaReloaded2
return Commands.CanFormat(); return Commands.CanFormat();
} }
public bool CanFormatDrugs(Office.IRibbonControl control)
{
return Commands.CanFormat();
}
#endregion #endregion
#region Public methods #region Public methods

View File

@ -23,12 +23,22 @@
<ribbon> <ribbon>
<tabs> <tabs>
<tab id="zaaReloaded2" label="zaaReloaded2"> <tab id="zaaReloaded2" label="zaaReloaded2">
<group id="zrlFormatGroup" label="Formatieren"> <group id="zrlGroupLab" label="Laborwerte">
<button id="zrlFormat" label="Formatieren" image="f.png" onAction="Ribbon_Click" size="large" <button id="zrlFormatLab" label="Formatieren" image="f.png" onAction="Ribbon_Click" size="large"
supertip="Formatiert den ausgewählten Bereich mit dem zuletzt verwendeten Stil." supertip="Formatiert den ausgewählten Bereich mit dem zuletzt verwendeten Stil."
getEnabled="CanFormat" /> getEnabled="CanFormat" />
<button id="zrlSettings" label="Stilauswahl" image="fff.png" onAction="Ribbon_Click" size="large" <button id="zrlSettings" label="Stilauswahl" image="fff.png" onAction="Ribbon_Click" size="large"
supertip="Zeigt eine Liste vorhandener Stile an. Stile können bearbeitet, hinzugefügt, gelöscht werden." /> supertip="Zeigt eine Liste vorhandener Stile an. Stile können bearbeitet, hinzugefügt, gelöscht werden." />
</group>
<group id="zrlGroupDrugs" label="Medikamente">
<button id="zrlFormatDrugsOneCol" label="Einspaltig" image="m.png" onAction="Ribbon_Click" size="large"
supertip="Formatiert die Medikationsliste einspaltig"
getEnabled="CanFormatDrugs" />
<button id="zrlFormatDrugsTwoCol" label="Zweispaltig" image="mm.png" onAction="Ribbon_Click" size="large"
supertip="Formatiert die Medikationsliste zweispaltig"
getEnabled="CanFormatDrugs" />
</group>
<group id="zrlSpecial" label="Spezial">
<button id="zrlDaniel" label="Daniels Spezial" image="dk.png" onAction="Ribbon_Click" size="large" <button id="zrlDaniel" label="Daniels Spezial" image="dk.png" onAction="Ribbon_Click" size="large"
getVisible="Daniel_GetVisible"/> getVisible="Daniel_GetVisible"/>
</group> </group>

View File

@ -1,2 +1,2 @@
2.1.12 2.2.3
2.1.12.0 2.2.3.0

View File

@ -86,6 +86,9 @@
<setting name="Repository" serializeAs="String"> <setting name="Repository" serializeAs="String">
<value>http://git.bovender.de</value> <value>http://git.bovender.de</value>
</setting> </setting>
<setting name="DrugsParagraph" serializeAs="String">
<value>zaaReloaded2-Medikamente</value>
</setting>
</zaaReloaded2.Properties.Settings> </zaaReloaded2.Properties.Settings>
</applicationSettings> </applicationSettings>
<userSettings> <userSettings>

View File

@ -29,6 +29,7 @@
<AssemblyName>zaaReloaded2</AssemblyName> <AssemblyName>zaaReloaded2</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<DefineConstants>VSTO40</DefineConstants> <DefineConstants>VSTO40</DefineConstants>
<IsWebBootstrapper>False</IsWebBootstrapper>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
<PublishUrl>publish\</PublishUrl> <PublishUrl>publish\</PublishUrl>
<InstallUrl /> <InstallUrl />
@ -38,7 +39,6 @@
<UpdateEnabled>true</UpdateEnabled> <UpdateEnabled>true</UpdateEnabled>
<UpdateInterval>7</UpdateInterval> <UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>days</UpdateIntervalUnits> <UpdateIntervalUnits>days</UpdateIntervalUnits>
<IsWebBootstrapper>False</IsWebBootstrapper>
<ProductName>zaaReloaded2</ProductName> <ProductName>zaaReloaded2</ProductName>
<PublisherName /> <PublisherName />
<SupportUrl /> <SupportUrl />
@ -194,6 +194,7 @@
--> -->
<ItemGroup> <ItemGroup>
<Compile Include="Commands.cs" /> <Compile Include="Commands.cs" />
<Compile Include="Helpers.cs" />
<Compile Include="Importer\ZaaImporter\AutoDetect.cs" /> <Compile Include="Importer\ZaaImporter\AutoDetect.cs" />
<Compile Include="Controller\Comments\CommentPool.cs" /> <Compile Include="Controller\Comments\CommentPool.cs" />
<Compile Include="Controller\Elements\ControlElementBase.cs" /> <Compile Include="Controller\Elements\ControlElementBase.cs" />
@ -221,6 +222,9 @@
<Compile Include="Formatter\DanielsStyle.cs" /> <Compile Include="Formatter\DanielsStyle.cs" />
<Compile Include="Formatter\DocumentWriter.cs" /> <Compile Include="Formatter\DocumentWriter.cs" />
<Compile Include="Formatter\NoLaboratoryDataException.cs" /> <Compile Include="Formatter\NoLaboratoryDataException.cs" />
<Compile Include="Medication\Formatter.cs" />
<Compile Include="Medication\Importer.cs" />
<Compile Include="Medication\Prescription.cs" />
<Compile Include="Preferences.cs" /> <Compile Include="Preferences.cs" />
<Compile Include="Ribbon.cs" /> <Compile Include="Ribbon.cs" />
<Compile Include="Thesaurus\ThesaurusBase.cs" /> <Compile Include="Thesaurus\ThesaurusBase.cs" />
@ -446,6 +450,12 @@
<ItemGroup> <ItemGroup>
<Resource Include="Icons\gear.png" /> <Resource Include="Icons\gear.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="Icons\m.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\mm.png" />
</ItemGroup>
<PropertyGroup> <PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
@ -454,10 +464,11 @@
<SignManifests>true</SignManifests> <SignManifests>true</SignManifests>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ManifestKeyFile>zaaReloaded2_TemporaryKey.pfx</ManifestKeyFile> <ManifestKeyFile>
</ManifestKeyFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ManifestCertificateThumbprint>0EDB0CD8E3605AC48387A527A80943403E568BD9</ManifestCertificateThumbprint> <ManifestCertificateThumbprint>6322CFC6CFA69B4D2DEFAE4A901473C8B35B0DB9</ManifestCertificateThumbprint>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignAssembly>true</SignAssembly> <SignAssembly>true</SignAssembly>