Sarvesh
Sarvesh

Reputation: 581

Compartment Search is not working in Hapi Fhir JPA Server

I am using Hapi FHIR Jpa Server implementation for R4. I was trying compartment search on this server. It is throwing error. I am using Generic Client to perform compartment search.

response = client.search()
  .forResource(FamilyMemberHistory.class)
  .withIdAndCompartment("b3126407-6d25-4fc1-a8b2-d0d6f629be92", "Patient")
  .returnBundle(Bundle.class)
  .execute();

I have registered LoggingInterceptor to my GenericClient to see how request is getting formed. It looks like http://localhost:8090/fhir/FamilyMemberHistory/b3126407-6d25-4fc1-a8b2-d0d6f629be92/Patient. When Hapi Fhir JPA Server receives this request, it is throwing following error.

2020-05-13 14:03:49.033 TRACE 52512 --- [io-8090-exec-10] c.u.f.r.s.method.SearchMethodBinding     : Method public ca.uhn.fhir.rest.api.server.IBundleProvider ca.uhn.fhir.jpa.rp.r4.FamilyMemberHistoryResourceProvider.search(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,ca.uhn.fhir.rest.api.server.RequestDetails,ca.uhn.fhir.rest.param.StringAndListParam,ca.uhn.fhir.rest.param.StringAndListParam,ca.uhn.fhir.rest.param.StringAndListParam,ca.uhn.fhir.rest.param.TokenAndListParam,ca.uhn.fhir.rest.param.TokenAndListParam,ca.uhn.fhir.rest.param.UriAndListParam,ca.uhn.fhir.rest.param.UriAndListParam,ca.uhn.fhir.rest.param.HasAndListParam,ca.uhn.fhir.rest.param.TokenAndListParam,ca.uhn.fhir.rest.param.StringAndListParam,ca.uhn.fhir.rest.param.TokenAndListParam,ca.uhn.fhir.rest.param.DateRangeParam,ca.uhn.fhir.rest.param.TokenAndListParam,ca.uhn.fhir.rest.param.TokenAndListParam,ca.uhn.fhir.rest.param.ReferenceAndListParam,ca.uhn.fhir.rest.param.UriAndListParam,ca.uhn.fhir.rest.param.ReferenceAndListParam,ca.uhn.fhir.rest.param.TokenAndListParam,ca.uhn.fhir.rest.param.TokenAndListParam,java.util.Map,java.util.Set,ca.uhn.fhir.rest.param.DateRangeParam,java.util.Set,ca.uhn.fhir.rest.api.SortSpec,java.lang.Integer,ca.uhn.fhir.rest.api.SummaryEnum,ca.uhn.fhir.rest.api.SearchTotalModeEnum) doesn't match because ID is not null: FamilyMemberHistory/b3126407-6d25-4fc1-a8b2-d0d6f629be92
2020-05-13 14:03:49.033 TRACE 52512 --- [io-8090-exec-10] ca.uhn.fhir.rest.server.ResourceBinding  : Handler public ca.uhn.fhir.rest.api.server.IBundleProvider ca.uhn.fhir.jpa.rp.r4.FamilyMemberHistoryResourceProvider.search(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,ca.uhn.fhir.rest.api.server.RequestDetails,ca.uhn.fhir.rest.param.StringAndListParam,ca.uhn.fhir.rest.param.StringAndListParam,ca.uhn.fhir.rest.param.StringAndListParam,ca.uhn.fhir.rest.param.TokenAndListParam,ca.uhn.fhir.rest.param.TokenAndListParam,ca.uhn.fhir.rest.param.UriAndListParam,ca.uhn.fhir.rest.param.UriAndListParam,ca.uhn.fhir.rest.param.HasAndListParam,ca.uhn.fhir.rest.param.TokenAndListParam,ca.uhn.fhir.rest.param.StringAndListParam,ca.uhn.fhir.rest.param.TokenAndListParam,ca.uhn.fhir.rest.param.DateRangeParam,ca.uhn.fhir.rest.param.TokenAndListParam,ca.uhn.fhir.rest.param.TokenAndListParam,ca.uhn.fhir.rest.param.ReferenceAndListParam,ca.uhn.fhir.rest.param.UriAndListParam,ca.uhn.fhir.rest.param.ReferenceAndListParam,ca.uhn.fhir.rest.param.TokenAndListParam,ca.uhn.fhir.rest.param.TokenAndListParam,java.util.Map,java.util.Set,ca.uhn.fhir.rest.param.DateRangeParam,java.util.Set,ca.uhn.fhir.rest.api.SortSpec,java.lang.Integer,ca.uhn.fhir.rest.api.SummaryEnum,ca.uhn.fhir.rest.api.SearchTotalModeEnum) does not match
2020-05-13 14:03:49.033 DEBUG 52512 --- [io-8090-exec-10] ca.uhn.fhir.rest.server.ResourceBinding  : Looking for a handler for ca.uhn.fhir.rest.server.servlet.ServletRequestDetails@25b24c89
2020-05-13 14:03:49.033  WARN 52512 --- [io-8090-exec-10] c.u.f.r.s.i.ExceptionHandlingInterceptor : Failure during REST processing: ca.uhn.fhir.rest.server.exceptions.InvalidRequestException: Invalid request: The FHIR endpoint on this server does not know how to handle GET operation[FamilyMemberHistory/b3126407-6d25-4fc1-a8b2-d0d6f629be92/Patient] with parameters [[]]

Upvotes: 0

Views: 965

Answers (2)

Blake Mumford
Blake Mumford

Reputation: 17721

As you have pointed out in your comment, the HAPI FHIR JPA Server implementation does not support Compartment Search. Please see this post in the HAPI FHIR Google Group in 2017.

If you wish to return all the FamilyMemberHistory resources for a particular patient, the FamilyMemberHistory Resource does offer a search parameter of patient:

[base]/FamilyMemberHistory?patient=[id]

Example:

http://hapi.fhir.org/baseR4/FamilyMemberHistory?patient=697321&_pretty=true

Upvotes: 0

Mirjam Baltus
Mirjam Baltus

Reputation: 2299

It looks like the Hapi library constructs the search URL the wrong way around. I would have expected your code to result in a GET [base]/Patient/[id]/FamilyMemberHistory, because a compartment search should list the compartment (i.e. Patient) first.

Perhaps you can work around this by switching the resource types in your code?

Upvotes: 0

Related Questions