2

我只是想知道是否有办法访问包中的资源。

IE

        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 目前是导致问题的原因。由于我有一个客户通过生成的 ID 访问他们的报告(因此是捆绑搜索命令),但是要访问由 diagnosticReport 引用的所有其他资源,我找不到将资源与捆绑分开或直接抓取的方法从捆绑。

谢谢

4

1 回答 1

3

If you just want to grab the DiagnosticReport resource from the bundle you should be able to do something like:

DiagnosticReport dr = (DiagnosticReport) bundle.getEntry().get(0).getResource();

If you wanted, you could also use includes to return the other linked resources in a single call to the server:

Bundle bundle = client.search().forResource(DiagnosticReport.class)
  .where(new StringClientParam("_id").matches().value("117376"))
  .include(new Include("DiagnosticReport:patient"))
  .include(new Include("DiagnosticReport:result"))
  .returnBundle(Bundle.class)
  .execute();
于 2016-07-25T21:35:42.547 回答