/** * Add a paratemer value to a Parameters resource * * @param theContext The FhirContext * @param theParameters The Parameters resource * @param theName The parametr name * @param theValue The parameter value (can be a {@link IBaseResource resource} or a {@link IBaseDatatype datatype}) */ public static void addParameterToParameters(FhirContext theContext, IBaseParameters theParameters, String theName, Object theValue) { RuntimeResourceDefinition def = theContext.getResourceDefinition(theParameters); BaseRuntimeChildDefinition paramChild = def.getChildByName("parameter"); BaseRuntimeElementCompositeDefinition<?> paramChildElem = (BaseRuntimeElementCompositeDefinition<?>) paramChild.getChildByName("parameter"); addClientParameter(theContext, theValue, theParameters, paramChild, paramChildElem, theName); }
private static void addClientParameter(FhirContext theContext, Object theValue, IBaseResource theTargetResource, BaseRuntimeChildDefinition paramChild, BaseRuntimeElementCompositeDefinition<?> paramChildElem, String theName) { if (theValue instanceof IBaseResource) { IBase parameter = createParameterRepetition(theContext, theTargetResource, paramChild, paramChildElem, theName); paramChildElem.getChildByName("resource").getMutator().addValue(parameter, (IBaseResource) theValue); } else if (theValue instanceof IBaseDatatype) { IBase parameter = createParameterRepetition(theContext, theTargetResource, paramChild, paramChildElem, theName); paramChildElem.getChildByName("value[x]").getMutator().addValue(parameter, (IBaseDatatype) theValue); } else if (theValue instanceof Collection) { Collection<?> collection = (Collection<?>) theValue; for (Object next : collection) { addClientParameter(theContext, next, theTargetResource, paramChild, paramChildElem, theName); } } else { throw new IllegalArgumentException("Don't know how to handle value of type " + theValue.getClass() + " for parameter " + theName); } }
/** * Add a paratemer value to a Parameters resource * * @param theContext The FhirContext * @param theParameters The Parameters resource * @param theName The parametr name * @param theValue The parameter value (can be a {@link IBaseResource resource} or a {@link IBaseDatatype datatype}) */ public static void addParameterToParameters(FhirContext theContext, IBaseParameters theParameters, String theName, Object theValue) { RuntimeResourceDefinition def = theContext.getResourceDefinition(theParameters); BaseRuntimeChildDefinition paramChild = def.getChildByName("parameter"); BaseRuntimeElementCompositeDefinition<?> paramChildElem = (BaseRuntimeElementCompositeDefinition<?>) paramChild.getChildByName("parameter"); addClientParameter(theContext, theValue, theParameters, paramChild, paramChildElem, theName); }
private static void addClientParameter(FhirContext theContext, Object theValue, IBaseResource theTargetResource, BaseRuntimeChildDefinition paramChild, BaseRuntimeElementCompositeDefinition<?> paramChildElem, String theName) { if (theValue instanceof IBaseResource) { IBase parameter = createParameterRepetition(theContext, theTargetResource, paramChild, paramChildElem, theName); paramChildElem.getChildByName("resource").getMutator().addValue(parameter, (IBaseResource) theValue); } else if (theValue instanceof IBaseDatatype) { IBase parameter = createParameterRepetition(theContext, theTargetResource, paramChild, paramChildElem, theName); paramChildElem.getChildByName("value[x]").getMutator().addValue(parameter, (IBaseDatatype) theValue); } else if (theValue instanceof Collection) { Collection<?> collection = (Collection<?>) theValue; for (Object next : collection) { addClientParameter(theContext, next, theTargetResource, paramChild, paramChildElem, theName); } } else { throw new IllegalArgumentException("Don't know how to handle value of type " + theValue.getClass() + " for parameter " + theName); } }