0

我正在尝试使用 hapi fhir 从 clojure 创建一个 dstu2 客户端。作为模板,我使用https://github.com/jamesagnew/hapi-fhir/blob/master/examples/src/main/java/example/GenericClientExample.java

但我无法执行

ctx.setPerformanceOptions(PerformanceOptionsEnum.DEFERRED_MODEL_SCANNING);
in clojure

我要做的是:

(def fhir-context (. FhirContext forDstu2))
=> #'emrspp.fhir-resources/fhir-context 
(def opts PerformanceOptionsEnum/DEFERRED_MODEL_SCANNING)
=>  #'emrspp.fhir-resources/opts 

但随后以下失败:

(.setPerformanceOptions fhir-context opts)
=>
CompilerException java.lang.IllegalArgumentException: No matching method found: setPerformanceOptions for class ca.uhn.fhir.context.FhirContext

clojure 反射给出以下内容:

(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

进口部分是:

 (: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            )

没有 :requires 除了 pprint 和反射

关于似乎存在但被执行的方法 setPerformanceOptions 发生了什么?

4

1 回答 1

1

几个小时后我想通了。我仔细查看了命名空间:http ://hapifhir.io/apidocs/ca/uhn/fhir/context/FhirContext.html 表明传递的参数需要是一个 java 集合,因此

(.setPerformanceOptions fhir-context opts)

必须改为

(.setPerformanceOptions fhir-context (java.util.ArrayList. [opts]))

或更简单

(.setPerformanceOptions fhir-context [opts] )
于 2017-03-12T21:46:54.630 回答