study

package
v0.0.0-...-4780336 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	COLLECTION_NAME_STUDY_INFOS                   = "study-infos"
	COLLECTION_NAME_CONFIDENTIAL_ID_MAP           = "confidential-id-map"
	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 ResponseInfo

type ResponseInfo 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"`
	ArrivedAt     int64              `bson:"arrivedAt" json:"arrivedAt"`
}

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) AddConfidentialIDMapEntry

func (dbService *StudyDBService) AddConfidentialIDMapEntry(instanceID, confidentialID, profileID, studyKey string) error

func (*StudyDBService) AddConfidentialResponse

func (dbService *StudyDBService) AddConfidentialResponse(instanceID string, studyKey string, response studytypes.SurveyResponse) (string, error)

func (*StudyDBService) AddSurveyResponse

func (dbService *StudyDBService) AddSurveyResponse(instanceID string, studyKey string, response studyTypes.SurveyResponse) (string, 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) DeleteConfidentialResponses

func (dbService *StudyDBService) DeleteConfidentialResponses(instanceID string, studyKey string, participantID string, key string) (count int64, err error)

func (*StudyDBService) DeleteMessagesFromParticipant

func (dbService *StudyDBService) DeleteMessagesFromParticipant(instanceID string, studyKey string, participantID string, messageIDs []string) error

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) DeleteResearcherMessages

func (dbService *StudyDBService) DeleteResearcherMessages(instanceID string, studyKey string, messageIDs []string) (int64, error)

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) FindResearcherMessages

func (dbService *StudyDBService) FindResearcherMessages(instanceID string, studyKey string) (messages []studyTypes.StudyMessage, 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) GetProfileIDFromConfidentialID

func (dbService *StudyDBService) GetProfileIDFromConfidentialID(instanceID, confidentialID, studyKey string) (string, error)

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) GetResponseInfos

func (dbService *StudyDBService) GetResponseInfos(instanceID string, studyKey string, filter bson.M, page int64, limit int64) (responseInfos []ResponseInfo, paginationInfo *PaginationInfos, err error)

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) RemoveConfidentialIDMapEntriesForProfile

func (dbService *StudyDBService) RemoveConfidentialIDMapEntriesForProfile(instanceID, profileID, studyKey string) error

func (*StudyDBService) RemoveConfidentialIDMapEntriesForStudy

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

func (*StudyDBService) ReplaceConfidentialResponse

func (dbService *StudyDBService) ReplaceConfidentialResponse(instanceID string, studyKey string, response studytypes.SurveyResponse) error

func (*StudyDBService) SaveParticipantState

func (dbService *StudyDBService) SaveParticipantState(instanceID string, studyKey string, pState studyTypes.Participant) (studyTypes.Participant, error)

func (*StudyDBService) SaveReport

func (dbService *StudyDBService) SaveReport(instanceID string, studyKey string, report studyTypes.Report) error

func (*StudyDBService) SaveResearcherMessage

func (dbService *StudyDBService) SaveResearcherMessage(instanceID string, studyKey string, message studyTypes.StudyMessage) error

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) UpdateParticipantIDonConfidentialResponses

func (dbService *StudyDBService) UpdateParticipantIDonConfidentialResponses(instanceID string, studyKey string, oldID string, newID string) (count int64, err error)

func (*StudyDBService) UpdateParticipantIDonReports

func (dbService *StudyDBService) UpdateParticipantIDonReports(instanceID string, studyKey string, oldID string, newID string) (count int64, err error)

func (*StudyDBService) UpdateParticipantIDonResponses

func (dbService *StudyDBService) UpdateParticipantIDonResponses(instanceID string, studyKey string, oldID string, newID string) (count int64, err 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) UpdateStudyStats

func (dbService *StudyDBService) UpdateStudyStats(instanceID string, studyKey string, stats studyTypes.StudyStats) 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

func (*StudyDBService) UpdateTaskTotalCount

func (dbService *StudyDBService) UpdateTaskTotalCount(instanceID string, taskID string, totalCount int) error

Jump to

Keyboard shortcuts

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