// FhirPath toDecimal() function public static decimal?ToDecimal(this IElementNavigator 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); }
// FhirPath toString() function public static string ToStringRepresentation(this IElementNavigator 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 Time) { return(((Time)val).ToString()); } else if (val is PartialDateTime) { return(((PartialDateTime)val).ToString()); } return(null); }
// FhirPath toInteger() function public static long?ToInteger(this IElementNavigator 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); }