Sha256: 741788c09f9f76af3468fe5bdb9d6cc78e0aac1a4900f7f4829afce2476c7fd4

Contents?: true

Size: 670 Bytes

Versions: 3

Compression:

Stored size: 670 Bytes

Contents

require_dependency "renalware/pathology"

#
# Create pathology observations requests and their child observations for an existing
# patient from HL7 message content.
#
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

3 entries across 3 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.rc9 app/models/renalware/pathology/create_observation_requests.rb
renalware-core-2.0.0.pre.rc8 app/models/renalware/pathology/create_observation_requests.rb
renalware-core-2.0.0.pre.rc7 app/models/renalware/pathology/create_observation_requests.rb