Class: Renalware::Patients::Ingestion::Commands::AddOrUpdatePatient
- Inherits:
-
Renalware::Patients::Ingestion::Command
- Object
- Renalware::Patients::Ingestion::Command
- Renalware::Patients::Ingestion::Commands::AddOrUpdatePatient
- 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:
-
If the patient exists as a Renalware::Patient, update their details
-
Find or create a Patients::Abridgement for this patient
-
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
-
#mapper_factory ⇒ Object
readonly
Returns the value of attribute mapper_factory.
Attributes inherited from Renalware::Patients::Ingestion::Command
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(message, mapper_factory: MessageMappers::Patient) ⇒ AddOrUpdatePatient
constructor
A new instance of AddOrUpdatePatient.
Methods inherited from Renalware::Patients::Ingestion::Command
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(, mapper_factory: MessageMappers::Patient) @mapper_factory = mapper_factory super() end |
Instance Attribute Details
#mapper_factory ⇒ Object (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
#call ⇒ Object
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().call end |