Hello!
Is there a way to filter on upcoming appointments or use FHIR api to list appointments by selecting a date/time range?
I want to use FHIR or API to get upcoming appointments and also able to filter then over a date range.
Any help appreciated!
This works but for a running production instance of OpenEMR instance with large number of appointments, it will try to return all appointments and could cause performance issues.
import json
import requests
import urllib3
urllib3.disable_warnings()
with open('./new_api_config.json') as ecf:
client_app = json.load(ecf)
with open('./rpi_openemr.json') as ecf:
emr_config = json.load(ecf)
ec = {
"base_url":emr_config['emr_host'],
"client_name": client_app['client_name'],
"client_id": client_app['client_id'],
"client_user": "admin",
"client_pass": "pass",
"contact": client_app['contacts'],
"scope": client_app['scope']
}
session = requests.Session()
session.headers.update({
'Accept': 'application/json',
"Content-Type": "application/x-www-form-urlencoded"
})
payload = {
"client_id": ec['client_id'],
"grant_type": "password",
"user_role" : "users",
"username": ec['client_user'],
"password": ec['client_pass'],
"scope": ec['scope']
}
token = session.post(
url = str('https://' + ec['base_url'] + '/oauth2/default/token'),
data = payload,
verify=False
).json()
appointment_url = f"https://{emr_config['emr_host']}/apis/default/fhir/Appointment"
headersList = {
"Content-Type": "application/json",
"Authorization": f"Bearer {token['access_token']}"
}
payload = {}
response = requests.request("GET", appointment_url, data=payload, headers=headersList, verify=False)
response.json()
–
Regards,
Atul