All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dev.dsf.fhir.search.SearchQueryIncludeParameterConfiguration Maven / Gradle / Ivy

package dev.dsf.fhir.search;

import java.sql.Connection;
import java.sql.SQLException;

import org.hl7.fhir.r4.model.Binary;
import org.hl7.fhir.r4.model.Resource;

import dev.dsf.fhir.function.BiConsumerWithSqlException;

public class SearchQueryIncludeParameterConfiguration
{
	private final String sql;
	private final IncludeParts includeParts;

	private final BiConsumerWithSqlException includeResourceModifier;

	public SearchQueryIncludeParameterConfiguration(String sql, IncludeParts includeParts)
	{
		this(sql, includeParts, null);
	}

	/**
	 * @param sql
	 *            not null
	 * @param includeParts
	 *            not null
	 * @param includeResourceModifier
	 *            Use this {@link BiConsumerWithSqlException} to modify the include resources. This consumer can be used
	 *            if the resources returned by the include SQL are not complete and additional content needs to be
	 *            retrieved from a not included column. For example the content of a {@link Binary} resource might not
	 *            be stored in the json column.
	 */
	public SearchQueryIncludeParameterConfiguration(String sql, IncludeParts includeParts,
			BiConsumerWithSqlException includeResourceModifier)
	{
		this.sql = sql;
		this.includeParts = includeParts;
		this.includeResourceModifier = includeResourceModifier;
	}

	public String getBundleUriQueryParameterValues()
	{
		return includeParts.toBundleUriQueryParameterValue();
	}

	public String getSql()
	{
		return sql;
	}

	public void modifyIncludeResource(Resource resource, Connection connection) throws SQLException
	{
		if (includeResourceModifier != null)
			includeResourceModifier.accept(resource, connection);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy