Exemplo n.º 1
0
        public void TestConvertNameMultipleNames()
        {
            var adt = new ADT_A01();

            var name1 = adt.PID.GetPatientName(0);

            name1.FamilyLastName.FamilyName.Value = "Khanna";
            name1.GivenName.Value           = "Nityan";
            name1.MiddleInitialOrName.Value = "Dave";

            var name2 = adt.PID.GetPatientName(1);

            name2.FamilyLastName.FamilyName.Value = "Smith";
            name2.GivenName.Value           = "II";
            name2.MiddleInitialOrName.Value = "Capitano";

            var names = new XPN[2];

            names[0] = name1;
            names[1] = name2;

            var actual = MessageUtil.ConvertNames(names);

            Assert.AreEqual(2, actual.Count(n => n.Component.Any(c => c.ComponentTypeKey == NameComponentKeys.Given)));
            Assert.AreEqual(2, actual.Count(n => n.Component.Any(c => c.ComponentTypeKey == NameComponentKeys.Family)));
        }
Exemplo n.º 2
0
 public void Cleanup()
 {
     this.entityTelecomAddress = null;
     this.xad = null;
     this.xpn = null;
     this.xtn = null;
 }
Exemplo n.º 3
0
        public void Initialize()
        {
            this.entityTelecomAddress = new EntityTelecomAddress
            {
                AddressUse = new Core.Model.DataTypes.Concept
                {
                    Key = TelecomAddressUseKeys.Public
                },
                Value = "9055751212"
            };

            this.xad = new XAD(Activator.CreateInstance(typeof(ADT_A01)) as IMessage);

            this.xad.AddressType.Value     = "L";
            this.xad.City.Value            = "Hamilton";
            this.xad.Country.Value         = "Canada";
            this.xad.StateOrProvince.Value = "Ontario";
            this.xad.StreetAddress.Value   = "123 Main street west";
            this.xad.ZipOrPostalCode.Value = "L8N3T2";

            this.xpn = new XPN(Activator.CreateInstance(typeof(ADT_A01)) as IMessage);

            this.xpn.DegreeEgMD.Value = "MD";
            this.xpn.FamilyLastName.FamilyName.Value = "Khanna";
            this.xpn.GivenName.Value           = "Nityan";
            this.xpn.PrefixEgDR.Value          = "Dr.";
            this.xpn.MiddleInitialOrName.Value = "Dave";

            this.xtn = new XTN(Activator.CreateInstance(typeof(ADT_A01)) as IMessage);
        }
        /// <summary>
        /// 创建fieldtype,如CE,XCN等
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="product"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public override abstractType Create(compositeType parent, Enum product, string name)
        {
            abstractType tmp = null;

            switch (product)
            {
            case enumField.CE: tmp = new CE(parent, name); break;

            case enumField.CM: tmp = new CM(parent, name); break;

            case enumField.CWE: tmp = new CWE(parent, name); break;

            case enumField.CX: tmp = new CX(parent, name); break;

            case enumField.DLN: tmp = new DLN(parent, name); break;

            case enumField.EI: tmp = new EI(parent, name); break;

            case enumField.ELD: tmp = new ELD(parent, name); break;

            case enumField.FN: tmp = new FN(parent, name); break;

            case enumField.HD: tmp = new HD(parent, name); break;

            case enumField.MSG: tmp = new MSG(parent, name); break;

            case enumField.PT: tmp = new PT(parent, name); break;

            case enumField.VID: tmp = new VID(parent, name); break;

            case enumField.XAD: tmp = new XAD(parent, name); break;

            case enumField.XCN: tmp = new XCN(parent, name); break;

            case enumField.XPN: tmp = new XPN(parent, name); break;

            case enumField.XTN: tmp = new XTN(parent, name); break;

            case enumField.ERL: tmp = new ERL(parent, name); break;

            case enumField.FC: tmp = new FC(parent, name); break;

            case enumField.XON: tmp = new XON(parent, name); break;

            case enumField.PL: tmp = new PL(parent, name); break;

            case enumField.CP: tmp = new CP(parent, name); break;

            case enumField.JCC: tmp = new JCC(parent, name); break;

            case enumField.TQ: tmp = new TQ(parent, name); break;

            case enumField.CQ: tmp = new CQ(parent, name); break;

            default: throw new NotSupportedException();
            }
            return(tmp);
        }
Exemplo n.º 5
0
        public void TestUpdateXPN()
        {
            var actual = new XPN(this.genericMessage);

            NotifierBase.UpdateXPN(entityName, actual);

            Assert.AreEqual("Khanna", actual.FamilyLastName.FamilyName.Value);
            Assert.AreEqual("Nityan David", actual.GivenName.Value);
        }
Exemplo n.º 6
0
        public void TestUpdateXPNFirstNameOnly()
        {
            var actual = new XPN(this.genericMessage);

            this.entityName.Component = new List <EntityNameComponent>
            {
                new EntityNameComponent(NameComponentKeys.Given, "Nityan")
            };

            NotifierBase.UpdateXPN(this.entityName, actual);

            Assert.AreEqual("Nityan", actual.GivenName.Value);
        }
Exemplo n.º 7
0
	///<summary>
	/// Returns a single repetition of Prior Patient Name(MRG-7).
	/// throws HL7Exception if the repetition number is invalid.
	/// <param name="rep">The repetition number (this is a repeating field)</param>
	///</summary>
	public XPN GetPriorPatientName(int rep)
	{
			XPN ret = null;
			try
			{
			IType t = this.GetField(7, rep);
				ret = (XPN)t;
		} catch (System.Exception ex) {
			HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value.  This is a bug.", ex);
				throw new System.Exception("An unexpected error ocurred", ex);
    }
			return ret;
  }
Exemplo n.º 8
0
        public void TestUpdateXPNLastNameOnly()
        {
            var actual = new XPN(this.genericMessage);

            this.entityName.Component = new List <EntityNameComponent>
            {
                new EntityNameComponent(NameComponentKeys.Family, "Khanna")
            };

            NotifierBase.UpdateXPN(this.entityName, actual);

            Assert.AreEqual("Khanna", actual.FamilyLastName.FamilyName.Value);
        }
Exemplo n.º 9
0
        public void TestConvertNameGivenNameOnly()
        {
            this.xpn = new XPN(Activator.CreateInstance(typeof(ADT_A01)) as IMessage);

            this.xpn.GivenName.Value = "Nityan";

            var actual = MessageUtil.ConvertName(this.xpn);

            Assert.AreEqual(1, actual.Component.Count(c => c.ComponentTypeKey == NameComponentKeys.Given));
            Assert.AreEqual("Nityan", actual.Component.FirstOrDefault(c => c.ComponentTypeKey == NameComponentKeys.Given)?.Value);

            Assert.AreEqual(0, actual.Component.Count(c => c.ComponentTypeKey == NameComponentKeys.Family));
            Assert.IsNull(actual.Component.FirstOrDefault(c => c.ComponentTypeKey == NameComponentKeys.Family)?.Value);
        }
Exemplo n.º 10
0
        public string Parse()
        {
            // Do something with this message, for example store it to a database
            XPN name = message.PID.GetPatientName().FirstOrDefault(n => n.GivenName.Value.Length > 0);

            Console.WriteLine("Name of the person: {0} {1} {2}", name.GivenName.Value, name.SecondAndFurtherGivenNamesOrInitialsThereof.Value,
                              name.FamilyName.Surname);

            // Create and return an Ack message
            Ack result = new Ack();

            result.SetMessage(message);
            return(result.GetAckMessage());
        }
Exemplo n.º 11
0
        /// <summary> Returns a single repetition of Name Of Insured (IN1-16).</summary>
        /// <param name="rep">the repetition number (this is a repeating field)
        /// </param>
        /// <throws>  HL7Exception if the repetition number is invalid. </throws>
        public virtual XPN getNameOfInsured(int rep)
        {
            XPN ret = null;

            try
            {
                Type t = this.getField(16, rep);
                ret = (XPN)t;
            }
            catch (System.InvalidCastException)
            {
                throw new Exception();
            }
            return(ret);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Updates an <see cref="XPN"/> segment.
        /// </summary>
        /// <param name="entityName">The entity name to use to update the XPN segment.</param>
        /// <param name="name">The XPN segment to update.</param>
        internal static XPN UpdateXPN(EntityName entityName, XPN name)
        {
            // ensure authenticated
            EnsureAuthenticated();

            tracer.TraceEvent(TraceEventType.Verbose, 0, "Adding names");

            name.NameTypeCode.Value = MessageUtil.GetCode(entityName.NameUseKey.Value, CodeSystemKeys.EntityNameUse);
            name.DegreeEgMD.Value   = string.Join(" ", entityName.LoadCollection <EntityNameComponent>("Component").Where(c => c.ComponentTypeKey == NameComponentKeys.Suffix).Select(c => c.Value));
            name.FamilyLastName.FamilyName.Value = string.Join(" ", entityName.Component.Where(c => c.ComponentTypeKey == NameComponentKeys.Family).Select(c => c.Value));
            name.GivenName.Value           = string.Join(" ", entityName.Component.Where(c => c.ComponentTypeKey == NameComponentKeys.Given).Select(c => c.Value));
            name.PrefixEgDR.Value          = string.Join(" ", entityName.Component.Where(c => c.ComponentTypeKey == NameComponentKeys.Prefix).Select(c => c.Value));
            name.MiddleInitialOrName.Value = string.Join(" ", entityName.Component.Where(c => c.ComponentTypeKey == NameComponentKeys.Delimiter).Select(c => c.Value));

            return(name);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Convert name to XPN
        /// </summary>
        public static XPN FromModel(this XPN me, EntityName name)
        {
            var refTerm = ApplicationServiceContext.Current.GetService <IConceptRepositoryService>().GetConceptReferenceTerm(name.NameUseKey.GetValueOrDefault(), NameUseCodeSystem);

            if (refTerm != null)
            {
                me.NameTypeCode.Value = refTerm.Mnemonic;
            }

            // Convert components
            foreach (var itm in name.LoadCollection <EntityNameComponent>("Component"))
            {
                if (itm.ComponentTypeKey == NameComponentKeys.Family)
                {
                    if (string.IsNullOrEmpty(me.FamilyName.Surname.Value))
                    {
                        me.FamilyName.Surname.Value = itm.Value;
                    }
                    else if (string.IsNullOrEmpty(me.FamilyName.OwnSurname.Value))
                    {
                        me.FamilyName.OwnSurname.Value = itm.Value;
                    }
                }
                else if (itm.ComponentTypeKey == NameComponentKeys.Given)
                {
                    if (String.IsNullOrEmpty(me.GivenName.Value))
                    {
                        me.GivenName.Value = itm.Value;
                    }
                    else
                    {
                        me.SecondAndFurtherGivenNamesOrInitialsThereof.Value += itm.Value + " ";
                    }
                }
                else if (itm.ComponentTypeKey == NameComponentKeys.Suffix)
                {
                    me.SuffixEgJRorIII.Value = itm.Value;
                }
                else if (itm.ComponentTypeKey == NameComponentKeys.Prefix)
                {
                    me.PrefixEgDR.Value = itm.Value;
                }
            }

            return(me);
        }
Exemplo n.º 14
0
  ///<summary>
  /// Returns all repetitions of Prior Patient Name (MRG-7).
   ///</summary>
  public XPN[] GetPriorPatientName() {
     XPN[] ret = null;
    try {
        IType[] t = this.GetField(7);  
        ret = new XPN[t.Length];
        for (int i = 0; i < ret.Length; i++) {
            ret[i] = (XPN)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;
}
Exemplo n.º 15
0
 /**
  * Returns all repetitions of Contact Person's Name (NK1-30).
  */
 public XPN[] getContactPersonSName()
 {
     XPN[] ret = null;
     try {
         Type[] t = this.getField(30);
         ret = new XPN[t.Length];
         for (int i = 0; i < ret.Length; i++)
         {
             ret[i] = (XPN)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);
 }
Exemplo n.º 16
0
        /// <summary>
        /// Creates a PersonName instance from an XPN instance.
        /// </summary>
        /// <param name="xpn">Name.</param>
        /// <returns>IPersonName</returns>
        internal static IPersonName GetPersonName(XPN xpn)
        {
            if (xpn == null)
            {
                return(null);
            }

            var name = BaseCDAModel.CreatePersonName();

            if (xpn.familylastname != null)
            {
                name.FamilyName = xpn.familylastname.familyname;
            }
            name.GivenNames = new List <string>();
            name.GivenNames.Add(xpn.givenname);
            name.NameUsages = new List <NameUsage>();

            if (xpn.nametypecode != null)
            {
                switch (xpn.nametypecode)
                {
                case "A":
                case "L":
                case "C":
                case "I":
                    name.NameUsages.Add(NameUsage.Legal);
                    break;

                case "D":
                    name.NameUsages.Add(NameUsage.ReportingName);
                    break;

                case "M":
                    name.NameUsages.Add(NameUsage.MaidenName);
                    break;

                case "B":
                    name.NameUsages.Add(NameUsage.NewbornName);
                    break;

                case "S":
                case "P":
                case "T":
                    name.NameUsages.Add(NameUsage.OtherName);
                    break;

                case "N":
                    name.NameUsages.Add(NameUsage.PreferredNameIndicator);
                    break;

                default:
                    name.NameUsages.Add(NameUsage.Undefined);
                    break;
                }
            }
            else
            {
                name.NameUsages = new List <NameUsage>()
                {
                    NameUsage.Undefined
                };
            }

            return(name);
        }
Exemplo n.º 17
0
 /// <summary>
 /// Converts the specified XPN instance to an entity name
 /// </summary>
 /// <param name="name">The name to be converted</param>
 /// <returns>The name</returns>
 public static EntityName ToModel(this XPN name)
 {
     return(new XPN[] { name }.ToModel().FirstOrDefault());
 }
Exemplo n.º 18
0
 /// <summary>
 /// Converts an <see cref="XPN"/> instance to an <see cref="EntityName"/> instance.
 /// </summary>
 /// <param name="name">The name to be converted.</param>
 /// <returns>Returns the converted name.</returns>
 public static EntityName ConvertName(XPN name)
 {
     return(MessageUtil.ConvertNames(new XPN[] { name }).FirstOrDefault());
 }