Mercurial > hg > orthanc
annotate OrthancServer/Sources/ServerJobs/SplitStudyJob.h @ 4921:309fb4f02704
fix signature of OrthancPluginIncomingCStoreInstanceFilter
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 23 Feb 2022 11:09:43 +0100 |
parents | 6eff25f70121 |
children | 0ea402b4d901 |
rev | line source |
---|---|
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
4870
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * modify it under the terms of the GNU General Public License as |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * published by the Free Software Foundation, either version 3 of the |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * License, or (at your option) any later version. |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * General Public License for more details. |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 **/ |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 #pragma once |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
4045 | 25 #include "../../../OrthancFramework/Sources/DicomFormat/DicomTag.h" |
3095
beeeb6096f27
removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
26 #include "../DicomInstanceOrigin.h" |
3941
771dbd9eb3bd
class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
27 #include "CleaningInstancesJob.h" |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 namespace Orthanc |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 { |
3095
beeeb6096f27
removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
31 class ServerContext; |
beeeb6096f27
removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
32 |
3941
771dbd9eb3bd
class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
33 class SplitStudyJob : public CleaningInstancesJob |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 private: |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 typedef std::map<std::string, std::string> SeriesUidMap; |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 typedef std::map<DicomTag, std::string> Replacements; |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 |
2846
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
40 std::set<DicomTag> allowedTags_; |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 std::string sourceStudy_; |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 std::string targetStudy_; |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 std::string targetStudyUid_; |
2846
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
44 SeriesUidMap seriesUidMap_; |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 DicomInstanceOrigin origin_; |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 Replacements replacements_; |
2845
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
47 std::set<DicomTag> removals_; |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 void CheckAllowedTag(const DicomTag& tag) const; |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 |
2845
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
51 void Setup(); |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
52 |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
53 // Make setter methods private to prevent incorrect calls |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
54 using SetOfInstancesJob::AddParentResource; |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
55 using SetOfInstancesJob::AddInstance; |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 protected: |
4205 | 58 virtual bool HandleInstance(const std::string& instance) ORTHANC_OVERRIDE; |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 public: |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 SplitStudyJob(ServerContext& context, |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 const std::string& sourceStudy); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 SplitStudyJob(ServerContext& context, |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 const Json::Value& serialized); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 |
2845
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
67 const std::string& GetSourceStudy() const |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
68 { |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
69 return sourceStudy_; |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
70 } |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 |
2847
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
72 const std::string& GetTargetStudy() const |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
73 { |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
74 return targetStudy_; |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
75 } |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
76 |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
77 const std::string& GetTargetStudyUid() const |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
78 { |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
79 return targetStudyUid_; |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
80 } |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
81 |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 void AddSourceSeries(const std::string& series); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
84 void AddSourceInstance(const std::string& instance); // New in Orthanc 1.9.4 |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
85 |
2847
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
86 bool LookupTargetSeriesUid(std::string& uid, |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
87 const std::string& series) const; |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
88 |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 void Replace(const DicomTag& tag, |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 const std::string& value); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 |
2847
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
92 bool LookupReplacement(std::string& value, |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
93 const DicomTag& tag) const; |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
94 |
2845
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
95 void Remove(const DicomTag& tag); |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
96 |
2847
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
97 bool IsRemoved(const DicomTag& tag) const |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
98 { |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
99 return removals_.find(tag) != removals_.end(); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
100 } |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2846
diff
changeset
|
101 |
2845
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
102 void SetOrigin(const DicomInstanceOrigin& origin); |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
103 |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
104 void SetOrigin(const RestApiCall& call); |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
105 |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
106 const DicomInstanceOrigin& GetOrigin() const |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
107 { |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
108 return origin_; |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
109 } |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
110 |
4205 | 111 virtual void Stop(JobStopReason reason) ORTHANC_OVERRIDE |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 |
4205 | 115 virtual void GetJobType(std::string& target) ORTHANC_OVERRIDE |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 { |
2845
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
117 target = "SplitStudy"; |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 |
4205 | 120 virtual void GetPublicContent(Json::Value& value) ORTHANC_OVERRIDE; |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 |
4205 | 122 virtual bool Serialize(Json::Value& target) ORTHANC_OVERRIDE; |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 }; |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 } |