createConsentDocument method

  1. @Deprecated('The Informed Consent endpoints are deprecated in CAWS. ' 'Informed Consent is uploaded as [InformedConsentInput] participant input ' 'data using a [ParticipationReference].')
Future<ConsentDocument> createConsentDocument(
  1. Map<String, dynamic> document, {
  2. String? studyDeploymentId,
})

Create a new (signed) consent document. Returns the created ConsentDocument if the document is uploaded correctly.

If studyDeploymentId is specified use this, otherwise use the study deployment id from CarpService.study.

Implementation

@Deprecated('The Informed Consent endpoints are deprecated in CAWS. '
    'Informed Consent is uploaded as [InformedConsentInput] participant input '
    'data using a [ParticipationReference].')
Future<ConsentDocument> createConsentDocument(
  Map<String, dynamic> document, {
  String? studyDeploymentId,
}) async {
  debug('REQUEST: POST ${getConsentDocumentEndpointUri(studyDeploymentId)}');

  // POST the document to the CARP web service
  http.Response response = await _post(
    getConsentDocumentEndpointUri(studyDeploymentId),
    body: json.encode(document),
  );

  int httpStatusCode = response.statusCode;
  Map<String, dynamic> responseJson =
      json.decode(response.body) as Map<String, dynamic>;

  if ((httpStatusCode == HttpStatus.ok) ||
      (httpStatusCode == HttpStatus.created)) {
    return ConsentDocument._(responseJson);
  }

  // All other cases are treated as an error.
  throw CarpServiceException.fromMap(httpStatusCode, responseJson);
}