0

我正在尝试使用 hapi-fhir-cli 将测试数据上传到本地 JPA fhir 服务器。但是在上传资源时,我收到以下错误。

2020-09-03 17:33:26.486 [main] INFO c.u.f.c.ExampleDataUploader 1 good references
2020-09-03 17:33:26.511 [main] INFO c.u.f.c.ExampleDataUploader Final bundle: 18 entries
2020-09-03 17:33:26.527 [main] INFO c.u.f.c.ExampleDataUploader About to upload 11 examples in a transaction, 2 remaining
2020-09-03 17:33:26.637 [main] INFO c.u.f.c.ExampleDataUploader Final bundle: 62 KB
2020-09-03 17:33:26.641 [main] INFO c.u.f.c.ExampleDataUploader Uploading bundle to server: http://127.0.0.1:8080/hapi-fhir-jpaserver/fhir
2020-09-03 17:33:26.960 [main] ERROR c.u.f.c.ExampleDataUploader Failed to upload bundle:HTTP 0: Failed to retrieve the server metadata statement during client initialization. URL used was http://127.0.0.1:8080/hapi-fhir-jpaserver/fhir/metadata

即使我将http://127.0.0.1:8080/hapi-fhir-jpaserver/fhir/metadata替换为公共 hapi fhir 测试服务器,即http://hapi.fhir.org/baseR4,我也会遇到同样的错误. 运行以下 hapi-fhir-cli 命令后出现上述错误。

hapi-fhir-5.1.0-cli>hapi-fhir-cli 上传示例-t http://127.0.0.1:8080/hapi-fhir-jpaserver/fhir -v dstu2 -l 40

如果我将版本更改为 dstu3 或 r4,我会收到验证错误,即 bundle type=transaction not found in valueset defined at hl7 website,即使它已定义。

有人对这两个错误有任何想法吗?任何帮助,将不胜感激。谢谢。

4

1 回答 1

0

你能显示你在哪里创建你的客户端代码(请)。

但我有两个建议:

您是否将 FhirContext 设置为正确的版本?您需要不记名令牌吗?

//导入ca.uhn.fhir.context.FhirContext;

private FhirContext getContext() {
    return FhirContext.forR4();
}

请注意,创建上下文(对“forR4”的调用很昂贵,因此您希望尽量减少调用它的次数)。

//// import ca.uhn.fhir.rest.client.api.IGenericClient;

private IGenericClient generateIGenericClient(FhirContext fhirContext, GenericClientCreateArgs createArgs) {
    IGenericClient client = fhirContext.newRestfulGenericClient(createArgs.getServerBase());
    if (null != createArgs && createArgs.getBearerToken().isPresent()) {
        String token = createArgs.getBearerToken().get();
        if (StringUtils.isNotBlank(token)) {
            BearerTokenAuthInterceptor authInterceptor = new BearerTokenAuthInterceptor(token);
            client.registerInterceptor(authInterceptor);
        }
    }

    return client;
}

和我的“args”持有者类:

import java.util.Optional;

public final class GenericClientCreateArgs {

    private String serverBase;

    private Optional<String> bearerToken;

    public String getServerBase() {
        return serverBase;
    }

    public void setServerBase(String serverBase) {
        this.serverBase = serverBase;
    }

    public Optional<String> getBearerToken() {
        return bearerToken;
    }

    public void setBearerToken(Optional<String> bearerToken) {
        this.bearerToken = bearerToken;
    }
}
于 2020-09-08T19:35:45.130 回答