comparison OrthancServer/ServerIndex.cpp @ 231:8098448bd827

export log
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 30 Nov 2012 12:18:44 +0100
parents 8a26a8e85edf
children 5368bbe813cf
comparison
equal deleted inserted replaced
230:ae2367145b49 231:8098448bd827
615 615
616 db_->GetChanges(target, since, maxResults); 616 db_->GetChanges(target, since, maxResults);
617 617
618 return true; 618 return true;
619 } 619 }
620
621 void ServerIndex::LogExportedResource(const std::string& publicId,
622 const std::string& remoteModality)
623 {
624 boost::mutex::scoped_lock lock(mutex_);
625
626 int64_t id;
627 ResourceType type;
628 if (!db_->LookupResource(publicId, id, type))
629 {
630 throw OrthancException(ErrorCode_InternalError);
631 }
632
633 std::string patientId;
634 std::string studyInstanceUid;
635 std::string seriesInstanceUid;
636 std::string sopInstanceUid;
637
638 int64_t currentId = id;
639 ResourceType currentType = type;
640
641 // Iteratively go up inside the patient/study/series/instance hierarchy
642 bool done = false;
643 while (!done)
644 {
645 DicomMap map;
646 db_->GetMainDicomTags(map, currentId);
647
648 switch (currentType)
649 {
650 case ResourceType_Patient:
651 patientId = map.GetValue(DICOM_TAG_PATIENT_ID).AsString();
652 done = true;
653 break;
654
655 case ResourceType_Study:
656 studyInstanceUid = map.GetValue(DICOM_TAG_STUDY_INSTANCE_UID).AsString();
657 currentType = ResourceType_Patient;
658 break;
659
660 case ResourceType_Series:
661 seriesInstanceUid = map.GetValue(DICOM_TAG_SERIES_INSTANCE_UID).AsString();
662 currentType = ResourceType_Study;
663 break;
664
665 case ResourceType_Instance:
666 sopInstanceUid = map.GetValue(DICOM_TAG_SOP_INSTANCE_UID).AsString();
667 currentType = ResourceType_Series;
668 break;
669
670 default:
671 throw OrthancException(ErrorCode_InternalError);
672 }
673
674 // If we have not reached the Patient level, find the parent of
675 // the current resource
676 if (!done)
677 {
678 assert(db_->LookupParent(currentId, currentId));
679 }
680 }
681
682 // No need for a SQLite::Transaction here, as we only insert 1 record
683 db_->LogExportedResource(type,
684 publicId,
685 remoteModality,
686 patientId,
687 studyInstanceUid,
688 seriesInstanceUid,
689 sopInstanceUid);
690 }
691
692
693 bool ServerIndex::GetExportedResources(Json::Value& target,
694 int64_t since,
695 unsigned int maxResults)
696 {
697 boost::mutex::scoped_lock lock(mutex_);
698 db_->GetExportedResources(target, since, maxResults);
699 return true;
700 }
620 } 701 }