study

package
v0.0.0-...-1cf31ce Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	COLLECTION_NAME_STUDY_INFOS                   = "study-infos"
	COLLECTION_NAME_STUDY_RULES                   = "studyRules"
	COLLECTION_NAME_SUFFIX_SURVEYS                = "surveys"
	COLLECTION_NAME_SUFFIX_RESPONSES              = "surveyResponses"
	COLLECTION_NAME_SUFFIX_PARTICIPANTS           = "participants"
	COLLECTION_NAME_SUFFIX_CONFIDENTIAL_RESPONSES = "confidentialResponses"
	COLLECTION_NAME_SUFFIX_REPORTS                = "reports"
	COLLECTION_NAME_SUFFIX_FILES                  = "participantFiles"
	COLLECTION_NAME_SUFFIX_RESEARCHER_MESSAGES    = "researcherMessages"
	COLLECTION_NAME_TASK_QUEUE                    = "taskQueue"
)

collection names

View Source
const (
	FALLBACK_PAGE_SIZE = 10
)
View Source
const (
	REMOVE_TASK_FROM_QUEUE_AFTER = 60 * 60 * 24 * 2 // 2 days
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PaginationInfos

type PaginationInfos struct {
	TotalCount  int64 `json:"totalCount"`
	CurrentPage int64 `json:"currentPage"`
	TotalPages  int64 `json:"totalPages"`
	PageSize    int64 `json:"pageSize"`
}

type StudyDBService

type StudyDBService struct {
	DBClient *mongo.Client

	DBNamePrefix string
	InstanceIDs  []string
	// contains filtered or unexported fields
}

func NewStudyDBService

func NewStudyDBService(configs db.DBConfig) (*StudyDBService, error)

func (*StudyDBService) CountParticipantFileInfos

func (dbService *StudyDBService) CountParticipantFileInfos(instanceID string, studyKey string, query bson.M) (int64, error)

count by query

func (*StudyDBService) CreateIndexForParticipantsCollection

func (dbService *StudyDBService) CreateIndexForParticipantsCollection(instanceID string, studyKey string) error

func (*StudyDBService) CreateIndexForReportsCollection

func (dbService *StudyDBService) CreateIndexForReportsCollection(instanceID string, studyKey string) error

func (*StudyDBService) CreateIndexForResponsesCollection

func (dbService *StudyDBService) CreateIndexForResponsesCollection(instanceID string, studyKey string) error

func (*StudyDBService) CreateIndexForStudyRulesCollection

func (dbService *StudyDBService) CreateIndexForStudyRulesCollection(instanceID string) error

func (*StudyDBService) CreateIndexForSurveyCollection

func (dbService *StudyDBService) CreateIndexForSurveyCollection(instanceID string, studyKey string) error

func (*StudyDBService) CreateStudy

func (dbService *StudyDBService) CreateStudy(instanceID string, study studyTypes.Study) error

func (*StudyDBService) CreateTask

func (dbService *StudyDBService) CreateTask(
	instanceID string,
	createdBy string,
	targetCount int,
	fileType string,
) (task studyTypes.Task, err error)

create task

func (*StudyDBService) DeleteParticipantByID

func (dbService *StudyDBService) DeleteParticipantByID(instanceID string, studyKey string, participantID string) error

delete participant

func (*StudyDBService) DeleteParticipantFileInfoByID

func (dbService *StudyDBService) DeleteParticipantFileInfoByID(instanceID string, studyKey string, fileInfoID string) error

delete one by id

func (*StudyDBService) DeleteResponseByID

func (dbService *StudyDBService) DeleteResponseByID(instanceID string, studyKey string, responseID string) error

delete response by id

func (*StudyDBService) DeleteResponses

func (dbService *StudyDBService) DeleteResponses(instanceID string, studyKey string, filter bson.M) error

delete responses by query

func (*StudyDBService) DeleteStudy

func (dbService *StudyDBService) DeleteStudy(instanceID string, studyKey string) error

delete study by study key

func (*StudyDBService) DeleteStudyRulesByID

func (dbService *StudyDBService) DeleteStudyRulesByID(instanceID string, studyKey string, id string) error

func (*StudyDBService) DeleteSurveyVersion

func (dbService *StudyDBService) DeleteSurveyVersion(instanceID string, studyKey string, surveyKey string, versionID string) (err error)

func (*StudyDBService) DeleteTaskByID

func (dbService *StudyDBService) DeleteTaskByID(instanceID string, taskID string) error

delete task by id

func (*StudyDBService) FindAndExecuteOnParticipantsStates

func (dbService *StudyDBService) FindAndExecuteOnParticipantsStates(
	ctx context.Context,
	instanceID string,
	studyKey string,
	filter bson.M,
	sort bson.M,
	returnOnErr bool,
	fn func(dbService *StudyDBService, p studyTypes.Participant, instanceID string, studyKey string, args ...interface{}) error,
	args ...interface{},
) error

execute function on participants

func (*StudyDBService) FindAndExecuteOnReports

func (dbService *StudyDBService) FindAndExecuteOnReports(
	ctx context.Context,
	instanceID string, studyKey string,
	filter bson.M,
	returnOnErr bool,
	fn func(instanceID string, studyKey string, report studyTypes.Report, args ...interface{}) error,
	args ...interface{},
) error

iterate over reports for query

func (*StudyDBService) FindAndExecuteOnResponses

func (dbService *StudyDBService) FindAndExecuteOnResponses(
	ctx context.Context,
	instanceID string, studyKey string,
	filter bson.M,
	sort bson.M,
	returnOnError bool,
	fn func(dbService *StudyDBService, r studyTypes.SurveyResponse, instanceID string, studyKey string, args ...interface{}) error,
	args ...interface{},
) error

execute on responses by query

func (*StudyDBService) FindConfidentialResponses

func (dbService *StudyDBService) FindConfidentialResponses(instanceID string, studyKey string, participantID string, key string) (responses []studytypes.SurveyResponse, err error)

func (*StudyDBService) GetCurrentStudyRules

func (dbService *StudyDBService) GetCurrentStudyRules(instanceID string, studyKey string) (rules studyTypes.StudyRules, err error)

func (*StudyDBService) GetCurrentSurveyVersion

func (dbService *StudyDBService) GetCurrentSurveyVersion(instanceID string, studyKey string, surveyKey string) (survey *studyTypes.Survey, err error)

func (*StudyDBService) GetNotificationSubscriptions

func (dbService *StudyDBService) GetNotificationSubscriptions(instanceID string, studyKey string) ([]studyTypes.NotificationSubscription, error)

func (*StudyDBService) GetParticipantByID

func (dbService *StudyDBService) GetParticipantByID(instanceID string, studyKey string, participantID string) (participant studyTypes.Participant, err error)

get participant by id

func (*StudyDBService) GetParticipantCount

func (dbService *StudyDBService) GetParticipantCount(instanceID string, studyKey string, filter bson.M) (int64, error)

get participant count for filter

func (*StudyDBService) GetParticipantFileInfoByID

func (dbService *StudyDBService) GetParticipantFileInfoByID(instanceID string, studyKey string, fileInfoID string) (participantFileInfo studytypes.FileInfo, err error)

get one by id

func (*StudyDBService) GetParticipantFileInfos

func (dbService *StudyDBService) GetParticipantFileInfos(instanceID string, studyKey string, query bson.M, page int64, limit int64) (fileInfos []studytypes.FileInfo, paginationInfo *PaginationInfos, err error)

func (*StudyDBService) GetParticipants

func (dbService *StudyDBService) GetParticipants(instanceID string, studyKey string, filter bson.M, sort bson.M, page int64, limit int64) (participants []studyTypes.Participant, paginationInfo *PaginationInfos, err error)

get paginated set of participants

func (*StudyDBService) GetReportByID

func (dbService *StudyDBService) GetReportByID(instanceID string, studyKey string, reportID string) (report studyTypes.Report, err error)

get report by id

func (*StudyDBService) GetReportCountForQuery

func (dbService *StudyDBService) GetReportCountForQuery(instanceID string, studyKey string, filter bson.M) (int64, error)

get report count for query

func (*StudyDBService) GetReports

func (dbService *StudyDBService) GetReports(instanceID string, studyKey string, filter bson.M, page int64, limit int64) (reports []studyTypes.Report, paginationInfo *PaginationInfos, err error)

get reports for query with pagination

func (*StudyDBService) GetResponseByID

func (dbService *StudyDBService) GetResponseByID(instanceID string, studyKey string, responseID string) (response studyTypes.SurveyResponse, err error)

get response by id

func (*StudyDBService) GetResponses

func (dbService *StudyDBService) GetResponses(instanceID string, studyKey string, filter bson.M, sort bson.M, page int64, limit int64) (responses []studyTypes.SurveyResponse, paginationInfo *PaginationInfos, err error)

get paginated responses by query

func (*StudyDBService) GetResponsesCount

func (dbService *StudyDBService) GetResponsesCount(instanceID string, studyKey string, filter bson.M) (int64, error)

get responses count by query

func (*StudyDBService) GetStudies

func (dbService *StudyDBService) GetStudies(instanceID string, statusFilter string, onlyKeys bool) (studies []studyTypes.Study, err error)

get studies

func (*StudyDBService) GetStudy

func (dbService *StudyDBService) GetStudy(instanceID string, studyKey string) (study studyTypes.Study, err error)

get study by study key

func (*StudyDBService) GetStudyRulesByID

func (dbService *StudyDBService) GetStudyRulesByID(instanceID string, studyKey string, id string) (rules studyTypes.StudyRules, err error)

func (*StudyDBService) GetStudyRulesHistory

func (dbService *StudyDBService) GetStudyRulesHistory(instanceID string, studyKey string) (ruleHistory []studyTypes.StudyRules, err error)

func (*StudyDBService) GetSurveyKeysForStudy

func (dbService *StudyDBService) GetSurveyKeysForStudy(instanceID string, studyKey string, includeUnpublished bool) (surveyKeys []string, err error)

func (*StudyDBService) GetSurveyVersion

func (dbService *StudyDBService) GetSurveyVersion(instanceID string, studyKey string, surveyKey string, versionID string) (survey *studyTypes.Survey, err error)

func (*StudyDBService) GetSurveyVersions

func (dbService *StudyDBService) GetSurveyVersions(instanceID string, studyKey string, surveyKey string) (surveys []*studyTypes.Survey, err error)

func (*StudyDBService) GetTaskByID

func (dbService *StudyDBService) GetTaskByID(instanceID string, taskID string) (task studyTypes.Task, err error)

get task by id

func (*StudyDBService) SaveStudyRules

func (dbService *StudyDBService) SaveStudyRules(instanceID string, studyKey string, rules studyTypes.StudyRules) error

func (*StudyDBService) SaveSurveyVersion

func (dbService *StudyDBService) SaveSurveyVersion(instanceID string, studyKey string, survey *studyTypes.Survey) (err error)

func (*StudyDBService) UnpublishSurvey

func (dbService *StudyDBService) UnpublishSurvey(instanceID string, studyKey string, surveyKey string) error

func (*StudyDBService) UpdateStudyDisplayProps

func (dbService *StudyDBService) UpdateStudyDisplayProps(instanceID string, studyKey string, name []studyTypes.LocalisedObject, description []studyTypes.LocalisedObject, tags []studyTypes.Tag) error

func (*StudyDBService) UpdateStudyFileUploadRule

func (dbService *StudyDBService) UpdateStudyFileUploadRule(instanceID string, studyKey string, fileUploadRule *studyTypes.Expression) error

func (*StudyDBService) UpdateStudyIsDefault

func (dbService *StudyDBService) UpdateStudyIsDefault(instanceID string, studyKey string, isDefault bool) error

update study is default

func (*StudyDBService) UpdateStudyNotificationSubscriptions

func (dbService *StudyDBService) UpdateStudyNotificationSubscriptions(instanceID string, studyKey string, subscriptions []studyTypes.NotificationSubscription) error

func (*StudyDBService) UpdateStudyStatus

func (dbService *StudyDBService) UpdateStudyStatus(instanceID string, studyKey string, status string) error

update study status

func (*StudyDBService) UpdateTaskCompleted

func (dbService *StudyDBService) UpdateTaskCompleted(
	instanceID string,
	taskID string,
	status string,
	processedCount int,
	errMsg string,
	resultFile string,
) error

func (*StudyDBService) UpdateTaskProgress

func (dbService *StudyDBService) UpdateTaskProgress(instanceID string, taskID string, processedCount int) error

update task processed count

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL