Skip to content

Instantly share code, notes, and snippets.

@douglasgsouza
Created May 13, 2024 13:17
Show Gist options
  • Save douglasgsouza/6ec315c6c9b98eae3056eced44c7db9f to your computer and use it in GitHub Desktop.
Save douglasgsouza/6ec315c6c9b98eae3056eced44c7db9f to your computer and use it in GitHub Desktop.
Medical Records Webhooks
graph TD
    subgraph Receive
    F[Feegow emit a webhook <br><small>POST /webhooks/feegow</small>]
    F-->F1[(fa:fa-list-check Store in a webhooks queue)]
    --o W0
    end
    subgraph Webhooks Processing
    W0[end]
    .-> P1[fa:fa-spinner Worker 1<br><small>read the queue in batch</small>] 
    --> P2[groups events by license and patient]
    --> P3[fetch records in Rest API]
    --> P4[processes the records]
    --> P5[(store records in internal database)]
    --> P6[emit a new event to queue<br><small>signaling that there are new documents for the patient</small>]
    --> P7[(fa:fa-list-check Store in a patient notifications queue)]
    --o N0
    end
    subgraph Sending Notifications
    N0[end]
    .->N1[fa:fa-spinner Worker 2<br><small>read the patients queue in batch</small>] 
    --> N2[iterates over all active listeners and distinct patients]
    --> N4[checks if there are new records to be sent to the patient and listener]
    --> N5[check whether you can send it immediately or wait for the debounce time]
    -->N6{Can send notification?}
    N6 -->|Yes| N7
    N7[send notification] --> N8[end]
    N6 -->|No| N1
    
    end

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment