Skip to content
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

Transformation Engine To Use Map<String,Object> As Args #1362

Merged
merged 27 commits into from
Oct 1, 2024

Conversation

jorg3lopez
Copy link
Contributor

@jorg3lopez jorg3lopez commented Sep 26, 2024

Complex Map As Args For Transformation Engine

This PR adds the logic for the trasnformation engine to use a Map<String,Object> intead of a Map<String,String> allowing for more flexibility when passing parameters when using the transformation_definitions.json file.

Issue

#1366

Checklist

  • All tests pass

Note: You may remove items that are not applicable

Map<String,String> args -> Map<String,Object> args
CustomFhirTransformation uses Map<String,Objcet> in signature
HappyPathCustomTransformationMockClass uses Map<String,Object>
TransformationRule expects a Map<String,Object>
if (alternateId != null) {
updateAlternateCodingId(allCodings, alternateId);
}
});
}

// Returns null if it is not a String
private String castToString(Object obj) {
return obj instanceof String ? (String) obj : null;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, do we want this to skip or pass an empty string ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we control the values passed in args, I think it's safe to assume they will be there and have the correct type. If that's not the case, we need to know so we can fix it, so it's better to let it fail

@jorg3lopez jorg3lopez marked this pull request as ready for review September 26, 2024 19:40
Copy link
Contributor

@basiliskus basiliskus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments. It's actually just one comment but in multiple places. Otherwise looks good to me

if (alternateId != null) {
updateAlternateCodingId(allCodings, alternateId);
}
});
}

// Returns null if it is not a String
private String castToString(Object obj) {
return obj instanceof String ? (String) obj : null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we control the values passed in args, I think it's safe to assume they will be there and have the correct type. If that's not the case, we need to know so we can fix it, so it's better to let it fail

jorg3lopez and others added 10 commits September 27, 2024 13:40
> When message has a mappable local observation code in OBX-3.4/5/6, should add the mapped code to OBX-3.1/2/3
> When message has an unmapped local observation code in OBX-3.4/5/6, no mapping should occur and a warning should be logged
> added createBundleWithObservation helper method
> added createCoding helper method
added createBundleWithMultipleCodings helper method
refactored When message has a mappable local observation code in OBX-3.4/5/6 and other content in OBX3-1/2/3, no mapping should occur unit test
refactored When message has a LOINC code, no mapping should occur unit test
added createBundleWithNoSystem helper method
refactored When no coding system, no mapping should occur
added createBundleWithNoExtension helper method
refactored When no coding extension, no mapping should occur unit test
added createBundleWithNoIdentifier helper method
refactored When no observation identifier, the observation does not change unit test
@jorg3lopez
Copy link
Contributor Author

Since local code to LOINC or PLT code PR was merged, I had to refactor that transformation class (MapLocalObservationCodes) and it's test cases.

Copy link
Contributor

@basiliskus basiliskus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one suggestion, otherwise looks good!

Copy link

sonarqubecloud bot commented Oct 1, 2024

@jorg3lopez jorg3lopez merged commit 3d114c0 into main Oct 1, 2024
16 checks passed
@jorg3lopez jorg3lopez deleted the feature/transformation-engine/map-object-args branch October 1, 2024 06:41
tjohnson7021 pushed a commit that referenced this pull request Oct 17, 2024
* changes:
Map<String,String> args -> Map<String,Object> args
CustomFhirTransformation uses Map<String,Objcet> in signature
HappyPathCustomTransformationMockClass uses Map<String,Object>
TransformationRule expects a Map<String,Object>

* unit test:
RemoveObservationRequests has invalid args

* rename test case

* args.get('name') not a string test case for UpdateSendingFacilityNamespaceTest

* added casting of Object to test cases in UpdateSendingFacilityNamespaceTest

* unit test when args.get('name') is not a string, for UpdateReceivingApplicationNamespaceTest

* added (Object) casting to test case in UpdateReceivingApplicationNamespaceTest

* null check for RemoveObservationrequests

* NoExceptionThrown when args.get('universalServiceIdentifier') is not a string

* null check for receiving application and args.get('name') in UpdateReceivingApplicationNamespace

* edited unit test: receiving application not in bundle, from UpdateReceivingApplicationNamespaceTest

* Map<String, String> -> Map<String, Object> for MapLocalObservationCodes

* refactored unit tests:
> When message has a mappable local observation code in OBX-3.4/5/6, should add the mapped code to OBX-3.1/2/3
> When message has an unmapped local observation code in OBX-3.4/5/6, no mapping should occur and a warning should be logged
> added createBundleWithObservation helper method
> added createCoding helper method

* refactored MapLocalObservationcodesTest:
added createBundleWithMultipleCodings helper method
refactored When message has a mappable local observation code in OBX-3.4/5/6 and other content in OBX3-1/2/3, no mapping should occur unit test

* refactored MapLocalObservationcodesTest:
refactored When message has a LOINC code, no mapping should occur unit test

* refactored MapLocalObservationCodesTest:
added createBundleWithNoSystem helper method
refactored When no coding system, no mapping should occur

* refactored MapLocalObservationCodesTest:
added createBundleWithNoExtension helper method
refactored When no coding extension, no mapping should occur unit test

* refactored MapLocalObservationCodesTest:
added createBundleWithNoIdentifier helper method
refactored When no observation identifier, the observation does not change unit test

* deleted unused helper method

* deleted comment

* remove null check when casthing to string

* remove casting method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants