In this lesson you’ll learn:
-
How to search for existing records using the Get Patients action
-
How to add Branch Logic to control workflow decisions
-
How to dynamically choose between creating or updating a patient
Introduction
In real-world automations, it’s common to check whether a record already exists before creating a new one. This prevents duplicate records and ensures your data stays clean.
In this lesson, you’ll learn how to:
-
Search for a patient by email using the Get Patients action.
-
Add Branch Logic to handle both possible outcomes:
-
Create a new patient if they don’t exist.
-
Update the patient information if they already exist.
-
Step 1: Add the Search Action (Get Patients)
-
In your workflow editor, click the ➕ icon after the Continue If step.
-
Select the DrChrono connector.
-
Choose the Get Patients (plural) action.
📌 Note: We can delete the "Create patient" action in our workflow that we have added in the previous beginner course , as we are implementing the search and create / update functionality now
-
Configure the search criteria:
-
Email: Map this to the email field from your Jotform submission.
-
Example:
email = {{emailFromJotform}}
-
- Test the step to ensure that the action works as expected.
📌 Note: This action always returns a list of patients. If the list is empty, it means no patient was found.
Step 2: Add the Branch Logic
Now, let’s control what happens based on the search results.
-
Click the ➕ icon right after the Get Patients step.
-
Select Branch from the Logic tab.
-
Configure the Branch Conditions:
-
Branch A (Patient Does Not Exist):
-
Value 1: Select the Patients array from the Get Patients step.
-
Condition:
is empty
-
This branch handles creating a new patient.
-
-
-
Default Branch (Patient Exists):
-
No configuration needed.
-
If the list is not empty, the workflow will automatically follow this branch to update the patient.
-
💡 Tip: Rename your branches to keep things organized—e.g., "New patient"
Step 3: Configure Actions Under Each Branch
-
Branch A (Create New Patient):
-
Add the Create Patient action.
-
Map the necessary fields from the Jotform submission and click the save button.
-
-
Default Branch (Update Existing Patient):
-
Add the Update Patient action.
-
Use data from the first item in the Patients array to retrieve the Patient ID.
How to Provide the Record ID for Update Actions
All Update actions in Keragon, including Update Patient, require a Record ID to identify which record to update.
In our case, the Patient ID comes from the results of the earlier Get Patients search action.
How to Find and Map the Patient ID:
-
Click on the Patient ID input field in the Update action.
-
Navigate to the Steps tab (since the data comes from a previous step).
-
Select the ID from the Get Patients step—this will usually be the ID of the first item in the returned list.
-
-
Update the relevant patient details and click the save button.
-
Success!
You’ve now built a smart workflow that automatically decides whether to create or update a patient—no manual intervention needed!
Step 4: Test Your Create Patient Action
- Select the "Create patient" action in "New patient" branch
- Click the "Test step" button to perform this action in DrChrono with all the data from Jotform that we have configured in the action's inputs.
Error: Date Format Mismatch
During testing, the workflow returned an error. If we review the error details, we’ll see that the Date field sent from Jotform to DrChrono is not in the correct format expected by DrChrono.
Next Lesson
Now that you’ve implemented logic branching, let’s address the error we found in the next lesson by applying Data Transformations to ensure all dates are correctly formatted before sending them to DrChrono.
Next Lesson: Add Data Transformations: Format Dates Correctly