From bbc80df53492dabda54c42dac556a3230c798aea Mon Sep 17 00:00:00 2001 From: Mike Brown Date: Fri, 23 Aug 2024 12:50:22 -0400 Subject: [PATCH] Support disease filter on results CSV download (#8052) * Backend support for results download disease filter * Frontend support for results download disease filter * Remove unused testing variable --- .../api/testresult/TestResultResolver.java | 7 + .../service/TestOrderService.java | 21 ++- .../src/main/resources/graphql/main.graphqls | 1 + .../service/TestOrderServiceTest.java | 134 ++++++++++++------ .../src/app/testResults/operations.graphql | 2 + .../viewResults/DownloadResultsCsvModal.tsx | 3 +- frontend/src/app/utils/testResultCSV.ts | 8 +- frontend/src/generated/graphql.tsx | 5 + 8 files changed, 132 insertions(+), 49 deletions(-) diff --git a/backend/src/main/java/gov/cdc/usds/simplereport/api/testresult/TestResultResolver.java b/backend/src/main/java/gov/cdc/usds/simplereport/api/testresult/TestResultResolver.java index 75855dff66..11fcd8356a 100644 --- a/backend/src/main/java/gov/cdc/usds/simplereport/api/testresult/TestResultResolver.java +++ b/backend/src/main/java/gov/cdc/usds/simplereport/api/testresult/TestResultResolver.java @@ -5,6 +5,7 @@ import gov.cdc.usds.simplereport.api.model.TopLevelDashboardMetrics; import gov.cdc.usds.simplereport.db.model.TestEvent; import gov.cdc.usds.simplereport.db.model.TestResultUpload; +import gov.cdc.usds.simplereport.service.DiseaseService; import gov.cdc.usds.simplereport.service.TestOrderService; import gov.cdc.usds.simplereport.service.TestResultUploadService; import gov.cdc.usds.simplereport.service.errors.InvalidBulkTestResultUploadException; @@ -25,6 +26,7 @@ public class TestResultResolver { private final TestOrderService tos; private final TestResultUploadService testResultUploadService; + private final DiseaseService diseaseService; @QueryMapping public Page testResultsPage( @@ -32,6 +34,7 @@ public Page testResultsPage( @Argument UUID patientId, @Argument String result, @Argument String role, + @Argument String disease, @Argument Date startDate, @Argument Date endDate, @Argument int pageNumber, @@ -48,6 +51,7 @@ public Page testResultsPage( patientId, Translators.parseTestResult(result), Translators.parsePersonRole(role, true), + diseaseService.getDiseaseByName(disease), startDate, endDate, pageNumber, @@ -58,6 +62,7 @@ public Page testResultsPage( patientId, Translators.parseTestResult(result), Translators.parsePersonRole(role, true), + diseaseService.getDiseaseByName(disease), startDate, endDate, pageNumber, @@ -70,6 +75,7 @@ public int testResultsCount( @Argument UUID patientId, @Argument String result, @Argument String role, + @Argument String disease, @Argument Date startDate, @Argument Date endDate, @Argument UUID orgId) { @@ -78,6 +84,7 @@ public int testResultsCount( patientId, Translators.parseTestResult(result), Translators.parsePersonRole(role, true), + diseaseService.getDiseaseByName(disease), startDate, endDate, orgId); diff --git a/backend/src/main/java/gov/cdc/usds/simplereport/service/TestOrderService.java b/backend/src/main/java/gov/cdc/usds/simplereport/service/TestOrderService.java index 598b58c615..096d4f1df1 100644 --- a/backend/src/main/java/gov/cdc/usds/simplereport/service/TestOrderService.java +++ b/backend/src/main/java/gov/cdc/usds/simplereport/service/TestOrderService.java @@ -19,6 +19,7 @@ import gov.cdc.usds.simplereport.db.model.Result; import gov.cdc.usds.simplereport.db.model.Result_; import gov.cdc.usds.simplereport.db.model.SpecimenType; +import gov.cdc.usds.simplereport.db.model.SupportedDisease; import gov.cdc.usds.simplereport.db.model.TestEvent; import gov.cdc.usds.simplereport.db.model.TestEvent_; import gov.cdc.usds.simplereport.db.model.TestOrder; @@ -94,6 +95,7 @@ private Specification buildTestEventSearchFilter( UUID patientId, TestResult result, PersonRole role, + SupportedDisease disease, Date startDate, Date endDate, UUID orgId) { @@ -137,6 +139,14 @@ private Specification buildTestEventSearchFilter( if (role != null) { p = cb.and(p, cb.equal(root.get(BaseTestInfo_.patient).get(Person_.role), role)); } + if (disease != null) { + p = + cb.and( + p, + cb.equal( + resultJoin.get(Result_.disease).get(IdentifiedEntity_.internalId), + disease.getInternalId())); + } if (startDate != null) { p = cb.and( @@ -173,6 +183,7 @@ public Page getFacilityTestEventsResults( UUID patientId, TestResult result, PersonRole role, + SupportedDisease disease, Date startDate, Date endDate, int pageOffset, @@ -182,7 +193,8 @@ public Page getFacilityTestEventsResults( PageRequest.of(pageOffset, pageSize, Sort.by("createdAt").descending()); return _testEventRepo.findAll( - buildTestEventSearchFilter(facilityId, patientId, result, role, startDate, endDate, null), + buildTestEventSearchFilter( + facilityId, patientId, result, role, disease, startDate, endDate, null), pageRequest); } @@ -192,6 +204,7 @@ public Page getOrganizationTestEventsResults( UUID patientId, TestResult result, PersonRole role, + SupportedDisease disease, Date startDate, Date endDate, int pageOffset, @@ -201,7 +214,8 @@ public Page getOrganizationTestEventsResults( PageRequest.of(pageOffset, pageSize, Sort.by("createdAt").descending()); return _testEventRepo.findAll( - buildTestEventSearchFilter(null, patientId, result, role, startDate, endDate, null), + buildTestEventSearchFilter( + null, patientId, result, role, disease, startDate, endDate, null), pageRequest); } @@ -211,13 +225,14 @@ public int getTestResultsCount( UUID patientId, TestResult result, PersonRole role, + SupportedDisease disease, Date startDate, Date endDate, UUID orgId) { return (int) _testEventRepo.count( buildTestEventSearchFilter( - facilityId, patientId, result, role, startDate, endDate, orgId)); + facilityId, patientId, result, role, disease, startDate, endDate, orgId)); } @Transactional(readOnly = true) diff --git a/backend/src/main/resources/graphql/main.graphqls b/backend/src/main/resources/graphql/main.graphqls index a8ab20987a..9d255a5d60 100644 --- a/backend/src/main/resources/graphql/main.graphqls +++ b/backend/src/main/resources/graphql/main.graphqls @@ -491,6 +491,7 @@ type Query { patientId: ID result: String role: String + disease: String startDate: DateTime endDate: DateTime pageNumber: Int = 0 diff --git a/backend/src/test/java/gov/cdc/usds/simplereport/service/TestOrderServiceTest.java b/backend/src/test/java/gov/cdc/usds/simplereport/service/TestOrderServiceTest.java index 200a84b6c3..8d16c38353 100644 --- a/backend/src/test/java/gov/cdc/usds/simplereport/service/TestOrderServiceTest.java +++ b/backend/src/test/java/gov/cdc/usds/simplereport/service/TestOrderServiceTest.java @@ -63,6 +63,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.UUID; @@ -1255,11 +1256,12 @@ void fetchTestEventsResults_standardUser_successDependsOnFacilityAccess() { assertThrows( AccessDeniedException.class, () -> - _service.getFacilityTestEventsResults(facilityId, null, null, null, null, null, 0, 10)); + _service.getFacilityTestEventsResults( + facilityId, null, null, null, null, null, null, 0, 10)); TestUserIdentities.setFacilityAuthorities(facility); _service.getFacilityTestEventsResults( - facility.getInternalId(), null, null, null, null, null, 0, 10); + facility.getInternalId(), null, null, null, null, null, null, 0, 10); } @Test @@ -1272,7 +1274,7 @@ void fetchTestEventsAtArchivedFacility_orgAdminUser_ok() { Page testEventsByFacility = _service.getFacilityTestEventsResults( - facility.getInternalId(), null, null, null, null, null, 0, 10); + facility.getInternalId(), null, null, null, null, null, null, 0, 10); assertThat(testEventsByFacility.getTotalElements()).isEqualTo(1); assertThat(testEventsByFacility.getTotalPages()).isEqualTo(1); } @@ -1289,7 +1291,8 @@ void fetchTestEventsAtArchivedFacility_standardUser_failure() { assertThrows( AccessDeniedException.class, () -> - _service.getFacilityTestEventsResults(facilityId, null, null, null, null, null, 0, 10)); + _service.getFacilityTestEventsResults( + facilityId, null, null, null, null, null, null, 0, 10)); } @Test @@ -1301,7 +1304,7 @@ void fetchAllFacilityTestEventsResults_orgAdminUser_ok() { _dataFactory.createTestEvent(p, facility); Page testEventsByOrg = - _service.getOrganizationTestEventsResults(null, null, null, null, null, 0, 10); + _service.getOrganizationTestEventsResults(null, null, null, null, null, null, 0, 10); assertThat(testEventsByOrg.getTotalElements()).isEqualTo(1); assertThat(testEventsByOrg.getTotalPages()).isEqualTo(1); } @@ -1316,7 +1319,7 @@ void fetchAllFacilityTestEventsResults_standardUser_failure() { assertThrows( AccessDeniedException.class, - () -> _service.getOrganizationTestEventsResults(null, null, null, null, null, 0, 10)); + () -> _service.getOrganizationTestEventsResults(null, null, null, null, null, null, 0, 10)); } @Test @@ -1379,7 +1382,7 @@ void fetchTestEventsResults_getTestEventsResults_NPlusOne() { // count queries long startQueryCount = QueryCountService.get().getSelect(); _service.getFacilityTestEventsResults( - facility.getInternalId(), null, null, null, null, null, 0, 50); + facility.getInternalId(), null, null, null, null, null, null, 0, 50); long firstPassTotal = QueryCountService.get().getSelect() - startQueryCount; // add more data @@ -1392,7 +1395,7 @@ void fetchTestEventsResults_getTestEventsResults_NPlusOne() { // count queries again and make sure queries made didn't increase startQueryCount = QueryCountService.get().getSelect(); _service.getFacilityTestEventsResults( - facility.getInternalId(), null, null, null, null, null, 0, 50); + facility.getInternalId(), null, null, null, null, null, null, 0, 50); long secondPassTotal = QueryCountService.get().getSelect() - startQueryCount; assertEquals(firstPassTotal, secondPassTotal); } @@ -1498,7 +1501,7 @@ void markAsErrorTest() { List events_before = _service .getFacilityTestEventsResults( - facility.getInternalId(), null, null, null, null, null, 0, 50) + facility.getInternalId(), null, null, null, null, null, null, 0, 50) .toList(); assertEquals(1, events_before.size()); @@ -1515,7 +1518,7 @@ void markAsErrorTest() { List events_after = _service .getFacilityTestEventsResults( - facility.getInternalId(), null, null, null, null, null, 0, 50) + facility.getInternalId(), null, null, null, null, null, null, 0, 50) .toList(); assertEquals(1, events_after.size()); assertEquals( @@ -1905,19 +1908,23 @@ void getTestEventsResults_pagination() { List testEvents = makedata(); List results_page0 = _service - .getFacilityTestEventsResults(_site.getInternalId(), null, null, null, null, null, 0, 5) + .getFacilityTestEventsResults( + _site.getInternalId(), null, null, null, null, null, null, 0, 5) .toList(); List results_page1 = _service - .getFacilityTestEventsResults(_site.getInternalId(), null, null, null, null, null, 1, 5) + .getFacilityTestEventsResults( + _site.getInternalId(), null, null, null, null, null, null, 1, 5) .toList(); List results_page2 = _service - .getFacilityTestEventsResults(_site.getInternalId(), null, null, null, null, null, 2, 5) + .getFacilityTestEventsResults( + _site.getInternalId(), null, null, null, null, null, null, 2, 5) .toList(); List results_page3 = _service - .getFacilityTestEventsResults(_site.getInternalId(), null, null, null, null, null, 3, 5) + .getFacilityTestEventsResults( + _site.getInternalId(), null, null, null, null, null, null, 3, 5) .toList(); Collections.reverse(testEvents); @@ -1932,30 +1939,32 @@ void getTestEventsResults_pagination() { @WithSimpleReportOrgAdminUser void getTestEventsResults_filtering() { List testEvents = makedata(); + List fluATestEvents = makeSpecificDiseaseData(_diseaseService.fluA(), _site); + testEvents.addAll(fluATestEvents); List positives = _service .getFacilityTestEventsResults( - _site.getInternalId(), null, TestResult.POSITIVE, null, null, null, 0, 10) + _site.getInternalId(), null, TestResult.POSITIVE, null, null, null, null, 0, 10) .toList(); List negatives = _service .getFacilityTestEventsResults( - _site.getInternalId(), null, TestResult.NEGATIVE, null, null, null, 0, 10) + _site.getInternalId(), null, TestResult.NEGATIVE, null, null, null, null, 0, 10) .toList(); List inconclusives = _service .getFacilityTestEventsResults( - _site.getInternalId(), null, TestResult.UNDETERMINED, null, null, null, 0, 10) + _site.getInternalId(), null, TestResult.UNDETERMINED, null, null, null, null, 0, 10) .toList(); List students = _service .getFacilityTestEventsResults( - _site.getInternalId(), null, null, PersonRole.STUDENT, null, null, 0, 10) + _site.getInternalId(), null, null, PersonRole.STUDENT, null, null, null, 0, 10) .toList(); List visitors = _service .getFacilityTestEventsResults( - _site.getInternalId(), null, null, PersonRole.VISITOR, null, null, 0, 10) + _site.getInternalId(), null, null, PersonRole.VISITOR, null, null, null, 0, 10) .toList(); List june1to3 = _service @@ -1964,6 +1973,7 @@ void getTestEventsResults_filtering() { null, null, null, + null, convertDate(LocalDateTime.of(2021, 6, 1, 0, 0, 0)), convertDate(LocalDateTime.of(2021, 6, 3, 23, 59, 59)), 0, @@ -1977,6 +1987,7 @@ void getTestEventsResults_filtering() { null, null, null, + null, convertDate(LocalDateTime.of(2021, 6, 2, 11, 59, 59)), 0, 10) @@ -1990,6 +2001,7 @@ void getTestEventsResults_filtering() { null, null, null, + null, 0, 10) .toList(); @@ -2002,9 +2014,15 @@ void getTestEventsResults_filtering() { null, null, null, + null, 0, 10) .toList(); + List fluAResults = + _service + .getFacilityTestEventsResults( + _site.getInternalId(), null, null, null, _diseaseService.fluA(), null, null, 0, 10) + .toList(); List allFilters = _service .getFacilityTestEventsResults( @@ -2012,6 +2030,7 @@ void getTestEventsResults_filtering() { _dataFactory.getPersonByName(CHARLES).getInternalId(), TestResult.POSITIVE, PersonRole.RESIDENT, + _diseaseService.covid(), convertDate(LocalDateTime.of(2021, 6, 1, 0, 0, 0)), convertDate(LocalDateTime.of(2021, 6, 1, 23, 59, 59)), 0, @@ -2023,17 +2042,24 @@ void getTestEventsResults_filtering() { assertTestResultsList( positives, testEvents.stream() - .filter(t -> t.getCovidTestResult().orElse(null) == TestResult.POSITIVE) + .filter( + t -> + t.getResults().stream().anyMatch(r -> r.getTestResult() == TestResult.POSITIVE)) .collect(Collectors.toList())); assertTestResultsList( negatives, testEvents.stream() - .filter(t -> t.getCovidTestResult().orElse(null) == TestResult.NEGATIVE) + .filter( + t -> + t.getResults().stream().anyMatch(r -> r.getTestResult() == TestResult.NEGATIVE)) .collect(Collectors.toList())); assertTestResultsList( inconclusives, testEvents.stream() - .filter(t -> t.getCovidTestResult().orElse(null) == TestResult.UNDETERMINED) + .filter( + t -> + t.getResults().stream() + .anyMatch(r -> r.getTestResult() == TestResult.UNDETERMINED)) .collect(Collectors.toList())); assertTestResultsList( students, @@ -2076,6 +2102,17 @@ void getTestEventsResults_filtering() { t.getCovidTestResult().orElse(null) == TestResult.NEGATIVE && t.getPatient().getNameInfo().equals(AMOS)) .collect(Collectors.toList())); + assertTestResultsList( + fluAResults, + testEvents.stream() + .filter( + t -> + t.getResults().stream() + .anyMatch( + r -> + Objects.equals( + r.getDisease().getName(), _diseaseService.fluA().getName()))) + .collect(Collectors.toList())); assertTestResultsList( allFilters, testEvents.stream() @@ -2084,6 +2121,12 @@ void getTestEventsResults_filtering() { t.getPatient().getNameInfo().equals(CHARLES) && t.getCovidTestResult().orElse(null) == TestResult.POSITIVE && t.getPatient().getRole() == PersonRole.RESIDENT + && t.getResults().stream() + .anyMatch( + r -> + Objects.equals( + r.getDisease().getName(), + _diseaseService.covid().getName())) && !t.getDateTested() .before(convertDate(LocalDateTime.of(2021, 6, 1, 0, 0, 0))) && !t.getDateTested() @@ -2103,7 +2146,7 @@ void getTestEventsResults_withMultiplex_returnsOnlyOneEvent() { var res = _service .getFacilityTestEventsResults( - facility.getInternalId(), null, null, null, null, null, 0, 10) + facility.getInternalId(), null, null, null, null, null, null, 0, 10) .toList(); assertEquals(1, res.size()); } @@ -2121,7 +2164,7 @@ void getTestEventsResults_withMultiplexAndCovid_returnsOnlyTwoEvent() { var res = _service .getFacilityTestEventsResults( - facility.getInternalId(), null, null, null, null, null, 0, 10) + facility.getInternalId(), null, null, null, null, null, null, 0, 10) .toList(); assertEquals(2, res.size()); } @@ -2144,7 +2187,7 @@ void getTestEventsResults_withResultFilter_returnsFluAndCovidNegatives() { var res = _service.getFacilityTestEventsResults( - facility.getInternalId(), null, TestResult.NEGATIVE, null, null, null, 0, 10); + facility.getInternalId(), null, TestResult.NEGATIVE, null, null, null, null, 0, 10); var expected = List.of(expected_allNeg.getInternalId(), expected_covidPos.getInternalId()); var actualInternalIds = res.stream().map(TestEvent::getInternalId).collect(Collectors.toList()); @@ -2158,7 +2201,8 @@ void getTestEventsResults_withResultFilter_returnsFluAndCovidNegatives() { void getTestResultsCount() { makedata(); int size = - _service.getTestResultsCount(_site.getInternalId(), null, null, null, null, null, null); + _service.getTestResultsCount( + _site.getInternalId(), null, null, null, null, null, null, null); assertEquals(11, size); } @@ -2167,7 +2211,7 @@ void getTestResultsCount() { void getTestResultsCount_forOrganization() { var testEvents = makeAdminData(); var orgId = testEvents.get(0).getOrganization().getInternalId(); - int size = _service.getTestResultsCount(null, null, null, null, null, null, orgId); + int size = _service.getTestResultsCount(null, null, null, null, null, null, null, orgId); assertEquals(4, size); } @@ -2177,7 +2221,7 @@ void getTestResultsCount_forOrganization_failsForNonSiteAdmins() { var otherOrgId = UUID.randomUUID(); assertThrows( AccessDeniedException.class, - () -> _service.getTestResultsCount(null, null, null, null, null, null, otherOrgId)); + () -> _service.getTestResultsCount(null, null, null, null, null, null, null, otherOrgId)); } @Test @@ -2236,7 +2280,7 @@ void getTopLevelDashboardMetrics_inOrgWithStandardUser_failure() { @WithSimpleReportOrgAdminUser void getTopLevelDashboardMetrics_showsNonCovidResults() { makedata(); - makeSpecificDiseaseData(_diseaseService.fluA()); + makeSpecificDiseaseData(_diseaseService.fluA(), null); Date startDate = Date.from(Instant.parse("2000-01-01T00:00:00Z")); Date endDate = new Date(System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(3)); @@ -2261,7 +2305,8 @@ void markAsErrorTest_successDependsOnFacilityAccess() { assertThrows( AccessDeniedException.class, () -> - _service.getFacilityTestEventsResults(facilityId, null, null, null, null, null, 0, 10)); + _service.getFacilityTestEventsResults( + facilityId, null, null, null, null, null, null, 0, 10)); assertThrows(AccessDeniedException.class, () -> _service.getTestResult(testEventId)); // make sure the corrected event is not sent to storage queue @@ -2271,7 +2316,7 @@ void markAsErrorTest_successDependsOnFacilityAccess() { TestUserIdentities.setFacilityAuthorities(facility); TestEvent correctedTestEvent = _service.markAsError(_e.getInternalId(), reasonMsg); _service.getFacilityTestEventsResults( - facility.getInternalId(), null, null, null, null, null, 0, 10); + facility.getInternalId(), null, null, null, null, null, null, 0, 10); _service.getTestResult(_e.getInternalId()).getTestOrder(); // make sure the corrected event is sent to storage queue verify(testEventReportingService).report(correctedTestEvent); @@ -2504,27 +2549,30 @@ private List makedata() { return testEvents; } - private List makeSpecificDiseaseData(SupportedDisease disease) { + private List makeSpecificDiseaseData(SupportedDisease disease, Facility site) { Organization org = _organizationService.getCurrentOrganization(); - _site = _dataFactory.createValidFacility(org, "The Facility for " + disease.getName()); + if (site == null) { + site = _dataFactory.createValidFacility(org, "The Facility for " + disease.getName()); + } Map patientsToResults = new HashMap<>(); - patientsToResults.put(AMOS, TestResult.POSITIVE); - patientsToResults.put(CHARLES, TestResult.NEGATIVE); + patientsToResults.put(DEXTER, TestResult.POSITIVE); + patientsToResults.put(ELIZABETH, TestResult.NEGATIVE); Map patientsToDates = new HashMap<>(); - patientsToDates.put(AMOS, convertDate(LocalDateTime.of(2021, 6, 1, 0, 0, 0))); - patientsToDates.put(CHARLES, convertDate(LocalDateTime.of(2021, 6, 1, 12, 0, 0))); + patientsToDates.put(DEXTER, convertDate(LocalDateTime.of(2021, 6, 1, 0, 0, 0))); + patientsToDates.put(ELIZABETH, convertDate(LocalDateTime.of(2021, 6, 1, 12, 0, 0))); Map patientsToRoles = new HashMap<>(); - patientsToRoles.put(AMOS, PersonRole.RESIDENT); - patientsToRoles.put(CHARLES, PersonRole.RESIDENT); + patientsToRoles.put(DEXTER, PersonRole.RESIDENT); + patientsToRoles.put(ELIZABETH, PersonRole.RESIDENT); Map patientsToSurveys = new HashMap<>(); patientsToSurveys.put( - AMOS, new AskOnEntrySurvey(null, null, Map.of("fake", true), false, null, null)); + DEXTER, new AskOnEntrySurvey(null, null, Map.of("fake", true), false, null, null)); patientsToSurveys.put( - CHARLES, new AskOnEntrySurvey(null, null, Collections.emptyMap(), false, null, null)); + ELIZABETH, new AskOnEntrySurvey(null, null, Collections.emptyMap(), false, null, null)); + Facility finalSite = site; return patientsToResults.keySet().stream() .map( n -> { @@ -2533,8 +2581,8 @@ private List makeSpecificDiseaseData(SupportedDisease disease) { AskOnEntrySurvey s = patientsToSurveys.get(n); Date d = patientsToDates.get(n); - Person person = _dataFactory.createMinimalPerson(org, _site, n, r); - return _dataFactory.createTestEvent(person, _site, s, t, d, disease); + Person person = _dataFactory.createMinimalPerson(org, finalSite, n, r); + return _dataFactory.createTestEvent(person, finalSite, s, t, d, disease); }) .collect(Collectors.toList()); } diff --git a/frontend/src/app/testResults/operations.graphql b/frontend/src/app/testResults/operations.graphql index 75258b5231..0a98d84c92 100644 --- a/frontend/src/app/testResults/operations.graphql +++ b/frontend/src/app/testResults/operations.graphql @@ -20,6 +20,7 @@ query GetFacilityResultsForCsvWithCount( $patientId: ID $result: String $role: String + $disease: String $startDate: DateTime $endDate: DateTime $pageNumber: Int @@ -30,6 +31,7 @@ query GetFacilityResultsForCsvWithCount( patientId: $patientId result: $result role: $role + disease: $disease startDate: $startDate endDate: $endDate pageNumber: $pageNumber diff --git a/frontend/src/app/testResults/viewResults/DownloadResultsCsvModal.tsx b/frontend/src/app/testResults/viewResults/DownloadResultsCsvModal.tsx index 07e9bed537..1e4cfdf75f 100644 --- a/frontend/src/app/testResults/viewResults/DownloadResultsCsvModal.tsx +++ b/frontend/src/app/testResults/viewResults/DownloadResultsCsvModal.tsx @@ -72,7 +72,8 @@ export const DownloadResultsCsvModal = ({ try { const csvResults = parseDataForCSV( data.testResultsPage.content, - disabledFeatureDiseaseList + disabledFeatureDiseaseList, + filterParams ); setResults(csvResults); } catch (e) { diff --git a/frontend/src/app/utils/testResultCSV.ts b/frontend/src/app/utils/testResultCSV.ts index 5d94f2558a..2bc52eec59 100644 --- a/frontend/src/app/utils/testResultCSV.ts +++ b/frontend/src/app/utils/testResultCSV.ts @@ -73,7 +73,8 @@ export type ResultCsvRow = export function parseDataForCSV( data: QueriedTestResult[], - excludedDiseases: MULTIPLEX_DISEASES[] = [] + excludedDiseases: MULTIPLEX_DISEASES[] = [], + filterParams?: FilterParams ): ResultCsvRow[] { let csvRows: ResultCsvRow[] = []; data.sort(byDateTested).forEach((r: QueriedTestResult) => { @@ -146,7 +147,10 @@ export function parseDataForCSV( if ( excludedDiseases.some( (d) => d.toLowerCase() === result?.disease.name.toLowerCase() - ) + ) || + (filterParams?.disease && + result?.disease.name.toLowerCase() !== + filterParams.disease.toLowerCase()) ) { return; } diff --git a/frontend/src/generated/graphql.tsx b/frontend/src/generated/graphql.tsx index 20f4d285cc..2c271b39a8 100644 --- a/frontend/src/generated/graphql.tsx +++ b/frontend/src/generated/graphql.tsx @@ -875,6 +875,7 @@ export type QueryTestResultsCountArgs = { }; export type QueryTestResultsPageArgs = { + disease?: InputMaybe; endDate?: InputMaybe; facilityId?: InputMaybe; pageNumber?: InputMaybe; @@ -2401,6 +2402,7 @@ export type GetFacilityResultsForCsvWithCountQueryVariables = Exact<{ patientId?: InputMaybe; result?: InputMaybe; role?: InputMaybe; + disease?: InputMaybe; startDate?: InputMaybe; endDate?: InputMaybe; pageNumber?: InputMaybe; @@ -7779,6 +7781,7 @@ export const GetFacilityResultsForCsvWithCountDocument = gql` $patientId: ID $result: String $role: String + $disease: String $startDate: DateTime $endDate: DateTime $pageNumber: Int @@ -7789,6 +7792,7 @@ export const GetFacilityResultsForCsvWithCountDocument = gql` patientId: $patientId result: $result role: $role + disease: $disease startDate: $startDate endDate: $endDate pageNumber: $pageNumber @@ -7874,6 +7878,7 @@ export const GetFacilityResultsForCsvWithCountDocument = gql` * patientId: // value for 'patientId' * result: // value for 'result' * role: // value for 'role' + * disease: // value for 'disease' * startDate: // value for 'startDate' * endDate: // value for 'endDate' * pageNumber: // value for 'pageNumber'