├── .gitmodules
├── PacsExplorer
├── App.xaml.cs
├── Converters
│ ├── NotNullToBooleanConverter.cs
│ └── DateConverter.cs
├── DicomSeriesQuery.cs
├── DicomSeries.cs
├── PacsExplorer.csproj
├── DicomStudyQuery.cs
├── ConfigWindow.xaml.cs
├── Settings.settings
├── App.xaml
├── App.config
├── DicomStudy.cs
├── MainWindow.xaml
├── ConfigWindow.xaml
├── Settings.Designer.cs
└── MainWindow.xaml.cs
├── .github
└── workflows
│ └── dotnet.yml
├── README.md
├── PacsExplorer.sln
├── .gitattributes
└── .gitignore
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "DicomScu"]
2 | path = DicomScu
3 | url = https://github.com/iberisoft/DicomScu.git
4 |
--------------------------------------------------------------------------------
/PacsExplorer/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace PacsExplorer
4 | {
5 | ///
6 | /// Interaction logic for App.xaml
7 | ///
8 | public partial class App : Application
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/.github/workflows/dotnet.yml:
--------------------------------------------------------------------------------
1 | name: .NET
2 |
3 | on: [push]
4 |
5 | jobs:
6 | build:
7 |
8 | runs-on: windows-latest
9 |
10 | steps:
11 | - uses: actions/checkout@v2
12 | with:
13 | submodules: true
14 | - name: Build
15 | run: dotnet build PacsExplorer.sln
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PACS Explorer
2 |
3 | [](https://github.com/iberisoft/PacsExplorer/actions/workflows/dotnet.yml)
4 |
5 | A window implementing DICOM store and query/retrieve SCU.
6 |
7 | The tool can upload DICOM files onto a PACS as well as query/retrieve them. If you install [MicroDicom Viewer](https://www.microdicom.com/)
8 | the tool will view retrieved images in MicroDicom.
9 |
--------------------------------------------------------------------------------
/PacsExplorer/Converters/NotNullToBooleanConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace PacsExplorer.Converters
6 | {
7 | class NotNullToBooleanConverter : IValueConverter
8 | {
9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => value != null;
10 |
11 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/PacsExplorer/Converters/DateConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace PacsExplorer.Converters
6 | {
7 | class DateConverter : IValueConverter
8 | {
9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => System.Convert.ToDateTime(value).ToShortDateString();
10 |
11 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/PacsExplorer/DicomSeriesQuery.cs:
--------------------------------------------------------------------------------
1 | using Dicom;
2 | using DicomScu;
3 |
4 | namespace PacsExplorer
5 | {
6 | public class DicomSeriesQuery : IDicomQuery
7 | {
8 | public string Modality { get; set; } = "";
9 |
10 | public string Number { get; set; } = "";
11 |
12 | public string Description { get; set; } = "";
13 |
14 | public void CopyTo(DicomDataset dataset)
15 | {
16 | dataset.AddOrUpdate(DicomTag.Modality, Modality);
17 | dataset.AddOrUpdate(DicomTag.SeriesNumber, Number);
18 | dataset.AddOrUpdate(DicomTag.SeriesDescription, Description);
19 | dataset.AddOrUpdate(DicomTag.NumberOfSeriesRelatedInstances, "");
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/PacsExplorer/DicomSeries.cs:
--------------------------------------------------------------------------------
1 | using Dicom;
2 |
3 | namespace PacsExplorer
4 | {
5 | class DicomSeries
6 | {
7 | public DicomSeries(DicomDataset dataset)
8 | {
9 | Modality = dataset.GetSingleValueOrDefault(DicomTag.Modality, "");
10 | Number = dataset.GetSingleValueOrDefault(DicomTag.SeriesNumber, "");
11 | Description = dataset.GetSingleValueOrDefault(DicomTag.SeriesDescription, "");
12 | Uid = dataset.GetSingleValueOrDefault(DicomTag.SeriesInstanceUID, "");
13 | if (dataset.TryGetSingleValue(DicomTag.NumberOfSeriesRelatedInstances, out int instanceCount))
14 | {
15 | InstanceCount = instanceCount;
16 | }
17 | }
18 |
19 | public string Modality { get; }
20 |
21 | public string Number { get; set; }
22 |
23 | public string Description { get; }
24 |
25 | public string Uid { get; }
26 |
27 | public int? InstanceCount { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/PacsExplorer/PacsExplorer.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net472
6 | true
7 | Pavel Zaytsev
8 | PACS Explorer.
9 | Copyright © 2024
10 | 1.3.3
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | True
25 | True
26 | Settings.settings
27 |
28 |
29 |
30 |
31 |
32 | SettingsSingleFileGenerator
33 | Settings.Designer.cs
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/PacsExplorer/DicomStudyQuery.cs:
--------------------------------------------------------------------------------
1 | using Dicom;
2 | using DicomScu;
3 | using System;
4 |
5 | namespace PacsExplorer
6 | {
7 | public class DicomStudyQuery : IDicomQuery
8 | {
9 | public string PatientName { get; set; } = "";
10 |
11 | public string PatientId { get; set; } = "";
12 |
13 | public string AccessionNumber { get; set; } = "";
14 |
15 | public string Modality { get; set; } = "";
16 |
17 | public DateTime StartDate { get; set; } = DateTime.Today.AddYears(-1);
18 |
19 | public DateTime EndDate { get; set; } = DateTime.Today;
20 |
21 | public string Description { get; set; } = "";
22 |
23 | public void CopyTo(DicomDataset dataset)
24 | {
25 | dataset.AddOrUpdate(DicomTag.PatientName, PatientName);
26 | dataset.AddOrUpdate(DicomTag.PatientID, PatientId);
27 | dataset.AddOrUpdate(DicomTag.AccessionNumber, AccessionNumber);
28 | dataset.AddOrUpdate(DicomTag.ModalitiesInStudy, Modality);
29 | dataset.AddOrUpdate(DicomTag.StudyDate, new DicomDateRange(StartDate, EndDate));
30 | dataset.AddOrUpdate(DicomTag.StudyDescription, Description);
31 | dataset.AddOrUpdate(DicomTag.NumberOfStudyRelatedInstances, "");
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/PacsExplorer/ConfigWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using Xceed.Wpf.Toolkit;
5 |
6 | namespace PacsExplorer
7 | {
8 | ///
9 | /// Interaction logic for ConfigWindow.xaml
10 | ///
11 | public partial class ConfigWindow : Window
12 | {
13 | public ConfigWindow()
14 | {
15 | InitializeComponent();
16 | }
17 |
18 | private void Submit(object sender, RoutedEventArgs e)
19 | {
20 | DialogResult = true;
21 | }
22 |
23 | private void Window_Closed(object sender, EventArgs e)
24 | {
25 | if (DialogResult == true)
26 | {
27 | ServerHost.GetBindingExpression(TextBox.TextProperty).UpdateSource();
28 | QrServerAeTitle.GetBindingExpression(TextBox.TextProperty).UpdateSource();
29 | QrServerPort.GetBindingExpression(IntegerUpDown.ValueProperty).UpdateSource();
30 | StoreServerAeTitle.GetBindingExpression(TextBox.TextProperty).UpdateSource();
31 | StoreServerPort.GetBindingExpression(IntegerUpDown.ValueProperty).UpdateSource();
32 | ClientAeTitle.GetBindingExpression(TextBox.TextProperty).UpdateSource();
33 | ClientPort.GetBindingExpression(IntegerUpDown.ValueProperty).UpdateSource();
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/PacsExplorer/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | localhost
7 |
8 |
9 | SERVER
10 |
11 |
12 | 106
13 |
14 |
15 | SERVER
16 |
17 |
18 | 104
19 |
20 |
21 | CLIENT
22 |
23 |
24 | 1000
25 |
26 |
27 | C:\Program Files\MicroDicom\mDicom.exe
28 |
29 |
30 |
--------------------------------------------------------------------------------
/PacsExplorer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29613.14
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PacsExplorer", "PacsExplorer\PacsExplorer.csproj", "{1B2A83C5-7E69-4D2F-B754-D4CEA20E6501}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DicomScu", "DicomScu\DicomScu\DicomScu.csproj", "{9A70DDB2-3D1C-4D2B-908E-894F5C005011}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {1B2A83C5-7E69-4D2F-B754-D4CEA20E6501}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {1B2A83C5-7E69-4D2F-B754-D4CEA20E6501}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {1B2A83C5-7E69-4D2F-B754-D4CEA20E6501}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {1B2A83C5-7E69-4D2F-B754-D4CEA20E6501}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {9A70DDB2-3D1C-4D2B-908E-894F5C005011}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {9A70DDB2-3D1C-4D2B-908E-894F5C005011}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {9A70DDB2-3D1C-4D2B-908E-894F5C005011}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {9A70DDB2-3D1C-4D2B-908E-894F5C005011}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {4E96D08B-2BDC-45A2-B63C-DD2156680502}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/PacsExplorer/App.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
14 |
18 |
21 |
24 |
27 |
30 |
33 |
36 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/PacsExplorer/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | C:\Program Files\MicroDicom\mDicom.exe
18 |
19 |
20 |
21 |
22 |
23 |
24 | localhost
25 |
26 |
27 | SERVER
28 |
29 |
30 | 106
31 |
32 |
33 | SERVER
34 |
35 |
36 | 104
37 |
38 |
39 | CLIENT
40 |
41 |
42 | 1000
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/PacsExplorer/DicomStudy.cs:
--------------------------------------------------------------------------------
1 | using Dicom;
2 | using System;
3 | using System.IO;
4 |
5 | namespace PacsExplorer
6 | {
7 | class DicomStudy
8 | {
9 | public DicomStudy(DicomDataset dataset)
10 | {
11 | PatientName = dataset.GetSingleValueOrDefault(DicomTag.PatientName, "");
12 | PatientId = dataset.GetSingleValueOrDefault(DicomTag.PatientID, "");
13 | AccessionNumber = dataset.GetSingleValueOrDefault(DicomTag.AccessionNumber, "");
14 | Modality = dataset.GetSingleValueOrDefault(DicomTag.ModalitiesInStudy, "");
15 | if (dataset.TryGetSingleValue(DicomTag.StudyDate, out DateTime date))
16 | {
17 | Date = date;
18 | }
19 | Description = dataset.GetSingleValueOrDefault(DicomTag.StudyDescription, "");
20 | Uid = dataset.GetSingleValueOrDefault(DicomTag.StudyInstanceUID, "");
21 | if (dataset.TryGetSingleValue(DicomTag.NumberOfStudyRelatedInstances, out int instanceCount))
22 | {
23 | InstanceCount = instanceCount;
24 | }
25 | }
26 |
27 | public DicomFile CreateEncapsulatedPdf(string filePath)
28 | {
29 | var dataset = new DicomDataset();
30 |
31 | dataset.AddOrUpdate(DicomTag.PatientName, PatientName);
32 | dataset.AddOrUpdate(DicomTag.PatientID, PatientId);
33 | dataset.AddOrUpdate(DicomTag.AccessionNumber, AccessionNumber);
34 | if (Date != null)
35 | {
36 | dataset.AddOrUpdate(DicomTag.StudyDate, Date.Value);
37 | }
38 | dataset.AddOrUpdate(DicomTag.StudyDescription, Description);
39 | dataset.AddOrUpdate(DicomTag.StudyInstanceUID, Uid);
40 |
41 | dataset.AddOrUpdate(DicomTag.Modality, "DOC");
42 | dataset.AddOrUpdate(DicomTag.ConversionType, "WSD");
43 | dataset.AddOrUpdate(DicomTag.SeriesInstanceUID, DicomUID.Generate());
44 | dataset.AddOrUpdate(DicomTag.SOPClassUID, DicomUID.EncapsulatedPDFStorage);
45 | dataset.AddOrUpdate(DicomTag.SOPInstanceUID, DicomUID.Generate());
46 |
47 | dataset.AddOrUpdate(DicomTag.DocumentTitle, Path.GetFileNameWithoutExtension(filePath));
48 | dataset.AddOrUpdate(DicomTag.MIMETypeOfEncapsulatedDocument, "application/pdf");
49 | dataset.AddOrUpdate(DicomTag.EncapsulatedDocument, File.ReadAllBytes(filePath));
50 |
51 | return new DicomFile(dataset);
52 | }
53 |
54 | public string PatientName { get; }
55 |
56 | public string PatientId { get; }
57 |
58 | public string AccessionNumber { get; }
59 |
60 | public string Modality { get; }
61 |
62 | public DateTime? Date { get; }
63 |
64 | public string Description { get; }
65 |
66 | public string Uid { get; }
67 |
68 | public int? InstanceCount { get; set; }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/PacsExplorer/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
65 |
66 |
67 |
68 |
69 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/PacsExplorer/ConfigWindow.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/PacsExplorer/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace PacsExplorer {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.8.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 |
26 | [global::System.Configuration.UserScopedSettingAttribute()]
27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
28 | [global::System.Configuration.DefaultSettingValueAttribute("localhost")]
29 | public string ServerHost {
30 | get {
31 | return ((string)(this["ServerHost"]));
32 | }
33 | set {
34 | this["ServerHost"] = value;
35 | }
36 | }
37 |
38 | [global::System.Configuration.UserScopedSettingAttribute()]
39 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
40 | [global::System.Configuration.DefaultSettingValueAttribute("SERVER")]
41 | public string QrServerAeTitle {
42 | get {
43 | return ((string)(this["QrServerAeTitle"]));
44 | }
45 | set {
46 | this["QrServerAeTitle"] = value;
47 | }
48 | }
49 |
50 | [global::System.Configuration.UserScopedSettingAttribute()]
51 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
52 | [global::System.Configuration.DefaultSettingValueAttribute("106")]
53 | public int QrServerPort {
54 | get {
55 | return ((int)(this["QrServerPort"]));
56 | }
57 | set {
58 | this["QrServerPort"] = value;
59 | }
60 | }
61 |
62 | [global::System.Configuration.UserScopedSettingAttribute()]
63 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
64 | [global::System.Configuration.DefaultSettingValueAttribute("SERVER")]
65 | public string StoreServerAeTitle {
66 | get {
67 | return ((string)(this["StoreServerAeTitle"]));
68 | }
69 | set {
70 | this["StoreServerAeTitle"] = value;
71 | }
72 | }
73 |
74 | [global::System.Configuration.UserScopedSettingAttribute()]
75 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
76 | [global::System.Configuration.DefaultSettingValueAttribute("104")]
77 | public int StoreServerPort {
78 | get {
79 | return ((int)(this["StoreServerPort"]));
80 | }
81 | set {
82 | this["StoreServerPort"] = value;
83 | }
84 | }
85 |
86 | [global::System.Configuration.UserScopedSettingAttribute()]
87 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
88 | [global::System.Configuration.DefaultSettingValueAttribute("CLIENT")]
89 | public string ClientAeTitle {
90 | get {
91 | return ((string)(this["ClientAeTitle"]));
92 | }
93 | set {
94 | this["ClientAeTitle"] = value;
95 | }
96 | }
97 |
98 | [global::System.Configuration.UserScopedSettingAttribute()]
99 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
100 | [global::System.Configuration.DefaultSettingValueAttribute("1000")]
101 | public int ClientPort {
102 | get {
103 | return ((int)(this["ClientPort"]));
104 | }
105 | set {
106 | this["ClientPort"] = value;
107 | }
108 | }
109 |
110 | [global::System.Configuration.ApplicationScopedSettingAttribute()]
111 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
112 | [global::System.Configuration.DefaultSettingValueAttribute("C:\\Program Files\\MicroDicom\\mDicom.exe")]
113 | public string ImageViewerPath {
114 | get {
115 | return ((string)(this["ImageViewerPath"]));
116 | }
117 | }
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Dd]ebugPublic/
19 | [Rr]elease/
20 | [Rr]eleases/
21 | x64/
22 | x86/
23 | [Aa][Rr][Mm]/
24 | [Aa][Rr][Mm]64/
25 | bld/
26 | [Bb]in/
27 | [Oo]bj/
28 | [Ll]og/
29 |
30 | # Visual Studio 2015/2017 cache/options directory
31 | .vs/
32 | # Uncomment if you have tasks that create the project's static files in wwwroot
33 | #wwwroot/
34 |
35 | # Visual Studio 2017 auto generated files
36 | Generated\ Files/
37 |
38 | # MSTest test Results
39 | [Tt]est[Rr]esult*/
40 | [Bb]uild[Ll]og.*
41 |
42 | # NUNIT
43 | *.VisualState.xml
44 | TestResult.xml
45 |
46 | # Build Results of an ATL Project
47 | [Dd]ebugPS/
48 | [Rr]eleasePS/
49 | dlldata.c
50 |
51 | # Benchmark Results
52 | BenchmarkDotNet.Artifacts/
53 |
54 | # .NET Core
55 | project.lock.json
56 | project.fragment.lock.json
57 | artifacts/
58 |
59 | # StyleCop
60 | StyleCopReport.xml
61 |
62 | # Files built by Visual Studio
63 | *_i.c
64 | *_p.c
65 | *_h.h
66 | *.ilk
67 | *.meta
68 | *.obj
69 | *.iobj
70 | *.pch
71 | *.pdb
72 | *.ipdb
73 | *.pgc
74 | *.pgd
75 | *.rsp
76 | *.sbr
77 | *.tlb
78 | *.tli
79 | *.tlh
80 | *.tmp
81 | *.tmp_proj
82 | *_wpftmp.csproj
83 | *.log
84 | *.vspscc
85 | *.vssscc
86 | .builds
87 | *.pidb
88 | *.svclog
89 | *.scc
90 |
91 | # Chutzpah Test files
92 | _Chutzpah*
93 |
94 | # Visual C++ cache files
95 | ipch/
96 | *.aps
97 | *.ncb
98 | *.opendb
99 | *.opensdf
100 | *.sdf
101 | *.cachefile
102 | *.VC.db
103 | *.VC.VC.opendb
104 |
105 | # Visual Studio profiler
106 | *.psess
107 | *.vsp
108 | *.vspx
109 | *.sap
110 |
111 | # Visual Studio Trace Files
112 | *.e2e
113 |
114 | # TFS 2012 Local Workspace
115 | $tf/
116 |
117 | # Guidance Automation Toolkit
118 | *.gpState
119 |
120 | # ReSharper is a .NET coding add-in
121 | _ReSharper*/
122 | *.[Rr]e[Ss]harper
123 | *.DotSettings.user
124 |
125 | # JustCode is a .NET coding add-in
126 | .JustCode
127 |
128 | # TeamCity is a build add-in
129 | _TeamCity*
130 |
131 | # DotCover is a Code Coverage Tool
132 | *.dotCover
133 |
134 | # AxoCover is a Code Coverage Tool
135 | .axoCover/*
136 | !.axoCover/settings.json
137 |
138 | # Visual Studio code coverage results
139 | *.coverage
140 | *.coveragexml
141 |
142 | # NCrunch
143 | _NCrunch_*
144 | .*crunch*.local.xml
145 | nCrunchTemp_*
146 |
147 | # MightyMoose
148 | *.mm.*
149 | AutoTest.Net/
150 |
151 | # Web workbench (sass)
152 | .sass-cache/
153 |
154 | # Installshield output folder
155 | [Ee]xpress/
156 |
157 | # DocProject is a documentation generator add-in
158 | DocProject/buildhelp/
159 | DocProject/Help/*.HxT
160 | DocProject/Help/*.HxC
161 | DocProject/Help/*.hhc
162 | DocProject/Help/*.hhk
163 | DocProject/Help/*.hhp
164 | DocProject/Help/Html2
165 | DocProject/Help/html
166 |
167 | # Click-Once directory
168 | publish/
169 |
170 | # Publish Web Output
171 | *.[Pp]ublish.xml
172 | *.azurePubxml
173 | # Note: Comment the next line if you want to checkin your web deploy settings,
174 | # but database connection strings (with potential passwords) will be unencrypted
175 | *.pubxml
176 | *.publishproj
177 |
178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
179 | # checkin your Azure Web App publish settings, but sensitive information contained
180 | # in these scripts will be unencrypted
181 | PublishScripts/
182 |
183 | # NuGet Packages
184 | *.nupkg
185 | # The packages folder can be ignored because of Package Restore
186 | **/[Pp]ackages/*
187 | # except build/, which is used as an MSBuild target.
188 | !**/[Pp]ackages/build/
189 | # Uncomment if necessary however generally it will be regenerated when needed
190 | #!**/[Pp]ackages/repositories.config
191 | # NuGet v3's project.json files produces more ignorable files
192 | *.nuget.props
193 | *.nuget.targets
194 |
195 | # Microsoft Azure Build Output
196 | csx/
197 | *.build.csdef
198 |
199 | # Microsoft Azure Emulator
200 | ecf/
201 | rcf/
202 |
203 | # Windows Store app package directories and files
204 | AppPackages/
205 | BundleArtifacts/
206 | Package.StoreAssociation.xml
207 | _pkginfo.txt
208 | *.appx
209 |
210 | # Visual Studio cache files
211 | # files ending in .cache can be ignored
212 | *.[Cc]ache
213 | # but keep track of directories ending in .cache
214 | !?*.[Cc]ache/
215 |
216 | # Others
217 | ClientBin/
218 | ~$*
219 | *~
220 | *.dbmdl
221 | *.dbproj.schemaview
222 | *.jfm
223 | *.pfx
224 | *.publishsettings
225 | orleans.codegen.cs
226 |
227 | # Including strong name files can present a security risk
228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
229 | #*.snk
230 |
231 | # Since there are multiple workflows, uncomment next line to ignore bower_components
232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
233 | #bower_components/
234 |
235 | # RIA/Silverlight projects
236 | Generated_Code/
237 |
238 | # Backup & report files from converting an old project file
239 | # to a newer Visual Studio version. Backup files are not needed,
240 | # because we have git ;-)
241 | _UpgradeReport_Files/
242 | Backup*/
243 | UpgradeLog*.XML
244 | UpgradeLog*.htm
245 | ServiceFabricBackup/
246 | *.rptproj.bak
247 |
248 | # SQL Server files
249 | *.mdf
250 | *.ldf
251 | *.ndf
252 |
253 | # Business Intelligence projects
254 | *.rdl.data
255 | *.bim.layout
256 | *.bim_*.settings
257 | *.rptproj.rsuser
258 | *- Backup*.rdl
259 |
260 | # Microsoft Fakes
261 | FakesAssemblies/
262 |
263 | # GhostDoc plugin setting file
264 | *.GhostDoc.xml
265 |
266 | # Node.js Tools for Visual Studio
267 | .ntvs_analysis.dat
268 | node_modules/
269 |
270 | # Visual Studio 6 build log
271 | *.plg
272 |
273 | # Visual Studio 6 workspace options file
274 | *.opt
275 |
276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
277 | *.vbw
278 |
279 | # Visual Studio LightSwitch build output
280 | **/*.HTMLClient/GeneratedArtifacts
281 | **/*.DesktopClient/GeneratedArtifacts
282 | **/*.DesktopClient/ModelManifest.xml
283 | **/*.Server/GeneratedArtifacts
284 | **/*.Server/ModelManifest.xml
285 | _Pvt_Extensions
286 |
287 | # Paket dependency manager
288 | .paket/paket.exe
289 | paket-files/
290 |
291 | # FAKE - F# Make
292 | .fake/
293 |
294 | # JetBrains Rider
295 | .idea/
296 | *.sln.iml
297 |
298 | # CodeRush personal settings
299 | .cr/personal
300 |
301 | # Python Tools for Visual Studio (PTVS)
302 | __pycache__/
303 | *.pyc
304 |
305 | # Cake - Uncomment if you are using it
306 | # tools/**
307 | # !tools/packages.config
308 |
309 | # Tabs Studio
310 | *.tss
311 |
312 | # Telerik's JustMock configuration file
313 | *.jmconfig
314 |
315 | # BizTalk build output
316 | *.btp.cs
317 | *.btm.cs
318 | *.odx.cs
319 | *.xsd.cs
320 |
321 | # OpenCover UI analysis results
322 | OpenCover/
323 |
324 | # Azure Stream Analytics local run output
325 | ASALocalRun/
326 |
327 | # MSBuild Binary and Structured Log
328 | *.binlog
329 |
330 | # NVidia Nsight GPU debugger configuration file
331 | *.nvuser
332 |
333 | # MFractors (Xamarin productivity tool) working folder
334 | .mfractor/
335 |
336 | # Local History for Visual Studio
337 | .localhistory/
338 |
339 | # BeatPulse healthcheck temp database
340 | healthchecksdb
--------------------------------------------------------------------------------
/PacsExplorer/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using Dicom;
2 | using DicomScu;
3 | using Microsoft.Win32;
4 | using PacsExplorer.Converters;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Diagnostics;
8 | using System.IO;
9 | using System.Linq;
10 | using System.Threading.Tasks;
11 | using System.Windows;
12 | using System.Windows.Controls;
13 | using System.Windows.Controls.Primitives;
14 | using System.Windows.Data;
15 | using System.Windows.Input;
16 |
17 | namespace PacsExplorer
18 | {
19 | ///
20 | /// Interaction logic for MainWindow.xaml
21 | ///
22 | public partial class MainWindow : Window
23 | {
24 | readonly Settings m_Settings = Settings.Default;
25 |
26 | public MainWindow()
27 | {
28 | InitializeComponent();
29 |
30 | StoragePath = Path.Combine(Path.GetTempPath(), nameof(PacsExplorer));
31 | Directory.CreateDirectory(StoragePath);
32 |
33 | DataContext = this;
34 | }
35 |
36 | public DicomStudyQuery StudyQuery { get; set; } = new DicomStudyQuery();
37 |
38 | public DicomSeriesQuery SeriesQuery { get; set; } = new DicomSeriesQuery();
39 |
40 | public string StoragePath { get; }
41 |
42 | private void Studies_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
43 | {
44 | if (e.PropertyName == nameof(DicomStudy.Date))
45 | {
46 | var column = (DataGridBoundColumn)e.Column;
47 | var binding = (Binding)column.Binding;
48 | binding.Converter = new DateConverter();
49 | }
50 | }
51 |
52 | DicomQrClient m_DicomQrClient;
53 | DicomStoreClient m_DicomStoreClient;
54 |
55 | private void CreateDicomQrClient()
56 | {
57 | if (m_DicomQrClient == null)
58 | {
59 | m_DicomQrClient = new DicomQrClient(m_Settings.ServerHost, m_Settings.QrServerPort, m_Settings.QrServerAeTitle, m_Settings.ClientAeTitle);
60 | }
61 | }
62 |
63 | private void CreateDicomStoreClient()
64 | {
65 | if (m_DicomStoreClient == null)
66 | {
67 | m_DicomStoreClient = new DicomStoreClient(m_Settings.ServerHost, m_Settings.StoreServerPort, m_Settings.StoreServerAeTitle, m_Settings.ClientAeTitle);
68 | }
69 | }
70 |
71 | private void OpenVerifyMenu(object sender, RoutedEventArgs e)
72 | {
73 | var menu = (ContextMenu)FindResource("VerifyMenu");
74 | menu.PlacementTarget = (Button)sender;
75 | menu.Placement = PlacementMode.Bottom;
76 | menu.IsOpen = true;
77 | }
78 |
79 | private async void VerifyQrServer(object sender, RoutedEventArgs e)
80 | {
81 | CreateDicomQrClient();
82 | var success = await DoWork(async () =>
83 | {
84 | await m_DicomQrClient.VerifyAsync();
85 | }, true);
86 | if (success)
87 | {
88 | MessageBox.Show("The server is running.", Title, MessageBoxButton.OK, MessageBoxImage.Information);
89 | }
90 | }
91 |
92 | private async void VerifyStoreServer(object sender, RoutedEventArgs e)
93 | {
94 | CreateDicomStoreClient();
95 | var success = await DoWork(async () =>
96 | {
97 | await m_DicomStoreClient.VerifyAsync();
98 | }, true);
99 | if (success)
100 | {
101 | MessageBox.Show("The server is running.", Title, MessageBoxButton.OK, MessageBoxImage.Information);
102 | }
103 | }
104 |
105 | private async void FindStudies(object sender, RoutedEventArgs e)
106 | {
107 | var button = (Button)sender;
108 | button.Focus();
109 |
110 | CreateDicomQrClient();
111 | await DoWork(async () =>
112 | {
113 | var request = DicomQrClient.CreateStudyQueryRequest(StudyQuery);
114 | var datasets = await m_DicomQrClient.QueryAsync(request);
115 | Studies.ItemsSource = datasets.Select(dataset => new DicomStudy(dataset)).OrderByDescending(study => study.Date);
116 | });
117 | }
118 |
119 | private async void Studies_SelectionChanged(object sender, SelectionChangedEventArgs e)
120 | {
121 | var study = (DicomStudy)Studies.SelectedItem;
122 | if (study == null)
123 | {
124 | Series.ItemsSource = null;
125 | return;
126 | }
127 |
128 | CreateDicomQrClient();
129 | await DoWork(async () =>
130 | {
131 | var request = DicomQrClient.CreateSeriesQueryRequest(study.Uid, SeriesQuery);
132 | var datasets = await m_DicomQrClient.QueryAsync(request);
133 | Series.ItemsSource = datasets.Select(dataset => new DicomSeries(dataset)).OrderBy(series => series.Number);
134 | });
135 | }
136 |
137 | private async void UploadFiles(object sender, RoutedEventArgs e)
138 | {
139 | var dialog = new OpenFileDialog
140 | {
141 | Multiselect = true
142 | };
143 | if (dialog.ShowDialog() == true)
144 | {
145 | await UploadFiles(dialog.FileNames.Select(filePath => DicomFile.Open(filePath)));
146 | }
147 | }
148 |
149 | private async void UploadPdfFiles(object sender, RoutedEventArgs e)
150 | {
151 | var dialog = new OpenFileDialog
152 | {
153 | Multiselect = true,
154 | Filter = "*.pdf|*.pdf"
155 | };
156 | if (dialog.ShowDialog() == true)
157 | {
158 | var study = (DicomStudy)Studies.SelectedItem;
159 | await UploadFiles(dialog.FileNames.Select(filePath => study.CreateEncapsulatedPdf(filePath)));
160 | }
161 | }
162 |
163 | private async Task UploadFiles(IEnumerable files)
164 | {
165 | CreateDicomStoreClient();
166 | await DoWork(async () =>
167 | {
168 | await m_DicomStoreClient.StoreAsync(files);
169 | }, true);
170 |
171 | CreateDicomQrClient();
172 | await DoWork(async () =>
173 | {
174 | var request = DicomQrClient.CreateStudyQueryRequest(StudyQuery);
175 | var datasets = await m_DicomQrClient.QueryAsync(request);
176 | Studies.ItemsSource = datasets.Select(dataset => new DicomStudy(dataset)).OrderByDescending(study => study.Date);
177 | });
178 | }
179 |
180 | private async void OpenStudy(object sender, RoutedEventArgs e)
181 | {
182 | await OpenStudy();
183 | }
184 |
185 | private async Task OpenStudy()
186 | {
187 | var study = (DicomStudy)Studies.SelectedItem;
188 | RetrievingProgress.Value = 0;
189 | RetrievingProgress.Maximum = study.InstanceCount ?? 0;
190 |
191 | await DoWork(async () =>
192 | {
193 | DeleteFolder(study);
194 | if (CGetOption.IsChecked == true)
195 | {
196 | var request = DicomQrClient.CreateStudyGetRequest(study.Uid);
197 | await m_DicomQrClient.RetrieveAsync(request, Save);
198 | }
199 | else
200 | {
201 | var request = DicomQrClient.CreateStudyMoveRequest(study.Uid, m_Settings.ClientAeTitle);
202 | await m_DicomQrClient.RetrieveAsync(request, Save, m_Settings.ClientPort);
203 | }
204 | OpenFolder(study);
205 | });
206 | }
207 |
208 | private async void OpenSeries(object sender, RoutedEventArgs e)
209 | {
210 | await OpenSeries();
211 | }
212 |
213 | private async Task OpenSeries()
214 | {
215 | var study = (DicomStudy)Studies.SelectedItem;
216 | var series = (DicomSeries)Series.SelectedItem;
217 | RetrievingProgress.Value = 0;
218 | RetrievingProgress.Maximum = series.InstanceCount ?? 0;
219 |
220 | await DoWork(async () =>
221 | {
222 | DeleteFolder(study);
223 | if (CGetOption.IsChecked == true)
224 | {
225 | var request = DicomQrClient.CreateSeriesGetRequest(study.Uid, series.Uid);
226 | await m_DicomQrClient.RetrieveAsync(request, Save);
227 | }
228 | else
229 | {
230 | var request = DicomQrClient.CreateSeriesMoveRequest(study.Uid, series.Uid, m_Settings.ClientAeTitle);
231 | await m_DicomQrClient.RetrieveAsync(request, Save, m_Settings.ClientPort);
232 | }
233 | OpenFolder(study);
234 | });
235 | }
236 |
237 | private async Task DoWork(Func action, bool indeterminateProgress = false)
238 | {
239 | try
240 | {
241 | IsEnabled = false;
242 | if (indeterminateProgress)
243 | {
244 | RetrievingProgress.IsIndeterminate = true;
245 | }
246 | await action();
247 | return true;
248 | }
249 | catch (Exception ex)
250 | {
251 | MessageBox.Show(ex.Message, Title, MessageBoxButton.OK, MessageBoxImage.Error);
252 | return false;
253 | }
254 | finally
255 | {
256 | IsEnabled = true;
257 | if (indeterminateProgress)
258 | {
259 | RetrievingProgress.IsIndeterminate = false;
260 | }
261 | }
262 | }
263 |
264 | private async Task Save(DicomDataset dataset)
265 | {
266 | Dispatcher.Invoke(() => ++RetrievingProgress.Value);
267 |
268 | var file = new DicomFile(dataset);
269 | var filePath = Path.Combine(StoragePath, dataset.GetString(DicomTag.StudyInstanceUID), dataset.GetString(DicomTag.SeriesInstanceUID), dataset.GetString(DicomTag.SOPInstanceUID) + ".dcm");
270 | Directory.CreateDirectory(Path.GetDirectoryName(filePath));
271 | await file.SaveAsync(filePath);
272 | return true;
273 | }
274 |
275 | private void OpenFolder(DicomStudy study)
276 | {
277 | var folderPath = Path.Combine(StoragePath, study.Uid);
278 | Process.Start(File.Exists(m_Settings.ImageViewerPath) ? m_Settings.ImageViewerPath : "explorer", folderPath);
279 | }
280 |
281 | private void DeleteFolder(DicomStudy study)
282 | {
283 | var folderPath = Path.Combine(StoragePath, study.Uid);
284 | if (Directory.Exists(folderPath))
285 | {
286 | Directory.Delete(folderPath, true);
287 | }
288 | }
289 |
290 | private async void Studies_MouseDoubleClick(object sender, MouseButtonEventArgs e)
291 | {
292 | var row = (DataGridRow)sender;
293 | Studies.SelectedItem = row.DataContext;
294 | await OpenStudy();
295 | }
296 |
297 | private async void Series_MouseDoubleClick(object sender, MouseButtonEventArgs e)
298 | {
299 | var row = (DataGridRow)sender;
300 | Series.SelectedItem = row.DataContext;
301 | await OpenSeries();
302 | }
303 |
304 | private void Configure(object sender, RoutedEventArgs e)
305 | {
306 | var window = new ConfigWindow
307 | {
308 | Owner = this
309 | };
310 | if (window.ShowDialog() == true)
311 | {
312 | m_Settings.Save();
313 | m_DicomQrClient = null;
314 | m_DicomStoreClient = null;
315 | }
316 | }
317 | }
318 | }
319 |
--------------------------------------------------------------------------------