【发布时间】:2020-08-04 17:00:25
【问题描述】:
【问题讨论】:
【问题讨论】:
我将在下面添加一些伪代码,但该库本质上是一个包装器并且没有后端,因此您绝对可以使用它来包装其他 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。
【讨论】: