[英]Is there any way to fetch the list of resource types available for a patient id from FHIR Server?
I want the fetch the list of resource types available for a patient from the FHIR server.我想从 FHIR 服务器获取患者可用的资源类型列表。 I tried to fetch the List of items from the Patient.我试图从患者那里获取物品清单。 But it doesn't contain all the resource types available for that particular patient.但它不包含该特定患者可用的所有资源类型。
http://hapi.fhir.org/baseR4/metadata http://hapi.fhir.org/baseR4/metadata
http://wildfhir4.aegis.net/fhir4-0-1/metadata http://wildfhir4.aegis.net/fhir4-0-1/metadata
https://vonk.fire.ly/R4/metadata https://vonk.fire.ly/R4/metadata
I think you're asking this.我想你在问这个。
If you examine any of the reference implementations above.如果您检查上述任何参考实现。 you'll get the CapabilityStatement.您将获得 CapabilityStatement。
You look at the CapabilityStatement, find the Fhir-Resource ("Patient" here), and then any includes and rev-includes.您查看 CapabilityStatement,找到 Fhir-Resource(此处为“Patient”),然后找到任何包含和 rev-includes。
"type": "Patient",
"searchInclude": [
"Patient:general-practitioner",
"Patient:link",
"Patient:organization"
],
"searchRevInclude": [
"Account:patient",
"Account:subject",
also see:另见:
https://www.hl7.org/fhir/search.html#include https://www.hl7.org/fhir/search.html#include
I think what your asking is resources types linked to a Patient.我认为您要问的是与患者相关的资源类型。 In this case you can do a http://base/fhir/Patient/[id]/$everything在这种情况下,您可以执行 http://base/fhir/Patient/[id]/$everything
https://hl7.org/fhir/operation-patient-everything.html https://hl7.org/fhir/operation-patient-everything.html
When you say "the list of resource types available for a patient from the FHIR server", I think what you mean is the resource types that can be searched by patient on the FHIR server.当您说“FHIR 服务器上患者可用的资源类型列表”时,我认为您的意思是患者可以在 FHIR 服务器上搜索的资源类型。
To build such a list, read the FHIR server's CapabilityStatement
.要构建这样的列表,请阅读 FHIR 服务器的CapabilityStatement
。 Iterate through the CapabilityStatement's resource
array, checking each item's searchParam
array for an element where name
= 'patient' and type
= 'reference'.遍历 CapabilityStatement 的resource
数组,检查每个项目的searchParam
数组中是否存在name
= 'patient' 和type
= 'reference' 的元素。 If you find it, add that item's type
value (ie the resource type) to the list.如果您找到它,将该项目的type
值(即资源类型)添加到列表中。
Thank you all for posting your answers.感谢大家发布您的答案。 I have achieved this by making a batch request like the below,我通过发出如下的批处理请求来实现这一点,
Bundle bundle = new Bundle();
bundle.setType(Bundle.BundleType.TRANSACTION);
// Adding bundle entries to make the batch request
// To fetch the resource count for each resource type
for (String resource : resources) {
String url = String.format(MyConstants.URLs.FETCH_SUMMARY_COUNT,
resource, patientId);
bundle.addEntry().getRequest().setUrl(url).setMethod(Bundle.HTTPVerb.GET);
}
try {
// Create a client
IGenericClient client = fhirContext.newRestfulGenericClient(fhirServerUrl);
BearerTokenAuthInterceptor bearerTokenAuthInterceptor = new BearerTokenAuthInterceptor(accessToken);
client.registerInterceptor(bearerTokenAuthInterceptor);
bundle = client.transaction().withBundle(bundle).execute();
IFhirPath iFhirPath = fhirContext.newFhirPath();
List<IntegerType> counts = iFhirPath.evaluate(bundle, MyConstants.FHIRPATH.SUMMARY_COUNT_FROM_BUNDLE,
IntegerType.class);
ResourceTypesResponse resourceTypesResponse = ResourceParser.getResourceTypes(counts, resources);
if (resourceTypesResponse == null) {
throw new PatientNotFoundException("Resource Not Found");
}
return resourceTypesResponse;
} catch (Exception e) {
if (e.getMessage().equalsIgnoreCase("HTTP 401 Unauthorized")) {
return getResourceBundleForPatient(patientId, resources);
} else {
throw new PatientNotFoundException("Patient Id Not Found");
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.