Use this guide to find an existing patient and choose the correct patient_id for follow-up requests like appointments, medical notes, and documents.
care_unit_id from step 1 in Show Doctor's Availability before running patient lookup requests.
import requests
CLIENT_ID = "your-client-id"
CLIENT_SECRET = "your-client-secret"
BASE_URL = "https://api.leyr.io/api"
EMR = "webdoc"
headers = {
"x-leyr-client-id": CLIENT_ID,
"x-leyr-client-secret": CLIENT_SECRET,
"Content-Type": "application/json"
}
care_unit_id = "L0_1"
response = requests.get(
f"{BASE_URL}/emrs/{EMR}/care-units/{care_unit_id}/patients",
headers=headers,
params={
"first_name": "Tolvan",
"last_name": "Tolvansson"
}
)
patients = response.json()
patient = patients[0]
print(f"Found patient Leyr ID: {patient['id']}")
print(f"EHR ID: {patient.get('emr_id')}")
patient_idpatient_id = f"emr_id:{patient['emr_id']}"
response = requests.get(
f"{BASE_URL}/emrs/{EMR}/care-units/{care_unit_id}/patients/{patient_id}",
headers=headers
)
patient_details = response.json()
print("✓ Patient loaded")
print(f"Name: {patient_details.get('first_name')} {patient_details.get('last_name')}")
print(f"Care Unit ID: {patient_details.get('care_unit_id')}")
The patient_id path parameter supports multiple formats:
abc_12345 (treated as EHR ID)emr_id:abc_12345se_personal_number:191212121212no_personal_number:26258605879nhs_number:9434765919For full details, see Patient IDs.
patient_id formats (emr_id:*, se_personal_number:*, etc.).id (Leyr) and emr_id (EHR) for traceability and support workflows.Attach a Document
Learn how to upload files to patient records. Documents are files like lab results, imaging reports, consent forms, or any other files that need to be attached to a patient's medical record.
Create Patient
Use this guide to create or upsert a patient before booking appointments, writing medical notes, or attaching documents.