public void AssertTagValueChanged(uint tag, string valueToSet, string originalCharacterSet, string expectedNewCharacterSet) { DicomAttributeCollection dataset = new DicomAttributeCollection(); SetupDataSet(dataset, originalCharacterSet); DicomFile file = new DicomFile("test", CreateMetaInfo(), dataset); Assert.AreEqual(originalCharacterSet, file.DataSet[DicomTags.SpecificCharacterSet].ToString()); SetTagCommand cmd = new SetTagCommand(tag, valueToSet); Assert.AreEqual(cmd.CanSaveInUnicode, UnicodeAllowed, "SetTagCommand.CanSaveInUnicode returns an incorrect value"); Assert.IsTrue(cmd.Apply(file), "SetTagCommand.Apply failed"); var filename = string.Format("Test-{0}.dcm", DicomTagDictionary.GetDicomTag(tag).Name); Assert.IsTrue(file.Save(filename), "Unable to save dicom file"); file = new DicomFile(filename); file.Load(); if (valueToSet == null) { Assert.AreEqual(string.Empty, file.DataSet[tag].ToString()); } else { Assert.AreEqual(valueToSet, file.DataSet[tag].ToString()); } Assert.IsTrue(file.DataSet[DicomTags.SpecificCharacterSet].ToString().Equals(expectedNewCharacterSet)); Delete(filename); }
public void AssertTagValueChanged(uint tag, string valueToSet, string originalCharacterSet, string expectedNewCharacterSet) { DicomAttributeCollection dataset = new DicomAttributeCollection(); SetupDataSet(dataset, originalCharacterSet); DicomFile file = new DicomFile("test", CreateMetaInfo(), dataset); Assert.AreEqual(originalCharacterSet, file.DataSet[DicomTags.SpecificCharacterSet].ToString()); SetTagCommand cmd = new SetTagCommand(tag, valueToSet); Assert.AreEqual(cmd.CanSaveInUnicode, UnicodeAllowed, "SetTagCommand.CanSaveInUnicode returns an incorrect value"); Assert.IsTrue(cmd.Apply(file), "SetTagCommand.Apply failed"); var filename = string.Format("Test-{0}.dcm", DicomTagDictionary.GetDicomTag(tag).Name); Assert.IsTrue(file.Save(filename), "Unable to save dicom file"); file = new DicomFile(filename); file.Load(); if (valueToSet == null) Assert.AreEqual(string.Empty, file.DataSet[tag].ToString()); else Assert.AreEqual(valueToSet, file.DataSet[tag].ToString()); Assert.IsTrue(file.DataSet[DicomTags.SpecificCharacterSet].ToString().Equals(expectedNewCharacterSet)); Delete(filename); }
public void AssertExceptionThrown(uint tag, string valueToSet, string originalCharacterSet) { DicomAttributeCollection dataset = new DicomAttributeCollection(); SetupDataSet(dataset, originalCharacterSet); DicomFile file = new DicomFile("test", CreateMetaInfo(), dataset); Assert.AreEqual(originalCharacterSet, file.DataSet[DicomTags.SpecificCharacterSet].ToString()); SetTagCommand cmd = new SetTagCommand(tag, valueToSet); try { cmd.Apply(file); Assert.Fail("DicomCharacterSetException is expected"); } catch (DicomCharacterSetException) { // good return; } catch (Exception) { Assert.Fail("DicomCharacterSetException is expected"); } }
public void AssertExceptionThrown(uint tag, string valueToSet, string originalCharacterSet) { DicomAttributeCollection dataset = new DicomAttributeCollection(); SetupDataSet(dataset, originalCharacterSet); DicomFile file = new DicomFile("test", CreateMetaInfo(), dataset); Assert.AreEqual(originalCharacterSet, file.DataSet[DicomTags.SpecificCharacterSet].ToString()); var sq = new OriginalAttributesSequence { ModifiedAttributesSequence = new DicomSequenceItem(), ModifyingSystem = ProductInformation.Component, ReasonForTheAttributeModification = "CORRECT", AttributeModificationDatetime = Platform.Time, SourceOfPreviousValues = file.SourceApplicationEntityTitle }; SetTagCommand cmd = new SetTagCommand(tag, valueToSet); try { cmd.Apply(file, sq); Assert.Fail("DicomCharacterSetException is expected"); } catch (DicomCharacterSetException) { // good return; } catch (Exception) { Assert.Fail("DicomCharacterSetException is expected"); } }
public async Task <NoContentResult> SetTag(string name, [FromBody] SetTagDto setTagDto) { var command = SetTagCommand.Create(name, setTagDto); await _mediator.Send(command); return(NoContent()); }
public Task SetTags(SetTagArgs args) { if (args.IsBadLocateArgs(ClientSpanLocateMode.ForCurrent)) { return(Task.FromResult(0)); } return(_commandQueue.Enqueue(SetTagCommand.Create(args))); }
private void CreateDestinationStudyStorage() { // This really should never happen; if (Context.History.DestStudyStorageKey != null) { _destinationStudyStorage = StudyStorageLocation.FindStorageLocations(StudyStorage.Load(Context.History.DestStudyStorageKey))[0]; return; } string newStudyInstanceUid = string.Empty; // Get the new Study Instance Uid by looking through the update commands foreach (BaseImageLevelUpdateCommand command in Commands) { SetTagCommand setTag = command as SetTagCommand; if (setTag != null && setTag.Tag.TagValue.Equals(DicomTags.StudyInstanceUid)) { newStudyInstanceUid = setTag.Value; break; } } if (string.IsNullOrEmpty(newStudyInstanceUid)) { throw new ApplicationException("Unexpectedly could not find new Study Instance Uid value for Create Study"); } using (ServerCommandProcessor processor = new ServerCommandProcessor("Reconciling image processor")) { // Assign new series and instance uid InitializeStorageCommand command = new InitializeStorageCommand(Context, newStudyInstanceUid, Context.WorkQueueItemStudyStorage.StudyFolder, TransferSyntax.GetTransferSyntax(Context.WorkQueueItemStudyStorage.TransferSyntaxUid)); processor.AddCommand(command); if (!processor.Execute()) { throw new ApplicationException(String.Format("Unable to create Study Storage for study: {0}", newStudyInstanceUid), processor.FailureException); } _destinationStudyStorage = command.Location; } }
public void AssertTagValueChanged(uint tag, string valueToSet, string originalCharacterSet, string expectedNewCharacterSet) { DicomAttributeCollection dataset = new DicomAttributeCollection(); SetupDataSet(dataset, originalCharacterSet); DicomFile file = new DicomFile("test", CreateMetaInfo(), dataset); Assert.AreEqual(originalCharacterSet, file.DataSet[DicomTags.SpecificCharacterSet].ToString()); SetTagCommand cmd = new SetTagCommand(tag, valueToSet); Assert.AreEqual(cmd.CanSaveInUnicode, UnicodeAllowed, "SetTagCommand.CanSaveInUnicode returns an incorrect value"); var sq = new OriginalAttributesSequence { ModifiedAttributesSequence = new DicomSequenceItem(), ModifyingSystem = ProductInformation.Component, ReasonForTheAttributeModification = "CORRECT", AttributeModificationDatetime = Platform.Time, SourceOfPreviousValues = file.SourceApplicationEntityTitle }; Assert.IsTrue(cmd.Apply(file, sq), "SetTagCommand.Apply failed"); var filename = string.Format("Test-{0}.dcm", DicomTagDictionary.GetDicomTag(tag).Name); Assert.IsTrue(file.Save(filename), "Unable to save dicom file"); file = new DicomFile(filename); file.Load(); if (valueToSet == null) { Assert.AreEqual(string.Empty, file.DataSet[tag].ToString()); } else { Assert.AreEqual(valueToSet, file.DataSet[tag].ToString()); } Assert.IsTrue(file.DataSet[DicomTags.SpecificCharacterSet].ToString().Equals(expectedNewCharacterSet)); Delete(filename); }
private bool UpdateNameBasedOnTheStudy(DicomFile file) { bool updated = false; string orginalPatientsNameInFile = file.DataSet[DicomTags.PatientsName].ToString(); if (_theStudy == null) { return(false); } StudyComparer comparer = new StudyComparer(); ServerPartition partition = ServerPartitionMonitor.Instance.FindPartition(_theStudy.ServerPartitionKey); DifferenceCollection list = comparer.Compare(file, _theStudy, partition.GetComparisonOptions()); if (list.Count == 1) { ComparisionDifference different = list[0]; if (different.DicomTag.TagValue == DicomTags.PatientsName) { if (DicomNameUtils.LookLikeSameNames(orginalPatientsNameInFile, _theStudy.PatientsName)) { using (ServerCommandProcessor processor = new ServerCommandProcessor("Update Patient's Name")) { SetTagCommand command = new SetTagCommand(file, DicomTags.PatientsName, orginalPatientsNameInFile, _theStudy.PatientsName); processor.AddCommand(command); if (!processor.Execute()) { throw new ApplicationException(String.Format("AUTO-CORRECTION Failed: Unable to correct the patient's name in the image. Reason: {0}", processor.FailureReason), processor.FailureException); } updated = true; } } } } return(updated); }
public void AssertTagValueChanged(uint tag, string valueToSet, string originalCharacterSet, string expectedNewCharacterSet) { DicomAttributeCollection dataset = new DicomAttributeCollection(); SetupDataSet(dataset, originalCharacterSet); DicomFile file = new DicomFile("test", CreateMetaInfo(), dataset); Assert.AreEqual(originalCharacterSet, file.DataSet[DicomTags.SpecificCharacterSet].ToString()); SetTagCommand cmd = new SetTagCommand(tag, valueToSet); Assert.AreEqual(cmd.CanSaveInUnicode, UnicodeAllowed, "SetTagCommand.CanSaveInUnicode returns an incorrect value"); var sq = new OriginalAttributesSequence { ModifiedAttributesSequence = new DicomSequenceItem(), ModifyingSystem = ProductInformation.Component, ReasonForTheAttributeModification = "CORRECT", AttributeModificationDatetime = Platform.Time, SourceOfPreviousValues = file.SourceApplicationEntityTitle }; Assert.IsTrue(cmd.Apply(file, sq), "SetTagCommand.Apply failed"); var filename = string.Format("Test-{0}.dcm", DicomTagDictionary.GetDicomTag(tag).Name); Assert.IsTrue(file.Save(filename), "Unable to save dicom file"); file = new DicomFile(filename); file.Load(); if (valueToSet == null) Assert.AreEqual(string.Empty, file.DataSet[tag].ToString()); else Assert.AreEqual(valueToSet, file.DataSet[tag].ToString()); Assert.IsTrue(file.DataSet[DicomTags.SpecificCharacterSet].ToString().Equals(expectedNewCharacterSet)); Delete(filename); }
public void AssertExceptionThrown(uint tag, string valueToSet, string originalCharacterSet) { DicomAttributeCollection dataset = new DicomAttributeCollection(); SetupDataSet(dataset, originalCharacterSet); DicomFile file = new DicomFile("test", CreateMetaInfo(), dataset); Assert.AreEqual(originalCharacterSet, file.DataSet[DicomTags.SpecificCharacterSet].ToString()); SetTagCommand cmd = new SetTagCommand(tag, valueToSet); try { cmd.Apply(file); Assert.Fail("DicomCharacterSetException is expected"); } catch(DicomCharacterSetException) { // good return; } catch(Exception) { Assert.Fail("DicomCharacterSetException is expected"); } }
public void AssertExceptionThrown(uint tag, string valueToSet, string originalCharacterSet) { DicomAttributeCollection dataset = new DicomAttributeCollection(); SetupDataSet(dataset, originalCharacterSet); DicomFile file = new DicomFile("test", CreateMetaInfo(), dataset); Assert.AreEqual(originalCharacterSet, file.DataSet[DicomTags.SpecificCharacterSet].ToString()); var sq = new OriginalAttributesSequence { ModifiedAttributesSequence = new DicomSequenceItem(), ModifyingSystem = ProductInformation.Component, ReasonForTheAttributeModification = "CORRECT", AttributeModificationDatetime = Platform.Time, SourceOfPreviousValues = file.SourceApplicationEntityTitle }; SetTagCommand cmd = new SetTagCommand(tag, valueToSet); try { cmd.Apply(file, sq); Assert.Fail("DicomCharacterSetException is expected"); } catch(DicomCharacterSetException) { // good return; } catch(Exception) { Assert.Fail("DicomCharacterSetException is expected"); } }