@Override public String toString() { return value.getValueAsString(); } };
@Override protected String doEncode(IPrimitiveType<?> theString) { return theString.getValueAsString(); }
private static Collection<String> toStrings(Collection<? extends IPrimitiveType<String>> theBase) { HashSet<String> retVal = new HashSet<>(); for (IPrimitiveType<String> next : theBase) { if (isNotBlank(next.getValueAsString())) { retVal.add(next.getValueAsString()); } } return retVal; }
public void setHeaders(List<? extends IPrimitiveType<String>> theHeader) { myHeaders = new ArrayList<>(); for (IPrimitiveType<String> next : theHeader) { if (isNotBlank(next.getValueAsString())) { myHeaders.add(next.getValueAsString()); } } }
/** * Convert a list of FHIR String objects to a set of native java Strings */ public static Set<String> toStringSet(List<? extends IPrimitiveType<?>> theStringList) { HashSet<String> retVal = new HashSet<>(); if (theStringList != null) { for (IPrimitiveType<?> string : theStringList) { if (string != null && string.getValue() != null) { retVal.add(string.getValueAsString()); } } } return retVal; }
public static String parseContentTextIntoWords(FhirContext theContext, IBaseResource theResource) { StringBuilder retVal = new StringBuilder(); @SuppressWarnings("rawtypes") List<IPrimitiveType> childElements = theContext.newTerser().getAllPopulatedChildElementsOfType(theResource, IPrimitiveType.class); for (@SuppressWarnings("rawtypes") IPrimitiveType nextType : childElements) { if (nextType instanceof StringDt || nextType.getClass().getSimpleName().equals("StringType")) { String nextValue = nextType.getValueAsString(); if (isNotBlank(nextValue)) { retVal.append(nextValue.replace("\n", " ").replace("\r", " ")); retVal.append("\n"); } } } return retVal.toString(); }
@Override public Object incomingServer(Object theObject) { IPrimitiveType<?> obj = (IPrimitiveType<?>) theObject; List<QualifiedParamList> paramList = Collections.singletonList(QualifiedParamList.splitQueryStringByCommasIgnoreEscape(null, obj.getValueAsString())); return mySearchParameterBinding.parse(myContext, paramList); }
@Override public Object incomingServer(Object theObject) { IPrimitiveType<?> obj = (IPrimitiveType<?>) theObject; List<QualifiedParamList> paramList = Collections.singletonList(QualifiedParamList.splitQueryStringByCommasIgnoreEscape(null, obj.getValueAsString())); return mySearchParameterBinding.parse(myContext, paramList); }
/** * Sets the value using a FHIR Date type, such as a {@link DateDt}, or a DateTimeType. */ public void setValue(IPrimitiveType<Date> theValue) { if (theValue != null) { myValue.setValueAsString(theValue.getValueAsString()); } else { myValue.setValue(null); } }
/** * Constructor */ public DateParam(ParamPrefixEnum thePrefix, IPrimitiveType<Date> theDate) { setPrefix(thePrefix); myValue.setValueAsString(theDate != null ? theDate.getValueAsString() : null); }
public static IntegerDt toInteger(Object theArgument) { if (theArgument instanceof IntegerDt) { return (IntegerDt) theArgument; } if (theArgument instanceof Integer) { return new IntegerDt((Integer) theArgument); } if (theArgument instanceof IPrimitiveType) { IPrimitiveType<?> pt = (IPrimitiveType<?>) theArgument; return new IntegerDt(pt.getValueAsString()); } return null; }
public static List<String> getBaseAsStrings(FhirContext theContext, IBaseResource theResource) { Validate.notNull(theContext, "theContext must not be null"); Validate.notNull(theResource, "theResource must not be null"); RuntimeResourceDefinition def = theContext.getResourceDefinition(theResource); BaseRuntimeChildDefinition base = def.getChildByName("base"); List<IBase> baseValues = base.getAccessor().getValues(theResource); List<String> retVal = new ArrayList<>(); for (IBase next : baseValues) { IPrimitiveType<?> nextPrimitive = (IPrimitiveType<?>) next; retVal.add(nextPrimitive.getValueAsString()); } return retVal; }
public static String getBundleType(FhirContext theContext, IBaseBundle theBundle) { RuntimeResourceDefinition def = theContext.getResourceDefinition(theBundle); BaseRuntimeChildDefinition entryChild = def.getChildByName("type"); List<IBase> entries = entryChild.getAccessor().getValues(theBundle); if (entries.size() > 0) { IPrimitiveType<?> typeElement = (IPrimitiveType<?>) entries.get(0); return typeElement.getValueAsString(); } return null; }
private static String getFirstIssueStringPart(FhirContext theCtx, IBaseOperationOutcome theOutcome, String name) { if (theOutcome == null) { return null; } RuntimeResourceDefinition ooDef = theCtx.getResourceDefinition(theOutcome); BaseRuntimeChildDefinition issueChild = ooDef.getChildByName("issue"); List<IBase> issues = issueChild.getAccessor().getValues(theOutcome); if (issues.isEmpty()) { return null; } IBase issue = issues.get(0); BaseRuntimeElementCompositeDefinition<?> issueElement = (BaseRuntimeElementCompositeDefinition<?>) theCtx.getElementDefinition(issue.getClass()); BaseRuntimeChildDefinition detailsChild = issueElement.getChildByName(name); List<IBase> details = detailsChild.getAccessor().getValues(issue); if (details.isEmpty()) { return null; } return ((IPrimitiveType<?>) details.get(0)).getValueAsString(); }
private <T extends IBaseBundle> IGetPageTyped<T> nextOrPrevious(String theWantRel, T theBundle) { RuntimeResourceDefinition def = myContext.getResourceDefinition(theBundle); List<IBase> links = def.getChildByName("link").getAccessor().getValues(theBundle); if (links == null || links.isEmpty()) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(GenericClient.class, "noPagingLinkFoundInBundle", theWantRel)); } for (IBase nextLink : links) { BaseRuntimeElementCompositeDefinition linkDef = (BaseRuntimeElementCompositeDefinition) myContext.getElementDefinition(nextLink.getClass()); List<IBase> rel = linkDef.getChildByName("relation").getAccessor().getValues(nextLink); if (rel == null || rel.isEmpty()) { continue; } String relation = ((IPrimitiveType<?>) rel.get(0)).getValueAsString(); if (theWantRel.equals(relation) || (theWantRel == PREVIOUS && PREV.equals(relation))) { List<IBase> urls = linkDef.getChildByName("url").getAccessor().getValues(nextLink); if (urls == null || urls.isEmpty()) { continue; } String url = ((IPrimitiveType<?>) urls.get(0)).getValueAsString(); if (isBlank(url)) { continue; } return (IGetPageTyped<T>) byUrl(url).andReturnBundle(theBundle.getClass()); } } throw new IllegalArgumentException(myContext.getLocalizer().getMessage(GenericClient.class, "noPagingLinkFoundInBundle", theWantRel)); }
private DateTimeType conformanceDate() { IPrimitiveType<Date> buildDate = getServerConfiguration().getConformanceDate(); if (buildDate != null && buildDate.getValue() != null) { try { return new DateTimeType(buildDate.getValueAsString()); } catch (DataFormatException e) { // fall through } } return DateTimeType.now(); }
private DateTimeType conformanceDate() { IPrimitiveType<Date> buildDate = getServerConfiguration().getConformanceDate(); if (buildDate != null && buildDate.getValue() != null) { try { return new DateTimeType(buildDate.getValueAsString()); } catch (DataFormatException e) { // fall through } } return DateTimeType.now(); }
private DateTimeType conformanceDate() { IPrimitiveType<Date> buildDate = getServerConfiguration().getConformanceDate(); if (buildDate != null && buildDate.getValue() != null) { try { return new DateTimeType(buildDate.getValueAsString()); } catch (DataFormatException e) { // fall through } } return DateTimeType.now(); }
@Override public void addRootPropertiesToBundle(String theId, String theServerBase, String theLinkSelf, String theLinkPrev, String theLinkNext, Integer theTotalResults, BundleTypeEnum theBundleType, IPrimitiveType<Date> theLastUpdated) { ensureBundle(); myBase = theServerBase; if (myBundle.getIdElement().isEmpty()) { myBundle.setId(theId); } if (myBundle.getIdElement().isEmpty()) { myBundle.setId(UUID.randomUUID().toString()); } if (myBundle.getMeta().getLastUpdated() == null && theLastUpdated != null) { myBundle.getMeta().getLastUpdatedElement().setValueAsString(theLastUpdated.getValueAsString()); } if (!hasLink(Constants.LINK_SELF, myBundle) && isNotBlank(theLinkSelf)) { myBundle.addLink().setRelation(Constants.LINK_SELF).setUrl(theLinkSelf); } if (!hasLink(Constants.LINK_NEXT, myBundle) && isNotBlank(theLinkNext)) { myBundle.addLink().setRelation(Constants.LINK_NEXT).setUrl(theLinkNext); } if (!hasLink(Constants.LINK_PREVIOUS, myBundle) && isNotBlank(theLinkPrev)) { myBundle.addLink().setRelation(Constants.LINK_PREVIOUS).setUrl(theLinkPrev); } if (myBundle.getTypeElement().isEmpty() && theBundleType != null) { myBundle.getTypeElement().setValueAsString(theBundleType.getCode()); } if (myBundle.getTotalElement().isEmpty() && theTotalResults != null) { myBundle.getTotalElement().setValue(theTotalResults); } }
@Override public void addRootPropertiesToBundle(String theId, String theServerBase, String theLinkSelf, String theLinkPrev, String theLinkNext, Integer theTotalResults, BundleTypeEnum theBundleType, IPrimitiveType<Date> theLastUpdated) { ensureBundle(); myBase = theServerBase; if (myBundle.getIdElement().isEmpty()) { myBundle.setId(theId); } if (myBundle.getIdElement().isEmpty()) { myBundle.setId(UUID.randomUUID().toString()); } if (myBundle.getMeta().getLastUpdated() == null && theLastUpdated != null) { myBundle.getMeta().getLastUpdatedElement().setValueAsString(theLastUpdated.getValueAsString()); } if (!hasLink(Constants.LINK_SELF, myBundle) && isNotBlank(theLinkSelf)) { myBundle.addLink().setRelation(Constants.LINK_SELF).setUrl(theLinkSelf); } if (!hasLink(Constants.LINK_NEXT, myBundle) && isNotBlank(theLinkNext)) { myBundle.addLink().setRelation(Constants.LINK_NEXT).setUrl(theLinkNext); } if (!hasLink(Constants.LINK_PREVIOUS, myBundle) && isNotBlank(theLinkPrev)) { myBundle.addLink().setRelation(Constants.LINK_PREVIOUS).setUrl(theLinkPrev); } if (myBundle.getTypeElement().isEmpty() && theBundleType != null) { myBundle.getTypeElement().setValueAsString(theBundleType.getCode()); } if (myBundle.getTotalElement().isEmpty() && theTotalResults != null) { myBundle.getTotalElement().setValue(theTotalResults); } }