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(); }
static List<IBaseResource> toListOfResourcesAndExcludeContainer(IBaseResource theResponseObject, FhirContext fhirContext) { if (theResponseObject == null) { return Collections.emptyList(); } List<IBaseResource> retVal; boolean isContainer = false; if (theResponseObject instanceof IBaseBundle) { isContainer = true; } else if (theResponseObject instanceof IBaseParameters) { isContainer = true; } if (!isContainer) { return Collections.singletonList(theResponseObject); } retVal = fhirContext.newTerser().getAllPopulatedChildElementsOfType(theResponseObject, IBaseResource.class); // Exclude the container if (retVal.size() > 0 && retVal.get(0) == theResponseObject) { retVal = retVal.subList(1, retVal.size()); } return retVal; }
return new HttpPostClientInvocation(theContext, theInput, b.toString()); FhirTerser t = theContext.newTerser(); List<Object> parameters = t.getValues(theInput, "Parameters.parameter");
@Override protected List<Object> extractValues(String thePaths, IBaseResource theResource) { List<Object> values = new ArrayList<>(); String[] nextPathsSplit = SPLIT.split(thePaths); FhirTerser t = getContext().newTerser(); for (String nextPath : nextPathsSplit) { String nextPathTrimmed = nextPath.trim(); List<Object> allValues; try { allValues = t.getValues(theResource, nextPathTrimmed); } catch (Exception e) { String msg = getContext().getLocalizer().getMessage(BaseSearchParamExtractor.class, "failedToExtractPaths", nextPath, e.toString()); throw new InternalErrorException(msg, e); } for (Object next : allValues) { if (next instanceof IBaseExtension) { IBaseDatatype value = ((IBaseExtension) next).getValue(); if (value != null) { values.add(value); } } else { values.add(next); } } } return values; }
private String determineSystemIfMissing(String theParamName, String code, String theSystem) { String retVal = theSystem; if (retVal == null) { RuntimeResourceDefinition resourceDef = myContext.getResourceDefinition(myResourceName); RuntimeSearchParam param = mySearchParamRegistry.getSearchParamByName(resourceDef, theParamName); if (param != null) { Set<String> valueSetUris = Sets.newHashSet(); for (String nextPath : param.getPathsSplit()) { BaseRuntimeChildDefinition def = myContext.newTerser().getDefinition(myResourceType, nextPath); if (def instanceof BaseRuntimeDeclaredChildDefinition) { String valueSet = ((BaseRuntimeDeclaredChildDefinition) def).getBindingValueSet(); if (isNotBlank(valueSet)) { valueSetUris.add(valueSet); } } } if (valueSetUris.size() == 1) { String valueSet = valueSetUris.iterator().next(); List<VersionIndependentConcept> candidateCodes = myTerminologySvc.expandValueSet(valueSet); for (VersionIndependentConcept nextCandidate : candidateCodes) { if (nextCandidate.getCode().equals(code)) { retVal = nextCandidate.getSystem(); break; } } } } } return retVal; }
private static boolean payloadContainsNoPlaceholderReferences(FhirContext theCtx, IBaseResource theNewPayload) { List<ResourceReferenceInfo> refs = theCtx.newTerser().getAllResourceReferences(theNewPayload); for (ResourceReferenceInfo next : refs) { String ref = next.getResourceReference().getReferenceElement().getValue(); if (isBlank(ref)) { IBaseResource resource = next.getResourceReference().getResource(); if (resource != null) { ref = resource.getIdElement().getValue(); } } if (isNotBlank(ref)) { if (ref.startsWith("#")) { continue; } if (ref.startsWith("urn:uuid:")) { throw new AssertionError("Reference at " + next.getName() + " is invalid: " + ref); } } } return true; }
IRuntimeDatatypeDefinition targetTypeDtDef = (IRuntimeDatatypeDefinition) targetTypeDef; if (targetTypeDtDef.isProfileOf(sourceType)) { FhirTerser terser = myContext.newTerser(); IBase newTarget = targetTypeDef.newInstance(); terser.cloneInto((IBase) nextValue, newTarget, true);
for (ResourceReferenceInfo nextRefInfo : ctx.newTerser().getAllResourceReferences(nextQueued)) { String nextRef = nextRefInfo.getResourceReference().getReferenceElement().getValue(); if (isNotBlank(nextRef) && !sent.contains(nextRef)) {
.newTerser() .getSingleValueOrNull(theSubscription, SubscriptionMatcherInterceptor.SUBSCRIPTION_TYPE, IPrimitiveType.class) .getValueAsString(); final IPrimitiveType<?> status = myFhirContext.newTerser().getSingleValueOrNull(theSubscription, SubscriptionMatcherInterceptor.SUBSCRIPTION_STATUS, IPrimitiveType.class); String statusString = status.getValueAsString();
private boolean loadReferences(IBaseResource theResource, WorkerContext theWorkerCtx, IValidationContext<?> theValCtx, ArrayList<ValidationMessage> theMessages) { List<ResourceReferenceInfo> refs = theValCtx.getFhirContext().newTerser().getAllResourceReferences(theResource);
return; FhirTerser terser = myContext.newTerser(); List<IBaseReference> allRefs = terser.getAllPopulatedChildElementsOfType(theResource, IBaseReference.class); for (IBaseReference nextRef : allRefs) {
List<ResourceReferenceInfo> refs = ctx.newTerser().getAllResourceReferences(next.getResource()); for (ResourceReferenceInfo nextRef : refs) { nextRef.getResourceReference().setResource(null);
private static void copy(FhirContext theCtx, IGenericClient theTarget, String theResType, List<IBaseResource> theQueued, Set<String> theSent, Bundle theReceived) { for (Bundle.BundleEntryComponent nextEntry : theReceived.getEntry()) { Resource nextResource = nextEntry.getResource(); nextResource.setId(theResType + "/" + "CR-" + nextResource.getIdElement().getIdPart()); boolean haveUnsentReference = false; for (ResourceReferenceInfo nextRefInfo : theCtx.newTerser().getAllResourceReferences(nextResource)) { IIdType nextRef = nextRefInfo.getResourceReference().getReferenceElement(); if (nextRef.hasIdPart()) { String newRef = nextRef.getResourceType() + "/" + "CR-" + nextRef.getIdPart(); ourLog.info("Changing reference {} to {}", nextRef.getValue(), newRef); nextRefInfo.getResourceReference().setReference(newRef); if (!theSent.contains(newRef)) { haveUnsentReference = true; } } } if (haveUnsentReference) { ourLog.info("Queueing {} for delivery after", nextResource.getId()); theQueued.add(nextResource); continue; } IIdType newId = theTarget .update() .resource(nextResource) .execute() .getId(); ourLog.info("Copied resource {} and got ID {}", nextResource.getId(), newId); theSent.add(nextResource.getIdElement().toUnqualifiedVersionless().getValue()); } }
List<BaseResourceReferenceDt> references = myContext.newTerser().getAllPopulatedChildElementsOfType(next, BaseResourceReferenceDt.class); do { List<IResource> addedResourcesThisPass = new ArrayList<IResource>(); List<BaseResourceReferenceDt> newReferences = myContext.newTerser().getAllPopulatedChildElementsOfType(iResource, BaseResourceReferenceDt.class); references.addAll(newReferences);
List<IBaseReference> references = myContext.newTerser().getAllPopulatedChildElementsOfType(next, IBaseReference.class); do { List<IAnyResource> addedResourcesThisPass = new ArrayList<IAnyResource>(); List<IBaseReference> newReferences = myContext.newTerser().getAllPopulatedChildElementsOfType(iResource, IBaseReference.class); references.addAll(newReferences);
List<IBaseReference> references = myContext.newTerser().getAllPopulatedChildElementsOfType(next, IBaseReference.class); do { List<IAnyResource> addedResourcesThisPass = new ArrayList<>(); List<IBaseReference> newReferences = myContext.newTerser().getAllPopulatedChildElementsOfType(iResource, IBaseReference.class); references.addAll(newReferences);
String nextResourceUrl = ((IPrimitiveType<?>)ctx.newTerser().getSingleValueOrNull(nextResource, "url")).getValueAsString(); ourLog.info("Uploading resource: {}", nextResourceUrl); client
List<IBaseReference> allReferences = myContext.newTerser().getAllPopulatedChildElementsOfType(theResource, IBaseReference.class); for (IBaseReference next : allReferences) { IBaseResource resource = next.getResource();
FhirTerser t = getContext().newTerser(); List<ResourceReferenceInfo> refs = t.getAllResourceReferences(theResource); for (ResourceReferenceInfo nextRef : refs) {