Search in sources :

Example 1 with StringClientParam

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

the class ObservationDownloader method retrievePatient.

static List<Patient> retrievePatient(String given, String family) {
    List<Patient> patients = new ArrayList<>();
    Bundle bundle = client.search().forResource(Patient.class).where(new StringClientParam("given").matches().value(given)).where(new StringClientParam("family").matches().value(family)).prettyPrint().returnBundle(Bundle.class).execute();
    while (true) {
        for (Bundle.BundleEntryComponent bundleEntryComponent : bundle.getEntry()) {
            Patient patient = (Patient) bundleEntryComponent.getResource();
            patients.add(patient);
        }
        if (bundle.getLink(IBaseBundle.LINK_NEXT) != null) {
            bundle = client.loadPage().next(bundle).execute();
        } else {
            break;
        }
    }
    return patients;
}
Also used : StringClientParam(ca.uhn.fhir.rest.gclient.StringClientParam) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) ArrayList(java.util.ArrayList)

Aggregations

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