001package ca.uhn.fhir.mdm.api;
002
003/*-
004 * #%L
005 * HAPI FHIR - Master Data Management
006 * %%
007 * Copyright (C) 2014 - 2022 Smile CDR, Inc.
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import ca.uhn.fhir.mdm.model.MdmTransactionContext;
024import org.hl7.fhir.instance.model.api.IBase;
025
026/**
027 * Service that applies survivorship rules on target and golden resources.
028 */
029public interface IMdmSurvivorshipService {
030
031        /**
032         * Applies survivorship rules to merge fields from the specified target resource to the golden resource. Survivorship
033         * rules may include, but not limited to the following data consolidation methods:
034         *
035         * <ul>
036         *  <li>
037         *  Length of field - apply the field value containing most or least number of characters - e.g. longest name
038         *  </li>
039         *  <li>
040         *  Date time - all the field value from the oldest or the newest recrod - e.g. use the most recent phone number
041         *  </li>
042         *  <li>
043         *  Frequency - use the most or least frequent number of occurrence - e.g. most common phone number
044         *  </li>
045         *  <li>
046         *  Integer - number functions (largest, sum, avg) - e.g. number of patient encounters
047         *  </li>
048         *  <li>
049         *  Quality of data - best quality data - e.g. data coming from a certain system is considered trusted and overrides
050         *  all other values
051         *  </li>
052         *  <li>
053         *  A hybrid approach combining all methods listed above as best fits
054         *  </li>
055         * </ul>
056         *
057         * @param theTargetResource        Target resource to merge fields from
058         * @param theGoldenResource        Golden resource to merge fields into
059         * @param theMdmTransactionContext Current transaction context
060         * @param <T>                      Resource type to apply the survivorship rules to
061         */
062        <T extends IBase> void applySurvivorshipRulesToGoldenResource(T theTargetResource, T theGoldenResource, MdmTransactionContext theMdmTransactionContext);
063}