Mercurial > hg > orthanc
annotate OrthancServer/Sources/ServerJobs/MergeStudyJob.cpp @ 4785:61da49321754 openssl-3.x
integration mainline->openssl-3.x
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 30 Aug 2021 22:21:24 +0200 |
parents | 783f8a048035 |
children | 70d2a97ca8cb |
rev | line source |
---|---|
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU General Public License as |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * published by the Free Software Foundation, either version 3 of the |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * License, or (at your option) any later version. |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * General Public License for more details. |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 **/ |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 #include "MergeStudyJob.h" |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
4045 | 24 #include "../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" |
25 #include "../../../OrthancFramework/Sources/Logging.h" | |
26 #include "../../../OrthancFramework/Sources/SerializationToolbox.h" | |
4140
0ddc5297a8ab
centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4139
diff
changeset
|
27 #include "../OrthancConfiguration.h" |
3095
beeeb6096f27
removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
28 #include "../ServerContext.h" |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 namespace Orthanc |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 { |
4715
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
33 static void RegisterSeries(std::map<std::string, std::string>& target, |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
34 const std::string& series) |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
35 { |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
36 // Generate a target SeriesInstanceUID for this series |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
37 if (target.find(series) == target.end()) |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
38 { |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
39 target[series] = FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Series); |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
40 } |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
41 } |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
42 |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
43 |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 void MergeStudyJob::AddSourceSeriesInternal(const std::string& series) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 { |
4715
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
46 RegisterSeries(seriesUidMap_, series); |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 // Add all the instances of the series as to be processed |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 std::list<std::string> instances; |
3941
771dbd9eb3bd
class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3940
diff
changeset
|
50 GetContext().GetIndex().GetChildren(instances, series); |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 for (std::list<std::string>::const_iterator |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 it = instances.begin(); it != instances.end(); ++it) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 AddInstance(*it); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 void MergeStudyJob::AddSourceStudyInternal(const std::string& study) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 if (study == targetStudy_) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 { |
2955 | 64 throw OrthancException(ErrorCode_UnknownResource, |
65 "Cannot merge a study into the same study: " + study); | |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 else |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 std::list<std::string> series; |
3941
771dbd9eb3bd
class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3940
diff
changeset
|
70 GetContext().GetIndex().GetChildren(series, study); |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 for (std::list<std::string>::const_iterator |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 it = series.begin(); it != series.end(); ++it) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 AddSourceSeriesInternal(*it); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 bool MergeStudyJob::HandleInstance(const std::string& instance) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 { |
3940
3661e2a72482
safeguard in merge/split job
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
83 if (!HasTrailingStep()) |
3661e2a72482
safeguard in merge/split job
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
84 { |
3661e2a72482
safeguard in merge/split job
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
85 throw OrthancException(ErrorCode_BadSequenceOfCalls, |
3661e2a72482
safeguard in merge/split job
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
86 "AddTrailingStep() should have been called after AddSourceXXX()"); |
3661e2a72482
safeguard in merge/split job
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
87 } |
3661e2a72482
safeguard in merge/split job
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
88 |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 /** |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 * Retrieve the DICOM instance to be modified |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 **/ |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
93 std::unique_ptr<ParsedDicomFile> modified; |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 try |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 { |
3941
771dbd9eb3bd
class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3940
diff
changeset
|
97 ServerContext::DicomCacheLocker locker(GetContext(), instance); |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 modified.reset(locker.GetDicom().Clone(true)); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 catch (OrthancException&) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 LOG(WARNING) << "An instance was removed after the job was issued: " << instance; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 return false; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 /** |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 * Chose the target UIDs |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 **/ |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 std::string series = modified->GetHasher().HashSeries(); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 SeriesUidMap::const_iterator targetSeriesUid = seriesUidMap_.find(series); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 if (targetSeriesUid == seriesUidMap_.end()) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 throw OrthancException(ErrorCode_BadFileFormat); // Should never happen |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 /** |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 * Copy the tags from the "Patient Module Attributes" and "General |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 * Study Module Attributes" modules of the target study |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 **/ |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 for (std::set<DicomTag>::const_iterator it = removals_.begin(); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 it != removals_.end(); ++it) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 modified->Remove(*it); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 for (Replacements::const_iterator it = replacements_.begin(); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 it != replacements_.end(); ++it) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 modified->ReplacePlainString(it->first, it->second); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 /** |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 * Store the new instance into Orthanc |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 **/ |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 modified->ReplacePlainString(DICOM_TAG_SERIES_INSTANCE_UID, targetSeriesUid->second); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 |
3507
69e49fc044f8
Fix generation of "SOP Instance UID" on split and merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3095
diff
changeset
|
145 // Fix since Orthanc 1.5.8: Assign new "SOPInstanceUID", as the instance has been modified |
69e49fc044f8
Fix generation of "SOP Instance UID" on split and merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3095
diff
changeset
|
146 modified->ReplacePlainString(DICOM_TAG_SOP_INSTANCE_UID, FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Instance)); |
69e49fc044f8
Fix generation of "SOP Instance UID" on split and merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3095
diff
changeset
|
147 |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
148 std::unique_ptr<DicomInstanceToStore> toStore(DicomInstanceToStore::CreateFromParsedDicomFile(*modified)); |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
149 toStore->SetOrigin(origin_); |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 std::string modifiedInstance; |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
152 if (GetContext().Store(modifiedInstance, *toStore, |
3814
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
153 StoreInstanceMode_Default) != StoreStatus_Success) |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 LOG(ERROR) << "Error while storing a modified instance " << instance; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 return false; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 return true; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 MergeStudyJob::MergeStudyJob(ServerContext& context, |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 const std::string& targetStudy) : |
3941
771dbd9eb3bd
class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3940
diff
changeset
|
165 CleaningInstancesJob(context, false /* by default, remove source instances */), |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 targetStudy_(targetStudy) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 /** |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 * Check the validity of the input ID |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 **/ |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 ResourceType type; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 |
3941
771dbd9eb3bd
class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3940
diff
changeset
|
174 if (!GetContext().GetIndex().LookupResourceType(type, targetStudy) || |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 type != ResourceType_Study) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 { |
2955 | 177 throw OrthancException(ErrorCode_UnknownResource, |
178 "Cannot merge into an unknown study: " + targetStudy); | |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 /** |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 * Detect the tags to be removed/replaced by parsing one child |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 * instance of the study |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 **/ |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 DicomTag::AddTagsForModule(removals_, DicomModule_Patient); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 DicomTag::AddTagsForModule(removals_, DicomModule_Study); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 std::list<std::string> instances; |
3941
771dbd9eb3bd
class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3940
diff
changeset
|
191 GetContext().GetIndex().GetChildInstances(instances, targetStudy); |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 if (instances.empty()) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 throw OrthancException(ErrorCode_UnknownResource); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 DicomMap dicom; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 { |
3941
771dbd9eb3bd
class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3940
diff
changeset
|
201 ServerContext::DicomCacheLocker locker(GetContext(), instances.front()); |
4140
0ddc5297a8ab
centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4139
diff
changeset
|
202 OrthancConfiguration::DefaultExtractDicomSummary(dicom, locker.GetDicom()); |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 const std::set<DicomTag> moduleTags = removals_; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 for (std::set<DicomTag>::const_iterator it = moduleTags.begin(); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 it != moduleTags.end(); ++it) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 const DicomValue* value = dicom.TestAndGetValue(*it); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 std::string str; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 if (value != NULL && |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
213 value->CopyToString(str, false)) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 removals_.erase(*it); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 replacements_.insert(std::make_pair(*it, str)); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
220 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 void MergeStudyJob::SetOrigin(const DicomInstanceOrigin& origin) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 if (IsStarted()) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 else |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 origin_ = origin; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
235 void MergeStudyJob::SetOrigin(const RestApiCall& call) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
236 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
237 SetOrigin(DicomInstanceOrigin::FromRest(call)); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
238 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 |
4715
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
241 void MergeStudyJob::AddSource(const std::string& publicId) |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
242 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
243 ResourceType level; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
244 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 if (IsStarted()) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
246 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
247 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
248 } |
4715
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
249 else if (!GetContext().GetIndex().LookupResourceType(level, publicId)) |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
250 { |
2955 | 251 throw OrthancException(ErrorCode_UnknownResource, |
4715
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
252 "Cannot find this resource: " + publicId); |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
253 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
254 else |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
255 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
256 switch (level) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
257 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
258 case ResourceType_Study: |
4715
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
259 AddSourceStudyInternal(publicId); |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
260 break; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
261 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
262 case ResourceType_Series: |
4715
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
263 AddSourceSeries(publicId); |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
264 break; |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
265 |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
266 case ResourceType_Instance: |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
267 AddSourceInstance(publicId); |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
268 break; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
269 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
270 default: |
2955 | 271 throw OrthancException(ErrorCode_UnknownResource, |
4715
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
272 "This resource is neither a study, nor a series, nor an instance: " + |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
273 publicId + " is a " + std::string(EnumerationToString(level))); |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
274 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
275 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
276 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
277 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
278 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
279 void MergeStudyJob::AddSourceSeries(const std::string& series) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
280 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
281 std::string parent; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
282 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
283 if (IsStarted()) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
284 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
285 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
286 } |
3941
771dbd9eb3bd
class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3940
diff
changeset
|
287 else if (!GetContext().GetIndex().LookupParent(parent, series, ResourceType_Study)) |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
288 { |
2955 | 289 throw OrthancException(ErrorCode_UnknownResource, |
290 "This resource is not a series: " + series); | |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
291 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
292 else if (parent == targetStudy_) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
293 { |
2955 | 294 throw OrthancException(ErrorCode_UnknownResource, |
295 "Cannot merge series " + series + | |
296 " into its parent study " + targetStudy_); | |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
297 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
298 else |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
299 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
300 AddSourceSeriesInternal(series); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
301 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
302 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
303 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
304 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
305 void MergeStudyJob::AddSourceStudy(const std::string& study) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
306 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
307 ResourceType actualLevel; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
308 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
309 if (IsStarted()) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
310 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
311 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
312 } |
3941
771dbd9eb3bd
class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3940
diff
changeset
|
313 else if (!GetContext().GetIndex().LookupResourceType(actualLevel, study) || |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
314 actualLevel != ResourceType_Study) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
315 { |
2955 | 316 throw OrthancException(ErrorCode_UnknownResource, |
317 "This resource is not a study: " + study); | |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
318 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
319 else |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
320 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
321 AddSourceStudyInternal(study); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
322 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
323 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
324 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
325 |
4715
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
326 void MergeStudyJob::AddSourceInstance(const std::string& instance) |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
327 { |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
328 std::string parentStudy, parentSeries; |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
329 |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
330 if (IsStarted()) |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
331 { |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
332 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
333 } |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
334 else if (!GetContext().GetIndex().LookupParent(parentSeries, instance, ResourceType_Series) || |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
335 !GetContext().GetIndex().LookupParent(parentStudy, parentSeries, ResourceType_Study)) |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
336 { |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
337 throw OrthancException(ErrorCode_UnknownResource, |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
338 "This resource is not an instance: " + instance); |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
339 } |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
340 else if (parentStudy == targetStudy_) |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
341 { |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
342 throw OrthancException(ErrorCode_UnknownResource, |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
343 "Cannot merge instance " + instance + |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
344 " into its parent study " + targetStudy_); |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
345 } |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
346 else |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
347 { |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
348 RegisterSeries(seriesUidMap_, parentSeries); |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
349 AddInstance(instance); |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
350 } |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
351 } |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
352 |
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
353 |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
354 void MergeStudyJob::GetPublicContent(Json::Value& value) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
355 { |
3941
771dbd9eb3bd
class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3940
diff
changeset
|
356 CleaningInstancesJob::GetPublicContent(value); |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
357 value["TargetStudy"] = targetStudy_; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
358 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
359 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
360 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
361 static const char* TARGET_STUDY = "TargetStudy"; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
362 static const char* REPLACEMENTS = "Replacements"; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
363 static const char* REMOVALS = "Removals"; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
364 static const char* SERIES_UID_MAP = "SeriesUIDMap"; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
365 static const char* ORIGIN = "Origin"; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
366 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
367 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
368 MergeStudyJob::MergeStudyJob(ServerContext& context, |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
369 const Json::Value& serialized) : |
3941
771dbd9eb3bd
class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3940
diff
changeset
|
370 CleaningInstancesJob(context, serialized, |
771dbd9eb3bd
class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3940
diff
changeset
|
371 false /* by default, remove source instances */) // (*) |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
372 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
373 if (!HasTrailingStep()) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
374 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
375 // Should have been set by (*) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
376 throw OrthancException(ErrorCode_InternalError); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
377 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
378 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
379 targetStudy_ = SerializationToolbox::ReadString(serialized, TARGET_STUDY); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
380 SerializationToolbox::ReadMapOfTags(replacements_, serialized, REPLACEMENTS); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
381 SerializationToolbox::ReadSetOfTags(removals_, serialized, REMOVALS); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
382 SerializationToolbox::ReadMapOfStrings(seriesUidMap_, serialized, SERIES_UID_MAP); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
383 origin_ = DicomInstanceOrigin(serialized[ORIGIN]); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
384 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
385 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
386 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
387 bool MergeStudyJob::Serialize(Json::Value& target) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
388 { |
3941
771dbd9eb3bd
class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3940
diff
changeset
|
389 if (!CleaningInstancesJob::Serialize(target)) |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
390 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
391 return false; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
392 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
393 else |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
394 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
395 target[TARGET_STUDY] = targetStudy_; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
396 SerializationToolbox::WriteMapOfTags(target, replacements_, REPLACEMENTS); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
397 SerializationToolbox::WriteSetOfTags(target, removals_, REMOVALS); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
398 SerializationToolbox::WriteMapOfStrings(target, seriesUidMap_, SERIES_UID_MAP); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
399 origin_.Serialize(target[ORIGIN]); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
400 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
401 return true; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
402 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
403 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
404 } |