comparison OrthancServer/ServerIndex.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
450 } 450 }
451 451
452 452
453 namespace Internals 453 namespace Internals
454 { 454 {
455 class ServerIndexListenerTmp : public IServerIndexListener 455 class ServerIndexListenerTodo : public IServerIndexListener
456 { 456 {
457 public: 457 public:
458 virtual void SignalRemainingAncestor(ResourceType parentType, 458 virtual void SignalRemainingAncestor(ResourceType parentType,
459 const std::string& publicId) 459 const std::string& publicId)
460 { 460 {
470 } 470 }
471 471
472 472
473 ServerIndex::ServerIndex(const std::string& storagePath) 473 ServerIndex::ServerIndex(const std::string& storagePath)
474 { 474 {
475 listener2_.reset(new Internals::ServerIndexListenerTmp); 475 listener2_.reset(new Internals::ServerIndexListenerTodo);
476 476
477 if (storagePath == ":memory:") 477 if (storagePath == ":memory:")
478 { 478 {
479 db_.OpenInMemory(); 479 db_.OpenInMemory();
480 db2_.reset(new DatabaseWrapper(*listener2_)); 480 db2_.reset(new DatabaseWrapper(*listener2_));
538 } 538 }
539 539
540 // Create the patient/study/series/instance hierarchy 540 // Create the patient/study/series/instance hierarchy
541 instance = db2_->CreateResource(hasher.HashInstance(), ResourceType_Instance); 541 instance = db2_->CreateResource(hasher.HashInstance(), ResourceType_Instance);
542 542
543 DicomMap dicom;
544 dicomSummary.ExtractInstanceInformation(dicom);
545 db2_->SetMainDicomTags(instance, dicom);
546
543 if (!db2_->LookupResource(hasher.HashSeries(), series, type)) 547 if (!db2_->LookupResource(hasher.HashSeries(), series, type))
544 { 548 {
545 // This is a new series 549 // This is a new series
546 isNewSeries = true; 550 isNewSeries = true;
547 series = db2_->CreateResource(hasher.HashSeries(), ResourceType_Series); 551 series = db2_->CreateResource(hasher.HashSeries(), ResourceType_Series);
552 dicomSummary.ExtractSeriesInformation(dicom);
553 db2_->SetMainDicomTags(series, dicom);
548 db2_->AttachChild(series, instance); 554 db2_->AttachChild(series, instance);
549 555
550 if (!db2_->LookupResource(hasher.HashStudy(), study, type)) 556 if (!db2_->LookupResource(hasher.HashStudy(), study, type))
551 { 557 {
552 // This is a new study 558 // This is a new study
553 study = db2_->CreateResource(hasher.HashStudy(), ResourceType_Study); 559 study = db2_->CreateResource(hasher.HashStudy(), ResourceType_Study);
560 dicomSummary.ExtractStudyInformation(dicom);
561 db2_->SetMainDicomTags(study, dicom);
554 db2_->AttachChild(study, series); 562 db2_->AttachChild(study, series);
555 563
556 if (!db2_->LookupResource(hasher.HashPatient(), patient, type)) 564 if (!db2_->LookupResource(hasher.HashPatient(), patient, type))
557 { 565 {
558 // This is a new patient 566 // This is a new patient
559 patient = db2_->CreateResource(hasher.HashPatient(), ResourceType_Patient); 567 patient = db2_->CreateResource(hasher.HashPatient(), ResourceType_Patient);
568 dicomSummary.ExtractPatientInformation(dicom);
569 db2_->SetMainDicomTags(patient, dicom);
560 db2_->AttachChild(patient, study); 570 db2_->AttachChild(patient, study);
561 } 571 }
562 else 572 else
563 { 573 {
564 assert(type == ResourceType_Patient); 574 assert(type == ResourceType_Patient);
575 db2_->AttachChild(patient, study);
565 } 576 }
566 } 577 }
567 else 578 else
568 { 579 {
569 assert(type == ResourceType_Study); 580 assert(type == ResourceType_Study);
581 db2_->AttachChild(study, series);
570 } 582 }
571 } 583 }
572 else 584 else
573 { 585 {
574 assert(type == ResourceType_Series); 586 assert(type == ResourceType_Series);
587 db2_->AttachChild(series, instance);
575 } 588 }
576 589
577 // Attach the files to the newly created instance 590 // Attach the files to the newly created instance
578 db2_->AttachFile(instance, "_dicom", fileUuid, uncompressedFileSize); 591 db2_->AttachFile(instance, "_dicom", fileUuid, uncompressedFileSize);
579 db2_->AttachFile(instance, "_json", jsonUuid, 0); // TODO "0" 592 db2_->AttachFile(instance, "_json", jsonUuid, 0); // TODO "0"