Sha256: 3e9ce1d10c75b0e0f6b42f052c9f75f00d08bf5c4a76d5a8ad4c825fa7981139
Contents?: true
Size: 1.29 KB
Versions: 27
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true require_dependency "renalware/ukrdc" require "attr_extras" module Renalware module UKRDC class PathologyObservationRequestsQuery pattr_initialize [:patient_id!, :changes_since!] def call observation_requests end private def observation_requests Pathology::ObservationRequest .where(id: Pathology::ObservationRequest.distinct_for_patient_id(patient_id)) .where("requested_at >= ?", effective_changes_since) .where("loinc_code is not null") .eager_load( :description, observations: { description: :measurement_unit } ) .order(observed_at: :asc) end # If there is a pathology_start_date configured in an ENV var, use this # for fetching pathology. This allows us to send a one-off batch of patients # with historical pathology. Most of the time this setting is not present, and # default to using changes_since. def effective_changes_since configured_pathology_start_date || changes_since end def configured_pathology_start_date start_date = Renalware.config.ukrdc_pathology_start_date return if start_date.blank? Date.parse(start_date) end end end end
Version data entries
27 entries across 27 versions & 1 rubygems