Class: Renalware::Patients::Ingestion::Commands::AddOrUpdatePatient

Inherits:
Renalware::Patients::Ingestion::Command show all
Defined in:
app/models/renalware/patients/ingestion/commands/add_or_update_patient.rb

Overview

We could be here as a results of 2 scenarios:

  • ADT28 add patient

  • ADT31 update patient

In both circumstances our action is the same:

  1. If the patient exists as a Renalware::Patient, update their details

  2. Find or create a Patients::Abridgement for this patient

  3. Update their abridgement info, including their Renalware::Patient id if one exists

So basically we are maintaining patient data in 2 places: a) in Renalware::Patient and its associated address and demographics tables b) in Renalware::Patients::Abrigement, which is an abbreviated version of the patient’s

details (name, numbers, DOB ect), enabling us to find and import a new patient by
taking the abridgement, finding all previously received ADT and ORU etc feed_messages
for the patient and replaying those messages to build the patient with their
and pathology. If a patient is already a Renalware::Patient then in theory we do
not need to maintain an abridgement for them, but for consistentency we do; it has
advantages when trying to add a new patient in the Renalware UI - e.g. it can show you
that that patient is already added because there is a patient_id on the abridgement.

Instance Attribute Summary collapse

Attributes inherited from Renalware::Patients::Ingestion::Command

#message

Instance Method Summary collapse

Methods inherited from Renalware::Patients::Ingestion::Command

for

Constructor Details

#initialize(message, mapper_factory: MessageMappers::Patient) ⇒ AddOrUpdatePatient

Returns a new instance of AddOrUpdatePatient.



29
30
31
32
33
# File 'app/models/renalware/patients/ingestion/commands/add_or_update_patient.rb', line 29

def initialize(message, mapper_factory: MessageMappers::Patient)
  @mapper_factory = mapper_factory

  super(message)
end

Instance Attribute Details

#mapper_factoryObject (readonly)

Returns the value of attribute mapper_factory.



35
36
37
# File 'app/models/renalware/patients/ingestion/commands/add_or_update_patient.rb', line 35

def mapper_factory
  @mapper_factory
end

Instance Method Details

#callObject



37
38
39
40
# File 'app/models/renalware/patients/ingestion/commands/add_or_update_patient.rb', line 37

def call
  update_patient_if_exists
  UpdateMasterPatientIndex.new(message).call
end