comparison OrthancServer/FromDcmtkBridge.cpp @ 1693:558b25228a23

creation of tag hierarchy from json
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 08 Oct 2015 13:45:33 +0200
parents e447f3cb8b30
children 06d579e82bb8
comparison
equal deleted inserted replaced
1692:4eaf164dd574 1693:558b25228a23
1010 return ValueRepresentation_Other; 1010 return ValueRepresentation_Other;
1011 } 1011 }
1012 } 1012 }
1013 1013
1014 1014
1015 static bool IsBinaryTag(const DcmTag& key)
1016 {
1017 return key.isPrivate() || key.isUnknownVR();
1018 }
1019
1015 1020
1016 DcmElement* FromDcmtkBridge::CreateElementForTag(const DicomTag& tag) 1021 DcmElement* FromDcmtkBridge::CreateElementForTag(const DicomTag& tag)
1017 { 1022 {
1018 DcmTag key(tag.GetGroup(), tag.GetElement()); 1023 DcmTag key(tag.GetGroup(), tag.GetElement());
1024
1025 if (IsBinaryTag(key))
1026 {
1027 return new DcmOtherByteOtherWord(key);
1028 }
1019 1029
1020 switch (key.getEVR()) 1030 switch (key.getEVR())
1021 { 1031 {
1022 // http://support.dcmtk.org/docs/dcvr_8h-source.html 1032 // http://support.dcmtk.org/docs/dcvr_8h-source.html
1023 1033
1161 std::string mime; 1171 std::string mime;
1162 Toolbox::DecodeDataUriScheme(mime, binary, value); 1172 Toolbox::DecodeDataUriScheme(mime, binary, value);
1163 decoded = &binary; 1173 decoded = &binary;
1164 } 1174 }
1165 1175
1166 1176 DcmTag key(tag.GetGroup(), tag.GetElement());
1167 if (FromDcmtkBridge::IsPrivateTag(tag) || 1177
1168 FromDcmtkBridge::IsUnknownTag(tag)) 1178 if (IsBinaryTag(key))
1169 { 1179 {
1170 if (element.putUint8Array((const Uint8*) decoded->c_str(), decoded->size()).good()) 1180 if (element.putUint8Array((const Uint8*) decoded->c_str(), decoded->size()).good())
1171 { 1181 {
1172 return; 1182 return;
1173 } 1183 }
1175 { 1185 {
1176 throw OrthancException(ErrorCode_InternalError); 1186 throw OrthancException(ErrorCode_InternalError);
1177 } 1187 }
1178 } 1188 }
1179 1189
1180 DcmTag key(tag.GetGroup(), tag.GetElement());
1181 bool ok = false; 1190 bool ok = false;
1182 1191
1183 try 1192 try
1184 { 1193 {
1185 switch (key.getEVR()) 1194 switch (key.getEVR())
1312 throw OrthancException(ErrorCode_InternalError); 1321 throw OrthancException(ErrorCode_InternalError);
1313 } 1322 }
1314 } 1323 }
1315 1324
1316 1325
1317 DcmElement* FromDcmtkBridge::FromJson(const Json::Value& value, 1326 DcmElement* FromDcmtkBridge::FromJson(const DicomTag& tag,
1318 const DicomTag& tag, 1327 const Json::Value& value,
1319 bool decodeBinaryTags) 1328 bool decodeBinaryTags)
1320 { 1329 {
1321 std::auto_ptr<DcmElement> element; 1330 std::auto_ptr<DcmElement> element;
1322 1331
1323 switch (value.type()) 1332 switch (value.type())
1343 std::auto_ptr<DcmItem> item(new DcmItem); 1352 std::auto_ptr<DcmItem> item(new DcmItem);
1344 1353
1345 Json::Value::Members members = value[i].getMemberNames(); 1354 Json::Value::Members members = value[i].getMemberNames();
1346 for (Json::Value::ArrayIndex j = 0; j < members.size(); j++) 1355 for (Json::Value::ArrayIndex j = 0; j < members.size(); j++)
1347 { 1356 {
1348 item->insert(FromJson(value[i][members[j]], ParseTag(members[j]), decodeBinaryTags)); 1357 item->insert(FromJson(ParseTag(members[j]), value[i][members[j]], decodeBinaryTags));
1349 } 1358 }
1350 1359
1351 sequence->append(item.release()); 1360 sequence->append(item.release());
1352 } 1361 }
1353 1362