I am new to HAPI FHIR. Everything goes alright, including the Web UI. I even success to configure to create schema in mysql database. However, in the last step, something error happened and hard to me to fix.
This is my servlet:
super.initialize();
myAppCtx = ContextLoaderListener.getCurrentWebApplicationContext();
FhirVersionEnum fhirVersion = FhirVersionEnum.DSTU2;
setFhirContext(new FhirContext(fhirVersion));
// Resource
IFhirResourceDao<Patient> patientDAO = myAppCtx.getBean("myPatientDaoDstu2", IFhirResourceDao.class);
JpaResourceProviderDstu2<Patient> patientProvider = new JpaResourceProviderDstu2<Patient>(patientDAO);
List<IResourceProvider> resourceProviders = new ArrayList<IResourceProvider>();
resourceProviders.add(patientProvider);
setResourceProviders(resourceProviders);
// System
Object systemProvider;
systemProvider = myAppCtx.getBean("mySystemProviderDstu2", JpaSystemProviderDstu2.class);
setPlainProviders(systemProvider);
// Conformance
IFhirSystemDao<Bundle, MetaDt> systemDao = myAppCtx.getBean("mySystemDaoDstu2", IFhirSystemDao.class);
JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(this, systemDao,
myAppCtx.getBean(DaoConfig.class));
confProvider.setImplementationDescription("HBI Solutions");
setServerConformanceProvider(confProvider);
web.xml is here
<web-app>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
com.hbisolutions.www.fhir.config.FhirServerConfig
</param-value>
</context-param>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>com.hbisolutions.www.fhir.config.FhirTesterConfig</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
However, when I go to the Web UI and search a patient, error shows that
Error: HTTP 400 : Invalid request: The FHIR endpoint on this server does not know how to handle GET operation[Patient] with parameters [[_pretty]]
Any idea how to solve this? And BTW, do I need to add ever resource type to the resourceProviders
?
Thanks in advance.
I finally got things working. It turns out that I do not need to implement each resource by myself. There is a bean which contains all the resource types.
try replacing
IFhirResourceDao<Patient> patientDAO = myAppCtx.getBean("myPatientDaoDstu2", IFhirResourceDao.class);
JpaResourceProviderDstu2<Patient> patientProvider = new JpaResourceProviderDstu2<Patient>(patientDAO);
List<IResourceProvider> resourceProviders = new ArrayList<IResourceProvider>();
resourceProviders.add(patientProvider);
setResourceProviders(resourceProviders);
with
String resourceProviderBeanName = "myResourceProvidersDstu2";
List<IResourceProvider> beans = myAppCtx.getBean(resourceProviderBeanName, List.class);
setResourceProviders(beans);