Sha256: ce04fcbf36b04a5f4408325772a1a5e1c85b52ebbb59f7d9bae5cbfbc6bf235f
Contents?: true
Size: 1.28 KB
Versions: 18
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true require_dependency "renalware/pathology" module Renalware module Pathology class NearestObservationResultsController < Pathology::BaseController def index near_date authorize Patient, :index? render json: nearest_results end private def code_group @code_group ||= CodeGroup.find(params[:code_group_id]) end def observation_description_ids @observation_description_ids ||= code_group.memberships.pluck(:observation_description_id) end def near_date Date.parse(params[:date]) end # rubocop:disable Metrics/MethodLength def nearest_results Pathology .cast_patient(Patient.find(params[:patient_id])) .observations .joins(:description) .where(description_id: observation_description_ids) .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 end end end
Version data entries
18 entries across 18 versions & 1 rubygems