hl7-fhir - fhir.js - 如何在 nodejs 应用程序的搜索查询中传递 Oauth 令牌
问题描述
我有一个连接到 FHIR 服务器并查询患者数据的 nodejs 应用程序。我不确定如何将 Oauth2 令牌传递给 getPatient 函数。我正在为应用程序使用 fhir.js 节点库。
var Fhir = require('fhir.js');
var user = require('user.js);
function getPatient(response){
return new Promise(function(resolve,reject) {
var patientid = 123456;
var Oauth2Token = user.token;
// Create fhir instance
var fhir = Fhir({
baseUrl: process.env.baseUrl,
});
// Execute the search
fhir.search({
type: 'Patient',
query: {id: patientid}
})
.then(function(response){
//manipulate your data here.
var data = response.data.entry[0].resource;
console.log("FHIR Data :",data);
resolve(data);
})
.catch(function(error){
//Error responses
if (error.status){
console.log('Error', error.status);
reject(error);
}
//Errors
if (error.message){
console.log('Error', error.message);
reject(error);
}
});
});
}
解决方案
您可以尝试将 patientId 放在引号中吗?
var patientid = "123456";
推荐阅读
- android - 如何在 Android 应用程序中集成 Dymo Labelwriter 无线标签打印机 SD2008209
- python - 替代“for”LINQ 相当于 Where?
- javascript - Threejs对象旋转值的问题
- c# - 使用 ClickOnce 从 UNC 自动更新 VSTO Excel 插件
- c# - ASP.NET Core 错误:System.TypeLoadException:无法加载类型“Microsoft.AspNetCore.WebUtilities.FileBufferingWriteStream”
- eclipse - Liferay 中的 Eclipse 主题在几行代码后不起作用
- google-apps-script - 如何修复错误'参考错误:“文档”未定义'
- excel - 如何通过 OLEDB 或 SSIS 中的任何其他源连接 Excel 源?
- r - 使用一个shapefile(具有许多多边形)批处理/提取一个栅格的原始数据?
- hive - 我想了解 Hive Metastore 的 db&table 特定信息