
001/*- 002 * #%L 003 * HAPI FHIR JPA Server 004 * %% 005 * Copyright (C) 2014 - 2025 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.config; 021 022import ca.uhn.fhir.context.FhirContext; 023import ca.uhn.fhir.jpa.api.dao.DaoRegistry; 024import ca.uhn.fhir.jpa.api.svc.IDeleteExpungeSvc; 025import ca.uhn.fhir.jpa.api.svc.IIdHelperService; 026import ca.uhn.fhir.jpa.api.svc.IMdmClearHelperSvc; 027import ca.uhn.fhir.jpa.bulk.mdm.MdmClearHelperSvcImpl; 028import ca.uhn.fhir.jpa.dao.mdm.JpaMdmLinkImplFactory; 029import ca.uhn.fhir.jpa.dao.mdm.MdmLinkDaoJpaImpl; 030import ca.uhn.fhir.jpa.entity.MdmLink; 031import ca.uhn.fhir.jpa.model.dao.JpaPid; 032import ca.uhn.fhir.mdm.api.IMdmLinkExpandSvc; 033import ca.uhn.fhir.mdm.dao.IMdmLinkDao; 034import ca.uhn.fhir.mdm.dao.IMdmLinkImplFactory; 035import ca.uhn.fhir.mdm.svc.BulkExportMdmEidMatchOnlyResourceExpander; 036import ca.uhn.fhir.mdm.svc.BulkExportMdmResourceExpander; 037import ca.uhn.fhir.mdm.svc.MdmEidMatchOnlyExpandSvc; 038import ca.uhn.fhir.mdm.svc.MdmExpandersHolder; 039import ca.uhn.fhir.mdm.svc.MdmExpansionCacheSvc; 040import ca.uhn.fhir.mdm.svc.MdmLinkExpandSvc; 041import ca.uhn.fhir.mdm.svc.MdmSearchExpansionSvc; 042import org.springframework.context.annotation.Bean; 043import org.springframework.context.annotation.Configuration; 044import org.springframework.context.annotation.Primary; 045 046@Configuration 047public class MdmJpaConfig { 048 049 @Bean 050 public MdmExpandersHolder mdmLinkExpandSvcHolder( 051 FhirContext theFhirContext, 052 IMdmLinkExpandSvc theMdmLinkExpandSvc, 053 MdmEidMatchOnlyExpandSvc theMdmEidMatchOnlyLinkExpandSvc, 054 BulkExportMdmEidMatchOnlyResourceExpander theBulkExportMdmEidMatchOnlyResourceExpander, 055 BulkExportMdmResourceExpander theBulkExportMdmResourceExpander) { 056 return new MdmExpandersHolder( 057 theFhirContext, 058 theMdmLinkExpandSvc, 059 theMdmEidMatchOnlyLinkExpandSvc, 060 theBulkExportMdmResourceExpander, 061 theBulkExportMdmEidMatchOnlyResourceExpander); 062 } 063 064 @Bean 065 public MdmEidMatchOnlyExpandSvc mdmEidMatchOnlyLinkExpandSvc(DaoRegistry theDaoRegistry) { 066 return new MdmEidMatchOnlyExpandSvc(theDaoRegistry); 067 } 068 069 @Bean 070 @Primary 071 public IMdmLinkExpandSvc mdmLinkExpandSvc() { 072 return new MdmLinkExpandSvc(); 073 } 074 075 @Bean 076 public MdmSearchExpansionSvc mdmSearchExpansionSvc() { 077 return new MdmSearchExpansionSvc(); 078 } 079 080 @Bean 081 public IMdmLinkDao<JpaPid, MdmLink> mdmLinkDao() { 082 return new MdmLinkDaoJpaImpl(); 083 } 084 085 @Bean 086 public BulkExportMdmResourceExpander bulkExportMDMResourceExpander( 087 MdmExpansionCacheSvc theMdmExpansionCacheSvc, 088 IMdmLinkDao theMdmLinkDao, 089 IIdHelperService<JpaPid> theIdHelperService, 090 DaoRegistry theDaoRegistry, 091 FhirContext theFhirContext) { 092 return new BulkExportMdmResourceExpander( 093 theMdmExpansionCacheSvc, theMdmLinkDao, theIdHelperService, theDaoRegistry, theFhirContext); 094 } 095 096 @Bean 097 public BulkExportMdmEidMatchOnlyResourceExpander bulkExportMDMEidMatchOnlyResourceExpander( 098 DaoRegistry theDaoRegistry, 099 MdmEidMatchOnlyExpandSvc theMdmEidMatchOnlyLinkExpandSvc, 100 FhirContext theFhirContext, 101 IIdHelperService<JpaPid> theIdHelperService) { 102 return new BulkExportMdmEidMatchOnlyResourceExpander( 103 theDaoRegistry, theMdmEidMatchOnlyLinkExpandSvc, theFhirContext, theIdHelperService); 104 } 105 106 @Bean 107 public IMdmLinkImplFactory<MdmLink> mdmLinkImplFactory() { 108 return new JpaMdmLinkImplFactory(); 109 } 110 111 @Bean 112 public IMdmClearHelperSvc<JpaPid> helperSvc(IDeleteExpungeSvc<JpaPid> theDeleteExpungeSvc) { 113 return new MdmClearHelperSvcImpl(theDeleteExpungeSvc); 114 } 115}