This is how I was able to create a patient using the Cerner FHIR API from a SYSTEM account application. First, you'll need to get a list of Organizations that SYSTEM SYSTEM (username SYSTEM) is a member of/is registered as a provider for in Cerner. You'll need to get that list from Cerner FHIR support. Ours looks like this (names blurred out)
Once you have that, you can fill in the all-important organization ID in the required Identifier reference field. If your referenced organization does NOT have SYSTEM as a member, the create will fail with a 400 BAD REQUEST error with no helpful instructions on how to fix it in the returned JSON body.
The other important note is that you must use the system application base URL for the request rather than the client application base URL. The system application base URL is used to make requests on behalf of the SYTEM user ID.
Finally, when getting a bearer token for SYSTEM requests, you'll need the following scopes:
"system/Patient.read",
"system/Person.read",
"system/Patient.write",
"system/Person.write"
Here's a valid request for our domain via Postman with the app ID in the base URL replaced with an anonymized value. Request URL + Headers:
and message body:
{
"resourceType": "Patient",
"identifier": [
{
"assigner": {
"reference": "Organization/7297258"
}
}
],
"active": true,
"name": [
{
"use": "official",
"family": "Kringle",
"given": [
"Chris",
"JellyBelly"
]
}
],
"telecom": [
{
"system": "email",
"value": "
hohoh...@gmail.com",
"use": "home",
"period": {
"start": "1960-12-19T12:12:25.000Z"
}
}
],
"gender": "male",
"birthDate": "1960-12-25",
"address": [
{
"use": "home",
"line": [
"2450 N Pennsylvania St"
],
"city": "Beverly Hills",
"state": "CA",
"postalCode": "90210",
"country": "United States",
"period": {
"start": "1960-12-19T12:12:25.000Z"
}
}
]
}
Not all of the above fields are strictly necessary. The Cerner documentation for the create call is here:
The Hl7 Nuget package was used to Create JSON request bodies as follows:
private static Patient CreatePatient(string firstName, string middleName, string lastName, AdministrativeGender gender, Date birthDate,
string streetAddress, string city, string state, string country, string postalCode,
string emailAddress, int medicalOrganizationId)
{
var identifier = new Identifier()
{
Assigner = new ResourceReference()
{
Reference = $"Organization/{medicalOrganizationId}"
}
};
var name = new HumanName()
{
Given = new string[] { firstName, middleName },
Family = lastName,
Use = HumanName.NameUse.Official
};
var address = new Address()
{
Line = new string[] { streetAddress },
City = city,
State = state,
PostalCode = postalCode,
Country = country,
Use = Address.AddressUse.Home,
Period = new Period(new FhirDateTime("1960-12-19T12:12:25.000Z"), null)
};
var email = new ContactPoint()
{
System = ContactPoint.ContactPointSystem.Email,
Value = emailAddress,
Use = ContactPoint.ContactPointUse.Home,
Period = new Period(new FhirDateTime("1960-12-19T12:12:25.000Z"), null)
};
var patient = new Patient()
{
Active = true,
Identifier = new List<Identifier>(new[] { identifier }),
Name = new List<HumanName>(new[] { name }),
Gender = gender,
Address = new List<Address>(new[] { address }),
BirthDateElement = birthDate,
Telecom = new List<ContactPoint>(new[] { email })
};
return patient;
}