Skip to content

Commit

Permalink
fix: URL of reference type search
Browse files Browse the repository at this point in the history
# Problems
- lodash set generates nested objects, while queryBuilder[field] does not,
resulting in double query json and unable to find anything.
- The match is {resourceType}/{id}

# Solutions
- Only keep queryBuilder[field]
- Change to URL
  • Loading branch information
Chinlinlee committed Sep 23, 2023
1 parent 10bdedf commit e2d56c8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions models/FHIR/queryBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,15 +464,16 @@ function referenceQuery(query, field, type = "") {
const isUrl = query.match(urlRegex);
let typeAndId = query.split("/");
let queryBuilder = {};

if (isUrl) {
_.set(queryBuilder, field, isUrl[3]);
queryBuilder[field] = isUrl[3];
queryBuilder[field] = isUrl[0];
return queryBuilder;
} else if (typeAndId.length == 2) {
queryBuilder[field] = `${typeAndId[0]}/${typeAndId[1]}`;
} else {
queryBuilder[field] = { $regex: new RegExp(query) };
}

if (type) {
let andQuery = {
$and: []
Expand Down

0 comments on commit e2d56c8

Please sign in to comment.