001/*-
002 * #%L
003 * HAPI FHIR - Master Data Management
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.mdm.api;
021
022import ca.uhn.fhir.mdm.model.MdmTransactionContext;
023import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId;
024import org.hl7.fhir.instance.model.api.IAnyResource;
025
026import java.util.List;
027
028public interface IMdmLinkSvc {
029
030        /**
031         * Update a link between a Golden Resource record and its source resource record. If a link does not exist between
032         * these two records, create it.
033         *
034         * @param theGoldenResource        the Golden Resource to link the source resource to.
035         * @param theSourceResource        the source resource, which can be of any of the MDM supported types
036         * @param theMatchResult           the current status of the match to set the link to.
037         * @param theLinkSource            MANUAL or AUTO: what caused the link.
038         * @param theMdmTransactionContext
039         */
040        void updateLink(
041                        IAnyResource theGoldenResource,
042                        IAnyResource theSourceResource,
043                        MdmMatchOutcome theMatchResult,
044                        MdmLinkSourceEnum theLinkSource,
045                        MdmTransactionContext theMdmTransactionContext);
046
047        /**
048         * Delete a link between given Golden Resource and the corresponding source resource
049         *
050         * @param theExistingGoldenResource
051         * @param theSourceResource
052         * @param theMdmTransactionContext
053         */
054        void deleteLink(
055                        IAnyResource theExistingGoldenResource,
056                        IAnyResource theSourceResource,
057                        MdmTransactionContext theMdmTransactionContext);
058
059        /**
060         * Delete all link records whose source or target points to the provided pids.
061         * @param thePersistentIds
062         */
063        void deleteLinksWithAnyReferenceTo(List<IResourcePersistentId> thePersistentIds);
064}