16.13.1System-to-System Data Exchange Examples

 

This page contains example interceptors that can be registered with System-to-System Data Exchange.

16.13.2Example: Custom Member Match

 

The following interceptor can be used to implement custom patient matching algorithm for the $member-match operation.

/*-
 * #%L
 * Smile CDR - CDR
 * %%
 * Copyright (C) 2016 - 2025 Smile CDR, Inc.
 * %%
 * All rights reserved.
 * #L%
 */
package com.smilecdr.demo.s2sdataexchange;

import ca.cdr.api.fhir.interceptor.CdrHook;
import ca.cdr.api.fhir.interceptor.CdrPointcut;
import ca.cdr.api.fhir.interceptor.MemberMatchRequest;
import ca.uhn.fhir.interceptor.api.Interceptor;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.util.StopWatch;
import org.hl7.fhir.r4.model.Patient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@SuppressWarnings({"unused", "EmptyTryBlock"})
@Interceptor
public class S2SDataExchangeInterceptorTemplate {
	private static final Logger ourLog = LoggerFactory.getLogger(S2SDataExchangeInterceptorTemplate.class);

	@CdrHook(CdrPointcut.MEMBER_MATCH)
	public Patient channelImportMessagePreProcessed(
			MemberMatchRequest theMemberMatchRequest, RequestDetails theRequestDetails) {
		ourLog.info("Interceptor MEMBER_MATCH - started");
		StopWatch stopWatch = new StopWatch();
		try {
			// your implementation goes here
		} finally {
			ourLog.info("Interceptor MEMBER_MATCH - ended, execution took {}", stopWatch);
		}
		// should return a Patient if matching patient is found or null otherwise
		return null;
	}
}