Mercurial > hg > orthanc
comparison OrthancServer/FromDcmtkBridge.cpp @ 2216:9a8fab016145
sample worklist plugin fine-tuning the C-Find query
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 12 Dec 2016 11:01:09 +0100 |
parents | e3fd5bc429a2 |
children | 3eefb84ac0bd |
comparison
equal
deleted
inserted
replaced
2215:028214a95194 | 2216:9a8fab016145 |
---|---|
1644 ok = false; | 1644 ok = false; |
1645 } | 1645 } |
1646 | 1646 |
1647 if (!ok) | 1647 if (!ok) |
1648 { | 1648 { |
1649 throw OrthancException(ErrorCode_InternalError); | 1649 LOG(ERROR) << "While creating a DICOM instance, tag (" << tag.Format() |
1650 << ") has out-of-range value: \"" << *decoded << "\""; | |
1651 throw OrthancException(ErrorCode_BadFileFormat); | |
1650 } | 1652 } |
1651 } | 1653 } |
1652 | 1654 |
1653 | 1655 |
1654 DcmElement* FromDcmtkBridge::FromJson(const DicomTag& tag, | 1656 DcmElement* FromDcmtkBridge::FromJson(const DicomTag& tag, |
1661 switch (value.type()) | 1663 switch (value.type()) |
1662 { | 1664 { |
1663 case Json::stringValue: | 1665 case Json::stringValue: |
1664 element.reset(CreateElementForTag(tag)); | 1666 element.reset(CreateElementForTag(tag)); |
1665 FillElementWithString(*element, tag, value.asString(), decodeDataUriScheme, dicomEncoding); | 1667 FillElementWithString(*element, tag, value.asString(), decodeDataUriScheme, dicomEncoding); |
1668 break; | |
1669 | |
1670 case Json::nullValue: | |
1671 element.reset(CreateElementForTag(tag)); | |
1672 FillElementWithString(*element, tag, "", decodeDataUriScheme, dicomEncoding); | |
1666 break; | 1673 break; |
1667 | 1674 |
1668 case Json::arrayValue: | 1675 case Json::arrayValue: |
1669 { | 1676 { |
1670 DcmTag key(tag.GetGroup(), tag.GetElement()); | 1677 DcmTag key(tag.GetGroup(), tag.GetElement()); |
1740 DicomTag tag = FromDcmtkBridge::ParseTag(tags[i]); | 1747 DicomTag tag = FromDcmtkBridge::ParseTag(tags[i]); |
1741 if (tag == DICOM_TAG_SPECIFIC_CHARACTER_SET) | 1748 if (tag == DICOM_TAG_SPECIFIC_CHARACTER_SET) |
1742 { | 1749 { |
1743 const Json::Value& value = json[tags[i]]; | 1750 const Json::Value& value = json[tags[i]]; |
1744 if (value.type() != Json::stringValue || | 1751 if (value.type() != Json::stringValue || |
1745 !GetDicomEncoding(encoding, value.asCString())) | 1752 (value.asString().length() != 0 && |
1753 !GetDicomEncoding(encoding, value.asCString()))) | |
1746 { | 1754 { |
1747 LOG(ERROR) << "Unknown encoding while creating DICOM from JSON: " << value; | 1755 LOG(ERROR) << "Unknown encoding while creating DICOM from JSON: " << value; |
1748 throw OrthancException(ErrorCode_BadRequest); | 1756 throw OrthancException(ErrorCode_BadRequest); |
1757 } | |
1758 | |
1759 if (value.asString().length() == 0) | |
1760 { | |
1761 return defaultEncoding; | |
1749 } | 1762 } |
1750 } | 1763 } |
1751 } | 1764 } |
1752 | 1765 |
1753 return encoding; | 1766 return encoding; |