From 9539f18772dee6e34c6d9601281ddd6db305af65 Mon Sep 17 00:00:00 2001 From: Lillie Dae Date: Mon, 20 Nov 2023 12:15:27 +0000 Subject: [PATCH] minor fix Signed-off-by: Lillie Dae --- src/Api/Hl7ApplicationConfigEntity.cs | 27 ++++++++++++++++--- .../Hl7ApplicationConfigConfiguration.cs | 5 ---- .../Hl7ApplicationConfigRepository.cs | 2 +- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/Api/Hl7ApplicationConfigEntity.cs b/src/Api/Hl7ApplicationConfigEntity.cs index 67116c655..27e25f666 100644 --- a/src/Api/Hl7ApplicationConfigEntity.cs +++ b/src/Api/Hl7ApplicationConfigEntity.cs @@ -31,21 +31,21 @@ public class Hl7ApplicationConfigEntity : MongoDBEntityBase /// Gets or sets the sending identifier. /// [JsonProperty("sending_identifier")] - public KeyValuePair SendingId { get; set; } + public StringKeyValuePair SendingId { get; set; } = new(); /// /// Gets or sets the data link. /// Value is either PatientId or StudyInstanceUid /// [JsonProperty("data_link")] - public KeyValuePair DataLink { get; set; } + public DataKeyValuePair DataLink { get; set; } = new(); /// /// Gets or sets the data mapping. /// Value is a DICOM Tag /// [JsonProperty("data_mapping")] - public Dictionary DataMapping { get; set; } = new(); + public List DataMapping { get; set; } = new(); public IEnumerable Validate() { @@ -95,6 +95,27 @@ public override string ToString() } } + //string key, string value + public class StringKeyValuePair : IKeyValuePair + { + [Key] + public string Key { get; set; } = string.Empty; + public string Value { get; set; } = string.Empty; + } + + public class DataKeyValuePair : IKeyValuePair + { + [Key] + public string Key { get; set; } = string.Empty; + public DataLinkType Value { get; set; } + } + + public interface IKeyValuePair + { + public TKey Key { get; set; } + public TValue Value { get; set; } + } + public enum DataLinkType { PatientId, diff --git a/src/Database/EntityFramework/Configuration/Hl7ApplicationConfigConfiguration.cs b/src/Database/EntityFramework/Configuration/Hl7ApplicationConfigConfiguration.cs index 66b37bff9..41ad63ad3 100644 --- a/src/Database/EntityFramework/Configuration/Hl7ApplicationConfigConfiguration.cs +++ b/src/Database/EntityFramework/Configuration/Hl7ApplicationConfigConfiguration.cs @@ -25,11 +25,6 @@ internal class Hl7ApplicationConfigConfiguration : IEntityTypeConfiguration builder) { builder.HasKey(j => j.Id); - builder.Property(j => j.DataLink).IsRequired(); - builder.Property(j => j.DataMapping).IsRequired(); - builder.Property(j => j.SendingId).IsRequired(); - - builder.Ignore(p => p.Id); } } } diff --git a/src/Database/EntityFramework/Repositories/Hl7ApplicationConfigRepository.cs b/src/Database/EntityFramework/Repositories/Hl7ApplicationConfigRepository.cs index 15dbe82e3..7f6711ab4 100644 --- a/src/Database/EntityFramework/Repositories/Hl7ApplicationConfigRepository.cs +++ b/src/Database/EntityFramework/Repositories/Hl7ApplicationConfigRepository.cs @@ -54,7 +54,7 @@ public Hl7ApplicationConfigRepository(ILogger lo } public Task> GetAllAsync(CancellationToken cancellationToken = default) => - _retryPolicy.ExecuteAsync(() => { return _dataset.ToListAsync(cancellationToken); }); + _retryPolicy.ExecuteAsync(() => _dataset.ToListAsync(cancellationToken)); public Task GetByIdAsync(string id) => _retryPolicy.ExecuteAsync(() => _dataset.FirstOrDefaultAsync(x => x.Id.Equals(id)));