Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
Make Place-based exposure screen conditional on severity (#1534)
Browse files Browse the repository at this point in the history
  • Loading branch information
smcmurtry authored Apr 28, 2021
1 parent d804815 commit 62c3889
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 24 deletions.
14 changes: 11 additions & 3 deletions src/locale/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,18 @@
"OutbreakExposed": {
"Title": "Possible exposure at a visit",
"Body": "Someone tested positive from one of your visits.",
"NextSteps": {
"CTA": "Negative test?",
"SelfIsolate": {
"Title": "Isolate and get tested",
"Body": "If you have symptoms, get tested right away. If you do not have symptoms, wait to get tested at least 7 days after the date of exposure.\n\nYou also need to isolate for 14 days from the date of exposure.\n\nIf you have questions, contact your local public health unit.",
"CTA": "Negative test?"
"Body": "You’re a high-risk contact. If you have symptoms, get tested right away. If you do not have symptoms, wait to get tested at least 7 days after the date of exposure.\n\nYou also need to isolate for 14 days from the date of exposure.\n\nIf you have questions, contact your local public health unit."
},
"GetTested": {
"Title": "Get tested",
"Body": "You need to get tested as soon as possible.\n\nIn the meantime, avoid contact with vulnerable people.\n\nIf you have questions, contact your local public health unit."
},
"SelfMonitor": {
"Title": "Avoid people and self-monitor",
"Body": "You need to avoid contact with vulnerable people and watch yourself carefully for symptoms. If you get symptoms, take a self-assessment.\n\nIf you have questions, contact your local public health unit."
}
}
},
Expand Down
14 changes: 11 additions & 3 deletions src/locale/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,18 @@
"OutbreakExposed": {
"Title": "Exposition possible lors d’une visite",
"Body": "Une personne déclarée positive était présente lors d’une de vos visites.",
"NextSteps": {
"CTA": "Résultat de test négatif?",
"SelfIsolate": {
"Title": "Isolez-vous et passez un test",
"Body": "Si vous avez des symptômes, faites-vous tester immédiatement. Si vous n’en avez pas, attendez 7 jours après la date d’exposition pour vous faire tester.\n\nVous devez vous isoler pendant 14 jours à partir de la date d’exposition.\n\nPour toute question, contactez le bureau de santé de votre région.",
"CTA": "Résultat de test négatif?"
"Body": "Vous êtes un contact à risque élevé. Si vous avez des symptômes, faites-vous tester immédiatement. Si vous n’en avez pas, attendez 7 jours après la date d’exposition pour vous faire tester.\n\nVous devez vous isoler pendant 14 jours à partir de la date d’exposition.\n\nPour toute question, contactez le bureau de santé de votre région."
},
"GetTested": {
"Title": "Passez un test",
"Body": "Vous devez passer un test de dépistage dès que possible.\n\nEntre-temps, évitez les contacts avec les personnes vulnérables.\n\nPour toute question, contactez le bureau de santé de votre région."
},
"SelfMonitor": {
"Title": "Évitez les contacts et surveillez vos symptômes",
"Body": "Vous devez éviter les contacts avec les personnes vulnérables et surveiller vos symptômes. Si vous en développez, remplissez une autoévaluation.\n\nPour toute question, contactez le bureau de santé de votre région."
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/locale/translations/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/screens/home/views/ClearOutbreakExposureView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const ClearOutbreakExposureScreen = () => {
export const NegativeOutbreakTestButton = () => {
const navigation = useNavigation();
const i18n = useI18n();
const text = i18n.translate(`QRCode.OutbreakExposed.NextSteps.CTA`);
const text = i18n.translate(`QRCode.OutbreakExposed.CTA`);

const toClearOutbreakExposure = useCallback(() => navigation.navigate('ClearOutbreakExposure'), [navigation]);

Expand Down
68 changes: 54 additions & 14 deletions src/screens/home/views/OutbreakExposedView.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,76 @@
import React from 'react';
import {RoundedBox, Text} from 'components';
import {useI18n} from 'locale';
import {RoundedBox, Text, TextMultiline} from 'components';
import {useI18n, I18n} from 'locale';
import {useOutbreakService} from 'services/OutbreakService';
import {getCurrentOutbreakHistory, OutbreakSeverity} from 'shared/qr';

import {BaseHomeView} from '../components/BaseHomeView';
import {HomeScreenTitle} from '../components/HomeScreenTitle';

import {NegativeOutbreakTestButton} from './ClearOutbreakExposureView';

const ExposureText = () => {
export const OutbreakExposedView = () => {
const i18n = useI18n();
const {outbreakHistory} = useOutbreakService();
const currentOutbreakHistory = getCurrentOutbreakHistory(outbreakHistory);
const mostRecentHistoryItem = currentOutbreakHistory[0];
const severity = mostRecentHistoryItem.severity;

return (
<>
<BaseHomeView iconName="hand-caution-yellow" testID="outbreakExposure">
<RoundedBox isFirstBox>
<HomeScreenTitle>{i18n.translate(`QRCode.OutbreakExposed.Title`)}</HomeScreenTitle>
<Text marginBottom="m">{i18n.translate(`QRCode.OutbreakExposed.Body`)}</Text>
</RoundedBox>

<RoundedBox isFirstBox={false}>
<Text variant="bodyTitle" marginBottom="m" accessibilityRole="header">
{i18n.translate('QRCode.OutbreakExposed.NextSteps.Title')}
</Text>
<Text marginBottom="m">{i18n.translate('QRCode.OutbreakExposed.NextSteps.Body')}</Text>
<NegativeOutbreakTestButton />
<ConditionalText severity={severity} i18n={i18n} />
</RoundedBox>
</BaseHomeView>
);
};

const ConditionalText = ({severity, i18n}: {severity: OutbreakSeverity; i18n: I18n}) => {
switch (severity) {
case OutbreakSeverity.GetTested:
return <GetTestedText i18n={i18n} />;
case OutbreakSeverity.SelfIsolate:
return <IsolateText i18n={i18n} />;
case OutbreakSeverity.SelfMonitor:
return <MonitorText i18n={i18n} />;
}
};

const IsolateText = ({i18n}: {i18n: I18n}) => {
return (
<>
<Text variant="bodyTitle" marginBottom="m" accessibilityRole="header">
{i18n.translate('QRCode.OutbreakExposed.SelfIsolate.Title')}
</Text>
<TextMultiline marginBottom="m" text={i18n.translate('QRCode.OutbreakExposed.SelfIsolate.Body')} />
<NegativeOutbreakTestButton />
</>
);
};

export const OutbreakExposedView = () => {
const MonitorText = ({i18n}: {i18n: I18n}) => {
return (
<BaseHomeView iconName="hand-caution-yellow" testID="outbreakExposure">
<ExposureText />
</BaseHomeView>
<>
<Text variant="bodyTitle" marginBottom="m" accessibilityRole="header">
{i18n.translate('QRCode.OutbreakExposed.SelfMonitor.Title')}
</Text>
<TextMultiline marginBottom="m" text={i18n.translate('QRCode.OutbreakExposed.SelfMonitor.Body')} />
</>
);
};

const GetTestedText = ({i18n}: {i18n: I18n}) => {
return (
<>
<Text variant="bodyTitle" marginBottom="m" accessibilityRole="header">
{i18n.translate('QRCode.OutbreakExposed.GetTested.Title')}
</Text>
<TextMultiline marginBottom="m" text={i18n.translate('QRCode.OutbreakExposed.GetTested.Body')} />
<NegativeOutbreakTestButton />
</>
);
};
16 changes: 14 additions & 2 deletions src/shared/qr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import {getCurrentDate, getHoursBetween} from './date-fns';

export const OUTBREAK_EXPOSURE_DURATION_DAYS = 14;

export enum OutbreakSeverity {
SelfMonitor = 1,
SelfIsolate = 2,
GetTested = 3,
}

export interface CheckInData {
id: string;
name: string;
Expand Down Expand Up @@ -46,6 +52,7 @@ export interface OutbreakHistoryItem {
outbreakEndTimestamp: number;
checkInTimestamp: number;
notificationTimestamp: number;
severity: OutbreakSeverity;
}

/** returns a new outbreakHistory with the `isExpired` property updated */
Expand Down Expand Up @@ -75,13 +82,17 @@ export const ignoreHistoryItems = (
});
};

export const isExposedToOutbreak = (outbreakHistory: OutbreakHistoryItem[]) => {
const currentOutbreakHistory = outbreakHistory.filter(outbreak => {
export const getCurrentOutbreakHistory = (outbreakHistory: OutbreakHistoryItem[]) => {
return outbreakHistory.filter(outbreak => {
if (outbreak.isExpired || outbreak.isIgnored) {
return false;
}
return true;
});
};

export const isExposedToOutbreak = (outbreakHistory: OutbreakHistoryItem[]) => {
const currentOutbreakHistory = getCurrentOutbreakHistory(outbreakHistory);

if (currentOutbreakHistory.length > 0) {
return true;
Expand Down Expand Up @@ -206,6 +217,7 @@ export const createOutbreakHistoryItem = (matchData: MatchData): OutbreakHistory
outbreakEndTimestamp: Number(matchData.outbreakEvent.endTime),
checkInTimestamp,
notificationTimestamp: getCurrentDate().getTime() /* revisit */,
severity: matchData.outbreakEvent.severity,
};
return newItem;
};
Expand Down

0 comments on commit 62c3889

Please sign in to comment.