Last active
August 1, 2022 12:31
-
-
Save mdlavin/32eae32122b7e8a0113b1db44ba6a465 to your computer and use it in GitHub Desktop.
Secure Health Data Storage Article - Create Patient Snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createPatient = async (accountId: string, projectId: string) => { | |
const patient = await fetch(`https://fhir.us.lifeomic.com/${accountId}/dstu3/Patient`, { | |
method: 'POST', | |
headers: { | |
authorization: `Bearer ${process.env.PHC_API_KEY}`, | |
'content-type': 'application/json' | |
}, | |
body: JSON.stringify({ | |
resourceType: "Patient", | |
// Fill in the details of your patient | |
name: [ | |
{ | |
use: "official", | |
family: "Lavin", | |
given: ["Matt"] | |
} | |
], | |
gender: "male", | |
// Add a `meta` tag to the resource so that the PHC knows what project to put the patient in. | |
meta: { | |
tag: [ | |
{ | |
system: 'http://lifeomic.com/fhir/dataset', | |
code: projectId | |
} | |
] | |
} | |
}) | |
}) | |
// The result from the POST is a copy of the body from above | |
// and also includes a new `id` attribute. | |
// { | |
// "id": <newid> | |
// "resourceType": "Patient", | |
// ...rest | |
// } | |
return patient.json(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment