Skip to content

Commit

Permalink
fix: empty array entry of Bundle present
Browse files Browse the repository at this point in the history
- refact unique to bundle function
- replace condition of total to entry length. I
think check entry length better than total
  • Loading branch information
Chinlinlee committed Mar 2, 2022
1 parent bff8643 commit fddf2f6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 0 additions & 1 deletion api/FHIRApiService/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ module.exports = async function(req, res, resourceType, paramsSearch) {
docs = [...docs, ...includeDocs, ...reincludeDocs];
let bundle = createBundle(req, docs, count, paginationSkip, paginationLimit, resourceType);
res.header('Last-Modified', new Date().toUTCString());
bundle.entry = _.uniqBy(bundle.entry, "fullUrl");
return doRes(200 , bundle);
} catch (e) {
let errorStr = JSON.stringify(e, Object.getOwnPropertyNames(e));
Expand Down
3 changes: 2 additions & 1 deletion models/FHIR/func.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ function createBundle(req, docs, count, skip, limit, resource, option) {
bundle.entry.push(entry);
}
}
if (bundle.total == 0) {
bundle.entry = _.uniqBy(bundle.entry, "fullUrl");
if (bundle.entry.length == 0) {
delete bundle.entry;
}
for (let index in bundle.link) {
Expand Down

0 comments on commit fddf2f6

Please sign in to comment.