Reputation: 125
I am trying to create a dstu2 client from clojure using hapi fhir. As a template i use https://github.com/jamesagnew/hapi-fhir/blob/master/examples/src/main/java/example/GenericClientExample.java
But I am not able to execute
ctx.setPerformanceOptions(PerformanceOptionsEnum.DEFERRED_MODEL_SCANNING);
in clojure
What i do is the following:
(def fhir-context (. FhirContext forDstu2))
=> #'emrspp.fhir-resources/fhir-context
(def opts PerformanceOptionsEnum/DEFERRED_MODEL_SCANNING)
=> #'emrspp.fhir-resources/opts
But then the followint fails:
(.setPerformanceOptions fhir-context opts)
=>
CompilerException java.lang.IllegalArgumentException: No matching method found: setPerformanceOptions for class ca.uhn.fhir.context.FhirContext
clojure reflection gives the following :
(pprint (filter #(= "setPerformanceOptions" (str (:name %))) (:members (r/reflect fhir-context))))
=>
~
({:name setPerformanceOptions,
:return-type void,
:declaring-class ca.uhn.fhir.context.FhirContext,
:parameter-types [ca.uhn.fhir.context.PerformanceOptionsEnum<>],
:exception-types [],
:flags #{:varargs :public}}
{:name setPerformanceOptions,
:return-type void,
:declaring-class ca.uhn.fhir.context.FhirContext,
:parameter-types [java.util.Collection],
:exception-types [],
:flags #{:public}})
nil
The imports section is:
(:import [org.hl7.fhir.instance.model.api IBaseOperationOutcome IBaseResource ]
7 [ca.uhn.fhir.context FhirContext PerformanceOptionsEnum]
8 [ca.uhn.fhir.model.base.resource BaseOperationOutcome ]
9 [ca.uhn.fhir.model.dstu2.resource Bundle
10 Conformance Observation
11 OperationOutcome
12 Organization Parameters
13 Patient Provenance]
14 [ca.uhn.fhir.model.dstu2.valueset AdministrativeGenderEnum IssueSeverityEnum]
15 [ca.uhn.fhir.model.primitive DateDt IdDt InstantDt]
16 [ca.uhn.fhir.rest.api MethodOutcome SummaryEnum ]
17 [ca.uhn.fhir.rest.client IGenericClient ServerValidationModeEnum interceptor.LoggingInterceptor ]
18 [ca.uhn.fhir.rest.method.SearchStyleEnum ]
19 [ca.uhn.fhir.rest.param.DateRangeParam ]
20 [ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException ]
21 )
with no :requires except pprint and reflection
Any hits of what happens regarding the method setPerformanceOptions that appears to be there but be executed ????
Upvotes: 0
Views: 76
Reputation: 125
I figured it out after hours. I closer look at the namespace : http://hapifhir.io/apidocs/ca/uhn/fhir/context/FhirContext.html reveals that the passing argument needs to be a java collection and thus
(.setPerformanceOptions fhir-context opts)
must be changed to
(.setPerformanceOptions fhir-context (java.util.ArrayList. [opts]))
or simplier
(.setPerformanceOptions fhir-context [opts] )
Upvotes: 1