Hi,
I'm trying to Create an Appointment for a Patient using API “https://fhir-ehr-code.cerner.com/r4/ec2458f2-1e24-41c8-b71b-0e701af7583d/Appointment”
Code
“import json
appointment_url = "https://fhir-ehr-code.cerner.com/r4/ec2458f2-1e24-41c8-b71b-0e701af7583d/Appointment"
appointment_data = {
'resourceType': 'Appointment',
'status': 'proposed',
'serviceType': [
{
'coding': [
{
'code': '408443003',
'system': 'http://snomed.info/sct'
}
]
}
],
'reasonCode': [
{
'text': 'I have a cramp'
}
],
'comment': 'Appointment request comment',
'participant': [
{
'actor': {
'reference': 'Patient/12724067'
},
'status': 'needs-action'
},
{
'actor': {
'reference': 'Location/21304876',
'display': 'MX Clinic 1'
},
'status': 'needs-action'
}
],
'requestedPeriod': [
{
'start': '2025-07-10T13:28:17-05:00',
'end': '2025-07-10T14:28:17-05:00'
}
]
}
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/fhir+json",
"Accept": "application/fhir+json"
}
response = requests.post(
appointment_url,
headers=headers,
data=json.dumps(appointment_data),
verify=False
)
print("Status:", response.status_code)
print("Headers:", response.headers)
try:
data = response.json()
print("JSON Response:", json.dumps(data, indent=2))
except ValueError:
print("Non-JSON Response:", response.text)”
For Code I have received the response as
“Status: 201 Headers: {'Content-Type': 'application/fhir+json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'Oracle API Gateway', 'Cache-Control': 'no-cache', 'Etag': 'W/"0"', 'Date': 'Tue, 07 Oct 2025 15:21:24 GMT', 'Location': 'https://fhir-ehr-code.cerner.com/r4/ec2458f2-1e24-41c8-b71b-0e701af7583d/Appointment/6677032', 'Last-Modified': 'Tue, 07 Oct 2025 15:21:24 GMT', 'Vary': 'Origin', 'X-Permitted-Cross-Domain-Policies': 'none', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'X-Xss-Protection': '1; mode=block', 'Strict-Transport-Security': 'max-age=631152000', 'Server-Response-Time': '931.678129', 'X-Download-Options': 'noopen', 'X-Runtime': '0.931613', 'X-Request-Id': '/18786FE97E86B2501EAF9AFC1E4E5AB4+dfFQ_RXZT', 'opc-request-id': '/18786FE97E86B2501EAF9AFC1E4E5AB4/B876636C98C8DFC19E83BB82EF5E368A', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'X-Cache': 'Miss from cloudfront', 'Via': '1.1 64b7afcb85063b512f44ca8b665127ac.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'MAA50-P1', 'X-Amz-Cf-Id': 'zjLP9MD5TaQQ7T4xG7skB3GpTZQ-tBXpardSWot__FTJGJ3irdQdqw=='} Non-JSON Response: ”
But When I'm trying to book the appointment using the below code.
‘import json
import requests
appointment_url = "https://fhir-ehr-code.cerner.com/r4/ec2458f2-1e24-41c8-b71b-0e701af7583d/Appointment"
appointment_data = {
"resourceType":"Appointment",
"status":"booked",
"slot":[
{
"reference":"Slot/24477854-21304876-62852027-0"
}
],
"participant":[
{
"actor":{
"reference":"Patient/12724066"
},
"status":"accepted"
}
],
"reasonCode":[
{
"text":"I have a cramp"
}
]
}
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json",
"Accept": "application/json"
}
response = requests.post(
appointment_url,
headers=headers,
data=json.dumps(appointment_data),
verify=False
)
print("Status:", response.status_code)
print("Headers:", response.headers)
try:
data = response.json()
print("JSON Response:", json.dumps(data, indent=2))
except ValueError:
print("Non-JSON Response:", response.text)
’
I'm getting the follwoiung repsonse.
‘Status: 422 Headers: {'Content-Type': 'application/fhir+json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Cache-Control': 'no-cache', 'Server': 'Oracle API Gateway', 'Date': 'Tue, 07 Oct 2025 15:24:31 GMT', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'X-Xss-Protection': '1; mode=block', 'Strict-Transport-Security': 'max-age=631152000', 'Vary': 'Accept,Origin', 'X-Runtime': '0.457645', 'opc-request-id': '/4347ABDB1DE711C08F2855FDD2F05E44/0412B3D3BD1FF611AAFB7D2F833DD571', 'X-Download-Options': 'noopen', 'X-Permitted-Cross-Domain-Policies': 'none', 'X-Request-Id': '/4347ABDB1DE711C08F2855FDD2F05E44+O2Qa_q0I0', 'Server-Response-Time': '457.714897', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 279ccf895dda648a867be1dfc032289e.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'MAA50-P1', 'X-Amz-Cf-Id': '-yvZXCUVLWxsbqTRbEu_dLV5x5jpdPGr-VAj5lE59_Hz1Ivux1PSEw=='} JSON Response: { "resourceType": "OperationOutcome", "issue": [ { "severity": "error", "code": "invalid", "details": { "text": "Unprocessable entity" } } ] }’
Can you explain how to fix the issue.