|
@@ -6,35 +6,43 @@ using System.IO;
|
|
|
using System.Text.Encodings.Web;
|
|
|
using System.Text.Json;
|
|
|
using System.Text.Unicode;
|
|
|
-using System.Threading;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
using System.Windows.Input;
|
|
|
using System.Windows.Media;
|
|
|
using System.Windows.Media.Imaging;
|
|
|
-using System.Windows.Threading;
|
|
|
|
|
|
namespace TestViewer
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// Interaction logic for MainWindow.xaml
|
|
|
/// </summary>
|
|
|
- public partial class MainWindow : Window
|
|
|
+ public partial class MainWindow
|
|
|
{
|
|
|
- private readonly Database _db;
|
|
|
+ private readonly Database? _db;
|
|
|
+ private DateTime _startDate = new(2023, 1, 1);
|
|
|
+ private DateTime _endDate = DateTime.Now;
|
|
|
private int _pageIndex = -1;
|
|
|
- private int _pageCount = 0;
|
|
|
+ private int _pageCount;
|
|
|
private string _partKey = string.Empty;
|
|
|
private string _conclusionKey = string.Empty;
|
|
|
|
|
|
public MainWindow()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
+ CreateStart.SelectedDate = _startDate;
|
|
|
+ CreateStart.DisplayDate = _startDate;
|
|
|
+ CreateEnd.SelectedDate = _endDate;
|
|
|
+ CreateEnd.DisplayDate = _endDate;
|
|
|
+ CreateStart.SelectedDateChanged += (_, _) => { _startDate = CreateStart.SelectedDate.Value.Date; };
|
|
|
+ CreateEnd.SelectedDateChanged += (_, _) => { _endDate = CreateEnd.SelectedDate.Value.Date.AddDays(1); };
|
|
|
Loading.LoadingChanged += OnLoadingChanged;
|
|
|
- var fileDialog = new OpenFileDialog();
|
|
|
- fileDialog.Title = "Open database file";
|
|
|
- fileDialog.Filter = "*.db|*.db";
|
|
|
+ var fileDialog = new OpenFileDialog
|
|
|
+ {
|
|
|
+ Title = "Open database file",
|
|
|
+ Filter = "*.db|*.db"
|
|
|
+ };
|
|
|
if (fileDialog.ShowDialog() == true)
|
|
|
{
|
|
|
_db = new Database(fileDialog.FileName);
|
|
@@ -67,14 +75,13 @@ namespace TestViewer
|
|
|
|
|
|
private void OnBatchTaskSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
{
|
|
|
- var batchTask = BatchTaskList.SelectedValue as BatchTask;
|
|
|
- if (batchTask != null)
|
|
|
+ if (BatchTaskList.SelectedValue is BatchTask batchTask)
|
|
|
{
|
|
|
Loading.Run(() =>
|
|
|
{
|
|
|
_pageIndex = 0;
|
|
|
- _pageCount = _db.GetPageCount(batchTask.Id, _partKey, _conclusionKey);
|
|
|
- var exams = _db.GetExams(batchTask.Id, _pageIndex, _partKey, _conclusionKey);
|
|
|
+ _pageCount = _db!.GetPageCount(batchTask.Id, _partKey, _conclusionKey,_startDate, _endDate);
|
|
|
+ var exams = _db.GetExams(batchTask.Id, _pageIndex, _partKey, _conclusionKey, _startDate, _endDate);
|
|
|
Dispatcher.Invoke(() =>
|
|
|
{
|
|
|
foreach (var exam in exams)
|
|
@@ -89,171 +96,167 @@ namespace TestViewer
|
|
|
|
|
|
private void OnExamSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
{
|
|
|
- ExamControllScrollView.ScrollToHome();
|
|
|
+ ExamScrollView.ScrollToHome();
|
|
|
ExamContent.Children.Clear();
|
|
|
- if (ExamList.SelectedValue != null)
|
|
|
+ if (ExamList.SelectedValue is Exam exam)
|
|
|
{
|
|
|
- var exam = ExamList.SelectedValue as Exam;
|
|
|
- if (exam != null)
|
|
|
+ Dictionary<string, string>? reportContent;
|
|
|
+ try
|
|
|
{
|
|
|
- Dictionary<string, string>? reportContent = null;
|
|
|
- try
|
|
|
- {
|
|
|
- reportContent = JsonSerializer.Deserialize<Dictionary<string, string>>(exam.Report);
|
|
|
- }
|
|
|
- catch
|
|
|
+ reportContent = JsonSerializer.Deserialize<Dictionary<string, string>>(exam.Report);
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ reportContent = null;
|
|
|
+ }
|
|
|
+ if (reportContent != null)
|
|
|
+ {
|
|
|
+ var partStackPanel = new StackPanel() { Margin = new Thickness(16), Orientation = Orientation.Horizontal };
|
|
|
+ partStackPanel.Children.Add(new TextBlock()
|
|
|
{
|
|
|
- reportContent = null;
|
|
|
- }
|
|
|
- if (reportContent != null)
|
|
|
+ VerticalAlignment = VerticalAlignment.Center,
|
|
|
+ Text = "部位: ",
|
|
|
+ FontWeight = FontWeights.Bold,
|
|
|
+ FontSize = 16,
|
|
|
+ });
|
|
|
+ partStackPanel.Children.Add(new TextBlock()
|
|
|
{
|
|
|
- var partStackPanel = new StackPanel() { Margin = new Thickness(16), Orientation = Orientation.Horizontal };
|
|
|
- partStackPanel.Children.Add(new TextBlock()
|
|
|
- {
|
|
|
- VerticalAlignment = VerticalAlignment.Center,
|
|
|
- Text = "部位: ",
|
|
|
- FontWeight = FontWeights.Bold,
|
|
|
- FontSize = 16,
|
|
|
- });
|
|
|
- partStackPanel.Children.Add(new TextBlock()
|
|
|
- {
|
|
|
- VerticalAlignment = VerticalAlignment.Center,
|
|
|
- Text = $"{reportContent["Part"]}",
|
|
|
- FontSize = 16,
|
|
|
- });
|
|
|
- ExamContent.Children.Add(partStackPanel);
|
|
|
+ VerticalAlignment = VerticalAlignment.Center,
|
|
|
+ Text = $"{reportContent["Part"]}",
|
|
|
+ FontSize = 16,
|
|
|
+ });
|
|
|
+ ExamContent.Children.Add(partStackPanel);
|
|
|
|
|
|
- var deviceStackPanel = new StackPanel() { Margin = new Thickness(16), Orientation = Orientation.Horizontal };
|
|
|
- deviceStackPanel.Children.Add(new TextBlock()
|
|
|
- {
|
|
|
- VerticalAlignment = VerticalAlignment.Center,
|
|
|
- Text = "设备: ",
|
|
|
- FontWeight = FontWeights.Bold,
|
|
|
- FontSize = 16,
|
|
|
- });
|
|
|
- deviceStackPanel.Children.Add(new TextBlock()
|
|
|
- {
|
|
|
- VerticalAlignment = VerticalAlignment.Center,
|
|
|
- Text = $"{reportContent["Device"]}",
|
|
|
- FontSize = 16,
|
|
|
- });
|
|
|
- ExamContent.Children.Add(deviceStackPanel);
|
|
|
+ var deviceStackPanel = new StackPanel() { Margin = new Thickness(16), Orientation = Orientation.Horizontal };
|
|
|
+ deviceStackPanel.Children.Add(new TextBlock()
|
|
|
+ {
|
|
|
+ VerticalAlignment = VerticalAlignment.Center,
|
|
|
+ Text = "设备: ",
|
|
|
+ FontWeight = FontWeights.Bold,
|
|
|
+ FontSize = 16,
|
|
|
+ });
|
|
|
+ deviceStackPanel.Children.Add(new TextBlock()
|
|
|
+ {
|
|
|
+ VerticalAlignment = VerticalAlignment.Center,
|
|
|
+ Text = $"{reportContent["Device"]}",
|
|
|
+ FontSize = 16,
|
|
|
+ });
|
|
|
+ ExamContent.Children.Add(deviceStackPanel);
|
|
|
|
|
|
- var conclusionStackPanel = new StackPanel() { Margin = new Thickness(16), Orientation = Orientation.Horizontal };
|
|
|
- conclusionStackPanel.Children.Add(new TextBlock()
|
|
|
- {
|
|
|
- VerticalAlignment = VerticalAlignment.Center,
|
|
|
- Text = "结论: ",
|
|
|
- FontWeight = FontWeights.Bold,
|
|
|
- FontSize = 16,
|
|
|
- });
|
|
|
- var conclusion = "无结论";
|
|
|
- if (!string.IsNullOrEmpty(reportContent["Conclusion"]))
|
|
|
- {
|
|
|
- conclusion = reportContent["Conclusion"];
|
|
|
- }
|
|
|
- conclusionStackPanel.Children.Add(new TextBlock()
|
|
|
- {
|
|
|
- VerticalAlignment = VerticalAlignment.Center,
|
|
|
- Text = conclusion,
|
|
|
- FontSize = 16,
|
|
|
- });
|
|
|
- ExamContent.Children.Add(conclusionStackPanel);
|
|
|
+ var conclusionStackPanel = new StackPanel() { Margin = new Thickness(16), Orientation = Orientation.Horizontal };
|
|
|
+ conclusionStackPanel.Children.Add(new TextBlock()
|
|
|
+ {
|
|
|
+ VerticalAlignment = VerticalAlignment.Center,
|
|
|
+ Text = "结论: ",
|
|
|
+ FontWeight = FontWeights.Bold,
|
|
|
+ FontSize = 16,
|
|
|
+ });
|
|
|
+ var conclusion = "无结论";
|
|
|
+ if (!string.IsNullOrEmpty(reportContent["Conclusion"]))
|
|
|
+ {
|
|
|
+ conclusion = reportContent["Conclusion"];
|
|
|
+ }
|
|
|
+ conclusionStackPanel.Children.Add(new TextBlock()
|
|
|
+ {
|
|
|
+ VerticalAlignment = VerticalAlignment.Center,
|
|
|
+ Text = conclusion,
|
|
|
+ FontSize = 16,
|
|
|
+ });
|
|
|
+ ExamContent.Children.Add(conclusionStackPanel);
|
|
|
|
|
|
- ExamContent.Children.Add(new Border() { Height = 1, Width = 2000, BorderBrush = Brushes.Gray, Background = Brushes.Gray });
|
|
|
+ ExamContent.Children.Add(new Border() { Height = 1, Width = 2000, BorderBrush = Brushes.Gray, Background = Brushes.Gray });
|
|
|
|
|
|
- ExamContent.Children.Add(new TextBlock()
|
|
|
- {
|
|
|
- Width = 2000,
|
|
|
- Margin = new Thickness(16, 16, 16, 8),
|
|
|
- Text = $"超声所见:",
|
|
|
- FontSize = 16,
|
|
|
- FontWeight = FontWeights.Bold,
|
|
|
- });
|
|
|
+ ExamContent.Children.Add(new TextBlock()
|
|
|
+ {
|
|
|
+ Width = 2000,
|
|
|
+ Margin = new Thickness(16, 16, 16, 8),
|
|
|
+ Text = "超声所见:",
|
|
|
+ FontSize = 16,
|
|
|
+ FontWeight = FontWeights.Bold,
|
|
|
+ });
|
|
|
|
|
|
- ExamContent.Children.Add(new TextBlock()
|
|
|
- {
|
|
|
- Margin = new Thickness(16, 8, 16, 16),
|
|
|
- Text = reportContent["Summary"].Replace(@"\n", Environment.NewLine),
|
|
|
- FontSize = 16,
|
|
|
- TextWrapping = TextWrapping.Wrap,
|
|
|
- });
|
|
|
+ ExamContent.Children.Add(new TextBlock()
|
|
|
+ {
|
|
|
+ Margin = new Thickness(16, 8, 16, 16),
|
|
|
+ Text = reportContent["Summary"].Replace(@"\n", Environment.NewLine),
|
|
|
+ FontSize = 16,
|
|
|
+ TextWrapping = TextWrapping.Wrap,
|
|
|
+ });
|
|
|
|
|
|
- ExamContent.Children.Add(new TextBlock()
|
|
|
- {
|
|
|
- Width = 2000,
|
|
|
- Margin = new Thickness(16, 16, 16, 8),
|
|
|
- Text = $"超声提示:",
|
|
|
- FontSize = 16,
|
|
|
- FontWeight = FontWeights.Bold,
|
|
|
- });
|
|
|
+ ExamContent.Children.Add(new TextBlock()
|
|
|
+ {
|
|
|
+ Width = 2000,
|
|
|
+ Margin = new Thickness(16, 16, 16, 8),
|
|
|
+ Text = "超声提示:",
|
|
|
+ FontSize = 16,
|
|
|
+ FontWeight = FontWeights.Bold,
|
|
|
+ });
|
|
|
|
|
|
- ExamContent.Children.Add(new TextBlock()
|
|
|
- {
|
|
|
- Margin = new Thickness(16, 8, 16, 16),
|
|
|
- Text = reportContent["Comment"].Replace(@"\n", Environment.NewLine),
|
|
|
- FontSize = 16,
|
|
|
- TextWrapping = TextWrapping.Wrap,
|
|
|
- });
|
|
|
- }
|
|
|
- else
|
|
|
+ ExamContent.Children.Add(new TextBlock()
|
|
|
+ {
|
|
|
+ Margin = new Thickness(16, 8, 16, 16),
|
|
|
+ Text = reportContent["Comment"].Replace(@"\n", Environment.NewLine),
|
|
|
+ FontSize = 16,
|
|
|
+ TextWrapping = TextWrapping.Wrap,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ExamContent.Children.Add(new TextBlock()
|
|
|
+ {
|
|
|
+ Margin = new Thickness(16),
|
|
|
+ Text = exam.Report,
|
|
|
+ FontSize = 20,
|
|
|
+ TextWrapping = TextWrapping.Wrap,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ ExamContent.Children.Add(new Border() { Height = 1, Width = 2000, BorderBrush = Brushes.Gray, Background = Brushes.Gray });
|
|
|
+ var images = _db!.GetImages(exam.Id);
|
|
|
+ foreach (var image in images)
|
|
|
+ {
|
|
|
+ var img = new BitmapImage();
|
|
|
+ img.BeginInit();
|
|
|
+ img.StreamSource = new MemoryStream(image.Data);
|
|
|
+ img.EndInit();
|
|
|
+ var imageBorder = new Border
|
|
|
{
|
|
|
- ExamContent.Children.Add(new TextBlock()
|
|
|
+ Margin = new Thickness(16),
|
|
|
+ Width = 200,
|
|
|
+ Height = 200,
|
|
|
+ Background = Brushes.Black,
|
|
|
+ Child = new System.Windows.Controls.Image()
|
|
|
{
|
|
|
- Margin = new Thickness(16),
|
|
|
- Text = exam.Report,
|
|
|
- FontSize = 20,
|
|
|
- TextWrapping = TextWrapping.Wrap,
|
|
|
- });
|
|
|
- }
|
|
|
- ExamContent.Children.Add(new Border() { Height = 1, Width = 2000, BorderBrush = Brushes.Gray, Background = Brushes.Gray });
|
|
|
- var images = _db.GetImages(exam.Id);
|
|
|
- foreach (var image in images)
|
|
|
+ Source = img
|
|
|
+ },
|
|
|
+ Cursor = Cursors.Hand
|
|
|
+
|
|
|
+ };
|
|
|
+ imageBorder.MouseDown += (_, _) =>
|
|
|
{
|
|
|
- var img = new BitmapImage();
|
|
|
- img.BeginInit();
|
|
|
- img.StreamSource = new MemoryStream(image.Data);
|
|
|
- img.EndInit();
|
|
|
- var imageBorder = new Border()
|
|
|
+ var viewImageWindow = new Window
|
|
|
{
|
|
|
- Margin = new Thickness(16),
|
|
|
- Width = 200,
|
|
|
- Height = 200,
|
|
|
+ Owner = this,
|
|
|
Background = Brushes.Black,
|
|
|
- Child = new System.Windows.Controls.Image()
|
|
|
- {
|
|
|
- Source = img
|
|
|
- },
|
|
|
- Cursor = Cursors.Hand
|
|
|
-
|
|
|
+ WindowStartupLocation = WindowStartupLocation.CenterOwner
|
|
|
};
|
|
|
- imageBorder.MouseDown += (sender, e) =>
|
|
|
+ var width = img.Width + 16;
|
|
|
+ var height = img.Height + 16;
|
|
|
+ if (width >= SystemParameters.PrimaryScreenWidth || height >= SystemParameters.PrimaryScreenHeight)
|
|
|
{
|
|
|
- var viewImageWindow = new Window
|
|
|
- {
|
|
|
- Owner = this,
|
|
|
- Background = Brushes.Black,
|
|
|
- WindowStartupLocation = WindowStartupLocation.CenterOwner
|
|
|
- };
|
|
|
- var width = img.Width + 16;
|
|
|
- var height = img.Height + 16;
|
|
|
- if (width >= SystemParameters.PrimaryScreenWidth || height >= SystemParameters.PrimaryScreenHeight)
|
|
|
- {
|
|
|
- viewImageWindow.WindowState = WindowState.Maximized;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- viewImageWindow.Width = width;
|
|
|
- viewImageWindow.Height = height;
|
|
|
- }
|
|
|
- viewImageWindow.Content = new System.Windows.Controls.Image()
|
|
|
- {
|
|
|
- Source = img
|
|
|
- };
|
|
|
- viewImageWindow.ShowDialog();
|
|
|
+ viewImageWindow.WindowState = WindowState.Maximized;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ viewImageWindow.Width = width;
|
|
|
+ viewImageWindow.Height = height;
|
|
|
+ }
|
|
|
+ viewImageWindow.Content = new System.Windows.Controls.Image()
|
|
|
+ {
|
|
|
+ Source = img
|
|
|
};
|
|
|
- ExamContent.Children.Add(imageBorder);
|
|
|
- }
|
|
|
+ viewImageWindow.ShowDialog();
|
|
|
+ };
|
|
|
+ ExamContent.Children.Add(imageBorder);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -262,14 +265,13 @@ namespace TestViewer
|
|
|
{
|
|
|
if (_pageIndex < _pageCount - 1)
|
|
|
{
|
|
|
- var batchTask = BatchTaskList.SelectedValue as BatchTask;
|
|
|
- if (batchTask != null)
|
|
|
+ if (BatchTaskList.SelectedValue is BatchTask batchTask)
|
|
|
{
|
|
|
ExamList.Items.Clear();
|
|
|
_pageIndex++;
|
|
|
Loading.Run(() =>
|
|
|
{
|
|
|
- var exams = _db.GetExams(batchTask.Id, _pageIndex, _partKey, _conclusionKey);
|
|
|
+ var exams = _db!.GetExams(batchTask.Id, _pageIndex, _partKey, _conclusionKey,_startDate, _endDate);
|
|
|
Dispatcher.Invoke(() =>
|
|
|
{
|
|
|
foreach (var exam in exams)
|
|
@@ -287,14 +289,13 @@ namespace TestViewer
|
|
|
{
|
|
|
if (_pageIndex > 0)
|
|
|
{
|
|
|
- var batchTask = BatchTaskList.SelectedValue as BatchTask;
|
|
|
- if (batchTask != null)
|
|
|
+ if (BatchTaskList.SelectedValue is BatchTask batchTask)
|
|
|
{
|
|
|
ExamList.Items.Clear();
|
|
|
_pageIndex--;
|
|
|
Loading.Run(() =>
|
|
|
{
|
|
|
- var exams = _db.GetExams(batchTask.Id, _pageIndex, _partKey, _conclusionKey);
|
|
|
+ var exams = _db!.GetExams(batchTask.Id, _pageIndex, _partKey, _conclusionKey, _startDate, _endDate);
|
|
|
Dispatcher.Invoke(() =>
|
|
|
{
|
|
|
foreach (var exam in exams)
|
|
@@ -312,16 +313,15 @@ namespace TestViewer
|
|
|
{
|
|
|
_partKey = PartKey.Text;
|
|
|
_conclusionKey = ConclusionKey.Text;
|
|
|
- var batchTask = BatchTaskList.SelectedValue as BatchTask;
|
|
|
- if (batchTask != null)
|
|
|
+ if (BatchTaskList.SelectedValue is BatchTask batchTask)
|
|
|
{
|
|
|
ExamList.Items.Clear();
|
|
|
- Exam[]? exams = null;
|
|
|
+ Exam[]? exams;
|
|
|
Loading.Run(() =>
|
|
|
{
|
|
|
- _pageCount = _db.GetPageCount(batchTask.Id, _partKey, _conclusionKey);
|
|
|
+ _pageCount = _db!.GetPageCount(batchTask.Id, _partKey, _conclusionKey, _startDate, _endDate);
|
|
|
_pageIndex = 0;
|
|
|
- exams = _db.GetExams(batchTask.Id, _pageIndex, _partKey, _conclusionKey);
|
|
|
+ exams = _db.GetExams(batchTask.Id, _pageIndex, _partKey, _conclusionKey,_startDate, _endDate);
|
|
|
Dispatcher.Invoke(() =>
|
|
|
{
|
|
|
foreach (var exam in exams)
|
|
@@ -338,8 +338,7 @@ namespace TestViewer
|
|
|
{
|
|
|
var partKey = PartKey.Text;
|
|
|
var conclusionKey = ConclusionKey.Text;
|
|
|
- var batchTask = BatchTaskList.SelectedValue as BatchTask;
|
|
|
- if (batchTask != null)
|
|
|
+ if (BatchTaskList.SelectedValue is BatchTask batchTask)
|
|
|
{
|
|
|
FolderBrowserEx.FolderBrowserDialog dialog = new FolderBrowserEx.FolderBrowserDialog();
|
|
|
var result = dialog.ShowDialog();
|
|
@@ -367,7 +366,7 @@ namespace TestViewer
|
|
|
Owner = this
|
|
|
};
|
|
|
var canClose = false;
|
|
|
- progressWindow.Closing += (s, e) => { e.Cancel = !canClose; };
|
|
|
+ progressWindow.Closing += (_, arg) => { arg.Cancel = !canClose; };
|
|
|
|
|
|
|
|
|
var progressBar = new ProgressBar
|
|
@@ -384,15 +383,14 @@ namespace TestViewer
|
|
|
WriteIndented = true,
|
|
|
Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
|
|
|
};
|
|
|
- var pageCount = _db.GetPageCount(batchTask.Id, partKey, conclusionKey);
|
|
|
+ var pageCount = _db!.GetPageCount(batchTask.Id, partKey, conclusionKey,_startDate, _endDate);
|
|
|
if (pageCount > 0)
|
|
|
{
|
|
|
for (int i = 0; i < pageCount; i++)
|
|
|
{
|
|
|
- var exams = _db.GetExams(batchTask.Id, i, partKey, conclusionKey);
|
|
|
- for (var j = 0; j < exams.Length; j++)
|
|
|
+ var exams = _db.GetExams(batchTask.Id, i, partKey, conclusionKey,_startDate, _endDate);
|
|
|
+ foreach (var exam in exams)
|
|
|
{
|
|
|
- var exam = exams[j];
|
|
|
var images = _db.GetImages(exam.Id);
|
|
|
foreach (var image in images)
|
|
|
{
|
|
@@ -406,7 +404,7 @@ namespace TestViewer
|
|
|
{ "PatientAge", exam.PatientAge },
|
|
|
{ "ExamDate", exam.ExamDate }
|
|
|
};
|
|
|
- Dictionary<string, string>? reportContent = null;
|
|
|
+ Dictionary<string, string>? reportContent;
|
|
|
try
|
|
|
{
|
|
|
reportContent = JsonSerializer.Deserialize<Dictionary<string, string>>(exam.Report);
|