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
20 changes: 0 additions & 20 deletions app/lib/patient_team_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def relations
school_move_school_relation,
school_move_team_relation,
vaccination_record_import_relation,
vaccination_record_organisation_relation,
vaccination_record_session_relation
]
end
Expand Down Expand Up @@ -182,25 +181,6 @@ def vaccination_record_import_relation
)
end

def vaccination_record_organisation_relation
source = PatientTeam.sources.fetch("vaccination_record_organisation")

scope =
merge_patient_scope(
VaccinationRecord.where(
session_id: nil
).joins_teams_on_performed_ods_code
)

scope = scope.merge(team_scope) if team_scope

scope.select(
:patient_id,
Arel.sql("teams.id AS team_id"),
Arel.sql("#{source} AS source")
)
end

def vaccination_record_session_relation
source = PatientTeam.sources.fetch("vaccination_record_session")

Expand Down
3 changes: 2 additions & 1 deletion spec/features/cli_teams_reset_national_reporting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ def and_a_patient_is_associated_with_both_teams
:vaccination_record,
team: @point_of_care_team,
patient: @shared_patient,
performed_at: 2.days.ago
performed_at: 2.days.ago,
session: create(:session, team: @point_of_care_team)
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

def given_mavis_logins_are_configured
@team = create(:team, :national_reporting, :with_one_nurse, ods_code: "R1L")
create(:school, team: @team, urn: 100_000)
@school = create(:school, team: @team, urn: 100_000)
end

def given_i_am_signed_in_as_a_national_reporting_user
Expand All @@ -73,7 +73,12 @@ def given_a_patient_already_exists
)

# Create a vaccination record to link this patient with the team
create(:vaccination_record, patient: @existing_patient, team: @team)
create(
:vaccination_record,
patient: @existing_patient,
team: @team,
session: create(:session, team: @team, location: @school)
)
end

def and_sending_to_nhs_immunisations_api_is_enabled
Expand Down
3 changes: 2 additions & 1 deletion spec/features/national_reporting_team_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def given_i_am_signed_in_as_an_national_reporting_team
programmes: [Programme.flu, Programme.hpv],
ods_code: "XX99"
)
create(:school, team: @team, urn: 100_000)
@school = create(:school, team: @team, urn: 100_000)
sign_in @team.users.first
end

Expand All @@ -79,6 +79,7 @@ def and_there_is_a_child_with_parents
:vaccination_record,
programme: Programme.flu,
patient: @child_with_parents,
session: create(:session, team: @team, location: @school),
team: @team
)
end
Expand Down
5 changes: 1 addition & 4 deletions spec/lib/patient_team_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@

it "adds the patient to the team" do
expect(patient.teams).to be_empty
expect { call }.to change(PatientTeam, :count).by(1)
expect(PatientTeam.last.sources).to contain_exactly(
"vaccination_record_organisation"
)
expect { call }.not_to change(PatientTeam, :count)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/policies/patient_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
)
end

it { should contain_exactly(patient_with_vaccination_record) }
it { should be_empty }
end
end
end