001/* 002 * #%L 003 * HAPI FHIR - Core Library 004 * %% 005 * Copyright (C) 2014 - 2024 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 = 031 "classpath:ca/uhn/fhir/narrative/narratives-hapiserver.properties"; 032 033 private boolean myUseHapiServerConformanceNarrative; 034 private volatile NarrativeTemplateManifest myManifest; 035 036 public DefaultThymeleafNarrativeGenerator() { 037 super(); 038 } 039 040 @Override 041 protected NarrativeTemplateManifest getManifest() { 042 NarrativeTemplateManifest retVal = myManifest; 043 if (retVal == null) { 044 List<String> propertyFiles = new ArrayList<>(); 045 propertyFiles.add(NARRATIVES_PROPERTIES); 046 if (myUseHapiServerConformanceNarrative) { 047 propertyFiles.add(HAPISERVER_NARRATIVES_PROPERTIES); 048 } 049 retVal = NarrativeTemplateManifest.forManifestFileLocation(propertyFiles); 050 myManifest = retVal; 051 } 052 return retVal; 053 } 054 055 /** 056 * 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 057 * instances. This narrative provides a friendly search page which can assist users of the service. 058 */ 059 public void setUseHapiServerConformanceNarrative(boolean theValue) { 060 myUseHapiServerConformanceNarrative = theValue; 061 } 062 063 /** 064 * 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 065 * instances. This narrative provides a friendly search page which can assist users of the service. 066 */ 067 public boolean isUseHapiServerConformanceNarrative() { 068 return myUseHapiServerConformanceNarrative; 069 } 070}