Ejemplo n.º 1
0
        // FhirPath toDecimal() function
        public static decimal?ToDecimal(this ITypedElement focus)
        {
            var val = focus.getValue <object>("focus");

            if (val is decimal)
            {
                return((decimal)val);
            }
            else if (val is string)
            {
                try
                {
                    return(XmlConvert.ToDecimal((string)val));
                }
                catch
                {
                    return(null);
                }
            }
            else if (val is bool)
            {
                return((bool)val ? 1m : 0m);
            }

            return(null);
        }
Ejemplo n.º 2
0
        // FhirPath toString() function
        public static string ToStringRepresentation(this ITypedElement focus)
        {
            var val = focus.getValue <object>("focus");

            if (val is string)
            {
                return((string)val);
            }
            else if (val is long)
            {
                return(XmlConvert.ToString((long)val));
            }
            else if (val is decimal)
            {
                return(XmlConvert.ToString((decimal)val));
            }
            else if (val is bool)
            {
                return((bool)val ? "true" : "false");
            }
            else if (val is PartialTime)
            {
                return(((PartialTime)val).ToString());
            }
            else if (val is PartialDateTime)
            {
                return(((PartialDateTime)val).ToString());
            }

            return(null);
        }
Ejemplo n.º 3
0
        // FhirPath toInteger() function
        public static long?ToInteger(this ITypedElement focus)
        {
            var val = focus.getValue <object>("focus");

            if (val is long)
            {
                return((long)val);
            }
            else if (val is string)
            {
                try
                {
                    return(XmlConvert.ToInt64((string)val));
                }
                catch
                {
                    return(null);
                }
            }
            else if (val is bool)
            {
                return((bool)val ? 1L : 0L);
            }

            return(null);
        }