Update resources
Updating resource on the server is done with the update()
and update_async()
methods of the FhirServer
class.
These methods accept a list of fhir.resources
objects that are required to have a server assigned id
and resource_type
attribute.
These resources are then updated on the server using a batch transaction.
Note
As with all the methods of the library, there are asynchronous and synchronous versions of the methods presented here.
Simply add the await
keyword and append _async
to the method name to use the asynchronous version.
from fhir_kindling import FhirServer
from fhir.resources.patient import Patient
fhir_server = FhirServer(api_address="http://fhir.example.com/R4")
# Get a list of 100 patients
patients = server.query("Patient").limit(100).resources
# Update the first name of all patients
for patient in patients:
patient.name[0].given[0] = "John"
# Update the patients on the server
update_response = fhir_server.update(resources=patients)
print(update_response)
Update API
update(self, resources)
Update a list of resources that exist on the server
Parameters:
Name | Type | Description | Default |
---|---|---|---|
resources |
List[Union[fhir.resources.fhirresourcemodel.FHIRResourceModel, dict]] |
List of updated resources coming to send to the server |
required |
Returns: Bundle update response from the fhir server