private void minimizeResource(IBaseResource theInput) { if (theInput instanceof IBaseBundle) { for (IBaseResource next : BundleUtil.toListOfResources(myCtx, (IBaseBundle) theInput)) { minimizeResource(next); } } BaseRuntimeElementCompositeDefinition<?> element = (BaseRuntimeElementCompositeDefinition) myCtx.getElementDefinition(theInput.getClass()); BaseRuntimeChildDefinition textElement = element.getChildByName("text"); if (textElement != null) { textElement.getMutator().setValue(theInput, null); } }
private boolean requestAppliesToTransaction(FhirContext theContext, RuleOpEnum theOp, IBaseResource theInputResource) { if (!"Bundle".equals(theContext.getResourceDefinition(theInputResource).getName())) { return false; } IBaseBundle request = (IBaseBundle) theInputResource; String bundleType = defaultString(BundleUtil.getBundleType(theContext, request)); //noinspection EnumSwitchStatementWhichMissesCases if (theOp == RuleOpEnum.TRANSACTION) { if ("transaction".equals(bundleType) || "batch".equals(bundleType)) { return true; } else { String msg = theContext.getLocalizer().getMessage(RuleImplOp.class, "invalidRequestBundleTypeForTransaction", '"' + bundleType + '"'); throw new UnprocessableEntityException(msg); } } return false; }
/** * Extract all of the resources from a given bundle */ public static List<IBaseResource> toListOfResources(FhirContext theContext, IBaseBundle theBundle) { return toListOfResourcesOfType(theContext, theBundle, null); }
return new Verdict(PolicyEnum.DENY, this); List<BundleEntryParts> inputResources = BundleUtil.toListOfEntries(ctx, (IBaseBundle) theInputResource); Verdict verdict = null;
return new Verdict(PolicyEnum.DENY, this); List<BundleEntryParts> inputResources = BundleUtil.toListOfEntries(ctx, (IBaseBundle) theInputResource); Verdict verdict = null;
private void sendBundleToTarget(String targetServer, FhirContext ctx, IBaseBundle bundle, CommandLine theCommandLine) throws Exception { List<IBaseResource> resources = BundleUtil.toListOfResources(ctx, bundle);
/** * Extract all of the resources from a given bundle */ public static List<IBaseResource> toListOfResources(FhirContext theContext, IBaseBundle theBundle) { return toListOfResourcesOfType(theContext, theBundle, null); }
private boolean requestAppliesToTransaction(FhirContext theContext, RuleOpEnum theOp, IBaseResource theInputResource) { if (!"Bundle".equals(theContext.getResourceDefinition(theInputResource).getName())) { return false; } IBaseBundle request = (IBaseBundle) theInputResource; String bundleType = defaultString(BundleUtil.getBundleType(theContext, request)); //noinspection EnumSwitchStatementWhichMissesCases if (theOp == RuleOpEnum.TRANSACTION) { if ("transaction".equals(bundleType) || "batch".equals(bundleType)) { return true; } else { String msg = theContext.getLocalizer().getMessage(RuleImplOp.class, "invalidRequestBundleTypeForTransaction", '"' + bundleType + '"'); throw new UnprocessableEntityException(msg); } } return false; }
Class<? extends IBaseResource> type = getContext().getResourceDefinition("Bundle").getImplementingClass(); bundle = (IBaseBundle) parser.parseResource(type, theResponseInputStream); listOfResources = BundleUtil.toListOfResources(getContext(), bundle); List<IBaseResource> list = BundleUtil.toListOfResources(getContext(), bundle); if (list.size() == 0) { return null;
@Override public Object translateQueryParametersIntoServerArgument(RequestDetails theRequest, BaseMethodBinding<?> theMethodBinding) throws InternalErrorException, InvalidRequestException { // TODO: don't use a default encoding, just fail! EncodingEnum encoding = RestfulServerUtils.determineRequestEncoding(theRequest); IParser parser = encoding.newParser(theRequest.getServer().getFhirContext()); Reader reader = ResourceParameter.createRequestReader(theRequest); try { switch (myParamStyle) { case RESOURCE_LIST: { Class<? extends IBaseResource> type = myContext.getResourceDefinition("Bundle").getImplementingClass(); IBaseResource bundle = parser.parseResource(type, reader); List<IBaseResource> resourceList = BundleUtil.toListOfResources(myContext, (IBaseBundle) bundle); return resourceList; } case RESOURCE_BUNDLE: return parser.parseResource(myResourceBundleType, reader); } throw new IllegalStateException("Unknown type: " + myParamStyle); // should not happen } finally { IOUtils.closeQuietly(reader); } }
@Override public IBundleProvider search(SearchParameterMap theParams) { FhirContext fhirContext = myClient.getFhirContext(); IBaseBundle bundle = myClient .search() .forResource(ResourceTypeEnum.SEARCHPARAMETER.getCode()) .cacheControl(new CacheControlDirective().setNoCache(true)) .execute(); return new SimpleBundleProvider(BundleUtil.toListOfResources(fhirContext, bundle)); }
@Override public IBundleProvider search(SearchParameterMap theMap) { FhirContext fhirContext = myClient.getFhirContext(); String searchURL = ResourceTypeEnum.SUBSCRIPTION.getCode() + theMap.toNormalizedQueryString(myFhirContext); IBaseBundle bundle = myClient .search() .byUrl(searchURL) .cacheControl(new CacheControlDirective().setNoCache(true)) .execute(); return new SimpleBundleProvider(BundleUtil.toListOfResources(fhirContext, bundle)); }
List<IBaseResource> subResources = BundleUtil.toListOfResources(myCtx, bundle); for (IBaseResource nextSubResource : subResources) { validateResource(ValidationContext.subContext(theCtx, nextSubResource));
Class<? extends IBaseResource> type = getContext().getResourceDefinition("Bundle").getImplementingClass(); bundle = (IBaseBundle) parser.parseResource(type, theResponseInputStream); listOfResources = BundleUtil.toListOfResources(getContext(), bundle); List<IBaseResource> list = BundleUtil.toListOfResources(getContext(), bundle); if (list.size() == 0) { return null;
@Override public Object translateQueryParametersIntoServerArgument(RequestDetails theRequest, BaseMethodBinding<?> theMethodBinding) throws InternalErrorException, InvalidRequestException { // TODO: don't use a default encoding, just fail! EncodingEnum encoding = RestfulServerUtils.determineRequestEncoding(theRequest); IParser parser = encoding.newParser(theRequest.getServer().getFhirContext()); Reader reader = ResourceParameter.createRequestReader(theRequest); try { switch (myParamStyle) { case RESOURCE_LIST: { Class<? extends IBaseResource> type = myContext.getResourceDefinition("Bundle").getImplementingClass(); IBaseResource bundle = parser.parseResource(type, reader); List<IBaseResource> resourceList = BundleUtil.toListOfResources(myContext, (IBaseBundle) bundle); return resourceList; } case RESOURCE_BUNDLE: return parser.parseResource(myResourceBundleType, reader); } throw new IllegalStateException("Unknown type: " + myParamStyle); // should not happen } finally { IOUtils.closeQuietly(reader); } }
List<IBaseResource> subResources = BundleUtil.toListOfResources(myCtx, bundle); for (IBaseResource nextSubResource : subResources) { validateResource(ValidationContext.subContext(theCtx, nextSubResource));