Sha256: 631282303b24b47fa26dc7f72d3064d9f34ac0a4c3eddb2fbb17589f0bba0cdb
Contents?: true
Size: 963 Bytes
Versions: 134
Compression:
Stored size: 963 Bytes
Contents
# frozen_string_literal: true 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 include Wisper::Publisher def call(params) Array(params).each do |request| patient = find_patient(request.fetch(:patient_id)) observation_params = request.fetch(:observation_request) broadcast :before_observation_request_persisted, observation_params obr = patient.observation_requests.create!(observation_params) broadcast :after_observation_request_persisted, obr end end private def find_patient(id) ::Renalware::Pathology::Patient.find_by(id: id) || NullObject.instance end end end end
Version data entries
134 entries across 134 versions & 1 rubygems