Skip to content

Commit

Permalink
Use a cached context for increased performance. The default construct…
Browse files Browse the repository at this point in the history
…or R4FhirModelResolver() constructor recreates the FhirContext. (#1753)
  • Loading branch information
vitorpamplona committed Mar 6, 2023
1 parent d73f6cb commit 9ee9c81
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ import org.opencds.cqf.cql.evaluator.measure.r4.R4MeasureProcessor
import org.opencds.cqf.cql.evaluator.plandefinition.OperationParametersParser
import org.opencds.cqf.cql.evaluator.plandefinition.r4.PlanDefinitionProcessor

// Uses the already cached FhirContext instead of creating a new one
// on the default protected R4FhirModelResolver() constructor.
// This is a heavy object to load. Avoid having to create a new one.
object cachedR4FhirModelResolver : R4FhirModelResolver(FhirContext.forR4Cached())

class FhirOperator(fhirContext: FhirContext, fhirEngine: FhirEngine) {
// Initialize the measure processor
private val fhirEngineTerminologyProvider = FhirEngineTerminologyProvider(fhirContext, fhirEngine)
Expand All @@ -69,7 +74,7 @@ class FhirOperator(fhirContext: FhirContext, fhirEngine: FhirEngine) {
}
private val dataProvider =
CompositeDataProvider(
CachingModelResolverDecorator(R4FhirModelResolver()),
CachingModelResolverDecorator(cachedR4FhirModelResolver),
fhirEngineRetrieveProvider
)
private val fhirEngineDal = FhirEngineDal(fhirEngine)
Expand Down

0 comments on commit 9ee9c81

Please sign in to comment.