Exemple #1
0
        /// <summary>
        /// Converts an <see cref="EntityTelecomAddress"/> instance to <see cref="FhirTelecom"/> instance.
        /// </summary>
        /// <param name="telecomAddress">The telecom address.</param>
        /// <returns>Returns the mapped FHIR telecom.</returns>
        public static FhirTelecom ToFhirTelecom(EntityTelecomAddress telecomAddress)
        {
            traceSource.TraceEvent(TraceEventType.Verbose, 0, "Mapping entity telecom address");

            return(new FhirTelecom()
            {
                Use = DataTypeConverter.ToFhirCodeableConcept(telecomAddress.AddressUse)?.GetPrimaryCode()?.Code,
                Value = telecomAddress.IETFValue
            });
        }
Exemple #2
0
        /// <summary>
        /// Converts an <see cref="EntityAddress"/> instance to a <see cref="FhirAddress"/> instance.
        /// </summary>
        /// <param name="address">The address.</param>
        /// <returns>Returns a FHIR address.</returns>
        public static FhirAddress ToFhirAddress(EntityAddress address)
        {
            traceSource.TraceEvent(TraceEventType.Verbose, 0, "Mapping entity address");

            if (address == null)
            {
                return(null);
            }

            // Return value
            var retVal = new FhirAddress()
            {
                Use  = DataTypeConverter.ToFhirCodeableConcept(address.AddressUse, "http://hl7.org/fhir/address-use")?.GetPrimaryCode()?.Code,
                Line = new List <FhirString>()
            };

            // Process components
            foreach (var com in address.LoadCollection <EntityAddressComponent>(nameof(EntityAddress.Component)))
            {
                if (com.ComponentTypeKey == AddressComponentKeys.City)
                {
                    retVal.City = com.Value;
                }
                else if (com.ComponentTypeKey == AddressComponentKeys.Country)
                {
                    retVal.Country = com.Value;
                }
                else if (com.ComponentTypeKey == AddressComponentKeys.AddressLine ||
                         com.ComponentTypeKey == AddressComponentKeys.StreetAddressLine)
                {
                    retVal.Line.Add(com.Value);
                }
                else if (com.ComponentTypeKey == AddressComponentKeys.State)
                {
                    retVal.State = com.Value;
                }
                else if (com.ComponentTypeKey == AddressComponentKeys.PostalCode)
                {
                    retVal.Zip = com.Value;
                }
                else
                {
                    retVal.Extension.Add(new Extension()
                    {
                        Url   = FhirConstants.OpenIZProfile + "#address-" + com.LoadProperty <Concept>(nameof(EntityAddressComponent.ComponentType)).Mnemonic,
                        Value = new FhirString(com.Value)
                    });
                }
            }

            return(retVal);
        }
Exemple #3
0
        /// <summary>
        /// Converts an <see cref="EntityName"/> instance to a <see cref="FhirHumanName"/> instance.
        /// </summary>
        /// <param name="entityName">Name of the entity.</param>
        /// <returns>Returns the mapped FHIR human name.</returns>
        public static FhirHumanName ToFhirHumanName(EntityName entityName)
        {
            traceSource.TraceEvent(TraceEventType.Verbose, 0, "Mapping entity name");

            if (entityName == null)
            {
                return(null);
            }

            // Return value
            var retVal = new FhirHumanName
            {
                Use = DataTypeConverter.ToFhirCodeableConcept(entityName.NameUse, "http://hl7.org/fhir/name-use")?.GetPrimaryCode()?.Code
            };

            // Process components
            foreach (var com in entityName.LoadCollection <EntityNameComponent>(nameof(EntityName.Component)))
            {
                if (string.IsNullOrEmpty(com.Value))
                {
                    continue;
                }

                if (com.ComponentTypeKey == NameComponentKeys.Given)
                {
                    retVal.Given.Add(com.Value);
                }
                else if (com.ComponentTypeKey == NameComponentKeys.Family)
                {
                    retVal.Family.Add(com.Value);
                }
                else if (com.ComponentTypeKey == NameComponentKeys.Prefix)
                {
                    retVal.Prefix.Add(com.Value);
                }
                else if (com.ComponentTypeKey == NameComponentKeys.Suffix)
                {
                    retVal.Suffix.Add(com.Value);
                }
            }

            return(retVal);
        }