Google Healthcare API Node.js – 使用开始和结束日期筛选预约

huangapple go评论55阅读模式
英文:

Google Healthcare API Nodejs - Filter Appointment using start and end date

问题

I cannot filter an Appointment from start and end date using the google healthcare API.

I am trying to recreate the query below:

Appointment?date=ge2023-02-03T04:00:00.000Z&date=le2023-02-05T04:00:00.000Z

This is my javascript code using the library:

const parent = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}`;

const params = {
   parent,
   resourceType,
   date: `le${end}`,
   date: `ge${start}`,
};

const resource = await healthcare.projects.locations.datasets.fhirStores.fhir.search(params);

date: `ge${start}` is ignored because you cannot duplicate the same key.
Is there any other way I can achieve this.
Thanks!

英文:

I cannot filter an Appointment from start and end date using the google healthcare API.

I am trying to recreate the query below:

Appointment?date=ge2023-02-03T04:00:00.000Z&date=le2023-02-05T04:00:00.000Z

This is my javascript code using the library:

const parent = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}`;

const params = {
   parent,
   resourceType,
   date: `le${end}`,
   date: `ge${start}`,
};

const resource = await healthcare.projects.locations.datasets.fhirStores.fhir.search(params);

date: `ge${start}` is ignored because you cannot duplicate the same key.
Is there any other way I can achieve this.
Thanks!

答案1

得分: 1

我成功使它工作。

const params = {
   parent,
   resourceType,
   "date:end": `le${end}`,
   "date:start": `ge${start}`,
};

只需将"date"更改为"date:start""date:end"

英文:

I was able to make it work.

const params = {
   parent,
   resourceType,
   "date:end": `le${end}`,
   "date:start": `ge${start}`,
};

Just change "date" to "date:start" and "date:end"

答案2

得分: 0

我看到你已经能够让这个工作,但有更好的方法。你实际上想要做的是指定多个日期参数。你提出的解决方案是通过使用不存在的修饰符 :start:end 来实现的。默认情况下,FHIR 存储会删除它不认识的修饰符,所以你的查询与 date=le...&date=ge... 是相同的,这是你想要的最终结果。但是,如果你使用了头部 Prefer: handling=strict,或者在你的 FHIR 存储配置中设置了 defaultSearchHandlingStrict,你将会收到来自此搜索的错误信息。

那么正确的做法是什么呢?如果你想要指定多个查询参数以进行 AND 运算(使用 Node API),你只需要指定一个数组。将来,如果你想要将它们进行 OR 运算,你可以使用单个参数并使用逗号分隔的列表。所以你的代码变成了

  const params = {
    parent,
    resourceType,
    date: [`le${end}`, `ge${start}`],
  };

顺便提一下,使用 resourceType 参数的 search 方法是未定义的,你想要的方法是 searchType。它们在代码生成的方式上看起来相同,但它们的功能略有不同。

英文:

I see that you were able to make this work, but there's a better way. What you essentially want to do here is specify multiple date parameters. The solution that you've come up with does this, but by using non-existent modifiers, :start and :end. By default the FHIR store drop modifiers it does not recognize, so your query as the same as date=le...&date=ge..., which is the end result you want. But if you were using the header Prefer: handling=strict, or set defaultSearchHandlingStrict in your FHIR store config, you'll get an error back from this search.

So what's the correct thing to do? If you want to specify multiple query parameters to be ANDed together (with the Node API), all you need to do is specify an array. In the future, if you wanted to OR them together you would use a single parameter with a comma separated list. So your code becomes

  const params = {
    parent,
    resourceType,
    date: [`le${end}`, `ge${start}`],
  };

As a side note, the behaviour of search with the resourceType parameter is undefined, the method you want is searchType. These look the same due to the way the code is generated, but they function slightly differently.

huangapple
  • 本文由 发表于 2023年2月6日 05:19:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/75355582.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定