Sha256: 065dab68a5fc5e6e3547a28c0158a0af9c15cb229ae7ce2c22ca5ef528e30c4d

Contents?: true

Size: 753 Bytes

Versions: 11

Compression:

Stored size: 753 Bytes

Contents

require_dependency "renalware/pathology"

#
# Create pathology observations requests and their child observations for an existing
# patient from HL7 message content previously parsed into an array of hashes (there can be > 1 OBR
# in each message).
#
module Renalware
  module Pathology
    class CreateObservationRequests
      def call(params)
        Array(params).each do |request|
          patient = find_patient(request.fetch(:patient_id))
          observation_params = request.fetch(:observation_request)
          patient.observation_requests.create!(observation_params)
        end
      end

      private

      def find_patient(id)
        ::Renalware::Pathology::Patient.find_by(id: id) || NullObject.instance
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
renalware-core-2.0.8 app/models/renalware/pathology/create_observation_requests.rb
renalware-core-2.0.7 app/models/renalware/pathology/create_observation_requests.rb
renalware-core-2.0.5 app/models/renalware/pathology/create_observation_requests.rb
renalware-core-2.0.4 app/models/renalware/pathology/create_observation_requests.rb
renalware-core-2.0.3 app/models/renalware/pathology/create_observation_requests.rb
renalware-core-2.0.2 app/models/renalware/pathology/create_observation_requests.rb
renalware-core-2.0.1 app/models/renalware/pathology/create_observation_requests.rb
renalware-core-2.0.0 app/models/renalware/pathology/create_observation_requests.rb
renalware-core-2.0.0.pre.rc13 app/models/renalware/pathology/create_observation_requests.rb
renalware-core-2.0.0.pre.rc11 app/models/renalware/pathology/create_observation_requests.rb
renalware-core-2.0.0.pre.rc10 app/models/renalware/pathology/create_observation_requests.rb