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

Story/1024/add new transformations #1068

Closed
wants to merge 162 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
f5e94fe
Refactored validation rule engine in preparation for tranformation en…
basiliskus Apr 23, 2024
28505a5
Fixed instantiation
basiliskus Apr 23, 2024
2c3f69d
Merge branch 'main' into story/1024/transformation-engine
basiliskus Apr 24, 2024
bdd568a
Refactored to make Rule interface more generic
basiliskus Apr 25, 2024
f65cede
Fixed tests
basiliskus Apr 25, 2024
0cf5640
Update transformation_definitions.json
luis-pabon-tf Apr 25, 2024
a08c687
Merge branch 'main' into story/1024/transformation-engine
basiliskus Apr 25, 2024
8631334
Added missing override tags
basiliskus Apr 25, 2024
6214e84
Fixed arg naming
basiliskus Apr 25, 2024
4756364
Use generics to deserialize correct type of Rule implementation
basiliskus Apr 25, 2024
1de28ef
Converted RuleEngine back into a singleton and added parameters
basiliskus Apr 26, 2024
5c8073b
Refactored to have a separate implementation for ValidationRuleEngine
basiliskus Apr 26, 2024
45a3bca
Refactored to pass TypeReference and fix mapping issue
basiliskus Apr 26, 2024
d5490e8
Added missing override tags
basiliskus Apr 26, 2024
8e7398c
Fixed tests in ValidationRuleEngineIntegrationTest
basiliskus Apr 26, 2024
dbd8043
Fixed more tests
basiliskus Apr 26, 2024
d399054
Removed transformation engine implementation to move into new PR
basiliskus Apr 26, 2024
24ae3d3
Added TransformationRuleEngine skeleton
basiliskus Apr 26, 2024
90698e4
Merge branch 'story/1024/transformation-engine' into story/1024/trans…
basiliskus Apr 26, 2024
0eb2682
Moved transformation engine files from refactoring PR
basiliskus Apr 26, 2024
a865999
Added actual transformation rules based on existing transformations
basiliskus Apr 29, 2024
76b7d82
Update ValidationRuleTest.groovy
luis-pabon-tf Apr 29, 2024
27ea75d
Update ValidationRuleEngineTest.groovy
luis-pabon-tf Apr 29, 2024
0f1b275
Update ValidationRuleEngine.java
luis-pabon-tf Apr 29, 2024
5acab7a
Update ValidationRuleEngineTest.groovy
luis-pabon-tf Apr 29, 2024
28b0d7a
Update ValidationRuleEngineTest.groovy
luis-pabon-tf Apr 29, 2024
1f57bb1
Update Rule loading to handle Path for flexibility
saquino0827 Apr 29, 2024
5d4dd9e
Merge branch 'story/1024/transformation-engine' of https://github.com…
saquino0827 Apr 29, 2024
34a2bf9
Fixed remaining test
basiliskus Apr 29, 2024
e137c1d
Fixed actual remaining test
basiliskus Apr 29, 2024
0fc78c5
Changed naming
basiliskus Apr 29, 2024
95d4b2d
Update ValidationRuleEngineTest.groovy
luis-pabon-tf Apr 29, 2024
a27a876
Merge branch 'story/1024/transformation-engine' of https://github.com…
luis-pabon-tf Apr 29, 2024
c0f0093
Added test coverage
basiliskus Apr 29, 2024
2a5f7ab
Updated javadocs
basiliskus Apr 29, 2024
3bc60fe
Merge branch 'story/1024/transformation-engine' into story/1024/trans…
basiliskus Apr 29, 2024
79705c7
Added CustomFhirTransformation interface
basiliskus Apr 29, 2024
4a5068d
Created trasnformation package and moved transformation engine files
basiliskus Apr 29, 2024
be631d7
Merge branch 'story/1024/transformation-engine' into story/1024/trans…
basiliskus Apr 29, 2024
643b314
Created trasnformation package and moved transformation engine files
basiliskus Apr 29, 2024
9fd6506
Added example for custom transform method for addEtorProcessingTag
basiliskus Apr 29, 2024
a3e9ddc
Move convertToOrder into the Custom FhirTransformation
saquino0827 Apr 29, 2024
2bd21c8
Changed implementation for rules implementation to inherit from Rule …
basiliskus Apr 29, 2024
6ba1943
Clean up
basiliskus Apr 29, 2024
da17647
Merge branch 'story/1024/transformation-engine' into story/1024/trans…
basiliskus Apr 29, 2024
2ee0505
Update transformation rule implementation
basiliskus Apr 29, 2024
70851c2
Added implementation for TransformationRuleEngine
basiliskus Apr 29, 2024
8597f88
Added flexibility to handle different rule types and added Transforma…
basiliskus Apr 29, 2024
d78d0ba
Updated todo comment with pending work
basiliskus Apr 29, 2024
a03dd0b
Added missing override tag
basiliskus Apr 29, 2024
4e44a3b
Merge branch 'story/1024/transformation-engine' into story/1024/trans…
basiliskus Apr 29, 2024
e9290aa
Create RuleTest.groovy
luis-pabon-tf Apr 30, 2024
7021d85
Update HapiMessageConverterHelper.java
luis-pabon-tf Apr 30, 2024
53445b3
Create addContactSectionToPatientResource.java
luis-pabon-tf Apr 30, 2024
db0cddf
Create convertToOmlOrder.java
luis-pabon-tf Apr 30, 2024
f8d91b1
Merge branch 'main' into story/1024/transformation-engine-implementation
luis-pabon-tf Apr 30, 2024
b3aeec9
Implemented custom method evaluation. Still need to test
basiliskus Apr 30, 2024
4392b27
Added failing integration test for TransformationRuleEngine
basiliskus Apr 30, 2024
369d810
Merge branch 'story/1024/transformation-engine' into story/1024/trans…
basiliskus Apr 30, 2024
0ab622e
Fixed TransformationRule mapping
basiliskus Apr 30, 2024
63518ba
Fixed custom method evaluation method
basiliskus Apr 30, 2024
9e49e24
Added better assertion for integration test
basiliskus Apr 30, 2024
79bd441
Updated transformation definitions
basiliskus Apr 30, 2024
a46ac92
Fixed error message
basiliskus Apr 30, 2024
15c59c2
Updated CustomFhirTransformation interface to return void as we don't…
basiliskus Apr 30, 2024
a9867af
Moved methods to more appropiate place
basiliskus Apr 30, 2024
8d88fd1
Fixed import
basiliskus Apr 30, 2024
ab25de9
Using existing method and turning it static
basiliskus Apr 30, 2024
a0df1ed
Replaced OrderConverter with transformation engine
basiliskus Apr 30, 2024
614e102
Replaced OrderConverter and ResultConverter with transformation engine
basiliskus Apr 30, 2024
14ec0c2
Added back internal metadata logging
basiliskus Apr 30, 2024
fd31ad5
Reusing static methods in HapiOrderConverter
basiliskus Apr 30, 2024
ae1f2d8
Renamed method with more appropiate name
basiliskus Apr 30, 2024
b105222
Fixed test for ConvertAndSendDemographicsUsecase
basiliskus May 1, 2024
511ec68
Start test coverage for existing transformation rules
saquino0827 May 1, 2024
728fcb0
Merge branch 'story/1024/transformation-engine-implementation' of htt…
saquino0827 May 1, 2024
3b6aae1
Fixed tests for SendOrderUseCase and renamed vartiables for consistency
basiliskus May 1, 2024
775d8a6
Fix PartnerMetadataOrchestratorTest
saquino0827 May 1, 2024
c999565
Removed unused HapiResultConverterTest
basiliskus May 1, 2024
fc2b07a
removed unused import
basiliskus May 1, 2024
52c7dcf
Add baseline scenarios for TransformationRuleEngineIntegrationTest
saquino0827 May 1, 2024
edee43b
Merge branch 'story/1024/transformation-engine-implementation' of htt…
saquino0827 May 1, 2024
a0ee472
Removed convertDemographicsToOrder rule while figuring out the condit…
basiliskus May 1, 2024
b43b99a
Start updating HapiOrderConverterTest
saquino0827 May 1, 2024
d32ae21
Merge branch 'story/1024/transformation-engine-implementation' of htt…
saquino0827 May 1, 2024
85efd28
Fixed HapiOrderConverter tests for convertDemographicsToOrder
basiliskus May 1, 2024
3151384
Update HapiOrderConverterTest.groovy
luis-pabon-tf May 1, 2024
939495b
Added missing MetricMetadata mock to fix test
basiliskus May 1, 2024
f32da54
Merge branch 'story/1024/transformation-engine-implementation' of git…
basiliskus May 1, 2024
7a65754
Update HapiOrderConverterTest.groovy
luis-pabon-tf May 1, 2024
ecbd9e2
Fixed loading of resource definitions file in engine
basiliskus May 1, 2024
fd76553
Fixed path reference to custom transformation classes
basiliskus May 1, 2024
9831637
Ignoring test for now
basiliskus May 1, 2024
60c046a
Moved tests to correct location
basiliskus May 1, 2024
4379229
Added empty tests to work on
basiliskus May 1, 2024
e201d83
Added back demographics transformation rule with fhirpath condition
basiliskus May 1, 2024
4130d72
Fixed names
basiliskus May 1, 2024
ea8ab68
Fixed demographics condition and e2e test
basiliskus May 1, 2024
d2521c1
refactoring: helper method -> applyTransoformation
jorg3lopez May 2, 2024
2bf76d7
refactor: remove assert and add custom exception handling
jorg3lopez May 2, 2024
e863469
Added helper static methods to get root path for the project
basiliskus May 2, 2024
f0c2b77
Missed in last commit
basiliskus May 2, 2024
4ddce46
Extracted helper method to create a fhir bundle
basiliskus May 2, 2024
f536a69
Refactoring: runRules continues to run rules if one fails
jorg3lopez May 2, 2024
b1ea6fc
Update TransformationRuleTest with basic getter/setter test
saquino0827 May 2, 2024
b79279b
Merge branch 'story/1024/transformation-engine-implementation' of htt…
saquino0827 May 2, 2024
1c9eb48
Update TransformationRuleEngineTest.groovy
luis-pabon-tf May 2, 2024
42755db
Merge branch 'story/1024/transformation-engine-implementation' of htt…
luis-pabon-tf May 2, 2024
20102de
WIP: fixing build for others
basiliskus May 2, 2024
9d8b27c
Added info logging when applying rule
basiliskus May 2, 2024
479f0cc
refactoring: create a classCache and separate responsibilities in loa…
jorg3lopez May 2, 2024
cddb40f
Update TransformationRuleEngineTest.groovy
luis-pabon-tf May 2, 2024
2815f4a
Merge branch 'story/1024/transformation-engine-implementation' of htt…
luis-pabon-tf May 2, 2024
8c8f750
Remove a duplicate for loop
luis-pabon-tf May 2, 2024
e64d775
refactoring: detail exception handling for TransformationRule::applyT…
jorg3lopez May 2, 2024
c9614e7
Added integration test + cleanup and refactoring
basiliskus May 2, 2024
043d863
refactoring: loadClassFromCache and added helper function
jorg3lopez May 2, 2024
89a01d0
Update TransformationRuleEngineIntegrationTest.groovy
luis-pabon-tf May 2, 2024
8d52ed3
Merge branch 'story/1024/transformation-engine-implementation' of htt…
luis-pabon-tf May 2, 2024
7947e86
Added integration test to match each rule to a test file and run it
basiliskus May 2, 2024
e461d56
Update TransformationRuleEngineIntegrationTest.groovy
luis-pabon-tf May 2, 2024
3bce6fc
Revert "Added integration test to match each rule to a test file and …
basiliskus May 2, 2024
6ec64aa
Merge branch 'story/1024/transformation-engine-implementation' of git…
basiliskus May 2, 2024
c3bb3ea
Fixed issues with merge and improved test
basiliskus May 2, 2024
78b3360
Update TransformationRuleEngineIntegrationTest.groovy
luis-pabon-tf May 2, 2024
b274082
Merge branch 'story/1024/transformation-engine-implementation' of htt…
luis-pabon-tf May 2, 2024
9b22430
Added tests for getRuleByName implementation
basiliskus May 2, 2024
f722ad6
Removed unused code
basiliskus May 2, 2024
386849b
Fixed integration test
basiliskus May 2, 2024
2a06236
refactor: deleted redundant if statement
jorg3lopez May 3, 2024
b75a8e3
refactor: don't stop transormation if a rule fails
jorg3lopez May 3, 2024
d1664b5
revert try catch, there is no excepton thrown when rules fail
jorg3lopez May 3, 2024
46bd8ef
Refactor: use ConcurrentHashMap
jorg3lopez May 3, 2024
1ed0fe3
Merge branch 'main' into story/1024/transformation-engine-implementation
basiliskus May 3, 2024
7d68b8d
Added double-checked locking with comment explaining it
luis-pabon-tf May 3, 2024
9301667
Merged with main
basiliskus May 3, 2024
cd22fb9
Merge branch 'story/1024/transformation-engine-implementation' of git…
basiliskus May 3, 2024
1c49e22
Merge branch 'main' into story/1024/transformation-engine-implementation
basiliskus May 3, 2024
0e4bb53
Getting new instance of the custom class using the interface
basiliskus May 3, 2024
9715088
Update TransformationRule exception being thrown
saquino0827 May 3, 2024
88eb52a
Merge branch 'story/1024/transformation-engine-implementation' of htt…
saquino0827 May 3, 2024
3c092dc
Refactored integration tests and removed test that is already covered
basiliskus May 3, 2024
e271ce2
Added missing override tag
basiliskus May 3, 2024
1281790
Fixed test helper logic
basiliskus May 3, 2024
ef2ab1b
Ignoring demographics transformation for now
basiliskus May 3, 2024
d0c5549
Removed custom exception constructor overload
basiliskus May 3, 2024
7ce3dd3
Update TransformationRuleTest coverage
saquino0827 May 3, 2024
5cee63e
Remove duplicate unit tests
saquino0827 May 3, 2024
83b4ddb
Update HapiOrderConverterTest syntax
saquino0827 May 3, 2024
4727eef
Merge branch 'story/1024/transformation-engine-implementation' of htt…
saquino0827 May 3, 2024
9729b86
Assert state before transformation in integration tests + add functio…
basiliskus May 3, 2024
02ef099
Merge branch 'story/1024/transformation-engine-implementation' of git…
basiliskus May 3, 2024
f511a5d
Update TransformationRuleEngine.java
luis-pabon-tf May 3, 2024
639ad9d
Refactored to use lookup table instead of switch statement
basiliskus May 3, 2024
3de164a
Added integration test to make sure consutive transformations don't i…
basiliskus May 3, 2024
17d7445
Merge branch 'main' into story/1024/transformation-engine-implementation
luis-pabon-tf May 6, 2024
db3c44b
Basic implementation of sending facility value set
luis-pabon-tf May 6, 2024
ffd54ea
Update TransformationRuleEngineIntegrationTest.groovy
luis-pabon-tf May 6, 2024
f45701a
Update the new rule
luis-pabon-tf May 7, 2024
4b1a825
Update TransformationRuleEngineIntegrationTest.groovy
luis-pabon-tf May 7, 2024
46306b1
Reverting adding lookup table since it obscures details when test fails
basiliskus May 7, 2024
7ebbb40
Merge branch 'main' into story/1024/transformation-engine-implementation
basiliskus May 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,25 @@ class DemographicsTest extends Specification {
parsedJsonBody.patientId == expectedPatientId
}

def "payload file check"() {
when:
def response = demographicsClient.submit(newbornPatientJsonFileString, true)
def parsedResponseBody = JsonParser.parseContent(response)
def sentPayload = SentPayloadReader.read()
def parsedSentPayload = JsonParser.parse(sentPayload)

then:
response.getCode() == 200
parsedSentPayload.entry[0].resource.resourceType == "MessageHeader"
parsedSentPayload.entry[2].resource.resourceType == "ServiceRequest"

parsedSentPayload.entry[1].resource.resourceType == "Patient"
parsedSentPayload.entry[1].resource.id == "infant-twin-1"

parsedSentPayload.entry[1].resource.identifier[1].value == parsedResponseBody.patientId //the second (index 1) identifier so happens to be the MRN
parsedSentPayload.resourceType + "/" + parsedSentPayload.id == parsedResponseBody.fhirResourceId
}
// todo: ignoring while figuring out how to filter the demographics example
// def "payload file check"() {
// when:
// def response = demographicsClient.submit(newbornPatientJsonFileString, true)
// def parsedResponseBody = JsonParser.parseContent(response)
// def sentPayload = SentPayloadReader.read()
// def parsedSentPayload = JsonParser.parse(sentPayload)
//
// then:
// response.getCode() == 200
// parsedSentPayload.entry[0].resource.resourceType == "MessageHeader"
// parsedSentPayload.entry[2].resource.resourceType == "ServiceRequest"
//
// parsedSentPayload.entry[1].resource.resourceType == "Patient"
// parsedSentPayload.entry[1].resource.id == "infant-twin-1"
//
// parsedSentPayload.entry[1].resource.identifier[1].value == parsedResponseBody.patientId //the second (index 1) identifier so happens to be the MRN
// parsedSentPayload.resourceType + "/" + parsedSentPayload.id == parsedResponseBody.fhirResourceId
// }

def "return a 400 response when request has unexpected format"() {
given:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,24 @@
import gov.hhs.cdc.trustedintermediary.etor.operationoutcomes.FhirMetadata;
import gov.hhs.cdc.trustedintermediary.etor.orders.Order;
import gov.hhs.cdc.trustedintermediary.etor.orders.OrderController;
import gov.hhs.cdc.trustedintermediary.etor.orders.OrderConverter;
import gov.hhs.cdc.trustedintermediary.etor.orders.OrderResponse;
import gov.hhs.cdc.trustedintermediary.etor.orders.OrderSender;
import gov.hhs.cdc.trustedintermediary.etor.orders.SendOrderUseCase;
import gov.hhs.cdc.trustedintermediary.etor.results.Result;
import gov.hhs.cdc.trustedintermediary.etor.results.ResultController;
import gov.hhs.cdc.trustedintermediary.etor.results.ResultConverter;
import gov.hhs.cdc.trustedintermediary.etor.results.ResultResponse;
import gov.hhs.cdc.trustedintermediary.etor.results.ResultSender;
import gov.hhs.cdc.trustedintermediary.etor.results.SendResultUseCase;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.RuleLoader;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation.TransformationRuleEngine;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.validation.ValidationRuleEngine;
import gov.hhs.cdc.trustedintermediary.external.database.DatabaseMessageLinkStorage;
import gov.hhs.cdc.trustedintermediary.external.database.DatabasePartnerMetadataStorage;
import gov.hhs.cdc.trustedintermediary.external.database.DbDao;
import gov.hhs.cdc.trustedintermediary.external.database.PostgresDao;
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiMessageConverterHelper;
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiMessageHelper;
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiOrderConverter;
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiPartnerMetadataConverter;
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiResultConverter;
import gov.hhs.cdc.trustedintermediary.external.localfile.FileMessageLinkStorage;
import gov.hhs.cdc.trustedintermediary.external.localfile.FilePartnerMetadataStorage;
import gov.hhs.cdc.trustedintermediary.external.localfile.MockRSEndpointClient;
Expand Down Expand Up @@ -111,12 +108,10 @@ public Map<HttpEndpoint, Function<DomainRequest, DomainResponse>> domainRegistra
ConvertAndSendDemographicsUsecase.class,
ConvertAndSendDemographicsUsecase.getInstance());
// Orders
ApplicationContext.register(OrderConverter.class, HapiOrderConverter.getInstance());
ApplicationContext.register(OrderController.class, OrderController.getInstance());
ApplicationContext.register(SendOrderUseCase.class, SendOrderUseCase.getInstance());
ApplicationContext.register(OrderSender.class, ReportStreamOrderSender.getInstance());
// Results
ApplicationContext.register(ResultConverter.class, HapiResultConverter.getInstance());
ApplicationContext.register(ResultController.class, ResultController.getInstance());
ApplicationContext.register(SendResultUseCase.class, SendResultUseCase.getInstance());
ApplicationContext.register(ResultSender.class, ReportStreamResultSender.getInstance());
Expand All @@ -136,6 +131,9 @@ public Map<HttpEndpoint, Function<DomainRequest, DomainResponse>> domainRegistra
ApplicationContext.register(
ValidationRuleEngine.class,
ValidationRuleEngine.getInstance("validation_definitions.json"));
ApplicationContext.register(
TransformationRuleEngine.class,
TransformationRuleEngine.getInstance("transformation_definitions.json"));

ApplicationContext.register(SendMessageHelper.class, SendMessageHelper.getInstance());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package gov.hhs.cdc.trustedintermediary.etor.demographics;

import gov.hhs.cdc.trustedintermediary.etor.messages.UnableToSendMessageException;
import gov.hhs.cdc.trustedintermediary.etor.orders.Order;
import gov.hhs.cdc.trustedintermediary.etor.orders.OrderConverter;
import gov.hhs.cdc.trustedintermediary.etor.orders.OrderSender;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation.TransformationRuleEngine;
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiOrder;
import javax.inject.Inject;
import org.hl7.fhir.r4.model.Bundle;

/**
* The overall logic that handles receiving patient demographics, converting it to a lab order, and
Expand All @@ -15,7 +16,7 @@ public class ConvertAndSendDemographicsUsecase {
private static final ConvertAndSendDemographicsUsecase INSTANCE =
new ConvertAndSendDemographicsUsecase();

@Inject OrderConverter converter;
@Inject TransformationRuleEngine transformationEngine;

@Inject OrderSender sender;

Expand All @@ -26,7 +27,8 @@ public static ConvertAndSendDemographicsUsecase getInstance() {
private ConvertAndSendDemographicsUsecase() {}

public void convertAndSend(Demographics<?> demographics) throws UnableToSendMessageException {
Order<?> order = converter.convertToOrder(demographics);
transformationEngine.runRules(demographics);
var order = new HapiOrder((Bundle) demographics.getUnderlyingResource());
sender.send(order);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
import gov.hhs.cdc.trustedintermediary.etor.messages.SendMessageHelper;
import gov.hhs.cdc.trustedintermediary.etor.messages.SendMessageUseCase;
import gov.hhs.cdc.trustedintermediary.etor.messages.UnableToSendMessageException;
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetadataStep;
import gov.hhs.cdc.trustedintermediary.etor.metadata.partner.PartnerMetadata;
import gov.hhs.cdc.trustedintermediary.etor.metadata.partner.PartnerMetadataMessageType;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation.TransformationRuleEngine;
import gov.hhs.cdc.trustedintermediary.wrappers.Logger;
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetadata;
import javax.inject.Inject;

/** The overall logic to receive, convert to OML, and subsequently send a lab order. */
public class SendOrderUseCase implements SendMessageUseCase<Order<?>> {
private static final SendOrderUseCase INSTANCE = new SendOrderUseCase();
@Inject OrderConverter converter;
@Inject TransformationRuleEngine transformationEngine;
@Inject OrderSender sender;
@Inject MetricMetadata metadata;
@Inject SendMessageHelper sendMessageHelper;
Expand Down Expand Up @@ -42,18 +42,9 @@ public void convertAndSend(final Order<?> order, String receivedSubmissionId)

sendMessageHelper.savePartnerMetadataForReceivedMessage(partnerMetadata);

var omlOrder = converter.convertToOmlOrder(order);
metadata.put(order.getFhirResourceId(), EtorMetadataStep.ORDER_CONVERTED_TO_OML);
transformationEngine.runRules(order);

omlOrder = converter.addContactSectionToPatientResource(omlOrder);
metadata.put(order.getFhirResourceId(), EtorMetadataStep.CONTACT_SECTION_ADDED_TO_PATIENT);

omlOrder = converter.addEtorProcessingTag(omlOrder);
metadata.put(
order.getFhirResourceId(),
EtorMetadataStep.ETOR_PROCESSING_TAG_ADDED_TO_MESSAGE_HEADER);

String outboundReportId = sender.send(omlOrder).orElse(null);
String outboundReportId = sender.send(order).orElse(null);
logger.logInfo("Sent order reportId: {}", outboundReportId);

sendMessageHelper.linkMessage(receivedSubmissionId);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@
import gov.hhs.cdc.trustedintermediary.etor.messages.SendMessageHelper;
import gov.hhs.cdc.trustedintermediary.etor.messages.SendMessageUseCase;
import gov.hhs.cdc.trustedintermediary.etor.messages.UnableToSendMessageException;
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetadataStep;
import gov.hhs.cdc.trustedintermediary.etor.metadata.partner.PartnerMetadata;
import gov.hhs.cdc.trustedintermediary.etor.metadata.partner.PartnerMetadataMessageType;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation.TransformationRuleEngine;
import gov.hhs.cdc.trustedintermediary.wrappers.Logger;
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetadata;
import javax.inject.Inject;

/** Use case for converting and sending a lab result message. */
public class SendResultUseCase implements SendMessageUseCase<Result<?>> {
private static final SendResultUseCase INSTANCE = new SendResultUseCase();

@Inject ResultConverter converter;
@Inject TransformationRuleEngine transformationEngine;
@Inject ResultSender sender;
@Inject MetricMetadata metadata;

@Inject SendMessageHelper sendMessageHelper;

Expand Down Expand Up @@ -45,12 +43,9 @@ public void convertAndSend(Result<?> result, String receivedSubmissionId)

sendMessageHelper.savePartnerMetadataForReceivedMessage(partnerMetadata);

var convertedResult = converter.addEtorProcessingTag(result);
metadata.put(
result.getFhirResourceId(),
EtorMetadataStep.ETOR_PROCESSING_TAG_ADDED_TO_MESSAGE_HEADER);
transformationEngine.runRules(result);

String outboundReportId = sender.send(convertedResult).orElse(null);
String outboundReportId = sender.send(result).orElse(null);
logger.logInfo("Sent result reportId: {}", outboundReportId);

sendMessageHelper.linkMessage(receivedSubmissionId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
* message, conditions to determine if the rule should run, and actions to run in case the condition
* is met.
*/
public class Rule {
public class Rule<T> {

protected final Logger logger = ApplicationContext.getImplementation(Logger.class);
protected final HapiFhir fhirEngine = ApplicationContext.getImplementation(HapiFhir.class);
private String name;
private String description;
private String message;
private List<String> conditions;
private List<String> rules;
private List<T> rules;

/**
* Do not delete this constructor! It is used for JSON deserialization when loading rules from a
Expand All @@ -31,7 +31,7 @@ public Rule(
String ruleDescription,
String ruleMessage,
List<String> ruleConditions,
List<String> ruleActions) {
List<T> ruleActions) {
name = ruleName;
description = ruleDescription;
message = ruleMessage;
Expand All @@ -55,7 +55,7 @@ public List<String> getConditions() {
return conditions;
}

public List<String> getRules() {
public List<T> getRules() {
return rules;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ public interface RuleEngine {
void ensureRulesLoaded() throws RuleLoaderException;

void runRules(FhirResource<?> resource);

Rule<?> getRuleByName(String ruleName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand All @@ -26,17 +24,17 @@ public static RuleLoader getInstance() {
return INSTANCE;
}

public <T> List<T> loadRules(Path path, TypeReference<Map<String, List<T>>> typeReference)
public <T> List<T> loadRules(
InputStream ruleDefinitionStream, TypeReference<Map<String, List<T>>> typeReference)
throws RuleLoaderException {
try (InputStream ruleDefinitionStream = Files.newInputStream(path)) {
try {
var rulesString =
new String(ruleDefinitionStream.readAllBytes(), StandardCharsets.UTF_8);
Map<String, List<T>> jsonObj =
formatter.convertJsonToObject(rulesString, typeReference);
return jsonObj.getOrDefault("definitions", Collections.emptyList());
} catch (IOException | FormatterProcessingException e) {
throw new RuleLoaderException(
"Failed to load rules definitions for provided path: " + path, e);
throw new RuleLoaderException("Failed to load rules definitions", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

/** Custom exception class use to catch RuleLoader exceptions */
public class RuleLoaderException extends Exception {

public RuleLoaderException(String message, Throwable cause) {
super(message, cause);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation;

import gov.hhs.cdc.trustedintermediary.etor.ruleengine.FhirResource;
import java.util.Map;

public interface CustomFhirTransformation {
void transform(FhirResource<?> resource, Map<String, String> args);
}
Loading
Loading