Subscriptions and Events Questions

For requests or help with our API
Post Reply
avie
Posts: 4
Joined: Thu Jul 04, 2024 6:37 am

Subscriptions and Events Questions

Post by avie » Thu Jul 04, 2024 6:43 am

Hi,

The example suggests that an event fired whenever a record is created or edited.

In my case I'm working with the Patient table.
If I get it well, an event should be fired anytime I create/edit a patient record via the API or via the Open Dental App.
If a patient is deleted through the app (it is said in the documentation that the API does not support patient deletion), is there any event fired to notify external system that the patient has actually been removed ?

Thanks,

SLeon
Posts: 521
Joined: Mon Mar 01, 2021 10:00 am

Re: API Guide – Subscriptions and Events

Post by SLeon » Fri Jul 05, 2024 8:31 am

Good morning,

Yes, by the nature of how data is collected for the subscription, deleted rows cannot be sent in an ApiEvent.
SLeon wrote:
Wed Jan 04, 2023 9:57 am
Open Dental will query the appointment table for rows with DateTStamp values equal to or greater than DateTimeStart (2022-11-28 15:04:31)
The query can only return rows that exists.

Patients are one of the few tables in the Open Dental schema that contain rows that are never actually deleted. You can parse the patient.PatStatus field that is in the ApiEvent payload, and look for the PatStatus of "Deleted".

avie
Posts: 4
Joined: Thu Jul 04, 2024 6:37 am

Re: API Guide – Subscriptions and Events

Post by avie » Fri Jul 05, 2024 11:24 am

Thanks for your quick reply, that's very clear.

I'm planning to use the Subscriptions feature to synchronize patient data between my system and Open Dental. This makes the Database Event System crucial for ensuring data consistency.

My last question is:

Is there a way to receive notifications whenever the Database Event System malfunctions? If not do you have suggestion about how to deal with this ?

Here's why this is important:

Early notification of system issues will allow me to inform users within my system that data synchronization might be interrupted. This will help prevent potential data discrepancies and ensure a smooth user experience.

Thanks again!

SLeon
Posts: 521
Joined: Mon Mar 01, 2021 10:00 am

Re: API Guide – Subscriptions and Events

Post by SLeon » Fri Jul 05, 2024 2:19 pm

To ensure Database ApiEvents are working properly, you can programmatically employ this strategy:
SLeon wrote:
Wed Jan 04, 2023 9:57 am
...
[*]For Database events, use Subscriptions GET a few times to see that the DateTimeStart is incremented by PollingSeconds. This will not occur if there is an issue processing the subscription due to the above reasons.
...
If you haven't received any events during business hours, you can send two Subscriptions GET requests (a few PollingSeconds intervals apart) to make sure the DateTimeStart is incrementing. I would strongly recommend against calling this in any sort of loop to minimize its impact on the dental office's database. Ideally this would be called only when you (programmatically) suspect an issue.

avie
Posts: 4
Joined: Thu Jul 04, 2024 6:37 am

Re: API Guide – Subscriptions and Events

Post by avie » Wed Jul 10, 2024 12:08 pm

Alright, I'll keep that in mind ;)

When using the Open Dental desktop app, I've noticed a behavior related to creating a new patient that involves event triggering:

Adding a New Patient:

1) Upon entering basic patient information and clicking the "Add" button, an event is triggered. This event includes details such as the Last Name of another family member already in the system, along with their Email and Phone, and sets the PatStatus to "Deleted."
Canceling Patient Creation:

2) If I decide to cancel the patient creation process by clicking the cancel button instead of submitting ("ok"), another event is triggered. This event also includes the Last Name, Email, and Phone of an existing family member, and sets the PatStatus to "Deleted."
Successful Patient Creation:

3) Upon successfully submitting the patient creation from the app by clicking "ok," a second event is triggered. This event correctly includes the newly entered patient information and sets the PatStatus to "Patient," which aligns with expected behavior.


I'm curious as to why these events with "Deleted" PatStatus and existing family member details are triggered when the patient creation is either canceled or not yet completed. It seems there might be an issue with when these events are fired in relation to the patient creation process.

Thanks

SLeon
Posts: 521
Joined: Mon Mar 01, 2021 10:00 am

Re: Subscriptions and Events Questions

Post by SLeon » Wed Jul 10, 2024 1:15 pm

Moving this topic to its own thread.

Many times Open dental will insert an object into the database at the beginning of the UI process, and then update it with the final details at the end. This pre-insertion is what you are seeing.

Post Reply