|
| 1 | +/* |
| 2 | + * Copyright 2021-2022 MONAI Consortium |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +using System; |
| 18 | +using System.Text.Json.Serialization; |
| 19 | +using Ardalis.GuardClauses; |
| 20 | + |
| 21 | +namespace Monai.Deploy.InformaticsGateway.Api.Storage |
| 22 | +{ |
| 23 | + /// <summary> |
| 24 | + /// Provides basic information for a FHIR resource and storage hierarchy/path. |
| 25 | + /// </summary> |
| 26 | + public sealed record Hl7FileStorageMetadata : FileStorageMetadata |
| 27 | + { |
| 28 | + public const string Hl7SubDirectoryName = "ehr"; |
| 29 | + public const string FileExtension = ".txt"; |
| 30 | + |
| 31 | + /// <inheritdoc/> |
| 32 | + [JsonIgnore] |
| 33 | + public override string DataTypeDirectoryName => Hl7SubDirectoryName; |
| 34 | + |
| 35 | + /// <inheritdoc/> |
| 36 | + [JsonPropertyName("file")] |
| 37 | + public override StorageObjectMetadata File { get; set; } |
| 38 | + |
| 39 | + /// <summary> |
| 40 | + /// DO NOT USE |
| 41 | + /// This constructor is intended for JSON serializer. |
| 42 | + /// Due to limitation in current version of .NET, the constructor must be public. |
| 43 | + /// https://github.com/dotnet/runtime/issues/31511 |
| 44 | + /// </summary> |
| 45 | + [JsonConstructor] |
| 46 | + public Hl7FileStorageMetadata() { } |
| 47 | + |
| 48 | + public Hl7FileStorageMetadata(string connectionId) |
| 49 | + : base(connectionId, Guid.NewGuid().ToString()) |
| 50 | + { |
| 51 | + Guard.Against.NullOrWhiteSpace(connectionId, nameof(connectionId)); |
| 52 | + |
| 53 | + Source = connectionId; |
| 54 | + |
| 55 | + File = new StorageObjectMetadata(FileExtension) |
| 56 | + { |
| 57 | + TemporaryPath = string.Join(PathSeparator, connectionId, DataTypeDirectoryName, $"{base.Id}{FileExtension}"), |
| 58 | + UploadPath = string.Join(PathSeparator, DataTypeDirectoryName, $"{base.Id}{FileExtension}"), |
| 59 | + ContentType = System.Net.Mime.MediaTypeNames.Text.Plain, |
| 60 | + }; |
| 61 | + } |
| 62 | + } |
| 63 | +} |
0 commit comments