Documentation
¶
Index ¶
- Constants
- type AssignedSurvey
- type ComponentProperties
- type Expression
- type ExpressionArg
- type FileInfo
- type ItemComponent
- type LocalisedObject
- type MaxItemsPerPage
- type NotificationSubscription
- type Participant
- type ParticipantMessage
- type Report
- type ReportData
- type ResponseItem
- type ResponseMeta
- type Study
- type StudyCodeListEntry
- type StudyConfigs
- type StudyMessage
- type StudyProps
- type StudyRules
- type StudyStats
- type StudyVariableDateConfig
- type StudyVariableFloatConfig
- type StudyVariableIntConfig
- type StudyVariableStringConfig
- type StudyVariables
- type StudyVariablesType
- type Style
- type Survey
- type SurveyContextDef
- type SurveyItem
- type SurveyItemResponse
- type SurveyProps
- type SurveyResponse
- type Tag
- type Task
- type Validation
Constants ¶
View Source
const ( PARTICIPANT_STUDY_STATUS_ACTIVE = "active" PARTICIPANT_STUDY_STATUS_TEMPORARY = "temporary" // for participants without a registered account PARTICIPANT_STUDY_STATUS_VIRTUAL = "virtual" // for participants created by study managers PARTICIPANT_STUDY_STATUS_EXITED = "exited" PARTICIPANT_STUDY_STATUS_ACCOUNT_DELETED = "accountDeleted" )
View Source
const ( FILE_STATUS_UPLOADING = "uploading" FILE_STATUS_READY = "ready" )
View Source
const ( STUDY_STATUS_ACTIVE = "active" STUDY_STATUS_INACTIVE = "inactive" )
View Source
const ( SURVEY_ITEM_TYPE_PAGE_BREAK = "pageBreak" SURVEY_ITEM_TYPE_END = "surveyEnd" )
View Source
const ( SURVEY_AVAILABLE_FOR_PUBLIC = "public" SURVEY_AVAILABLE_FOR_TEMPORARY_PARTICIPANTS = "temporary_participants" SURVEY_AVAILABLE_FOR_ACTIVE_PARTICIPANTS = "active_participants" SURVEY_AVAILABLE_FOR_PARTICIPANTS_IF_ASSIGNED = "participants_if_assigned" )
View Source
const ( TASK_STATUS_IN_PROGRESS = "in_progress" TASK_STATUS_COMPLETED = "completed" TASK_FILE_TYPE_JSON = "application/json" TASK_FILE_TYPE_CSV = "text/csv" )
View Source
const (
DEFAULT_ID_MAPPING_METHOD = "sha-256"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssignedSurvey ¶
type AssignedSurvey struct {
StudyKey string `bson:"studyKey" json:"studyKey"`
SurveyKey string `bson:"surveyKey" json:"surveyKey"`
ValidFrom int64 `bson:"validFrom" json:"validFrom"`
ValidUntil int64 `bson:"validUntil" json:"validUntil"`
Category string `bson:"category" json:"category"`
ProfileID string `bson:"profileID" json:"profileID"` // optional when sending surveys to multiple profiles
}
type ComponentProperties ¶
type ComponentProperties struct {
Min *ExpressionArg `bson:"min,omitempty" json:"min,omitempty"`
Max *ExpressionArg `bson:"max,omitempty" json:"max,omitempty"`
StepSize *ExpressionArg `bson:"stepSize,omitempty" json:"stepSize,omitempty"`
DateInputMode *ExpressionArg `bson:"dateInputMode,omitempty" json:"dateInputMode,omitempty"`
Pattern string `bson:"pattern,omitempty" json:"pattern,omitempty"`
}
type Expression ¶
type Expression struct {
Name string `bson:"name" json:"name"` // Name of the operation to be evaluated
ReturnType string `bson:"returnType,omitempty" json:"returnType,omitempty"`
Data []ExpressionArg `bson:"data,omitempty" json:"data,omitempty"` // Operation arguments
Metadata *struct {
SlotTypes []*string `bson:"slotTypes,omitempty" json:"slotTypes,omitempty"`
} `bson:"metadata,omitempty" json:"metadata,omitempty"`
}
type ExpressionArg ¶
type ExpressionArg struct {
DType string `bson:"dtype" json:"dtype"`
Exp *Expression `bson:"exp,omitempty" json:"exp,omitempty"`
Str string `bson:"str,omitempty" json:"str,omitempty"`
Num float64 `bson:"num,omitempty" json:"num,omitempty"`
}
func (ExpressionArg) IsExpression ¶
func (exp ExpressionArg) IsExpression() bool
func (ExpressionArg) IsNumber ¶
func (exp ExpressionArg) IsNumber() bool
func (ExpressionArg) IsString ¶
func (exp ExpressionArg) IsString() bool
type FileInfo ¶
type FileInfo struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
ParticipantID string `bson:"participantID,omitempty" json:"participantID,omitempty"`
Status string `bson:"status,omitempty" json:"status,omitempty"`
UploadedBy string `bson:"uploadedBy,omitempty" json:"uploadedBy,omitempty"` // if not uploaded by the participant
Path string `bson:"path,omitempty" json:"path,omitempty"`
PreviewPath string `bson:"previewPath,omitempty" json:"previewPath,omitempty"`
SubmittedAt int64 `bson:"submittedAt,omitempty" json:"submittedAt,omitempty"` // deprecated, use CreatedAt instead
CreatedAt time.Time `bson:"createdAt,omitempty" json:"createdAt,omitempty"`
UpdatedAt time.Time `bson:"updatedAt,omitempty" json:"updatedAt,omitempty"`
FileType string `bson:"fileType,omitempty" json:"fileType,omitempty"`
VisibleToParticipant bool `bson:"visibleToParticipant" json:"visibleToParticipant"`
Size int64 `bson:"size,omitempty" json:"size,omitempty"`
}
type ItemComponent ¶
type ItemComponent struct {
Role string `bson:"role" json:"role"`
Key string `bson:"key" json:"key"`
Content []LocalisedObject `bson:"content" json:"content"`
DisplayCondition *Expression `bson:"displayCondition,omitempty" json:"displayCondition,omitempty"`
Disabled *Expression `bson:"disabled,omitempty" json:"disabled,omitempty"`
// group component
Items []ItemComponent `bson:"items,omitempty" json:"items,omitempty"`
Order *Expression `bson:"order,omitempty" json:"order,omitempty"`
// response compontent
Dtype string `bson:"dtype,omitempty" json:"dtype,omitempty"`
Properties *ComponentProperties `bson:"properties,omitempty" json:"properties,omitempty"`
Style []Style `bson:"style,omitempty" json:"style,omitempty"`
Description []LocalisedObject `bson:"description" json:"description"`
}
type LocalisedObject ¶
type LocalisedObject struct {
Code string `bson:"code" json:"code"`
// For texts
Parts []ExpressionArg `bson:"parts" json:"parts"`
}
type MaxItemsPerPage ¶
type Participant ¶
type Participant struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
ParticipantID string `bson:"participantID" json:"participantId"` // reference to the study specific participant ID
CurrentStudySession string `bson:"currentStudySession" json:"currentStudySession"`
ModifiedAt int64 `bson:"modifiedAt" json:"modifiedAt"`
EnteredAt int64 `bson:"enteredAt" json:"enteredAt"`
StudyStatus string `bson:"studyStatus" json:"studyStatus"`
Flags map[string]string `bson:"flags" json:"flags"`
LinkingCodes map[string]string `bson:"linkingCodes" json:"linkingCodes"`
AssignedSurveys []AssignedSurvey `bson:"assignedSurveys" json:"assignedSurveys"`
LastSubmissions map[string]int64 `bson:"lastSubmission" json:"lastSubmissions"` // surveyKey with timestamp
Messages []ParticipantMessage `bson:"messages" json:"messages"`
}
Participant defines the datamodel for current state of the participant in a study as stored in the database
type ParticipantMessage ¶
type Report ¶
type Report struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
Key string `bson:"key" json:"key"`
ParticipantID string `bson:"participantID" json:"participantID"` // reference to the study specific participant ID
ResponseID string `bson:"responseID" json:"responseID"` // reference to the report
Timestamp int64 `bson:"timestamp" json:"timestamp"`
ModifiedAt time.Time `bson:"modifiedAt,omitempty" json:"modifiedAt,omitempty"` // if report is updated later, this is the time of the update
Data []ReportData `bson:"data" json:"data,omitempty"`
}
type ReportData ¶
type ResponseItem ¶
type ResponseItem struct {
Key string `bson:"key" json:"key"`
Value string `bson:"value,omitempty" json:"value,omitempty"`
Dtype string `bson:"dtype,omitempty" json:"dtype,omitempty"`
// for response option groups
Items []*ResponseItem `bson:"items,omitempty" json:"items,omitempty"`
}
type ResponseMeta ¶
type ResponseMeta struct {
Position int32 `bson:"position" json:"position"`
LocaleCode string `bson:"localeCode" json:"localeCode"`
// timestamps
Rendered []int64 `bson:"rendered" json:"rendered"`
Displayed []int64 `bson:"displayed" json:"displayed"`
Responded []int64 `bson:"responded" json:"responded"`
}
type Study ¶
type Study struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
Key string `bson:"key" json:"key"`
SecretKey string `bson:"secretKey" json:"secretKey"`
Status string `bson:"status" json:"status"`
Props StudyProps `bson:"props" json:"props"`
Configs StudyConfigs `bson:"configs" json:"configs"`
NotificationSubscriptions []NotificationSubscription `bson:"notificationSubscriptions" json:"notificationSubscriptions"`
// depracted fields potentially to be removed in the future
Stats StudyStats `bson:"studyStats" json:"stats"`
NextTimerEvent int64 `bson:"nextTimerEvent" json:"nextTimerEvent"`
Rules []Expression `bson:"rules" json:"rules"`
}
type StudyCodeListEntry ¶
type StudyConfigs ¶
type StudyConfigs struct {
ParticipantFileUploadRule *Expression `bson:"participantFileUploadRule" json:"participantFileUploadRule"`
IdMappingMethod string `bson:"idMappingMethod" json:"idMappingMethod"`
}
type StudyMessage ¶
type StudyMessage struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
Type string `bson:"type,omitempty" json:"type,omitempty"`
Payload map[string]string `bson:"payload,omitempty" json:"payload,omitempty"`
ParticipantID string `bson:"participantID,omitempty" json:"participantID,omitempty"`
}
type StudyProps ¶
type StudyProps struct {
Name []LocalisedObject `bson:"name" json:"name"`
Description []LocalisedObject `bson:"description" json:"description"`
Tags []Tag `bson:"tags" json:"tags"`
StartDate int64 `bson:"startDate" json:"startDate"`
EndDate int64 `bson:"endDate" json:"endDate"`
SystemDefaultStudy bool `bson:"systemDefaultStudy" json:"systemDefaultStudy"`
}
type StudyRules ¶
type StudyRules struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
StudyKey string `bson:"studyKey" json:"studyKey"`
UploadedAt int64 `bson:"uploadedAt" json:"uploadedAt"`
UploadedBy string `bson:"uploadedBy" json:"uploadedBy"`
Rules []Expression `bson:"rules,omitempty" json:"rules"`
SerialisedRules string `bson:"serialisedRules,omitempty" json:"serialisedRules,omitempty"`
}
func (*StudyRules) MarshalRules ¶
func (studyRules *StudyRules) MarshalRules() error
func (*StudyRules) UnmarshalRules ¶
func (studyRules *StudyRules) UnmarshalRules() error
type StudyStats ¶
type StudyVariableDateConfig ¶
type StudyVariableIntConfig ¶
type StudyVariables ¶
type StudyVariables struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
CreatedAt time.Time `bson:"createdAt" json:"createdAt"`
ConfigUpdatedAt time.Time `bson:"configUpdatedAt" json:"configUpdatedAt"`
ValueUpdatedAt time.Time `bson:"valueUpdatedAt" json:"valueUpdatedAt"`
StudyKey string `bson:"studyKey" json:"studyKey"`
Key string `bson:"key" json:"key"`
Value any `bson:"value" json:"value"`
Type StudyVariablesType `bson:"type" json:"type"`
// Metadata for editor
Label string `bson:"label" json:"label,omitempty"`
Description string `bson:"description" json:"description,omitempty"`
UIType string `bson:"uiType" json:"uiType,omitempty"`
UIPriority int `bson:"uiPriority" json:"uiPriority,omitempty"`
Configs map[string]any `bson:"configs" json:"configs,omitempty"`
}
func (*StudyVariables) UnmarshalJSON ¶
func (sv *StudyVariables) UnmarshalJSON(data []byte) error
UnmarshalJSON normalizes the Value field to the correct Go type based on Type. This ensures we persist correct BSON types and round-trip cleanly back to JSON.
type StudyVariablesType ¶
type StudyVariablesType string
const ( STUDY_VARIABLES_TYPE_STRING StudyVariablesType = "string" STUDY_VARIABLES_TYPE_INT StudyVariablesType = "int" STUDY_VARIABLES_TYPE_FLOAT StudyVariablesType = "float" STUDY_VARIABLES_TYPE_BOOLEAN StudyVariablesType = "boolean" STUDY_VARIABLES_TYPE_DATE StudyVariablesType = "date" )
type Survey ¶
type Survey struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
SurveyKey string `bson:"surveyKey,omitempty" json:"surveyKey,omitempty"`
Props SurveyProps `bson:"props,omitempty" json:"props,omitempty"`
PrefillRules []Expression `bson:"prefillRules,omitempty" json:"prefillRules,omitempty"`
ContextRules *SurveyContextDef `bson:"contextRules,omitempty" json:"contextRules,omitempty"`
MaxItemsPerPage *MaxItemsPerPage `bson:"maxItemsPerPage,omitempty" json:"maxItemsPerPage,omitempty"`
AvailableFor string `bson:"availableFor,omitempty" json:"availableFor,omitempty"`
RequireLoginBeforeSubmission bool `bson:"requireLoginBeforeSubmission,omitempty" json:"requireLoginBeforeSubmission,omitempty"`
Published int64 `bson:"published,omitempty" json:"published,omitempty"`
Unpublished int64 `bson:"unpublished,omitempty" json:"unpublished,omitempty"`
SurveyDefinition SurveyItem `bson:"surveyDefinition,omitempty" json:"surveyDefinition,omitempty"`
VersionID string `bson:"versionID,omitempty" json:"versionId,omitempty"`
Metadata map[string]string `bson:"metadata,omitempty" json:"metadata,omitempty"`
}
type SurveyContextDef ¶
type SurveyContextDef struct {
Mode *ExpressionArg `bson:"mode,omitempty" json:"mode,omitempty"`
PreviousResponses []Expression `bson:"previousResponses,omitempty" json:"previousResponses,omitempty"`
}
type SurveyItem ¶
type SurveyItem struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
Key string `bson:"key" json:"key"`
Follows []string `bson:"follows,omitempty" json:"follows,omitempty"`
Condition *Expression `bson:"condition,omitempty" json:"condition,omitempty"`
Priority float32 `bson:"priority,omitempty" json:"priority,omitempty"`
Metadata map[string]string `bson:"metadata,omitempty" json:"metadata,omitempty"`
// Question group attributes
Items []SurveyItem `bson:"items,omitempty" json:"items,omitempty"`
SelectionMethod *Expression `bson:"selectionMethod,omitempty" json:"selectionMethod,omitempty"`
// Question attributes
Type string `bson:"type,omitempty" json:"type,omitempty"` // Specify some special types e.g. 'pageBreak','surveyEnd'
Components *ItemComponent `bson:"components,omitempty" json:"components,omitempty"`
Validations []Validation `bson:"validations,omitempty" json:"validations,omitempty"`
ConfidentialMode string `bson:"confidentialMode,omitempty" json:"confidentialMode,omitempty"`
MapToKey string `bson:"mapToKey,omitempty" json:"mapToKey,omitempty"` // map to this key for confidential mode
}
type SurveyItemResponse ¶
type SurveyItemResponse struct {
Key string `bson:"key" json:"key"`
Meta ResponseMeta `bson:"meta" json:"meta"`
// for groups:
Items []SurveyItemResponse `bson:"items,omitempty" json:"items,omitempty"`
// for single items:
Response *ResponseItem `bson:"response,omitempty" json:"response,omitempty"`
ConfidentialMode string `bson:"confidentialMode,omitempty" json:"confidentialMode,omitempty"`
MapToKey string `bson:"mapToKey,omitempty" json:"mapToKey,omitempty"` // map to this key for confidential mode
}
type SurveyProps ¶
type SurveyProps struct {
Name []LocalisedObject `bson:"name,omitempty" json:"name,omitempty"`
Description []LocalisedObject `bson:"description,omitempty" json:"description,omitempty"`
TypicalDuration []LocalisedObject `bson:"typicalDuration,omitempty" json:"typicalDuration,omitempty"`
}
type SurveyResponse ¶
type SurveyResponse struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
Key string `bson:"key" json:"key"`
ParticipantID string `bson:"participantID" json:"participantId"`
VersionID string `bson:"versionID" json:"versionId"`
OpenedAt int64 `bson:"openedAt" json:"openedAt"`
SubmittedAt int64 `bson:"submittedAt" json:"submittedAt"`
ArrivedAt int64 `bson:"arrivedAt" json:"arrivedAt"`
Responses []SurveyItemResponse `bson:"responses" json:"responses"`
Context map[string]string `bson:"context" json:"context"`
}
type Tag ¶
type Tag struct {
Label []LocalisedObject `bson:"label" json:"label"`
}
type Task ¶
type Task struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
CreatedAt time.Time `bson:"createdAt" json:"createdAt"`
CreatedBy string `bson:"createdBy" json:"createdBy"`
UpdatedAt time.Time `bson:"updatedAt" json:"updatedAt"`
Status string `bson:"status" json:"status"`
TargetCount int `bson:"targetCount" json:"targetCount"`
ProcessedCount int `bson:"processedCount" json:"processedCount"`
ResultFile string `bson:"resultFile" json:"resultFile"`
FileType string `bson:"fileType" json:"fileType"`
Error string `bson:"error,omitempty" json:"error,omitempty"`
}
type Validation ¶
type Validation struct {
Key string `bson:"key" json:"key"`
Type string `bson:"type" json:"type"` // kind of validation : 'soft' or 'hard'
Rule Expression `bson:"expression" json:"rule"`
}
Click to show internal directories.
Click to hide internal directories.