ReproNim / reproschema

A standardized form generation and data collection schema to harmonize results by design across projects.
https://www.repronim.org/reproschema/
Other
14 stars 21 forks source link

encode activity locking/unlocking at the activity set level #45

Closed akeshavan closed 5 years ago

akeshavan commented 5 years ago

As a first pass:

For the voice pilot case, lets encode that the voice_task activity should initially be "locked" and a spot for a URL to "unlock" it:

{
    "@id": "nda_phq_schema",
    "skos:prefLabel": "NDA PHQ Assessment",
    "skos:altLabel": "nda_phq",
    "schema:description": "activity set for NDA-PHQ Assessments",
    "schema:schemaVersion": "0.0.1",
    "schema:version": "0.0.1",
    "ui": {
        "order": [
            "nda_guid",
            "phq9_schema",
            "phq9a_schema",
            "phq8_schema",
            "voice_task_schema"
        ],
        "shuffle": false,
        "locked": [
            "voice_task_schema",
        ],
       "unlock": "https://some/url/that_returns_a_list_of_strings_that_are_activities_to_unlock"
    }
}

the "unlock" endpoint will receive data from all activities and could be hit after completion of each activity. If it returns ["voice_task_schema"] then that activity will be shown

akeshavan commented 5 years ago

Now that we have activity-level branching logic, we can copy that pattern to the activity set level:


    "ui": {
        "order": [
            "nda_guid",
            "phq9_schema",
            "voice_task_schema"
        ],
        "shuffle": false,
        "visibility": [
            "nda_guid": true,
            "phq9_schema": "moment().diff(moment(nda_guid.birthDate), 'years') >= 18",
            "voice_task_schema": {
              "method": "POST",
              "url": "/path/to/server/endpoint",
              "payload": ["nda_guid", "phq9_schema"]
            }
        ]
    }

This says:

these conditions can be tested after completion of each activity. So initially, only nda_guid will show, and upon completion phq9_schema and voice_task_schema are evaluated. phq9_schema will evaluate to true, making it visible. After completion of that, all activities' visibilities are evaluated once more, and this server ping returns a true.

akeshavan commented 5 years ago

@sanuann @satra I've added:

        "visibility": {
            "phq9_schema": true,
            "nda_guid": {
              "method": "POST",
              "url": "https://us-central1-dmriprep.cloudfunctions.net/mit_voice_pilot",
              "payload": ["phq9_schema"]
            }
        }

but when jsonld parses this, I don't see the object as the value of "nda_guid" (but I do see that true is the value for "phq9_schema") -- where do I need to specify that the values of items in "visibility" can either be strings, booleans, or objects?

sanuann commented 5 years ago

you need to define it in the corresponding context file

sanuann commented 5 years ago

@akeshavan check this example http://tinyurl.com/y6hl8crm

akeshavan commented 5 years ago

got it! thanks!