예제 #1
0
        /// <summary>
        /// Convert a telecom address
        /// </summary>
        internal TelecommunicationsAddress ConvertTelecom(Telecom tel, List <IResultDetail> dtls)
        {
            var retVal = new TelecommunicationsAddress();

            if (tel.Use != null)
            {
                retVal.Use = MARC.Everest.Connectors.Util.ToWireFormat(HackishCodeMapping.Lookup(HackishCodeMapping.TELECOM_USE, tel.Use));
                // Extensions
                retVal.Use += ExtensionUtil.ParseTELUseExtension(tel.Extension, dtls);
            }
            if (String.IsNullOrEmpty(tel.Value))
            {
                dtls.Add(new MandatoryElementMissingResultDetail(ResultDetailType.Error, "Telecommunications address must carry a value", "telecom"));
            }
            else
            {
                retVal.Value = tel.Value;
                if (tel.System.Value == "phone" && !retVal.Value.StartsWith("tel:"))
                {
                    dtls.Add(new ValidationResultDetail(ResultDetailType.Error, "Telecommunications address must start with tel: when system is phone", null, null));
                }
                else if (tel.System.Value == "email" && !retVal.Value.StartsWith("mailto:"))
                {
                    dtls.Add(new ValidationResultDetail(ResultDetailType.Error, "Telecommunications address must start with mailto: when system is email", null, null));
                }
            }
            if (tel.Period != null)
            {
                dtls.Add(new UnsupportedFhirDatatypePropertyResultDetail(ResultDetailType.Warning, "Period", "Name"));
                tel.Period = null;
            }

            return(retVal);
        }
예제 #2
0
        /// <summary>
        /// Create an Everest TEL from the data model TEL
        /// </summary>
        public TEL CreateTEL(TelecommunicationsAddress tel, List <IResultDetail> dtls)
        {
            var retVal = new TEL()
            {
                Value = tel.Value
            };

            if (!String.IsNullOrEmpty(tel.Use))
            {
                retVal.Use = new SET <CS <TelecommunicationAddressUse> >(
                    (CS <TelecommunicationAddressUse>)Util.FromWireFormat(tel.Use, typeof(CS <TelecommunicationAddressUse>)),
                    CS <TelecommunicationAddressUse> .Comparator);
            }
            return(retVal);
        }
        /// <summary>
        /// Create an Everest TEL from the data model TEL
        /// </summary>
        public TEL CreateTEL(TelecommunicationsAddress tel)
        {
            var retVal = new TEL()
            {
                Value = tel.Value
            };

            if (tel.Use != null)
            {
                retVal.Use = new SET <CS <TelecommunicationAddressUse> >(
                    (CS <TelecommunicationAddressUse>)Util.FromWireFormat(tel.Use, typeof(CS <TelecommunicationAddressUse>)),
                    CS <TelecommunicationAddressUse> .Comparator);
            }
            return(retVal);
        }
예제 #4
0
        /// <summary>
        /// Convert telecom
        /// </summary>
        internal List <Telecom> ConvertTelecom(TelecommunicationsAddress tel)
        {
            var retVal = new List <Telecom>();
            var use    = MARC.Everest.Connectors.Util.Convert <SET <CS <TelecommunicationAddressUse> > >(tel.Use);

            foreach (var instance in use)
            {
                // Add telecom
                Telecom telInstance = new Telecom();
                // Convert use adding additional data if needed
                telInstance.Use = new PrimitiveCode <string>(HackishCodeMapping.ReverseLookup(HackishCodeMapping.TELECOM_USE, instance.Code));
                if (telInstance.Use == null || telInstance.Use.Value == null)
                {
                    telInstance.Use = new PrimitiveCode <string>();
                    telInstance.Use.Extension.Add(ExtensionUtil.CreateTELUseExtension((TelecommunicationAddressUse)instance.Code));
                }

                // Set values, etc
                try
                {
                    telInstance.Value = tel.Value;
                    switch (new Uri(telInstance.Value).Scheme)
                    {
                    case "mailto":
                        telInstance.System = new PrimitiveCode <string>("email");
                        break;

                    case "fax":
                        telInstance.System = new PrimitiveCode <string>("fax");
                        break;

                    case "tel":
                        telInstance.System = new PrimitiveCode <string>("phone");
                        break;

                    default:
                        telInstance.System = new PrimitiveCode <string>("url");
                        break;
                    }
                }
                catch { }
                retVal.Add(telInstance);
            }
            return(retVal);
        }
        /// <summary>
        /// Create a telecomm address
        /// </summary>
        private void CreateTelecommunicationsAddress(IDbConnection conn, IDbTransaction tx, TelecommunicationsAddress tel, decimal pId)
        {
            IDbCommand cmd = DbUtil.CreateCommandStoredProc(conn, tx);

            try
            {
                cmd.CommandText = "add_hc_ptcpt_tel";

                // Parameters
                cmd.Parameters.Add(DbUtil.CreateParameterIn(cmd, "ptcpt_id_in", DbType.Decimal, pId));
                cmd.Parameters.Add(DbUtil.CreateParameterIn(cmd, "tel_value_in", DbType.String, tel.Value));
                cmd.Parameters.Add(DbUtil.CreateParameterIn(cmd, "tel_use_in", DbType.String, tel.Use ?? "DIR"));

                // Now insert
                cmd.ExecuteNonQuery();
            }
            catch (DataException) { }
            finally
            {
                cmd.Dispose();
            }
        }