From e2d56c8ab3d09b89454be083a87a2fb408b5b754 Mon Sep 17 00:00:00 2001 From: chinlinlee Date: Sat, 23 Sep 2023 17:31:07 +0800 Subject: [PATCH] fix: URL of reference type search # 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 --- models/FHIR/queryBuild.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/models/FHIR/queryBuild.js b/models/FHIR/queryBuild.js index a49f01c6..e72889be 100644 --- a/models/FHIR/queryBuild.js +++ b/models/FHIR/queryBuild.js @@ -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: []