Skip to content

Commit c6f28c3

Browse files
committed
Enforce order steps are completed
Added active_workflow_step to InProgressAppointmentMixin
1 parent d702aee commit c6f28c3

50 files changed

Lines changed: 1488 additions & 495 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

manage_breast_screening/core/jinja2/workflow_step.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<div class="app-workflow-container">
1818
<div class="nhsuk-grid-row app-workflow-container__row">
1919
<div class="nhsuk-grid-column-one-quarter app-workflow-container__sidebar">
20-
{{ workflow_steps(presented_workflow.workflow_steps(active_workflow_step)) }}
20+
{{ workflow_steps(presented_workflow_steps) }}
2121
</div>
2222
<div class="nhsuk-grid-column-three-quarters app-workflow-container__main" id="workflow_content">
2323
{% set info_notification_params = get_notification_banner_params(

manage_breast_screening/mammograms/jinja2/mammograms/check_information.jinja

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
{% from "mammograms/check_information/images_taken_card.jinja" import images_taken_card %}
77
{% from "mammograms/check_information/medical_information_card.jinja" import medical_information_card %}
88

9-
{% set active_workflow_step = 'CHECK_INFORMATION' %}
10-
119
{% block step_content %}
1210
<p>Before concluding this appointment, confirm that the information recorded is correct.</p>
1311

manage_breast_screening/mammograms/jinja2/mammograms/confirm_identity.jinja

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
{% from "mammograms/macros.jinja" import appointment_cannot_proceed_link %}
77
{% from "components/participant-details/summary_list_rows.jinja" import address_html, date_of_birth_and_age_html, ethnicity_html %}
88

9-
{% set active_workflow_step = 'CONFIRM_IDENTITY' %}
10-
119
{% block step_content %}
1210
{% set return_url = request.path %}
1311
{% set confirm_button %}

manage_breast_screening/mammograms/jinja2/mammograms/gateway_images.jinja

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
{% from "nhsuk/components/button/macro.jinja" import button %}
33
{% from "nhsuk/components/fieldset/macro.jinja" import fieldset %}
44

5-
{% set active_workflow_step = 'TAKE_IMAGES' %}
6-
75
{% block form %}
86
<div class="nhsuk-u-margin-bottom-6"
97
data-module="app-image-stream"

manage_breast_screening/mammograms/jinja2/mammograms/image_details.jinja

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
{% from "nhsuk/components/button/macro.jinja" import button %}
33
{% from "nhsuk/components/fieldset/macro.jinja" import fieldset %}
44

5-
{% set active_workflow_step = 'TAKE_IMAGES' %}
6-
75
{% block form %}
86
<h2>How many images were taken?</h2>
97
<div class="nhsuk-grid-row">

manage_breast_screening/mammograms/jinja2/mammograms/multiple_images_information.jinja

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{% extends "workflow_step.jinja" %}
22
{% from "nhsuk/components/button/macro.jinja" import button %}
33

4-
{% set active_workflow_step = 'TAKE_IMAGES' %}
5-
64
{% block form %}
75
{{ form.series_fingerprint }}
86
<p>You have indicated multiple images were needed for some views.</p>

manage_breast_screening/mammograms/jinja2/mammograms/record_medical_information.jinja

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
{% from "mammograms/medical_information/section_cards.jinja" import mammogram_history_content, symptoms_content, medical_history_content, breast_features_content, other_information_content %}
55
{% from "mammograms/macros.jinja" import appointment_cannot_proceed_link %}
66

7-
{% set active_workflow_step = 'REVIEW_MEDICAL_INFORMATION' %}
8-
97
{% block step_content %}
108

119
{% set complete_all_button %}

manage_breast_screening/mammograms/jinja2/mammograms/take_images.jinja

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{% extends "workflow_step.jinja" %}
22

3-
{% set active_workflow_step = 'TAKE_IMAGES' %}
4-
53
{% block form %}
64
{% do form.standard_images.add_divider_after("NO_ADD_ADDITIONAL", "or") %}
75
{{ form.standard_images.as_field_group() }}

manage_breast_screening/mammograms/services/appointment_services.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,19 @@ def get_completed_steps(self):
148148
logger.info(f"Completed steps for {self.current_user.pk}: {step_names}")
149149

150150
return step_names
151+
152+
def is_valid_next_step(self, requested_step):
153+
completed_steps = self.get_completed_steps()
154+
for step in AppointmentWorkflowStepCompletion.StepNames:
155+
if step == requested_step:
156+
return True
157+
elif step not in completed_steps:
158+
logger.info(
159+
f"Invalid workflow step configuration. Step {step} "
160+
f"is incomplete but appears before the requested step {requested_step}"
161+
)
162+
return False
163+
164+
raise ValueError(
165+
f"Requested step {requested_step} not found in workflow steps."
166+
)

manage_breast_screening/mammograms/tests/conftest.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22

3+
from manage_breast_screening.mammograms.services.appointment_services import StepNames
34
from manage_breast_screening.participants.models.appointment import (
45
AppointmentStatusNames,
56
)
@@ -29,3 +30,57 @@ def in_progress_appointment(clinical_user_client):
2930
reinvite=False,
3031
clinic_slot__clinic__setting__provider=clinical_user_client.current_provider,
3132
)
33+
34+
35+
@pytest.fixture
36+
def confirmed_identity_appointment(clinical_user_client):
37+
appointment = AppointmentFactory.create(
38+
current_status=AppointmentStatusNames.IN_PROGRESS,
39+
current_status__created_by=clinical_user_client.user,
40+
clinic_slot__clinic__setting__provider=clinical_user_client.current_provider,
41+
)
42+
appointment.completed_workflow_steps.create(
43+
step_name=StepNames.CONFIRM_IDENTITY,
44+
created_by=clinical_user_client.user,
45+
)
46+
return appointment
47+
48+
49+
@pytest.fixture
50+
def reviewed_appointment(clinical_user_client):
51+
appointment = AppointmentFactory.create(
52+
current_status=AppointmentStatusNames.IN_PROGRESS,
53+
current_status__created_by=clinical_user_client.user,
54+
clinic_slot__clinic__setting__provider=clinical_user_client.current_provider,
55+
)
56+
appointment.completed_workflow_steps.create(
57+
step_name=StepNames.CONFIRM_IDENTITY,
58+
created_by=clinical_user_client.user,
59+
)
60+
appointment.completed_workflow_steps.create(
61+
step_name=StepNames.REVIEW_MEDICAL_INFORMATION,
62+
created_by=clinical_user_client.user,
63+
)
64+
return appointment
65+
66+
67+
@pytest.fixture
68+
def taken_images_appointment(clinical_user_client):
69+
appointment = AppointmentFactory.create(
70+
current_status=AppointmentStatusNames.IN_PROGRESS,
71+
current_status__created_by=clinical_user_client.user,
72+
clinic_slot__clinic__setting__provider=clinical_user_client.current_provider,
73+
)
74+
appointment.completed_workflow_steps.create(
75+
step_name=StepNames.CONFIRM_IDENTITY,
76+
created_by=clinical_user_client.user,
77+
)
78+
appointment.completed_workflow_steps.create(
79+
step_name=StepNames.REVIEW_MEDICAL_INFORMATION,
80+
created_by=clinical_user_client.user,
81+
)
82+
appointment.completed_workflow_steps.create(
83+
step_name=StepNames.TAKE_IMAGES,
84+
created_by=clinical_user_client.user,
85+
)
86+
return appointment

0 commit comments

Comments
 (0)