View Javadoc
1   package ca.uhn.fhir.context.api;
2   
3   /*
4    * #%L
5    * HAPI FHIR - Core Library
6    * %%
7    * Copyright (C) 2014 - 2018 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import java.util.Set;
24  
25  import ca.uhn.fhir.model.api.Include;
26  import ca.uhn.fhir.util.ResourceReferenceInfo;
27  
28  /**
29   * Created by Bill de Beaubien on 3/4/2015.
30   *
31   * Controls how bundles decide whether referenced resources should be included
32   */
33  public enum BundleInclusionRule {
34  	
35  	/**
36  	 * Decision is based on whether the resource's Include is in the IncludeSet (e.g. DiagnosticReport.result). Note that the resource has to be populated to be included.
37  	 *
38  	 * This is the default behavior
39  	 */
40  	BASED_ON_INCLUDES {
41  		@Override
42  		public boolean shouldIncludeReferencedResource(ResourceReferenceInfo theReferenceInfo, Set<Include> theIncludes) {
43  			return theReferenceInfo.matchesIncludeSet(theIncludes);
44  		}
45  	},
46  
47  	/**
48  	 * Decision is based on whether the resource reference is set to a populated resource (in which case its included) or just an id (in which case it's not included)
49  	 *
50  	 * This is the original HAPI behavior
51  	 */
52  	BASED_ON_RESOURCE_PRESENCE {
53  		@Override
54  		public boolean shouldIncludeReferencedResource(ResourceReferenceInfo theReferenceInfo, Set<Include> theIncludes) {
55  			return true;
56  		}
57  	};
58  
59  	public abstract boolean shouldIncludeReferencedResource(ResourceReferenceInfo theReferenceInfo, Set<Include> theIncludes);
60  }