Class: Renalware::Pathology::ObservationRequest
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Renalware::Pathology::ObservationRequest
- Defined in:
- app/models/renalware/pathology/observation_request.rb
Class Method Summary collapse
-
.distinct_for_patient_id(patient_id) ⇒ Object
Exlucludes duplicate rows; there may be an original OBR and one or more updates (with more complete results) and we only want the last received one got any requestor_order_number (actually for any requestor_order_number + requested_at + description_id) combination because requestor_order_number is sometimes blank rubocop:disable Metrics/MethodLength.
Instance Method Summary collapse
Class Method Details
.distinct_for_patient_id(patient_id) ⇒ Object
Exlucludes duplicate rows; there may be an original OBR and one or more updates (with more complete results) and we only want the last received one got any requestor_order_number (actually for any requestor_order_number + requested_at + description_id) combination because requestor_order_number is sometimes blank rubocop:disable Metrics/MethodLength
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/models/renalware/pathology/observation_request.rb', line 32 def self.distinct_for_patient_id(patient_id) select( Arel.sql( "DISTINCT ON (patient_id, requestor_order_number, requested_at, description_id) id" ) ) .where(patient_id: patient_id) .order( patient_id: :asc, requestor_order_number: :asc, requested_at: :asc, description_id: :asc, created_at: :desc ) end |
Instance Method Details
#requested_on ⇒ Object
23 24 25 |
# File 'app/models/renalware/pathology/observation_request.rb', line 23 def requested_on requested_at.to_date end |