public static void fetchRestOfBundle(IGenericClient theClient, Bundle theBundle) { // we need to keep track of which resources are already in the bundle so that if other resources (e.g. Practitioner) are _included, // we don't end up with multiple copies Set<String> resourcesAlreadyAdded = new HashSet<String>(); addInitialUrlsToSet(theBundle, resourcesAlreadyAdded); Bundle partialBundle = theBundle; for (;;) { if (partialBundle.getLink(IBaseBundle.LINK_NEXT) != null) { partialBundle = theClient.loadPage().next(partialBundle).execute(); addAnyResourcesNotAlreadyPresentToBundle(theBundle, partialBundle, resourcesAlreadyAdded); } else { break; } } // the self and next links for the aggregated bundle aren't really valid anymore, so remove them theBundle.getLink().clear(); }
/** * Load the previous page of results using the link with relation "prev" in the bundle. This * method accepts a DSTU2+ Bundle resource * @param <T> extends {@link IBaseBundle} * @param bundle the {@link IBaseBundle} * @param extraParameters see {@link ExtraParameters} for a full list of parameters that can be passed, may be NULL * @return the previous {@link IBaseBundle} */ public <T extends IBaseBundle> T previous(T bundle, Map<ExtraParameters, Object> extraParameters) { IGetPageTyped<T> getPageTyped = client.loadPage().previous(bundle); ExtraParameters.process(extraParameters, getPageTyped); return getPageTyped.execute(); }
/** * Load a page of results using the given URL and bundle type and return a DSTU1 Atom bundle * @param extraParameters see {@link ExtraParameters} for a full list of parameters that can be passed, may be NULL * @param <T> extends {@link IBaseBundle} * @param url the search url * @param returnType the return type * @return the {@link IBaseBundle} page */ public <T extends IBaseBundle> T byUrl(String url, Class<T> returnType, Map<ExtraParameters, Object> extraParameters) { IGetPageTyped<T> getPageTyped = client.loadPage().byUrl(url).andReturnBundle(returnType); ExtraParameters.process(extraParameters, getPageTyped); return getPageTyped.execute(); }
protected Bundle previousPage(Bundle bundle) { return client.loadPage() .previous(bundle) .execute(); }
private static void copy(FhirContext theCtx, IGenericClient theSource, IGenericClient theTarget, String theResType, List<IBaseResource> theQueued, Set<String> theSent) { Bundle received = theSource .search() .forResource(theResType) .returnBundle(Bundle.class) .execute(); copy(theCtx, theTarget, theResType, theQueued, theSent, received); while (received.getLink("next") != null) { ourLog.info("Fetching next page..."); received = theSource.loadPage().next(received).execute(); copy(theCtx, theTarget, theResType, theQueued, theSent, received); } }
protected Bundle previousPage(Bundle bundle) { return client.loadPage() .previous(bundle) .execute(); }
private static void paging() { { // START SNIPPET: searchPaging FhirContext ctx = FhirContext.forDstu2(); IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu2"); // Perform a search Bundle resultBundle = client.search() .forResource(Patient.class) .where(Patient.NAME.matches().value("Smith")) .returnBundle(Bundle.class) .execute(); if (resultBundle.getLink(Bundle.LINK_NEXT) != null) { // load next page Bundle nextPage = client.loadPage().next(resultBundle).execute(); } // END SNIPPET: searchPaging } }
protected Bundle previousPage(Bundle bundle) { return client.loadPage() .previous(bundle) .execute(); }
/** * Load the next page of results using the link with relation "next" in the bundle. This * method accepts a DSTU2 Bundle resource * @param <T> extends {@link IBaseBundle} * @param bundle the {@link IBaseBundle} * @param extraParameters see {@link ExtraParameters} for a full list of parameters that can be passed, may be NULL * @return the next {@link IBaseBundle} */ public <T extends IBaseBundle> T next(T bundle, Map<ExtraParameters, Object> extraParameters) { IGetPageTyped<T> getPageTyped = client.loadPage().next(bundle); ExtraParameters.process(extraParameters, getPageTyped); return getPageTyped.execute(); }
protected Bundle previousPage(Bundle bundle) { return client.loadPage() .previous(bundle) .execute(); }
protected Bundle nextPage(Bundle bundle) { return client.loadPage() .next(bundle) .execute(); }
protected Bundle previousPage(Bundle bundle) { return client.loadPage() .previous(bundle) .execute(); }
protected Bundle nextPage(Bundle bundle) { return client.loadPage() .next(bundle) .execute(); }
protected Bundle previousPage(Bundle bundle) { return client.loadPage() .previous(bundle) .execute(); }
protected Bundle nextPage(Bundle bundle) { return client.loadPage() .next(bundle) .execute(); }
protected Bundle nextPage(Bundle bundle) { return client.loadPage() .next(bundle) .execute(); }
protected Bundle nextPage(Bundle bundle) { return client.loadPage() .next(bundle) .execute(); }
protected Bundle nextPage(Bundle bundle) { return client.loadPage() .next(bundle) .execute(); }
public static void step2_search_for_patients_named_test() { FhirContext ctx = FhirContext.forDstu3(); IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu3"); org.hl7.fhir.dstu3.model.Bundle results = client .search() .forResource(Patient.class) .where(Patient.NAME.matches().value("test")) .returnBundle(org.hl7.fhir.dstu3.model.Bundle.class) .execute(); System.out.println("First page: "); System.out.println(ctx.newXmlParser().encodeResourceToString(results)); // Load the next page org.hl7.fhir.dstu3.model.Bundle nextPage = client .loadPage() .next(results) .execute(); System.out.println("Next page: "); System.out.println(ctx.newXmlParser().encodeResourceToString(nextPage)); }