From 2e7e3b4bb69deb2b87851049d6cdbf104d6100dc Mon Sep 17 00:00:00 2001 From: Mike Brown Date: Tue, 11 Jun 2024 14:50:46 -0400 Subject: [PATCH] Add covid only flag for resend mutation (#7790) * Add covid only flag for resend mutation * Update conditionals * Make booleans conditional for resend mutation * Update graphql codegen --- .../TestResultMutationResolver.java | 10 +++++--- .../src/main/resources/graphql/admin.graphqls | 2 +- .../TestResultMutationResolverTest.java | 24 +++++++++++++++++-- frontend/src/generated/graphql.tsx | 3 ++- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/backend/src/main/java/gov/cdc/usds/simplereport/api/testresult/TestResultMutationResolver.java b/backend/src/main/java/gov/cdc/usds/simplereport/api/testresult/TestResultMutationResolver.java index 564d6d2a9b..8619915c34 100644 --- a/backend/src/main/java/gov/cdc/usds/simplereport/api/testresult/TestResultMutationResolver.java +++ b/backend/src/main/java/gov/cdc/usds/simplereport/api/testresult/TestResultMutationResolver.java @@ -27,15 +27,19 @@ public class TestResultMutationResolver { @MutationMapping @AuthorizationConfiguration.RequireGlobalAdminUser public boolean resendToReportStream( - @Argument List testEventIds, @Argument boolean fhirOnly) { + @Argument List testEventIds, @Argument boolean fhirOnly, @Argument boolean covidOnly) { testEventRepository .findAllByInternalIdIn(testEventIds) .forEach( testEvent -> { - if (!fhirOnly) { + if (fhirOnly) { + fhirReportingService.report(testEvent); + } else if (covidOnly) { testEventReportingService.report(testEvent); + } else { + testEventReportingService.report(testEvent); + fhirReportingService.report(testEvent); } - fhirReportingService.report(testEvent); }); return true; diff --git a/backend/src/main/resources/graphql/admin.graphqls b/backend/src/main/resources/graphql/admin.graphqls index 1b42c636bb..a220082d86 100644 --- a/backend/src/main/resources/graphql/admin.graphqls +++ b/backend/src/main/resources/graphql/admin.graphqls @@ -10,7 +10,7 @@ extend type Query { getOrgAdminUserIds(orgId: ID!): [ID] } extend type Mutation { - resendToReportStream(testEventIds: [ID!]!, fhirOnly: Boolean!): Boolean + resendToReportStream(testEventIds: [ID!]!, fhirOnly: Boolean = false, covidOnly: Boolean = false): Boolean createDeviceType(input: CreateDeviceType!): DeviceType updateDeviceType(input: UpdateDeviceType!): DeviceType createSpecimenType(input: CreateSpecimenType!): SpecimenType diff --git a/backend/src/test/java/gov/cdc/usds/simplereport/api/testresult/TestResultMutationResolverTest.java b/backend/src/test/java/gov/cdc/usds/simplereport/api/testresult/TestResultMutationResolverTest.java index c8933b35fb..a10cfc1ce2 100644 --- a/backend/src/test/java/gov/cdc/usds/simplereport/api/testresult/TestResultMutationResolverTest.java +++ b/backend/src/test/java/gov/cdc/usds/simplereport/api/testresult/TestResultMutationResolverTest.java @@ -30,7 +30,7 @@ void resendToReportStream_success() { var actual = testResultMutationResolver.resendToReportStream( - List.of(UUID.randomUUID(), UUID.randomUUID()), false); + List.of(UUID.randomUUID(), UUID.randomUUID()), false, false); verify(mockCsvReporter, times(2)).report(any()); verify(mockFhirReporter, times(2)).report(any()); @@ -50,10 +50,30 @@ void resendToReportStream_fhirOnly_success() { var actual = testResultMutationResolver.resendToReportStream( - List.of(UUID.randomUUID(), UUID.randomUUID()), true); + List.of(UUID.randomUUID(), UUID.randomUUID()), true, false); verify(mockCsvReporter, times(0)).report(any()); verify(mockFhirReporter, times(2)).report(any()); assertThat(actual).isTrue(); } + + @Test + void resendToReportStream_covidOnly_success() { + var mockCsvReporter = mock(TestEventReportingService.class); + var mockFhirReporter = mock(TestEventReportingService.class); + var mockTestEventRepository = mock(TestEventRepository.class); + + when(mockTestEventRepository.findAllByInternalIdIn(any())) + .thenReturn(List.of(createCovidTestEvent(), createMultiplexTestEvent())); + var testResultMutationResolver = + new TestResultMutationResolver(mockTestEventRepository, mockCsvReporter, mockFhirReporter); + + var actual = + testResultMutationResolver.resendToReportStream( + List.of(UUID.randomUUID(), UUID.randomUUID()), false, true); + + verify(mockCsvReporter, times(2)).report(any()); + verify(mockFhirReporter, times(0)).report(any()); + assertThat(actual).isTrue(); + } } diff --git a/frontend/src/generated/graphql.tsx b/frontend/src/generated/graphql.tsx index bb49de3c29..0db90ef2f0 100644 --- a/frontend/src/generated/graphql.tsx +++ b/frontend/src/generated/graphql.tsx @@ -398,7 +398,8 @@ export type MutationResendActivationEmailArgs = { }; export type MutationResendToReportStreamArgs = { - fhirOnly: Scalars["Boolean"]["input"]; + covidOnly?: InputMaybe; + fhirOnly?: InputMaybe; testEventIds: Array; };