0

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 [[]]
Joe Taras
  • 15,166
  • 7
  • 42
  • 55
Sarvesh
  • 551
  • 1
  • 10
  • 25

2 Answers2

0

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?

Mirjam Baltus
  • 2,035
  • 9
  • 13
  • Yes you are right. It constructed wrong URL. However, I tried `GET [base]/Patient/[id]/FamilyMemberHistory` on my Hapi FHIR JPA Server by Postman. It is not working and throwing a similar error. I think Hapi FHIR JPA Server does not support Compartment Search. – Sarvesh May 14 '20 at 10:47
0

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

Blake Mumford
  • 17,201
  • 12
  • 49
  • 67
  • Yes, Compartment Search and Search Parameter approach produces the same output. However, I wanted to try the compartment search technique to get fhir resources. Now, it seems I have to stick with Search Parameter approach. – Sarvesh May 17 '20 at 17:18