Skip to content

Commit

Permalink
Support disease filter on results CSV download (#8052)
Browse files Browse the repository at this point in the history
* Backend support for results download disease filter

* Frontend support for results download disease filter

* Remove unused testing variable
  • Loading branch information
mpbrown committed Aug 23, 2024
1 parent 26f3804 commit bbc80df
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,13 +26,15 @@ public class TestResultResolver {

private final TestOrderService tos;
private final TestResultUploadService testResultUploadService;
private final DiseaseService diseaseService;

@QueryMapping
public Page<TestEvent> testResultsPage(
@Argument UUID facilityId,
@Argument UUID patientId,
@Argument String result,
@Argument String role,
@Argument String disease,
@Argument Date startDate,
@Argument Date endDate,
@Argument int pageNumber,
Expand All @@ -48,6 +51,7 @@ public Page<TestEvent> testResultsPage(
patientId,
Translators.parseTestResult(result),
Translators.parsePersonRole(role, true),
diseaseService.getDiseaseByName(disease),
startDate,
endDate,
pageNumber,
Expand All @@ -58,6 +62,7 @@ public Page<TestEvent> testResultsPage(
patientId,
Translators.parseTestResult(result),
Translators.parsePersonRole(role, true),
diseaseService.getDiseaseByName(disease),
startDate,
endDate,
pageNumber,
Expand All @@ -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) {
Expand All @@ -78,6 +84,7 @@ public int testResultsCount(
patientId,
Translators.parseTestResult(result),
Translators.parsePersonRole(role, true),
diseaseService.getDiseaseByName(disease),
startDate,
endDate,
orgId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -94,6 +95,7 @@ private Specification<TestEvent> buildTestEventSearchFilter(
UUID patientId,
TestResult result,
PersonRole role,
SupportedDisease disease,
Date startDate,
Date endDate,
UUID orgId) {
Expand Down Expand Up @@ -137,6 +139,14 @@ private Specification<TestEvent> 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(
Expand Down Expand Up @@ -173,6 +183,7 @@ public Page<TestEvent> getFacilityTestEventsResults(
UUID patientId,
TestResult result,
PersonRole role,
SupportedDisease disease,
Date startDate,
Date endDate,
int pageOffset,
Expand All @@ -182,7 +193,8 @@ public Page<TestEvent> 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);
}

Expand All @@ -192,6 +204,7 @@ public Page<TestEvent> getOrganizationTestEventsResults(
UUID patientId,
TestResult result,
PersonRole role,
SupportedDisease disease,
Date startDate,
Date endDate,
int pageOffset,
Expand All @@ -201,7 +214,8 @@ public Page<TestEvent> 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);
}

Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions backend/src/main/resources/graphql/main.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ type Query {
patientId: ID
result: String
role: String
disease: String
startDate: DateTime
endDate: DateTime
pageNumber: Int = 0
Expand Down
Loading

0 comments on commit bbc80df

Please sign in to comment.