public void TestListFormatters() { string input = @"The\brown\dog\\jumped"; string result = DicomDataFormatHelper.StringListFormat(DicomStringHelper.GetStringArray(input)); Assert.AreEqual(result, "The,\nbrown,\ndog,\njumped"); input = @"Doe^John^^^"; result = DicomDataFormatHelper.PersonNameFormatter(new PersonName(input)); Assert.AreEqual(result, "Doe, John"); input = @"^John^^^"; result = DicomDataFormatHelper.PersonNameFormatter(new PersonName(input)); Assert.AreEqual(result, "John"); input = @"Doe^^^^"; result = DicomDataFormatHelper.PersonNameFormatter(new PersonName(input)); Assert.AreEqual(result, "Doe"); input = @"Doe^John^^^\Doe^Jane^^^"; result = DicomDataFormatHelper.PersonNameListFormatter(DicomStringHelper.GetPersonNameArray(input)); Assert.AreEqual(result, "Doe, John,\nDoe, Jane"); input = @"^John^^^\Doe^Jane^^^"; result = DicomDataFormatHelper.PersonNameListFormatter(DicomStringHelper.GetPersonNameArray(input)); Assert.AreEqual(result, "John,\nDoe, Jane"); input = @"^John^^^\Doe^^^^"; result = DicomDataFormatHelper.PersonNameListFormatter(DicomStringHelper.GetPersonNameArray(input)); Assert.AreEqual(result, "John,\nDoe"); input = @"^^^^\Doe^^^^"; result = DicomDataFormatHelper.PersonNameListFormatter(DicomStringHelper.GetPersonNameArray(input)); Assert.AreEqual(result, "Doe"); input = @"^^^^\^^^^"; result = DicomDataFormatHelper.PersonNameListFormatter(DicomStringHelper.GetPersonNameArray(input)); Assert.AreEqual(result, ""); }
public ImageBrowserComponent(List <SeriesItem> InputSeriesList, Server node) { server = node; if (node == null) { server = new Server("localdatastore", "local", "localhost", "AE", 0, false, 0, 0); Platform.Log(LogLevel.Info, "null server"); } //this.Host.DesktopWindow.ShowMessageBox("foo", MessageBoxActions.Ok); foreach (SeriesItem item in InputSeriesList) { searchResult.SeriesList.Items.Add(item); //_currentSeriesList.Add } TableColumn <SeriesItem, string> column; column = new TableColumn <SeriesItem, string>( "Series Num", delegate(SeriesItem item) { return(item.SeriesNumber); }, null, 1.5f, //delegate(SeriesItem one, SeriesItem two) { return (int)(double.Parse(one.Time.ToString()) - double.Parse(two.Time.ToString())); } delegate(SeriesItem one, SeriesItem two) { return((int)(double.Parse(one.SeriesNumber.ToString()) - double.Parse(two.SeriesNumber.ToString()))); } ); searchResult.SeriesList.Columns.Add(column); column = new TableColumn <SeriesItem, string>( "Series Description", delegate(SeriesItem item) { return(item.SeriesDescription); }, 1.5f); searchResult.SeriesList.Columns.Add(column); column = new TableColumn <SeriesItem, string>( "Modality", delegate(SeriesItem item) { return(item.Modality); }, 1.5f); searchResult.SeriesList.Columns.Add(column); column = new TableColumn <SeriesItem, string>( "Date", delegate(SeriesItem item) { return(DicomDataFormatHelper.DateFormat(item.Date)); }, 1.5f); searchResult.SeriesList.Columns.Add(column); column = new TableColumn <SeriesItem, string>( "Time", delegate(SeriesItem item) { return(timeformatHMS(item.Time)); }, null, 1.5f, delegate(SeriesItem one, SeriesItem two) { return((int)(double.Parse(one.Time.ToString()) - double.Parse(two.Time.ToString()))); } ); searchResult.SeriesList.Columns.Add(column); }
/// <summary> /// Called by the framework when the user clicks the "apply" menu item or toolbar button. /// </summary> public void SeriesQuery() { string callingAE = ServerTree.GetClientAETitle(); List <SeriesItem> SeriesList = new List <SeriesItem>(); #region remote datastore // If remote data store, need to query server for series level information if (!this.Context.SelectedServerGroup.IsLocalDatastore) { // Loop through all selected servers foreach (Server node in this.Context.SelectedServerGroup.Servers) { DicomAttributeCollection dicomAttributeCollection = new DicomAttributeCollection(); // Query on "Series" Level dicomAttributeCollection[DicomTags.QueryRetrieveLevel].SetStringValue("SERIES"); string studyUID = this.Context.SelectedStudies[0].StudyInstanceUid; dicomAttributeCollection[DicomTags.StudyInstanceUid].SetStringValue(studyUID); dicomAttributeCollection[DicomTags.SeriesDescription].SetNullValue(); dicomAttributeCollection[DicomTags.SeriesInstanceUid].SetNullValue(); dicomAttributeCollection[DicomTags.SeriesNumber].SetNullValue(); dicomAttributeCollection[DicomTags.Modality].SetNullValue(); dicomAttributeCollection[DicomTags.Date].SetNullValue(); dicomAttributeCollection[DicomTags.Time].SetNullValue(); dicomAttributeCollection[DicomTags.RepetitionTime].SetNullValue(); IList <DicomAttributeCollection> resultsList; StudyRootFindScu findScu = new StudyRootFindScu(); List <string> seriesUIDs = new List <string>(); resultsList = findScu.Find( callingAE, node.AETitle, node.Host, node.Port, dicomAttributeCollection); findScu.CloseAssociation(); findScu.Dispose(); foreach (DicomAttributeCollection msg in resultsList) { string text = msg[DicomTags.SeriesInstanceUid]; Platform.Log(LogLevel.Info, text); SeriesItem series = new SeriesItem(); series.SeriesNumber = msg[DicomTags.SeriesNumber]; series.SeriesDescription = msg[DicomTags.SeriesDescription]; series.StudyInstanceUID = msg[DicomTags.StudyInstanceUid]; series.SeriesInstanceUID = msg[DicomTags.SeriesInstanceUid]; series.Modality = msg[DicomTags.Modality]; series.Date = msg[DicomTags.Date]; series.Time = msg[DicomTags.Time]; //series.NumberOfSeriesRelatedInstances = int.Parse(msg[DicomTags.NumberOfSeriesRelatedInstances].ToString()); SeriesList.Add(series); } _component = new SeriesBrowserComponent(SeriesList, node); _shelf = ApplicationComponent.LaunchAsShelf(this.Context.DesktopWindow, _component, "Series Browser", ShelfDisplayHint.DockBottom | ShelfDisplayHint.DockAutoHide); _shelf.Closed += Shelf_Closed; } } #endregion #region Local Datastore // If local datastore, can obtain series information by building study tree else { IImageViewer viewer = new ImageViewerComponent(); StudyTree studyTree = viewer.StudyTree; // Add selected objects studies to study tree foreach (StudyItem selectedstudy in this.Context.SelectedStudies) { string studyUID = selectedstudy.StudyInstanceUid; int numberOfSops = LocalStudyLoader.Start(new StudyLoaderArgs(studyUID, null)); for (int i = 0; i < numberOfSops; ++i) { Sop imageSop = LocalStudyLoader.LoadNextSop(); studyTree.AddSop(imageSop); } } foreach (Patient patient in studyTree.Patients) { foreach (Study study in patient.Studies) { foreach (Series series in study.Series) { SeriesItem seriesitem = new SeriesItem(); seriesitem.SeriesNumber = series.SeriesNumber.ToString(); seriesitem.SeriesDescription = series.SeriesDescription; seriesitem.StudyInstanceUID = study.StudyInstanceUid; seriesitem.SeriesInstanceUID = series.SeriesInstanceUid; seriesitem.Modality = series.Modality; seriesitem.Date = series.SeriesDate; seriesitem.Time = series.SeriesTime; //series.NumberOfSeriesRelatedInstances = int.Parse(msg[DicomTags.NumberOfSeriesRelatedInstances].ToString()); seriesitem.NumberOfSeriesRelatedInstances = series.Sops.Count.ToString(); SeriesList.Add(seriesitem); } _component = new SeriesBrowserComponent(SeriesList, null); _shelf = ApplicationComponent.LaunchAsShelf(this.Context.DesktopWindow, _component, DicomDataFormatHelper.PersonNameFormatter(patient.PatientsName), ShelfDisplayHint.DockBottom | ShelfDisplayHint.DockAutoHide); _shelf.Closed += Shelf_Closed; } } } #endregion }
public PatientStudyAnnotationItemProvider() : base("AnnotationItemProviders.Dicom.PatientStudy", new AnnotationResourceResolver(typeof(PatientStudyAnnotationItemProvider).Assembly)) { _annotationItems = new List <IAnnotationItem>(); AnnotationResourceResolver resolver = new AnnotationResourceResolver(this); _annotationItems.Add ( new DicomAnnotationItem <string> ( "Dicom.PatientStudy.AdditionalPatientsHistory", resolver, delegate(Frame frame) { return(frame.ParentImageSop.AdditionalPatientsHistory); }, DicomDataFormatHelper.RawStringFormat ) ); _annotationItems.Add ( new DicomAnnotationItem <string> ( "Dicom.PatientStudy.Occupation", resolver, FrameDataRetrieverFactory.GetStringRetriever(DicomTags.Occupation), DicomDataFormatHelper.RawStringFormat ) ); _annotationItems.Add ( new DicomAnnotationItem <string> ( "Dicom.PatientStudy.PatientsAge", resolver, FrameDataRetrieverFactory.GetStringRetriever(DicomTags.PatientsAge), DicomDataFormatHelper.RawStringFormat ) ); _annotationItems.Add ( new DicomAnnotationItem <double> ( "Dicom.PatientStudy.PatientsSize", resolver, FrameDataRetrieverFactory.GetDoubleRetriever(DicomTags.PatientsSize), delegate(double input) { if (double.IsNaN(input) || input == 0) { return(""); } return(String.Format(SR.FormatMeters, input.ToString("F2"))); } ) ); _annotationItems.Add ( new DicomAnnotationItem <double> ( "Dicom.PatientStudy.PatientsWeight", resolver, FrameDataRetrieverFactory.GetDoubleRetriever(DicomTags.PatientsWeight), delegate(double input) { if (double.IsNaN(input) || input == 0) { return(""); } return(String.Format(SR.FormatKilograms, input.ToString("F2"))); } ) ); _annotationItems.Add ( new DicomAnnotationItem <string> ( "Dicom.PatientStudy.Composite.PatientsAgeSex", resolver, delegate(Frame frame) { var components = new List <string>(); if (!string.IsNullOrEmpty(frame.ParentImageSop.PatientsAge)) { components.Add(frame.ParentImageSop.PatientsAge); } if (!string.IsNullOrEmpty(frame.ParentImageSop.PatientsSex)) { components.Add(frame.ParentImageSop.PatientsSex); } return(string.Join(SR.SeparatorAgeSexBirthDate, components.ToArray())); }, DicomDataFormatHelper.RawStringFormat ) ); _annotationItems.Add ( new DicomAnnotationItem <string> ( "Dicom.PatientStudy.Composite.PatientsAgeSexBirthDate", resolver, delegate(Frame frame) { var components = new List <string>(); if (!string.IsNullOrEmpty(frame.ParentImageSop.PatientsAge)) { components.Add(frame.ParentImageSop.PatientsAge); } if (!string.IsNullOrEmpty(frame.ParentImageSop.PatientsSex)) { components.Add(frame.ParentImageSop.PatientsSex); } if (!string.IsNullOrEmpty(frame.ParentImageSop.PatientsBirthDate)) { components.Add(DicomDataFormatHelper.DateFormat(frame.ParentImageSop.PatientsBirthDate)); } return(string.Join(SR.SeparatorAgeSexBirthDate, components.ToArray())); }, DicomDataFormatHelper.RawStringFormat ) ); }
/// <summary> /// Called by the framework when the user clicks the "apply" menu item or toolbar button. /// </summary> public void Apply() { List <string> seriesUIDs = new List <string>(); List <string> studyUIDs = new List <string>(); foreach (SeriesItem item in this.Context.SelectedMultipleSeries) { string foo = item.SeriesInstanceUID; Platform.Log(LogLevel.Info, foo); seriesUIDs.Add(item.SeriesInstanceUID); studyUIDs.Add(item.StudyInstanceUID); } // Code for local data store only (tool should be disabled for remote devices IImageViewer viewer = new ImageViewerComponent(); StudyTree studyTree = viewer.StudyTree; List <SeriesItem> imageList = new List <SeriesItem>(); // Add selected objects studies to study tree foreach (SeriesItem selectedseries in this.Context.SelectedMultipleSeries) { string studyUID = selectedseries.StudyInstanceUID; int numberOfSops = LocalStudyLoader.Start(new StudyLoaderArgs(studyUID, null)); for (int i = 0; i < numberOfSops; ++i) { Sop imageSop = LocalStudyLoader.LoadNextSop(); studyTree.AddSop(imageSop); } } foreach (Patient patient in studyTree.Patients) { foreach (Study study in patient.Studies) { string description = ""; foreach (Series series in study.Series) { string saveseries = seriesUIDs.Find(delegate(string s) { return(s.Equals(series.SeriesInstanceUid)); }); if (saveseries != null) { foreach (Sop sop in series.Sops) { SeriesItem image = new SeriesItem(); DicomFile file = ((ILocalSopDataSource)sop.DataSource).File; StudyData originalData = new StudyData(); file.DataSet.LoadDicomFields(originalData); image.Time = file.DataSet[DicomTags.TriggerTime]; image.SeriesDescription = file.DataSet[DicomTags.SeriesDescription]; image.Modality = file.DataSet[DicomTags.Modality]; image.SeriesNumber = sop.InstanceNumber.ToString(); image.Date = file.DataSet[DicomTags.StudyDate]; imageList.Add(image); description = image.SeriesDescription; } } } _component = new ImageBrowserComponent(imageList, null); _image_shelf = ApplicationComponent.LaunchAsShelf(this.Context.DesktopWindow, _component, DicomDataFormatHelper.PersonNameFormatter(patient.PatientsName) + ": " + description, ShelfDisplayHint.DockBottom | ShelfDisplayHint.DockAutoHide); _image_shelf.Closed += Image_Shelf_Closed; } } }