Advanced FHIR endpoint parameters

Some more FHIR endpoint parameters are not required in all scenarios.

All parameters are usually set on the FhirTransactionConfiguration (i.e. per FHIR component type), but you may wish to overwrite these settings in your endpoint URI.


Parameter name Type Default value Short description
fhirContext FhirContext STU3 or R4 Reference to a global HAPI FHIR Context. Otherwise a default FHIR contxt is used.
resourceProvider FhirProvider n/a Reference to a custom resource provider, configurable per endpoint.
clientRequestFactory ClientRequestFactory n/a reference to a custom ClientRequestFactory
consumerSelector Predicate () -> true reference to a Predicate that selects a FhirConsumer
consumerSelector Boolean false whether the endpoint shall try to sort a search result if requested by the client


The most commonly used of these is fhirContext (e.g. ?fhirContext=#fhirContext), which allows to reference a global FHIR Context instance like the one provided by the IPF Spring Boot FHIR starter. This is useful if you expose several FHIR endpoints that shall all use same configured context.


This is to determine what the HAPI Resource Provider shall be used. Usually, every component statically defines its own resource provider, but for custom searches etc. you may override the default resource provider with this option.


This is to determine what kind of ClientRequestFactory the Producer endpoint shall instantiate for constructing FHIR requests.


The consumerSelector parameter can be used to determine whether the given endpoint is selected for a FHIR payload or not. This is primarily useful for FHIR batch or transaction requests. These requests are directed at the root URL of the FHIR servlet, but if you need to support more than one type of batch requests via different endpoints you can choose what type shall be handled by this endpoint.


MHD ITI-65 is a transaction request containing DocumentManifest, DocumentReference and Binary resources. The request is defined with a Bundle.meta.profile value set to, so the transaction definition of ITI-65 statically configures so that ITI-65 consumer endpoints receive these requests:

	public Iti65TransactionConfiguration() {
                "Provide Document Bundle",
                new Iti65ClientAuditStrategy(),
                new Iti65ServerAuditStrategy(),
                BatchTransactionResourceProvider.getInstance(),      // Consumer side. accept registrations
                BatchTransactionClientRequestFactory.getInstance(),  // Formulate requests
                new Iti65Validator());
        setStaticConsumerSelector(new BundleProfileSelector(Iti65Constants.ITI65_PROFILE));

If you need to alter this behavior (using a different or no profile for your ITI-65 endpoint), you can do so by using consumerSelector=#mySelector, where mySelector is the name of a bean of type Predicate<Object>.

For demonstration purposes, here is the implementation of BundleProfileSelector:

public class BundleProfileSelector implements Predicate<Object> {

    private final Set<String> profileUris;

     * @param profileUris Profile URIs expected in the Bundle's meta element
    public BundleProfileSelector(String... profileUris) {
        this.profileUris = new HashSet<>(Arrays.asList(profileUris));

     * @param object bundle
     * @return true if one of the {@link #profileUris} are present in the Bundle's meta.profile
    public boolean test(Object object) {
        Bundle bundle = (Bundle) object;
        return bundle.getMeta().getProfile().stream()


This parameter can be set to true if the FHIR consumer endpoint shall attempt server-side orting if the client requests to do so. Sorting must be explicitly supported by the FHIR endpoint’s FhirSearchParameters implementation - it must extend FhirSearchAndSortParameters and implement the comparatorFor(String) method that returns a Comparator object for the provided sort parameter.

For demonstration purposes, here is the implementation of Iti78SearchParameters that supports selected sorting parameters:

public class Iti78SearchParameters extends FhirSearchAndSortParameters<PdqPatient> {


    public Optional<Comparator<PdqPatient>> comparatorFor(String paramName) {
        switch (paramName) {
            case PdqPatient.SP_BIRTHDATE: return Optional.of(CP_DATE);
            case PdqPatient.SP_FAMILY: return Optional.of(CP_FAMILY);
            case PdqPatient.SP_GIVEN: return Optional.of(CP_GIVEN);
        return Optional.empty();

    private static final Comparator<PdqPatient> CP_DATE = nullsLast(comparing(PdqPatient::getBirthDate));
    private static final Comparator<PdqPatient> CP_FAMILY = nullsLast(comparing(patient -> patient.getNameFirstRep().getFamily()));
    private static final Comparator<PdqPatient> CP_GIVEN = nullsLast(comparing(patient -> patient.getNameFirstRep().getGivenAsSingleString()));

Any “unknown” sorting parameters are ignored. The returned Comparators must be capable of handling null values - in this case they are ordered after all non-null values.