/// <summary> /// Parses a bindeable type into either a Coding (code, Coding, Quantity, string, uri) or CodeableConcept /// </summary> /// <param name="instance"></param> /// <param name="codedType"></param> /// <returns>An object, which is either a Coding or CodeableConcept</returns> public static object ParseBindable(this IElementNavigator instance, FHIRDefinedType codedType) { // 'code','Coding','CodeableConcept','Quantity','Extension', 'string', 'uri' if (codedType == FHIRDefinedType.Code) { return(instance.ParsePrimitiveCode()); } else if (codedType == FHIRDefinedType.Coding) { return(instance.ParseCoding()); } else if (codedType == FHIRDefinedType.CodeableConcept) { return(instance.ParseCodeableConcept()); } else if (codedType == FHIRDefinedType.Quantity) { var newCoding = new Coding(); var q = instance.ParseQuantity(); newCoding.Code = q.Unit; newCoding.System = q.System; return(newCoding); } else if (codedType == FHIRDefinedType.String) { return(instance.ParsePrimitiveCode()); } else if (codedType == FHIRDefinedType.Uri) { return(instance.ParsePrimitiveCode()); } else if (codedType == FHIRDefinedType.Extension) { throw new NotSupportedException($"The validator does not support binding to Extension values"); } else { throw new NotSupportedException($"FHIR type '{codedType}' is not bindeable"); } }