Skip to content

Store & notify HL7 messages #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ jobs:
with:
fetch-depth: 0

- uses: actions/setup-dotnet@v1
with:
dotnet-version: "6.0.x"

- name: Install GitVersion
run: dotnet tool install --global GitVersion.Tool

Expand Down Expand Up @@ -199,7 +203,7 @@ jobs:
needs: [build]
strategy:
matrix:
feature: [AcrApi, DicomDimseScp, DicomDimseScu, DicomWebExport, DicomWebStow]
feature: [AcrApi, DicomDimseScp, DicomDimseScu, DicomWebExport, DicomWebStow, HealthLevel7]
fail-fast: false
env:
TAG: ${{ needs.build.outputs.TAG }}
Expand Down
2 changes: 2 additions & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ header:
- '**/*.feature.cs'
- 'src/.sonarlint/**'
- 'src/coverlet.runsettings'
- 'src/Monai.Deploy.InformaticsGateway.sln'
- 'src/Database/Migrations/**'
- 'demos/**/.env/**'
- 'docs/templates/**'
- 'tests/Integration.Test/*.dev'
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ COPY --from=build /app/out .
COPY --from=build /tools /opt/dotnetcore-tools

EXPOSE 104
EXPOSE 2575
EXPOSE 5000

RUN ls -lR /opt/monai/ig
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.100",
"version": "6.0.400",
"rollForward": "latestFeature"
}
}
63 changes: 63 additions & 0 deletions src/Api/Storage/Hl7FileStorageMetadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright 2021-2022 MONAI Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using System;
using System.Text.Json.Serialization;
using Ardalis.GuardClauses;

namespace Monai.Deploy.InformaticsGateway.Api.Storage
{
/// <summary>
/// Provides basic information for a FHIR resource and storage hierarchy/path.
/// </summary>
public sealed record Hl7FileStorageMetadata : FileStorageMetadata
{
public const string Hl7SubDirectoryName = "ehr";
public const string FileExtension = ".txt";

/// <inheritdoc/>
[JsonIgnore]
public override string DataTypeDirectoryName => Hl7SubDirectoryName;

/// <inheritdoc/>
[JsonPropertyName("file")]
public override StorageObjectMetadata File { get; set; }

/// <summary>
/// DO NOT USE
/// This constructor is intended for JSON serializer.
/// Due to limitation in current version of .NET, the constructor must be public.
/// https://github.com/dotnet/runtime/issues/31511
/// </summary>
[JsonConstructor]
public Hl7FileStorageMetadata() { }

public Hl7FileStorageMetadata(string connectionId)
: base(connectionId, Guid.NewGuid().ToString())
{
Guard.Against.NullOrWhiteSpace(connectionId, nameof(connectionId));

Source = connectionId;

File = new StorageObjectMetadata(FileExtension)
{
TemporaryPath = string.Join(PathSeparator, connectionId, DataTypeDirectoryName, $"{base.Id}{FileExtension}"),
UploadPath = string.Join(PathSeparator, DataTypeDirectoryName, $"{base.Id}{FileExtension}"),
ContentType = System.Net.Mime.MediaTypeNames.Text.Plain,
};
}
}
}
6 changes: 4 additions & 2 deletions src/Api/Test/Storage/StorageObjectMetadataTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ public void GivenAStorageObjectMetadata_InitializeWithFileExtensionMissingDot_Ex
[Fact]
public void GivenAStorageObjectMetadata_WhenSetUploadIsCalled_ExpectUplaodValuesToBeSetAndDataStreamDisposed()
{
var metadata = new StorageObjectMetadata(".txt");
metadata.Data = new MemoryStream();
var metadata = new StorageObjectMetadata(".txt")
{
Data = new MemoryStream()
};
metadata.SetUploaded("MYBUCKET");

Assert.Equal("MYBUCKET", metadata.TemporaryBucketName);
Expand Down
22 changes: 21 additions & 1 deletion src/CLI/Services/ConfigurationOptionAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public interface IConfigurationOptionAccessor
/// </summary>
int DicomListeningPort { get; set; }

/// <summary>
/// Gets or sets the HL7 listening port from appsettings.json.
/// </summary>
int Hl7ListeningPort { get; set; }

/// <summary>
/// Gets or sets the Docker image prefix from appsettings.json.
/// This is used to query the Informatics Gateway Docker containers that are installed.
Expand Down Expand Up @@ -105,13 +110,28 @@ public int DicomListeningPort
}
set
{
Guard.Against.OutOfRangePort(value, nameof(InformaticsGatewayServerEndpoint));
Guard.Against.OutOfRangePort(value, nameof(DicomListeningPort));
var jObject = ReadConfigurationFile();
jObject["InformaticsGateway"]["dicom"]["scp"]["port"] = value;
SaveConfigurationFile(jObject);
}
}

public int Hl7ListeningPort
{
get
{
return GetValueFromJsonPath<int>("InformaticsGateway.hl7.port");
}
set
{
Guard.Against.OutOfRangePort(value, nameof(Hl7ListeningPort));
var jObject = ReadConfigurationFile();
jObject["InformaticsGateway"]["hl7"]["port"] = value;
SaveConfigurationFile(jObject);
}
}

public string DockerImagePrefix
{
get
Expand Down
4 changes: 4 additions & 0 deletions src/CLI/Services/DockerRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ public async Task<bool> StartApplication(ImageVersion imageVersion, Cancellation
createContainerParams.ExposedPorts.Add($"{_configurationService.Configurations.DicomListeningPort}/tcp", new EmptyStruct());
createContainerParams.HostConfig.PortBindings.Add($"{_configurationService.Configurations.DicomListeningPort}/tcp", new List<PortBinding> { new PortBinding { HostPort = $"{_configurationService.Configurations.DicomListeningPort}" } });

_logger.DockerPrtBinding(_configurationService.Configurations.Hl7ListeningPort);
createContainerParams.ExposedPorts.Add($"{_configurationService.Configurations.Hl7ListeningPort}/tcp", new EmptyStruct());
createContainerParams.HostConfig.PortBindings.Add($"{_configurationService.Configurations.Hl7ListeningPort}/tcp", new List<PortBinding> { new PortBinding { HostPort = $"{_configurationService.Configurations.Hl7ListeningPort}" } });

_logger.DockerPrtBinding(_configurationService.Configurations.InformaticsGatewayServerPort);
createContainerParams.ExposedPorts.Add($"{_configurationService.Configurations.InformaticsGatewayServerPort}/tcp", new EmptyStruct());
createContainerParams.HostConfig.PortBindings.Add($"{_configurationService.Configurations.InformaticsGatewayServerPort}/tcp", new List<PortBinding> { new PortBinding { HostPort = $"{_configurationService.Configurations.InformaticsGatewayServerPort}" } });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Monai.Deploy.InformaticsGateway.Client.Common</RootNamespace>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<IsTrimmable>true</IsTrimmable>
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Monai.Deploy.InformaticsGateway.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<PropertyGroup>
<RootNamespace>Monai.Deploy.InformaticsGateway.Common</RootNamespace>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<IsTrimmable>true</IsTrimmable>
<ProduceReferenceAssembly>True</ProduceReferenceAssembly>
Expand Down
22 changes: 18 additions & 4 deletions src/Configuration/Hl7Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
// SPDX-FileCopyrightText: © 2022 MONAI Consortium
// SPDX-License-Identifier: Apache License 2.0
/*
* Copyright 2022 MONAI Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using Microsoft.Extensions.Configuration;

namespace Monai.Deploy.InformaticsGateway.Configuration
{
public class Hl7Configuration
{
public static readonly int DefaultClientTimeout = 300000;
public static readonly int DefaultClientTimeout = 60000;
public const int DefaultMaximumNumberOfConnections = 10;

/// <summary>
/// Gets or sets the client connection timeout in milliseconds.
/// Defaults to 60,000ms.
/// </summary>
[ConfigurationKeyName("clientTimeout")]
public int ClientTimeoutMilliseconds { get; set; } = DefaultClientTimeout;
Expand All @@ -27,7 +41,7 @@ public class Hl7Configuration
/// Gets or sets the MLLP listening port.
/// Defaults to 2575.
/// </summary>
[ConfigurationKeyName("clientTimeout")]
[ConfigurationKeyName("port")]
public int Port { get; set; } = 2575;

/// <summary>
Expand Down
18 changes: 17 additions & 1 deletion src/Database/Migrations/20220802200605_R3_0.3.0.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion src/Database/Migrations/20220802200605_R3_0.3.0.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
using Microsoft.EntityFrameworkCore.Migrations;
/*
* Copyright 2022 MONAI Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
// <auto-generated />
/*
* Copyright 2022 MONAI Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
Expand Down
17 changes: 0 additions & 17 deletions src/Database/StorageMetadataWrapperEntityConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,15 @@
* limitations under the License.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Monai.Deploy.InformaticsGateway.Api.Storage;

namespace Monai.Deploy.InformaticsGateway.Database
{
internal class StorageMetadataWrapperEntityConfiguration : IEntityTypeConfiguration<StorageMetadataWrapper>
{
public void Configure(EntityTypeBuilder<StorageMetadataWrapper> builder)
{
var filesComparer = new ValueComparer<IList<FileStorageMetadata>>(
(c1, c2) => c1.SequenceEqual(c2),
c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())),
c => c.ToList());

var jsonSerializerSettings = new JsonSerializerOptions
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};

builder.HasKey(j => new
{
j.CorrelationId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<!--
~ Copyright 2022 MONAI Consortium
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
Expand Down
16 changes: 16 additions & 0 deletions src/Database/Test/Usings.cs
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
/*
* Copyright 2022 MONAI Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

global using Xunit;
3 changes: 2 additions & 1 deletion src/DicomWebClient/API/IDicomWebClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ public interface IDicomWebClient
/// </summary>
/// <param name="serviceType"><c>ServiceType</c> to be configured</param>
/// <param name="urlPrefix">Url prefix</param>
#pragma warning disable CA1054
void ConfigureServicePrefix(DicomWebServiceType serviceType, string urlPrefix);

#pragma warning restore CA1054
/// <summary>
/// Configures the authentication header for the DICOMweb client.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/DicomWebClient/API/IServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ namespace Monai.Deploy.InformaticsGateway.DicomWeb.Client.API
{
public interface IServiceBase
{
#pragma warning disable CA1054
bool TryConfigureServiceUriPrefix(string uriPrefix);
#pragma warning restore CA1054
}
}
Loading