/// <summary>
        /// Parses a bindeable type (code, Coding, CodeableConcept, Quantity, string, uri) into a FHIR coded datatype.
        /// Extensions will be parsed from the 'value' of the (simple) extension.
        /// </summary>
        /// <param name="instance"></param>
        /// <returns>An Element of a coded type (code, Coding or CodeableConcept) dependin on the instance type,
        /// or null if no bindable instance data was found</returns>
        /// <remarks>The instance type is mapped to a codable type as follows:
        ///   'code' => code
        ///   'Coding' => Coding
        ///   'CodeableConcept' => CodeableConcept
        ///   'Quantity' => Coding
        ///   'Extension' => depends on value[x]
        ///   'string' => code
        ///   'uri' => code
        /// </remarks>
        public static Element ParseBindable(this IElementNavigator instance)
        {
            var instanceType = ModelInfo.FhirTypeNameToFhirType(instance.Type);

            switch (instanceType)
            {
            case FHIRDefinedType.Code:
                return(instance.ParsePrimitive <Code>());

            case FHIRDefinedType.Coding:
                return(instance.ParseCoding());

            case FHIRDefinedType.CodeableConcept:
                return(instance.ParseCodeableConcept());

            case FHIRDefinedType.Quantity:
                return(parseQuantity(instance));

            case FHIRDefinedType.String:
                return(new Code(instance.ParsePrimitive <FhirString>()?.Value));

            case FHIRDefinedType.Uri:
                return(new Code(instance.ParsePrimitive <FhirUri>()?.Value));

            case FHIRDefinedType.Extension:
                return(parseExtension(instance));

            case null:
            //HACK: fall through - IElementNav did not provide a type
            //should not happen, and I have no intention to handle it.
            default:
                // Not bindable
                return(null);
            }

            Coding parseQuantity(IElementNavigator nav)
            {
                var newCoding = new Coding();
                var q         = instance.ParseQuantity();

                newCoding.Code   = q.Unit;
                newCoding.System = q.System ?? "http://unitsofmeasure.org";
                return(newCoding);
            }

            Element parseExtension(IElementNavigator nav)
            {
                // HACK: For now, assume this is a typed navigator, so we have "value",
                // not the unparsed "valueCode" etc AND we have Type (in ParseBindable())
                var valueChild = instance.Children("value").FirstOrDefault();

                if (valueChild != null)
                {
                    return(valueChild.ParseBindable());
                }
                else
                {
                    return(null);
                }
            }
        }