Merge branch 'decimals' into develop

This commit is contained in:
Daniel Kraus 2015-08-25 20:26:41 +02:00
commit 7b9157320a
6 changed files with 89 additions and 23 deletions

View File

@ -1,5 +1,5 @@
# LAURIS-NAME "KANONISCHER NAME" MATERIAL "IMMER REFERENZBEREICH" "BLACKLIST"
# =========== ================== ======== ======================= ===========
# LAURIS-NAME "KANONISCHER NAME" MATERIAL DEZIMALSTELLEN "IMMER REFERENZBEREICH" "BLACKLIST"
# =========== ================== ======== ============== ======================= ===========
"Übergangsepithelien (U)" Übergangsep. U
"a1-Microglobulin (SU)" a1-Microglobulin SU
"a1-Microglobulin (SU)/die" a1-Microglobulin SU
@ -9,7 +9,7 @@
"Albumin (SU)/die" Alb SU
Albumin Alb S
"Albumin/Creatinin (PU)" ACR U
"Alk. Phosphatase" AP S
"Alk. Phosphatase" AP S 0
Amylase Amylase S
"anorg. Phosphat" P S
"Bakterien (U)" Bakt U
@ -24,9 +24,9 @@ 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 (PU)" Krea U 0
"Creatinin (SU)" Krea SU 0
Creatinin Krea S 1
"Creatinin-Clearance (SU)/min" CrCl SU
"Cyclosporin-A vor Gabe" "CsA (C0)" S X
"Cystatin C (N Latex)" "Cystatin C" S X
@ -44,14 +44,14 @@ Gesamt-Bilirubin Bilirubin S
"Gesamt-Eiweiss (SU)/die" Proteinurie SU
Gesamt-Eiweiss Protein S
"Gesamt-Eiweiss/Creatinin (PU)" TPCR U
GGT GGT S
GGT GGT S 0
"glomeruläre Filtrationsrate" GFR SU
"glomerul. Filtrationsr. (MDRD)" "eGFR (MDRD)" S --- X
"glomerul. Filtrationsr. CKD-EP" "eGFR (CKD-EPI)" S
"Glucose (U)" Glukose U
Glucose Glukose S
"GOT (ASAT)" GOT S
"GPT (ALAT)" GPT S
"GOT (ASAT)" GOT S 0
"GPT (ALAT)" GPT S 0
Hämatokrit Hkt E
Hämoglobin Hb E
Haptoglobin Haptoglobin S X

View File

@ -153,8 +153,17 @@ namespace zaaReloaded2.Formatter
{
// Format the numerical value; this will convert
// decimal points to commas as needed.
int precision = LabItem.PreferredPrecision;
if (precision >= 0)
{
value = LabItem.NumericalValue.ToString("F" + precision);
}
else
{
// PreferredPrecision is negative, i.e. use precision as-is
value = String.Format("{0}", LabItem.NumericalValue);
}
}
else
{
value = LabItem.Value;

View File

@ -77,6 +77,7 @@ namespace zaaReloaded2.Importer.ZaaImporter
AlwaysPrintLimits = parameterDictionary.GetForceReferenceDisplay(OriginalName);
IsBlacklisted = parameterDictionary.GetIsBlacklisted(OriginalName);
Material = parameterDictionary.GetMaterial(OriginalName, Material);
PreferredPrecision = parameterDictionary.GetPrecision(OriginalName);
}
if (unitDictionary != null)
{

View File

@ -202,6 +202,8 @@ namespace zaaReloaded2.LabModel
}
}
public int PreferredPrecision { get; protected set; }
public bool AlwaysPrintLimits { get; protected set; }
public Material Material { get; protected set; }

View File

@ -89,6 +89,18 @@ namespace zaaReloaded2.Thesaurus
}
}
/// <summary>
/// Returns the desired number of decimals for a given parameter.
/// </summary>
/// <param name="laurisName">Laboratory item to look up;
/// this must be an original Lauris string.</param>
/// <returns>Number of decimals for the parameter, or -1 if
/// undefined.</returns>
public int GetPrecision(string laurisName)
{
return LookUpValue(laurisName, 3, -1);
}
/// <summary>
/// Returns whether or not reference limits shall always
/// be displayed for a given item, regardless whether it
@ -99,7 +111,7 @@ namespace zaaReloaded2.Thesaurus
/// <returns></returns>
public bool GetForceReferenceDisplay(string laurisName)
{
return LookUpValue(laurisName, 3, false);
return LookUpValue(laurisName, 4, false);
}
/// <summary>
@ -112,7 +124,7 @@ namespace zaaReloaded2.Thesaurus
/// false if not. Default is false.</returns>
public bool GetIsBlacklisted(string laurisName)
{
return LookUpValue(laurisName, 4, false);
return LookUpValue(laurisName, 5, false);
}
#endregion

View File

@ -153,6 +153,48 @@ namespace zaaReloaded2.Thesaurus
catch { }
}
/// <summary>
/// Looks up a dictionary key and returns an integer value from the requested field,
/// or a default value if the field is empty or contains only dashes.
/// </summary>
/// <param name="key">Key to look up.</param>
/// <param name="fieldNum">Zero-based index of the field to look up
/// (note that field 0 is the key itself).</param>
/// <param name="defaultValue">Default value that will be returned
/// if the field is empty or contains only dashes.</param>
/// <returns>Value of the requested field, or <paramref name="defaultValue"/>
/// if the field is empty or contains only dashes.</returns>
/// <exception cref="System.IndexOutOfRangeException">if fieldNum is negative.</exception>
protected int LookUpValue(string key, int fieldNum, int defaultValue)
{
string[] record;
if (Records.TryGetValue(key, out record))
{
if (fieldNum >= record.Length) return defaultValue;
string value = record[fieldNum];
if (string.IsNullOrWhiteSpace(value) || _dashes.IsMatch(value))
{
return defaultValue;
}
else
{
int intval;
if (int.TryParse(value, out intval))
{
return intval;
}
else
{
return defaultValue;
}
}
}
else
{
return defaultValue;
}
}
/// <summary>
/// Looks up a dictionary key and returns the value from the requested field,
/// or a default value if the field is empty or contains only dashes.