Example: Posting a Patient
The following code snippet takes a Client
object and uses it to post a Patient resource to Epic:
const response = await client.create(myPatient).catch((reason) => {
throw new Error(`Failed to create resource because: ${reason}`);
});
console.log(response);
Note that unlike the DocumentReference
example, we do not provide a patient or encounter ID to the create
function
The corresponding myPatient
:
const noteText = "Some example Note text"
const myPatient: Patient = {
"resourceType": "Patient",
"name": [
{
"use": "usual",
"given": [
"Demo"
],
"family": "Patient",
"prefix": [
"Mr."
]
}
],
"gender": "male",
"birthDate": "1990-01-01",
"address": [
{
"use": "home",
"type": "both",
"line": [
"123 Main St"
],
"city": "Anytown",
"state": "CA",
"postalCode": "12345",
"country": "US"
}
]
};