generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Results controller implementation (#807)
* results endpoint skeleton * Base of Result Controller with Hapi Result * Starting tests * Results Controller Update with base unit tests * Update EtorDomain with Results conrtroller * hapiResult initial logic (#806) * Update EtorDomain with a portion of result handling - Start the ResultsResponse object - Update EtorDomainRegistration to handle parsing results * Base refactor message typing interface * Remove missed merge conflicts * Fix spacing * Remove unnecessary field (patient id) * Fix ResultResponse to remove PatientId * Remove patient id from ResultMock * Update test coverage to fix missing/broken tests for the following: - EtorDomainRegistrationTest with result handling - SendResultUseCaseTest with Result Mocking extra non-existent Patient Id - ReportStreamResultSenderTest with Result Mocking extra non-existent Patient Id * Register Results controller in etor DomainRegistration * Fix CI tabbing * ignore java version file * Remove java version file * Add ResultResponse test coverage and fix CI spotless issues * Add EtorDomainRegistrationTest code coverage for handleResults * Add SendResultUseCase to EtorDomainRegistration and add test cases * Add MessageSender registration for ReportStreamResultSender * Spotless CI check failures * Fixed build * Fixed test * Reverted refactoring OrderSender => MessageSender and added ResultSender * Remove unnecessary variable for error logs * Add Result e2e testing base * ResultTest e2e base * Add base e2e tests for Result API Endpoint * Remove unused variable * Fixed argument name * Another missed fix --------- Co-authored-by: jorge Lopez <[email protected]> Co-authored-by: saquino0827 <[email protected]> Co-authored-by: Jorge Lopez <[email protected]> Co-authored-by: Samuel Aquino <[email protected]>
- Loading branch information
1 parent
2f56178
commit 52d7aeb
Showing
25 changed files
with
451 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
e2e/src/test/groovy/gov/hhs/cdc/trustedintermediary/e2e/ResultTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package gov.hhs.cdc.trustedintermediary.e2e | ||
|
||
import spock.lang.Specification | ||
|
||
import java.nio.file.Files | ||
import java.nio.file.Path | ||
|
||
class ResultTest extends Specification { | ||
def resultClient = new EndpointClient("/v1/etor/results") | ||
def labResultJsonFileString = Files.readString(Path.of("../examples/MN/004_MN_ORU_R01_NBS_translation_from_initial_hl7_ingestion.fhir")) | ||
def submissionId = "submissionId" | ||
|
||
def setup() { | ||
SentPayloadReader.delete() | ||
} | ||
|
||
def "a result response is returned from the ETOR order endpoint"() { | ||
given: | ||
def expectedFhirResourceId = "Bundle/1705511861639940150.e2c69100-24af-4bbd-86bf-2f29be816edf" | ||
|
||
when: | ||
def response = resultClient.submit(labResultJsonFileString, submissionId, true) | ||
def parsedJsonBody = JsonParsing.parseContent(response) | ||
|
||
then: | ||
response.getCode() == 200 | ||
parsedJsonBody.fhirResourceId == expectedFhirResourceId | ||
} | ||
|
||
// Will progress on these tests when sending data to RS | ||
// def "check that the rest of the message is unchanged except the parts we changed"() { | ||
// when: | ||
// resultClient.submit(labResultJsonFileString, submissionId, true) | ||
// def sentPayload = SentPayloadReader.read() | ||
// def parsedSentPayload = JsonParsing.parse(sentPayload) | ||
// def parsedLabResultJsonFile = JsonParsing.parse(labResultJsonFileString) | ||
// | ||
// then: | ||
// | ||
// parsedSentPayload == parsedLabResultJsonFile | ||
// } | ||
// | ||
// def "check that message type is converted to ORU_R01"() { | ||
// when: | ||
// resultClient.submit(labResultJsonFileString, submissionId, true) | ||
// def sentPayload = SentPayloadReader.read() | ||
// def parsedSentPayload = JsonParsing.parse(sentPayload) | ||
// | ||
// then: | ||
// //test that the MessageHeader's event is now an OML_O21 | ||
// parsedSentPayload.entry[0].resource.resourceType == "MessageHeader" | ||
// parsedSentPayload.entry[0].resource.eventCoding.code == "R01" | ||
// parsedSentPayload.entry[0].resource.eventCoding.display.contains("ORU") | ||
// } | ||
|
||
def "return a 400 response when request has unexpected format"() { | ||
given: | ||
def invalidJsonRequest = labResultJsonFileString.substring(1) | ||
|
||
when: | ||
def response = resultClient.submit(invalidJsonRequest, submissionId, true) | ||
def parsedJsonBody = JsonParsing.parseContent(response) | ||
|
||
then: | ||
response.getCode() == 400 | ||
!(parsedJsonBody.error as String).isEmpty() | ||
} | ||
|
||
def "return a 401 response when making an unauthenticated request"() { | ||
when: | ||
def response = resultClient.submit(labResultJsonFileString, submissionId, false) | ||
def parsedJsonBody = JsonParsing.parseContent(response) | ||
|
||
then: | ||
response.getCode() == 401 | ||
!(parsedJsonBody.error as String).isEmpty() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/messages/MessageSender.java
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/orders/OrderSender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package gov.hhs.cdc.trustedintermediary.etor.orders; | ||
|
||
import gov.hhs.cdc.trustedintermediary.etor.messages.UnableToSendMessageException; | ||
import java.util.Optional; | ||
|
||
/** Interface for sending a lab order. */ | ||
public interface OrderSender { | ||
Optional<String> send(Order<?> order) throws UnableToSendMessageException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,4 @@ public interface Result<T> { | |
T getUnderlyingResult(); | ||
|
||
String getFhirResourceId(); | ||
|
||
String getPatientId(); | ||
} |
29 changes: 29 additions & 0 deletions
29
etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/results/ResultController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package gov.hhs.cdc.trustedintermediary.etor.results; | ||
|
||
import gov.hhs.cdc.trustedintermediary.domainconnector.DomainRequest; | ||
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiResult; | ||
import gov.hhs.cdc.trustedintermediary.wrappers.FhirParseException; | ||
import gov.hhs.cdc.trustedintermediary.wrappers.HapiFhir; | ||
import gov.hhs.cdc.trustedintermediary.wrappers.Logger; | ||
import javax.inject.Inject; | ||
import org.hl7.fhir.r4.model.Bundle; | ||
|
||
public class ResultController { | ||
|
||
private static final ResultController INSTANCE = new ResultController(); | ||
@Inject HapiFhir fhir; | ||
@Inject Logger logger; | ||
|
||
private ResultController() {} | ||
|
||
public static ResultController getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
public Result<?> parseResults(DomainRequest request) throws FhirParseException { | ||
logger.logInfo("Parsing results"); | ||
var fhirBundle = fhir.parseResource(request.getBody(), Bundle.class); | ||
// ETOR Results metadata | ||
return new HapiResult(fhirBundle); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/results/ResultResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package gov.hhs.cdc.trustedintermediary.etor.results; | ||
|
||
public class ResultResponse { | ||
private String fhirResourceId; | ||
|
||
public ResultResponse(String fhirResourceId) { | ||
this.fhirResourceId = fhirResourceId; | ||
} | ||
|
||
public ResultResponse(Result<?> result) { | ||
this.fhirResourceId = result.getFhirResourceId(); | ||
} | ||
|
||
public String getFhirResourceId() { | ||
return fhirResourceId; | ||
} | ||
|
||
public void setFhirResourceId(final String fhirResourceId) { | ||
this.fhirResourceId = fhirResourceId; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/results/ResultSender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package gov.hhs.cdc.trustedintermediary.etor.results; | ||
|
||
import gov.hhs.cdc.trustedintermediary.etor.messages.UnableToSendMessageException; | ||
import java.util.Optional; | ||
|
||
/** Interface for sending a lab result. */ | ||
public interface ResultSender { | ||
Optional<String> send(Result<?> result) throws UnableToSendMessageException; | ||
} |
3 changes: 1 addition & 2 deletions
3
etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/results/SendResultUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/hapi/HapiResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package gov.hhs.cdc.trustedintermediary.external.hapi; | ||
|
||
import gov.hhs.cdc.trustedintermediary.etor.results.Result; | ||
import org.hl7.fhir.r4.model.Bundle; | ||
|
||
/** Filler concrete implementation of a {@link Result} using the Hapi FHIR library */ | ||
public class HapiResult implements Result<Bundle> { | ||
|
||
private final Bundle innerResult; | ||
|
||
public HapiResult(Bundle innerResult) { | ||
this.innerResult = innerResult; | ||
} | ||
|
||
@Override | ||
public Bundle getUnderlyingResult() { | ||
return innerResult; | ||
} | ||
|
||
@Override | ||
public String getFhirResourceId() { | ||
return innerResult.getId(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.