def call(workgroup: nil, **)
MavisCLI.load_rails
teams = find_teams(workgroup)
if teams.empty?
puts "No national reporting teams found."
return
end
puts "Found #{teams.count} national reporting team(s) to reset:"
teams.each do |team|
puts " - #{team.name} (#{team.workgroup})"
puts " - Cut-off date: #{team.national_reporting_cut_off_date}"
puts " - Immunisation imports (before cut-off): #{find_immunisation_imports_for_team(team).count}"
puts " - Total patients: #{find_patients_for_team(team).count}"
vaccination_records = find_vaccination_records_for_team(team)
puts " - Vaccination records: #{vaccination_records.count}"
if (synced = vaccination_records.synced_to_nhs_immunisations_api).any?
puts " - #{synced.count} vaccination record(s) have been" \
" synced to NHS Immunisations API and will NOT be deleted"
end
archive_reasons =
find_archive_reasons_for_team(
team,
find_patients_for_team(team).ids
)
puts " - Archive reasons: #{archive_reasons.count}"
end
puts
unless MavisCLI.prompt_to_continue(
"This will permanently delete all data associated with the" \
"above teams. Continue? (y/n) "
)
puts "Operation cancelled."
return
end
teams.each do |team|
puts "Resetting #{team.name} (#{team.workgroup})..."
reset_team(team)
end
puts "\nAll teams reset successfully."
end