use of ca.uhn.fhir.rest.gclient.ReferenceClientParam in project loinc2hpo by monarch-initiative.
the class FhirResourceRetriever method retrieveObservationFromServer.
/**
* @TODO: implement it
* retrieve a patient's observations from FHIR server
* @param patient
* @return
*/
public static List<Observation> retrieveObservationFromServer(Patient patient) {
List<Observation> observationList = new ArrayList<>();
String id = patient.getId();
if (id != null) {
Bundle observationBundle = client.search().forResource(Observation.class).where(new ReferenceClientParam("subject").hasId(id)).prettyPrint().returnBundle(Bundle.class).execute();
while (true) {
observationBundle.getEntry().forEach(p -> observationList.add((Observation) p.getResource()));
if (observationBundle.getLink(IBaseBundle.LINK_NEXT) != null) {
observationBundle = client.loadPage().next(observationBundle).execute();
} else {
break;
}
}
}
return observationList;
}
Aggregations