Method: DdeClient::DdeService#find_patient_updates

Defined in:
app/services/dde_client/dde_service.rb

#find_patient_updates(local_patient_id) ⇒ Object



191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'app/services/dde_client/dde_service.rb', line 191

def find_patient_updates(local_patient_id)
  dde_doc_id_type = PatientIdentifierType.where(name: 'Dde Person Document ID')
  doc_id = PatientIdentifier.find_by(patient_id: local_patient_id, identifier_type: dde_doc_id_type)
                            &.identifier
  return nil unless doc_id

  remote_patient = find_remote_patients_by_doc_id(doc_id).first
  return nil unless remote_patient

  Matcher.find_differences(Person.find(local_patient_id), remote_patient)
rescue DdeError => e
  Rails.logger.warn("Check for Dde patient updates failed: #{e.message}")
  nil
end