[英]Is there any way to fetch the list of resource types available for a patient id from FHIR Server?
我想从 FHIR 服务器获取患者可用的资源类型列表。 我试图从患者那里获取物品清单。 但它不包含该特定患者可用的所有资源类型。
http://hapi.fhir.org/baseR4/metadata
http://wildfhir4.aegis.net/fhir4-0-1/metadata
https://vonk.fire.ly/R4/metadata
我想你在问这个。
如果您检查上述任何参考实现。 您将获得 CapabilityStatement。
您查看 CapabilityStatement,找到 Fhir-Resource(此处为“Patient”),然后找到任何包含和 rev-includes。
"type": "Patient",
"searchInclude": [
"Patient:general-practitioner",
"Patient:link",
"Patient:organization"
],
"searchRevInclude": [
"Account:patient",
"Account:subject",
另见:
我认为您要问的是与患者相关的资源类型。 在这种情况下,您可以执行 http://base/fhir/Patient/[id]/$everything
当您说“FHIR 服务器上患者可用的资源类型列表”时,我认为您的意思是患者可以在 FHIR 服务器上搜索的资源类型。
要构建这样的列表,请阅读 FHIR 服务器的CapabilityStatement
。 遍历 CapabilityStatement 的resource
数组,检查每个项目的searchParam
数组中是否存在name
= 'patient' 和type
= 'reference' 的元素。 如果您找到它,将该项目的type
值(即资源类型)添加到列表中。
感谢大家发布您的答案。 我通过发出如下的批处理请求来实现这一点,
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.