001/*-
002 * #%L
003 * HAPI FHIR JPA Server - Master Data Management
004 * %%
005 * Copyright (C) 2014 - 2023 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.jpa.mdm.config;
021
022import ca.uhn.fhir.context.FhirContext;
023import ca.uhn.fhir.jpa.nickname.INicknameSvc;
024import ca.uhn.fhir.mdm.api.IMdmSettings;
025import ca.uhn.fhir.mdm.interceptor.MdmSearchExpandingInterceptor;
026import ca.uhn.fhir.mdm.rules.config.MdmRuleValidator;
027import ca.uhn.fhir.mdm.rules.matcher.IMatcherFactory;
028import ca.uhn.fhir.mdm.rules.matcher.MdmMatcherFactory;
029import ca.uhn.fhir.mdm.rules.svc.MdmResourceMatcherSvc;
030import ca.uhn.fhir.mdm.svc.MdmLinkDeleteSvc;
031import ca.uhn.fhir.rest.server.util.ISearchParamRegistry;
032import org.springframework.context.annotation.Bean;
033import org.springframework.context.annotation.Configuration;
034import org.springframework.context.annotation.Lazy;
035
036@Configuration
037public class MdmCommonConfig {
038        @Bean
039        MdmRuleValidator mdmRuleValidator(FhirContext theFhirContext, ISearchParamRegistry theSearchParamRetriever) {
040                return new MdmRuleValidator(theFhirContext, theSearchParamRetriever);
041        }
042
043        @Bean
044        @Lazy
045        public MdmSearchExpandingInterceptor mdmSearchExpandingInterceptor() {
046                return new MdmSearchExpandingInterceptor();
047        }
048
049        @Bean
050        MdmLinkDeleteSvc mdmLinkDeleteSvc() {
051                return new MdmLinkDeleteSvc();
052        }
053
054        @Bean
055        @Lazy
056        MdmResourceMatcherSvc mdmResourceComparatorSvc(
057                        FhirContext theFhirContext, IMatcherFactory theIMatcherFactory, IMdmSettings theMdmSettings) {
058                return new MdmResourceMatcherSvc(theFhirContext, theIMatcherFactory, theMdmSettings);
059        }
060
061        @Bean
062        @Lazy
063        public IMatcherFactory matcherFactory(
064                        FhirContext theFhirContext, IMdmSettings theSettings, INicknameSvc theNicknameSvc) {
065                return new MdmMatcherFactory(theFhirContext, theSettings, theNicknameSvc);
066        }
067}