예제 #1
0
        /// <summary>Adds a type profile.</summary>
        /// <param name="profileUrl">The profile url.</param>
        internal void AddTypeProfile(string profileUrl)
        {
            FhirElementProfile profile = new FhirElementProfile(new Uri(profileUrl));

            if (_typeProfiles.ContainsKey(profile.Name))
            {
                return;
            }

            _typeProfiles.Add(profile.Name, profile);
        }
예제 #2
0
        /// <summary>Initializes a new instance of the <see cref="FhirElementType"/> class.</summary>
        /// <exception cref="ArgumentNullException">Thrown when one or more required arguments are null.</exception>
        /// <param name="code">          The code.</param>
        /// <param name="targetProfiles">The target profiles.</param>
        /// <param name="typeProfiles">  The type profiles.</param>
        public FhirElementType(
            string code,
            IEnumerable <string> targetProfiles,
            IEnumerable <string> typeProfiles)
        {
            // TODO: chain initializers properly
            if (string.IsNullOrEmpty(code))
            {
                throw new ArgumentNullException(nameof(code));
            }

            if (IsXmlType(code, out string xmlFhirType))
            {
                code = xmlFhirType;
            }

            if (IsFhirPathType(code, out string fhirType))
            {
                code = fhirType;
            }

            // check for no slashes - implied relative StructureDefinition url
            int lastSlash = code.LastIndexOf('/');

            if (lastSlash == -1)
            {
                Name = code;
                URL  = new Uri(_baseElementTypeUri, code);
            }
            else
            {
                Name = code.Substring(lastSlash + 1);
                URL  = new Uri(code);
            }

            Type = Name;

            _targetProfiles = new Dictionary <string, FhirElementProfile>();
            if (targetProfiles != null)
            {
                foreach (string profileUrl in targetProfiles)
                {
                    if (string.IsNullOrEmpty(profileUrl))
                    {
                        continue;
                    }

                    FhirElementProfile profile = new FhirElementProfile(new Uri(profileUrl));

                    if (_targetProfiles.ContainsKey(profile.Name))
                    {
                        continue;
                    }

                    _targetProfiles.Add(profile.Name, profile);
                }
            }

            _typeProfiles = new Dictionary <string, FhirElementProfile>();
            if (typeProfiles != null)
            {
                foreach (string profileUrl in typeProfiles)
                {
                    if (string.IsNullOrEmpty(profileUrl))
                    {
                        continue;
                    }

                    FhirElementProfile profile = new FhirElementProfile(new Uri(profileUrl));

                    if (_typeProfiles.ContainsKey(profile.Name))
                    {
                        continue;
                    }

                    _typeProfiles.Add(profile.Name, profile);
                }
            }
        }