FHIR Chat · HAPI FHIR - Restful Server · implementers

Stream: implementers

Topic: HAPI FHIR - Restful Server


view this post on Zulip Joel Francis (Nov 05 2017 at 23:58):

Hi,

I am following the tutorial to create a restful server - http://hapifhir.io/doc_rest_server.html
Upon deployment, and access the Patient via /fhir/Patient/12345, I receive the following error:

Can anyone help shed some light on a possible resolution?

ca.uhn.fhir.context.ConfigurationException: Method uses the wrong Id datatype (IdDt / IdType) for the given context FHIR version: public org.hl7.fhir.instance.model.Patient resource.providers.RestfulPatientResourceProvider.getResourceById(ca.uhn.fhir.model.primitive.IdDt)
ca.uhn.fhir.rest.param.ParameterUtil.findIdParameterIndex(ParameterUtil.java:175)
ca.uhn.fhir.rest.server.method.ReadMethodBinding.<init>(ReadMethodBinding.java:60)
ca.uhn.fhir.rest.server.method.BaseMethodBinding.bindMethod(BaseMethodBinding.java:475)
ca.uhn.fhir.rest.server.RestfulServer.findResourceMethods(RestfulServer.java:291)
ca.uhn.fhir.rest.server.RestfulServer.findResourceMethods(RestfulServer.java:280)
ca.uhn.fhir.rest.server.RestfulServer.registerProviders(RestfulServer.java:1325)
ca.uhn.fhir.rest.server.RestfulServer.init(RestfulServer.java:955)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:748)

Thanks,

Joel

view this post on Zulip Christopher Schuler (Nov 06 2017 at 01:32):

I think the issue is with using org.hl7.fhir.instance.model.Patient. The snippets in that tutorial should really show the imports... That example uses ca.uhn.fhir.model.dstu2.resource.Patient. Here is the link to the source https://github.com/jamesagnew/hapi-fhir/blob/364c18e06e03437f0ac478105891c8be440721b7/examples/src/main/java/example/RestfulPatientResourceProvider.java.
Hope that helps.

view this post on Zulip Joel Francis (Nov 06 2017 at 02:33):

I think the issue is with using org.hl7.fhir.instance.model.Patient. The snippets in that tutorial should really show the imports... That example uses ca.uhn.fhir.model.dstu2.resource.Patient. Here is the link to the source https://github.com/jamesagnew/hapi-fhir/blob/364c18e06e03437f0ac478105891c8be440721b7/examples/src/main/java/example/RestfulPatientResourceProvider.java.
Hope that helps.

Thanks @Christopher Schuler but what if I wanted to have restful server based on FHIR 3.0.1. I also had the DSTU 2.0 Patient imports and it gave me the same issue. I also set the context in the server setFhirContext(FhirContext.forDstu3()); Any other ideas?

view this post on Zulip Joel Francis (Nov 06 2017 at 13:22):

@Christopher Schuler , you were right. I had the wrong stu2 import for patient. It works now. the read() works but the search() isn't getting invoked.


Last updated: Apr 12 2022 at 19:14 UTC