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
regionanddatastoreIdvalues. For more information, see Getting data store properties. -
Determine the type of FHIR
Resourceto update and collect the associatedidvalue. For more information, see Resource types. -
Construct a URL for the request using the collected values for HealthLake
regionanddatastoreId. Also include the FHIRResourcetype 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
JSONbody 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
updateinteraction uses aPUTrequest with either AWS Signature Version 4 or SMART on FHIR authorization. The followingcurlexample updates aPatientresource 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
idprovided in the request body: The server creates the FHIR resource. -
No matches,
idprovided and resource doesn't already exist with theid: The server treats the interaction as an Update as Create interaction. -
No matches,
idprovided and already exist: The server rejects the update with a409 Conflicterror. -
One Match, no resource
idprovided OR (resourceidprovided 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
idprovided but does not match resource found: The server returns a409 Conflicterror indicating the client id specification was a problem preferably with anOperationOutcome -
Multiple matches: The server returns a
412 Precondition Failederror 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
Configuring validation level for resource updates
When updating a FHIR resource, you can optionally specify an x-amzn-healthlake-fhir-validation-level
HTTP header to configure a validation level for the resource. AWS HealthLake currently supports the following validation levels:
-
strict: Resources are validated according to the profile element of the resource, or the R4 specification if no profile is present. This is the default validation level for AWS HealthLake. -
structure-only: Resources are validated against R4, ignoring any referenced profiles. -
minimal: Resources are validated minimally, ignoring certain R4 rules. Resources that fail structure checks required for search/analytics will be updated to include a warning for audit.
Resources updated with the minimal validation level may be ingested into a Datastore despite failing validation required for search indexing. In this case, resources will be updated to include a Healthlake specific extension to document said failures:
{ "url": "http://healthlake.amazonaws.com/fhir/StructureDefinition/validation-issue", "valueString": "{\"resourceType\":\"OperationOutcome\",\"issue\":[{\"severity\":\"error\",\"code\":\"processing\",\"details\":{\"text\":\"FHIR resource in payload failed FHIR validation rules.\"},\"diagnostics\":\"FHIR resource in payload failed FHIR validation rules.\"}]}" }
Additionally, the following HTTP response header will be included with a value of "true":
x-amzn-healthlake-validation-issues : true
Note
Note that data ingested that is malformed according the R4 specification may not be searchable as expected if these errors are present.