class Reports::CareplusExporter
Constants
- DOSE_CODES
- GENDER_CODE_MAPPINGS
- VACCINE_COLUMN_HEADINGS
Public Class Methods
Source
# File app/lib/reports/careplus_exporter.rb, line 56 def self.call( team:, programmes:, academic_year:, start_date:, end_date:, include_gender:, include_missing_nhs_number:, vaccine_columns: ) vaccination_records = vaccination_records_scope( team:, programmes:, academic_year:, start_date:, end_date:, include_missing_nhs_number: ).includes(:patient, :vaccine, session: %i[location team_location]) from_records( vaccination_records:, team:, programmes:, academic_year:, include_gender:, vaccine_columns: ) end
Source
# File app/lib/reports/careplus_exporter.rb, line 86 def self.from_records( vaccination_records:, team:, programmes:, academic_year:, include_gender:, vaccine_columns: ) new( vaccination_records:, team:, programmes:, academic_year:, include_gender:, vaccine_columns: ).call end
Source
# File app/lib/reports/careplus_exporter.rb, line 104 def self.vaccination_records_scope( team:, programmes:, academic_year:, start_date:, end_date:, include_missing_nhs_number: ) scope = team .vaccination_records .sourced_from_service .for_programmes(programmes) .for_academic_year(academic_year) .administered .order_by_performed_at .created_or_updated_between(start_date, end_date) scope = scope.joins(:patient).merge( Patient.with_nhs_number ) unless include_missing_nhs_number scope end
Public Instance Methods
Source
# File app/lib/reports/careplus_exporter.rb, line 45 def call CSV.generate(headers:, write_headers: true) do |csv| vaccination_records .group_by(&:patient) .transform_values(&:reverse) .each do |patient, vaccination_records| rows(patient:, vaccination_records:).each { |row| csv << row } end end end