Class: DdeClient::RollbackService
- Inherits:
-
Object
- Object
- DdeClient::RollbackService
- Defined in:
- app/services/dde_client/rollback_service.rb
Overview
this class will basically handle rolling back patients that were merged rubocop:disable Metrics/ClassLength
Constant Summary collapse
- Dde_CONFIG_PATH =
'config/application.yml'
Instance Attribute Summary collapse
-
#merge_type ⇒ Object
Returns the value of attribute merge_type.
-
#primary_patient ⇒ Object
Returns the value of attribute primary_patient.
-
#secondary_patient ⇒ Object
Returns the value of attribute secondary_patient.
-
#visit_type ⇒ Object
Returns the value of attribute visit_type.
Instance Method Summary collapse
-
#rollback_merged_patient(patient_id, visit_type_id) ⇒ Object
rubocop:disable Metrics/MethodLength.
Instance Attribute Details
#merge_type ⇒ Object
Returns the value of attribute merge_type.
6 7 8 |
# File 'app/services/dde_client/rollback_service.rb', line 6 def merge_type @merge_type end |
#primary_patient ⇒ Object
Returns the value of attribute primary_patient.
6 7 8 |
# File 'app/services/dde_client/rollback_service.rb', line 6 def primary_patient @primary_patient end |
#secondary_patient ⇒ Object
Returns the value of attribute secondary_patient.
6 7 8 |
# File 'app/services/dde_client/rollback_service.rb', line 6 def secondary_patient @secondary_patient end |
#visit_type ⇒ Object
Returns the value of attribute visit_type.
6 7 8 |
# File 'app/services/dde_client/rollback_service.rb', line 6 def visit_type @visit_type end |
Instance Method Details
#rollback_merged_patient(patient_id, visit_type_id) ⇒ Object
rubocop:disable Metrics/MethodLength
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/services/dde_client/rollback_service.rb', line 11 def rollback_merged_patient(patient_id, visit_type_id) @visit_type = VisitType.find(visit_type_id) tree = DdeClient::MergeAuditService.new.fetch_merge_audit(patient_id) ActiveRecord::Base.transaction do tree.each do |record| @primary_patient = record['primary_id'] @secondary_patient = record['secondary_id'] @merge_type = record['merge_type'] Rails.logger.debug("Processing rollback for patients: #{primary_patient} <=> #{secondary_patient}") process_rollback MergeAudit.find(record['id']).void("Rolling back to #{secondary_patient}") @common_void_reason = nil end end Patient.find(patient_id) end |