Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/cmds/fhir_cmds/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ async function search (type, query, options) {
}

const searchUrl = `${account}/dstu3/${type}/_search`;
let allResults = [];
while (true) {
const response = await post(
options,
Expand All @@ -73,8 +74,10 @@ async function search (type, query, options) {
linesResult.forEach(line => {
console.log(line);
});
} else {
} else if (options.jsonLine) {
results.forEach(result => print(result, options));
} else {
allResults = allResults.concat(results);
}
}

Expand All @@ -84,12 +87,16 @@ async function search (type, query, options) {
const parsedUrl = url.parse(next.url, true);
query = Object.assign(query, parsedUrl.query);
} else {
return;
break;
}
} else {
return;
break;
}
}

if (!csvConfig && !options.jsonLine) {
print(allResults, options);
}
}

function formatResults (results, csvConfig, options) {
Expand Down
6 changes: 3 additions & 3 deletions test/unit/commands/fhir-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ test.serial.cb('The "fhir" command should list fhir resources', t => {
t.is(postStub.getCall(0).args[2], '_tag=http%3A%2F%2Flifeomic.com%2Ffhir%2Fdataset%7CprojectId&pageSize=1000');
t.deepEqual(postStub.getCall(0).args[3], {headers: {'Content-Type': 'application/x-www-form-urlencoded'}});
t.is(printSpy.callCount, 1);
t.deepEqual(printSpy.getCall(0).args[0], {'resourceType': 'Patient', 'id': 'ABC1234'});
t.deepEqual(printSpy.getCall(0).args[0], [{'resourceType': 'Patient', 'id': 'ABC1234'}]);
t.end();
};

Expand All @@ -73,7 +73,7 @@ test.serial.cb('The "fhir" command should list fhir resources with a query expre
t.is(postStub.getCall(0).args[2], '_tag=http%3A%2F%2Flifeomic.com%2Ffhir%2Ftag%7Cvalue&_tag=http%3A%2F%2Flifeomic.com%2Ffhir%2Fdataset%7CprojectId&pageSize=1000');
t.deepEqual(postStub.getCall(0).args[3], {headers: {'Content-Type': 'application/x-www-form-urlencoded'}});
t.is(printSpy.callCount, 1);
t.deepEqual(printSpy.getCall(0).args[0], {'resourceType': 'Patient', 'id': 'ABC1234'});
t.deepEqual(printSpy.getCall(0).args[0], [{'resourceType': 'Patient', 'id': 'ABC1234'}]);
t.end();
};

Expand All @@ -91,7 +91,7 @@ test.serial.cb('Limit should set the page size for the "fhir" command', t => {
t.is(postStub.getCall(0).args[2], 'pageSize=10');
t.deepEqual(postStub.getCall(0).args[3], {headers: {'Content-Type': 'application/x-www-form-urlencoded'}});
t.is(printSpy.callCount, 1);
t.deepEqual(printSpy.getCall(0).args[0], {'resourceType': 'Patient', 'id': 'ABC1234'});
t.deepEqual(printSpy.getCall(0).args[0], [{'resourceType': 'Patient', 'id': 'ABC1234'}]);
t.end();
};

Expand Down