Conditionally add the default NarrativeGenerator to the context

#182
This commit is contained in:
Vladimir Nemergut
2020-12-02 11:37:59 +01:00
parent ccfaee6f0a
commit bb99a69085
3 changed files with 19 additions and 1 deletions

View File

@@ -21,6 +21,8 @@ import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.jpa.searchparam.registry.ISearchParamRegistry;
import ca.uhn.fhir.jpa.subscription.util.SubscriptionDebugLogInterceptor;
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
import ca.uhn.fhir.narrative.INarrativeGenerator;
import ca.uhn.fhir.narrative2.NullNarrativeGenerator;
import ca.uhn.fhir.rest.server.ETagSupportEnum;
import ca.uhn.fhir.rest.server.HardcodedServerAddressStrategy;
import ca.uhn.fhir.rest.server.RestfulServer;
@@ -177,7 +179,11 @@ public class BaseJpaRestfulServer extends RestfulServer {
* This server tries to dynamically generate narratives
*/
FhirContext ctx = getFhirContext();
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
INarrativeGenerator theNarrativeGenerator =
appProperties.getNarrative_enabled() ?
new DefaultThymeleafNarrativeGenerator() :
new NullNarrativeGenerator();
ctx.setNarrativeGenerator(theNarrativeGenerator);
/*
* Default to JSON and pretty printing