comparison OrthancFramework/Sources/DicomParsing/DicomModification.cpp @ 4677:521e39b3f2c0

Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 03 Jun 2021 21:06:34 +0200
parents caf963ee3de9
children 2e850edf03d6
comparison
equal deleted inserted replaced
4676:caf963ee3de9 4677:521e39b3f2c0
37 "Orthanc " ORTHANC_VERSION " - PS 3.15-2008 Table E.1-1"; 37 "Orthanc " ORTHANC_VERSION " - PS 3.15-2008 Table E.1-1";
38 38
39 static const std::string ORTHANC_DEIDENTIFICATION_METHOD_2017c = 39 static const std::string ORTHANC_DEIDENTIFICATION_METHOD_2017c =
40 "Orthanc " ORTHANC_VERSION " - PS 3.15-2017c Table E.1-1 Basic Profile"; 40 "Orthanc " ORTHANC_VERSION " - PS 3.15-2017c Table E.1-1 Basic Profile";
41 41
42 static const std::string ORTHANC_DEIDENTIFICATION_METHOD_2021b =
43 "Orthanc " ORTHANC_VERSION " - PS 3.15-2021b Table E.1-1 Basic Profile";
44
42 namespace Orthanc 45 namespace Orthanc
43 { 46 {
44 class DicomModification::RelationshipsVisitor : public ITagVisitor 47 class DicomModification::RelationshipsVisitor : public ITagVisitor
45 { 48 {
46 private: 49 private:
250 { 253 {
251 Replacements::iterator it = replacements_.find(DICOM_TAG_DEIDENTIFICATION_METHOD); 254 Replacements::iterator it = replacements_.find(DICOM_TAG_DEIDENTIFICATION_METHOD);
252 255
253 if (it != replacements_.end() && 256 if (it != replacements_.end() &&
254 (it->second->asString() == ORTHANC_DEIDENTIFICATION_METHOD_2008 || 257 (it->second->asString() == ORTHANC_DEIDENTIFICATION_METHOD_2008 ||
255 it->second->asString() == ORTHANC_DEIDENTIFICATION_METHOD_2017c)) 258 it->second->asString() == ORTHANC_DEIDENTIFICATION_METHOD_2017c ||
259 it->second->asString() == ORTHANC_DEIDENTIFICATION_METHOD_2021b))
256 { 260 {
257 delete it->second; 261 delete it->second;
258 replacements_.erase(it); 262 replacements_.erase(it);
259 } 263 }
260 } 264 }
589 // Set the DeidentificationMethod tag 593 // Set the DeidentificationMethod tag
590 ReplaceInternal(DICOM_TAG_DEIDENTIFICATION_METHOD, ORTHANC_DEIDENTIFICATION_METHOD_2017c); 594 ReplaceInternal(DICOM_TAG_DEIDENTIFICATION_METHOD, ORTHANC_DEIDENTIFICATION_METHOD_2017c);
591 } 595 }
592 596
593 597
598 void DicomModification::SetupAnonymization2021b()
599 {
600 /**
601 * This is Table E.1-1 from PS 3.15-2021b (DICOM Part 15: Security
602 * and System Management Profiles), "basic profile" column. It was
603 * generated automatically by calling:
604 * "../../../OrthancServer/Resources/GenerateAnonymizationProfile.py
605 * https://raw.githubusercontent.com/jodogne/dicom-specification/master/2021b/part15.xml"
606 *
607 * http://dicom.nema.org/medical/dicom/2021b/output/chtml/part15/chapter_E.html#table_E.1-1a
608 * http://dicom.nema.org/medical/dicom/2021b/output/chtml/part15/chapter_E.html#table_E.1-1
609 **/
610
611 #include "DicomModification_Anonymization2021b.impl.h"
612
613 // Set the DeidentificationMethod tag
614 ReplaceInternal(DICOM_TAG_DEIDENTIFICATION_METHOD, ORTHANC_DEIDENTIFICATION_METHOD_2021b);
615 }
616
617
594 void DicomModification::SetupAnonymization(DicomVersion version) 618 void DicomModification::SetupAnonymization(DicomVersion version)
595 { 619 {
596 isAnonymization_ = true; 620 isAnonymization_ = true;
597 621
598 removals_.clear(); 622 removals_.clear();
611 635
612 case DicomVersion_2017c: 636 case DicomVersion_2017c:
613 SetupAnonymization2017c(); 637 SetupAnonymization2017c();
614 break; 638 break;
615 639
640 case DicomVersion_2021b:
641 SetupAnonymization2021b();
642 break;
643
616 default: 644 default:
617 throw OrthancException(ErrorCode_ParameterOutOfRange); 645 throw OrthancException(ErrorCode_ParameterOutOfRange);
618 } 646 }
619 647
620 // Set the PatientIdentityRemoved tag 648 // Set the PatientIdentityRemoved tag
1027 throw OrthancException(ErrorCode_BadFileFormat); 1055 throw OrthancException(ErrorCode_BadFileFormat);
1028 } 1056 }
1029 1057
1030 bool force = GetBooleanValue("Force", request, false); 1058 bool force = GetBooleanValue("Force", request, false);
1031 1059
1032 // As of Orthanc 1.3.0, the default anonymization is done 1060 // DicomVersion version = DicomVersion_2008; // For Orthanc <= 1.2.0
1033 // according to PS 3.15-2017c Table E.1-1 (basic profile) 1061 // DicomVersion version = DicomVersion_2017c; // For Orthanc between 1.3.0 and 1.9.3
1034 DicomVersion version = DicomVersion_2017c; 1062 DicomVersion version = DicomVersion_2021b; // For Orthanc >= 1.9.4
1035 if (request.isMember("DicomVersion")) 1063 if (request.isMember("DicomVersion"))
1036 { 1064 {
1037 if (request["DicomVersion"].type() != Json::stringValue) 1065 if (request["DicomVersion"].type() != Json::stringValue)
1038 { 1066 {
1039 throw OrthancException(ErrorCode_BadFileFormat); 1067 throw OrthancException(ErrorCode_BadFileFormat);