001/*- 002 * #%L 003 * HAPI FHIR JPA Server - International Patient Summary (IPS) 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.jpa.ips.jpa; 021 022import ca.uhn.fhir.jpa.ips.api.IpsSectionContext; 023import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; 024import jakarta.annotation.Nonnull; 025import org.hl7.fhir.instance.model.api.IBaseResource; 026 027/** 028 * Implementations of this interface are used to fetch resources to include 029 * for a given IPS section by performing a search in a local JPA repository. 030 * 031 * @since 7.2.0 032 */ 033public interface IJpaSectionSearchStrategy<T extends IBaseResource> { 034 035 /** 036 * This method can manipulate the {@link SearchParameterMap} that will 037 * be used to find candidate resources for the given IPS section. The map will already have 038 * a subject/patient parameter added to it. The map provided in {@literal theSearchParameterMap} 039 * will contain a subject/patient reference (e.g. <code>?patient=Patient/123</code>), but no 040 * other parameters. This method can add other parameters. The default implementation of this 041 * interface performs no action. 042 * <p> 043 * For example, for a Vital Signs section, the implementation might add a parameter indicating 044 * the parameter <code>category=vital-signs</code>. 045 * </p> 046 * 047 * @param theIpsSectionContext The context, which indicates the IPS section and the resource type 048 * being searched for. 049 * @param theSearchParameterMap The map to manipulate. 050 */ 051 default void massageResourceSearch( 052 @Nonnull IpsSectionContext<T> theIpsSectionContext, @Nonnull SearchParameterMap theSearchParameterMap) { 053 // no action taken by default 054 } 055 056 /** 057 * This method will be called for each found resource candidate for inclusion in the 058 * IPS document. The strategy can decide whether to include it or not. Note that the 059 * default implementation will always return {@literal true}. 060 * <p> 061 * This method is called once for every resource that is being considered for inclusion 062 * in an IPS section. 063 * </p> 064 */ 065 default boolean shouldInclude(@Nonnull IpsSectionContext<T> theIpsSectionContext, @Nonnull T theCandidate) { 066 return true; 067 } 068}