Sha256: aa98878ffc5bcdc6a88d2a324df8ff31d37ab8616917f226775ecafae082d9c2
Contents?: true
Size: 1.15 KB
Versions: 18
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true require_dependency "renalware/pathology" module Renalware module Pathology class NearestObservationsQuery pattr_initialize [:patient!, :date!, :code_group!, look_behind_days!: 2] # rubocop:disable Metrics/MethodLength def call pathology_patient .observations .joins(:description) .where(description_id: observation_description_ids) .where("observed_at >= ?", (date - look_behind_days.days).beginning_of_day) .select( :observed_at, :result, :description_id, "pathology_observation_descriptions.code as code" ) .map do |row| { code: row.code, observed_on: row.observed_at.to_date, result: row.result } end end # rubocop:enable Metrics/MethodLength private def pathology_patient Pathology.cast_patient(patient) end def observation_description_ids @observation_description_ids ||= code_group.memberships.pluck(:observation_description_id) end end end end
Version data entries
18 entries across 18 versions & 1 rubygems