private Dictionary <string, PropertyInfo> GetPropertyLookup(object o)
        {
            Type t = o.GetType();

            Dictionary <string, PropertyInfo> props = new Dictionary <string, PropertyInfo>();

            foreach (PropertyInfo pi in t.GetProperties())
            {
                bool skip = false;

                foreach (var attr in pi.CustomAttributes)
                {
                    if (attr.AttributeType == typeof(SkipObservationAttribute))
                    {
                        skip = true;
                    }
                }

                if (!pi.CanWrite)
                {
                    skip = true;
                }

                if (!skip)
                {
                    Attribute attr = pi.GetCustomAttribute(typeof(CdaCodingInfo));

                    if (attr == null)
                    {
                        props.Add(pi.Name, pi);
                    }
                    else
                    {
                        CdaCodingInfo codingAttr = attr as CdaCodingInfo;

                        props.Add(codingAttr.Code, pi);
                    }
                }
            }

            return(props);
        }
        protected List <Observation> GetObservations(object obj, string patientDfn, string pregnancyIen, string babyIen)
        {
            List <Observation> returnList = new List <Observation>();

            PropertyInfo[] props = obj.GetType().GetProperties();

            foreach (PropertyInfo pi in props)
            {
                bool skip = false;

                foreach (var attr in pi.CustomAttributes)
                {
                    if (attr.AttributeType == typeof(SkipObservationAttribute))
                    {
                        skip = true;
                    }
                }

                if (!pi.CanWrite)
                {
                    skip = true;
                }

                if (!skip)
                {
                    object orig = pi.GetValue(obj);

                    var tempVal = pi.GetValue(obj);

                    if (tempVal != null)
                    {
                        Observation obs = GetObservationPrototype(obj, patientDfn, pregnancyIen, babyIen);

                        Attribute attr = pi.GetCustomAttribute(typeof(CdaCodingInfo));

                        if (attr == null)
                        {
                            obs.Code = pi.Name;
                        }
                        else
                        {
                            CdaCodingInfo codingAttr = attr as CdaCodingInfo;
                            obs.Code        = codingAttr.Code;
                            obs.CodeSystem  = codingAttr.CodeSystem;
                            obs.Description = codingAttr.DisplayName;
                        }

                        attr = pi.GetCustomAttribute(typeof(IsNarrative));

                        if (attr == null)
                        {
                            obs.Value = tempVal.ToString();
                        }
                        else
                        {
                            obs.Narrative = tempVal.ToString();
                        }

                        returnList.Add(obs);
                    }
                }
            }

            return(returnList);
        }