Implement Laboratory and TimePoints.
This commit is contained in:
parent
2cf31914dd
commit
07ee4fbf2a
49
Tests/Importer/ZaaImporter/ZaaImporterTest.cs
Executable file
49
Tests/Importer/ZaaImporter/ZaaImporterTest.cs
Executable file
@ -0,0 +1,49 @@
|
|||||||
|
/* ZaaImporterTest.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.IO;
|
||||||
|
using zaa = zaaReloaded2.Importer.ZaaImporter;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Tests.Importer.ZaaImporter
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
class ZaaImporterTest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Parses the demo-output.txt file that is built into the assembly.
|
||||||
|
/// Note that this demo text contains seven time points, only six of
|
||||||
|
/// which are distinct. Thus, the two time points with identical time
|
||||||
|
/// stamps should be merged in the <see cref="Laboratory"/>.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void ParseTimePoints()
|
||||||
|
{
|
||||||
|
Stream s = this.GetType().Assembly.GetManifestResourceStream("Tests.demo-output.txt");
|
||||||
|
StreamReader r = new StreamReader(s);
|
||||||
|
zaa.ZaaImporter importer = new zaa.ZaaImporter();
|
||||||
|
importer.Import(r.ReadToEnd());
|
||||||
|
|
||||||
|
// Only 6 distinct time points (see method documentation above).
|
||||||
|
Assert.AreEqual(6, importer.Laboratory.TimePoints.Count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -66,6 +66,7 @@
|
|||||||
<Compile Include="Dictionaries\DictionaryTest.cs" />
|
<Compile Include="Dictionaries\DictionaryTest.cs" />
|
||||||
<Compile Include="Importer\ZaaImporter\LaurisItemTest.cs" />
|
<Compile Include="Importer\ZaaImporter\LaurisItemTest.cs" />
|
||||||
<Compile Include="Importer\ZaaImporter\LaurisParagraphTest.cs" />
|
<Compile Include="Importer\ZaaImporter\LaurisParagraphTest.cs" />
|
||||||
|
<Compile Include="Importer\ZaaImporter\ZaaImporterTest.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="LineParserTest.cs" />
|
<Compile Include="LineParserTest.cs" />
|
||||||
<Compile Include="Dictionaries\TestDictionary.cs" />
|
<Compile Include="Dictionaries\TestDictionary.cs" />
|
||||||
|
@ -1,17 +1,27 @@
|
|||||||
[22.10.2013 12:30:00]
|
# This file contains 7 time points.
|
||||||
Aerobe Kultur: Enterokokken ; Wachstum: 10 ;
|
# This leading text should be ignored.
|
||||||
Auftragskommentare: Untersuchungsmaterial:: Mittelstrahlurin (nativ) ; Befundstatus Auftrag: Endbefund ;
|
# DO NOT CHANGE THE FOLLOWING TEXT, LEST THE TESTS WILL FAIL!
|
||||||
Urinproteine quantitativ: Gesamt-Eiweiss (PU): 135 [<= 120] mg/l; Gesamt-Eiweiss/Creatinin (PU): 281 [<= 70] mg/g Crea; Albumin (PU): 57 [<= 30] mg/l; Albumin/Creatinin (PU): 118.8 [<= 30] mg/g Crea;
|
(06.07.2015 15:16:00)
|
||||||
Urin - Klin. Chemie: Creatinin (PU): 48.0 [40 - 278] mg/dl;
|
Urin - Klin. Chemie: Sammelzeit (U): 24 h; Sammelmenge (U): 1300 ml; Natrium (SU): 107.8 [54 - 150] mmol/l; Natrium (SU)/die: 140.1 [40 - 220] mmol/d;
|
||||||
Urinproteine quantitativ: Gesamt-Eiweiss (SU): 184 [<= 120] mg/l; Gesamt-Eiweiss (SU)/die: 340 [<= 150] mg/d; Albumin (SU): 81 mg/l; Albumin (SU)/die: 149.9 [<= 30] mg/d; a1-Microglobulin (SU): 35.3 mg/l; a1-Microglobulin (SU)/die: 65.3 [<= 20] mg/d; Immunglobulin G (SU): 8 mg/l; Immunglobulin G (SU)/die: 14.8 [<= 15] mg/d;
|
(06.07.2015 13:39:00)
|
||||||
Urin - Klin. Chemie: Sammelzeit (U): 24 h; Sammelmenge (U): 1850 ml;
|
Urin - Klin. Chemie: Creatinin (PU): 153.7 [40 - 278] mg/dl;
|
||||||
Klinische Chemie: Natrium: 139 [135 - 145] mmol/l; Kalium: 5.2 [3.5 - 5] mmol/l; Calcium: 2.4 [2.0 - 2.7] mmol/l; anorg. Phosphat: 0.58 [0.87 - 1.45] mmol/l; Calcium-Phosphat-Produkt: 1.39 [<= 4.4] mmol²/l²; Glucose: 112 [74 - 106] mg/dl; glomerul. Filtrationsr. CKD-EP: 42 ml/min /1,73qm; glomerul. Filtrationsr. (MDRD): 42 ml/min /1,73qm; Creatinin: 1.84 [0 - 1.17] mg/dl; Harnstoff: 54.3 [10 - 50] mg/dl; Harnsäure: 4.6 [3.4 - 7] mg/dl; Gesamt-Bilirubin: 0.7 [0.1 - 1.2] mg/dl; GOT (ASAT): 303.0 [<= 50] U/l; GPT (ALAT): 508.0 [<= 50] U/l; GGT: 489.0 [<= 60] U/l; Alk. Phosphatase: 56 [40 - 130] U/l; Lactat Dehydrogenase: 320 [<= 250] U/l; CK gesamt: 52 [<= 190] U/l; Amylase: 62 [<= 110] U/l; Cholesterin: 120 [130 - 220] mg/dl; Triglyceride: 94 [74 - 172] mg/dl; LDL - Cholesterin: 56 [0 - 150] mg/dl; HDL - Cholesterin: 45 [>= 35] mg/dl; Eisen: 215 [59 - 158] µg/dl; Gesamt-Eiweiss: 5.7 [6.6 - 8.7] g/dl; Albumin: 4.0 [3.5 - 5.5] g/dl;
|
(06.07.2015 12:31:00)
|
||||||
Gerinnung: Niedermol. Heparin (Anti-Xa): 0.99 U/ml;
|
Klinische Chemie: Natrium: 144 [135 - 145] mmol/l; Kalium: 4.3 [3.5 - 5] mmol/l; Calcium: 2.3 [2.0 - 2.7] mmol/l; Korrigiertes Calcium: 2.3 [2.0 - 2.7] mmol/l; Magnesium: 0.87 [0.7 - 1.05] mmol/l; anorg. Phosphat: 0.98 [0.87 - 1.45] mmol/l; Calcium-Phosphat-Produkt: 2.25 [<= 4.4] mmol²/l²; Glucose: 93 [74 - 106] mg/dl; glomerul. Filtrationsr. CKD-EP: 56 ml/min /1,73qm; glomerul. Filtrationsr. (MDRD): 54 ml/min /1,73qm; Creatinin: 1.52 [0 - 1.17] mg/dl; Harnstoff: 41.1 [10 - 50] mg/dl; Harnsäure: 7.7 [3.4 - 7] mg/dl; Gesamt-Bilirubin: 0.2 [0.1 - 1.2] mg/dl; GOT (ASAT): 22.2 [<= 50] U/l; GPT (ALAT): 28.0 [<= 50] U/l; GGT: 49.0 [<= 60] U/l; Alk. Phosphatase: 70 [40 - 130] U/l; Lactat Dehydrogenase: 205 [<= 250] U/l; Cholesterin: 219 [130 - 220] mg/dl; Triglyceride: 195 [74 - 172] mg/dl; LDL - Cholesterin: 141 [0 - 150] mg/dl; HDL - Cholesterin: 39 [>= 35] mg/dl; Albumin: 4.1 [3.5 - 5.5] g/dl;
|
||||||
Hämatologie: Leukozyten: 2.9 [5 - 10] n*1000/µl; Erythrozyten: 3.23 [4 - 6] n*10E6/µl; Hämoglobin: 10.1 [14 - 18] g/dl; Hämatokrit: 30.8 [42 - 50] %; MCV: 95.4 [82 - 94] fl; MCH (HbE): 31.3 [27 - 33] pg; MCHC: 32.8 [32 - 36] g/dl; Thrombozyten: 112 [150 - 450] n*1000/µl; Mittleres Plättchenvolumen: 11.1 [9.7 - 11.9] fl; Neutrophile: 74.4 [41 - 70] %; Lymphozyten: 13.0 [25 - 40] %; Monozyten: 11.3 [2 - 8] %; Eosinophile: 1.0 [0.8 - 6.2] %; Basophile: 0.3 [0 - 1] %; Neutrophile: 2.18 [1.8 - 7.2] n*1000/µl; Lymphozyten: 0.38 [1 - 4.05] n*1000/µl; Monozyten: 0.33 [0.08 - 0.8] n*1000/µl; Eosinophile: 0.0 [0.04 - 0.36] n*1000/µl; Basophile: 0.0 [0 - 0.08] n*1000/µl; Unreife Granulozyten: 0.3 %;
|
Hämatologie: Leukozyten: 7.2 [5 - 10] n*1000/µl; Erythrozyten: 4.79 [4 - 6] n*10E6/µl; Hämoglobin: 14.0 [14 - 18] g/dl; Hämatokrit: 41.0 [42 - 50] %; MCV: 85.6 [82 - 94] fl; MCH (HbE): 29.2 [27 - 33] pg; MCHC: 34.1 [32 - 36] g/dl; Thrombozyten: 269 [150 - 450] n*1000/µl; Mittleres Plättchenvolumen: 10.3 [9.7 - 11.9] fl;
|
||||||
Urinproteine quantitativ: Gesamt-Eiweiss (SU): 186 [<= 120] mg/l; Gesamt-Eiweiss (SU)/die: 344 [<= 150] mg/d; Albumin (SU): 79 mg/l; Albumin (SU)/die: 146.2 [<= 30] mg/d;
|
Urin - Klin. Chemie: Sammelzeit (U): 24 h; Sammelmenge (U): 1300 ml; Creatinin-Clearance (SU)/min: 90 [98 - 156] ml/min; Harnstoff-Clearance (SU)/min: 40 [60 - 80] ml/min; glomeruläre Filtrationsrate: 65 ml/min; Calcium (SU): 0.64 mmol/l; Calcium (SU)/die: 0.83 [2.5 - 8] mmol/d; Creatinin (SU): 151.5 mg/dl; Harnstoff (SU): 1831 [900 - 3000] mg/dl; Harnstoff (SU)/die: 23.8 [<= 35] g/d; Kalium (SU): 39.2 [20 - 80] mmol/l; Kalium (SU)/die: 50.96 [25 - 125] mmol/d; Natrium (SU): 108.1 [54 - 150] mmol/l; Natrium (SU)/die: 140.5 [40 - 220] mmol/d;
|
||||||
Urin - Klin. Chemie: Sammelzeit (U): 24 h; Sammelmenge (U): 1850 ml; Creatinin-Clearance (SU)/min: 46 [98 - 156] ml/min; Harnstoff-Clearance (SU)/min: 21 [60 - 80] ml/min; glomeruläre Filtrationsrate: 34 ml/min; Calcium (SU): 0.79 mmol/l; Calcium (SU)/die: 1.46 [2.5 - 8] mmol/d; Creatinin (SU): 65.5 mg/dl; Harnstoff (SU): 904 [900 - 3000] mg/dl; Harnstoff (SU)/die: 16.7 [<= 35] g/d; Kalium (SU): 24.4 [20 - 80] mmol/l; Kalium (SU)/die: 45.14 [25 - 125] mmol/d; Natrium (SU): 133.2 [54 - 150] mmol/l; Natrium (SU)/die: 246.4 [40 - 220] mmol/d;
|
Serumproteine und Tumormarker: C-reaktives Protein: 0.71 [0 - 0.5] mg/dl;
|
||||||
Serumproteine und Tumormarker: Ferritin: 3754 [30 - 400] µg/l; Transferrin: 217 [200 - 380] mg/dl; Transferrinsättigung: 70.2 [16 - 45] %; Haptoglobin: < 10 [34 - 200] mg/dl; C-reaktives Protein: < 0.01 [0 - 0.5] mg/dl; Cystatin C (N Latex): 2.37 [0.57 - 0.96] mg/l;
|
(06.07.2015 13:29:00)
|
||||||
Akutbestimmungen / TDM / Drogen: Tacrolimus (FK506): 10.7 µg/l;
|
Hepatitis Serologie: HBs-Antikörper: neg. ;
|
||||||
Klinische Chemie: Natrium: 140 [135 - 145] mmol/l; Kalium: 5.2 [3.5 - 5] mmol/l; Calcium: 2.3 [2.0 - 2.7] mmol/l; anorg. Phosphat: 0.59 [0.87 - 1.45] mmol/l; Chlorid: 109 [94 - 110] mmol/l; Glucose: 114 [74 - 106] mg/dl; glomerul. Filtrationsr. CKD-EP: 42 ml/min /1,73qm; glomerul. Filtrationsr. (MDRD): 42 ml/min /1,73qm; Creatinin: 1.85 [0 - 1.17] mg/dl; Harnstoff: 56.1 [10 - 50] mg/dl; Cholinesterase: 3387 [5320 - 12920] U/l; Lactat Dehydrogenase: 318 [<= 250] U/l; Gesamt-Eiweiss: 5.7 [6.6 - 8.7] g/dl; Albumin: 3.9 [3.5 - 5.5] g/dl;
|
(06.07.2015 12:20:00)
|
||||||
Serumproteine und Tumormarker: C-reaktives Protein: < 0.01 [0 - 0.5] mg/dl;
|
Schilddrüse: TSH: 1.30 [0.3 - 4.0] mIU/l;
|
||||||
Akutbestimmungen / TDM / Drogen: PO2 (art.): 64.0 [70 - 100] mmHg; PCO2 (art.): 36.3 [36 - 44] mmHg; pH: 7.393 [7.36 - 7.44] ; Basenabweichung: -2.4 [-2 - 2] mmol/l; aktuelles Bicarbonat: 21.6 [22 - 26] mmol/l; Standard Bicarbonat: 22.4 [22 - 26] mmol/l; Sauerstoffsättigung (art.): 95.8 [95 - 99] %;
|
Ca-Phosphat-Stoffwechsel: PTH intakt: 56.1 [12 - 65] ng/l;
|
||||||
|
(06.07.2015 10:28:00)
|
||||||
|
Urinproteine quantitativ: Gesamt-Eiweiss (SU): < 40 [<= 120] mg/l; Albumin (SU): < 12 mg/l; a1-Microglobulin (SU): < 6 mg/l;
|
||||||
|
Urin - Klin. Chemie: Sammelzeit (U): 24 h; Sammelmenge (U): 2900 ml; Natrium (SU): < 20 [54 - 150] mmol/l;
|
||||||
|
(06.07.2015 10:28:00)
|
||||||
|
Klinische Chemie: Natrium: 138 [135 - 145] mmol/l; Kalium: 4.6 [3.5 - 5] mmol/l; Calcium: 2.5 [2.0 - 2.7] mmol/l; Korrigiertes Calcium: 2.3 [2.0 - 2.7] mmol/l; Magnesium: 0.78 [0.7 - 1.05] mmol/l; anorg. Phosphat: 0.82 [0.87 - 1.45] mmol/l; Calcium-Phosphat-Produkt: 2.05 [<= 4.4] mmol²/l²; Glucose: 96 [82 - 115] mg/dl; glomerul. Filtrationsr. CKD-EP: 92 ml/min /1,73qm; glomerul. Filtrationsr. (MDRD): 97 ml/min /1,73qm; Creatinin: 0.84 [0 - 1.17] mg/dl; Harnstoff: 17.5 [10 - 50] mg/dl; Harnsäure: 7.0 [3.4 - 7] mg/dl; Gesamt-Bilirubin: 0.9 [0.1 - 1.2] mg/dl; GOT (ASAT): 34.1 [<= 50] U/l; GPT (ALAT): 39.0 [<= 50] U/l; GGT: 24.7 [<= 60] U/l; Alk. Phosphatase: 58 [40 - 130] U/l; Lactat Dehydrogenase: 180 [<= 250] U/l; Cholesterin: 156 [130 - 220] mg/dl; Triglyceride: 113 [74 - 172] mg/dl; LDL - Cholesterin: 84 [0 - 150] mg/dl; HDL - Cholesterin: 49 [>= 35] mg/dl; Albumin: 4.7 [3.5 - 5.5] g/dl;
|
||||||
|
Hämatologie: Leukozyten: 8.3 [5 - 10] n*1000/µl; Erythrozyten: 5.51 [4 - 6] n*10E6/µl; Hämoglobin: 16.0 [14 - 18] g/dl; Hämatokrit: 45.6 [42 - 50] %; MCV: 82.8 [82 - 94] fl; MCH (HbE): 29.0 [27 - 33] pg; MCHC: 35.1 [32 - 36] g/dl; Thrombozyten: 154 [150 - 450] n*1000/µl; Mittleres Plättchenvolumen: 9.5 [9.7 - 11.9] fl; Neutrophile abs.: 3.32 n*1000/µl; Lymphozyten abs.: 4.23 n*1000/µl; Segmentkernige: 40 [50 - 70] %; Eosinophile: 2 [0 - 6] %; Basophile: 1 [0 - 1.0] %; Lymphozyten: 51 [25 - 40] %; Monozyten: 6 [2 - 8] %; Neutrophile: 50.9 [41 - 70] %; Lymphozyten: 32.1 [25 - 40] %; Monozyten: 15.6 [2 - 8] %; Eosinophile: 1.2 [0.8 - 6.2] %; Basophile: 0.2 [0 - 1] %; Neutrophile: 4.23 [1.8 - 7.2] n*1000/µl; Lymphozyten: 2.67 [1 - 4.05] n*1000/µl; Monozyten: 1.30 [0.08 - 0.8] n*1000/µl; Eosinophile: 0.1 [0.04 - 0.36] n*1000/µl; Basophile: 0.0 [0 - 0.08] n*1000/µl; Unreife Granulozyten: 0.2 %;
|
||||||
|
Urinproteine quantitativ: Gesamt-Eiweiss (SU): < 40 [<= 120] mg/l; Albumin (SU): < 12 mg/l;
|
||||||
|
Urin - Klin. Chemie: Sammelzeit (U): 24 h; Sammelmenge (U): 2900 ml; Creatinin-Clearance (SU)/min: 84 [98 - 156] ml/min; Harnstoff-Clearance (SU)/min: 52 [60 - 80] ml/min; glomeruläre Filtrationsrate: 68 ml/min; Calcium (SU): 0.71 mmol/l; Calcium (SU)/die: 2.06 [2.5 - 8] mmol/d; Creatinin (SU): 35.2 mg/dl; Harnstoff (SU): 454 [900 - 3000] mg/dl; Harnstoff (SU)/die: 13.2 [<= 35] g/d; Kalium (SU): 14.5 [20 - 80] mmol/l; Kalium (SU)/die: 42.05 [25 - 125] mmol/d; Natrium (SU): < 20 [54 - 150] mmol/l;
|
||||||
|
Serumproteine und Tumormarker: C-reaktives Protein: 0.13 [0 - 0.5] mg/dl;
|
||||||
|
Akutbestimmungen / TDM / Drogen: Tacrolimus (FK506): 6.2 µg/l;
|
||||||
|
@ -108,7 +108,7 @@ namespace zaaReloaded2.Importer.ZaaImporter
|
|||||||
foreach (Capture itemCapture in m.Groups["items"].Captures)
|
foreach (Capture itemCapture in m.Groups["items"].Captures)
|
||||||
{
|
{
|
||||||
LaurisItem i = new LaurisItem(itemCapture.Value, _parameterDictionary, _unitDictionary);
|
LaurisItem i = new LaurisItem(itemCapture.Value, _parameterDictionary, _unitDictionary);
|
||||||
Items.Add(i.QualifiedName, i);
|
Items[i.QualifiedName] = i;
|
||||||
}
|
}
|
||||||
IsLaurisParagraph = Items.Count > 0;
|
IsLaurisParagraph = Items.Count > 0;
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,52 @@ namespace zaaReloaded2.Importer.ZaaImporter
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
class LaurisTimePoint : TimePoint
|
class LaurisTimePoint : TimePoint
|
||||||
{
|
{
|
||||||
|
#region Static methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Examines a string and returns true if it resembles
|
||||||
|
/// a time stamp line in the Lauris output.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="line">Line to examine.</param>
|
||||||
|
/// <returns>True if line resembles a time stamp line
|
||||||
|
/// in the Lauris output.</returns>
|
||||||
|
static public bool IsTimeStampLine(string line)
|
||||||
|
{
|
||||||
|
return _timeStampRegex.IsMatch(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a Regex object that matches a Lauris time stamp
|
||||||
|
/// line.
|
||||||
|
/// </summary>
|
||||||
|
static public Regex TimeStampRegex
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _timeStampRegex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets an array of paragraphs in this LaurisText.
|
/// Gets an array of paragraphs in this LaurisText.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] Paragraphs { get; private set; }
|
public string[] Paragraphs
|
||||||
|
{
|
||||||
|
[DebuggerStepThrough]
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _paragraphs;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_paragraphs = value;
|
||||||
|
ParseParagraphs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Is true if the LaurisText has time stamp in the first
|
/// Is true if the LaurisText has time stamp in the first
|
||||||
@ -62,7 +102,6 @@ namespace zaaReloaded2.Importer.ZaaImporter
|
|||||||
Paragraphs = value.Split(
|
Paragraphs = value.Split(
|
||||||
new string[] { Environment.NewLine },
|
new string[] { Environment.NewLine },
|
||||||
StringSplitOptions.None);
|
StringSplitOptions.None);
|
||||||
ParseParagraphs();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,23 +112,35 @@ namespace zaaReloaded2.Importer.ZaaImporter
|
|||||||
|
|
||||||
public LaurisTimePoint() { }
|
public LaurisTimePoint() { }
|
||||||
|
|
||||||
public LaurisTimePoint(string laurisTest)
|
|
||||||
: this()
|
|
||||||
{
|
|
||||||
_parameterDictionary = null;
|
|
||||||
_unitDictionary = null;
|
|
||||||
LaurisText = laurisTest;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LaurisTimePoint(
|
public LaurisTimePoint(
|
||||||
string laurisTest,
|
string laurisText,
|
||||||
ParameterDictionary parameterDictionary,
|
ParameterDictionary parameterDictionary,
|
||||||
UnitDictionary unitDictionary)
|
UnitDictionary unitDictionary)
|
||||||
: this()
|
: this()
|
||||||
{
|
{
|
||||||
_parameterDictionary = parameterDictionary;
|
_parameterDictionary = parameterDictionary;
|
||||||
_unitDictionary = unitDictionary;
|
_unitDictionary = unitDictionary;
|
||||||
LaurisText = laurisTest;
|
LaurisText = laurisText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LaurisTimePoint(string laurisText)
|
||||||
|
: this(laurisText, null, null)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
public LaurisTimePoint(
|
||||||
|
string[] paragraphs,
|
||||||
|
ParameterDictionary parameterDictionary,
|
||||||
|
UnitDictionary unitDictionary)
|
||||||
|
: this()
|
||||||
|
{
|
||||||
|
_parameterDictionary = parameterDictionary;
|
||||||
|
_unitDictionary = unitDictionary;
|
||||||
|
Paragraphs = paragraphs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LaurisTimePoint(string[] paragraphs)
|
||||||
|
: this(paragraphs, null, null)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -139,7 +190,7 @@ namespace zaaReloaded2.Importer.ZaaImporter
|
|||||||
if (Paragraphs.Length == 0)
|
if (Paragraphs.Length == 0)
|
||||||
throw new InvalidOperationException("The time point has no paragraphs.");
|
throw new InvalidOperationException("The time point has no paragraphs.");
|
||||||
|
|
||||||
Match m = _dateStampRegex.Match(Paragraphs[0]);
|
Match m = _timeStampRegex.Match(Paragraphs[0]);
|
||||||
bool success = false;
|
bool success = false;
|
||||||
if (m.Success)
|
if (m.Success)
|
||||||
{
|
{
|
||||||
@ -158,7 +209,7 @@ namespace zaaReloaded2.Importer.ZaaImporter
|
|||||||
|
|
||||||
void AddItems(IItemDictionary items)
|
void AddItems(IItemDictionary items)
|
||||||
{
|
{
|
||||||
|
Items.Merge(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -169,8 +220,9 @@ namespace zaaReloaded2.Importer.ZaaImporter
|
|||||||
/// A regular expression that matches the time stamp in the first
|
/// A regular expression that matches the time stamp in the first
|
||||||
/// paragraph of a LaurisText.
|
/// paragraph of a LaurisText.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static readonly Regex _dateStampRegex = new Regex(
|
static readonly Regex _timeStampRegex = new Regex(
|
||||||
@"^\s*\[?\s*(?<datetime>\d\d\.\d\d\.\d\d\d\d\s+\d\d:\d\d)");
|
@"^\s*\(?\s*(?<datetime>\d\d\.\d\d\.\d\d\d\d\s+\d\d:\d\d)");
|
||||||
|
string[] _paragraphs;
|
||||||
ParameterDictionary _parameterDictionary;
|
ParameterDictionary _parameterDictionary;
|
||||||
UnitDictionary _unitDictionary;
|
UnitDictionary _unitDictionary;
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Bovender.Extensions;
|
||||||
using zaaReloaded2.LabModel;
|
using zaaReloaded2.LabModel;
|
||||||
|
|
||||||
namespace zaaReloaded2.Importer.ZaaImporter
|
namespace zaaReloaded2.Importer.ZaaImporter
|
||||||
@ -34,21 +35,68 @@ namespace zaaReloaded2.Importer.ZaaImporter
|
|||||||
|
|
||||||
public Laboratory Laboratory
|
public Laboratory Laboratory
|
||||||
{
|
{
|
||||||
|
[DebuggerStepThrough]
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if (_laboratory == null)
|
||||||
|
{
|
||||||
|
_laboratory = new Laboratory();
|
||||||
|
}
|
||||||
|
return _laboratory;
|
||||||
}
|
}
|
||||||
|
[DebuggerStepThrough]
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
_laboratory = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Import(string text)
|
public void Import(string text)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
string[] paragraphs = text.Split(
|
||||||
|
new string[] { Environment.NewLine },
|
||||||
|
StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
int i = 0;
|
||||||
|
int start = 0;
|
||||||
|
int numParagraphs = paragraphs.Length;
|
||||||
|
|
||||||
|
while (i < numParagraphs)
|
||||||
|
{
|
||||||
|
// Search for the next occurrence of a time stamp line
|
||||||
|
while (i < numParagraphs
|
||||||
|
&& !LaurisTimePoint.IsTimeStampLine(paragraphs[i]))
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Find an alternative to returning in the middle of the method.
|
||||||
|
if (i >= numParagraphs) return;
|
||||||
|
|
||||||
|
if (LaurisTimePoint.IsTimeStampLine(paragraphs[i]))
|
||||||
|
{
|
||||||
|
// Remember the time stamp line's index
|
||||||
|
start = i;
|
||||||
|
|
||||||
|
// Seek the next time stamp line
|
||||||
|
while (i + 1 < numParagraphs
|
||||||
|
&& !LaurisTimePoint.IsTimeStampLine(paragraphs[i + 1]))
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Laboratory.AddTimePoint(
|
||||||
|
new LaurisTimePoint(paragraphs.Slice(start, i - start + 1))
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Fields
|
||||||
|
|
||||||
|
Laboratory _laboratory;
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,5 +32,40 @@ namespace zaaReloaded2.LabModel
|
|||||||
public SortedDictionary<DateTime, TimePoint> TimePoints { get; set; }
|
public SortedDictionary<DateTime, TimePoint> TimePoints { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
|
|
||||||
|
public Laboratory()
|
||||||
|
{
|
||||||
|
TimePoints = new SortedDictionary<DateTime, TimePoint>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a new time point with laboratory items to the laboratory.
|
||||||
|
/// If a time point with same time stamp exists already, the new
|
||||||
|
/// items will be added to the existing ones.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="timePoint">Time point to add to the laboratory.</param>
|
||||||
|
public void AddTimePoint(TimePoint timePoint)
|
||||||
|
{
|
||||||
|
if (timePoint == null)
|
||||||
|
throw new ArgumentNullException("timePoint");
|
||||||
|
|
||||||
|
TimePoint tp;
|
||||||
|
if (TimePoints.TryGetValue(timePoint.TimeStamp, out tp))
|
||||||
|
{
|
||||||
|
tp.MergeItems(timePoint);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TimePoints[timePoint.TimeStamp] = timePoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,5 +48,25 @@ namespace zaaReloaded2.LabModel
|
|||||||
public IItemDictionary Items { get; set; }
|
public IItemDictionary Items { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds the items from another time point to this
|
||||||
|
/// time point. There is no check for plausibility,
|
||||||
|
/// i.e. the other time point may have a different
|
||||||
|
/// time stamp.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="otherTimePoint">Other TimePoint to
|
||||||
|
/// merge into the current one.</param>
|
||||||
|
public void MergeItems(TimePoint otherTimePoint)
|
||||||
|
{
|
||||||
|
if (otherTimePoint == null)
|
||||||
|
throw new ArgumentNullException("otherTimePoint");
|
||||||
|
|
||||||
|
Items.Merge(otherTimePoint.Items);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,24 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
packages.config
|
||||||
|
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.
|
||||||
|
-->
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Bovender" version="0.1.0.0" targetFramework="net40" />
|
<package id="Bovender" version="0.2.0.0" targetFramework="net40" />
|
||||||
<package id="Expression.Blend.Sdk" version="1.0.2" targetFramework="net40" />
|
<package id="Expression.Blend.Sdk" version="1.0.2" targetFramework="net40" />
|
||||||
</packages>
|
</packages>
|
@ -111,6 +111,9 @@
|
|||||||
-->
|
-->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Accessibility" />
|
<Reference Include="Accessibility" />
|
||||||
|
<Reference Include="Bovender">
|
||||||
|
<HintPath>..\packages\Bovender.0.2.0.0\lib\net40\Bovender.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
@ -187,6 +190,7 @@
|
|||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<None Include="packages.config" />
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
Loading…
Reference in New Issue
Block a user