Ejemplo n.º 1
0
        /// <summary>Adds a value set.</summary>
        /// <param name="valueSet">Set the value belongs to.</param>
        public void AddValueSet(FhirValueSet valueSet)
        {
            if (valueSet == null)
            {
                return;
            }

            string version = "*";

            if (!string.IsNullOrEmpty(valueSet.Version))
            {
                version = valueSet.Version;
            }

            if (_valueSetsByVersion.ContainsKey(version))
            {
                return;
            }

            _valueSetsByVersion.Add(version, valueSet);
        }
Ejemplo n.º 2
0
        /// <summary>Gets a version.</summary>
        /// <param name="version">The version.</param>
        /// <param name="vs">     [out] The vs.</param>
        /// <returns>True if it succeeds, false if it fails.</returns>
        public bool TryGetValueSet(string version, out FhirValueSet vs)
        {
            if (_valueSetsByVersion.Count == 0)
            {
                vs = null;
                return(false);
            }

            if ((!string.IsNullOrEmpty(version)) &&
                _valueSetsByVersion.ContainsKey(version))
            {
                vs = _valueSetsByVersion[version];
                return(true);
            }

            if (!string.IsNullOrEmpty(version))
            {
                vs = null;
                return(false);
            }

            if (_valueSetsByVersion.Count == 1)
            {
                vs = _valueSetsByVersion.Values.First();
                return(true);
            }

            string vLast = string.Empty;

            foreach (string vsVersion in _valueSetsByVersion.Keys)
            {
                if (string.Compare(vLast, vsVersion, StringComparison.Ordinal) > 0)
                {
                    vLast = vsVersion;
                }
            }

            vs = _valueSetsByVersion[vLast];
            return(true);
        }