I was just wondering if there is a way to access a resource within a bundle.
I.E
FhirContext ctx = FhirContext.forDstu3();
String baseSite= "http://fhirtest.uhn.ca/baseDstu3/";
IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu3");
System.out.println("Connected to server");
Bundle bundle = client.search().forResource(DiagnosticReport.class).where(DiagnosticReport.IDENTIFIER.exactly().identifier(id)).returnBundle(Bundle.class).execute();
DiagnosticReport diag =client.read().resource(DiagnosticReport.class).withId(bundle.getEntry().get(0).getResource());
String finalBundle=ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(diag);
System.out.println(finalBundle);
Observation obv = client.read().resource(Observation.class).withUrl(baseSite+diag.getResult().get(0).getReference()).execute();
Sequence seq = client.read().resource(Sequence.class).withUrl(baseSite+obv.getRelated().get(0).getTarget()).execute();
diag is currently what is causing issues. Since I have a client access their report via ID that is generated (thus the bundle search command) but to access all the other resources that are referenced by diagnosticReport I can't find a way to either separate the resource from the bundle or directly grab from the bundle.
Thank you