![](/img/trans.png)
[英]HL7-Fhir : when posting a resource, is it allowed to reference to another resources by search criteria?
[英]Accessing a resource within a Bundle HL7-FHIR
我只是想知道是否有一種方法可以訪問捆綁中的資源。
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();
診斷是當前引起問題的原因。 由於我有一個客戶端通過生成的ID訪問他們的報告(因此,使用包搜索命令),但是要訪問diagnosticReport引用的所有其他資源,因此無法找到一種方法來從包中分離資源或直接獲取資源從捆綁中。
謝謝
如果您只想從捆綁軟件中獲取DiagnosticReport
資源,則應該可以執行以下操作:
DiagnosticReport dr = (DiagnosticReport) bundle.getEntry().get(0).getResource();
如果需要,還可以使用include在一次調用中將其他鏈接的資源返回給服務器:
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();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.