use of org.snomed.snowstorm.fhir.services.FHIRMedicationProvider in project snowstorm by IHTSDO.
the class HapiRestfulServlet method initialize.
/**
* The initialize method is automatically called when the servlet is starting up, so it can be used to configure the
* servlet to define resource providers, or set up configuration, interceptors, etc.
*/
@Override
protected void initialize() throws ServletException {
final WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
setDefaultResponseEncoding(EncodingEnum.JSON);
final FhirContext ctxt = FhirContext.forR4();
final LenientErrorHandler delegateHandler = new LenientErrorHandler();
ctxt.setParserErrorHandler(new StrictErrorHandler() {
@Override
public void unknownAttribute(IParseLocation theLocation, String theAttributeName) {
delegateHandler.unknownAttribute(theLocation, theAttributeName);
}
@Override
public void unknownElement(IParseLocation theLocation, String theElementName) {
delegateHandler.unknownElement(theLocation, theElementName);
}
@Override
public void unknownReference(IParseLocation theLocation, String theReference) {
delegateHandler.unknownReference(theLocation, theReference);
}
});
setFhirContext(ctxt);
/*
* The servlet defines any number of resource providers, and configures itself to use them by calling
* setResourceProviders()
*/
List<IResourceProvider> resourceProviders = new ArrayList<>();
FHIRCodeSystemProvider csp = applicationContext.getBean(FHIRCodeSystemProvider.class);
FHIRValueSetProvider vsp = applicationContext.getBean(FHIRValueSetProvider.class);
FHIRConceptMapProvider cmp = applicationContext.getBean(FHIRConceptMapProvider.class);
FHIRMedicationProvider mp = applicationContext.getBean(FHIRMedicationProvider.class);
FHIRStructureDefinitionProvider sd = applicationContext.getBean(FHIRStructureDefinitionProvider.class);
resourceProviders.add(csp);
resourceProviders.add(vsp);
resourceProviders.add(cmp);
resourceProviders.add(mp);
resourceProviders.add(sd);
setResourceProviders(resourceProviders);
FHIRTerminologyCapabilitiesProvider tcp = applicationContext.getBean(FHIRTerminologyCapabilitiesProvider.class);
setServerConformanceProvider(tcp);
// Now register interceptors
RootInterceptor interceptor = new RootInterceptor();
registerInterceptor(interceptor);
logger.info("FHIR Resource providers and interceptors registered");
}
Aggregations