
001/* 002 * #%L 003 * HAPI FHIR JPA Server 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.config.r4; 021 022import ca.uhn.fhir.context.FhirContext; 023import ca.uhn.fhir.context.support.IValidationSupport; 024import ca.uhn.fhir.jpa.api.IDaoRegistry; 025import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; 026import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; 027import ca.uhn.fhir.jpa.config.GeneratedDaoAndResourceProviderConfigR4; 028import ca.uhn.fhir.jpa.config.JpaConfig; 029import ca.uhn.fhir.jpa.dao.ITransactionProcessorVersionAdapter; 030import ca.uhn.fhir.jpa.dao.r4.TransactionProcessorVersionAdapterR4; 031import ca.uhn.fhir.jpa.graphql.GraphQLProvider; 032import ca.uhn.fhir.jpa.graphql.GraphQLProviderWithIntrospection; 033import ca.uhn.fhir.jpa.provider.JpaSystemProvider; 034import ca.uhn.fhir.jpa.provider.r4.IMemberMatchConsentHook; 035import ca.uhn.fhir.jpa.provider.r4.MemberMatchR4ResourceProvider; 036import ca.uhn.fhir.jpa.provider.r4.MemberMatcherR4Helper; 037import ca.uhn.fhir.jpa.term.TermLoaderSvcImpl; 038import ca.uhn.fhir.jpa.term.TermVersionAdapterSvcR4; 039import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc; 040import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc; 041import ca.uhn.fhir.jpa.term.api.ITermLoaderSvc; 042import ca.uhn.fhir.jpa.term.api.ITermVersionAdapterSvc; 043import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; 044import org.hl7.fhir.r4.model.Bundle; 045import org.hl7.fhir.r4.model.Consent; 046import org.hl7.fhir.r4.model.Coverage; 047import org.hl7.fhir.r4.model.Meta; 048import org.hl7.fhir.r4.model.Patient; 049import org.hl7.fhir.utilities.graphql.IGraphQLStorageServices; 050import org.springframework.beans.factory.annotation.Autowired; 051import org.springframework.context.annotation.Bean; 052import org.springframework.context.annotation.Configuration; 053import org.springframework.context.annotation.Import; 054import org.springframework.context.annotation.Lazy; 055import org.springframework.transaction.annotation.EnableTransactionManagement; 056 057@Configuration 058@EnableTransactionManagement 059@Import({ 060 FhirContextR4Config.class, 061 GeneratedDaoAndResourceProviderConfigR4.class, 062 JpaConfig.class 063}) 064public class JpaR4Config { 065 066 @Bean 067 public ITermVersionAdapterSvc terminologyVersionAdapterSvc() { 068 return new TermVersionAdapterSvcR4(); 069 } 070 071 @Bean 072 public ITransactionProcessorVersionAdapter transactionProcessorVersionFacade() { 073 return new TransactionProcessorVersionAdapterR4(); 074 } 075 076 @Bean(name = JpaConfig.GRAPHQL_PROVIDER_NAME) 077 @Lazy 078 public GraphQLProvider graphQLProvider(FhirContext theFhirContext, IGraphQLStorageServices theGraphqlStorageServices, IValidationSupport theValidationSupport, ISearchParamRegistry theSearchParamRegistry, IDaoRegistry theDaoRegistry) { 079 return new GraphQLProviderWithIntrospection(theFhirContext, theValidationSupport, theGraphqlStorageServices, theSearchParamRegistry, theDaoRegistry); 080 } 081 082 @Bean(name = "mySystemDaoR4") 083 public IFhirSystemDao<Bundle, Meta> systemDaoR4() { 084 ca.uhn.fhir.jpa.dao.r4.FhirSystemDaoR4 retVal = new ca.uhn.fhir.jpa.dao.r4.FhirSystemDaoR4(); 085 return retVal; 086 } 087 088 @Bean(name = "mySystemProviderR4") 089 public JpaSystemProvider<Bundle, Meta> systemProviderR4(FhirContext theFhirContext) { 090 JpaSystemProvider<Bundle, Meta> retVal = new JpaSystemProvider<>(); 091 retVal.setContext(theFhirContext); 092 retVal.setDao(systemDaoR4()); 093 return retVal; 094 } 095 096 @Bean 097 public ITermLoaderSvc termLoaderService(ITermDeferredStorageSvc theDeferredStorageSvc, ITermCodeSystemStorageSvc theCodeSystemStorageSvc) { 098 return new TermLoaderSvcImpl(theDeferredStorageSvc, theCodeSystemStorageSvc); 099 } 100 101 @Bean 102 public MemberMatcherR4Helper memberMatcherR4Helper( 103 @Autowired FhirContext theContext, 104 @Autowired IFhirResourceDao<Coverage> theCoverageDao, 105 @Autowired IFhirResourceDao<Patient> thePatientDao, 106 @Autowired IFhirResourceDao<Consent> theConsentDao, 107 @Autowired(required = false) IMemberMatchConsentHook theExtensionProvider 108 ) { 109 return new MemberMatcherR4Helper( 110 theContext, 111 theCoverageDao, 112 thePatientDao, 113 theConsentDao, 114 theExtensionProvider 115 ); 116 } 117 118 @Bean 119 public MemberMatchR4ResourceProvider memberMatchR4ResourceProvider(FhirContext theFhirContext, MemberMatcherR4Helper theMemberMatchR4Helper) { 120 return new MemberMatchR4ResourceProvider(theFhirContext, theMemberMatchR4Helper); 121 } 122}