Add Lauris paragraph parser.
This commit is contained in:
parent
39f63835be
commit
443f3ac4e1
@ -126,5 +126,14 @@ namespace Tests
|
|||||||
Assert.IsFalse(i.HasUpperLimit, "HasUpperLimit");
|
Assert.IsFalse(i.HasUpperLimit, "HasUpperLimit");
|
||||||
// TODO: Define the behavior of LabItem.IsNormal if no normal value known
|
// TODO: Define the behavior of LabItem.IsNormal if no normal value known
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase("Albumin (SU)/die: 149.9 [<= 30] mg/d; ", Material.SU)]
|
||||||
|
[TestCase("Gesamt-Eiweiss/Creatinin (PU): 281 [<= 70] mg/g Crea;", Material.U)]
|
||||||
|
[TestCase("Cystatin C (N Latex): 2.37 [0.57 - 0.96] mg/l; ", Material.B)]
|
||||||
|
public void ParseLaurisMaterial(string laurisString, Material expectedMaterial)
|
||||||
|
{
|
||||||
|
LabItem i = new LabItem(laurisString);
|
||||||
|
Assert.AreEqual(expectedMaterial, i.Material);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
36
Tests/LaurisParagraphTest.cs
Executable file
36
Tests/LaurisParagraphTest.cs
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
/* LaurisParagraphTest.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 NUnit.Framework;
|
||||||
|
using zaaReloaded2.Models;
|
||||||
|
|
||||||
|
namespace Tests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
class LaurisParagraphTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void ParseParagraph()
|
||||||
|
{
|
||||||
|
string demo = "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;";
|
||||||
|
LaurisParagraph lp = new LaurisParagraph(demo);
|
||||||
|
Assert.AreEqual(139, lp.Items["Natrium"].NumericalValue);
|
||||||
|
Assert.AreEqual(2.4, lp.Items["Calcium"].NumericalValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -59,6 +59,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Dictionaries\DictionaryTest.cs" />
|
<Compile Include="Dictionaries\DictionaryTest.cs" />
|
||||||
<Compile Include="LabItemTest.cs" />
|
<Compile Include="LabItemTest.cs" />
|
||||||
|
<Compile Include="LaurisParagraphTest.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" />
|
||||||
@ -76,6 +77,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Dictionaries\test_dictionary.txt" />
|
<EmbeddedResource Include="Dictionaries\test_dictionary.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="demo-output.txt" />
|
||||||
|
</ItemGroup>
|
||||||
<Choose>
|
<Choose>
|
||||||
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
|
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
17
Tests/demo-output.txt
Executable file
17
Tests/demo-output.txt
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
[22.10.2013 12:30:00]
|
||||||
|
Aerobe Kultur: Enterokokken ; Wachstum: 10 ;
|
||||||
|
Auftragskommentare: Untersuchungsmaterial:: Mittelstrahlurin (nativ) ; Befundstatus Auftrag: Endbefund ;
|
||||||
|
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;
|
||||||
|
Urin - Klin. Chemie: Creatinin (PU): 48.0 [40 - 278] mg/dl;
|
||||||
|
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;
|
||||||
|
Urin - Klin. Chemie: Sammelzeit (U): 24 h; Sammelmenge (U): 1850 ml;
|
||||||
|
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;
|
||||||
|
Gerinnung: Niedermol. Heparin (Anti-Xa): 0.99 U/ml;
|
||||||
|
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 %;
|
||||||
|
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): 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: 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;
|
||||||
|
Akutbestimmungen / TDM / Drogen: Tacrolimus (FK506): 10.7 µg/l;
|
||||||
|
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;
|
||||||
|
Serumproteine und Tumormarker: C-reaktives Protein: < 0.01 [0 - 0.5] mg/dl;
|
||||||
|
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] %;
|
@ -1,117 +1,114 @@
|
|||||||
# LAURIS-NAME "KANONISCHER NAME" MATERIAL "IMMER REFERENZBEREICH"
|
# LAURIS-NAME "KANONISCHER NAME" MATERIAL "IMMER REFERENZBEREICH"
|
||||||
# =========== ================== ======== =======================
|
# =========== ================== ======== =======================
|
||||||
"Lactat Dehydrogenase" LDH S
|
"Übergangsepithelien (U)" Übergangsep. U
|
||||||
"Cystatin C" --- S X
|
"a1-Microglobulin (SU)" a1-Microglobulin SU
|
||||||
"glomerul. Filtrationsr. CKD-EP" "eGFR (CKD-EPI)" S
|
"a1-Microglobulin (SU)/die" a1-Microglobulin SU
|
||||||
Übergangsepithelien (U) --- U
|
"aktuelles Bicarbonat" Bic BGA
|
||||||
a1-Microglobulin (SU) --- SU
|
"Albumin (PU)" Alb U
|
||||||
a1-Microglobulin (SU)/die --- SU
|
"Albumin (SU)" Alb SU
|
||||||
aktuelles Bicarbonat --- BGA
|
"Albumin (SU)/die" Alb SU
|
||||||
Albumin (PU) --- U
|
Albumin Alb S
|
||||||
Albumin (SU) --- SU
|
Albumin/Creatinin (PU)" ACR U
|
||||||
Albumin (SU)/die --- SU
|
"Alk. Phosphatase" AP S
|
||||||
Albumin --- S
|
Amylase Amylase S
|
||||||
Albumin/Creatinin (PU) --- U
|
anorg. Phosphat" Phosphat S
|
||||||
Alk. Phosphatase --- S
|
Bakterien (U)" Bakt U
|
||||||
Amylase --- S
|
Basenabweichung BE BGA
|
||||||
anorg. Phosphat --- S
|
Basophile Baso E
|
||||||
Bakterien (U) --- U
|
Bilirubin (U)" Bilirubin U
|
||||||
Basenabweichung --- BGA
|
C-reaktives Protein" CRP S
|
||||||
Basophile --- E
|
Calcium (SU)" Ca SU
|
||||||
Bilirubin (U) --- U
|
Calcium (SU)/die" Ca SU
|
||||||
C-reaktives Protein --- S
|
Calcium Ca S
|
||||||
Calcium (SU) --- SU
|
Calcium-Phosphat-Produkt CaxP S
|
||||||
Calcium (SU)/die --- SU
|
Cholesterin Chol S
|
||||||
Calcium --- S
|
CK gesamt" CK S
|
||||||
Calcium-Phosphat-Produkt --- S
|
CK MB" CK-MB S
|
||||||
Cholesterin --- S
|
Creatinin (PU)" Krea U
|
||||||
CK gesamt --- S
|
Creatinin (SU)" Krea SU
|
||||||
CK MB --- S
|
Creatinin Krea S
|
||||||
Creatinin (PU) --- U
|
Creatinin-Clearance (SU)/min" CrCl SU
|
||||||
Creatinin (SU) --- SU
|
Cyclosporin-A vor Gabe" "CsA (C0)" S X
|
||||||
Creatinin --- S
|
Cystatin C (N Latex)" "Cystatin C" S X
|
||||||
Creatinin-Clearance (SU)/min --- SU
|
Eisen Fe S
|
||||||
Cyclosporin-A vor Gabe --- S
|
Eosinophile Eos E
|
||||||
Cystatin C (N Latex) --- S
|
Erythrozyten (U)" Ery U
|
||||||
Eisen --- S
|
Erythrozyten Ery E
|
||||||
Eosinophile --- E
|
Ferritin Ferr S
|
||||||
Erythrozyten (U) --- U
|
Gesamt-Bilirubin Bilirubin S
|
||||||
Erythrozyten --- E
|
Gesamt-Eiweiss (PU)" Protein U
|
||||||
Ferritin --- S
|
Gesamt-Eiweiss (SU)" Protein SU
|
||||||
Gesamt-Bilirubin --- S
|
Gesamt-Eiweiss (SU)/die" Proteinurie SU
|
||||||
Gesamt-Eiweiss (PU) --- U
|
Gesamt-Eiweiss Protein S
|
||||||
Gesamt-Eiweiss (SU) --- SU
|
Gesamt-Eiweiss/Creatinin (PU)" TPCR U
|
||||||
Gesamt-Eiweiss (SU)/die --- SU
|
GGT GGT S
|
||||||
Gesamt-Eiweiss --- S
|
glomeruläre Filtrationsrate" GFR SU
|
||||||
Gesamt-Eiweiss/Creatinin (PU) --- U
|
glomerul. Filtrationsr. (MDRD)" "eGFR (MDRD)" S
|
||||||
GGT --- S
|
glomerul. Filtrationsr. CKD-EP" "eGFR (CKD-EPI)" S
|
||||||
glomeruläre Filtrationsrate --- SU
|
Glucose (U)" Glukose U
|
||||||
glomerul. Filtrationsr. (MDRD) --- S
|
Glucose Glukose S
|
||||||
glomerul. Filtrationsr. CKD-EP --- S
|
GOT (ASAT)" GOT S
|
||||||
Glucose (U) --- U
|
GPT (ALAT)" GPT S
|
||||||
Glucose --- S
|
Hämatokrit Hkt E
|
||||||
GOT (ASAT) --- S
|
Hämoglobin Hb E
|
||||||
GPT (ALAT) --- S
|
Haptoglobin Haptoglobin S X
|
||||||
Hämatokrit --- E
|
Harnsäure Harnsäure S
|
||||||
Hämoglobin --- E
|
Harnstoff (SU)" Hst SU
|
||||||
Haptoglobin --- S
|
Harnstoff (SU)/die" Hst/Tag SU
|
||||||
Harnsäure --- S
|
Harnstoff" Hst S
|
||||||
Harnstoff (SU) --- SU
|
Harnstoff-Clearance (SU)/min" HstCl SU
|
||||||
Harnstoff (SU)/die --- SU
|
HbA1c (NGSP)" HbA1c E
|
||||||
Harnstoff --- S
|
HDL - Cholesterin" HDL S
|
||||||
Harnstoff-Clearance (SU)/min --- SU
|
hyaline Zylinder (U)" "hyal. Zyl." U
|
||||||
HbA1c (NGSP) --- E
|
Kalium (SU)" K U
|
||||||
HDL - Cholesterin --- S
|
Kalium (SU)/die" K SU
|
||||||
hyaline Zylinder (U) --- U
|
Kalium K S
|
||||||
Kalium (SU) --- U
|
Ketonkörper (U)" KK U
|
||||||
Kalium (SU)/die --- SU
|
Lactat Dehydrogenase" LDH S
|
||||||
Kalium --- S
|
LDL - Cholesterin" LDL S
|
||||||
Ketonkörper (U) --- U
|
Leukozyten (U)" Leu U
|
||||||
Lactat Dehydrogenase --- S
|
Leukozyten Leu E
|
||||||
LDL - Cholesterin --- S
|
Lymphozyten Lym E
|
||||||
Leukozyten (U) --- U
|
MCH (HbE) MCH E
|
||||||
Leukozyten --- E
|
MCHC MCHC E
|
||||||
Lymphozyten --- E
|
MCV MCV E
|
||||||
MCH (HbE) --- E
|
Mittleres Plättchenvolumen MPV E
|
||||||
MCHC --- E
|
Monozyten Mon E
|
||||||
MCV --- E
|
Natrium (SU)" Na SU
|
||||||
Mittleres Plättchenvolumen --- E
|
Natrium (SU)/die" Na SU
|
||||||
Monozyten --- E
|
Natrium Na S
|
||||||
Natrium (SU) --- SU
|
Neutrophile Neu E
|
||||||
Natrium (SU)/die --- SU
|
Nitrit (U)" Nitrit U
|
||||||
Natrium --- S
|
NT-proBNP NT-proBNP S
|
||||||
Neutrophile --- E
|
PCO2 (art.)" pCO2 BGA
|
||||||
Nitrit (U) --- U
|
pH (U)" pH U
|
||||||
NT-proBNP --- S
|
pH" pH BGA
|
||||||
PCO2 (art.) --- BGA
|
Plattenepithelien (U)" Plattenep U
|
||||||
pH (U) --- U
|
PO2 (art.)" pO2 BGA
|
||||||
pH --- BGA
|
Protein (U)" Protein U
|
||||||
Plattenepithelien (U) --- U
|
Sammelmenge (U)" Volumen SU
|
||||||
PO2 (art.) --- BGA
|
Sammelzeit (U)" Zeit SU
|
||||||
Protein (U) --- U
|
Sauerstoffsättigung (art.)" SO2 BGA
|
||||||
Sammelmenge (U) --- SU
|
Sirolimus SIR S
|
||||||
Sammelzeit (U) --- SU
|
spezifisches Gewicht (U)" "spez. Gew." U
|
||||||
Sauerstoffsättigung (art.) --- BGA
|
Standard Bicarbonat" "Std.-Bic." BGA
|
||||||
Sirolimus --- S
|
Tacrolimus (FK506)" TAC S
|
||||||
spezifisches Gewicht (U) --- U
|
Thrombozyten Thr E
|
||||||
Standard Bicarbonat --- BGA
|
Transferrin Transferrin S
|
||||||
Tacrolimus (FK506) --- S
|
Transferrinsättigung" Tf.-Sätt. S
|
||||||
Thrombozyten --- E
|
Triglyceride" TG S
|
||||||
Transferrin --- S
|
Troponin T (high sensitive)" hsTnT S
|
||||||
Transferrinsättigung --- S
|
Unreife Granulozyten" Gran E
|
||||||
Triglyceride --- S
|
Urobilinogen (U)" Urobilinogen U
|
||||||
Troponin T (high sensitive) --- S
|
Niedermol. Heparin (Anti-Xa)" Anti-Xa Z
|
||||||
Unreife Granulozyten --- E
|
Thromboplastinzeit n. Quick" Quick Z
|
||||||
Urobilinogen (U) --- U
|
PTT aPTT Z
|
||||||
Niedermol. Heparin (Anti-Xa) --- Z
|
Ratio int. norm." INR Z
|
||||||
Thromboplastinzeit n. Quick --- Z
|
Komplementfaktor C3c C3c S X
|
||||||
PTT --- Z
|
Komplementfaktor C4 C4 S X
|
||||||
Ratio int. norm. --- Z
|
Anti-DNAse B "Anti-DNAse B" S
|
||||||
Komplementfaktor C3c --- S
|
Anti-Streptolysin ASL S
|
||||||
Komplementfaktor C4 --- S
|
PTH intakt" iPTH S
|
||||||
Anti-DNAse B --- S
|
TSH TSH S
|
||||||
Anti-Streptolysin --- S
|
HAPTOGLOBIN Haptoglobin S
|
||||||
PTH intakt --- S
|
FRAGMENTOZYTEN Fragmentozyten E
|
||||||
TSH --- S
|
|
||||||
HAPTOGLOBIN --- S
|
|
||||||
FRAGMENTOZYTEN --- E
|
|
||||||
|
@ -30,7 +30,7 @@ namespace zaaReloaded2.Dictionaries
|
|||||||
/// canonical parameter names, and to assign categories and determine
|
/// canonical parameter names, and to assign categories and determine
|
||||||
/// which parameters always require the output of reference intervals.
|
/// which parameters always require the output of reference intervals.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class ParameterDictionary : DictionaryBase
|
public class ParameterDictionary : DictionaryBase
|
||||||
{
|
{
|
||||||
#region Public methods
|
#region Public methods
|
||||||
|
|
||||||
@ -49,19 +49,18 @@ namespace zaaReloaded2.Dictionaries
|
|||||||
/// Looks up the material for a given <paramref name="laurisName"/>.
|
/// Looks up the material for a given <paramref name="laurisName"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="laurisName">Lauris item name to look up.</param>
|
/// <param name="laurisName">Lauris item name to look up.</param>
|
||||||
/// <returns><see cref="zaaReloaded2.Models.Materials"/> enum; if no material is
|
/// <returns><see cref="zaaReloaded2.Models.Material"/> enum; if no material is
|
||||||
/// found in the dictionary, the default material "S" (serum) is returned.</returns>
|
/// found in the dictionary, the default material "S" (serum) is returned.</returns>
|
||||||
public Materials GetMaterial(string laurisName)
|
public Material GetMaterial(string laurisName)
|
||||||
{
|
{
|
||||||
string textValue = LookUpValue(laurisName, 2);
|
string textValue = LookUpValue(laurisName, 2);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Materials m = (Materials)Enum.Parse(typeof(Materials), textValue, true);
|
return MaterialFactory.FromAbbreviation(textValue);
|
||||||
return m;
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return Materials.S;
|
return Material.B;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ namespace zaaReloaded2.Dictionaries
|
|||||||
/// Dictionary that is used to convert Lauris units to canonical
|
/// Dictionary that is used to convert Lauris units to canonical
|
||||||
/// zaaReloaded2 units.
|
/// zaaReloaded2 units.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class UnitDictionary : DictionaryBase
|
public class UnitDictionary : DictionaryBase
|
||||||
{
|
{
|
||||||
#region Public methods
|
#region Public methods
|
||||||
|
|
||||||
|
@ -172,9 +172,29 @@ namespace zaaReloaded2.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string CanonicalName { get; private set; }
|
public string CanonicalName { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the canonical name prefixed with the abbreviation
|
||||||
|
/// for the material, e.g. "U-Na" for sodium in the spot urine,
|
||||||
|
/// but only if the material is not blood.
|
||||||
|
/// </summary>
|
||||||
|
public string QualifiedCanonicalName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (Material == Models.Material.B)
|
||||||
|
{
|
||||||
|
return CanonicalName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return String.Format("{0}-{1}", Material.ToString(), CanonicalName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool AlwaysPrintLimits { get; private set; }
|
public bool AlwaysPrintLimits { get; private set; }
|
||||||
|
|
||||||
public Materials Material { get; private set; }
|
public Material Material { get; private set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -185,15 +205,11 @@ namespace zaaReloaded2.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public LabItem() { }
|
public LabItem() { }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a LabItem object from a given Lauris output.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="laurisString">Lauris output to parse.</param>
|
|
||||||
public LabItem(string laurisString)
|
public LabItem(string laurisString)
|
||||||
:this()
|
|
||||||
{
|
{
|
||||||
Lauris = laurisString;
|
Lauris = laurisString;
|
||||||
ParseLauris();
|
ParseLauris();
|
||||||
|
DetectMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -203,15 +219,27 @@ namespace zaaReloaded2.Models
|
|||||||
/// to always print the reference interval).
|
/// to always print the reference interval).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="laurisString">Lauris output to parse.</param>
|
/// <param name="laurisString">Lauris output to parse.</param>
|
||||||
/// <param name="dictionary">ParameterDictionary that is used
|
/// <param name="parameterDictionary">ParameterDictionary that is used
|
||||||
/// to look up the canonical name, material type, and whether or
|
/// to look up the canonical name, material type, and whether or
|
||||||
/// not to always print the reference interval</param>
|
/// not to always print the reference interval</param>
|
||||||
public LabItem(string laurisString, Dictionaries.ParameterDictionary dictionary)
|
public LabItem(string laurisString,
|
||||||
|
Dictionaries.ParameterDictionary parameterDictionary,
|
||||||
|
Dictionaries.UnitDictionary unitDictionary)
|
||||||
: this(laurisString)
|
: this(laurisString)
|
||||||
{
|
{
|
||||||
CanonicalName = dictionary.GetCanonicalName(Name);
|
if (parameterDictionary != null)
|
||||||
AlwaysPrintLimits = dictionary.GetForceReferenceDisplay(Name);
|
{
|
||||||
Material = dictionary.GetMaterial(Name);
|
CanonicalName = parameterDictionary.GetCanonicalName(Name);
|
||||||
|
AlwaysPrintLimits = parameterDictionary.GetForceReferenceDisplay(Name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CanonicalName = Name;
|
||||||
|
}
|
||||||
|
if (unitDictionary != null)
|
||||||
|
{
|
||||||
|
Unit = unitDictionary.TranslateLaurisUnit(Unit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -222,7 +250,7 @@ namespace zaaReloaded2.Models
|
|||||||
/// Parses the original Lauris string contained in
|
/// Parses the original Lauris string contained in
|
||||||
/// <see cref="Lauris"/>.
|
/// <see cref="Lauris"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void ParseLauris()
|
void ParseLauris()
|
||||||
{
|
{
|
||||||
// Examples of Lauris output strings:
|
// Examples of Lauris output strings:
|
||||||
// "Natrium: 139 [135 - 145] mmol/l"
|
// "Natrium: 139 [135 - 145] mmol/l"
|
||||||
@ -294,6 +322,32 @@ namespace zaaReloaded2.Models
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Analyses the Lauris name for a material abbreviation.
|
||||||
|
/// If the parameter does not refer to blood (serum, whole
|
||||||
|
/// blood, etc.), Lauris appends an abbreviation in parentheses
|
||||||
|
/// to the parameter name.
|
||||||
|
/// </summary>
|
||||||
|
/// <example>
|
||||||
|
/// Gesamt-Eiweiss (SU), Albumin (SU)/die, Gesamt-Eiweiss (PU)
|
||||||
|
/// </example>
|
||||||
|
void DetectMaterial()
|
||||||
|
{
|
||||||
|
Match m = _materialRegex.Match(Name);
|
||||||
|
if (m.Success)
|
||||||
|
{
|
||||||
|
switch (m.Groups["material"].Value.ToUpper())
|
||||||
|
{
|
||||||
|
case "SU":
|
||||||
|
Material = Models.Material.SU;
|
||||||
|
break;
|
||||||
|
case "PU":
|
||||||
|
Material = Models.Material.U;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Fields
|
#region Fields
|
||||||
@ -301,6 +355,7 @@ namespace zaaReloaded2.Models
|
|||||||
double _numericalValue;
|
double _numericalValue;
|
||||||
double _lowerLimit;
|
double _lowerLimit;
|
||||||
double _upperLimit;
|
double _upperLimit;
|
||||||
|
static readonly Regex _materialRegex = new Regex(@"\((?<material>(SU|PU))\)");
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
129
zaaReloaded2/Models/LaurisParagraph.cs
Executable file
129
zaaReloaded2/Models/LaurisParagraph.cs
Executable file
@ -0,0 +1,129 @@
|
|||||||
|
/* LaurisParagraph.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.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace zaaReloaded2.Models
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Parses an entire Lauris paragraph (such as "Klinische Chemie: ...")
|
||||||
|
/// and creates a list of <see cref="LabItem"/>s.
|
||||||
|
/// </summary>
|
||||||
|
public class LaurisParagraph
|
||||||
|
{
|
||||||
|
#region Public properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a collection of <see cref="LabItem"/>s found in this paragraph.
|
||||||
|
/// </summary>
|
||||||
|
public IDictionary<string, LabItem> Items { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the caption that was extracted from the <see cref="OriginalParagraph"/>,
|
||||||
|
/// e.g. "Klin. Chemie" in "Klin. Chemie: Natrium ...".
|
||||||
|
/// </summary>
|
||||||
|
public string Caption { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the original paragraph that this object was constructed from.
|
||||||
|
/// </summary>
|
||||||
|
public string OriginalParagraph { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Is true if the <see cref="OriginalParagraph"/> matches the expected
|
||||||
|
/// format and contains <see cref="LabItem"/>s.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsLaurisParagraph { get; private set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
|
|
||||||
|
public LaurisParagraph(string paragraph)
|
||||||
|
{
|
||||||
|
OriginalParagraph = paragraph;
|
||||||
|
Parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a <see cref="LaurisParagraph"/> object from a given
|
||||||
|
/// Lauris paragraph, using a <paramref name="parameterDictionary"/>
|
||||||
|
/// and a <paramref name="unitDictionary"/> to translate the individual
|
||||||
|
/// items' properties.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="paragraph">lauris paragraph to parse.</param>
|
||||||
|
/// <param name="parameterDictionary">ParameterDictionary that contains
|
||||||
|
/// canonical names and material types.</param>
|
||||||
|
/// <param name="unitDictionary">Unit dictionary that contains canonical
|
||||||
|
/// unit names.</param>
|
||||||
|
public LaurisParagraph(string paragraph,
|
||||||
|
Dictionaries.ParameterDictionary parameterDictionary,
|
||||||
|
Dictionaries.UnitDictionary unitDictionary)
|
||||||
|
{
|
||||||
|
OriginalParagraph = paragraph;
|
||||||
|
_parameterDictionary = parameterDictionary;
|
||||||
|
_unitDictionary = unitDictionary;
|
||||||
|
Parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to parse a Lauris paragraph.
|
||||||
|
/// </summary>
|
||||||
|
void Parse()
|
||||||
|
{
|
||||||
|
Match m = _expectedFormat.Match(OriginalParagraph);
|
||||||
|
if (m.Success)
|
||||||
|
{
|
||||||
|
Items = new Dictionary<string, LabItem>();
|
||||||
|
if (m.Groups["caption"].Success)
|
||||||
|
{
|
||||||
|
Caption = m.Groups["caption"].Value.Trim(new char[] {' ', ':'});
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (Capture itemCapture in m.Groups["items"].Captures)
|
||||||
|
{
|
||||||
|
LabItem i = new LabItem(itemCapture.Value, _parameterDictionary, _unitDictionary);
|
||||||
|
Items.Add(i.QualifiedCanonicalName, i);
|
||||||
|
}
|
||||||
|
IsLaurisParagraph = Items.Count > 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IsLaurisParagraph = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Fields
|
||||||
|
|
||||||
|
static readonly Regex _expectedFormat = new Regex(@"(?<caption>[^:]+:\s*)?(?<items>[^:]+:\s*[^;]+;)*");
|
||||||
|
Dictionaries.ParameterDictionary _parameterDictionary;
|
||||||
|
Dictionaries.UnitDictionary _unitDictionary;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@ -26,34 +26,32 @@ namespace zaaReloaded2.Models
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Enumerates the known materials.
|
/// Enumerates the known materials.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
enum Materials
|
public enum Material
|
||||||
{
|
{
|
||||||
[Description("Serum")]
|
[Description("Blut")]
|
||||||
/// Serum
|
/// Blood
|
||||||
S,
|
B,
|
||||||
[Description("Plasma")]
|
|
||||||
/// Plasma
|
|
||||||
P,
|
|
||||||
[Description("EDTA-Blut")]
|
|
||||||
/// EDTA-Blut
|
|
||||||
E,
|
|
||||||
[Description("BGA")]
|
|
||||||
/// BGA
|
|
||||||
BGA,
|
|
||||||
[Description("Zitrat")]
|
|
||||||
/// Zitrat-Blut
|
|
||||||
Z,
|
|
||||||
[Description("Laktat")]
|
|
||||||
/// Laktat-Blut
|
|
||||||
L,
|
|
||||||
[Description("Urin")]
|
[Description("Urin")]
|
||||||
/// Urin (Spoturin)
|
/// Urine (spot)
|
||||||
U,
|
U,
|
||||||
[Description("Sammelurin")]
|
[Description("Sammelurin")]
|
||||||
/// Sammelurin
|
/// Collected urine
|
||||||
SU,
|
SU,
|
||||||
[Description("Sondermaterial")]
|
}
|
||||||
/// Sondermaterial
|
|
||||||
X
|
/// <summary>
|
||||||
|
/// Contains factory methods to create Material values.
|
||||||
|
/// </summary>
|
||||||
|
public static class MaterialFactory
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a <see cref="Material"/> value from an abbreviation of a material.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="abbreviation">Abbreviation of a material.</param>
|
||||||
|
/// <returns>Materials value.</returns>
|
||||||
|
public static Material FromAbbreviation(string abbreviation)
|
||||||
|
{
|
||||||
|
return (Material)Enum.Parse(typeof(Material), abbreviation, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -165,7 +165,8 @@
|
|||||||
<Compile Include="Dictionaries\ParameterDictionary.cs" />
|
<Compile Include="Dictionaries\ParameterDictionary.cs" />
|
||||||
<Compile Include="Dictionaries\UnitDictionary.cs" />
|
<Compile Include="Dictionaries\UnitDictionary.cs" />
|
||||||
<Compile Include="Models\LabItem.cs" />
|
<Compile Include="Models\LabItem.cs" />
|
||||||
<Compile Include="Models\Materials.cs" />
|
<Compile Include="Models\LaurisParagraph.cs" />
|
||||||
|
<Compile Include="Models\Material.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs">
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
Loading…
Reference in New Issue
Block a user