Skip to content

Commit 0cc0d2e

Browse files
authored
Merge pull request #4469 from nhsuk/healthcare-assistant-admin
Ensure HCAs have medical secretary role
2 parents b337e05 + 07d1e89 commit 0cc0d2e

20 files changed

+82
-77
lines changed

app/controllers/concerns/authentication_concern.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def selected_cis2_workgroup_is_valid?
4949
end
5050

5151
def selected_cis2_role_is_valid?
52-
cis2_info.is_admin? || cis2_info.is_nurse? ||
52+
cis2_info.is_medical_secretary? || cis2_info.is_nurse? ||
5353
cis2_info.is_healthcare_assistant? || cis2_info.is_superuser? ||
5454
cis2_info.is_prescriber?
5555
end

app/models/cis2_info.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class CIS2Info
44
include RequestSessionPersistable
55

66
NURSE_ROLE = "S8000:G8000:R8001"
7-
ADMIN_ROLE = "S8000:G8001:R8006"
7+
MEDICAL_SECRETARY_ROLE = "S8000:G8001:R8006"
88

99
SUPERUSER_WORKGROUP = "mavissuperusers"
1010

@@ -39,16 +39,17 @@ def team
3939
def has_valid_workgroup? =
4040
organisation&.teams&.exists?(workgroup: workgroups) || false
4141

42-
def is_admin?
43-
role_code == ADMIN_ROLE
42+
def is_medical_secretary?
43+
role_code == MEDICAL_SECRETARY_ROLE
4444
end
4545

4646
def is_nurse?
4747
role_code == NURSE_ROLE
4848
end
4949

5050
def is_healthcare_assistant?
51-
activity_codes.include?(PERSONAL_MEDICATION_ADMINISTRATION_ACTIVITY_CODE)
51+
role_code == MEDICAL_SECRETARY_ROLE &&
52+
activity_codes.include?(PERSONAL_MEDICATION_ADMINISTRATION_ACTIVITY_CODE)
5253
end
5354

5455
def is_prescriber?

app/models/user.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class User < ApplicationRecord
7777
enum :fallback_role,
7878
{
7979
nurse: 0,
80-
admin: 1,
80+
medical_secretary: 1,
8181
superuser: 2,
8282
healthcare_assistant: 3,
8383
prescriber: 4
@@ -133,14 +133,18 @@ def role_description
133133
elsif is_nurse?
134134
"Nurse"
135135
else
136-
"Administrator"
136+
"Medical secretary"
137137
end
138138

139139
is_superuser? ? "#{role} (Superuser)" : role
140140
end
141141

142-
def is_admin?
143-
cis2_enabled? ? cis2_info.is_admin? : fallback_role_admin?
142+
def is_medical_secretary?
143+
if cis2_enabled?
144+
cis2_info.is_medical_secretary?
145+
else
146+
fallback_role_medical_secretary?
147+
end
144148
end
145149

146150
def is_nurse?

db/seeds.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def create_team_sessions(user, team)
258258
# is not available and password= fails to run.
259259
team = create_team(ods_code: "R1L")
260260
user = create_user(:nurse, team:, email: "nurse.joy@example.com")
261-
create_user(:admin, team:, email: "admin.hope@example.com")
261+
create_user(:medical_secretary, team:, email: "admin.hope@example.com")
262262
create_user(:superuser, team:, email: "superuser@example.com")
263263
create_user(:healthcare_assistant, team:, email: "hca@example.com")
264264

spec/factories/teams.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
end
5454

5555
trait :with_one_admin do
56-
users { [create(:user, :admin, team: instance)] }
56+
users { [create(:user, :medical_secretary, team: instance)] }
5757
end
5858

5959
trait :with_one_healthcare_assistant do

spec/factories/users.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@
8080
end
8181
end
8282

83-
trait :admin do
84-
sequence(:email) { |n| "admin-#{n}@example.com" }
85-
role_code { CIS2Info::ADMIN_ROLE }
86-
fallback_role { :admin }
83+
trait :medical_secretary do
84+
sequence(:email) { |n| "medical-secretary-#{n}@example.com" }
85+
role_code { CIS2Info::MEDICAL_SECRETARY_ROLE }
86+
fallback_role { :medical_secretary }
8787
show_in_suppliers { false }
8888
end
8989

@@ -96,7 +96,7 @@
9696

9797
trait :healthcare_assistant do
9898
sequence(:email) { |n| "healthcare-assistant-#{n}@example.com" }
99-
role_code { nil }
99+
role_code { CIS2Info::MEDICAL_SECRETARY_ROLE }
100100
activity_codes do
101101
[CIS2Info::PERSONAL_MEDICATION_ADMINISTRATION_ACTIVITY_CODE]
102102
end
@@ -117,8 +117,8 @@
117117
end
118118
end
119119

120-
factory :admin, parent: :user, traits: %i[admin]
121120
factory :healthcare_assistant, parent: :user, traits: %i[healthcare_assistant]
121+
factory :medical_secretary, parent: :user, traits: %i[medical_secretary]
122122
factory :prescriber, parent: :user, traits: %i[prescriber]
123123
factory :superuser, parent: :user, traits: %i[superuser]
124124
end

spec/features/doubles_vaccination_cannot_record_as_admin_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
describe "MenACWY and Td/IPV vaccination" do
44
around { |example| travel_to(Time.zone.local(2024, 2, 1)) { example.run } }
55

6-
scenario "Cannot be recorded by an admin" do
6+
scenario "Cannot be recorded by a medical secretary" do
77
given_i_am_signed_in_as_an_admin
88
when_i_go_to_a_patient_that_is_ready_to_vaccinate
99
then_i_cannot_record_that_the_patient_has_been_vaccinated
@@ -32,7 +32,7 @@ def given_i_am_signed_in_as_an_admin
3232
session: @session
3333
)
3434

35-
sign_in team.users.first, role: :admin
35+
sign_in team.users.first, role: :medical_secretary
3636

3737
visit "/"
3838
end

spec/features/edit_vaccination_record_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
then_i_should_see_the_vaccination_record
184184
end
185185

186-
scenario "Cannot as an admin" do
186+
scenario "Cannot as a medical secretary" do
187187
given_i_am_signed_in_as_an_admin
188188
and_an_administered_vaccination_record_exists
189189

@@ -254,7 +254,7 @@ def given_i_am_signed_in
254254
end
255255

256256
def given_i_am_signed_in_as_an_admin
257-
sign_in @team.users.first, role: :admin
257+
sign_in @team.users.first, role: :medical_secretary
258258
end
259259

260260
def and_an_administered_vaccination_record_exists

spec/features/patient_specific_directions_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
scenario "admin cannot bulk add PSDs to patients" do
2727
given_a_flu_programme_with_a_running_session(user_type: :with_one_admin)
2828
and_a_patient_with_consent_given_nasal_only_triage_not_needed
29-
and_i_am_signed_in(role: :admin)
29+
and_i_am_signed_in(role: :medical_secretary)
3030

3131
when_i_go_to_the_session_psds_tab
3232
then_i_should_not_see_link_to_bulk_add_psds

spec/features/td_ipv_already_had_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
then_i_see_the_patient_doesnt_need_triage
6262
end
6363

64-
scenario "can't record as already vaccinated as an admin" do
64+
scenario "can't record as already vaccinated as a medical secretary" do
6565
given_a_td_ipv_programme_with_a_session(clinic: false)
6666
and_a_patient_is_in_the_session
6767
and_the_patient_doesnt_need_triage
@@ -147,7 +147,7 @@ def when_i_go_the_session
147147
end
148148

149149
def when_i_go_the_session_as_an_admin
150-
sign_in @nurse, role: :admin
150+
sign_in @nurse, role: :medical_secretary
151151
visit dashboard_path
152152
click_on "Sessions", match: :first
153153
choose "Scheduled"

0 commit comments

Comments
 (0)