comparison OrthancServer/ServerIndex.cpp @ 1299:4ce47e8ed0d2

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 06 Feb 2015 15:13:05 +0100
parents 501432928727
children 919dfb2fb3fe
comparison
equal deleted inserted replaced
1298:cf9779324cbf 1299:4ce47e8ed0d2
490 db_.SetMainDicomTag(resource, element.GetTag(), element.GetValue().AsString()); 490 db_.SetMainDicomTag(resource, element.GetTag(), element.GetValue().AsString());
491 } 491 }
492 } 492 }
493 493
494 494
495 int64_t ServerIndex::CreateResource(const std::string& publicId,
496 ResourceType type)
497 {
498 int64_t id = db_.CreateResource(publicId, type);
499
500 ChangeType changeType;
501 switch (type)
502 {
503 case ResourceType_Patient:
504 changeType = ChangeType_NewPatient;
505 break;
506
507 case ResourceType_Study:
508 changeType = ChangeType_NewStudy;
509 break;
510
511 case ResourceType_Series:
512 changeType = ChangeType_NewSeries;
513 break;
514
515 case ResourceType_Instance:
516 changeType = ChangeType_NewInstance;
517 break;
518
519 default:
520 throw OrthancException(ErrorCode_InternalError);
521 }
522
523 ServerIndexChange change(changeType, type, publicId);
524 db_.LogChange(id, change);
525 return id;
526 }
527
495 528
496 ServerIndex::ServerIndex(ServerContext& context, 529 ServerIndex::ServerIndex(ServerContext& context,
497 IDatabaseWrapper& db) : 530 IDatabaseWrapper& db) :
498 done_(false), 531 done_(false),
499 db_(db), 532 db_(db),
567 } 600 }
568 601
569 Recycle(instanceSize, hasher.HashPatient()); 602 Recycle(instanceSize, hasher.HashPatient());
570 603
571 // Create the instance 604 // Create the instance
572 int64_t instance = db_.CreateResource(hasher.HashInstance(), ResourceType_Instance); 605 int64_t instance = CreateResource(hasher.HashInstance(), ResourceType_Instance);
573 606
574 DicomMap dicom; 607 DicomMap dicom;
575 dicomSummary.ExtractInstanceInformation(dicom); 608 dicomSummary.ExtractInstanceInformation(dicom);
576 SetMainDicomTags(instance, dicom); 609 SetMainDicomTags(instance, dicom);
577 610
622 } 655 }
623 656
624 // Create the series if needed 657 // Create the series if needed
625 if (isNewSeries) 658 if (isNewSeries)
626 { 659 {
627 series = db_.CreateResource(hasher.HashSeries(), ResourceType_Series); 660 series = CreateResource(hasher.HashSeries(), ResourceType_Series);
628 dicomSummary.ExtractSeriesInformation(dicom); 661 dicomSummary.ExtractSeriesInformation(dicom);
629 SetMainDicomTags(series, dicom); 662 SetMainDicomTags(series, dicom);
630 } 663 }
631 664
632 // Create the study if needed 665 // Create the study if needed
633 if (isNewStudy) 666 if (isNewStudy)
634 { 667 {
635 study = db_.CreateResource(hasher.HashStudy(), ResourceType_Study); 668 study = CreateResource(hasher.HashStudy(), ResourceType_Study);
636 dicomSummary.ExtractStudyInformation(dicom); 669 dicomSummary.ExtractStudyInformation(dicom);
637 SetMainDicomTags(study, dicom); 670 SetMainDicomTags(study, dicom);
638 } 671 }
639 672
640 // Create the patient if needed 673 // Create the patient if needed
641 if (isNewPatient) 674 if (isNewPatient)
642 { 675 {
643 patient = db_.CreateResource(hasher.HashPatient(), ResourceType_Patient); 676 patient = CreateResource(hasher.HashPatient(), ResourceType_Patient);
644 dicomSummary.ExtractPatientInformation(dicom); 677 dicomSummary.ExtractPatientInformation(dicom);
645 SetMainDicomTags(patient, dicom); 678 SetMainDicomTags(patient, dicom);
646 } 679 }
647 680
648 // Create the parent-to-child links 681 // Create the parent-to-child links