View source: R/build_resources.R
fhir_put | R Documentation |
This function is a convenience wrapper around httr::PUT()
.
fhir_put(
url,
body,
username = NULL,
password = NULL,
token = NULL,
add_headers = NULL,
verbose = 1,
log_errors = NULL
)
url |
An object of class fhir_url or a character vector of length one containing the url to PUT to. |
body |
An object of class fhir_resource or fhir_body. See details for how to generate them. |
username |
A character vector of length one containing the username for basic authentication. |
password |
A character vector of length one containing the password for basic authentication. |
token |
A character vector of length one or object of class httr::Token, for bearer token authentication (e.g. OAuth2). See |
add_headers |
A named character vector of custom headers to add to the HTTP request, e.g. |
verbose |
An integer vector of length one. If 0, nothing is printed, if > 0 success message is printed. Defaults to 1. |
log_errors |
Either |
fhir_put()
accepts two classes for the body:
A fhir_resource as created by fhir_build_resource()
. This is used when just a single resource should be PUT to the server.
In this case url
must contain the base url plus the resource type and the resource id,
e.g. http://hapi.fhir.org/baseR4/Patient/1a2b3c.
A fhir_body as created by fhir_body()
. This is the most flexible approach, because within the fhir_body object you can represent
any kind of content
as a string and set the type
accordingly. See examples.
For examples of how to create the different body types see the respective help pages. For an example of the entire workflow around creating and PUTing resources, see the package vignette on recreating resources.
## Not run:
### 1. PUT fhir__resource object
#unserialize example resource
resource <- fhir_unserialize(example_resource2)
#have a look at the resource
resource
#put
fhir_put(url = "http://hapi.fhir.org/baseR4/Patient/1a2b3c", body = resource)
### 2. PUT fhir_body object
#define body
body <- fhir_body(content = "<Patient> <id value='x1y2'/> <gender value='female'/> </Patient>",
type = "xml")
#put
fhir_put(url = "http://hapi.fhir.org/baseR4/Patient/x1y2", body = body)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.