Elation initial implementation
Integration
The integration is done through the Elation API. As the time of writing this, it's a one-way integration from Arc to Elation. The following data is sent to Elation:
- Patient demographics
- First name
- Middle name
- Last name
- DOB
- Sex
- Preferred language
- PCP fields
- Primary physician (hardcoded to "Katie")
- Address & comms
- Address (address, city, state, zip)
- First two phone numbers (primary and owned numbers have priority)
- Insurance info
- Payer name
- Member ID
- Medicaid ID
Elation::Event
model
Emulates an event-based architecture, tracking events that change patient data and requiring sync with Elation.
Models are responsible for tracking its own changes and generating the corresponding Elation::Event
record (e.g., profile changes). The Elation::Event
model is handles sending data to Elation.
Each Event instance belongs to a virtual queue, represented by the "resource_id" column. Events within the same queue are processed in their creation order to prevent data desynchronization and race conditions
Elation::ProcessEventsJob
job
This job is responsible for processing all the Elation::Event
records that belong to a certain queue, which is provided as an argument to the job.
If any of the events in a queue fails to be processed, the execution of that queue is stopped, and the job is re-enqueued to be retried later.
Retry logic
All the retry logic is contained in the Elation::Event::Retriable
module, which is included in the Event model.
Errors are split into two types: non-retryable errors, which cause the Event to be flagged as failed and not retried anymore. This also triggers an alert to the development team. And retryable errors, such as transient network issues or rate limiting, which are retried up to 5 times with a backoff strategy (~5 seconds, 1 minute, 12 minutes, 1 hour, 4 hours).
Adding a new type of event
To add a new type of event, you need to:
- Add the new event to the
Elation::Event#event_type
enum - Add a new create method to the
Elation::Event
modeldef self.create_my_new_event(chart)
create!(
source: 'arc',
event_type: 'my_new_event',
resource: chart,
data: {
# ... additional event data if needed
}
)
end - Add a new interactor for processing this new event type and a new case in the
Elation::Event#process!
method In case of failure, the interactor should return a context with:retriable
: booleanerror_message
: string