Skip to content

Commit

Permalink
fix: not response 204 when empty matched document
Browse files Browse the repository at this point in the history
- Refactor, correct name correspond to DICOM level
  • Loading branch information
Chinlinlee committed May 9, 2022
1 parent 61118d0 commit 4d8b4a1
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 29 deletions.
16 changes: 11 additions & 5 deletions api/dicom-web/controller/QIDO-RS/queryAllInstances.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,22 @@ module.exports = async function (req, res) {
}

let dicomTagQuery = convertAllQueryToDICOMTag(query);
let studiesJson = await getInstanceDicomJson(
let instancesJson = await getInstanceDicomJson(
dicomTagQuery,
limit,
skip,
req
);
res.writeHead(200, {
"Content-Type": "application/dicom+json"
});
res.end(JSON.stringify(studiesJson.data));
let instancesJsonLength = _.get(instancesJson, "data.length", 0);
if (instancesJsonLength > 0) {
res.writeHead(200, {
"Content-Type": "application/dicom+json"
});
res.end(JSON.stringify(instancesJson.data));
} else {
res.writeHead(204);
res.end();
}
} catch (e) {
let errorStr = JSON.stringify(e, Object.getOwnPropertyNames(e));
logger.error(`[QIDO-RS] [Error: ${errorStr}]`);
Expand Down
16 changes: 11 additions & 5 deletions api/dicom-web/controller/QIDO-RS/queryAllSeries.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,22 @@ module.exports = async function (req, res) {
}

let dicomTagQuery = convertAllQueryToDICOMTag(query);
let studiesJson = await getSeriesDicomJson(
let seriesJson = await getSeriesDicomJson(
dicomTagQuery,
limit,
skip,
req
);
res.writeHead(200, {
"Content-Type": "application/dicom+json"
});
res.end(JSON.stringify(studiesJson.data));
let seriesJsonLength = _.get(seriesJson, "data.length", 0);
if (seriesJsonLength > 0) {
res.writeHead(200, {
"Content-Type": "application/dicom+json"
});
res.end(JSON.stringify(seriesJson.data));
} else {
res.writeHead(204);
res.end();
}
} catch (e) {
let errorStr = JSON.stringify(e, Object.getOwnPropertyNames(e));
logger.error(`[QIDO-RS] [Error: ${errorStr}]`);
Expand Down
14 changes: 10 additions & 4 deletions api/dicom-web/controller/QIDO-RS/queryAllStudies.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,16 @@ module.exports = async function (req, res) {
skip,
req
);
res.writeHead(200, {
"Content-Type": "application/dicom+json"
});
res.end(JSON.stringify(studiesJson.data));
let studiesJsonLength = _.get(studiesJson, "data.length", 0);
if (studiesJsonLength > 0) {
res.writeHead(200, {
"Content-Type": "application/dicom+json"
});
res.end(JSON.stringify(studiesJson.data));
} else {
res.writeHead(204);
res.end();
}
} catch (e) {
let errorStr = JSON.stringify(e, Object.getOwnPropertyNames(e));
logger.error(`[QIDO-RS] [Error: ${errorStr}]`);
Expand Down
16 changes: 11 additions & 5 deletions api/dicom-web/controller/QIDO-RS/queryStudies-Instances.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,22 @@ module.exports = async function (req, res) {
}

let dicomTagQuery = convertAllQueryToDICOMTag(query);
let studiesJson = await getInstanceDicomJson(
let instancesJson = await getInstanceDicomJson(
dicomTagQuery,
limit,
skip,
req
);
res.writeHead(200, {
"Content-Type": "application/dicom+json"
});
res.end(JSON.stringify(studiesJson.data));
let instancesJsonLength = _.get(instancesJson, "data.length", 0);
if (instancesJsonLength > 0) {
res.writeHead(200, {
"Content-Type": "application/dicom+json"
});
res.end(JSON.stringify(instancesJson.data));
} else {
res.writeHead(204);
res.end();
}
} catch (e) {
let errorStr = JSON.stringify(e, Object.getOwnPropertyNames(e));
logger.error(`[QIDO-RS] [Error: ${errorStr}]`);
Expand Down
16 changes: 11 additions & 5 deletions api/dicom-web/controller/QIDO-RS/queryStudies-Series-Instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,22 @@ module.exports = async function (req, res) {
}

let dicomTagQuery = convertAllQueryToDICOMTag(query);
let studiesJson = await getInstanceDicomJson(
let instancesJson = await getInstanceDicomJson(
dicomTagQuery,
limit,
skip,
req
);
res.writeHead(200, {
"Content-Type": "application/dicom+json"
});
res.end(JSON.stringify(studiesJson.data));
let instancesJsonLength = _.get(instancesJson, "data.length", 0);
if (instancesJsonLength > 0) {
res.writeHead(200, {
"Content-Type": "application/dicom+json"
});
res.end(JSON.stringify(instancesJson.data));
} else {
res.writeHead(204);
res.end();
}
} catch (e) {
let errorStr = JSON.stringify(e, Object.getOwnPropertyNames(e));
logger.error(`[QIDO-RS] [Error: ${errorStr}]`);
Expand Down
16 changes: 11 additions & 5 deletions api/dicom-web/controller/QIDO-RS/queryStudies-Series.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,22 @@ module.exports = async function (req, res) {
}

let dicomTagQuery = convertAllQueryToDICOMTag(query);
let studiesJson = await getSeriesDicomJson(
let seriesJson = await getSeriesDicomJson(
dicomTagQuery,
limit,
skip,
req
);
res.writeHead(200, {
"Content-Type": "application/dicom+json"
});
res.end(JSON.stringify(studiesJson.data));
let seriesJsonLength = _.get(seriesJson, "data.length", 0);
if (seriesJsonLength > 0) {
res.writeHead(200, {
"Content-Type": "application/dicom+json"
});
res.end(JSON.stringify(seriesJson.data));
} else {
res.writeHead(204);
res.end();
}
} catch (e) {
let errorStr = JSON.stringify(e, Object.getOwnPropertyNames(e));
logger.error(`[QIDO-RS] [Error: ${errorStr}]`);
Expand Down

0 comments on commit 4d8b4a1

Please sign in to comment.