001/* 002 * #%L 003 * HAPI FHIR - Core Library 004 * %% 005 * Copyright (C) 2014 - 2023 Smile CDR, Inc. 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package ca.uhn.fhir.narrative; 021 022import ca.uhn.fhir.narrative2.NarrativeTemplateManifest; 023 024import java.util.ArrayList; 025import java.util.List; 026 027public class DefaultThymeleafNarrativeGenerator extends BaseThymeleafNarrativeGenerator implements INarrativeGenerator { 028 029 public static final String NARRATIVES_PROPERTIES = "classpath:ca/uhn/fhir/narrative/narratives.properties"; 030 static final String HAPISERVER_NARRATIVES_PROPERTIES = "classpath:ca/uhn/fhir/narrative/narratives-hapiserver.properties"; 031 032 private boolean myUseHapiServerConformanceNarrative; 033 private volatile NarrativeTemplateManifest myManifest; 034 035 public DefaultThymeleafNarrativeGenerator() { 036 super(); 037 } 038 039 @Override 040 protected NarrativeTemplateManifest getManifest() { 041 NarrativeTemplateManifest retVal = myManifest; 042 if (retVal == null) { 043 List<String> propertyFiles = new ArrayList<>(); 044 propertyFiles.add(NARRATIVES_PROPERTIES); 045 if (myUseHapiServerConformanceNarrative) { 046 propertyFiles.add(HAPISERVER_NARRATIVES_PROPERTIES); 047 } 048 retVal = NarrativeTemplateManifest.forManifestFileLocation(propertyFiles); 049 myManifest = retVal; 050 } 051 return retVal; 052 } 053 054 /** 055 * If set to <code>true</code> (default is <code>false</code>) a special custom narrative for the Conformance resource will be provided, which is designed to be used with HAPI FHIR Server 056 * instances. This narrative provides a friendly search page which can assist users of the service. 057 */ 058 public void setUseHapiServerConformanceNarrative(boolean theValue) { 059 myUseHapiServerConformanceNarrative = theValue; 060 } 061 062 /** 063 * If set to <code>true</code> (default is <code>false</code>) a special custom narrative for the Conformance resource will be provided, which is designed to be used with HAPI FHIR Server 064 * instances. This narrative provides a friendly search page which can assist users of the service. 065 */ 066 public boolean isUseHapiServerConformanceNarrative() { 067 return myUseHapiServerConformanceNarrative; 068 } 069 070}