Skip to content

Commit

Permalink
feat(imagingStudy): add identifier search parameter and catch error…
Browse files Browse the repository at this point in the history
… with query
  • Loading branch information
Chinlinlee committed Feb 5, 2022
1 parent 2cc85d7 commit 94885d5
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions api/FHIR/ImagingStudy/controller/get_ImagingStudy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
const mongodb = require('models/mongodb');
const _ = require('lodash');
const {createBundle} = require('models/FHIR/func');
const {handleError} = require('../../../../models/FHIR/httpMessage');
const queryBuild = require('../../../../models/FHIR/queryBuild');
const FHIRFilter = {
_id: 0,
__v: 0,
Expand Down Expand Up @@ -35,13 +37,16 @@ module.exports = async function (req, res) {
}
});
queryParameter.$and = [];
Object.keys(queryParameter).forEach(key => {
for (let key in queryParameter) {
try {
paramsSearch[key](queryParameter);
} catch (e) {

if (key != "$and") {
console.log(e);
return res.status(400).send(handleError.processing(`Unknown search parameter ${key}`))
}
}
});
}
if (queryParameter.$and.length == 0) {
delete queryParameter["$and"];
}
Expand Down Expand Up @@ -113,4 +118,13 @@ const paramsSearch = {
});
delete query["_id"];
}
}
paramsSearch["identifier"] = (query) => {
let buildResult = queryBuild.tokenQuery(query["identifier"], "value", "identifier", "");
for (let i in buildResult) {
query.$and.push({
[i]: buildResult[i]
});
}
delete query['identifier'];
}

0 comments on commit 94885d5

Please sign in to comment.