/* ParameterDictionary.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.Reflection;
using System.Text;
using System.IO;
using zaaReloaded2.LabModel;
namespace zaaReloaded2.Dictionaries
{
///
/// Dictionary that is used to convert Lauris parameter names to
/// canonical parameter names, and to assign categories and determine
/// which parameters always require the output of reference intervals.
///
public class ParameterDictionary : DictionaryBase
{
#region Public methods
///
/// Looks up the canonical name for a given .
///
/// Lauris item name to look up.
/// Canonical name, or original Lauris name if no canonical name
/// is defined for this item.
public string GetCanonicalName(string laurisName)
{
return LookUpValue(laurisName, 1, laurisName);
}
///
/// Looks up the material for a given .
///
/// Lauris item name to look up.
/// enum; if no material is
/// found in the dictionary, the default material "S" (serum) is returned.
public Material GetMaterial(string laurisName)
{
string textValue = LookUpValue(laurisName, 2);
try
{
return MaterialFactory.FromAbbreviation(textValue);
}
catch
{
return Material.B;
}
}
///
/// Returns whether or not reference limits shall always
/// be displayed for a given item, regardless whether it
/// is normal or not.
///
/// Laboratory item to look up; this must
/// be an original Lauris string.
///
public bool GetForceReferenceDisplay(string laurisName)
{
return LookUpValue(laurisName, 3, false);
}
#endregion
#region Overrides
///
/// Returns the resource stream for Defaults\parameters.txt.
///
protected override System.IO.Stream GetDefaultStream()
{
return Assembly.GetExecutingAssembly().GetManifestResourceStream(
"zaaReloaded2.Defaults.parameters.txt");
}
///
/// Returns a path to a file parameters.txt in the addin directory
/// as provided by .
///
protected override string GetUserFileName()
{
return Path.Combine(ThisAddIn.Subdir, "parameters.txt");
}
#endregion
}
}