diff --git a/frontend/src/pages/SurveyPage.jsx b/frontend/src/pages/SurveyPage.jsx
index 83bd3cb..5bbd233 100644
--- a/frontend/src/pages/SurveyPage.jsx
+++ b/frontend/src/pages/SurveyPage.jsx
@@ -476,6 +476,12 @@ function QuestionField({
return null;
}
+/** Soft eligibility note when Extended-Dose Pack duration is under 6 months. */
+const EXTENDED_DOSE_DURATION_ID = 'extended_dose_duration';
+const LESS_THAN_SIX_MONTHS_ID = 'less_than_6_months';
+const ELIGIBILITY_NOTE =
+ 'As per the study eligibility criteria, physicians must have at least 6 months of prescribing experience with both packs. Kindly review and confirm your response.';
+
export default function SurveyPage() {
const { token } = useParams();
const [screen, setScreen] = useState('loading');
@@ -486,6 +492,7 @@ export default function SurveyPage() {
const [error, setError] = useState('');
const [stepErrors, setStepErrors] = useState([]);
const [confirming, setConfirming] = useState(false);
+ const [eligibilityConfirming, setEligibilityConfirming] = useState(false);
const [busy, setBusy] = useState(false);
const [saving, setSaving] = useState(false);
/** @type {[{ message: string, tone: 'success' | 'error' } | null, Function]} */
@@ -608,6 +615,19 @@ export default function SurveyPage() {
dirtyRef.current = true;
setStepErrors((current) => current.filter((item) => item.id !== id));
setAnswers((current) => ({ ...current, [id]: value }));
+
+ if (
+ id === EXTENDED_DOSE_DURATION_ID &&
+ value &&
+ typeof value === 'object' &&
+ value.choice === LESS_THAN_SIX_MONTHS_ID
+ ) {
+ setEligibilityConfirming(true);
+ }
+ }
+
+ function closeEligibilityConfirm() {
+ setEligibilityConfirming(false);
}
async function saveProgress() {
@@ -873,6 +893,23 @@ export default function SurveyPage() {
) : null}
+ {eligibilityConfirming ? (
+
+
+
Please confirm
+
{ELIGIBILITY_NOTE}
+
+
+
+
+
+ ) : null}
);
}
diff --git a/frontend/src/pages/SurveyPage.test.jsx b/frontend/src/pages/SurveyPage.test.jsx
index 4d469cc..88b61f5 100644
--- a/frontend/src/pages/SurveyPage.test.jsx
+++ b/frontend/src/pages/SurveyPage.test.jsx
@@ -232,4 +232,63 @@ describe('survey steps', () => {
fireEvent.change(select, { target: { value: 'kerala' } });
expect(select).toHaveValue('kerala');
});
+
+ it('shows an eligibility note when Extended-Dose Pack duration is under 6 months', async () => {
+ const withDuration = {
+ ...survey,
+ definition: {
+ sections: [
+ {
+ id: 'prescribing',
+ title: 'Prescribing',
+ questions: [
+ {
+ id: 'extended_dose_duration',
+ type: 'single_choice',
+ label:
+ 'For how long have you been prescribing the Extended-Dose Pack to your patients with asthma and/or COPD?',
+ required: true,
+ options: [
+ { id: 'less_than_6_months', label: 'Less than 6 months' },
+ { id: 'six_months_to_one_year', label: '6 months to less than 1 year' },
+ { id: 'more_than_one_year', label: 'More than 1 year' },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+ };
+ vi.stubGlobal(
+ 'fetch',
+ vi.fn().mockResolvedValue({ ok: true, json: async () => withDuration }),
+ );
+
+ renderSurvey();
+ const underSix = await screen.findByRole('radio', { name: 'Less than 6 months' });
+ expect(underSix).not.toBeChecked();
+
+ fireEvent.click(underSix);
+ expect(underSix).toBeChecked();
+ expect(
+ await screen.findByText(
+ /physicians must have at least 6 months of prescribing experience with both packs/i,
+ ),
+ ).toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole('button', { name: 'Confirm' }));
+ expect(
+ screen.queryByText(
+ /physicians must have at least 6 months of prescribing experience with both packs/i,
+ ),
+ ).not.toBeInTheDocument();
+ expect(underSix).toBeChecked();
+
+ fireEvent.click(screen.getByRole('radio', { name: 'More than 1 year' }));
+ expect(
+ screen.queryByText(
+ /physicians must have at least 6 months of prescribing experience with both packs/i,
+ ),
+ ).not.toBeInTheDocument();
+ });
});