001package ca.uhn.fhir.jpa.config.dstu3;
002
003import ca.uhn.fhir.context.FhirContext;
004import ca.uhn.fhir.context.support.IValidationSupport;
005import ca.uhn.fhir.jpa.api.IDaoRegistry;
006import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao;
007import ca.uhn.fhir.jpa.config.GeneratedDaoAndResourceProviderConfigDstu3;
008import ca.uhn.fhir.jpa.config.JpaConfig;
009import ca.uhn.fhir.jpa.config.SharedConfigDstu3Plus;
010import ca.uhn.fhir.jpa.dao.ITransactionProcessorVersionAdapter;
011import ca.uhn.fhir.jpa.dao.dstu3.TransactionProcessorVersionAdapterDstu3;
012import ca.uhn.fhir.jpa.graphql.GraphQLProvider;
013import ca.uhn.fhir.jpa.graphql.GraphQLProviderWithIntrospection;
014import ca.uhn.fhir.jpa.term.TermLoaderSvcImpl;
015import ca.uhn.fhir.jpa.term.TermReadSvcDstu3;
016import ca.uhn.fhir.jpa.term.TermVersionAdapterSvcDstu3;
017import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc;
018import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc;
019import ca.uhn.fhir.jpa.term.api.ITermLoaderSvc;
020import ca.uhn.fhir.jpa.term.api.ITermReadSvcDstu3;
021import ca.uhn.fhir.jpa.term.api.ITermVersionAdapterSvc;
022import ca.uhn.fhir.rest.server.util.ISearchParamRegistry;
023import org.hl7.fhir.dstu3.model.Bundle;
024import org.hl7.fhir.dstu3.model.Meta;
025import org.hl7.fhir.utilities.graphql.IGraphQLStorageServices;
026import org.springframework.context.annotation.Bean;
027import org.springframework.context.annotation.Configuration;
028import org.springframework.context.annotation.Import;
029import org.springframework.context.annotation.Lazy;
030import org.springframework.transaction.annotation.EnableTransactionManagement;
031
032/*
033 * #%L
034 * HAPI FHIR JPA Server
035 * %%
036 * Copyright (C) 2014 - 2022 Smile CDR, Inc.
037 * %%
038 * Licensed under the Apache License, Version 2.0 (the "License");
039 * you may not use this file except in compliance with the License.
040 * You may obtain a copy of the License at
041 *
042 * http://www.apache.org/licenses/LICENSE-2.0
043 *
044 * Unless required by applicable law or agreed to in writing, software
045 * distributed under the License is distributed on an "AS IS" BASIS,
046 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
047 * See the License for the specific language governing permissions and
048 * limitations under the License.
049 * #L%
050 */
051
052@Configuration
053@EnableTransactionManagement
054@Import({
055        FhirContextDstu3Config.class,
056        GeneratedDaoAndResourceProviderConfigDstu3.class,
057        SharedConfigDstu3Plus.class,
058        JpaConfig.class
059})
060public class JpaDstu3Config {
061        @Bean
062        public ITermVersionAdapterSvc terminologyVersionAdapterSvc() {
063                return new TermVersionAdapterSvcDstu3();
064        }
065
066        @Bean(name = JpaConfig.GRAPHQL_PROVIDER_NAME)
067        @Lazy
068        public GraphQLProvider graphQLProvider(FhirContext theFhirContext, IGraphQLStorageServices theGraphqlStorageServices, IValidationSupport theValidationSupport, ISearchParamRegistry theSearchParamRegistry, IDaoRegistry theDaoRegistry) {
069                return new GraphQLProviderWithIntrospection(theFhirContext, theValidationSupport, theGraphqlStorageServices, theSearchParamRegistry, theDaoRegistry);
070        }
071
072        @Bean
073        public ITransactionProcessorVersionAdapter transactionProcessorVersionFacade() {
074                return new TransactionProcessorVersionAdapterDstu3();
075        }
076
077        @Bean(name = "mySystemDaoDstu3")
078        public IFhirSystemDao<Bundle, Meta> systemDaoDstu3() {
079                return new ca.uhn.fhir.jpa.dao.dstu3.FhirSystemDaoDstu3();
080        }
081
082        @Bean(name = "mySystemProviderDstu3")
083        public ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3 systemProviderDstu3(FhirContext theFhirContext) {
084                ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3 retVal = new ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3();
085                retVal.setContext(theFhirContext);
086                retVal.setDao(systemDaoDstu3());
087                return retVal;
088        }
089
090        @Bean
091        public ITermLoaderSvc termLoaderService(ITermDeferredStorageSvc theDeferredStorageSvc, ITermCodeSystemStorageSvc theCodeSystemStorageSvc) {
092                return new TermLoaderSvcImpl(theDeferredStorageSvc, theCodeSystemStorageSvc);
093        }
094
095   @Bean
096        public ITermReadSvcDstu3 terminologyService() {
097                return new TermReadSvcDstu3();
098        }
099
100}