comparison OrthancServer/DatabaseWrapper.cpp @ 189:ccbc2cf64a0d

record main dicom tags and changes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 12 Nov 2012 18:03:48 +0100
parents 090cefdab1d1
children b6cef9d45cc3
comparison
equal deleted inserted replaced
188:090cefdab1d1 189:ccbc2cf64a0d
176 { 176 {
177 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Resources VALUES(NULL, ?, ?, NULL)"); 177 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Resources VALUES(NULL, ?, ?, NULL)");
178 s.BindInt(0, type); 178 s.BindInt(0, type);
179 s.BindString(1, publicId); 179 s.BindString(1, publicId);
180 s.Run(); 180 s.Run();
181 return db_.GetLastInsertRowId(); 181 int64_t id = db_.GetLastInsertRowId();
182
183 ChangeType changeType;
184 switch (type)
185 {
186 case ResourceType_Patient:
187 changeType = ChangeType_NewPatient;
188 break;
189
190 case ResourceType_Study:
191 changeType = ChangeType_NewStudy;
192 break;
193
194 case ResourceType_Series:
195 changeType = ChangeType_NewSeries;
196 break;
197
198 case ResourceType_Instance:
199 changeType = ChangeType_NewInstance;
200 break;
201
202 default:
203 throw OrthancException(ErrorCode_InternalError);
204 }
205
206 LogChange(changeType, id, type);
207 return id;
182 } 208 }
183 209
184 bool DatabaseWrapper::LookupResource(const std::string& publicId, 210 bool DatabaseWrapper::LookupResource(const std::string& publicId,
185 int64_t& id, 211 int64_t& id,
186 ResourceType& type) 212 ResourceType& type)
383 } 409 }
384 } 410 }
385 411
386 412
387 void DatabaseWrapper::LogChange(ChangeType changeType, 413 void DatabaseWrapper::LogChange(ChangeType changeType,
388 const std::string& publicId, 414 int64_t internalId,
389 ResourceType resourceType, 415 ResourceType resourceType,
390 const boost::posix_time::ptime& date) 416 const boost::posix_time::ptime& date)
391 { 417 {
392 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Changes VALUES(NULL, ?, ?, ?, ?)"); 418 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Changes VALUES(NULL, ?, ?, ?, ?)");
393 s.BindInt(0, changeType); 419 s.BindInt(0, changeType);
394 s.BindString(1, publicId); 420 s.BindInt(1, internalId);
395 s.BindInt(2, resourceType); 421 s.BindInt(2, resourceType);
396 s.BindString(3, boost::posix_time::to_iso_string(date)); 422 s.BindString(3, boost::posix_time::to_iso_string(date));
397 s.Run(); 423 s.Run();
398 } 424 }
399 425