Skip to content
Merged
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
@@ -0,0 +1,21 @@
{% from 'nhsuk/components/warning-callout/macro.jinja' import warningCallout %}
{% macro appointment_note_banner(appointment_note, change_url=None, show_change_link=True) %}
{% if appointment_note %}
{% set appointment_note_html %}
<div class="nhsuk-u-margin-bottom-3">
{{ appointment_note.content | nl2br }}
</div>
{% if show_change_link and change_url %}
<p class="nhsuk-u-margin-bottom-0">
<a href="{{ change_url }}">
Change<span class="nhsuk-u-visually-hidden"> appointment note</span>
</a>
</p>
{% endif %}
{% endset %}
{{ warningCallout({
"heading": "Appointment note",
"html": appointment_note_html
}) }}
{% endif %}
{% endmacro %}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{% extends 'layout-app.jinja' %}
{% from 'nhsuk/components/card/macro.jinja' import card %}
{% from 'nhsuk/components/warning-callout/macro.jinja' import warningCallout %}
{% from 'nhsuk/components/back-link/macro.jinja' import backLink %}
{% from 'nhsuk/components/summary-list/macro.jinja' import summaryList %}
{% from 'components/appointment-status/macro.jinja' import appointment_status %}
{% from 'components/appointment-header/macro.jinja' import appointment_header %}
{% from 'components/check-in/macro.jinja' import check_in %}
{% from 'components/secondary-navigation/macro.jinja' import app_secondary_navigation %}
{% from 'mammograms/special_appointments/special_appointment_banner.jinja' import special_appointment_banner %}
{% from 'mammograms/appointment_notes/appointment_note_banner.jinja' import appointment_note_banner %}

{% block beforeContent %}
{{ backLink({
Expand Down Expand Up @@ -55,6 +55,11 @@
"items": secondary_nav_items
}) }}

{{ appointment_note_banner(
appointment_note,
change_url=url('mammograms:appointment_note', kwargs={'pk': presented_appointment.pk})
) }}

{% set appointment_details_html %}
{{ summaryList({
"rows": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)

from ...core.utils.date_formatting import format_date, format_relative_date, format_time
from ...participants.models import AppointmentStatus, SupportReasons
from ...participants.models import AppointmentNote, AppointmentStatus, SupportReasons
from ...participants.presenters import ParticipantPresenter, status_colour


Expand Down Expand Up @@ -113,6 +113,13 @@ def status_attribution(self):
else:
return None

@cached_property
def note(self):
try:
return self._appointment.note
except AppointmentNote.DoesNotExist:
return None


class ClinicSlotPresenter:
def __init__(self, clinic_slot):
Expand Down
7 changes: 7 additions & 0 deletions manage_breast_screening/mammograms/views/appointment_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging

from django.contrib import messages
from django.http import Http404
from django.shortcuts import redirect, render
from django.urls import reverse, reverse_lazy
Expand Down Expand Up @@ -68,6 +69,7 @@ def get(self, request, *args, **kwargs):
"presented_appointment": appointment_presenter,
"presented_participant": appointment_presenter.participant,
"presented_mammograms": last_known_mammogram_presenter,
"appointment_note": appointment_presenter.note,
"secondary_nav_items": present_secondary_nav(
appointment.pk, current_tab="appointment"
),
Expand Down Expand Up @@ -155,6 +157,11 @@ def form_valid(self, form):
auditor.audit_create(note)
else:
auditor.audit_update(note)
messages.add_message(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Design question, but I'm wondering if this success message is unnecessary here.

Instead of redirecting back to the top of the notes tab, we could potentially redirect the user back to the appointment details tab, where the appointment note is visible as a banner.

When I tested the current version, it wasn't obvious to me that the banner was added to the appointment details tab after submitting the form on the notes tab.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.request,
messages.SUCCESS,
"Appointment note saved",
)
return redirect("mammograms:appointment_note", pk=self.appointment.pk)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ def test_clinical_user_adds_and_updates_an_appointment_note(self):

self.when_i_enter_a_note()
self.and_i_save_the_note()
self.then_i_see_a_message_confirming_the_save()
self.then_the_note_field_contains(self.initial_note_text)
self.and_the_appointment_details_tab_shows_the_note(self.initial_note_text)

self.when_i_update_the_note()
self.and_i_save_the_note()
self.then_i_see_a_message_confirming_the_save()
self.then_the_note_field_contains(self.updated_note_text)
self.and_the_appointment_details_tab_shows_the_note(self.updated_note_text)

def and_there_is_an_appointment_for_my_provider(self):
self.appointment = AppointmentFactory(
Expand All @@ -48,6 +52,10 @@ def when_i_enter_a_note(self):
self.page.get_by_label("Note").fill(self.initial_note_text)

def when_i_update_the_note(self):
secondary_nav = self.page.locator(".app-secondary-navigation")
expect(secondary_nav).to_be_visible()
note_tab = secondary_nav.get_by_text("Note")
note_tab.click()
field = self.page.get_by_label("Note")
expect(field).to_have_value(self.initial_note_text)
field.fill(self.updated_note_text)
Expand All @@ -61,3 +69,20 @@ def when_i_save_the_note(self):

def then_the_note_field_contains(self, text):
expect(self.page.get_by_label("Note")).to_have_value(text)

def then_i_see_a_message_confirming_the_save(self):
banner = self.page.locator(".nhsuk-notification-banner--success")
expect(banner).to_be_visible()
expect(banner).to_contain_text("Appointment note saved")

def and_the_appointment_details_tab_shows_the_note(self, text):
secondary_nav = self.page.locator(".app-secondary-navigation")
expect(secondary_nav).to_be_visible()
appointment_details_tab = secondary_nav.get_by_text("Appointment details")
appointment_details_tab.click()

note_container = self.page.locator(
".nhsuk-warning-callout", has_text="Appointment note"
)
expect(note_container).to_be_visible()
expect(note_container).to_contain_text(text)
Loading