如何实现HAPI FHIR资源道?
How to implement HAPI FHIR resource dao?
我是 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>
但是,当我上网 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
?
提前致谢。
我终于开始工作了。事实证明,我不需要自己实现每个资源。有一个包含所有资源类型的 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);
我是 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>
但是,当我上网 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
?
提前致谢。
我终于开始工作了。事实证明,我不需要自己实现每个资源。有一个包含所有资源类型的 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);