protected BaseImageLevelUpdateCommand(string name) : base("ImageLevelUpdateCommand", true) { UpdateEntry = new ImageLevelUpdateEntry(); CommandName = name; Description = "Update Dicom Tag"; }
private void UpdateEntity(ServerEntity entity) { EntityDicomMap entityMap = EntityDicomMapManager.Get(entity.GetType()); foreach (BaseImageLevelUpdateCommand command in _commands) { ImageLevelUpdateEntry entry = command.UpdateEntry; if (!entityMap.ContainsKey(entry.TagPath.Tag)) { continue; } string value = entry.GetStringValue(); DicomTag tag = entry.TagPath.Tag; if (tag.TagValue == DicomTags.PatientsSex) { // Valid Patient's Sex value : "M", "F" or "O" if (!String.IsNullOrEmpty(value) && !value.ToUpper().Equals("M") && !value.ToUpper().Equals("F")) { value = "O"; } } int maxLength = tag.VR.Equals(DicomVr.PNvr) ? 64 : (int)tag.VR.MaximumLength; if (value != null && value.Length > maxLength) { Platform.Log(LogLevel.Warn, "Truncating value to VR Length: {0}: {1}", tag.VR.Name, value); if (!entityMap.Populate(entity, entry.TagPath.Tag, value.Substring(0, maxLength))) { throw new ApplicationException(String.Format("Unable to update {0}. See log file for details.", entity.Name)); } } else { if (!entityMap.Populate(entity, entry.TagPath.Tag, value)) { throw new ApplicationException(String.Format("Unable to update {0}. See log file for details.", entity.Name)); } } } }
public AddOriginalAttributes() { UpdateEntry = new ImageLevelUpdateEntry() { TagPath = new DicomTagPath() { Tag = DicomTagDictionary.GetDicomTag(DicomTags.OriginalAttributesSequence) }, Value = "N/A", OriginalValue = "N/A" }; }
protected static DicomAttribute FindAttribute(DicomAttributeCollection collection, ImageLevelUpdateEntry entry) { if (collection == null) { return(null); } if (entry.TagPath.Parents != null) { foreach (DicomTag tag in entry.TagPath.Parents) { DicomAttribute sq = collection[tag] as DicomAttributeSQ; if (sq == null) { throw new Exception(String.Format("Invalid tag value: {0}({1}) is not a SQ VR", tag, tag.Name)); } if (sq.IsEmpty) { DicomSequenceItem item = new DicomSequenceItem(); sq.AddSequenceItem(item); } DicomSequenceItem[] items = sq.Values as DicomSequenceItem[]; Platform.CheckForNullReference(items, "items"); collection = items[0]; } } return(collection[entry.TagPath.Tag]); }
protected static DicomAttribute FindAttribute(DicomAttributeCollection collection, ImageLevelUpdateEntry entry) { if (collection == null) return null; if (entry.TagPath.Parents != null) { foreach (DicomTag tag in entry.TagPath.Parents) { DicomAttribute sq = collection[tag] as DicomAttributeSQ; if (sq == null) { throw new Exception(String.Format("Invalid tag value: {0}({1}) is not a SQ VR", tag, tag.Name)); } if (sq.IsEmpty) { DicomSequenceItem item = new DicomSequenceItem(); sq.AddSequenceItem(item); } DicomSequenceItem[] items = sq.Values as DicomSequenceItem[]; Platform.CheckForNullReference(items, "items"); collection = items[0]; } } return collection[entry.TagPath.Tag]; }
private void Initialize() { using (IPersistenceContext readContext = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { _backupDir = ServerExecutionContext.Current.BackupDirectory; _oldStudyPath = _oldStudyLocation.GetStudyPath(); _oldStudyInstanceUid = _oldStudyLocation.StudyInstanceUid; _oldStudyFolder = _oldStudyLocation.StudyFolder; _newStudyInstanceUid = _oldStudyInstanceUid; _study = _oldStudyLocation.LoadStudy(readContext); _totalSopCount = _study.NumberOfStudyRelatedInstances; _curPatient = _study.LoadPatient(readContext); _oldPatientInfo = new PatientInfo { Name = _curPatient.PatientsName, PatientId = _curPatient.PatientId, IssuerOfPatientId = _curPatient.IssuerOfPatientId }; _newPatientInfo = new PatientInfo(_oldPatientInfo); Debug.Assert(_newPatientInfo.Equals(_oldPatientInfo)); foreach (BaseImageLevelUpdateCommand command in _commands) { ImageLevelUpdateEntry imageLevelUpdate = command.UpdateEntry; if (imageLevelUpdate == null) { continue; } if (imageLevelUpdate.TagPath.Tag.TagValue == DicomTags.StudyInstanceUid) { _newStudyInstanceUid = imageLevelUpdate.GetStringValue(); } else if (imageLevelUpdate.TagPath.Tag.TagValue == DicomTags.PatientId) { _newPatientInfo.PatientId = imageLevelUpdate.GetStringValue(); } else if (imageLevelUpdate.TagPath.Tag.TagValue == DicomTags.IssuerOfPatientId) { _newPatientInfo.IssuerOfPatientId = imageLevelUpdate.GetStringValue(); } else if (imageLevelUpdate.TagPath.Tag.TagValue == DicomTags.PatientsName) { _newPatientInfo.Name = imageLevelUpdate.GetStringValue(); } } Platform.CheckForNullReference(_newStudyInstanceUid, "_newStudyInstanceUid"); NewStudyPath = Path.Combine(_oldStudyLocation.FilesystemPath, _partition.PartitionFolder); NewStudyPath = Path.Combine(NewStudyPath, _oldStudyFolder); NewStudyPath = Path.Combine(NewStudyPath, _newStudyInstanceUid); _newPatient = FindPatient(_newPatientInfo, readContext); _patientInfoIsNotChanged = _newPatientInfo.Equals(_oldPatientInfo); Statistics.InstanceCount = _study.NumberOfStudyRelatedInstances; Statistics.StudySize = (ulong)_oldStudyLocation.LoadStudyXml().GetStudySize(); // The study path will be changed. We will need to delete the original folder at the end. // May be too simple to test if two paths are the same. But let's assume it is good enough for 99% of the time. _deleteOriginalFolder = NewStudyPath != _oldStudyPath; _initialized = true; } }
protected BaseImageLevelUpdateCommand() : base("ImageLevelUpdateCommand", true) { UpdateEntry = new ImageLevelUpdateEntry(); }