-
Notifications
You must be signed in to change notification settings - Fork 103
Open
Description
The patient search throws an error, since collection.find() returns no promise. The problem is solved with replacing the search function with:
module.exports.search = (args) =>
new Promise((resolve, reject) => {
logger.info('Patient >>> search');
let { base_version } = args;
let query = {};
switch (base_version) {
case VERSIONS['1_0_2']:
query = buildDstu2SearchQuery(args);
break;
case VERSIONS['3_0_1']:
case VERSIONS['4_0_0']:
case VERSIONS['4_0_1']:
query = buildStu3SearchQuery(args);
break;
}
// Grab an instance of our DB and collection
let db = globals.get(CLIENT_DB);
let collection = db.collection(`${COLLECTION.PATIENT}_${base_version}`);
let Patient = getPatient(base_version);
// Query our collection for this observation
collection
.find(query)
.toArray()
.then((patients) => {
// convert mongo object to fhir ressource
patients.forEach(function (element, i, returnArray) {
returnArray[i] = new Patient(element);
});
resolve(patients);
})
.catch((err) => {
logger.error('Error with Patient.search: ', err);
return reject(handleError({ error: err }));
});
});
Metadata
Metadata
Assignees
Labels
No labels