Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use same endpoint for download results as the results list view #8110

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gov.cdc.usds.simplereport.api.testresult;

import gov.cdc.usds.simplereport.api.model.ApiFacility;
import gov.cdc.usds.simplereport.db.model.auxiliary.ResolvedSurveyData;
import gov.cdc.usds.simplereport.db.model.auxiliary.TestResultsListItem;
import org.springframework.graphql.data.method.annotation.SchemaMapping;
import org.springframework.stereotype.Controller;
Expand All @@ -12,4 +13,9 @@ public class ResultDataResolver {
public ApiFacility getFacility(TestResultsListItem result) {
return new ApiFacility(result.getFacility());
}

@SchemaMapping(typeName = "Result", field = "surveyData")
public ResolvedSurveyData getSurveyData(TestResultsListItem result) {
return new ResolvedSurveyData(result.getSurveyData());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package gov.cdc.usds.simplereport.db.model.auxiliary;

import java.time.LocalDate;
import java.util.List;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class ResolvedSurveyData {

private String pregnancy;
private String syphilisHistory;
private String symptoms;
private Boolean noSymptoms;
private LocalDate symptomOnset;
private List<String> genderOfSexualPartners;

public ResolvedSurveyData(AskOnEntrySurvey surveyData) {
this.pregnancy = surveyData.getPregnancy();
this.syphilisHistory = surveyData.getSyphilisHistory();
this.symptoms = surveyData.getSymptomsJSON();
this.noSymptoms = surveyData.getNoSymptoms();
this.symptomOnset = surveyData.getSymptomOnsetDate();
this.genderOfSexualPartners = surveyData.getGenderOfSexualPartners();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class TestResultsListItem {
private final TestCorrectionStatus correctionStatus;
private final String reasonForCorrection;
private final ApiUser createdBy;
private final AskOnEntrySurvey surveyData;

public TestResultsListItem(Result result) {
this.id = result.getTestEvent().getInternalId();
Expand All @@ -37,5 +38,6 @@ public TestResultsListItem(Result result) {
this.correctionStatus = result.getTestEvent().getCorrectionStatus();
this.reasonForCorrection = result.getTestEvent().getReasonForCorrection();
this.createdBy = result.getTestEvent().getCreatedBy();
this.surveyData = result.getTestEvent().getSurveyData();
}
}
10 changes: 10 additions & 0 deletions backend/src/main/resources/graphql/main.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,15 @@ type TestResultsPage {
content: [TestResult]
}

type AskOnEntrySurvey {
pregnancy: String
syphilisHistory: String
symptoms: String
symptomOnset: LocalDate
noSymptoms: Boolean
genderOfSexualPartners: [String]
}

type Result {
id: ID!
facility: Facility!
Expand All @@ -321,6 +330,7 @@ type Result {
correctionStatus: String
reasonForCorrection: String
createdBy: ApiUser
surveyData: AskOnEntrySurvey
}

type ResultsPage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,19 @@ void submitAndFetchMultiplexResult() {

assertTrue(testResults.has(0), "Has at least one submitted test result=");
assertEquals(dateTested, testResults.get(0).get("dateTested").asText());
assertEquals("{\"25064002\":\"true\"}", testResults.get(0).get("symptoms").asText());
assertEquals("false", testResults.get(0).get("noSymptoms").asText());
assertEquals("77386006", testResults.get(0).get("pregnancy").asText());
assertEquals("2020-09-15", testResults.get(0).get("symptomOnset").asText());
assertEquals("[\"male\"]", testResults.get(0).get("genderOfSexualPartners").toString());
assertEquals(
"{\"25064002\":\"true\"}", testResults.get(0).get("surveyData").get("symptoms").asText());
assertEquals("false", testResults.get(0).get("surveyData").get("noSymptoms").asText());
assertEquals("77386006", testResults.get(0).get("surveyData").get("pregnancy").asText());
assertEquals("2020-09-15", testResults.get(0).get("surveyData").get("symptomOnset").asText());
assertEquals(
"[\"male\"]",
testResults.get(0).get("surveyData").get("genderOfSexualPartners").toString());
testResults
.get(0)
.get("results")
.elements()
.forEachRemaining(
r -> {
switch (r.get("disease").get("name").asText()) {
switch (r.get("disease").asText()) {
case "COVID-19":
assertEquals(TestResult.NEGATIVE.toString(), r.get("testResult").asText());
break;
Expand All @@ -199,7 +200,7 @@ void submitAndFetchMultiplexResult() {
assertEquals(TestResult.UNDETERMINED.toString(), r.get("testResult").asText());
break;
default:
fail("Unexpected disease=" + r.get("disease").get("name").asText());
fail("Unexpected disease=" + r.get("disease").asText());
}
});
}
Expand Down Expand Up @@ -279,8 +280,8 @@ void testResultOperations_standardUser_successDependsOnFacilityAccess() {
updateSelfPrivileges(Role.USER, true, Set.of());
ArrayNode testResults = fetchTestResults(fetchVariables);
assertEquals(2, testResults.size());
UUID t1Id = UUID.fromString(testResults.get(0).get("internalId").asText());
UUID t2Id = UUID.fromString(testResults.get(1).get("internalId").asText());
UUID t1Id = UUID.fromString(testResults.get(0).get("id").asText());
UUID t2Id = UUID.fromString(testResults.get(1).get("id").asText());

updateSelfPrivileges(Role.USER, false, Set.of(_secondSite.getInternalId()));

Expand Down Expand Up @@ -506,13 +507,13 @@ private ObjectNode submitQueueItem(

private ArrayNode fetchTestResults(Map<String, Object> variables) {
return (ArrayNode)
runQuery("test-results-with-count-query", variables).get("testResultsPage").get("content");
runQuery("test-results-with-count-query", variables).get("resultsPage").get("content");
}

private ArrayNode fetchTestResultsMultiplex(Map<String, Object> variables) {
return (ArrayNode)
runQuery("test-results-with-count-multiplex-query", variables)
.get("testResultsPage")
.get("resultsPage")
.get("content");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
query GetFacilityResultsWithCountMultiplex(
$facilityId: ID!
) {
testResultsPage(facilityId: $facilityId) {
resultsPage(
facilityId: $facilityId
) {
content {
internalId
id
dateAdded
dateTested
results {
disease {
name
}
testResult
disease
testResult
correctionStatus
reasonForCorrection
facility {
name
isDeleted
}
deviceType {
internalId
Expand All @@ -20,18 +25,34 @@ query GetFacilityResultsWithCountMultiplex(
firstName
middleName
lastName
lookupId
birthDate
gender
role
email
phoneNumbers {
type
number
}
}
patientLink {
internalId
}
symptoms
noSymptoms
pregnancy
symptomOnset
genderOfSexualPartners
surveyData {
pregnancy
syphilisHistory
symptoms
symptomOnset
noSymptoms
genderOfSexualPartners
}
createdBy {
nameInfo {
firstName
middleName
lastName
}
}
}

totalElements
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
query GetFacilityResultsWithCount($facilityId: ID) {
testResultsPage(facilityId: $facilityId) {
resultsPage(
facilityId: $facilityId
) {
content {
internalId
id
dateAdded
dateTested
results {
disease {
internalId
name
loinc
}
testResult
disease
testResult
correctionStatus
reasonForCorrection
facility {
name
isDeleted
}
deviceType {
internalId
Expand All @@ -20,16 +23,26 @@ query GetFacilityResultsWithCount($facilityId: ID) {
firstName
middleName
lastName
lookupId
birthDate
gender
role
email
phoneNumbers {
type
number
}
}
patientLink {
internalId
}
symptoms
noSymptoms
pregnancy
symptomOnset
createdBy {
nameInfo {
firstName
middleName
lastName
}
}
}
totalElements
}
}
}
91 changes: 91 additions & 0 deletions frontend/src/app/testResults/operations.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,97 @@ query GetResultsMultiplexWithCount(
}
}

query GetResultsForDownload(
$facilityId: ID
$patientId: ID
$result: String
$role: String
$disease: String
$startDate: DateTime
$endDate: DateTime
$pageNumber: Int
$pageSize: Int
) {
resultsPage(
facilityId: $facilityId
patientId: $patientId
result: $result
role: $role
disease: $disease
startDate: $startDate
endDate: $endDate
pageNumber: $pageNumber
pageSize: $pageSize
) {
content {
id
dateAdded
dateUpdated
dateTested
disease
testResult
correctionStatus
reasonForCorrection
facility {
name
isDeleted
}
deviceType {
name
manufacturer
model
swabTypes {
internalId,
name
}
}
patient {
firstName
middleName
lastName
birthDate
gender
race
ethnicity
tribalAffiliation
role
lookupId
street
streetTwo
city
county
state
zipCode
country
email
phoneNumbers {
type
number
}
residentCongregateSetting
employedInHealthcare
preferredLanguage
}
createdBy {
nameInfo {
firstName
middleName
lastName
}
}
surveyData {
pregnancy
syphilisHistory
symptoms
symptomOnset
noSymptoms
genderOfSexualPartners
}
}
totalElements
}
}

query GetAllFacilities($showArchived: Boolean) {
facilities(showArchived: $showArchived) {
id
Expand Down
Loading
Loading