Skip to content

Commit

Permalink
Fix transform runtime bug
Browse files Browse the repository at this point in the history
  • Loading branch information
james-cockayne-ad committed Jan 23, 2025
1 parent 301e54e commit c053e66
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions OmopTransformer/Transformation/RecordTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,29 @@ namespace OmopTransformer.Transformation;
internal class RecordTransformer : IRecordTransformer
{
private readonly ILogger<RecordTransformer> _logger;
private readonly Icd10Resolver _cd10Resolver;
private readonly Opcs4Resolver _opcs4Resolver;
private readonly ConceptResolver _resolver;
private readonly Icdo3Resolver _icdo3Resolver;
private readonly MeasurementMapsToValueResolver _relationshipResolver;
private readonly Icd10NonStandardResolver _icd10NonStandardResolver;
private readonly Icd10StandardResolver _icd10StandardResolver;

public RecordTransformer(
ILogger<RecordTransformer> logger,
Icd10Resolver cd10Resolver,
ConceptResolver resolver,
Opcs4Resolver opcs4Resolver,
Icdo3Resolver icdo3Resolver,
MeasurementMapsToValueResolver relationshipResolver)
MeasurementMapsToValueResolver relationshipResolver,
Icd10NonStandardResolver icd10NonStandardResolver,
Icd10StandardResolver icd10StandardResolver)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_cd10Resolver = cd10Resolver;
_resolver = resolver;
_opcs4Resolver = opcs4Resolver;
_icdo3Resolver = icdo3Resolver;
_relationshipResolver = relationshipResolver;
_icd10NonStandardResolver = icd10NonStandardResolver;
_icd10StandardResolver = icd10StandardResolver;
}

public void Transform<T>(IOmopRecord<T> record)
Expand Down Expand Up @@ -180,10 +183,11 @@ private void TransformSelector<T>(IOmopRecord<T> record, TransformAttribute tran
transformAttribute
.Value
.Select(argumentName => originType.GetProperty(argumentName)!.GetValue(originData))
.Concat(firstConstructorTypes.Any(type => type == typeof(Icd10Resolver)) ? new[] { _cd10Resolver } : new List<object>())
.Concat(firstConstructorTypes.Any(type => type == typeof(Opcs4Resolver)) ? new[] { _opcs4Resolver } : new List<object>())
.Concat(firstConstructorTypes.Any(type => type == typeof(Icdo3Resolver)) ? new[] { _icdo3Resolver } : new List<object>())
.Concat(firstConstructorTypes.Any(type => type == typeof(ConceptResolver)) ? new[] { _resolver } : new List<object>())
.Concat(firstConstructorTypes.Any(type => type == typeof(Icd10NonStandardResolver)) ? new [] { _icd10NonStandardResolver } : new List<object>())
.Concat(firstConstructorTypes.Any(type => type == typeof(Icd10StandardResolver)) ? new[] { _icd10StandardResolver } : new List<object>())
.Concat(firstConstructorTypes.Any(type => type == typeof(MeasurementMapsToValueResolver)) ? new[] { _relationshipResolver } : new List<object>())
.ToArray();

Expand Down
2 changes: 1 addition & 1 deletion OmopTransformerTests/Transformation/TransformationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void TestTransformation()

var logger = Substitute.For<ILogger<RecordTransformer>>();

new RecordTransformer(logger, null!, null!, null!, null!, null!).Transform(testConcept);
new RecordTransformer(logger, null!, null!, null!, null!, null!, null!).Transform(testConcept);

Assert.AreEqual(testConcept.Text, "hello world");
Assert.AreEqual(testConcept.JoinedText, "line 1\r\nline 2");
Expand Down

0 comments on commit c053e66

Please sign in to comment.