Compare commits
1 Commits
master
...
release/1.
| Author | SHA1 | Date | |
|---|---|---|---|
| a01234a56d |
13
Dockerfile
Normal file
13
Dockerfile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Use the official .NET SDK image to build and publish the app
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy everything and build
|
||||||
|
COPY . .
|
||||||
|
RUN dotnet publish -c Release -o out
|
||||||
|
|
||||||
|
# Use the official .NET runtime image for a smaller container
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS runtime
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=build /app/out ./
|
||||||
|
ENTRYPOINT ["dotnet", "DicomMigratorApp.dll"]
|
||||||
42
Program.cs
42
Program.cs
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using FellowOakDicom;
|
using FellowOakDicom;
|
||||||
using FellowOakDicom.Network;
|
using FellowOakDicom.Network;
|
||||||
@ -38,12 +39,13 @@ namespace DicomMigratorApp
|
|||||||
|
|
||||||
_logger.LogInformation("Application started");
|
_logger.LogInformation("Application started");
|
||||||
|
|
||||||
connectionString = "Server=127.0.0.1;Port=3306;Database=dms_db;User Id=root;Password=Rootmatrix23@;";
|
connectionString = Environment.GetEnvironmentVariable("ConnectionStrings__DefaultConnection")
|
||||||
targetIP = "127.0.0.1";
|
?? "Server=127.0.0.1;Port=3306;Database=dms_db;User Id=root;Password=Rootmatrix23@;";
|
||||||
senderAET = "MYAE";
|
targetIP = Environment.GetEnvironmentVariable("TARGET_IP") ?? "127.0.0.1";
|
||||||
targetAET = "ORTHANC";
|
senderAET = Environment.GetEnvironmentVariable("SENDER_AET") ?? "MYAE";
|
||||||
folderLocation = "D:\\dicom_imags\\";
|
targetAET = Environment.GetEnvironmentVariable("TARGET_AET") ?? "ORTHANC";
|
||||||
var targetPortStr = "4242";
|
folderLocation = Environment.GetEnvironmentVariable("FOLDER_LOCATION") ?? "D:\\dicom_images\\";
|
||||||
|
string targetPortStr = Environment.GetEnvironmentVariable("TARGET_PORT") ?? "4242";
|
||||||
|
|
||||||
if (!int.TryParse(targetPortStr, out targetPort))
|
if (!int.TryParse(targetPortStr, out targetPort))
|
||||||
{
|
{
|
||||||
@ -51,20 +53,28 @@ namespace DicomMigratorApp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var migrationStudy = await GetMigrationStudy(connectionString);
|
var migrationStudy = await GetMigrationStudy(connectionString);
|
||||||
if (migrationStudy == null)
|
if (migrationStudy == null)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("No studies found for migration.");
|
await Task.Delay(5000);
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation($"Retrieved studyDetails for Migration");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await MigrateStudy(migrationStudy.StudyInstanceUID, folderLocation + migrationStudy.StudyInstanceUID);
|
var folderPath = Path.Combine(folderLocation, migrationStudy.StudyInstanceUID);
|
||||||
|
if (!Directory.Exists(folderPath))
|
||||||
|
{
|
||||||
|
_logger.LogError($"Study folder not found for studyInstanceUID {migrationStudy.StudyInstanceUID}");
|
||||||
|
await UpdateSourceCFind(connectionString, migrationStudy.StudyInstanceUID, "MIGRATION_SIUID_FOLDER_NOT_PRESENT");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
await MigrateStudy(migrationStudy.StudyInstanceUID, folderPath, targetIP, targetPort, senderAET, targetAET);
|
||||||
await UpdateSourceCFind(connectionString, migrationStudy.StudyInstanceUID, "MIGRATION_COMPLETE");
|
await UpdateSourceCFind(connectionString, migrationStudy.StudyInstanceUID, "MIGRATION_COMPLETE");
|
||||||
}
|
}
|
||||||
catch (DicomAssociationRejectedException ex)
|
catch (DicomAssociationRejectedException ex)
|
||||||
@ -83,6 +93,7 @@ namespace DicomMigratorApp
|
|||||||
_logger.LogError(ex, "An error occurred in the main processing loop");
|
_logger.LogError(ex, "An error occurred in the main processing loop");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static async Task<SourceStudy> GetMigrationStudy(string connectionString)
|
private static async Task<SourceStudy> GetMigrationStudy(string connectionString)
|
||||||
{
|
{
|
||||||
@ -92,10 +103,8 @@ namespace DicomMigratorApp
|
|||||||
{
|
{
|
||||||
using (var connection = new MySqlConnection(connectionString))
|
using (var connection = new MySqlConnection(connectionString))
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Opening a connection to the database");
|
|
||||||
await connection.OpenAsync();
|
await connection.OpenAsync();
|
||||||
_logger.LogInformation("Database connection established");
|
var command = new MySqlCommand("SELECT study_instance_uid,patient_id,status FROM source_cfind WHERE status='QR_COMPLETE' and (schedule_date IS NOT NULL AND LEFT(schedule_date, 8) >= DATE_FORMAT(CURDATE(), '%Y%m%d')) LIMIT 1", connection);
|
||||||
var command = new MySqlCommand("SELECT study_instance_uid,patient_id,status FROM source_cfind WHERE status='QR_COMPLETE' LIMIT 1", connection);
|
|
||||||
var reader = await command.ExecuteReaderAsync();
|
var reader = await command.ExecuteReaderAsync();
|
||||||
|
|
||||||
while (await reader.ReadAsync())
|
while (await reader.ReadAsync())
|
||||||
@ -150,11 +159,12 @@ namespace DicomMigratorApp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task MigrateStudy(string studyInstanceUID, string folderPath)
|
private static async Task MigrateStudy(string studyInstanceUID, string folderPath, string targetIP, int targetPort, string senderAET, string targetAET)
|
||||||
{
|
{
|
||||||
var client = DicomClientFactory.Create(targetIP, targetPort, false, senderAET, targetAET);
|
var client = DicomClientFactory.Create(targetIP, targetPort, false, senderAET, targetAET);
|
||||||
|
|
||||||
var files = System.IO.Directory.GetFiles(folderPath, "*");
|
// Gather all DICOM files in the directory and subdirectories
|
||||||
|
var files = Directory.GetFiles(folderPath, "*", SearchOption.AllDirectories);
|
||||||
foreach (var file in files)
|
foreach (var file in files)
|
||||||
{
|
{
|
||||||
var dicomFile = await DicomFile.OpenAsync(file);
|
var dicomFile = await DicomFile.OpenAsync(file);
|
||||||
|
|||||||
22
docker-compose.yml
Normal file
22
docker-compose.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
dicommigratorautomated:
|
||||||
|
image: seyfertsoft/dicommigratorautomated:1.0.0
|
||||||
|
container_name: dicommigratorautomated
|
||||||
|
environment:
|
||||||
|
- "ConnectionStrings__DefaultConnection=Server=mysqldb;Port=3306;Database=dms_db;User Id=root;Password=Rootmatrix23@;"
|
||||||
|
- TARGET_IP=127.0.0.1
|
||||||
|
- SENDER_AET=MYAE
|
||||||
|
- TARGET_AET=ORTHANC
|
||||||
|
- "FOLDER_LOCATION=D:\\dicom_imags\\"
|
||||||
|
- TARGET_PORT=4242
|
||||||
|
volumes:
|
||||||
|
- /path/to/images1:/app/images1
|
||||||
|
- /path/to/images2:/app/images2
|
||||||
|
networks:
|
||||||
|
- dmsnetwork
|
||||||
|
|
||||||
|
networks:
|
||||||
|
dmsnetwork:
|
||||||
|
external: true
|
||||||
Loading…
x
Reference in New Issue
Block a user