From 40a75b3ae4e3efe42005b4969f95041958e7e3ef Mon Sep 17 00:00:00 2001 From: Michael Knopke Date: Mon, 14 Sep 2020 12:01:02 +0200 Subject: [PATCH] excluding failed conversions --- examples/find.js | 12 ++++++++---- src/FindAsyncWorker.cc | 17 +++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/examples/find.js b/examples/find.js index e640162..bbb2504 100644 --- a/examples/find.js +++ b/examples/find.js @@ -103,10 +103,6 @@ addon.findScu(JSON.stringify( "port": "5678" }, "tags" : [ - { - "key": "00200012", - "value": "", - }, { "key": "0020000E", "value": "1.3.46.670589.5.2.10.2156913941.892665339.860724", @@ -115,6 +111,14 @@ addon.findScu(JSON.stringify( "key": "00080052", "value": "IMAGE", }, + { + "key": "00200012", + "value": "", + }, + { + "key": "00200013", + "value": "", + }, ], "verbose": true } diff --git a/src/FindAsyncWorker.cc b/src/FindAsyncWorker.cc index 2d804c2..03cfb63 100644 --- a/src/FindAsyncWorker.cc +++ b/src/FindAsyncWorker.cc @@ -112,11 +112,13 @@ void FindScuCallback::callback(T_DIMSE_C_FindRQ *request, int &responseCount, T_ { OFString value; // TODO: use correct method depending on VR type - responseIdentifiers->findAndGetOFStringArray(element.xtag, value); - ns::DicomElement cp; - cp.xtag = element.xtag; - cp.value = to_utf8(std::string(value.c_str())); - responseItem.push_back(cp); + OFCondition status = responseIdentifiers->findAndGetOFStringArray(element.xtag, value); + if (status.good()) { + ns::DicomElement cp; + cp.xtag = element.xtag; + cp.value = to_utf8(std::string(value.c_str())); + responseItem.push_back(cp); + } } m_responseContainer->push_back(responseItem); } @@ -222,7 +224,6 @@ void FindAsyncWorker::Execute(const ExecutionProgress &progress) json v = json::object(); for (const ns::DicomElement &elm : obj) { - std::string value = elm.value; std::string keyName = int_to_hex(elm.xtag.getGroup()) + int_to_hex(elm.xtag.getElement()); DcmTag t(elm.xtag); @@ -232,7 +233,7 @@ void FindAsyncWorker::Execute(const ExecutionProgress &progress) jsonValue = json::array({json{{"Alphabetic", value}}}); } else if (vr == "DS" || vr == "IS" || vr == "SL" || vr == "SS" || vr == "UL" || vr == "US") { - if (value.length == 0) { + if (value.length() == 0) { jsonValue = json::array({}); } else { @@ -250,7 +251,7 @@ void FindAsyncWorker::Execute(const ExecutionProgress &progress) } } else if (vr == "FL" || vr == "FD") { - if (value.length == 0) { + if (value.length() == 0) { jsonValue = json::array({}); } else {