ResourceValidate method

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

Validates an input FHIR resource's conformance to its profiles and the profiles configured on the FHIR store.

Implements the FHIR extended operation $validate (DSTU2, STU3, or R4). The request body must contain a JSON-encoded FHIR resource, and the request headers must contain Content-Type: application/fhir+json. The Parameters input syntax is not supported. The profile query parameter can be used to request that the resource only be validated against a specific profile. If a profile with the given URL cannot be found in the FHIR store then an error is returned. Errors generated by validation 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.

request - The metadata request object.

Request parameters:

parent - Required. The name of the FHIR store that holds the profiles being used for validation. Value must have pattern ^projects/\[^/\]+/locations/\[^/\]+/datasets/\[^/\]+/fhirStores/\[^/\]+$.

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

profile - Required. The canonical URL of a profile that this resource should be validated against. For example, to validate a Patient resource against the US Core Patient profile this parameter would be http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient. A StructureDefinition with this canonical URL must exist in the FHIR store.

$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> ResourceValidate(
  HttpBody request,
  core.String parent,
  core.String type, {
  core.String? profile,
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if (profile != null) 'profile': [profile],
    if ($fields != null) 'fields': [$fields],
  };

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

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