Search in sources :

Example 1 with TokenClientParam

use of ca.uhn.fhir.rest.gclient.TokenClientParam in project loinc2hpo by monarch-initiative.

the class ObservationDownloader method retrieveObservation.

static List<Observation> retrieveObservation(String loincCode) {
    List<Observation> results = new ArrayList<>();
    Bundle bundle = client.search().forResource(Observation.class).where(new TokenClientParam("code").exactly().systemAndCode(LOINC_SYSTEM, loincCode)).prettyPrint().returnBundle(Bundle.class).execute();
    while (true) {
        for (Bundle.BundleEntryComponent bundleEntryComponent : bundle.getEntry()) {
            Observation observation = (Observation) bundleEntryComponent.getResource();
            results.add(observation);
        }
        if (bundle.getLink(IBaseBundle.LINK_NEXT) != null) {
            bundle = client.loadPage().next(bundle).execute();
        } else {
            break;
        }
    }
    return results;
}
Also used : TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) ArrayList(java.util.ArrayList)

Aggregations

TokenClientParam (ca.uhn.fhir.rest.gclient.TokenClientParam)1 ArrayList (java.util.ArrayList)1 IBaseBundle (org.hl7.fhir.instance.model.api.IBaseBundle)1