Skip to content

Commit

Permalink
Merge branch 'story/672/marshal-results-into-fhir' into story-672-db_…
Browse files Browse the repository at this point in the history
…extra_fields
  • Loading branch information
halprin committed Jan 9, 2024
2 parents 4631b96 + 269dd5c commit 1377721
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {
testImplementation 'org.apache.groovy:groovy:4.0.17'
testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0'
testImplementation 'com.openpojo:openpojo:0.9.1'
testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.15.5'
testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.15.6'
}

jacocoTestCoverageVerification {
Expand Down
2 changes: 1 addition & 1 deletion etor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {
testImplementation 'org.apache.groovy:groovy:4.0.17'
testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0'
testImplementation 'com.openpojo:openpojo:0.9.1'
testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.15.5'
testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.15.6'
}

jacocoTestCoverageVerification {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import gov.hhs.cdc.trustedintermediary.etor.metadata.PartnerMetadataException;
import gov.hhs.cdc.trustedintermediary.etor.metadata.PartnerMetadataOrchestrator;
import gov.hhs.cdc.trustedintermediary.etor.metadata.PartnerMetadataStorage;
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;
Expand Down Expand Up @@ -44,7 +45,6 @@
import java.util.Optional;
import java.util.function.Function;
import javax.inject.Inject;
import org.hl7.fhir.r4.model.OperationOutcome;

/**
* The domain connector for the ETOR domain. It connects it with the larger trusted intermediary. It
Expand Down Expand Up @@ -181,11 +181,11 @@ DomainResponse handleMetadata(DomainRequest request) {
404, "Metadata not found for ID: " + metadataId);
}

OperationOutcome responseObject =
FhirMetadata<?> responseObject =
orderConverter.extractPublicMetadataToOperationOutcome(metadata.get());

return domainResponseHelper.constructOkResponseFromString(
fhir.encodeResourceToJson(responseObject));
fhir.encodeResourceToJson(responseObject.getUnderlyingOutcome()));
} catch (PartnerMetadataException e) {
String errorMessage = "Unable to retrieve requested metadata";
logger.logError(errorMessage, e);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package gov.hhs.cdc.trustedintermediary.etor.operationoutcomes;

/**
* Wrapper interface for our public facing metadata. Wraps an operation outcomes object to be
* returned to our ReST API
*
* @param <T>
*/
public interface FhirMetadata<T> {

T getUnderlyingOutcome();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package gov.hhs.cdc.trustedintermediary.etor.operationoutcomes;

import org.hl7.fhir.r4.model.OperationOutcome;

/** Implementation of our wrapper for public facing metadata. Returns an operation outcomes */
public class HapiFhirMetadata implements FhirMetadata<OperationOutcome> {

private final OperationOutcome innerOutcome;

public HapiFhirMetadata(OperationOutcome outcome) {
this.innerOutcome = outcome;
}

@Override
public OperationOutcome getUnderlyingOutcome() {
return innerOutcome;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import gov.hhs.cdc.trustedintermediary.etor.demographics.Demographics;
import gov.hhs.cdc.trustedintermediary.etor.metadata.PartnerMetadata;
import org.hl7.fhir.r4.model.OperationOutcome;
import gov.hhs.cdc.trustedintermediary.etor.operationoutcomes.FhirMetadata;

/** Interface for converting things to orders and things in orders. */
public interface OrderConverter {
Expand All @@ -12,5 +12,5 @@ public interface OrderConverter {

Order<?> addContactSectionToPatientResource(Order<?> order);

OperationOutcome extractPublicMetadataToOperationOutcome(PartnerMetadata metadata);
FhirMetadata<?> extractPublicMetadataToOperationOutcome(PartnerMetadata metadata);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import gov.hhs.cdc.trustedintermediary.etor.demographics.Demographics;
import gov.hhs.cdc.trustedintermediary.etor.metadata.PartnerMetadata;
import gov.hhs.cdc.trustedintermediary.etor.operationoutcomes.FhirMetadata;
import gov.hhs.cdc.trustedintermediary.etor.operationoutcomes.HapiFhirMetadata;
import gov.hhs.cdc.trustedintermediary.etor.orders.Order;
import gov.hhs.cdc.trustedintermediary.etor.orders.OrderConverter;
import gov.hhs.cdc.trustedintermediary.wrappers.Logger;
Expand Down Expand Up @@ -204,7 +206,7 @@ private Provenance createProvenanceResource(Date orderDate) {
}

@Override
public OperationOutcome extractPublicMetadataToOperationOutcome(PartnerMetadata metadata) {
public FhirMetadata<?> extractPublicMetadataToOperationOutcome(PartnerMetadata metadata) {
var operation = new OperationOutcome();

operation.setId(metadata.receivedSubmissionId());
Expand All @@ -223,7 +225,7 @@ public OperationOutcome extractPublicMetadataToOperationOutcome(PartnerMetadata
.add(createInformationIssueComponent("order ingestion", orderIngestion));
operation.getIssue().add(createInformationIssueComponent("payload hash", metadata.hash()));

return operation;
return new HapiFhirMetadata(operation);
}

protected OperationOutcome.OperationOutcomeIssueComponent createInformationIssueComponent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import gov.hhs.cdc.trustedintermediary.etor.demographics.PatientDemographicsResp
import gov.hhs.cdc.trustedintermediary.etor.metadata.PartnerMetadata
import gov.hhs.cdc.trustedintermediary.etor.metadata.PartnerMetadataException
import gov.hhs.cdc.trustedintermediary.etor.metadata.PartnerMetadataOrchestrator
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
Expand Down Expand Up @@ -331,11 +332,11 @@ class EtorDomainRegistrationTest extends Specification {
TestApplicationContext.register(DomainResponseHelper, mockResponseHelper)

def mockOrderConverter = Mock(OrderConverter)
mockOrderConverter.extractPublicMetadataToOperationOutcome(_ as PartnerMetadata) >> Mock(OperationOutcome)
mockOrderConverter.extractPublicMetadataToOperationOutcome(_ as PartnerMetadata) >> Mock(FhirMetadata)
TestApplicationContext.register(OrderConverter, mockOrderConverter)

def mockFhir = Mock(HapiFhir)
mockFhir.encodeResourceToJson(_ as OperationOutcome) >> ""
mockFhir.encodeResourceToJson(_) >> ""
TestApplicationContext.register(HapiFhir, mockFhir)
TestApplicationContext.injectRegisteredImplementations()

Expand Down
2 changes: 1 addition & 1 deletion shared/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dependencies {
testFixturesImplementation 'org.apache.groovy:groovy:4.0.17'
testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0'
testFixturesImplementation 'com.openpojo:openpojo:0.9.1'
testFixturesImplementation 'nl.jqno.equalsverifier:equalsverifier:3.15.5'
testFixturesImplementation 'nl.jqno.equalsverifier:equalsverifier:3.15.6'

// dotenv-java
implementation 'io.github.cdimascio:dotenv-java:3.0.0'
Expand Down

0 comments on commit 1377721

Please sign in to comment.