annotate OrthancServer/Sources/ServerJobs/SplitStudyJob.h @ 5663:3765085693e5 large-queries

merge default -> large-queries
author Alain Mazy <am@orthanc.team>
date Thu, 04 Jul 2024 07:40:58 +0200
parents f7adfb22e20e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
5640
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
2844
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 *
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * 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
10 * 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
11 * 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
12 * 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
13 *
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * 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
15 * 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
16 * 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
17 * General Public License for more details.
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 *
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * 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
20 * 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
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
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
26 #include "../../../OrthancFramework/Sources/DicomFormat/DicomTag.h"
3095
beeeb6096f27 removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
27 #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
28 #include "CleaningInstancesJob.h"
2844
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 namespace Orthanc
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 {
3095
beeeb6096f27 removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
32 class ServerContext;
beeeb6096f27 removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
33
3941
771dbd9eb3bd class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
34 class SplitStudyJob : public CleaningInstancesJob
2844
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 private:
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 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
38 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
39
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
2846
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
41 std::set<DicomTag> allowedTags_;
2844
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 std::string sourceStudy_;
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 std::string targetStudy_;
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 std::string targetStudyUid_;
2846
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
45 SeriesUidMap seriesUidMap_;
2844
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 DicomInstanceOrigin origin_;
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 Replacements replacements_;
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
48 std::set<DicomTag> removals_;
2844
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 void CheckAllowedTag(const DicomTag& tag) const;
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
52 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
53
bad8935cd5f2 "/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
54 // 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
55 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
56 using SetOfInstancesJob::AddInstance;
2844
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 protected:
4205
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
59 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
60
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 public:
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 SplitStudyJob(ServerContext& context,
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 const std::string& sourceStudy);
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 SplitStudyJob(ServerContext& context,
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 const Json::Value& serialized);
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
68 const std::string& GetSourceStudy() const
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
69 {
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
70 return sourceStudy_;
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
71 }
2844
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
2847
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2846
diff changeset
73 const std::string& GetTargetStudy() const
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2846
diff changeset
74 {
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2846
diff changeset
75 return targetStudy_;
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
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2846
diff changeset
78 const std::string& GetTargetStudyUid() const
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2846
diff changeset
79 {
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2846
diff changeset
80 return targetStudyUid_;
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2846
diff changeset
81 }
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2846
diff changeset
82
2844
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 void AddSourceSeries(const std::string& series);
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
4712
bad8935cd5f2 "/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
85 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
86
2847
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2846
diff changeset
87 bool LookupTargetSeriesUid(std::string& uid,
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2846
diff changeset
88 const std::string& series) const;
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2846
diff changeset
89
2844
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 void Replace(const DicomTag& tag,
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 const std::string& value);
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
2847
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2846
diff changeset
93 bool LookupReplacement(std::string& value,
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2846
diff changeset
94 const DicomTag& tag) const;
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2846
diff changeset
95
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
96 void Remove(const DicomTag& tag);
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
97
2847
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2846
diff changeset
98 bool IsRemoved(const DicomTag& tag) const
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2846
diff changeset
99 {
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2846
diff changeset
100 return removals_.find(tag) != removals_.end();
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2846
diff changeset
101 }
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2846
diff changeset
102
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
103 void SetOrigin(const DicomInstanceOrigin& origin);
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
104
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
105 void SetOrigin(const RestApiCall& call);
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
106
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
107 const DicomInstanceOrigin& GetOrigin() const
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
108 {
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
109 return origin_;
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
110 }
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
111
4205
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
112 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
113 {
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 }
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115
4205
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
116 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
117 {
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
118 target = "SplitStudy";
2844
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 }
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120
4205
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
121 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
122
4205
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
123 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
124 };
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }