Updating a FHIR resource
The FHIR update
interaction creates a new current version for an existing
resource or creates an initial version if no resource already exists for the given
id
. For additional information, see update
To update a FHIR resource
-
Collect HealthLake
region
anddatastoreId
values. For more information, see Getting data store properties. -
Determine the type of FHIR
Resource
to update and collect the associatedid
value. For more information, see Resource types. -
Construct a URL for the request using the collected values for HealthLake
region
anddatastoreId
. Also include the FHIRResource
type and its associatedid
. To view the entire URL path in the following example, scroll over the Copy button.PUT https://healthlake.
region
.amazonaws.com/datastore/datastoreId
/r4/Resource
/id
-
Construct a
JSON
body for the request, specifying the FHIR data updates to be made. For the purpose of this procedure, save the file asupdate-patient.json
.{ "id": "2de04858-ba65-44c1-8af1-f2fe69a977d9", "resourceType": "Patient", "active": true, "name": [ { "use": "official", "family": "Doe", "given": [ "Jane" ] }, { "use": "usual", "given": [ "Jane" ] } ], "gender": "female", "birthDate": "1985-12-31" }
-
Send the request. The FHIR
update
interaction uses aPUT
request with either AWS Signature Version 4 or SMART on FHIR authorization. The followingcurl
example updates aPatient
resource in HealthLake. To view the entire example, scroll over the Copy button.
Updating FHIR resources based on conditions
Conditional update allows you to update an existing resource based on some identification
search criteria, rather than by logical FHIR id
. When the server processes the
update, it performs a search using its standard search capabilities for the resource type,
with the goal of resolving a single logical id
for the request.
The action the server takes depends on how many matches it finds:
-
No matches, no
id
provided in the request body: The server creates the FHIR resource. -
No matches,
id
provided and resource doesn't already exist with theid
: The server treats the interaction as an Update as Create interaction. -
No matches,
id
provided and already exist: The server rejects the update with a409 Conflict
error. -
One Match, no resource
id
provided OR (resourceid
provided and it matches the found resource): The server performs the update against the matching resource as above where, if the resource was updated, the server SHALL return a200 OK
. -
One Match, resource
id
provided but does not match resource found: The server returns a409 Conflict
error indicating the client id specification was a problem preferably with anOperationOutcome
-
Multiple matches: The server returns a
412 Precondition Failed
error indicating the client's criteria were not selective enough preferably with an OperationOutcome
The following example updates a Patient
resource whose name is peter,
birthdate is 1st Jan 2000, and phone number is 1234567890.
PUT https://healthlake.
region
.amazonaws.com/datastore/datastoreId
/r4/Patient?name=peter&birthdate=2000-01-01&phone=1234567890