Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
Signed-off-by: Lillie Dae <lillie.dae@answerdigital.com>
  • Loading branch information
lillie-dae committed Nov 20, 2023
1 parent b1f6c49 commit 9539f18
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
27 changes: 24 additions & 3 deletions src/Api/Hl7ApplicationConfigEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ public class Hl7ApplicationConfigEntity : MongoDBEntityBase
/// Gets or sets the sending identifier.
/// </summary>
[JsonProperty("sending_identifier")]
public KeyValuePair<string, string> SendingId { get; set; }
public StringKeyValuePair SendingId { get; set; } = new();

/// <summary>
/// Gets or sets the data link.
/// Value is either PatientId or StudyInstanceUid
/// </summary>
[JsonProperty("data_link")]
public KeyValuePair<string, DataLinkType> DataLink { get; set; }
public DataKeyValuePair DataLink { get; set; } = new();

/// <summary>
/// Gets or sets the data mapping.
/// Value is a DICOM Tag
/// </summary>
[JsonProperty("data_mapping")]
public Dictionary<string, string> DataMapping { get; set; } = new();
public List<StringKeyValuePair> DataMapping { get; set; } = new();

public IEnumerable<string> Validate()

Check warning on line 50 in src/Api/Hl7ApplicationConfigEntity.cs

View workflow job for this annotation

GitHub Actions / unit-test

Refactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.
{
Expand Down Expand Up @@ -95,6 +95,27 @@ public override string ToString()
}
}

//string key, string value
public class StringKeyValuePair : IKeyValuePair<string, string>
{
[Key]
public string Key { get; set; } = string.Empty;
public string Value { get; set; } = string.Empty;
}

public class DataKeyValuePair : IKeyValuePair<string, DataLinkType>
{
[Key]
public string Key { get; set; } = string.Empty;
public DataLinkType Value { get; set; }
}

public interface IKeyValuePair<TKey, TValue>
{
public TKey Key { get; set; }
public TValue Value { get; set; }
}

public enum DataLinkType
{
PatientId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ internal class Hl7ApplicationConfigConfiguration : IEntityTypeConfiguration<Hl7A
public void Configure(EntityTypeBuilder<Hl7ApplicationConfigEntity> 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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Hl7ApplicationConfigRepository(ILogger<Hl7ApplicationConfigRepository> lo
}

public Task<List<Hl7ApplicationConfigEntity>> GetAllAsync(CancellationToken cancellationToken = default) =>
_retryPolicy.ExecuteAsync(() => { return _dataset.ToListAsync(cancellationToken); });
_retryPolicy.ExecuteAsync(() => _dataset.ToListAsync(cancellationToken));

public Task<Hl7ApplicationConfigEntity?> GetByIdAsync(string id) =>
_retryPolicy.ExecuteAsync(() => _dataset.FirstOrDefaultAsync(x => x.Id.Equals(id)));
Expand Down

0 comments on commit 9539f18

Please sign in to comment.