【问题标题】:Creating Resolvers that work with an external FHIR Server创建与外部 FHIR 服务器一起使用的解析器
【发布时间】:2020-08-04 17:00:25
【问题描述】:

我正在探索这个图书馆 https://github.com/Asymmetrik/graphql-fhir

它不包含如何为第 3 方 FHIR 服务器实现解析器的逻辑。

有人尝试过吗?

【问题讨论】:

    标签: graphql hl7-fhir


    【解决方案1】:

    我将在下面添加一些伪代码,但该库本质上是一个包装器并且没有后端,因此您绝对可以使用它来包装其他 FHIR 服务器。 GraphQL 解析器可以解析同步或异步。因此,如果我们以耐心解析器 (https://github.com/Asymmetrik/graphql-fhir/blob/master/src/resources/4_0_0/profiles/patient/resolver.js) 为例,并希望将其连接到第三方服务器,例如 HAPI 或其他服务器。你可以像这样实现它(伪代码未经测试):

    module.exports.getPatient = function getPatient(root, args, context = {}, info) {
        // args contains the arguments in GraphQL format, note that these may
        // not map directly to another FHIR server for naming restriction reasons
        // e.g. fooBar in graphql might be foo-bar in REST
        
        // Make an HTTP request, use any http library, for example, fetch
        return fetch('some/fhir/server/patient', {
            method: 'post',
            body: JSON.stringify(args) // remember args may need to be mapped
          })
          .then(response => response.json())
          .then(results => {
            // Make sure the response matches what the resolver expects, in this
            // case, a single patient
            return results;
          });
    };
    

    https://github.com/Asymmetrik/graphql-fhir/blob/master/FAQ.md#resolvers 有一个示例,但这是加载本地患者,您只需向某个 3rd 方服务器发出 HTTP 请求并异步返回结果。对于处理错误,请务必同时查看 https://github.com/Asymmetrik/graphql-fhir/blob/master/FAQ.md#resolvers

    【讨论】:

    • 所以只是为了澄清。在将 GraphQL 过滤器查询转换为 FHIR 资源 REST 参数方面,库应该开箱即用地处理它(尽管在某些情况下可能需要映射)?同样在将资源链接在一起的情况下,例如,只要有高级 FHIR 资源解析器,库是否会自动支持这种情况?
    • 是的,所以源代码是从发布的结构定义中生成的。因此,除非必须,否则我们不会重命名任何参数,我认为这并不常见。就在您向 3rd Party FHIR 服务器编写查询时,您可能会不时遇到这种情况。至于服用药物的患者,您是像 and 查询还是像嵌套查询一样思考(graphql 允许嵌套解析器进行更多过滤)?我们确实支持 FHIR 规范中定义的大多数参数,因为代码只是从规范中生成的。
    猜你喜欢
    • 1970-01-01
    • 2023-02-09
    • 2022-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-07
    • 2010-12-10
    相关资源
    最近更新 更多