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
26 changes: 26 additions & 0 deletions tests/tx/search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,32 @@ describe('Search Worker', () => {
expect(response.body.link).toBeUndefined();
});

test('should return only count with _summary=count for ValueSet', async () => {
const response = await request(app)
.get('/tx/r5/ValueSet')
.query({ _summary: 'count' })
.set('Accept', 'application/json');

expect(response.status).toBe(200);
expect(response.body.resourceType).toBe('Bundle');
expect(response.body.type).toBe('searchset');
expect(response.body.total).toBeGreaterThan(0);
expect(response.body.entry).toBeUndefined();
});

test('bundleFromR5 handles bundle without entries', () => {
const { bundleFromR5 } = require('../../tx/xversion/xv-bundle');
const r5Bundle = {
resourceType: 'Bundle',
type: 'searchset',
total: 42
};
const r4Bundle = bundleFromR5(r5Bundle, '4.0.1');
expect(r4Bundle.resourceType).toBe('Bundle');
expect(r4Bundle.total).toBe(42);
expect(r4Bundle.entry).toBeUndefined();
});

test('should return full resources with _summary=false', async () => {
const response = await request(app)
.get('/tx/r5/CodeSystem')
Expand Down
6 changes: 3 additions & 3 deletions tx/xversion/xv-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function bundleToR5(jsonObj, sourceVersion) {
return jsonObj; // No conversion needed
}

for (let be of jsonObj.entry) {
for (let be of jsonObj.entry || []) {
convertResourceToR5(be.resource, sourceVersion);
}

Expand Down Expand Up @@ -51,7 +51,7 @@ function bundleFromR5(r5Obj, targetVersion) {
}
bundle.total = r5Obj.total;
bundle.link = r5Obj.link;
for (let be5 of r5Obj.entry) {
for (let be5 of r5Obj.entry || []) {
let be = {};
if (!bundle.entry) {
bundle.entry = [];
Expand All @@ -68,4 +68,4 @@ function bundleFromR5(r5Obj, targetVersion) {
return bundle;
}

module.exports = { bundleToR5, bundleFromR5 };
module.exports = { bundleToR5, bundleFromR5 };
Loading