Add Lauris paragraph parser.
This commit is contained in:
		@@ -1,117 +1,114 @@
 | 
			
		||||
# LAURIS-NAME                      "KANONISCHER NAME"   MATERIAL   "IMMER REFERENZBEREICH"
 | 
			
		||||
# ===========                      ==================   ========   =======================
 | 
			
		||||
"Lactat Dehydrogenase"             LDH                  S
 | 
			
		||||
"Cystatin C"                       ---                  S          X
 | 
			
		||||
"glomerul.  Filtrationsr. CKD-EP"  "eGFR (CKD-EPI)"     S 
 | 
			
		||||
Übergangsepithelien (U)            ---                  U
 | 
			
		||||
a1-Microglobulin (SU)              ---                  SU
 | 
			
		||||
a1-Microglobulin (SU)/die          ---                  SU
 | 
			
		||||
aktuelles Bicarbonat               ---                  BGA
 | 
			
		||||
Albumin (PU)                       ---                  U
 | 
			
		||||
Albumin (SU)                       ---                  SU
 | 
			
		||||
Albumin (SU)/die                   ---                  SU
 | 
			
		||||
Albumin                            ---                  S
 | 
			
		||||
Albumin/Creatinin (PU)             ---                  U
 | 
			
		||||
Alk. Phosphatase                   ---                  S
 | 
			
		||||
Amylase                            ---                  S
 | 
			
		||||
anorg. Phosphat                    ---                  S
 | 
			
		||||
Bakterien (U)                      ---                  U
 | 
			
		||||
Basenabweichung                    ---                  BGA
 | 
			
		||||
Basophile                          ---                  E
 | 
			
		||||
Bilirubin (U)                      ---                  U
 | 
			
		||||
C-reaktives Protein                ---                  S
 | 
			
		||||
Calcium (SU)                       ---                  SU
 | 
			
		||||
Calcium (SU)/die                   ---                  SU
 | 
			
		||||
Calcium                            ---                  S
 | 
			
		||||
Calcium-Phosphat-Produkt           ---                  S
 | 
			
		||||
Cholesterin                        ---                  S
 | 
			
		||||
CK gesamt                          ---                  S
 | 
			
		||||
CK MB                              ---                  S
 | 
			
		||||
Creatinin (PU)                     ---                  U
 | 
			
		||||
Creatinin (SU)                     ---                  SU
 | 
			
		||||
Creatinin                          ---                  S
 | 
			
		||||
Creatinin-Clearance (SU)/min       ---                  SU
 | 
			
		||||
Cyclosporin-A vor Gabe             ---                  S
 | 
			
		||||
Cystatin C (N Latex)               ---                  S
 | 
			
		||||
Eisen                              ---                  S
 | 
			
		||||
Eosinophile                        ---                  E
 | 
			
		||||
Erythrozyten (U)                   ---                  U
 | 
			
		||||
Erythrozyten                       ---                  E
 | 
			
		||||
Ferritin                           ---                  S
 | 
			
		||||
Gesamt-Bilirubin                   ---                  S
 | 
			
		||||
Gesamt-Eiweiss (PU)                ---                  U
 | 
			
		||||
Gesamt-Eiweiss (SU)                ---                  SU
 | 
			
		||||
Gesamt-Eiweiss (SU)/die            ---                  SU
 | 
			
		||||
Gesamt-Eiweiss                     ---                  S
 | 
			
		||||
Gesamt-Eiweiss/Creatinin (PU)      ---                  U
 | 
			
		||||
GGT                                ---                  S
 | 
			
		||||
glomeruläre Filtrationsrate        ---                  SU
 | 
			
		||||
glomerul. Filtrationsr. (MDRD)     ---                  S
 | 
			
		||||
glomerul. Filtrationsr. CKD-EP     ---                  S
 | 
			
		||||
Glucose (U)                        ---                  U
 | 
			
		||||
Glucose                            ---                  S
 | 
			
		||||
GOT (ASAT)                         ---                  S
 | 
			
		||||
GPT (ALAT)                         ---                  S
 | 
			
		||||
Hämatokrit                         ---                  E
 | 
			
		||||
Hämoglobin                         ---                  E
 | 
			
		||||
Haptoglobin                        ---                  S
 | 
			
		||||
Harnsäure                          ---                  S
 | 
			
		||||
Harnstoff (SU)                     ---                  SU
 | 
			
		||||
Harnstoff (SU)/die                 ---                  SU
 | 
			
		||||
Harnstoff                          ---                  S
 | 
			
		||||
Harnstoff-Clearance (SU)/min       ---                  SU
 | 
			
		||||
HbA1c (NGSP)                       ---                  E
 | 
			
		||||
HDL - Cholesterin                  ---                  S
 | 
			
		||||
hyaline Zylinder (U)               ---                  U
 | 
			
		||||
Kalium (SU)                        ---                  U
 | 
			
		||||
Kalium (SU)/die                    ---                  SU
 | 
			
		||||
Kalium                             ---                  S
 | 
			
		||||
Ketonkörper (U)                    ---                  U
 | 
			
		||||
Lactat Dehydrogenase               ---                  S
 | 
			
		||||
LDL - Cholesterin                  ---                  S
 | 
			
		||||
Leukozyten (U)                     ---                  U
 | 
			
		||||
Leukozyten                         ---                  E
 | 
			
		||||
Lymphozyten                        ---                  E
 | 
			
		||||
MCH (HbE)                          ---                  E
 | 
			
		||||
MCHC                               ---                  E
 | 
			
		||||
MCV                                ---                  E
 | 
			
		||||
Mittleres Plättchenvolumen         ---                  E
 | 
			
		||||
Monozyten                          ---                  E
 | 
			
		||||
Natrium (SU)                       ---                  SU
 | 
			
		||||
Natrium (SU)/die                   ---                  SU
 | 
			
		||||
Natrium                            ---                  S
 | 
			
		||||
Neutrophile                        ---                  E
 | 
			
		||||
Nitrit (U)                         ---                  U
 | 
			
		||||
NT-proBNP                          ---                  S
 | 
			
		||||
PCO2 (art.)                        ---                  BGA
 | 
			
		||||
pH (U)                             ---                  U
 | 
			
		||||
pH                                 ---                  BGA
 | 
			
		||||
Plattenepithelien (U)              ---                  U
 | 
			
		||||
PO2 (art.)                         ---                  BGA
 | 
			
		||||
Protein (U)                        ---                  U
 | 
			
		||||
Sammelmenge (U)                    ---                  SU
 | 
			
		||||
Sammelzeit (U)                     ---                  SU
 | 
			
		||||
Sauerstoffsättigung (art.)         ---                  BGA
 | 
			
		||||
Sirolimus                          ---                  S
 | 
			
		||||
spezifisches Gewicht (U)           ---                  U
 | 
			
		||||
Standard Bicarbonat                ---                  BGA
 | 
			
		||||
Tacrolimus (FK506)                 ---                  S
 | 
			
		||||
Thrombozyten                       ---                  E
 | 
			
		||||
Transferrin                        ---                  S
 | 
			
		||||
Transferrinsättigung               ---                  S
 | 
			
		||||
Triglyceride                       ---                  S
 | 
			
		||||
Troponin T (high sensitive)        ---                  S
 | 
			
		||||
Unreife Granulozyten               ---                  E
 | 
			
		||||
Urobilinogen (U)                   ---                  U
 | 
			
		||||
Niedermol. Heparin (Anti-Xa)       ---                  Z
 | 
			
		||||
Thromboplastinzeit n. Quick        ---                  Z
 | 
			
		||||
PTT                                ---                  Z
 | 
			
		||||
Ratio int. norm.                   ---                  Z
 | 
			
		||||
Komplementfaktor C3c               ---                  S
 | 
			
		||||
Komplementfaktor C4                ---                  S
 | 
			
		||||
Anti-DNAse B                       ---                  S
 | 
			
		||||
Anti-Streptolysin                  ---                  S
 | 
			
		||||
PTH intakt                         ---                  S
 | 
			
		||||
TSH                                ---                  S
 | 
			
		||||
HAPTOGLOBIN                        ---                  S
 | 
			
		||||
FRAGMENTOZYTEN                     ---                  E
 | 
			
		||||
"Übergangsepithelien (U)"          Übergangsep.         U
 | 
			
		||||
"a1-Microglobulin (SU)"            a1-Microglobulin     SU
 | 
			
		||||
"a1-Microglobulin (SU)/die"        a1-Microglobulin     SU
 | 
			
		||||
"aktuelles Bicarbonat"             Bic                  BGA
 | 
			
		||||
"Albumin (PU)"                     Alb                  U
 | 
			
		||||
"Albumin (SU)"                     Alb                  SU
 | 
			
		||||
"Albumin (SU)/die"                 Alb                  SU
 | 
			
		||||
Albumin                            Alb                  S
 | 
			
		||||
Albumin/Creatinin (PU)"            ACR                  U
 | 
			
		||||
"Alk. Phosphatase"                 AP                   S
 | 
			
		||||
Amylase                            Amylase              S
 | 
			
		||||
anorg. Phosphat"                   Phosphat             S
 | 
			
		||||
Bakterien (U)"                     Bakt                 U
 | 
			
		||||
Basenabweichung                    BE                   BGA
 | 
			
		||||
Basophile                          Baso                 E
 | 
			
		||||
Bilirubin (U)"                     Bilirubin            U
 | 
			
		||||
C-reaktives Protein"               CRP                  S
 | 
			
		||||
Calcium (SU)"                      Ca                   SU
 | 
			
		||||
Calcium (SU)/die"                  Ca                   SU
 | 
			
		||||
Calcium                            Ca                   S
 | 
			
		||||
Calcium-Phosphat-Produkt           CaxP                 S
 | 
			
		||||
Cholesterin                        Chol                 S
 | 
			
		||||
CK gesamt"                         CK                   S
 | 
			
		||||
CK MB"                             CK-MB                S
 | 
			
		||||
Creatinin (PU)"                    Krea                 U
 | 
			
		||||
Creatinin (SU)"                    Krea                 SU
 | 
			
		||||
Creatinin                          Krea                 S
 | 
			
		||||
Creatinin-Clearance (SU)/min"      CrCl                 SU
 | 
			
		||||
Cyclosporin-A vor Gabe"            "CsA (C0)"           S      X
 | 
			
		||||
Cystatin C (N Latex)"              "Cystatin C"         S      X
 | 
			
		||||
Eisen                              Fe                   S
 | 
			
		||||
Eosinophile                        Eos                  E
 | 
			
		||||
Erythrozyten (U)"                  Ery                  U
 | 
			
		||||
Erythrozyten                       Ery                  E
 | 
			
		||||
Ferritin                           Ferr                 S
 | 
			
		||||
Gesamt-Bilirubin                   Bilirubin            S
 | 
			
		||||
Gesamt-Eiweiss (PU)"               Protein              U
 | 
			
		||||
Gesamt-Eiweiss (SU)"               Protein              SU
 | 
			
		||||
Gesamt-Eiweiss (SU)/die"           Proteinurie          SU
 | 
			
		||||
Gesamt-Eiweiss                     Protein              S
 | 
			
		||||
Gesamt-Eiweiss/Creatinin (PU)"     TPCR                 U
 | 
			
		||||
GGT                                GGT                  S
 | 
			
		||||
glomeruläre Filtrationsrate"       GFR                  SU
 | 
			
		||||
glomerul. Filtrationsr. (MDRD)"    "eGFR (MDRD)"        S
 | 
			
		||||
glomerul. Filtrationsr. CKD-EP"    "eGFR (CKD-EPI)"     S
 | 
			
		||||
Glucose (U)"                       Glukose              U
 | 
			
		||||
Glucose                            Glukose              S
 | 
			
		||||
GOT (ASAT)"                        GOT                  S
 | 
			
		||||
GPT (ALAT)"                        GPT                  S
 | 
			
		||||
Hämatokrit                         Hkt                  E
 | 
			
		||||
Hämoglobin                         Hb                   E
 | 
			
		||||
Haptoglobin                        Haptoglobin          S      X
 | 
			
		||||
Harnsäure                          Harnsäure            S
 | 
			
		||||
Harnstoff (SU)"                    Hst                  SU
 | 
			
		||||
Harnstoff (SU)/die"                Hst/Tag              SU
 | 
			
		||||
Harnstoff"                         Hst                  S
 | 
			
		||||
Harnstoff-Clearance (SU)/min"      HstCl                SU
 | 
			
		||||
HbA1c (NGSP)"                      HbA1c                E
 | 
			
		||||
HDL - Cholesterin"                 HDL                  S
 | 
			
		||||
hyaline Zylinder (U)"              "hyal. Zyl."         U
 | 
			
		||||
Kalium (SU)"                       K                    U
 | 
			
		||||
Kalium (SU)/die"                   K                    SU
 | 
			
		||||
Kalium                             K                    S
 | 
			
		||||
Ketonkörper (U)"                   KK                   U
 | 
			
		||||
Lactat Dehydrogenase"              LDH                  S
 | 
			
		||||
LDL - Cholesterin"                 LDL                  S
 | 
			
		||||
Leukozyten (U)"                    Leu                  U
 | 
			
		||||
Leukozyten                         Leu                  E
 | 
			
		||||
Lymphozyten                        Lym                  E
 | 
			
		||||
MCH (HbE)                          MCH                  E
 | 
			
		||||
MCHC                               MCHC                 E
 | 
			
		||||
MCV                                MCV                  E
 | 
			
		||||
Mittleres Plättchenvolumen         MPV                  E
 | 
			
		||||
Monozyten                          Mon                  E
 | 
			
		||||
Natrium (SU)"                      Na                   SU
 | 
			
		||||
Natrium (SU)/die"                  Na                   SU
 | 
			
		||||
Natrium                            Na                   S
 | 
			
		||||
Neutrophile                        Neu                  E
 | 
			
		||||
Nitrit (U)"                        Nitrit               U
 | 
			
		||||
NT-proBNP                          NT-proBNP            S
 | 
			
		||||
PCO2 (art.)"                       pCO2                 BGA
 | 
			
		||||
pH (U)"                            pH                   U
 | 
			
		||||
pH"                                pH                   BGA
 | 
			
		||||
Plattenepithelien (U)"             Plattenep            U
 | 
			
		||||
PO2 (art.)"                        pO2                  BGA
 | 
			
		||||
Protein (U)"                       Protein              U
 | 
			
		||||
Sammelmenge (U)"                   Volumen              SU
 | 
			
		||||
Sammelzeit (U)"                    Zeit                 SU
 | 
			
		||||
Sauerstoffsättigung (art.)"        SO2                  BGA
 | 
			
		||||
Sirolimus                          SIR                  S
 | 
			
		||||
spezifisches Gewicht (U)"          "spez. Gew."         U
 | 
			
		||||
Standard Bicarbonat"               "Std.-Bic."          BGA
 | 
			
		||||
Tacrolimus (FK506)"                TAC                  S
 | 
			
		||||
Thrombozyten                       Thr                  E
 | 
			
		||||
Transferrin                        Transferrin          S
 | 
			
		||||
Transferrinsättigung"              Tf.-Sätt.            S
 | 
			
		||||
Triglyceride"                      TG                   S
 | 
			
		||||
Troponin T (high sensitive)"       hsTnT                S
 | 
			
		||||
Unreife Granulozyten"              Gran                 E
 | 
			
		||||
Urobilinogen (U)"                  Urobilinogen         U
 | 
			
		||||
Niedermol. Heparin (Anti-Xa)"      Anti-Xa              Z
 | 
			
		||||
Thromboplastinzeit n. Quick"       Quick                Z
 | 
			
		||||
PTT                                aPTT                 Z
 | 
			
		||||
Ratio int. norm."                  INR                  Z
 | 
			
		||||
Komplementfaktor C3c               C3c                  S     X
 | 
			
		||||
Komplementfaktor C4                C4                   S     X
 | 
			
		||||
Anti-DNAse B                       "Anti-DNAse B"       S
 | 
			
		||||
Anti-Streptolysin                  ASL                  S
 | 
			
		||||
PTH intakt"                        iPTH                 S
 | 
			
		||||
TSH                                TSH                  S
 | 
			
		||||
HAPTOGLOBIN                        Haptoglobin          S
 | 
			
		||||
FRAGMENTOZYTEN                     Fragmentozyten       E
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,7 @@ namespace zaaReloaded2.Dictionaries
 | 
			
		||||
    /// canonical parameter names, and to assign categories and determine
 | 
			
		||||
    /// which parameters always require the output of reference intervals.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    class ParameterDictionary : DictionaryBase
 | 
			
		||||
    public class ParameterDictionary : DictionaryBase
 | 
			
		||||
    {
 | 
			
		||||
        #region Public methods
 | 
			
		||||
 | 
			
		||||
@@ -49,19 +49,18 @@ namespace zaaReloaded2.Dictionaries
 | 
			
		||||
        /// Looks up the material for a given <paramref name="laurisName"/>.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <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>
 | 
			
		||||
        public Materials GetMaterial(string laurisName)
 | 
			
		||||
        public Material GetMaterial(string laurisName)
 | 
			
		||||
        {
 | 
			
		||||
            string textValue = LookUpValue(laurisName, 2);
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                Materials m = (Materials)Enum.Parse(typeof(Materials), textValue, true);
 | 
			
		||||
                return m;
 | 
			
		||||
                return MaterialFactory.FromAbbreviation(textValue);
 | 
			
		||||
            }
 | 
			
		||||
            catch
 | 
			
		||||
            {
 | 
			
		||||
                return Materials.S;
 | 
			
		||||
                return Material.B;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,7 @@ namespace zaaReloaded2.Dictionaries
 | 
			
		||||
    /// Dictionary that is used to convert Lauris units to canonical
 | 
			
		||||
    /// zaaReloaded2 units.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    class UnitDictionary : DictionaryBase
 | 
			
		||||
    public class UnitDictionary : DictionaryBase
 | 
			
		||||
    {
 | 
			
		||||
        #region Public methods
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -172,9 +172,29 @@ namespace zaaReloaded2.Models
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        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 Materials Material { get; private set; }
 | 
			
		||||
        public Material Material { get; private set; }
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
@@ -185,15 +205,11 @@ namespace zaaReloaded2.Models
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        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)
 | 
			
		||||
            :this()
 | 
			
		||||
        {
 | 
			
		||||
            Lauris = laurisString;
 | 
			
		||||
            ParseLauris();
 | 
			
		||||
            DetectMaterial();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
@@ -203,15 +219,27 @@ namespace zaaReloaded2.Models
 | 
			
		||||
        /// to always print the reference interval).
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <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
 | 
			
		||||
        /// 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)
 | 
			
		||||
        {
 | 
			
		||||
            CanonicalName = dictionary.GetCanonicalName(Name);
 | 
			
		||||
            AlwaysPrintLimits = dictionary.GetForceReferenceDisplay(Name);
 | 
			
		||||
            Material = dictionary.GetMaterial(Name);
 | 
			
		||||
            if (parameterDictionary != null)
 | 
			
		||||
            {
 | 
			
		||||
                CanonicalName = parameterDictionary.GetCanonicalName(Name);
 | 
			
		||||
                AlwaysPrintLimits = parameterDictionary.GetForceReferenceDisplay(Name);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                CanonicalName = Name;
 | 
			
		||||
            }
 | 
			
		||||
            if (unitDictionary != null)
 | 
			
		||||
            {
 | 
			
		||||
                Unit = unitDictionary.TranslateLaurisUnit(Unit);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
@@ -222,7 +250,7 @@ namespace zaaReloaded2.Models
 | 
			
		||||
        /// Parses the original Lauris string contained in
 | 
			
		||||
        /// <see cref="Lauris"/>.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private void ParseLauris()
 | 
			
		||||
        void ParseLauris()
 | 
			
		||||
        {
 | 
			
		||||
            // Examples of Lauris output strings:
 | 
			
		||||
            // "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
 | 
			
		||||
 | 
			
		||||
        #region Fields
 | 
			
		||||
@@ -301,6 +355,7 @@ namespace zaaReloaded2.Models
 | 
			
		||||
        double _numericalValue;
 | 
			
		||||
        double _lowerLimit;
 | 
			
		||||
        double _upperLimit;
 | 
			
		||||
        static readonly Regex _materialRegex = new Regex(@"\((?<material>(SU|PU))\)");
 | 
			
		||||
 | 
			
		||||
        #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>
 | 
			
		||||
    /// Enumerates the known materials.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    enum Materials
 | 
			
		||||
    public enum Material
 | 
			
		||||
    {
 | 
			
		||||
        [Description("Serum")]
 | 
			
		||||
        /// Serum
 | 
			
		||||
        S,
 | 
			
		||||
        [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("Blut")]
 | 
			
		||||
        /// Blood
 | 
			
		||||
        B,
 | 
			
		||||
        [Description("Urin")]
 | 
			
		||||
        /// Urin (Spoturin)
 | 
			
		||||
        /// Urine (spot)
 | 
			
		||||
        U,
 | 
			
		||||
        [Description("Sammelurin")]
 | 
			
		||||
        /// Sammelurin
 | 
			
		||||
        /// Collected urine
 | 
			
		||||
        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\UnitDictionary.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">
 | 
			
		||||
      <SubType>Code</SubType>
 | 
			
		||||
    </Compile>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user