Ejemplo n.º 1
0
        /// <summary>
        /// Parses an HL7 AD type field and returns a new instance
        /// </summary>
        public static PostalAddress FromHL7Ad(string ad)
        {
            List <string> fields = HL7Util.SplitField(ad, 1, 5);

            return(new PostalAddress {
                Street = fields[0], City = fields[2], State = fields[3], Zip = fields[4]
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Intializes a new <see cref="Person"/> from data found in a sourcePatientInfo field
        /// </summary>
        public static Person FromSourcePatientInfoValues(IEnumerable <string> values)
        {
            Person        p      = null;
            Sex?          sex    = null;
            DateTime?     dob    = null;
            PostalAddress?postal = null;

            foreach (string[] fields in values.Select(s => s.Split('|')))
            {
                if (fields.Length != 2)
                {
                    throw new ArgumentException();
                }
                switch (fields[0])
                {
                case "PID-3":
                    break;

                case "PID-5":
                    p = Person.FromXCN(fields[1]);
                    break;

                case "PID-7":
                    dob = HL7Util.DateTimeFromHL7Value(fields[1]);
                    break;

                case "PID-8":
                    sex = HL7Util.FromHL7Value(fields[1]);
                    break;

                case "PID-11":
                    postal = PostalAddress.FromHL7Ad(fields[1]);
                    break;
                }
            }

            if (p == null)
            {
                throw new ArgumentException();
            }
            if (dob != null)
            {
                p.Dob = dob;
            }
            if (sex != null)
            {
                p.Sex = sex;
            }
            if (postal != null)
            {
                p.Address = postal;
            }
            return(p);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Parses an XCN and returns a Person
        /// </summary>
        public static Person FromXCN(string xcn)
        {
            if (xcn == null)
            {
                throw new ArgumentException();
            }

            Person p = new Person();

            List <string> fields = HL7Util.SplitField(xcn, 2, 7);

            p.Last   = fields[1];
            p.First  = fields[2];
            p.MI     = fields[3];
            p.Suffix = fields[4];
            p.Prefix = fields[5];
            p.Degree = fields[6];

            return(p);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Parses the XTN datatype and returns the corresponding <see cref="Telecom"/>
        /// </summary>
        public static Telecom FromXTN(string i)
        {
            List <string> fields = HL7Util.SplitField(i, 1, 10);

            return(new Telecom(new MailAddress(fields[3], fields[8]), fields[11]));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Parses the XON datatype and returns the corresponding <see cref="Institution"/>
        /// </summary>
        public static Institution FromXON(string i)
        {
            List <string> fields = HL7Util.SplitField(i, 1, 10);

            return(new Institution(fields[0], fields[9]));
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Formats the provided value as a string suitable for inclusion in HL7
 /// </summary>
 public static string AsString(this Sex?s)
 {
     return(HL7Util.ToHL7Value(s));
 }