简体   繁体   English

如何实现HAPI FHIR资源dao?

[英]How to implement HAPI FHIR resource dao?

I am new to HAPI FHIR. 我是HAPI FHIR的新手。 Everything goes alright, including the Web UI. 一切顺利,包括Web UI。 I even success to configure to create schema in mysql database. 我甚至成功配置在mysql数据库中创建模式。 However, in the last step, something error happened and hard to me to fix. 然而,在最后一步,发生了一些错误,我很难解决。

This is my servlet: 这是我的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.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>

However, when I go to the Web UI and search a patient, error shows that 但是,当我转到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]]

Any idea how to solve this? 不知道怎么解决这个问题? And BTW, do I need to add ever resource type to the resourceProviders ? 顺便说一句,我是否需要将所有资源类型添加到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. 有一个bean包含所有资源类型。

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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM