create method

Future<HttpBody> create(
  1. HttpBody request,
  2. String parent,
  3. String type, {
  4. String? $fields,
})

Creates a FHIR resource.

Implements the FHIR standard create interaction (DSTU2, STU3, R4), which creates a new resource with a server-assigned resource ID. Also supports the FHIR standard conditional create interaction (DSTU2, STU3, R4), specified by supplying an If-None-Exist header containing a FHIR search query, limited to searching by resource identifier. If no resources match this search query, the server processes the create operation as normal. When using conditional create, the search term for identifier should be in the pattern identifier=system|value or identifier=value - similar to the search method on resources with a specific identifier. The request body must contain a JSON-encoded FHIR resource, and the request headers must contain Content-Type: application/fhir+json. On success, the response body contains a JSON-encoded representation of the resource as it was created on the server, including the server-assigned resource ID and version ID. Errors generated by the FHIR store contain a JSON-encoded OperationOutcome resource describing the reason for the error. If the request cannot be mapped to a valid API method on a FHIR store, a generic GCP error might be returned instead. For samples that show how to call create, see Creating a FHIR resource.

request - The metadata request object.

Request parameters:

parent - Required. The name of the FHIR store this resource belongs to. Value must have pattern ^projects/\[^/\]+/locations/\[^/\]+/datasets/\[^/\]+/fhirStores/\[^/\]+$.

type - Required. The FHIR resource type to create, such as Patient or Observation. For a complete list, see the FHIR Resource Index (DSTU2, STU3, R4). Must match the resource type in the provided content. Value must have pattern ^\[^/\]+$.

$fields - Selector specifying which fields to include in a partial response.

Completes with a HttpBody.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<HttpBody> create(
  HttpBody request,
  core.String parent,
  core.String type, {
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'v1/' +
      core.Uri.encodeFull('$parent') +
      '/fhir/' +
      core.Uri.encodeFull('$type');

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return HttpBody.fromJson(response_ as core.Map<core.String, core.dynamic>);
}