Mercurial > hg > orthanc
comparison OrthancServer/Search/Compatibility/ICreateInstance.cpp @ 3091:476cba12c2b0 db-changes
IDatabaseWrapper::GetChildrenMetadata()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 05 Jan 2019 15:08:53 +0100 |
parents | 195ba4cbac3f |
children |
comparison
equal
deleted
inserted
replaced
3090:31244604f617 | 3091:476cba12c2b0 |
---|---|
38 | 38 |
39 namespace Orthanc | 39 namespace Orthanc |
40 { | 40 { |
41 namespace Compatibility | 41 namespace Compatibility |
42 { | 42 { |
43 bool ICreateInstance::Apply(ICreateInstance& compatibility, | 43 bool ICreateInstance::Apply(ICreateInstance& database, |
44 IDatabaseWrapper& database, | |
45 IDatabaseWrapper::CreateInstanceResult& result, | 44 IDatabaseWrapper::CreateInstanceResult& result, |
46 int64_t& instanceId, | 45 int64_t& instanceId, |
47 const std::string& hashPatient, | 46 const std::string& hashPatient, |
48 const std::string& hashStudy, | 47 const std::string& hashStudy, |
49 const std::string& hashSeries, | 48 const std::string& hashSeries, |
60 instanceId = tmp; | 59 instanceId = tmp; |
61 return false; | 60 return false; |
62 } | 61 } |
63 } | 62 } |
64 | 63 |
65 instanceId = compatibility.CreateResource(hashInstance, ResourceType_Instance); | 64 instanceId = database.CreateResource(hashInstance, ResourceType_Instance); |
66 | 65 |
67 result.isNewPatient_ = false; | 66 result.isNewPatient_ = false; |
68 result.isNewStudy_ = false; | 67 result.isNewStudy_ = false; |
69 result.isNewSeries_ = false; | 68 result.isNewSeries_ = false; |
70 result.patientId_ = -1; | 69 result.patientId_ = -1; |
114 } | 113 } |
115 | 114 |
116 // Create the series if needed | 115 // Create the series if needed |
117 if (result.isNewSeries_) | 116 if (result.isNewSeries_) |
118 { | 117 { |
119 result.seriesId_ = compatibility.CreateResource(hashSeries, ResourceType_Series); | 118 result.seriesId_ = database.CreateResource(hashSeries, ResourceType_Series); |
120 } | 119 } |
121 | 120 |
122 // Create the study if needed | 121 // Create the study if needed |
123 if (result.isNewStudy_) | 122 if (result.isNewStudy_) |
124 { | 123 { |
125 result.studyId_ = compatibility.CreateResource(hashStudy, ResourceType_Study); | 124 result.studyId_ = database.CreateResource(hashStudy, ResourceType_Study); |
126 } | 125 } |
127 | 126 |
128 // Create the patient if needed | 127 // Create the patient if needed |
129 if (result.isNewPatient_) | 128 if (result.isNewPatient_) |
130 { | 129 { |
131 result.patientId_ = compatibility.CreateResource(hashPatient, ResourceType_Patient); | 130 result.patientId_ = database.CreateResource(hashPatient, ResourceType_Patient); |
132 } | 131 } |
133 | 132 |
134 // Create the parent-to-child links | 133 // Create the parent-to-child links |
135 compatibility.AttachChild(result.seriesId_, instanceId); | 134 database.AttachChild(result.seriesId_, instanceId); |
136 | 135 |
137 if (result.isNewSeries_) | 136 if (result.isNewSeries_) |
138 { | 137 { |
139 compatibility.AttachChild(result.studyId_, result.seriesId_); | 138 database.AttachChild(result.studyId_, result.seriesId_); |
140 } | 139 } |
141 | 140 |
142 if (result.isNewStudy_) | 141 if (result.isNewStudy_) |
143 { | 142 { |
144 compatibility.AttachChild(result.patientId_, result.studyId_); | 143 database.AttachChild(result.patientId_, result.studyId_); |
145 } | 144 } |
146 | 145 |
147 // Sanity checks | 146 // Sanity checks |
148 assert(result.patientId_ != -1); | 147 assert(result.patientId_ != -1); |
149 assert(result.studyId_ != -1); | 148 assert(result.studyId_ != -1); |