-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add result and condition filters to test results list (#6682)
* Refactor results table - each multiplex result on own row * Rename TestResultsList test titles to reflect refactor; remove obsoleted test * Add skeleton structure for returning Results by facility & organization * Add result service methods to return results with various filters applied * Adds support for GraphQL query to filter and return granular test result data - Adds resolver method to return paginated test result data - Adds a utility `TestResultsListItem` class - this is the object returned by the server - Adds a data resolver to correctly fetch facility data for a test result * Defines query operation to retrieve filtered test results from server; updates to expected shape of incoming test result in result table UI component * Fix page & result count display; Tidy comments & un-used code * Remove reference to non-existent generated GraphQL method * Test changes - update many, many mocks and fudge some typing to get things to build (for now) * Fix reference to test id in mock * Update some more test results mocks * Update sooooo many mocks, other test tweaks * comment out some junk so I can build * Broke out new ResultService tests into nested block to keep setup separate from existing tests * Correct mocks for ResultsTable unit tests * Update test result CSV download mock * Actually correct mock response for CSV results download * Cleanup.... * Add ResultService test for date range filter; clean up some code smells * Remove unused file * More code smell cleanup, on the frontend this time * Remove unread local variables in unit test file * Add some (not super-useful) unit tests for ResultResolver * Get patient link via GraphQL query for test result row in e2e tests * Un-comment things from testing * Run login hooks for patient link e2e test - needed for one-off GraphQL query from Cypress * Add and employ a GraphQL query called from Cypress to get patient link for a result * Try to get the right envvar for the SR frontend... * Ditto * once more, with feeling * Get rid of some stuff that should not be there * Remove some commented-out code and unused test result item properties * Remove unnecessary assertion in TestResultsList unit tests * Codegen * Remove some unused properties on mock objects for ResultsTable
- Loading branch information
1 parent
2472259
commit 8353d11
Showing
41 changed files
with
1,650 additions
and
951 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
backend/src/main/java/gov/cdc/usds/simplereport/api/testresult/ResultDataResolver.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,15 @@ | ||
package gov.cdc.usds.simplereport.api.testresult; | ||
|
||
import gov.cdc.usds.simplereport.api.model.ApiFacility; | ||
import gov.cdc.usds.simplereport.db.model.auxiliary.TestResultsListItem; | ||
import org.springframework.graphql.data.method.annotation.SchemaMapping; | ||
import org.springframework.stereotype.Controller; | ||
|
||
@Controller | ||
public class ResultDataResolver { | ||
|
||
@SchemaMapping(typeName = "Result", field = "facility") | ||
public ApiFacility getFacility(TestResultsListItem result) { | ||
return new ApiFacility(result.getFacility()); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
backend/src/main/java/gov/cdc/usds/simplereport/api/testresult/ResultResolver.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,74 @@ | ||
package gov.cdc.usds.simplereport.api.testresult; | ||
|
||
import gov.cdc.usds.simplereport.api.Translators; | ||
import gov.cdc.usds.simplereport.db.model.SupportedDisease; | ||
import gov.cdc.usds.simplereport.db.model.auxiliary.TestResultsListItem; | ||
import gov.cdc.usds.simplereport.service.DiseaseService; | ||
import gov.cdc.usds.simplereport.service.ResultService; | ||
import gov.cdc.usds.simplereport.service.TestOrderService; | ||
import java.util.Date; | ||
import java.util.UUID; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.graphql.data.method.annotation.Argument; | ||
import org.springframework.graphql.data.method.annotation.QueryMapping; | ||
import org.springframework.stereotype.Controller; | ||
|
||
@Controller | ||
@RequiredArgsConstructor | ||
public class ResultResolver { | ||
|
||
private final ResultService service; | ||
private final DiseaseService diseaseService; | ||
|
||
@QueryMapping | ||
public Page<TestResultsListItem> resultsPage( | ||
@Argument UUID facilityId, | ||
@Argument UUID patientId, | ||
@Argument String result, | ||
@Argument String role, | ||
@Argument String disease, | ||
@Argument Date startDate, | ||
@Argument Date endDate, | ||
@Argument int pageNumber, | ||
@Argument int pageSize) { | ||
|
||
if (pageNumber < 0) { | ||
pageNumber = TestOrderService.DEFAULT_PAGINATION_PAGEOFFSET; | ||
} | ||
|
||
if (pageSize < 1) { | ||
pageSize = TestOrderService.DEFAULT_PAGINATION_PAGESIZE; | ||
} | ||
|
||
SupportedDisease supportedDisease = | ||
disease != null ? diseaseService.getDiseaseByName(disease) : null; | ||
|
||
if (facilityId == null) { | ||
return service | ||
.getOrganizationResults( | ||
patientId, | ||
Translators.parseTestResult(result), | ||
Translators.parsePersonRole(role, true), | ||
supportedDisease, | ||
startDate, | ||
endDate, | ||
pageNumber, | ||
pageSize) | ||
.map(TestResultsListItem::new); | ||
} | ||
|
||
return service | ||
.getFacilityResults( | ||
facilityId, | ||
patientId, | ||
Translators.parseTestResult(result), | ||
Translators.parsePersonRole(role, true), | ||
supportedDisease, | ||
startDate, | ||
endDate, | ||
pageNumber, | ||
pageSize) | ||
.map(TestResultsListItem::new); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
backend/src/main/java/gov/cdc/usds/simplereport/db/model/auxiliary/TestResultsListItem.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,41 @@ | ||
package gov.cdc.usds.simplereport.db.model.auxiliary; | ||
|
||
import gov.cdc.usds.simplereport.db.model.ApiUser; | ||
import gov.cdc.usds.simplereport.db.model.DeviceType; | ||
import gov.cdc.usds.simplereport.db.model.Facility; | ||
import gov.cdc.usds.simplereport.db.model.Person; | ||
import gov.cdc.usds.simplereport.db.model.Result; | ||
import java.util.Date; | ||
import java.util.UUID; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class TestResultsListItem { | ||
private final UUID id; | ||
private final Facility facility; | ||
private final Person patient; | ||
private final Date dateAdded; | ||
private final Date dateUpdated; | ||
private final DeviceType deviceType; | ||
private final String disease; | ||
private final TestResult testResult; | ||
private final Date dateTested; | ||
private final TestCorrectionStatus correctionStatus; | ||
private final String reasonForCorrection; | ||
private final ApiUser createdBy; | ||
|
||
public TestResultsListItem(Result result) { | ||
this.id = result.getTestEvent().getInternalId(); | ||
this.facility = result.getTestEvent().getFacility(); | ||
this.patient = result.getTestEvent().getPatient(); | ||
this.dateAdded = result.getTestEvent().getDateTested(); | ||
this.dateUpdated = result.getUpdatedAt(); | ||
this.deviceType = result.getTestEvent().getDeviceType(); | ||
this.disease = result.getDisease().getName(); | ||
this.testResult = result.getTestResult(); | ||
this.dateTested = result.getTestEvent().getDateTested(); | ||
this.correctionStatus = result.getTestEvent().getCorrectionStatus(); | ||
this.reasonForCorrection = result.getTestEvent().getReasonForCorrection(); | ||
this.createdBy = result.getTestEvent().getCreatedBy(); | ||
} | ||
} |
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
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.