Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Study-level, posted by the user

POST /v1/apps/selfv3/participants/{userId}/demographics

...

App-level, posted on the user’s behalf (by app admin)

POST /v1/apps/selfv3/participants/self/demographics

...

Uses the assessment JSON model

POST /v1/appsv3/self/participants/{userId}/demographics/assessment

...

Uses the assessment JSON model

POST /v1v3/apps/self/participants/self/demographics/assessment

...

Study-level, done by researcher or study coordinator

DELETE /v1v3/apps/self/participants/{userId}/demographics/{demographicId}

...

Study-level, done by researcher or study coordinator

DELETE /v1v3/apps/self/participants/{userId}/demographics

...

Study-level, done by researcher/study-coordinator

GET /v1v3/apps/self/participants/{userId}/demographics

...

Study-level, done by researcher/study-coordinator

GET /v1/appsv3/self/participants/demographics

...

Certain routes use an assessment response model for demographic input:

Code Block
{
  "stepHistory": [
    {
      "children": [
        {
          "identifier": <string> (category name),
          "answerType": { (optional)
              "typeunit": <string> (this field is only checked to see if it contains "array")
      },
      "value": <array or
          },
          "value": <single value, any type OR array of single value, any type OR object with fields of single value, any type>
        }
      ]
    }
  ]
}

Although other fields may be included in the normal assessment model, all other fields are discarded for demographics use. “type” is only used to determine whether to deserialize “value” as an array or single value.

Example:

Code Block
{
  "stepHistory": [
    {
      "children": [
        {
          "identifier": "height",
          "answerType": {
              "typeunit": "floatcm"
          },
          "value": 72.0
        },
        {
          "identifier": "race",
          "answerTypevalue": {[
           "type": "arrayAsian",
      },       "value":Native [Hawaiian or Other Pacific Islander"
    "Asian",      ]
   "Native Hawaiian or Other Pacific Islander"}
      ]
    }
  ]
}

Internal model

SQL:

Code Block
languagesql
CREATE TABLE IF NOT EXISTS `DemographicsUsers` (
    `id` varchar(60) NOT NULL,
    `studyId` varchar(60) NULL,
    `appId` varchar(60) NOT NULL,
    `userId` varchar(255) NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY (`studyId`, `appId`, `userId`),
    CONSTRAINT `DemographicUser-Account-Constraint` FOREIGN KEY (`userId`) REFERENCES `Accounts` (`id`) ON DELETE CASCADE,
    CONSTRAINT `DemographicUser-Study-Constraint` FOREIGN KEY (`studyId`, `appId`) REFERENCES `Substudies` (`id`, `studyId`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE IF NOT EXISTS `Demographics` (
    `id` varchar(60) NOT NULL,
    `demographicUserId` varchar(60) NOT NULL,
    `categoryName` varchar(768255) NOT NULL,
    `multipleSelect` boolean NOT NULL,
    `units` varchar(512) NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY (`demographicUserId`, `categoryName`),
    CONSTRAINT `Demographic-DemographicUser-Constraint` FOREIGN KEY (`demographicUserId`) REFERENCES `DemographicsUsers` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE IF NOT EXISTS `DemographicsValues` (
    `demographicId` varchar(60) NOT NULL,
    `value` varchar(1024) NOT NULL,
    CONSTRAINT `DemographicValue-Demographic-Constraint` FOREIGN KEY (`demographicId`) REFERENCES `Demographics` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

...