annotate OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp @ 800:ecedd89055db

generation of DICOM images from PNG files
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 06 May 2014 16:33:40 +0200
parents e7b1ca0f1e04
children a811bdf8b8eb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege,
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Belgium
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * In addition, as a special exception, the copyright holders of this
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * program give permission to link the code of its release with the
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * the linked executables. You must obey the GNU General Public License
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * you do not wish to do so, delete this exception statement from your
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * version. If you delete this exception statement from all source files
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * in the program, then also delete it here.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #include "OrthancRestApi.h"
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
35 #include "../DicomModification.h"
795
d466b3606aca refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 791
diff changeset
36 #include "../FromDcmtkBridge.h"
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
37
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include <glog/logging.h>
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 namespace Orthanc
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 // Modification of DICOM instances ------------------------------------------
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
44 enum TagOperation
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
46 TagOperation_Keep,
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
47 TagOperation_Remove
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
48 };
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
50 static void ParseListOfTags(DicomModification& target,
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
51 const Json::Value& query,
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
52 TagOperation operation)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 {
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
54 if (!query.isArray())
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 throw OrthancException(ErrorCode_BadRequest);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
59 for (Json::Value::ArrayIndex i = 0; i < query.size(); i++)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 {
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
61 std::string name = query[i].asString();
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
62
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 DicomTag tag = FromDcmtkBridge::ParseTag(name);
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
64
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
65 switch (operation)
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
66 {
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
67 case TagOperation_Keep:
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
68 target.Keep(tag);
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
69 VLOG(1) << "Keep: " << name << " " << tag << std::endl;
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
70 break;
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
72 case TagOperation_Remove:
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
73 target.Remove(tag);
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
74 VLOG(1) << "Remove: " << name << " " << tag << std::endl;
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
75 break;
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
76
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
77 default:
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
78 throw OrthancException(ErrorCode_InternalError);
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
79 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
84 static void ParseReplacements(DicomModification& target,
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 const Json::Value& replacements)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 if (!replacements.isObject())
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 throw OrthancException(ErrorCode_BadRequest);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 Json::Value::Members members = replacements.getMemberNames();
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 for (size_t i = 0; i < members.size(); i++)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 const std::string& name = members[i];
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 std::string value = replacements[name].asString();
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
796
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
98 DicomTag tag = FromDcmtkBridge::ParseTag(name);
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 796
diff changeset
99 target.Replace(tag, value);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
101 VLOG(1) << "Replace: " << name << " " << tag << " == " << value << std::endl;
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 static std::string GeneratePatientName(ServerContext& context)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 uint64_t seq = context.GetIndex().IncrementGlobalSequence(GlobalProperty_AnonymizationSequence);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 return "Anonymized" + boost::lexical_cast<std::string>(seq);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
113 static bool ParseModifyRequest(DicomModification& target,
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 const RestApi::PostCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 {
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
116 // curl http://localhost:8042/series/95a6e2bf-9296e2cc-bf614e2f-22b391ee-16e010e0/modify -X POST -d '{"Replace":{"InstitutionName":"My own clinic"}}'
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
117
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 Json::Value request;
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
119 if (call.ParseJsonRequest(request) && request.isObject())
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 {
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
121 if (request.isMember("RemovePrivateTags"))
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
122 {
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
123 target.SetRemovePrivateTags(true);
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
124 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 if (request.isMember("Remove"))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 {
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
128 ParseListOfTags(target, request["Remove"], TagOperation_Remove);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 if (request.isMember("Replace"))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 {
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
133 ParseReplacements(target, request["Replace"]);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 return true;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 else
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 return false;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
145 static bool ParseAnonymizationRequest(DicomModification& target,
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
146 RestApi::PostCall& call)
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
147 {
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
148 // curl http://localhost:8042/instances/6e67da51-d119d6ae-c5667437-87b9a8a5-0f07c49f/anonymize -X POST -d '{"Replace":{"PatientName":"hello","0010-0020":"world"},"Keep":["StudyDescription", "SeriesDescription"],"KeepPrivateTags": null,"Remove":["Modality"]}' > Anonymized.dcm
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
149
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
150 target.SetupAnonymization();
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
151 std::string patientName = target.GetReplacement(DICOM_TAG_PATIENT_NAME);
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
152
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
153 Json::Value request;
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
154 if (call.ParseJsonRequest(request) && request.isObject())
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
155 {
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
156 if (request.isMember("KeepPrivateTags"))
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
157 {
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
158 target.SetRemovePrivateTags(false);
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
159 }
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
160
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
161 if (request.isMember("Remove"))
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
162 {
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
163 ParseListOfTags(target, request["Remove"], TagOperation_Remove);
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
164 }
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
165
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
166 if (request.isMember("Replace"))
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
167 {
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
168 ParseReplacements(target, request["Replace"]);
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
169 }
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
170
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
171 if (request.isMember("Keep"))
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
172 {
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
173 ParseListOfTags(target, request["Keep"], TagOperation_Keep);
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
174 }
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
175
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
176 if (target.GetReplacement(DICOM_TAG_PATIENT_NAME) == patientName)
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
177 {
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
178 // Overwrite the random Patient's Name by one that is more
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
179 // user-friendly (provided none was specified by the user)
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
180 target.Replace(DICOM_TAG_PATIENT_NAME, GeneratePatientName(OrthancRestApi::GetContext(call)));
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
181 }
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
182
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
183 return true;
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
184 }
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
185 else
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
186 {
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
187 return false;
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
188 }
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
189 }
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
190
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
191
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
192 static void AnonymizeOrModifyInstance(DicomModification& modification,
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 RestApi::PostCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 {
778
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
195 std::string id = call.GetUriComponent("id", "");
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196
778
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
197 ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), id);
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
198
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
199 std::auto_ptr<ParsedDicomFile> modified(locker.GetDicom().Clone());
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
200 modification.Apply(*modified);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 modified->Answer(call.GetOutput());
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
205 static void AnonymizeOrModifyResource(DicomModification& modification,
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 MetadataType metadataType,
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 ChangeType changeType,
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 ResourceType resourceType,
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 RestApi::PostCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 bool isFirst = true;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 Json::Value result(Json::objectValue);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
216 typedef std::list<std::string> Instances;
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 Instances instances;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 std::string id = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 context.GetIndex().GetChildInstances(instances, id);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 if (instances.empty())
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
226
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 /**
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 * Loop over all the instances of the resource.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 **/
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 for (Instances::const_iterator it = instances.begin();
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 it != instances.end(); ++it)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 LOG(INFO) << "Modifying instance " << *it;
778
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
235
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
236 std::auto_ptr<ServerContext::DicomCacheLocker> locker;
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
237
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
238 try
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
239 {
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
240 locker.reset(new ServerContext::DicomCacheLocker(OrthancRestApi::GetContext(call), *it));
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
241 }
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
242 catch (OrthancException&)
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
243 {
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
244 // This child instance has been removed in between
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
245 continue;
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
246 }
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
247
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
248 ParsedDicomFile& original = locker->GetDicom();
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 DicomInstanceHasher originalHasher = original.GetHasher();
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 /**
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 * Compute the resulting DICOM instance and store it into the Orthanc store.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 **/
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 std::auto_ptr<ParsedDicomFile> modified(original.Clone());
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
257 modification.Apply(*modified);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 std::string modifiedInstance;
791
381f90e2b69d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 788
diff changeset
260 if (context.Store(modifiedInstance, *modified) != StoreStatus_Success)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 LOG(ERROR) << "Error while storing a modified instance " << *it;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 /**
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 * Record metadata information (AnonymizedFrom/ModifiedFrom).
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 **/
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 DicomInstanceHasher modifiedHasher = modified->GetHasher();
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
273 if (originalHasher.HashSeries() != modifiedHasher.HashSeries())
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 context.GetIndex().SetMetadata(modifiedHasher.HashSeries(),
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 metadataType, originalHasher.HashSeries());
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
279 if (originalHasher.HashStudy() != modifiedHasher.HashStudy())
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 context.GetIndex().SetMetadata(modifiedHasher.HashStudy(),
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 metadataType, originalHasher.HashStudy());
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
285 if (originalHasher.HashPatient() != modifiedHasher.HashPatient())
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 context.GetIndex().SetMetadata(modifiedHasher.HashPatient(),
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 metadataType, originalHasher.HashPatient());
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 assert(*it == originalHasher.HashInstance());
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 assert(modifiedInstance == modifiedHasher.HashInstance());
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 context.GetIndex().SetMetadata(modifiedInstance, metadataType, *it);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 /**
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 * Compute the JSON object that is returned by the REST call.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 **/
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 if (isFirst)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 std::string newId;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 switch (resourceType)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 case ResourceType_Series:
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 newId = modifiedHasher.HashSeries();
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 break;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 case ResourceType_Study:
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 newId = modifiedHasher.HashStudy();
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 break;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 case ResourceType_Patient:
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 newId = modifiedHasher.HashPatient();
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 break;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 default:
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 throw OrthancException(ErrorCode_InternalError);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 result["Type"] = EnumerationToString(resourceType);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 result["ID"] = newId;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 result["Path"] = GetBasePath(resourceType, newId);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 result["PatientID"] = modifiedHasher.HashPatient();
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 isFirst = false;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 static void ModifyInstance(RestApi::PostCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 {
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
337 DicomModification modification;
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
338
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
339 if (ParseModifyRequest(modification, call))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 {
796
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
341 if (modification.IsReplaced(DICOM_TAG_PATIENT_ID))
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
342 {
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
343 modification.SetLevel(ResourceType_Patient);
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
344 }
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
345 else if (modification.IsReplaced(DICOM_TAG_STUDY_INSTANCE_UID))
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
346 {
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
347 modification.SetLevel(ResourceType_Study);
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
348 }
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
349 else if (modification.IsReplaced(DICOM_TAG_SERIES_INSTANCE_UID))
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
350 {
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
351 modification.SetLevel(ResourceType_Series);
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
352 }
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
353 else
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
354 {
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
355 modification.SetLevel(ResourceType_Instance);
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
356 }
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
357
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
358 AnonymizeOrModifyInstance(modification, call);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 static void AnonymizeInstance(RestApi::PostCall& call)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 {
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
365 DicomModification modification;
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
367 if (ParseAnonymizationRequest(modification, call))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 {
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
369 AnonymizeOrModifyInstance(modification, call);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
374 template <enum ChangeType changeType,
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
375 enum ResourceType resourceType>
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
376 static void ModifyResource(RestApi::PostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 {
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
378 DicomModification modification;
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
380 if (ParseModifyRequest(modification, call))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381 {
796
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
382 modification.SetLevel(resourceType);
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
383 AnonymizeOrModifyResource(modification, MetadataType_ModifiedFrom,
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
384 changeType, resourceType, call);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
389 template <enum ChangeType changeType,
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
390 enum ResourceType resourceType>
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
391 static void AnonymizeResource(RestApi::PostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 {
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
393 DicomModification modification;
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
395 if (ParseAnonymizationRequest(modification, call))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396 {
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
397 AnonymizeOrModifyResource(modification, MetadataType_AnonymizedFrom,
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
398 changeType, resourceType, call);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
400 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402
796
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
403 static void Create(RestApi::PostCall& call)
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
404 {
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
405 // curl http://localhost:8042/tools/create-dicom -X POST -d '{"PatientName":"Hello^World"}'
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 796
diff changeset
406 // curl http://localhost:8042/tools/create-dicom -X POST -d '{"PatientName":"Hello^World","PixelData":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gUGDDcB53FulQAAAElJREFUGNNtj0sSAEEEQ1+U+185s1CtmRkblQ9CZldsKHJDk6DLGLJa6chjh0ooQmpjXMM86zPwydGEj6Ed/UGykkEM8X+p3u8/8LcOJIWLGeMAAAAASUVORK5CYII="}'
796
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
407
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
408 Json::Value request;
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
409 if (call.ParseJsonRequest(request) && request.isObject())
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
410 {
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
411 DicomModification modification;
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
412 ParseReplacements(modification, request);
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
413
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
414 ParsedDicomFile dicom;
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 796
diff changeset
415
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 796
diff changeset
416 if (modification.IsReplaced(DICOM_TAG_PIXEL_DATA))
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 796
diff changeset
417 {
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 796
diff changeset
418 dicom.EmbedImage(modification.GetReplacement(DICOM_TAG_PIXEL_DATA));
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 796
diff changeset
419 modification.Keep(DICOM_TAG_PIXEL_DATA);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 796
diff changeset
420 }
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 796
diff changeset
421
796
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
422 modification.Apply(dicom);
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
423
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
424 std::string id;
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
425 StoreStatus status = OrthancRestApi::GetContext(call).Store(id, dicom);
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
426
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
427 if (status == StoreStatus_Failure)
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
428 {
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
429 LOG(ERROR) << "Error while storing a manually-created instance";
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
430 return;
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
431 }
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
432
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
433 OrthancRestApi::GetApi(call).AnswerStoredInstance(call, id, status);
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
434 }
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
435 }
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
436
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
437
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438 void OrthancRestApi::RegisterAnonymizeModify()
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440 Register("/instances/{id}/modify", ModifyInstance);
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
441 Register("/series/{id}/modify", ModifyResource<ChangeType_ModifiedSeries, ResourceType_Series>);
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
442 Register("/studies/{id}/modify", ModifyResource<ChangeType_ModifiedStudy, ResourceType_Study>);
796
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
443 Register("/patients/{id}/modify", ModifyResource<ChangeType_ModifiedPatient, ResourceType_Patient>);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 Register("/instances/{id}/anonymize", AnonymizeInstance);
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
446 Register("/series/{id}/anonymize", AnonymizeResource<ChangeType_ModifiedSeries, ResourceType_Series>);
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
447 Register("/studies/{id}/anonymize", AnonymizeResource<ChangeType_ModifiedStudy, ResourceType_Study>);
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
448 Register("/patients/{id}/anonymize", AnonymizeResource<ChangeType_ModifiedPatient, ResourceType_Patient>);
796
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
449
e7b1ca0f1e04 creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
450 Register("/tools/create-dicom", Create);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
451 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452 }