我是HAPI FHIR的新手。一切顺利,包括Web UI。我甚至成功配置在mysql数据库中创建模式。但是,在最后一步中,发生了一些错误,我很难解决。
这是我的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就在这里
<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>
但是,当我转到Web UI并搜索患者时,错误显示
Error: HTTP 400 : Invalid request: The FHIR endpoint on this server does not know how to handle GET operation[Patient] with parameters [[_pretty]]
知道如何解决这个问题吗?顺便说一下,我是否需要将所有资源类型添加到resourceProviders
?
提前致谢。
答案 0 :(得分:0)
我终于把事情搞定了。事实证明,我不需要自己实现每个资源。有一个包含所有资源类型的bean。
尝试替换
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);
与
String resourceProviderBeanName = "myResourceProvidersDstu2";
List<IResourceProvider> beans = myAppCtx.getBean(resourceProviderBeanName, List.class);
setResourceProviders(beans);