cph-cachet / carp.core-kotlin

Infrastructure-agnostic framework for distributed data collection.
https://carp.cachet.dk/core/
MIT License
20 stars 2 forks source link

Need the study ID in the study invitation #477

Open bardram opened 1 month ago

bardram commented 1 month ago

Right now we are storing the study id in the applicationData of the StudyInvitation. However, this is a hack and we would like to use application data for something else.

Therefore, studyId needs to be a property of either StudyInvitation or ActiveParticipationInvitation.

Whathecode commented 1 month ago

I don't really consider that a hack. If you look at the system decomposition, you see there is no dependency from the client to the studies subsystem, but only to the deployments subsystem.

We'd need strong reasons to introduce tighter coupling here, even if just through an ID. What is the exact use case the client needs the study ID for? If this is an application-specific use case, it really doesn't belong in core. If the use case is somehow related to core, we may need some other feature or communication which is mediated by the deployments subsystem.

we would like to use application data for something else

You can use a JSON object to store multiple fields in applicationData. The backend automatically parses this, so you don't have to escape JSON strings.

bardram commented 1 month ago

This is needed to get resources for the "study" (and not just the personal deployment).

I don't really consider that a hack. If you look at the system decomposition, you see there is no dependency from the client to the studies subsystem, but only to the deployments subsystem.

That's because you're looking at the wrong dependency - the one in play here is the one linking to the "Reource" sub-system (which is implemented in CAWS). Here it says "study" in the description of the link.

We'd need strong reasons to introduce tighter coupling here, even if just through an ID. What is the exact use case the client needs the study ID for? If this is an application-specific use case, it really doesn't belong in core. If the use case is somehow related to core, we may need some other feature or communication which is mediated by the deployments subsystem.

The current use case is to get study-specific "resources" like the informed consent text, onboarding participant information, general info about the study, news articles about the study, etc.

You can use a JSON object to store multiple fields in applicationData. The backend automatically parses this, so you don't have to escape JSON strings.

Yes - we are also considering this if you don't want to fix this issue.

Whathecode commented 1 month ago

This is needed to get resources for the "study" (and not just the personal deployment).

That makes sense. That's indeed why a "resources" subsystem in core was expected, and as you know is currently still missing. :) I think the right solution here is to start working towards adding that subsystem to core.

Resources: Contains a simple file store for resources (such as images, videos, and text documents) which can be referenced from within study protocols to be used during a study.

The reason I am hesitant to add studyId to StudyInvitation is because StudyInvitation resides in the deployments subsystem. And, this subsystem is designed to remain agnostic about "studies".

Similarly, the resources subsystem will likely benefit from being "studies" agnostic to keep things decoupled; at least, that was the original thinking behind the subsystem decomposition. If the client (through the deployments subsystem) receives resource IDs through the study protocol, there is no need to refer to studyID. Where and when study protocols can reference resource IDs is what needs to be carefully designed.

Consider that when a client retrieves resources from a "resources" subsystem using studyId, there is still coupling in the sense that the specific client doing so needs to know which resources to retrieve, or how to handle retrieved resources, as determined by the studies subsystem.

Some of the cases where this is needed may be "application-specific", and such assumptions can be hardcoded for a specific platform (outside of core, but through extensibility of core), but others may be generic CARP core use cases.

The current use case is to get study-specific "resources" like the informed consent text, onboarding participant information, general info about the study, news articles about the study, etc.

Yes - we are also considering this if you don't want to fix this issue.

It's not about wanting, it's about finding out whether it belongs in core. :) I.e., what is the benefit of adding it to core instead of applicationData. If core doesn't act on that data in any way (yet, at least), that's a strong sign it doesn't belong there. It would simply introduce coupling to assumptions in specific extending platforms. Informed consent is a nice example of something which should more formally be handled by core (as it should have an impact on data collection), but then probably not through a "resource" or studyId.