Hapi FHIR - 预约患者 ID 和服务类别名称列表

问题描述 投票:0回答:1

我是 HAPI FHIR api 的新手, 但我正在尝试获取具有服务类别和服务类型代码的 patientID 的预约资源。

我可以找到

withIDAndCompartment
患者的预约,但不确定如何添加搜索条件。

Bundle bundle = fhirClient.search().forResource(Patient.class).withIdAndCompartment(patientId, ResourceType.Appointment.name()).returnBundle(Bunle.class).execute();

List<Appointment> appointments = BundleUtil.toListOfResourcesOfType(fhirClient.getFhirContext(), bundle, Appointment.class);

将返回 patientId 的约会。

我不确定如何使用TokenClientParam,

Appointment.SERVICE_CATEGORY
Appointment.SERVICE_TYPE
,通过输入服务类别或服务类型代码来搜索预约类型。

任何帮助将不胜感激

java hl7-fhir hapi hapi-fhir
1个回答
0
投票

你可以试试:

// Create the search parameters
AppointmentSearchParams searchParams = new AppointmentSearchParams();
searchParams
  .setServiceCategory(new TokenClientParam("http://example.com/fhir/service-category", "category-code"))
  .setServiceType(new TokenClientParam("http://example.com/fhir/service-type", "type-code"));

// Execute the search
Bundle bundle = fhirClient.search()
  .forResource(Appointment.class)
  .withIdAndCompartment(patientId, ResourceType.Patient.name())
  .where(searchParams)
  .returnBundle(Bundle.class)
  .execute();

// Retrieve the Appointments from the search results
List<Appointment> appointments = BundleUtil.toListOfResourcesOfType(fhirClient.getFhirContext(), bundle, Appointment.class);

注意:您应该将 http://example.com/fhir/service-categoryhttp://example.com/fhir/service-type 替换为服务类别和服务类型代码的实际系统值你想搜索。如果您不知道这些或想在所有系统中搜索,那么您的搜索参数将需要如下所示。注意使用 null 而不是实际的系统值:

// Create the search parameters
AppointmentSearchParams searchParams = new AppointmentSearchParams();
searchParams
  .setServiceCategory(new TokenClientParam(null, "category-code"))
  .setServiceType(new TokenClientParam(null, "type-code"));
© www.soinside.com 2019 - 2024. All rights reserved.