From 12cd58180f47ce296ff58cfaa2201af70e545326 Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Fri, 31 Jul 2015 17:19:49 +0200 Subject: [PATCH] Create rudimentary view models, default settings. --- Tests/Controller/SettingsRepositoryTest.cs | 28 +- Tests/Tests.csproj | 14 + .../ViewModels/SettingsRepositoryViewModel.cs | 36 +++ Tests/ViewModels/SettingsViewModelTest.cs | 69 +++++ Tests/packages.config | 2 + .../Controller/Elements/CustomText.cs | 12 +- .../Controller/Elements/FormatElementBase.cs | 19 ++ zaaReloaded2/Controller/Elements/Items.cs | 35 +-- .../Controller/Elements/SelectEachDay.cs | 4 + .../Controller/Elements/SelectFirstDay.cs | 4 + .../Controller/Elements/SelectLastDay.cs | 4 + zaaReloaded2/Controller/Settings.cs | 37 +++ zaaReloaded2/Controller/SettingsRepository.cs | 70 ++++- zaaReloaded2/Properties/Settings.Designer.cs | 126 +++++++++ zaaReloaded2/Properties/Settings.settings | 42 +++ .../ViewModels/ControlElementViewModel.cs | 50 ++++ zaaReloaded2/ViewModels/ElementViewModel.cs | 73 +++++ .../ViewModels/FormatElementViewModel.cs | 56 ++++ zaaReloaded2/ViewModels/SettingsViewModel.cs | 253 ++++++++++++++++++ zaaReloaded2/app.config | 42 +++ zaaReloaded2/zaaReloaded2.csproj | 4 + 21 files changed, 937 insertions(+), 43 deletions(-) create mode 100755 Tests/ViewModels/SettingsRepositoryViewModel.cs create mode 100755 Tests/ViewModels/SettingsViewModelTest.cs create mode 100755 zaaReloaded2/ViewModels/ControlElementViewModel.cs create mode 100755 zaaReloaded2/ViewModels/ElementViewModel.cs create mode 100755 zaaReloaded2/ViewModels/FormatElementViewModel.cs create mode 100755 zaaReloaded2/ViewModels/SettingsViewModel.cs diff --git a/Tests/Controller/SettingsRepositoryTest.cs b/Tests/Controller/SettingsRepositoryTest.cs index 7fdc722..687aa36 100755 --- a/Tests/Controller/SettingsRepositoryTest.cs +++ b/Tests/Controller/SettingsRepositoryTest.cs @@ -49,12 +49,34 @@ namespace Tests.Controller Settings s = new Settings(); string testName = "test"; s.Name = testName; - sr.Settings.Add(s); + sr.SettingsList.Add(s); sr.Store(); sr = null; sr = SettingsRepository.Load(); - Assert.AreEqual(1, sr.Settings.Count); - Assert.AreEqual(testName, sr.Settings[0].Name); + Assert.AreEqual(1, sr.SettingsList.Count); + Assert.AreEqual(testName, sr.SettingsList[0].Name); + } + + [Test] + public void CreateDefaultSettings() + { + SettingsRepository sr = new SettingsRepository(); + sr.SettingsList.Add(new Settings("test1", null)); + sr.SettingsList.Add(new Settings("test2", null)); + sr.SettingsList.Add(new Settings("test3", null)); + sr.ResetDefault(); + + // Assert that there are now only the 2 default settings + Assert.AreEqual(2, sr.SettingsList.Count); + + Assert.AreEqual( + zaaReloaded2.Properties.Settings.Default.SettingsNameWard, + sr.SettingsList[0].Name, + "Settings for ward expected as #1 (index 0) in list"); + Assert.AreEqual( + zaaReloaded2.Properties.Settings.Default.SettingsNameClinic, + sr.SettingsList[1].Name, + "Settings for outpatient clinic expected as #2 (index 1) in list"); } } } diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 48f28f4..4caecda 100755 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -41,6 +41,10 @@ zaaReloaded2.pfx + + ..\packages\Bovender.0.2.0.0\lib\net40\Bovender.dll + True + True @@ -48,10 +52,18 @@ False ..\packages\NUnit.2.6.4\lib\nunit.framework.dll + + 3.5 + + ..\packages\Expression.Blend.Sdk.1.0.2\lib\net40-client\System.Windows.Interactivity.dll + True + + + @@ -79,6 +91,8 @@ + + diff --git a/Tests/ViewModels/SettingsRepositoryViewModel.cs b/Tests/ViewModels/SettingsRepositoryViewModel.cs new file mode 100755 index 0000000..badb4ef --- /dev/null +++ b/Tests/ViewModels/SettingsRepositoryViewModel.cs @@ -0,0 +1,36 @@ +/* SettingsRepositoryViewModel.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.Controller; + +namespace Tests.ViewModels +{ + [TestFixture] + class SettingsRepositoryViewModel + { + [Test] + public void CannotDeleteDefaultSettings() + { + + } + } +} diff --git a/Tests/ViewModels/SettingsViewModelTest.cs b/Tests/ViewModels/SettingsViewModelTest.cs new file mode 100755 index 0000000..f06d5d8 --- /dev/null +++ b/Tests/ViewModels/SettingsViewModelTest.cs @@ -0,0 +1,69 @@ +/* SettingsViewModelTest.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.ViewModels; +using zaaReloaded2.Controller; + +namespace Tests.ViewModels +{ + [TestFixture] + class SettingsViewModelTest + { + SettingsViewModel _settingsVM; + + [SetUp] + public void SetUp() + { + _settingsVM = new SettingsViewModel(); + } + + [Test] + public void AddElement() + { + + } + + [Test] + public void AddChildElement() + { + + } + + [Test] + public void CannotAddChildElementToFormatElement() + { + + } + + [Test] + public void DeleteElement() + { + + } + + [Test] + public void CopyElement() + { + + } + } +} diff --git a/Tests/packages.config b/Tests/packages.config index 512ce05..e9b2d17 100755 --- a/Tests/packages.config +++ b/Tests/packages.config @@ -1,4 +1,6 @@  + + \ No newline at end of file diff --git a/zaaReloaded2/Controller/Elements/CustomText.cs b/zaaReloaded2/Controller/Elements/CustomText.cs index 1061b17..f3ebe9f 100755 --- a/zaaReloaded2/Controller/Elements/CustomText.cs +++ b/zaaReloaded2/Controller/Elements/CustomText.cs @@ -25,22 +25,16 @@ namespace zaaReloaded2.Controller.Elements /// /// Controller element that writes arbitrary text to the document. /// - class CustomText : ElementBase + class CustomText : FormatElementBase { public override string Label { - get { return String.Format("\"{0}\"", Text); } + get { return String.Format("\"{0}\"", Content); } } public override void Run(Formatter.Formatter formatter) { - formatter.Write(Text); + formatter.WriteParagraph(Content); } - - /// - /// Gets or sets the arbitrary text that will be written - /// to the document. - /// - public string Text { get; set; } } } diff --git a/zaaReloaded2/Controller/Elements/FormatElementBase.cs b/zaaReloaded2/Controller/Elements/FormatElementBase.cs index 8a0db99..c47d4ad 100755 --- a/zaaReloaded2/Controller/Elements/FormatElementBase.cs +++ b/zaaReloaded2/Controller/Elements/FormatElementBase.cs @@ -23,5 +23,24 @@ namespace zaaReloaded2.Controller.Elements /// public abstract class FormatElementBase : ElementBase { + /// + /// Gets or sets the content of this format element. + /// + public string Content + { + get { return _content; } + set + { + _content = value; + + } + } + + /// + /// Is called whenever the Content is changed. + /// + protected virtual void OnContentChanged() {} + + private string _content; } } diff --git a/zaaReloaded2/Controller/Elements/Items.cs b/zaaReloaded2/Controller/Elements/Items.cs index fa31de6..b1d258b 100755 --- a/zaaReloaded2/Controller/Elements/Items.cs +++ b/zaaReloaded2/Controller/Elements/Items.cs @@ -31,17 +31,18 @@ namespace zaaReloaded2.Controller.Elements /// to a Word document. /// [Serializable] - class Items : FormatElementBase + class Items : CustomText { #region ElementBase implementation public override string Label { - get { return Line; } + get { return Content; } } public override void Run(zaaReloaded2.Formatter.Formatter formatter) { + ParseLine(); if (_items == null || _items.Count == 0) return; bool _needComma = false; @@ -75,37 +76,14 @@ namespace zaaReloaded2.Controller.Elements #endregion - #region Properties - - /// - /// Gets or sets a text line that contains a comma-separated list of - /// parsable laboratory item names. The list may optionally be preceded - /// with a caption followed by a colon. - /// - public string Line - { - [DebuggerStepThrough] - get - { - return _line; - } - set - { - _line = value; - ParseLine(); - } - } - - #endregion - #region Constructors public Items() : base() { } - public Items(string line) + public Items(string content) : this() { - Line = line; + Content = content; } #endregion @@ -121,7 +99,7 @@ namespace zaaReloaded2.Controller.Elements _items = null; _caption = null; Regex r = new Regex(@"((?[^:]+):\s*)?((?[^,]+),\s*)*(?[^,]+)"); - Match m = r.Match(Line); + Match m = r.Match(Content); if (m.Success) { if (m.Groups["caption"].Success) @@ -203,7 +181,6 @@ namespace zaaReloaded2.Controller.Elements #region Fields - string _line; string _caption; List _items; static Regex _wildcard = new Regex(@"(?[^-]+-)?\*"); diff --git a/zaaReloaded2/Controller/Elements/SelectEachDay.cs b/zaaReloaded2/Controller/Elements/SelectEachDay.cs index 50eaea3..ef42a56 100755 --- a/zaaReloaded2/Controller/Elements/SelectEachDay.cs +++ b/zaaReloaded2/Controller/Elements/SelectEachDay.cs @@ -39,5 +39,9 @@ namespace zaaReloaded2.Controller.Elements public SelectEachDay(FormatElementBase formatElement) : base(formatElement) { } + + public SelectEachDay(IList formatElements) + : base(formatElements) + { } } } diff --git a/zaaReloaded2/Controller/Elements/SelectFirstDay.cs b/zaaReloaded2/Controller/Elements/SelectFirstDay.cs index 116055f..930a585 100755 --- a/zaaReloaded2/Controller/Elements/SelectFirstDay.cs +++ b/zaaReloaded2/Controller/Elements/SelectFirstDay.cs @@ -43,5 +43,9 @@ namespace zaaReloaded2.Controller.Elements public SelectFirstDay(FormatElementBase formatElement) : base(formatElement) { } + + public SelectFirstDay(IList formatElements) + : base(formatElements) + { } } } diff --git a/zaaReloaded2/Controller/Elements/SelectLastDay.cs b/zaaReloaded2/Controller/Elements/SelectLastDay.cs index d836e02..2e2230d 100755 --- a/zaaReloaded2/Controller/Elements/SelectLastDay.cs +++ b/zaaReloaded2/Controller/Elements/SelectLastDay.cs @@ -44,5 +44,9 @@ namespace zaaReloaded2.Controller.Elements public SelectLastDay(FormatElementBase formatElement) : base(formatElement) { } + + public SelectLastDay(IList formatElements) + : base(formatElements) + { } } } diff --git a/zaaReloaded2/Controller/Settings.cs b/zaaReloaded2/Controller/Settings.cs index 7986d98..d4a120a 100755 --- a/zaaReloaded2/Controller/Settings.cs +++ b/zaaReloaded2/Controller/Settings.cs @@ -56,6 +56,43 @@ namespace zaaReloaded2.Controller Elements = new List(); } + /// + /// Creates a new Settings object with an initial + /// set of elements. + /// + /// Set of ElementBase + /// object (or derived ones). + public Settings(IList initialElements) + { + Elements = initialElements; + } + + /// + /// Creates a new Settings object with an initial + /// set of elements and a name. + /// + /// Set of ElementBase + /// object (or derived ones). + /// Name of these settings. + public Settings(string name, IList initialElements) + : this(initialElements) + { + Name = name; + } + + #endregion + + #region Public methods + + /// + /// Adds an element to the list of Elements. + /// + /// Element to add. + public void AddElement(ElementBase element) + { + Elements.Add(element); + } + #endregion } } diff --git a/zaaReloaded2/Controller/SettingsRepository.cs b/zaaReloaded2/Controller/SettingsRepository.cs index dd21850..64ce8e4 100755 --- a/zaaReloaded2/Controller/SettingsRepository.cs +++ b/zaaReloaded2/Controller/SettingsRepository.cs @@ -21,9 +21,19 @@ using System.Collections.ObjectModel; using System.Configuration; using System.Linq; using System.Text; +using zaaReloaded2.Controller.Elements; namespace zaaReloaded2.Controller { + /// + /// A repository for zaaReloaded2.Controller.Settings. + /// + /// + /// This class is derived from ApplicationSettingsBase to be able + /// to simply store it in the assembly's properties. However, this + /// causes some confusion because .NET's ApplicationSettings are + /// different from zaaReloaded's Settings. + /// [Serializable] public class SettingsRepository : ApplicationSettingsBase { @@ -48,7 +58,7 @@ namespace zaaReloaded2.Controller [UserScopedSetting()] [SettingsSerializeAs(SettingsSerializeAs.Xml)] - public IList Settings { get; private set; } + public IList SettingsList { get; private set; } #endregion @@ -56,7 +66,63 @@ namespace zaaReloaded2.Controller public SettingsRepository() { - Settings = new List(); + SettingsList = new List(); + } + + #endregion + + #region Public methods + + /// + /// Resets the Settings contained in this SettingsRepository + /// to the default set of settings. + /// + public void ResetDefault() + { + SettingsList.Clear(); + + // Shortcut to assembly properties + zaaReloaded2.Properties.Settings def = zaaReloaded2.Properties.Settings.Default; + + // TODO: May want to create deep copies of this list below + List defaultItems = new List() + { + new Items(def.DefaultItemsClinicalChem), + new Items(def.DefaultItemsInflammation), + new Items(def.DefaultItemsCardio), + new Items(def.DefaultItemsKidney), + new Items(def.DefaultItemsLiver), + new Items(def.DefaultItemsLipids), + new Items(def.DefaultItemsHematology), + new Items(def.DefaultItemsCoagulation), + new Items(def.DefaultItemsDrugs), + new Items(def.DefaultItemsCollectedUrine), + new Items(def.DefaultItemsSpotUrine), + new Items(def.DefaultItemsOther), + }; + + // Configure the settings for the ward + SettingsList.Add( + new Settings( + def.SettingsNameWard, + new List() + { + new SelectFirstDay(defaultItems), + new SelectLastDay(defaultItems) + } + ) + ); + + // Configure the settings for the outpatient clinic + SettingsList.Add( + new Settings( + def.SettingsNameClinic, + new List() + { + new SelectEachDay(defaultItems), + } + ) + ); } #endregion diff --git a/zaaReloaded2/Properties/Settings.Designer.cs b/zaaReloaded2/Properties/Settings.Designer.cs index a538f7c..ec1e26e 100755 --- a/zaaReloaded2/Properties/Settings.Designer.cs +++ b/zaaReloaded2/Properties/Settings.Designer.cs @@ -107,5 +107,131 @@ namespace zaaReloaded2.Properties { return ((global::System.Uri)(this["LicenseUrl"])); } } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("Standard für Station")] + public string SettingsNameWard { + get { + return ((string)(this["SettingsNameWard"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("Standard für NepA")] + public string SettingsNameClinic { + get { + return ((string)(this["SettingsNameClinic"])); + } + } + + [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"])); + } + } } } diff --git a/zaaReloaded2/Properties/Settings.settings b/zaaReloaded2/Properties/Settings.settings index ab61a45..6d11aea 100755 --- a/zaaReloaded2/Properties/Settings.settings +++ b/zaaReloaded2/Properties/Settings.settings @@ -29,5 +29,47 @@ http://www.apache.org/licenses/LICENSE-2.0 + + Standard für Station + + + 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 + \ No newline at end of file diff --git a/zaaReloaded2/ViewModels/ControlElementViewModel.cs b/zaaReloaded2/ViewModels/ControlElementViewModel.cs new file mode 100755 index 0000000..1826c42 --- /dev/null +++ b/zaaReloaded2/ViewModels/ControlElementViewModel.cs @@ -0,0 +1,50 @@ +/* ElementViewModelBase.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 Bovender.Mvvm.ViewModels; +using zaaReloaded2.Controller.Elements; +using System.Diagnostics; +using System.Collections.ObjectModel; + +namespace zaaReloaded2.ViewModels +{ + class ControlElementViewModel : ElementViewModel + { + #region Properties + + public ObservableCollection Elements + { + get { return null; } + } + + #endregion + + #region Constructors + + public ControlElementViewModel() : base() { } + + public ControlElementViewModel(ControlElementBase controlElement) + : base(controlElement) + { } + + #endregion + } +} diff --git a/zaaReloaded2/ViewModels/ElementViewModel.cs b/zaaReloaded2/ViewModels/ElementViewModel.cs new file mode 100755 index 0000000..b46a9e8 --- /dev/null +++ b/zaaReloaded2/ViewModels/ElementViewModel.cs @@ -0,0 +1,73 @@ +/* ElementViewModel.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.Diagnostics; +using System.Linq; +using System.Text; +using Bovender.Mvvm.ViewModels; +using zaaReloaded2.Controller.Elements; +using System.Collections.ObjectModel; + +namespace zaaReloaded2.ViewModels +{ + abstract class ElementViewModel : ViewModelBase + { + #region Properties + + /// + /// Gets the label of the wrapped element. + /// + public virtual string Label + { + [DebuggerStepThrough] + get + { + return Element.Label; + } + } + + #endregion + + #region Constructors + + public ElementViewModel() { } + + public ElementViewModel(ElementBase element) + { + Element = element; + } + + #endregion + + #region Protected properties + + protected ElementBase Element { get; set; } + + #endregion + + #region Implementation of ViewModelBase + + public override object RevealModelObject() + { + return Element; + } + + #endregion + } +} diff --git a/zaaReloaded2/ViewModels/FormatElementViewModel.cs b/zaaReloaded2/ViewModels/FormatElementViewModel.cs new file mode 100755 index 0000000..a7205db --- /dev/null +++ b/zaaReloaded2/ViewModels/FormatElementViewModel.cs @@ -0,0 +1,56 @@ +/* FormatElementViewModel.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.Diagnostics; +using System.Linq; +using System.Text; +using zaaReloaded2.Controller.Elements; + +namespace zaaReloaded2.ViewModels +{ + class FormatElementViewModel : ElementViewModel + { + #region Public properties + + public string Content + { + [DebuggerStepThrough] + get { return ((FormatElementBase)Element).Content; } + set + { + ((FormatElementBase)Element).Content = value; + OnPropertyChanged("Content"); + } + } + + #endregion + + #region Constructors + + public FormatElementViewModel() : base() { } + + public FormatElementViewModel(FormatElementBase formatElement) + : this() + { + Element = formatElement; + } + + #endregion + } +} diff --git a/zaaReloaded2/ViewModels/SettingsViewModel.cs b/zaaReloaded2/ViewModels/SettingsViewModel.cs new file mode 100755 index 0000000..6ab8849 --- /dev/null +++ b/zaaReloaded2/ViewModels/SettingsViewModel.cs @@ -0,0 +1,253 @@ +/* SettingsViewModel.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.Diagnostics; +using System.Linq; +using System.Text; +using Bovender.Mvvm; +using Bovender.Mvvm.ViewModels; +using zaaReloaded2.Controller; +using zaaReloaded2.Controller.Elements; +using zaaReloaded2.Formatter; + +namespace zaaReloaded2.ViewModels +{ + /// + /// View model for the zaaReloaded2.Controller.Settings class. + /// + class SettingsViewModel : ViewModelBase + { + #region Properties + + /// + /// Gets or sets the name of the Settings + /// + public string Name + { + [DebuggerStepThrough] + get + { + return _settings.Name; + } + [DebuggerStepThrough] + set + { + _settings.Name = value; + OnPropertyChanged("Name"); + } + } + + /// + /// Is true if the settings' name is editable. + /// If the settings' name is a default, preconfigured name, + /// this will be false. + /// + public bool IsNameEnabled + { + get + { + return (Name != Properties.Settings.Default.SettingsNameClinic) && + (Name != Properties.Settings.Default.SettingsNameWard); + } + } + + /// + /// Gets a list of element view models. + /// + public IList Elements + { + get + { + if (_elements == null) { _elements = new List(); } + return _elements; + } + } + + /// + /// Gets or sets the currently selected element. + /// + public ElementViewModel SelectedElement + { + get { return _selectedElement; } + set + { + _selectedElement = value; + OnPropertyChanged("SelectedElement"); + } + } + + /// + /// Returns an EnumProvider object for the ReferenceStyle + /// + public EnumProvider ReferenceStyle + { + get + { + if (_referenceStyle == null) + { + _referenceStyle = new EnumProvider(_settings.ReferenceStyle); + } + return _referenceStyle; + } + } + + #endregion + + #region Constructors + + public SettingsViewModel() + : this(new Settings()) + { } + + public SettingsViewModel(Settings settings) + : base() + { + _settings = settings; + _elements = new List(); + foreach (ElementBase element in settings.Elements) + { + ElementViewModel vm; + if (element is FormatElementBase) + { + vm = new FormatElementViewModel(element as FormatElementBase); + } + else if (element is ControlElementBase) + { + vm = new ControlElementViewModel(element as ControlElementBase); + } + else + { + throw new InvalidOperationException( + "Cannot create ViewModel for " + element.GetType().ToString()); + } + AddElementViewModel(vm); + } + } + + #endregion + + #region Messages + + #endregion + + #region Commands + + public DelegatingCommand AddElementCommand + { + get + { + if (_addElementCommand == null) + { + _addElementCommand = new DelegatingCommand( + param => DoAddElement()); + } + return _addElementCommand; + } + } + + public DelegatingCommand DeleteElementCommand + { + get + { + if (_deleteElementCommand == null) + { + _deleteElementCommand = new DelegatingCommand( + param => DoDeleteElement(), + param => CanDeleteElement()); + } + return _deleteElementCommand; + } + } + + public DelegatingCommand CopyElementCommand + { + get + { + if (_copyElementCommand == null) + { + _copyElementCommand = new DelegatingCommand( + param => DoCopyElement(), + param => CanCopyElement()); + } + return _copyElementCommand; + } + } + + #endregion + + #region Private methods + + void DoAddElement() { } + + void DoDeleteElement() { } + + bool CanDeleteElement() { return _selectedElement != null; } + + void DoCopyElement() { } + + bool CanCopyElement() { return _selectedElement != null; } + + /// + /// Internal function that creates wires the OnProperty changed event + /// of an ElementViewModel's wrapped model and adds the view model + /// to the Elements collection. + /// + void AddElementViewModel(ElementViewModel elementViewModel) + { + elementViewModel.PropertyChanged += ElementViewModel_PropertyChanged; + Elements.Add(elementViewModel); + } + + /// + /// Sets or unsets the SelectedElement property whenever the IsSelected + /// property of an ElementViewModel changes. + /// + void ElementViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + ElementViewModel vm = sender as ElementViewModel; + if (vm != null) + { + SelectedElement = vm.IsSelected ? vm : null; + } + } + + #endregion + + #region Implementation of ViewModelBase + + public override object RevealModelObject() + { + return _settings; + } + + #endregion + + #region Fields + + Settings _settings; + DelegatingCommand _addElementCommand; + DelegatingCommand _deleteElementCommand; + DelegatingCommand _copyElementCommand; + List _elements; + ElementViewModel _selectedElement; + EnumProvider _referenceStyle; + + #endregion + } +} diff --git a/zaaReloaded2/app.config b/zaaReloaded2/app.config index 8971605..400e7ef 100755 --- a/zaaReloaded2/app.config +++ b/zaaReloaded2/app.config @@ -50,6 +50,48 @@ http://www.apache.org/licenses/LICENSE-2.0 + + Standard für Station + + + 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 + diff --git a/zaaReloaded2/zaaReloaded2.csproj b/zaaReloaded2/zaaReloaded2.csproj index 1aa5e8a..0258aff 100755 --- a/zaaReloaded2/zaaReloaded2.csproj +++ b/zaaReloaded2/zaaReloaded2.csproj @@ -219,10 +219,14 @@ + + + AboutView.xaml + ResXFileCodeGenerator Resources.Designer.cs