1

我是 HAPI FHIR 的新手。一切正常,包括 Web UI。我什至成功配置在 mysql 数据库中创建模式。但是,在最后一步中,发生了一些错误,我很难修复。

这是我的小服务程序:

        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?

提前致谢。

4

1 回答 1

2

我终于把事情搞定了。事实证明,我不需要自己实现每个资源。有一个包含所有资源类型的 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);
于 2017-04-05T02:06:06.177 回答