Sha256: 37a6cebe63114ac2df24b6e4ae6c42fe2cbdd8493eaaf5ddf1bc5df5c0da9121

Contents?: true

Size: 727 Bytes

Versions: 1

Compression:

Stored size: 727 Bytes

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 >= ?", changes_since)
          .where("coalesce(loinc_code, '') != ''") # excludes NULL and ''
          .eager_load(
            :description,
            observations: { description: :measurement_unit }
          )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
renalware-core-2.0.95 app/models/renalware/ukrdc/pathology_observation_requests_query.rb