Beispiel #1
0
 ///<summary>
 /// Returns all repetitions of Certification Agency Phone Number (ZN3-19).
 ///</summary>
 public XTN[] GetCertificationAgencyPhoneNumber()
 {
     XTN[] ret = null;
     try {
         IType[] t = this.GetField(19);
         ret = new XTN[t.Length];
         for (int i = 0; i < ret.Length; i++)
         {
             ret[i] = (XTN)t[i];
         }
     } catch (HL7Exception he) {
         HapiLogFactory.GetHapiLog(this.GetType()).Error("Unexpected problem obtaining field value.  This is a bug.", he);
         throw new System.Exception("An unexpected error ocurred", he);
     } catch (System.Exception cce) {
         HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value.  This is a bug.", cce);
         throw new System.Exception("An unexpected error ocurred", cce);
     }
     return(ret);
 }
Beispiel #2
0
 /**
  * Returns all repetitions of Contact Telecommunication (FAC-8).
  */
 public XTN[] getContactTelecommunication()
 {
     XTN[] ret = null;
     try {
         Type[] t = this.getField(8);
         ret = new XTN[t.Length];
         for (int i = 0; i < ret.Length; i++)
         {
             ret[i] = (XTN)t[i];
         }
     } catch (HL7Exception he) {
         HapiLogFactory.getHapiLog(this.GetType()).error("Unexpected problem obtaining field value.  This is a bug.", he);
         throw new System.Exception("An unexpected error ocurred", he);
     } catch (System.Exception cce) {
         HapiLogFactory.getHapiLog(GetType()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
         throw new System.Exception("An unexpected error ocurred", cce);
     }
     return(ret);
 }
Beispiel #3
0
 /// <summary> Returns all repetitions of Help Desk Contact Point (ERR-12).</summary>
 public virtual XTN[] getHelpDeskContactPoint()
 {
     XTN[] ret = null;
     try
     {
         Type[] t = this.getField(12);
         ret = new XTN[t.Length];
         for (int i = 0; i < ret.Length; i++)
         {
             ret[i] = (XTN)t[i];
         }
     }
     catch (System.InvalidCastException)
     {
         throw new Exception();
     }
     catch (NuGenHL7Exception)
     {
         throw new Exception();
     }
     return(ret);
 }
Beispiel #4
0
 /// <summary> Returns all repetitions of Certification Agency Phone Number (IN3-19).</summary>
 public virtual XTN[] getCertificationAgencyPhoneNumber()
 {
     XTN[] ret = null;
     try
     {
         Type[] t = this.getField(19);
         ret = new XTN[t.Length];
         for (int i = 0; i < ret.Length; i++)
         {
             ret[i] = (XTN)t[i];
         }
     }
     catch (System.InvalidCastException)
     {
         throw new Exception();
     }
     catch (NuGenHL7Exception)
     {
         throw new Exception();
     }
     return(ret);
 }
Beispiel #5
0
 /// <summary> Returns all repetitions of Primary Observer Telephone (PEO-21).</summary>
 public virtual XTN[] getPrimaryObserverTelephone()
 {
     XTN[] ret = null;
     try
     {
         Type[] t = this.getField(21);
         ret = new XTN[t.Length];
         for (int i = 0; i < ret.Length; i++)
         {
             ret[i] = (XTN)t[i];
         }
     }
     catch (System.InvalidCastException)
     {
         throw new Exception();
     }
     catch (NuGenHL7Exception)
     {
         throw new Exception();
     }
     return(ret);
 }
Beispiel #6
0
 /// <summary> Returns all repetitions of Provider Communication Information (PRD-5).</summary>
 public virtual XTN[] getProviderCommunicationInformation()
 {
     XTN[] ret = null;
     try
     {
         Type[] t = this.getField(5);
         ret = new XTN[t.Length];
         for (int i = 0; i < ret.Length; i++)
         {
             ret[i] = (XTN)t[i];
         }
     }
     catch (System.InvalidCastException)
     {
         throw new Exception();
     }
     catch (NuGenHL7Exception)
     {
         throw new Exception();
     }
     return(ret);
 }
Beispiel #7
0
        /// <summary>
        /// Converts a <see cref="XTN"/> instance to a <see cref="EntityTelecomAddress"/> instance.
        /// </summary>
        /// <param name="xtn">The v2 XTN instance to be converted.</param>
        /// <returns>Returns the converted entity telecom address instance.</returns>
        public static EntityTelecomAddress ConvertXTN(XTN xtn)
        {
            var re     = new Regex(@"([+0-9A-Za-z]{1,4})?\((\d{3})\)?(\d{3})\-(\d{4})X?(\d{1,6})?");
            var retVal = new EntityTelecomAddress();

            if (xtn.AnyText.Value == null)
            {
                var sb = new StringBuilder("tel:");

                try
                {
                    if (xtn.CountryCode.Value != null)
                    {
                        sb.AppendFormat("{0}-", xtn.CountryCode);
                    }

                    if (xtn.PhoneNumber?.Value != null && !xtn.PhoneNumber.Value.Contains("-"))
                    {
                        xtn.PhoneNumber.Value = xtn.PhoneNumber.Value.Insert(3, "-");
                    }

                    sb.AppendFormat("{0}-{1}", xtn.AreaCityCode, xtn.PhoneNumber);

                    if (xtn.Extension.Value != null)
                    {
                        sb.AppendFormat(";ext={0}", xtn.Extension);
                    }
                }
                catch
                {
                    // ignored
                }

                if (sb.ToString().EndsWith("tel:") || sb.ToString() == "tel:-")
                {
                    retVal.Value = "tel:" + xtn.AnyText.Value;
                }
                else
                {
                    retVal.Value = sb.ToString();
                }
            }
            else
            {
                var match = re.Match(xtn.AnyText.Value);

                var sb = new StringBuilder("tel:");

                for (var i = 1; i < 5; i++)
                {
                    if (!string.IsNullOrEmpty(match.Groups[i].Value))
                    {
                        sb.AppendFormat("{0}{1}", match.Groups[i].Value, i == 4 ? "" : "-");
                    }
                }

                if (!string.IsNullOrEmpty(match.Groups[5].Value))
                {
                    sb.AppendFormat(";ext={0}", match.Groups[5].Value);
                }

                retVal.Value = sb.ToString();
            }

            // Use code conversion
            var use = Guid.Empty;

            if (!string.IsNullOrEmpty(xtn.TelecommunicationUseCode.Value))
            {
                var concept = GetConcept(xtn.TelecommunicationUseCode.Value, "urn:oid:2.16.840.1.113883.5.1011");

                // TODO: cleanup
                if (concept == null)
                {
                    throw new ArgumentException("Code not known");
                }

                use = concept.Key.Value;
            }

            retVal.AddressUseKey = use;

            return(retVal);
        }
Beispiel #8
0
        /// <summary>
        /// Converts a <see cref="XTN"/> instance to a <see cref="EntityTelecomAddress"/> instance.
        /// </summary>
        /// <param name="xtn">The v2 XTN instance to be converted.</param>
        /// <returns>Returns the converted entity telecom address instance.</returns>
        public static EntityTelecomAddress ToModel(this XTN xtn)
        {
            var re     = new Regex(@"([+0-9A-Za-z]{1,4})?\((\d{3})\)?(\d{3})\-(\d{4})X?(\d{1,6})?");
            var retVal = new EntityTelecomAddress();

            if (!String.IsNullOrEmpty(xtn.EmailAddress?.Value))
            {
                retVal.IETFValue = $"mailto:{xtn.EmailAddress.Value}";
            }
            else if (xtn.AnyText.Value == null)
            {
                var sb = new StringBuilder("tel:");

                try
                {
                    if (xtn.CountryCode.Value != null)
                    {
                        sb.AppendFormat("{0}{1}-", xtn.CountryCode.Value.Contains("+") ? "" : "+", xtn.CountryCode);
                    }

                    if (!String.IsNullOrEmpty(xtn.TelephoneNumber?.Value))
                    {
                        if (xtn.TelephoneNumber?.Value != null && !xtn.TelephoneNumber.Value.Contains("-"))
                        {
                            xtn.TelephoneNumber.Value = xtn.TelephoneNumber.Value.Insert(3, "-");
                        }
                        sb.AppendFormat("{0}-{1}", xtn.AreaCityCode, xtn.TelephoneNumber.Value);
                    }
                    else
                    {
                        sb.AppendFormat("{0}-{1}", xtn.AreaCityCode, xtn.LocalNumber.Value.Contains("-") ? xtn.LocalNumber.Value : xtn.LocalNumber.Value.Replace(" ", "-").Insert(3, "-"));
                    }

                    if (xtn.Extension.Value != null)
                    {
                        sb.AppendFormat(";ext={0}", xtn.Extension);
                    }
                }
                catch
                {
                    // ignored
                }

                if (sb.ToString().EndsWith("tel:") || sb.ToString() == "tel:-")
                {
                    retVal.IETFValue = "tel:" + xtn.AnyText.Value;
                }
                else
                {
                    retVal.IETFValue = sb.ToString();
                }
            }
            else
            {
                var match = re.Match(xtn.UnformattedTelephoneNumber.Value);
                var sb    = new StringBuilder("tel:");

                for (var i = 1; i < 5; i++)
                {
                    if (!string.IsNullOrEmpty(match.Groups[i].Value))
                    {
                        sb.AppendFormat("{0}{1}", match.Groups[i].Value, i == 4 ? "" : "-");
                    }
                }

                if (!string.IsNullOrEmpty(match.Groups[5].Value))
                {
                    sb.AppendFormat(";ext={0}", match.Groups[5].Value);
                }

                retVal.IETFValue = sb.ToString();
            }

            // Use code conversion
            Guid use = NullReasonKeys.NoInformation;

            if (!string.IsNullOrEmpty(xtn.TelecommunicationUseCode.Value))
            {
                var concept = ApplicationServiceContext.Current.GetService <IConceptRepositoryService>().GetConceptByReferenceTerm(xtn.TelecommunicationUseCode.Value, TelecomUseCodeSystem);

                if (concept == null)
                {
                    throw new HL7DatatypeProcessingException("Error processing XTN", 1, new KeyNotFoundException($"Telecom use code {xtn.TelecommunicationUseCode.Value} not known"));
                }

                use = concept.Key.Value;
            }

            retVal.AddressUseKey = use;

            // Type code conversion
            Guid?type = null;

            if (!string.IsNullOrEmpty(xtn.TelecommunicationEquipmentType.Value))
            {
                var concept = ApplicationServiceContext.Current.GetService <IConceptRepositoryService>().GetConceptByReferenceTerm(xtn.TelecommunicationEquipmentType.Value, TelecomTypeCodeSystem);
                if (concept == null)
                {
                    throw new HL7DatatypeProcessingException("Error processing XTN", 2, new KeyNotFoundException($"Telecom equipment type {xtn.TelecommunicationEquipmentType.Value} not known"));
                }
                type = concept.Key.Value;
            }
            retVal.TypeConceptKey = type;
            return(retVal);
        }