Skip to content

Consent, Messages and Translations

CAWS handles three types of special-purpose resources:

  • The informed consent document to be shown to the user
  • A set of messages and news items to be show to the user
  • Translation files that can help translate the text used in a study deployment protocol (like the text is a user survey)

Each of the are handled by an InformedConsentManager, MessageManager, and LocalizationManager, respectively. All of these managers are implemented in the CarpResourceManager manager.

Here is an example of uploading and downloading an informed consent document to be shown to the user (via the Research Package):

// Create and initialize the informed consent manager.
//
// The CarpResourceManager() is a singleton that uses the
// the CarpService() singleton for accessing CAWS. Hence,
// CarpService needs to be authenticated and initialized before
// using the CarpResourceManager.
InformedConsentManager icManager = CarpResourceManager();
icManager.initialize();
// Create a simple informed consent...
final consent = RPOrderedTask(
identifier: '12',
steps: [
RPInstructionStep(identifier: "1", title: "Welcome!")
..text = "Welcome to this study! ",
RPCompletionStep(
identifier: "2",
title: "Thank You!",
text: "We saved your consent document.",
),
],
);
// .. and upload it to CAWS.
await icManager.setConsentDocument(consent);
// Get the informed consent back as a RPOrderedTask, if available.
RPOrderedTask? myConsent = await icManager.getConsentDocument();

Note that we distinguish between a “consent document” and the “informed consent”. A consent document is typically created and uploaded once for a study. Then later, all participants (i.e., deployments) can access this informed consent document via the getConsentDocument method, and show it to the user for signature. Once the consent document is signed by the user, it can be stored as an InformedConsentInput and then be uploaded to CAWS using the setInformedConsent method on a ParticipationReference.

Below are examples of how messages can be uploaded and retrieved from CAWS:

// Create and initialize the message manager.
MessageManager messageManager = CarpResourceManager();
messageManager.initialize();
// Create a message and upload it to CAWS.
messageManager.setMessage(Message(
id: '123',
title: 'Great News!',
message: 'There are great news from CARP',
type: MessageType.news,
));
// Get all messages from CAWS.
messageManager.getMessages().then((messages) {
print('Messages: $messages');
});
// Get a specific message from CAWS.
messageManager.getMessage('123').then((message) {
print('Message: $message');
});
// Delete a specific message from CAWS.
messageManager.deleteMessage('123').then((_) {
print('Message deleted...');
});

Translations files can be up- and downloaded like this:

// Create and initialize the message manager.
LocalizationManager localizationManager = CarpResourceManager();
localizationManager.initialize();
// A Danish locale
var locale = Locale('da');
// Create a translation file for Danish and upload it to CAWS.
localizationManager.setLocalizations(locale, {
'morning': 'morgen',
'midday': 'middag',
'evening': 'aften',
});
// Get translation file for Danish
if (localizationManager.isSupported(locale)) {
localizationManager.getLocalizations(locale);
}