annotate OrthancServer/Search/Compatibility/ICompatibilityCreateInstance.cpp @ 3080:1a75595d8e44 db-changes

started refactoring of ServerIndex::Store()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 03 Jan 2019 18:21:22 +0100
parents
children 847a0ed92654
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3080
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "../../PrecompiledHeadersServer.h"
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "ICompatibilityCreateInstance.h"
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../../../Core/OrthancException.h"
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 namespace Orthanc
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 namespace Compatibility
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 bool ICompatibilityCreateInstance::Apply(IDatabaseWrapper::CreateInstanceResult& result,
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 int64_t& instanceId,
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 ICompatibilityCreateInstance& compatibility,
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 IDatabaseWrapper& database,
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 const std::string& hashPatient,
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 const std::string& hashStudy,
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 const std::string& hashSeries,
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 const std::string& hashInstance,
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 bool overwrite)
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 {
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 {
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 ResourceType type;
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 int64_t tmp;
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 if (database.LookupResource(tmp, type, hashInstance))
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 {
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 assert(type == ResourceType_Instance);
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 if (overwrite)
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 {
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 // Overwrite the old instance
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 LOG(INFO) << "Overwriting instance: " << hashInstance;
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 database.DeleteResource(tmp);
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 }
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 else
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 {
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 // Do nothing if the instance already exists
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 instanceId = tmp;
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 return false;
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 }
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 }
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 }
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 instanceId = compatibility.CreateResource(hashInstance, ResourceType_Instance);
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 result.isNewPatient_ = false;
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 result.isNewStudy_ = false;
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 result.isNewSeries_ = false;
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 result.patientId_ = -1;
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 result.studyId_ = -1;
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 result.seriesId_ = -1;
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 // Detect up to which level the patient/study/series/instance
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 // hierarchy must be created
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 {
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 ResourceType dummy;
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 if (database.LookupResource(result.seriesId_, dummy, hashSeries))
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 {
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 assert(dummy == ResourceType_Series);
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 // The patient, the study and the series already exist
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 bool ok = (database.LookupResource(result.patientId_, dummy, hashPatient) &&
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 database.LookupResource(result.studyId_, dummy, hashStudy));
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 assert(ok);
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 }
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 else if (database.LookupResource(result.studyId_, dummy, hashStudy))
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 {
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 assert(dummy == ResourceType_Study);
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 // New series: The patient and the study already exist
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 result.isNewSeries_ = true;
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 bool ok = database.LookupResource(result.patientId_, dummy, hashPatient);
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 assert(ok);
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 }
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 else if (database.LookupResource(result.patientId_, dummy, hashPatient))
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 {
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 assert(dummy == ResourceType_Patient);
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 // New study and series: The patient already exist
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 result.isNewStudy_ = true;
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 result.isNewSeries_ = true;
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 }
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 else
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 {
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 // New patient, study and series: Nothing exists
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 result.isNewPatient_ = true;
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 result.isNewStudy_ = true;
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 result.isNewSeries_ = true;
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 }
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 // Create the series if needed
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 if (result.isNewSeries_)
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 {
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 result.seriesId_ = compatibility.CreateResource(hashSeries, ResourceType_Series);
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 }
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 // Create the study if needed
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 if (result.isNewStudy_)
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 {
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 result.studyId_ = compatibility.CreateResource(hashStudy, ResourceType_Study);
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 }
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 // Create the patient if needed
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 if (result.isNewPatient_)
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 {
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 result.patientId_ = compatibility.CreateResource(hashPatient, ResourceType_Patient);
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 }
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 // Create the parent-to-child links
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 compatibility.AttachChild(result.seriesId_, instanceId);
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 if (result.isNewSeries_)
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 {
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 compatibility.AttachChild(result.studyId_, result.seriesId_);
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 }
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 if (result.isNewStudy_)
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 {
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 compatibility.AttachChild(result.patientId_, result.studyId_);
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 }
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 // Sanity checks
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 assert(result.patientId_ != -1);
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 assert(result.studyId_ != -1);
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 assert(result.seriesId_ != -1);
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 assert(instanceId != -1);
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 return true;
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 }
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 }
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 }