Skip to content

Commit

Permalink
Add syphilis AOE data on result View Details (#8150)
Browse files Browse the repository at this point in the history
* Add full AOE survey data on GetTestResultDetails

* Update typing on optional user fields

* Update TestResultDetailsModal.test.tsx

* Update test for new blurred vision code

* Update order of symptoms in test string
  • Loading branch information
mpbrown authored Sep 26, 2024
1 parent 00710d9 commit e5c2ccc
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import gov.cdc.usds.simplereport.db.model.Result;
import gov.cdc.usds.simplereport.db.model.TestEvent;
import gov.cdc.usds.simplereport.db.model.auxiliary.AskOnEntrySurvey;
import gov.cdc.usds.simplereport.db.model.auxiliary.ResolvedSurveyData;
import gov.cdc.usds.simplereport.db.repository.PatientLinkRepository;
import java.time.LocalDate;
import java.util.Date;
Expand Down Expand Up @@ -106,6 +107,11 @@ public Set<Result> getResults(TestEvent testEvent) {
return testEvent.getResults();
}

@SchemaMapping(typeName = "TestResult", field = "surveyData")
public ResolvedSurveyData getSurveyData(TestEvent testEvent) {
return new ResolvedSurveyData(getSurvey(testEvent));
}

@Override
@SchemaMapping(typeName = "TestResult", field = "id")
public UUID getId(TestEvent testEvent) {
Expand Down
5 changes: 3 additions & 2 deletions backend/src/main/resources/graphql/main.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,13 @@ type TestResult {
symptomOnset: LocalDate
genderOfSexualPartners: [String]
deviceType: DeviceType
results: [MultiplexResult]
results: [MultiplexResult!]
dateTested: DateTime
correctionStatus: String
reasonForCorrection: String
createdBy: ApiUser
patientLink: PatientLink
surveyData: AskOnEntrySurvey
}

type TestResultsPage {
Expand All @@ -314,7 +315,7 @@ type AskOnEntrySurvey {
symptoms: String
symptomOnset: LocalDate
noSymptoms: Boolean
genderOfSexualPartners: [String]
genderOfSexualPartners: [String!]
}

type Result {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ const nonMultiplexTestResult = {
symptoms: '{"00000":"false"}',
symptomOnset: "myOnset",
pregnancy: null,
surveyData: {
pregnancy: null,
syphilisHistory: null,
symptoms: '{"00000":"false"}',
symptomOnset: "myOnset",
noSymptoms: false,
genderOfSexualPartners: null,
},
deviceType: {
name: "Fake device",
},
Expand Down Expand Up @@ -67,8 +75,8 @@ hivTestResult.results = [
__typename: "MultiplexResult",
},
];
hivTestResult.genderOfSexualPartners = ["female", "male", "other"];
hivTestResult.pregnancy = "77386006";
hivTestResult.surveyData.genderOfSexualPartners = ["female", "male", "other"];
hivTestResult.surveyData.pregnancy = "77386006";

const syphilisTestResult = JSON.parse(JSON.stringify(nonMultiplexTestResult));
syphilisTestResult.results = [
Expand All @@ -78,8 +86,17 @@ syphilisTestResult.results = [
__typename: "MultiplexResult",
},
];
syphilisTestResult.pregnancy = "77386006";
syphilisTestResult.symptoms = '{"266128007":"true"}';
syphilisTestResult.surveyData.pregnancy = "77386006";
syphilisTestResult.surveyData.syphilisHistory = "1087151000119108";
syphilisTestResult.surveyData.symptoms =
'{"724386005":"false","195469007":"false","26284000":"false","266128007":"true","56940005":"true","91554004":"false","15188001":"false","246636008":"true","56317004":"false"}';
syphilisTestResult.surveyData.symptomOnset = "2024-09-24";
syphilisTestResult.surveyData.noSymptoms = false;
syphilisTestResult.surveyData.genderOfSexualPartners = [
"female",
"male",
"other",
];

const renderComponent = (testResult: TestResult) =>
render(
Expand Down Expand Up @@ -176,8 +193,17 @@ describe("Syphilis TestResultDetailsModal", () => {
expect(screen.getByText("Syphilis result")).toBeInTheDocument();
expect(screen.getByText("Symptoms")).toBeInTheDocument();
expect(screen.getByText("Symptom onset")).toBeInTheDocument();
expect(screen.getByText("Body Rash")).toBeInTheDocument();
expect(
screen.getByText(
"Palmar (hand)/plantar (foot) rash, Blurred vision, Body Rash"
)
).toBeInTheDocument();
expect(screen.getByText("Gender of sexual partners")).toBeInTheDocument();
expect(screen.getByText("Female, Male, Other")).toBeInTheDocument();
expect(screen.getByText("Pregnant?")).toBeInTheDocument();
expect(
screen.getByText("Previously told they have syphilis?")
).toBeInTheDocument();
});

it("matches screenshot", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ import { formatFullName } from "../../../utils/user";
import { symptomsStringToArray } from "../../../utils/symptoms";
import {
GetTestResultDetailsDocument,
GetTestResultDetailsQuery,
Result as ResponseResult,
} from "../../../../generated/graphql";
import {
PregnancyCode,
Pregnancy,
pregnancyMap,
SyphilisHistory,
syphillisHistoryMap,
} from "../../../../patientApp/timeOfTest/constants";
import {
getSortedResults,
Expand All @@ -24,33 +27,6 @@ import "./TestResultPrintModal.scss";
import { MULTIPLEX_DISEASES } from "../../constants";
import { formatGenderOfSexualPartnersForDisplay } from "../../../utils/gender";

type Result = {
dateTested: string;
results: MultiplexResult[];
correctionStatus: TestCorrectionStatus;
noSymptoms: boolean;
symptoms: string;
symptomOnset: string;
pregnancy: PregnancyCode;
genderOfSexualPartners?: string[];
deviceType: {
name: string;
};
patient: {
firstName: string;
middleName: string;
lastName: string;
birthDate: string;
};
createdBy: {
name: {
firstName: string;
middleName: string;
lastName: string;
};
};
};

const labelClasses = "text-bold text-no-strike text-ink";
const containerClasses =
"width-full font-sans-md add-list-reset border-base-lighter border-2px radius-md padding-x-2 padding-y-1";
Expand All @@ -61,8 +37,11 @@ interface TestResultDetailsModalProps {
testResult: ResponseResult | undefined;
closeModal: () => void;
}

type QueriedTestResult = NonNullable<GetTestResultDetailsQuery>["testResult"];

interface DetachedTestResultDetailsModalProps {
data: { testResult: Nullable<Result> };
data: { testResult: NonNullable<QueriedTestResult> };
closeModal: () => void;
}

Expand All @@ -74,15 +53,21 @@ export const DetachedTestResultDetailsModal = ({
data?.testResult.results,
MULTIPLEX_DISEASES.HIV
);
const isSyphilisResult = !!getResultForDisease(
data?.testResult.results,
MULTIPLEX_DISEASES.SYPHILIS
);

const dateTested = data?.testResult.dateTested;

const results = data?.testResult.results;
const correctionStatus = data?.testResult.correctionStatus;
const symptoms = data?.testResult.symptoms;
const symptomOnset = data?.testResult.symptomOnset;
const pregnancy = data?.testResult.pregnancy;
const genderOfSexualPartners = data?.testResult.genderOfSexualPartners ?? [];
const symptoms = data?.testResult.surveyData?.symptoms;
const symptomOnset = data?.testResult.surveyData?.symptomOnset;
const pregnancy = data?.testResult.surveyData?.pregnancy;
const genderOfSexualPartners =
data?.testResult.surveyData?.genderOfSexualPartners ?? [];
const syphilisHistory = data?.testResult.surveyData?.syphilisHistory;
const deviceType = data?.testResult.deviceType;
const patient = data?.testResult.patient;
const createdBy = data?.testResult.createdBy;
Expand Down Expand Up @@ -199,11 +184,11 @@ export const DetachedTestResultDetailsModal = ({
)}
<DetailsRow
label="Pregnant?"
value={pregnancy && pregnancyMap[pregnancy]}
value={pregnancy && pregnancyMap[pregnancy as keyof Pregnancy]}
removed={removed}
aria-describedby="result-detail-title"
/>
{isHIVResult && (
{(isHIVResult || isSyphilisResult) && (
<DetailsRow
label="Gender of sexual partners"
value={formatGenderOfSexualPartnersForDisplay(
Expand All @@ -213,6 +198,17 @@ export const DetachedTestResultDetailsModal = ({
aria-describedby="result-detail-title"
/>
)}
{isSyphilisResult && (
<DetailsRow
label="Previously told they have syphilis?"
value={
syphilisHistory &&
syphillisHistoryMap[syphilisHistory as keyof SyphilisHistory]
}
removed={removed}
aria-describedby="result-detail-title"
/>
)}
<DetailsRow
label="Submitted by"
value={createdBy?.name && formatFullName(createdBy.name)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ Object {
<td
class="padding-y-3 border-bottom-1px border-base-lighter"
>
Body Rash
Palmar (hand)/plantar (foot) rash, Blurred vision, Body Rash
</td>
</tr>
<tr>
Expand All @@ -486,7 +486,7 @@ Object {
<td
class="padding-y-3 border-bottom-1px border-base-lighter"
>
Invalid date
09/24/2024
</td>
</tr>
<tr>
Expand All @@ -501,6 +501,30 @@ Object {
Yes
</td>
</tr>
<tr>
<th
class="text-bold text-no-strike text-ink padding-y-3 border-bottom-1px border-base-lighter width-card-lg text-left"
>
Gender of sexual partners
</th>
<td
class="padding-y-3 border-bottom-1px border-base-lighter"
>
Female, Male, Other
</td>
</tr>
<tr>
<th
class="text-bold text-no-strike text-ink padding-y-3 border-bottom-1px border-base-lighter width-card-lg text-left"
>
Previously told they have syphilis?
</th>
<td
class="padding-y-3 border-bottom-1px border-base-lighter"
>
Yes
</td>
</tr>
<tr>
<th
class="text-bold text-no-strike text-ink padding-y-3 width-card-lg text-left"
Expand Down Expand Up @@ -634,7 +658,7 @@ Object {
<td
class="padding-y-3 border-bottom-1px border-base-lighter"
>
Body Rash
Palmar (hand)/plantar (foot) rash, Blurred vision, Body Rash
</td>
</tr>
<tr>
Expand All @@ -646,7 +670,7 @@ Object {
<td
class="padding-y-3 border-bottom-1px border-base-lighter"
>
Invalid date
09/24/2024
</td>
</tr>
<tr>
Expand All @@ -661,6 +685,30 @@ Object {
Yes
</td>
</tr>
<tr>
<th
class="text-bold text-no-strike text-ink padding-y-3 border-bottom-1px border-base-lighter width-card-lg text-left"
>
Gender of sexual partners
</th>
<td
class="padding-y-3 border-bottom-1px border-base-lighter"
>
Female, Male, Other
</td>
</tr>
<tr>
<th
class="text-bold text-no-strike text-ink padding-y-3 border-bottom-1px border-base-lighter width-card-lg text-left"
>
Previously told they have syphilis?
</th>
<td
class="padding-y-3 border-bottom-1px border-base-lighter"
>
Yes
</td>
</tr>
<tr>
<th
class="text-bold text-no-strike text-ink padding-y-3 width-card-lg text-left"
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/app/testResults/viewResults/operations.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ query GetTestResultDetails($id: ID!) {
symptomOnset
pregnancy
genderOfSexualPartners
surveyData {
pregnancy
syphilisHistory
symptoms
symptomOnset
noSymptoms
genderOfSexualPartners
}
deviceType {
name
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/app/utils/user.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
type OptionalString = string | undefined | null;

type RequiredUserFields = {
firstName: OptionalString;
middleName: OptionalString;
lastName: OptionalString;
firstName?: OptionalString;
middleName?: OptionalString;
lastName?: OptionalString;
suffix?: OptionalString;
};

Expand Down
Loading

0 comments on commit e5c2ccc

Please sign in to comment.