Documentation
¶
Index ¶
- Constants
- Variables
- func OrganisationScope(ctx context.Context) func(db *gorm.DB) *gorm.DB
- func ProgramScope(ctx context.Context, tableName string) func(db *gorm.DB) *gorm.DB
- type AccessToken
- type Address
- type Appointment
- type AuditLog
- type AuthorityPermission
- type AuthorityRole
- type AuthorityRoleClient
- type AuthorityRolePermission
- type AuthorityRoleUser
- type AuthorizationCode
- type Base
- type Booking
- type Caregiver
- type CaregiverClient
- type Client
- type ClientAddress
- type ClientFacilities
- type ClientFacility
- type ClientHealthDiaryEntry
- type ClientHealthDiaryQuote
- type ClientIdentifiers
- type ClientRelatedPerson
- type ClientServiceRequest
- type Community
- type CommunityClient
- type CommunityStaff
- type Contact
- type Create
- type Delete
- type Facility
- type FacilityIdentifier
- type Feedback
- type Identifier
- type Metric
- type Notification
- type OauthClient
- type OauthClientJWT
- type Organisation
- type OrganisationUser
- type PGInstance
- func (db *PGInstance) AcceptTerms(ctx context.Context, userID *string, termsID *int) (bool, error)
- func (db *PGInstance) AddCaregiverToClient(ctx context.Context, clientCaregiver *CaregiverClient) error
- func (db *PGInstance) AddFacilitiesToClientProfile(ctx context.Context, clientID string, facilities []string) error
- func (db *PGInstance) AddFacilitiesToStaffProfile(ctx context.Context, staffID string, facilities []string) error
- func (db *PGInstance) AddFacilityToProgram(ctx context.Context, programID string, facilityIDs []string) error
- func (db *PGInstance) CanRecordHeathDiary(ctx context.Context, clientID string) (bool, error)
- func (db *PGInstance) CheckAppointmentExistsByExternalID(ctx context.Context, externalID string) (bool, error)
- func (db PGInstance) CheckCaregiverExists(ctx context.Context, userID string) (bool, error)
- func (db PGInstance) CheckClientExists(ctx context.Context, userID string) (bool, error)
- func (db *PGInstance) CheckFacilityExistsByIdentifier(ctx context.Context, identifier *FacilityIdentifier) (bool, error)
- func (db *PGInstance) CheckIdentifierExists(ctx context.Context, identifierType string, identifierValue string) (bool, error)
- func (db *PGInstance) CheckIfClientExistsInProgram(ctx context.Context, userID, programID string) (bool, error)
- func (db *PGInstance) CheckIfClientHasPendingSurveyServiceRequest(ctx context.Context, clientID string, projectID int, formID string) (bool, error)
- func (db *PGInstance) CheckIfClientHasUnresolvedServiceRequests(ctx context.Context, clientID string, serviceRequestType string) (bool, error)
- func (db *PGInstance) CheckIfFacilityExistsInProgram(ctx context.Context, programID, facilityID string) (bool, error)
- func (db *PGInstance) CheckIfPhoneNumberExists(ctx context.Context, phone string, isOptedIn bool, flavour feedlib.Flavour) (bool, error)
- func (db *PGInstance) CheckIfProgramNameExists(ctx context.Context, organisationID string, programName string) (bool, error)
- func (db *PGInstance) CheckIfStaffHasUnresolvedServiceRequests(ctx context.Context, staffID string, serviceRequestType string) (bool, error)
- func (db *PGInstance) CheckIfSuperUserExists(ctx context.Context) (bool, error)
- func (db *PGInstance) CheckIfUsernameExists(ctx context.Context, username string) (bool, error)
- func (db *PGInstance) CheckOrganisationExists(ctx context.Context, organisationID string) (bool, error)
- func (db *PGInstance) CheckPhoneExists(ctx context.Context, phone string) (bool, error)
- func (db PGInstance) CheckStaffExists(ctx context.Context, userID string) (bool, error)
- func (db *PGInstance) CheckStaffExistsInProgram(ctx context.Context, userID, programID string) (bool, error)
- func (db *PGInstance) CheckUserHasPin(ctx context.Context, userID string) (bool, error)
- func (db *PGInstance) CompleteOnboardingTour(ctx context.Context, userID string, flavour feedlib.Flavour) (bool, error)
- func (db *PGInstance) CreateAccessToken(ctx context.Context, token *AccessToken) error
- func (db *PGInstance) CreateAppointment(ctx context.Context, appointment *Appointment) error
- func (db *PGInstance) CreateAuthorizationCode(ctx context.Context, code *AuthorizationCode) error
- func (db *PGInstance) CreateBooking(ctx context.Context, booking *Booking) (*Booking, error)
- func (db *PGInstance) CreateCaregiver(ctx context.Context, caregiver *Caregiver) error
- func (db *PGInstance) CreateClient(ctx context.Context, client *Client, contactID, identifierID string) error
- func (db *PGInstance) CreateCommunity(ctx context.Context, community *Community) (*Community, error)
- func (db *PGInstance) CreateFacilities(ctx context.Context, facilities []*Facility) ([]*Facility, error)
- func (db *PGInstance) CreateHealthDiaryEntry(ctx context.Context, healthDiary *ClientHealthDiaryEntry) (*ClientHealthDiaryEntry, error)
- func (db *PGInstance) CreateIdentifier(ctx context.Context, identifier *Identifier) error
- func (db *PGInstance) CreateMetric(ctx context.Context, metric *Metric) error
- func (db *PGInstance) CreateNotification(ctx context.Context, notification *Notification) error
- func (db *PGInstance) CreateOauthClient(ctx context.Context, client *OauthClient) error
- func (db *PGInstance) CreateOauthClientJWT(ctx context.Context, jwt *OauthClientJWT) error
- func (db *PGInstance) CreateOrUpdateSession(ctx context.Context, session *Session) error
- func (db *PGInstance) CreateOrganisation(ctx context.Context, organization *Organisation) (*Organisation, error)
- func (db *PGInstance) CreateProgram(ctx context.Context, program *Program) (*Program, error)
- func (db *PGInstance) CreateQuestion(ctx context.Context, input *Question) error
- func (db *PGInstance) CreateQuestionChoice(ctx context.Context, input *QuestionInputChoice) error
- func (db *PGInstance) CreateQuestionnaire(ctx context.Context, input *Questionnaire) error
- func (db *PGInstance) CreateRefreshToken(ctx context.Context, token *RefreshToken) error
- func (db *PGInstance) CreateScreeningTool(ctx context.Context, input *ScreeningTool) error
- func (db *PGInstance) CreateScreeningToolResponse(ctx context.Context, screeningToolResponse *ScreeningToolResponse, ...) (*string, error)
- func (db *PGInstance) CreateSecurityQuestions(ctx context.Context, securityQuestions []*SecurityQuestion) ([]*SecurityQuestion, error)
- func (db *PGInstance) CreateServiceRequest(ctx context.Context, serviceRequestInput *ClientServiceRequest) error
- func (db *PGInstance) CreateStaffServiceRequest(ctx context.Context, serviceRequestInput *StaffServiceRequest) error
- func (db *PGInstance) CreateTermsOfService(ctx context.Context, termsOfService *TermsOfService) (*TermsOfService, error)
- func (db *PGInstance) CreateUser(ctx context.Context, user *User) error
- func (db *PGInstance) CreateUserSurveys(ctx context.Context, userSurveys []*UserSurvey) error
- func (db *PGInstance) DeleteAccessToken(ctx context.Context, signature string) error
- func (db *PGInstance) DeleteClientProfile(ctx context.Context, clientID string, userID *string) error
- func (db *PGInstance) DeleteCommunity(ctx context.Context, communityID string) error
- func (db *PGInstance) DeleteFacility(ctx context.Context, identifier *FacilityIdentifier) (bool, error)
- func (db *PGInstance) DeleteOrganisation(ctx context.Context, organisation *Organisation) error
- func (db *PGInstance) DeleteRefreshToken(ctx context.Context, signature string) error
- func (db *PGInstance) DeleteStaffProfile(ctx context.Context, staffID string) error
- func (db *PGInstance) FindContacts(ctx context.Context, contactType, contactValue string) ([]*Contact, error)
- func (db *PGInstance) GetAccessToken(ctx context.Context, token AccessToken) (*AccessToken, error)
- func (db *PGInstance) GetAllScreeningTools(ctx context.Context, pagination *domain.Pagination) ([]*ScreeningTool, *domain.Pagination, error)
- func (db *PGInstance) GetAppointment(ctx context.Context, params *Appointment) (*Appointment, error)
- func (db *PGInstance) GetAppointmentServiceRequests(ctx context.Context, lastSyncTime time.Time, facilityID string) ([]*ClientServiceRequest, error)
- func (db *PGInstance) GetAuthorizationCode(ctx context.Context, code string) (*AuthorizationCode, error)
- func (db *PGInstance) GetAvailableScreeningTools(ctx context.Context, clientID string, screeningTool ScreeningTool, ...) ([]*ScreeningTool, error)
- func (db *PGInstance) GetCaregiverByUserID(ctx context.Context, userID string) (*Caregiver, error)
- func (db *PGInstance) GetCaregiverManagedClients(ctx context.Context, userID string, pagination *domain.Pagination) ([]*CaregiverClient, *domain.Pagination, error)
- func (db *PGInstance) GetCaregiverProfileByCaregiverID(ctx context.Context, caregiverID string) (*Caregiver, error)
- func (db *PGInstance) GetCaregiverProfileByUserID(ctx context.Context, userID string, organisationID string) (*Caregiver, error)
- func (db *PGInstance) GetCaregiversClient(ctx context.Context, caregiverClient CaregiverClient) ([]*CaregiverClient, error)
- func (db *PGInstance) GetClientFacilities(ctx context.Context, clientFacility ClientFacilities, ...) ([]*ClientFacilities, *domain.Pagination, error)
- func (db *PGInstance) GetClientHealthDiaryEntries(ctx context.Context, params map[string]interface{}) ([]*ClientHealthDiaryEntry, error)
- func (db *PGInstance) GetClientHealthDiaryQuote(ctx context.Context, limit int) ([]*ClientHealthDiaryQuote, error)
- func (db *PGInstance) GetClientIdentifiers(ctx context.Context, clientID string) ([]*Identifier, error)
- func (db *PGInstance) GetClientJWT(ctx context.Context, jti string) (*OauthClientJWT, error)
- func (db *PGInstance) GetClientProfile(ctx context.Context, userID string, programID string) (*Client, error)
- func (db *PGInstance) GetClientProfileByClientID(ctx context.Context, clientID string) (*Client, error)
- func (db *PGInstance) GetClientProfilesByIdentifier(ctx context.Context, identifierType, value string) ([]*Client, error)
- func (db *PGInstance) GetClientScreeningToolServiceRequestByToolType(ctx context.Context, clientID, toolType, status string) (*ClientServiceRequest, error)
- func (db *PGInstance) GetClientServiceRequestByID(ctx context.Context, serviceRequestID string) (*ClientServiceRequest, error)
- func (db *PGInstance) GetClientServiceRequests(ctx context.Context, requestType, status, clientID, facilityID string) ([]*ClientServiceRequest, error)
- func (db *PGInstance) GetClientUserPrograms(ctx context.Context, userID string) ([]*Program, error)
- func (db *PGInstance) GetClientsByFilterParams(ctx context.Context, facilityID string, params *dto.ClientFilterParamsInput) ([]*Client, error)
- func (db *PGInstance) GetClientsByParams(ctx context.Context, params Client, lastSyncTime *time.Time) ([]*Client, error)
- func (db *PGInstance) GetClientsInAFacility(ctx context.Context, facilityID string) ([]*Client, error)
- func (db *PGInstance) GetClientsPendingServiceRequestsCount(ctx context.Context, facilityID string, programID *string) (*domain.ServiceRequestsCount, error)
- func (db *PGInstance) GetClientsSurveyCount(ctx context.Context, userID string) (int, error)
- func (db *PGInstance) GetClientsSurveyServiceRequest(ctx context.Context, facilityID string, projectID int, formID string, ...) ([]*ClientServiceRequest, *domain.Pagination, error)
- func (db *PGInstance) GetCommunityByID(ctx context.Context, communityID string) (*Community, error)
- func (db *PGInstance) GetContactByUserID(ctx context.Context, userID *string, contactType string) (*Contact, error)
- func (db *PGInstance) GetCurrentTerms(ctx context.Context) (*TermsOfService, error)
- func (db *PGInstance) GetFacilitiesWithoutFHIRID(ctx context.Context) ([]*Facility, error)
- func (db *PGInstance) GetFacilityRespondedScreeningTools(ctx context.Context, facilityID, programID string, ...) ([]*ScreeningTool, *domain.Pagination, error)
- func (db PGInstance) GetFacilityStaffs(ctx context.Context, facilityID string) ([]*StaffProfile, error)
- func (db *PGInstance) GetHealthDiaryEntryByID(ctx context.Context, healthDiaryEntryID string) (*ClientHealthDiaryEntry, error)
- func (db *PGInstance) GetNotification(ctx context.Context, notificationID string) (*Notification, error)
- func (db *PGInstance) GetNotificationsCount(ctx context.Context, notification Notification) (int, error)
- func (db *PGInstance) GetOTP(ctx context.Context, phoneNumber string, flavour feedlib.Flavour) (*UserOTP, error)
- func (db *PGInstance) GetOauthClient(ctx context.Context, id string) (*OauthClient, error)
- func (db *PGInstance) GetOrCreateContact(ctx context.Context, contact *Contact) (*Contact, error)
- func (db *PGInstance) GetOrCreateNextOfKin(ctx context.Context, person *RelatedPerson, clientID, contactID string) error
- func (db *PGInstance) GetOrganisation(ctx context.Context, id string) (*Organisation, error)
- func (db *PGInstance) GetProgramByID(ctx context.Context, programID string) (*Program, error)
- func (db *PGInstance) GetProgramClientProfileByIdentifier(ctx context.Context, programID, identifierType, value string) (*Client, error)
- func (db *PGInstance) GetProgramFacilities(ctx context.Context, programID string) ([]*ProgramFacility, error)
- func (db *PGInstance) GetQuestionInputChoicesByQuestionID(ctx context.Context, questionID string) ([]*QuestionInputChoice, error)
- func (db *PGInstance) GetQuestionnaireByID(ctx context.Context, id string) (*Questionnaire, error)
- func (db *PGInstance) GetQuestionsByQuestionnaireID(ctx context.Context, questionnaireID string) ([]*Question, error)
- func (db *PGInstance) GetRecentHealthDiaryEntries(ctx context.Context, lastSyncTime time.Time, clientID string) ([]*ClientHealthDiaryEntry, error)
- func (db *PGInstance) GetRefreshToken(ctx context.Context, token RefreshToken) (*RefreshToken, error)
- func (db *PGInstance) GetScreeningToolByID(ctx context.Context, id string) (*ScreeningTool, error)
- func (db *PGInstance) GetScreeningToolQuestionResponsesByResponseID(ctx context.Context, responseID string) ([]*ScreeningToolQuestionResponse, error)
- func (db *PGInstance) GetScreeningToolResponseByID(ctx context.Context, id string) (*ScreeningToolResponse, error)
- func (db *PGInstance) GetScreeningToolResponsesWithPendingServiceRequests(ctx context.Context, clientID, programID string) ([]*ScreeningToolResponse, error)
- func (db *PGInstance) GetScreeningToolResponsesWithin24Hours(ctx context.Context, clientID, programID string) ([]*ScreeningToolResponse, error)
- func (db *PGInstance) GetScreeningToolServiceRequestOfRespondents(ctx context.Context, facilityID, programID string, screeningToolID string, ...) ([]*ClientServiceRequest, *domain.Pagination, error)
- func (db *PGInstance) GetSecurityQuestionByID(ctx context.Context, securityQuestionID *string) (*SecurityQuestion, error)
- func (db *PGInstance) GetSecurityQuestionResponse(ctx context.Context, questionID string, userID string) (*SecurityQuestionResponse, error)
- func (db *PGInstance) GetSecurityQuestions(ctx context.Context, flavour feedlib.Flavour) ([]*SecurityQuestion, error)
- func (db *PGInstance) GetServiceRequests(ctx context.Context, requestType, requestStatus *string, facilityID string, ...) ([]*ClientServiceRequest, *domain.Pagination, error)
- func (db *PGInstance) GetServiceRequestsForKenyaEMR(ctx context.Context, facilityID string, lastSyncTime time.Time) ([]*ClientServiceRequest, error)
- func (db *PGInstance) GetSharedHealthDiaryEntries(ctx context.Context, clientID string, facilityID string) ([]*ClientHealthDiaryEntry, error)
- func (db *PGInstance) GetStaffFacilities(ctx context.Context, staffFacility StaffFacilities, ...) ([]*StaffFacilities, *domain.Pagination, error)
- func (db *PGInstance) GetStaffIdentifiers(ctx context.Context, staffID string, identifierType *string) ([]*Identifier, error)
- func (db *PGInstance) GetStaffPendingServiceRequestsCount(ctx context.Context, facilityID string, programID string) (*domain.ServiceRequestsCount, error)
- func (db *PGInstance) GetStaffProfile(ctx context.Context, userID string, programID string) (*StaffProfile, error)
- func (db *PGInstance) GetStaffProfileByStaffID(ctx context.Context, staffID string) (*StaffProfile, error)
- func (db *PGInstance) GetStaffServiceRequestByID(ctx context.Context, serviceRequestID string) (*StaffServiceRequest, error)
- func (db *PGInstance) GetStaffServiceRequests(ctx context.Context, requestType, requestStatus *string, facilityID string, ...) ([]*StaffServiceRequest, *domain.Pagination, error)
- func (db *PGInstance) GetStaffUserPrograms(ctx context.Context, userID string) ([]*Program, error)
- func (db *PGInstance) GetSurveysWithServiceRequests(ctx context.Context, facilityID, programID string) ([]*UserSurvey, error)
- func (db *PGInstance) GetUserClientProfiles(ctx context.Context, userID string) ([]*Client, error)
- func (db *PGInstance) GetUserPINByUserID(ctx context.Context, userID string) (*PINData, error)
- func (db *PGInstance) GetUserProfileByPhoneNumber(ctx context.Context, phoneNumber string) (*User, error)
- func (db *PGInstance) GetUserProfileByPushToken(ctx context.Context, pushToken string) (*User, error)
- func (db *PGInstance) GetUserProfileByStaffID(ctx context.Context, staffID string) (*User, error)
- func (db *PGInstance) GetUserProfileByUserID(ctx context.Context, userID *string) (*User, error)
- func (db *PGInstance) GetUserProfileByUsername(ctx context.Context, username string) (*User, error)
- func (db *PGInstance) GetUserSecurityQuestionsResponses(ctx context.Context, userID, flavour string) ([]*SecurityQuestionResponse, error)
- func (db *PGInstance) GetUserStaffProfiles(ctx context.Context, userID string) ([]*StaffProfile, error)
- func (db *PGInstance) GetUserSurveyForms(ctx context.Context, params map[string]interface{}) ([]*UserSurvey, error)
- func (db *PGInstance) GetValidClientJWT(ctx context.Context, jti string) (*OauthClientJWT, error)
- func (db *PGInstance) InactivateFacility(ctx context.Context, identifier *FacilityIdentifier) (bool, error)
- func (db *PGInstance) InvalidatePIN(ctx context.Context, userID string) (bool, error)
- func (db *PGInstance) ListAppointments(ctx context.Context, params *Appointment, filters []*firebasetools.FilterParam, ...) ([]*Appointment, *domain.Pagination, error)
- func (db *PGInstance) ListAvailableNotificationTypes(ctx context.Context, params *Notification) ([]enums.NotificationType, error)
- func (db *PGInstance) ListBookings(ctx context.Context, clientID string, bookingState enums.BookingState, ...) ([]*Booking, *domain.Pagination, error)
- func (db *PGInstance) ListClientsCaregivers(ctx context.Context, clientID string, pagination *domain.Pagination) ([]*CaregiverClient, *domain.Pagination, error)
- func (db *PGInstance) ListCommunities(ctx context.Context, programID string, organisationID string) ([]*Community, error)
- func (db *PGInstance) ListFacilities(ctx context.Context, searchTerm *string, filter []*domain.FiltersParam, ...) ([]*Facility, *domain.Pagination, error)
- func (db *PGInstance) ListNotifications(ctx context.Context, params *Notification, ...) ([]*Notification, *domain.Pagination, error)
- func (db *PGInstance) ListOrganisations(ctx context.Context, pagination *domain.Pagination) ([]*Organisation, *domain.Pagination, error)
- func (db *PGInstance) ListProgramFacilities(ctx context.Context, programID, searchTerm *string, ...) ([]*Facility, *domain.Pagination, error)
- func (db *PGInstance) ListPrograms(ctx context.Context, organisationID *string, pagination *domain.Pagination) ([]*Program, *domain.Pagination, error)
- func (db *PGInstance) ListSurveyRespondents(ctx context.Context, params *UserSurvey, facilityID string, ...) ([]*UserSurvey, *domain.Pagination, error)
- func (db *PGInstance) ReactivateFacility(ctx context.Context, identifier *FacilityIdentifier) (bool, error)
- func (db *PGInstance) RegisterCaregiver(ctx context.Context, user *User, contact *Contact, caregiver *Caregiver) error
- func (db *PGInstance) RegisterClient(ctx context.Context, user *User, contact *Contact, identifier *Identifier, ...) (*Client, error)
- func (db *PGInstance) RegisterExistingUserAsCaregiver(ctx context.Context, caregiver *Caregiver) (*Caregiver, error)
- func (db *PGInstance) RegisterExistingUserAsClient(ctx context.Context, identifier *Identifier, client *Client) (*Client, error)
- func (db *PGInstance) RegisterExistingUserAsStaff(ctx context.Context, identifier *Identifier, staff *StaffProfile) (*StaffProfile, error)
- func (db *PGInstance) RegisterStaff(ctx context.Context, user *User, contact *Contact, identifier *Identifier, ...) (*StaffProfile, error)
- func (db *PGInstance) RemoveFacilitiesFromClientProfile(ctx context.Context, clientID string, facilities []string) error
- func (db *PGInstance) RemoveFacilitiesFromStaffProfile(ctx context.Context, staffID string, facilities []string) error
- func (db *PGInstance) ResolveStaffServiceRequest(ctx context.Context, staffID *string, serviceRequestID *string, ...) (bool, error)
- func (db *PGInstance) RetrieveFacility(ctx context.Context, id *string, isActive bool) (*Facility, error)
- func (db *PGInstance) RetrieveFacilityByIdentifier(ctx context.Context, identifier *FacilityIdentifier, isActive bool) (*Facility, error)
- func (db PGInstance) RetrieveFacilityIdentifiersByFacilityID(ctx context.Context, facilityID *string) ([]*FacilityIdentifier, error)
- func (db *PGInstance) SaveFeedback(ctx context.Context, feedback *Feedback) error
- func (db *PGInstance) SaveOTP(ctx context.Context, otpInput *UserOTP) error
- func (db *PGInstance) SavePin(ctx context.Context, pinData *PINData) (bool, error)
- func (db *PGInstance) SaveSecurityQuestionResponse(ctx context.Context, securityQuestionResponse []*SecurityQuestionResponse) error
- func (db *PGInstance) SaveTemporaryUserPin(ctx context.Context, pinPayload *PINData) (bool, error)
- func (db *PGInstance) SearchCaregiverUser(ctx context.Context, searchParameter string) ([]*Caregiver, error)
- func (db *PGInstance) SearchClientProfile(ctx context.Context, searchParameter string) ([]*Client, error)
- func (db *PGInstance) SearchClientServiceRequests(ctx context.Context, searchParameter string, requestType string, ...) ([]*ClientServiceRequest, error)
- func (db *PGInstance) SearchOrganisation(ctx context.Context, searchParameter string) ([]*Organisation, error)
- func (db *PGInstance) SearchPlatformCaregivers(ctx context.Context, searchParameter string) ([]*Caregiver, error)
- func (db *PGInstance) SearchPrograms(ctx context.Context, searchParameter string, organisationID string, ...) ([]*Program, *domain.Pagination, error)
- func (db *PGInstance) SearchStaffProfile(ctx context.Context, searchParameter string, programID *string) ([]*StaffProfile, error)
- func (db *PGInstance) SearchStaffServiceRequests(ctx context.Context, searchParameter string, requestType string, ...) ([]*StaffServiceRequest, error)
- func (db *PGInstance) SetInProgressBy(ctx context.Context, requestID string, staffID string) (bool, error)
- func (db *PGInstance) UpdateAccessToken(ctx context.Context, code *AccessToken, updateData map[string]interface{}) error
- func (db *PGInstance) UpdateAppointment(ctx context.Context, appointment *Appointment, ...) (*Appointment, error)
- func (db *PGInstance) UpdateAuthorizationCode(ctx context.Context, code *AuthorizationCode, ...) error
- func (db *PGInstance) UpdateBooking(ctx context.Context, booking *Booking, updateData map[string]interface{}) error
- func (db *PGInstance) UpdateCaregiver(ctx context.Context, caregiver *Caregiver, updates map[string]interface{}) error
- func (db *PGInstance) UpdateCaregiverClient(ctx context.Context, caregiverClient *CaregiverClient, ...) error
- func (db *PGInstance) UpdateClient(ctx context.Context, client *Client, updates map[string]interface{}) (*Client, error)
- func (db *PGInstance) UpdateClientIdentifier(ctx context.Context, clientID string, identifierType string, ...) error
- func (db *PGInstance) UpdateClientServiceRequest(ctx context.Context, clientServiceRequest *ClientServiceRequest, ...) error
- func (db *PGInstance) UpdateFacility(ctx context.Context, facility *Facility, updateData map[string]interface{}) error
- func (db *PGInstance) UpdateFailedSecurityQuestionsAnsweringAttempts(ctx context.Context, userID string, failCount int) error
- func (db *PGInstance) UpdateHealthDiary(ctx context.Context, clientHealthDiaryEntry *ClientHealthDiaryEntry, ...) error
- func (db *PGInstance) UpdateIsCorrectSecurityQuestionResponse(ctx context.Context, userID string, isCorrectSecurityQuestionResponse bool) (bool, error)
- func (db *PGInstance) UpdateNotification(ctx context.Context, notification *Notification, ...) error
- func (db *PGInstance) UpdateProgram(ctx context.Context, program *Program, updateData map[string]interface{}) error
- func (db *PGInstance) UpdateRefreshToken(ctx context.Context, code *RefreshToken, updateData map[string]interface{}) error
- func (db *PGInstance) UpdateServiceRequests(ctx context.Context, payload []*ClientServiceRequest) (bool, error)
- func (db *PGInstance) UpdateStaff(ctx context.Context, staff *StaffProfile, updates map[string]interface{}) (*StaffProfile, error)
- func (db *PGInstance) UpdateUser(ctx context.Context, user *User, updateData map[string]interface{}) error
- func (db *PGInstance) UpdateUserContact(ctx context.Context, userContact *Contact, updates map[string]interface{}) error
- func (db *PGInstance) UpdateUserPinChangeRequiredStatus(ctx context.Context, userID string, flavour feedlib.Flavour, status bool) error
- func (db *PGInstance) UpdateUserPinUpdateRequiredStatus(ctx context.Context, userID string, flavour feedlib.Flavour, status bool) error
- func (db *PGInstance) UpdateUserSurveys(ctx context.Context, survey *UserSurvey, updateData map[string]interface{}) error
- func (db *PGInstance) VerifyOTP(ctx context.Context, payload *dto.VerifyOTPInput) (bool, error)
- type PINData
- type PKCE
- type Program
- type ProgramFacility
- type Query
- type Question
- type QuestionInputChoice
- type Questionnaire
- type RefreshToken
- type RelatedPerson
- type RelatedPersonAddresses
- type RelatedPersonContacts
- type ScreeningTool
- type ScreeningToolQuestionResponse
- type ScreeningToolResponse
- type SecurityQuestion
- type SecurityQuestionResponse
- type Session
- type StaffFacilities
- type StaffIdentifiers
- type StaffProfile
- type StaffServiceRequest
- type TermsOfService
- type Update
- type User
- type UserOTP
- type UserSurvey
Constants ¶
const ( // DBHost .. DBHost = "POSTGRES_HOST" // DBPort ... DBPort = "POSTGRES_PORT" // DBUser ... DBUser = "POSTGRES_USER" // DBPASSWORD ... DBPASSWORD = "POSTGRES_PASSWORD" // DBName ... DBName = "POSTGRES_DB" )
Variables ¶
var GCSBaseURL = serverutils.MustGetEnvVar(helpers.GoogleCloudStorageURL)
GCSBaseURL is the Google Cloud Storage URL
Functions ¶
func OrganisationScope ¶
OrganisationScope is a reusable query used for filtering out records for a specific organisation
func ProgramScope ¶
ProgramScope generates a GORM scope to filter records based on the program ID.
This function creates a GORM scope that filters records in a table based on the program ID stored in the provided context. It allows specifying the table name in the 'tableName' parameter to avoid ambiguity when the 'program_id' column exists in multiple tables involved in the query.
When ambiguity occurs, an error like `pq: column reference "program_id" is ambiguous` will be returned. The error occurs in GORM when a column name is used in a query, but the database engine cannot determine which table the column belongs to due to the column being present in multiple tables involved in the query
Types ¶
type AccessToken ¶
type AccessToken struct { Base ID string `gorm:"primarykey"` Active bool `gorm:"column:active"` Signature string `gorm:"unique;column:signature"` RequestedAt time.Time `gorm:"column:requested_at"` RequestedScopes pq.StringArray `gorm:"type:varchar(256)[];column:requested_scopes"` GrantedScopes pq.StringArray `gorm:"type:varchar(256)[];column:granted_scopes"` Form pgtype.JSONB `gorm:"type:jsonb;column:form;default:'{}'"` RequestedAudience pq.StringArray `gorm:"type:varchar(256)[];column:requested_audience"` GrantedAudience pq.StringArray `gorm:"type:varchar(256)[];column:granted_audience"` ClientID string `gorm:"column:client_id"` Client OauthClient SessionID string `gorm:"column:session_id"` Session Session }
func (*AccessToken) BeforeCreate ¶
func (a *AccessToken) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating
func (AccessToken) TableName ¶
func (AccessToken) TableName() string
TableName references the table name in the database
type Address ¶
type Address struct { Base ID *string `gorm:"primaryKey;column:id"` Active bool `gorm:"column:active;not null"` AddressType string `gorm:"column:address_type;not null"` Text string `gorm:"column:text;not null"` PostalCode string `gorm:"column:postal_code;not null"` Country string `gorm:"column:country;not null"` OrganisationID string `gorm:"column:organisation_id;not null"` }
Address holds the details of an organization/facility Types include:- Postal, Physical or Both
func (*Address) BeforeCreate ¶
BeforeCreate is a hook run before creating a new facility
func (*Address) BeforeUpdate ¶
BeforeUpdate is a hook called before updating Address.
type Appointment ¶
type Appointment struct { Base ID string `gorm:"primaryKey;column:id;"` Active bool `gorm:"column:active;not null"` ExternalID string `gorm:"column:external_id"` Reason string `gorm:"column:reason"` Provider string `gorm:"column:provider"` Date time.Time `gorm:"column:date"` HasRescheduledAppointment bool `gorm:"column:has_rescheduled_appointment"` ProgramID string `gorm:"column:program_id"` OrganisationID string `gorm:"column:organisation_id;not null"` ClientID string `gorm:"column:client_id"` FacilityID string `gorm:"column:facility_id"` CaregiverID *string `gorm:"column:caregiver_id"` }
Appointment represents a single appointment
func (*Appointment) BeforeCreate ¶
func (a *Appointment) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating an appointment
func (Appointment) TableName ¶
func (Appointment) TableName() string
TableName references the table that we map data from
type AuditLog ¶
type AuditLog struct { Base ID *string `gorm:"primaryKey;column:id"` Active bool `gorm:"column:active;not null"` Timestamp time.Time `gorm:"column:timestamp;not null"` RecordType string `gorm:"column:record_type;not null"` Notes string `gorm:"column:notes"` Payload pgtype.JSONB `gorm:"column:payload"` OrganisationID string `gorm:"column:organisation_id;not null"` }
AuditLog is used to record all sensitive changes e.g - changing a client's treatment buddy - changing a client's facility - deactivating a client - changing a client's assigned community health volunteer Rules of thumb: is there a need to find out what/when/why something occurred? Is a mistake potentially serious? Is there potential for fraud?
func (*AuditLog) BeforeCreate ¶
BeforeCreate is a hook run before creating a new facility
func (*AuditLog) BeforeUpdate ¶
BeforeUpdate is a hook called before updating AuditLog.
type AuthorityPermission ¶
type AuthorityPermission struct { Base AuthorityPermissionID *string `gorm:"column:id"` Name string `gorm:"column:name"` Description string `gorm:"column:description"` Category string `gorm:"column:category"` Scope string `gorm:"column:scope"` }
AuthorityPermission is the gorms authority permission model
func (*AuthorityPermission) BeforeCreate ¶
func (a *AuthorityPermission) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating authority permission
func (*AuthorityPermission) BeforeUpdate ¶
func (a *AuthorityPermission) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating AuthorityPermission.
func (AuthorityPermission) TableName ¶
func (AuthorityPermission) TableName() string
TableName references the table that we map data from
type AuthorityRole ¶
type AuthorityRole struct { Base AuthorityRoleID *string `gorm:"column:id"` Name string `gorm:"column:name"` Active bool `gorm:"column:active"` OrganisationID string `gorm:"column:organisation_id"` ProgramID string `gorm:"column:program_id"` }
AuthorityRole is the gorms authority role model
func (*AuthorityRole) BeforeCreate ¶
func (a *AuthorityRole) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating authority role
func (*AuthorityRole) BeforeUpdate ¶
func (a *AuthorityRole) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating AuthorityRole.
func (AuthorityRole) TableName ¶
func (AuthorityRole) TableName() string
TableName references the table that we map data from
type AuthorityRoleClient ¶
type AuthorityRoleClient struct { ID int `gorm:"primaryKey;column:id;autoincrement"` ClientID *string `gorm:"column:client_id"` RoleID *string `gorm:"column:authorityrole_id"` }
AuthorityRoleClient is the gorms authority role client model
func (AuthorityRoleClient) TableName ¶
func (AuthorityRoleClient) TableName() string
TableName references the table that we map data from
type AuthorityRolePermission ¶
type AuthorityRolePermission struct { ID int `gorm:"primaryKey;column:id;autoincrement"` PermissionID *string `gorm:"column:authoritypermission_id"` RoleID *string `gorm:"column:authorityrole_id"` Active bool `gorm:"column:active"` }
AuthorityRolePermission is the gorms authority role permission model
func (AuthorityRolePermission) TableName ¶
func (AuthorityRolePermission) TableName() string
TableName references the table that we map data from
type AuthorityRoleUser ¶
type AuthorityRoleUser struct { ID int `gorm:"primaryKey;column:id;autoincrement"` UserID *string `gorm:"column:user_id"` RoleID *string `gorm:"column:authorityrole_id"` }
AuthorityRoleUser is the gorms authority role user model
func (AuthorityRoleUser) TableName ¶
func (AuthorityRoleUser) TableName() string
TableName references the table that we map data from
type AuthorizationCode ¶
type AuthorizationCode struct { Base ID string `gorm:"primarykey"` Active bool `gorm:"column:active"` Code string `gorm:"column:code"` RequestedAt time.Time `gorm:"column:requested_at"` RequestedScopes pq.StringArray `gorm:"type:varchar(256)[];column:requested_scopes"` GrantedScopes pq.StringArray `gorm:"type:varchar(256)[];column:granted_scopes"` Form pgtype.JSONB `gorm:"type:jsonb;column:form;default:'{}'"` RequestedAudience pq.StringArray `gorm:"type:varchar(256)[];column:requested_audience"` GrantedAudience pq.StringArray `gorm:"type:varchar(256)[];column:granted_audience"` SessionID string `gorm:"column:session_id"` Session Session ClientID string `gorm:"column:client_id"` Client OauthClient }
func (*AuthorizationCode) BeforeCreate ¶
func (a *AuthorizationCode) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating
func (AuthorizationCode) TableName ¶
func (AuthorizationCode) TableName() string
TableName references the table name in the database
type Base ¶
type Base struct { CreatedAt time.Time `gorm:"column:created;not null"` UpdatedAt time.Time `gorm:"column:updated;not null"` CreatedBy *string `gorm:"column:created_by"` UpdatedBy *string `gorm:"column:updated_by"` DeletedAt *time.Time `gorm:"column:deleted_at"` }
Base model contains defines common fields across tables
type Booking ¶
type Booking struct { Base ID string `gorm:"column:id"` Active bool `gorm:"column:active"` Services pq.StringArray `gorm:"type:text[];column:services"` Date time.Time `gorm:"column:date"` FacilityID string `gorm:"column:facility_id"` ClientID string `gorm:"column:client_id"` OrganisationID string `gorm:"column:organisation_id"` ProgramID string `gorm:"column:program_id"` VerificationCode string `gorm:"column:verification_code"` VerificationCodeStatus string `gorm:"column:verification_code_status"` BookingStatus string `gorm:"column:booking_status"` Client Client `gorm:"ForeignKey:client_id;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"` Facility Facility `gorm:"ForeignKey:facility_id;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"` }
Booking defines the database model used to persit a booking record
func (*Booking) BeforeCreate ¶
BeforeCreate is a hook run before creating
type Caregiver ¶
type Caregiver struct { Base ID string `gorm:"primaryKey;column:id"` Active bool `gorm:"column:active"` CaregiverNumber string `gorm:"column:caregiver_number"` OrganisationID string `gorm:"column:organisation_id;not null"` UserID string `gorm:"column:user_id"` UserProfile User `gorm:"ForeignKey:user_id;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"` CurrentClient *string `gorm:"column:current_client"` CurrentFacility *string `gorm:"column:current_facility"` }
Caregiver is the caregiver profile information for a user TODO: remove "N" when original caregiver is removed
func (*Caregiver) BeforeCreate ¶
BeforeCreate is a hook run before creating a caregiver
func (*Caregiver) BeforeUpdate ¶
BeforeUpdate is a hook called before updating a caregiver.
type CaregiverClient ¶
type CaregiverClient struct { Base CaregiverID string `gorm:"column:caregiver_id;not null"` ClientID string `gorm:"column:client_id;not null"` Active bool `gorm:"column:active"` RelationshipType enums.CaregiverType `gorm:"column:relationship_type;not null"` CaregiverConsent enums.ConsentState `gorm:"column:caregiver_consent"` CaregiverConsentAt *time.Time `gorm:"column:caregiver_consent_at"` ClientConsent enums.ConsentState `gorm:"column:client_consent"` ClientConsentAt *time.Time `gorm:"column:client_consent_at"` OrganisationID string `gorm:"column:organisation_id;not null"` AssignedBy string `gorm:"column:assigned_by;not null"` ProgramID string `gorm:"column:program_id"` }
CaregiverClient stores clients assigned to a caregiver and the associated relationship details
func (*CaregiverClient) BeforeCreate ¶
func (c *CaregiverClient) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating a caregiver client
func (*CaregiverClient) BeforeUpdate ¶
func (c *CaregiverClient) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating a caregiver client.
func (*CaregiverClient) TableName ¶
func (c *CaregiverClient) TableName() string
TableName references the table name in the database
type Client ¶
type Client struct { Base ID *string `gorm:"primaryKey;unique;column:id"` Active bool `gorm:"column:active"` ClientTypes pq.StringArray `gorm:"type:text[];column:client_types"` TreatmentEnrollmentDate *time.Time `gorm:"column:enrollment_date"` FHIRPatientID *string `gorm:"column:fhir_patient_id"` HealthRecordID *string `gorm:"column:emr_health_record_id"` ClientCounselled bool `gorm:"column:counselled"` UserID *string `gorm:"column:user_id;not null"` User User `gorm:"ForeignKey:user_id;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"` FacilityID string `gorm:"column:current_facility_id"` OrganisationID string `gorm:"column:organisation_id"` ProgramID string `gorm:"column:program_id"` }
Client holds the details of end users who are not using the system in a professional capacity e.g consumers, patients etc. It is a linkage model e.g to tie together all of a person's identifiers and their health record ID
func (*Client) BeforeCreate ¶
BeforeCreate is a hook run before creating a client profile
func (*Client) BeforeDelete ¶
BeforeDelete hook is called when deleting a record
func (*Client) BeforeUpdate ¶
BeforeUpdate is a hook called before updating Client.
type ClientAddress ¶
type ClientAddress struct { ID *string `gorm:"column:id"` ClientID string `gorm:"column:client_id"` AddressID string `gorm:"column:address_id"` }
ClientAddress represents a through table that holds addresses that belong to a client
func (ClientAddress) TableName ¶
func (ClientAddress) TableName() string
TableName composes the table's name
type ClientFacilities ¶
type ClientFacilities struct { ID int `gorm:"primaryKey;column:id;autoincrement"` ClientID *string `gorm:"column:client_id"` FacilityID *string `gorm:"column:facility_id"` }
ClientFacilities links a client with their facilities it is a through table
func (*ClientFacilities) TableName ¶
func (s *ClientFacilities) TableName() string
TableName references the table that we map data from
type ClientFacility ¶
type ClientFacility struct { Base ID *string `gorm:"column:id"` Active bool `gorm:"column:active"` OrganisationID string `gorm:"column:organisation_id"` ClientID string `gorm:"column:client_id"` FacilityID string `gorm:"column:facility_id"` ProgramID string `gorm:"column:program_id"` }
ClientFacility represents the client facility table
func (*ClientFacility) BeforeCreate ¶
func (c *ClientFacility) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating a client facility
func (*ClientFacility) BeforeUpdate ¶
func (c *ClientFacility) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating ClientFacility.
func (ClientFacility) TableName ¶
func (ClientFacility) TableName() string
TableName represents the client facility table name
type ClientHealthDiaryEntry ¶
type ClientHealthDiaryEntry struct { Base ClientHealthDiaryEntryID *string `gorm:"column:id"` Active bool `gorm:"column:active"` Mood string `gorm:"column:mood"` Note string `gorm:"column:note"` EntryType string `gorm:"column:entry_type"` ProgramID string `gorm:"column:program_id"` ClientID string `gorm:"column:client_id"` OrganisationID string `gorm:"column:organisation_id"` CaregiverID *string `gorm:"column:caregiver_id"` }
ClientHealthDiaryEntry models a client's health diary entry
func (*ClientHealthDiaryEntry) BeforeCreate ¶
func (c *ClientHealthDiaryEntry) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating a client Health Diary Entry
func (*ClientHealthDiaryEntry) BeforeUpdate ¶
func (c *ClientHealthDiaryEntry) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating ClientHealthDiaryEntry.
func (*ClientHealthDiaryEntry) TableName ¶
func (c *ClientHealthDiaryEntry) TableName() string
TableName references the table that we map data from
type ClientHealthDiaryQuote ¶
type ClientHealthDiaryQuote struct { Base ClientHealthDiaryQuoteID *string `gorm:"column:id"` Active bool `gorm:"column:active"` Quote string `gorm:"column:quote"` Author string `gorm:"column:by"` ProgramID string `gorm:"column:program_id"` OrganisationID string `gorm:"column:organisation_id"` }
ClientHealthDiaryQuote is the gorms client health diary quotes model
func (*ClientHealthDiaryQuote) BeforeCreate ¶
func (c *ClientHealthDiaryQuote) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating view count
func (*ClientHealthDiaryQuote) BeforeUpdate ¶
func (c *ClientHealthDiaryQuote) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating ClientHealthDiaryQuote.
func (ClientHealthDiaryQuote) TableName ¶
func (ClientHealthDiaryQuote) TableName() string
TableName references the table that we map data from
type ClientIdentifiers ¶
type ClientIdentifiers struct { ID int `gorm:"primaryKey;column:id;autoincrement"` ClientID *string `gorm:"column:client_id"` IdentifierID *string `gorm:"column:identifier_id"` }
ClientIdentifiers links a client with their identifiers
func (*ClientIdentifiers) TableName ¶
func (c *ClientIdentifiers) TableName() string
TableName references the table that we map data from
type ClientRelatedPerson ¶
type ClientRelatedPerson struct { ID int `gorm:"primaryKey;column:id;autoincrement"` ClientID *string `gorm:"column:client_id"` RelatedPersonID *string `gorm:"column:relatedperson_id"` }
ClientRelatedPerson links a client with their related person e.g next of kin
func (*ClientRelatedPerson) TableName ¶
func (c *ClientRelatedPerson) TableName() string
TableName references the table that we map data from
type ClientServiceRequest ¶
type ClientServiceRequest struct { Base ID *string `gorm:"column:id"` Active bool `gorm:"column:active"` RequestType string `gorm:"column:request_type"` Request string `gorm:"column:request"` Status string `gorm:"column:status"` InProgressAt *time.Time `gorm:"column:in_progress_at"` ResolvedAt *time.Time `gorm:"column:resolved_at"` InProgressByID *string `gorm:"column:in_progress_by_id"` Meta string `gorm:"column:meta"` ProgramID string `gorm:"column:program_id"` OrganisationID string `gorm:"column:organisation_id"` ResolvedByID *string `gorm:"column:resolved_by_id"` FacilityID string `gorm:"column:facility_id"` ClientID string `gorm:"column:client_id"` CaregiverID *string `gorm:"column:caregiver_id"` }
ClientServiceRequest maps the client service request table. It is used to store the tasks for the healthcare staff on the platform
func (*ClientServiceRequest) BeforeCreate ¶
func (c *ClientServiceRequest) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook called before creating a service request.
func (*ClientServiceRequest) BeforeUpdate ¶
func (c *ClientServiceRequest) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating a client service request.
func (ClientServiceRequest) TableName ¶
func (ClientServiceRequest) TableName() string
TableName references the table that we map data from
type Community ¶
type Community struct { Base ID string `gorm:"primaryKey;column:id"` RoomID string `json:"room_id"` Name string `gorm:"column:name"` Description string `gorm:"column:description"` Active bool `gorm:"column:active"` MinimumAge int `gorm:"column:min_age"` MaximumAge int `gorm:"column:max_age"` Gender pq.StringArray `gorm:"type:text[];column:gender"` ClientTypes pq.StringArray `gorm:"type:text[];column:client_types"` ProgramID string `gorm:"column:program_id"` OrganisationID string `gorm:"column:organisation_id"` }
Community defines the payload to create a community
func (*Community) BeforeCreate ¶
BeforeCreate is a hook run before creating a community
func (*Community) BeforeUpdate ¶
BeforeUpdate is a hook called before updating community.
type CommunityClient ¶
type CommunityClient struct { ID int `gorm:"primaryKey;column:id;autoincrement"` CommunityID *string `gorm:"column:community_id"` ClientID *string `gorm:"column:client_id"` }
CommunityClient is represents the relationship between a client and a community. It is basically a through table
func (CommunityClient) TableName ¶
func (CommunityClient) TableName() string
TableName references the table that we map data from
type CommunityStaff ¶
type CommunityStaff struct { ID int `gorm:"primaryKey;column:id;autoincrement"` CommunityID *string `gorm:"column:community_id"` StaffID *string `gorm:"column:staff_id"` }
CommunityStaff is represents the relationship between a staff and a Community. It is basically a through table
func (CommunityStaff) TableName ¶
func (CommunityStaff) TableName() string
TableName references the table that we map data from
type Contact ¶
type Contact struct { Base ID string `gorm:"primaryKey;unique;column:id"` Type string `gorm:"column:contact_type;not null"` Value string `gorm:"unique;column:contact_value;not null"` Active bool `gorm:"column:active;not null"` // a user may opt not to be contacted via this contact // e.g if it's a shared phone owned by a teenager OptedIn bool `gorm:"column:opted_in;not null"` UserID *string `gorm:"column:user_id;not null"` OrganisationID string `gorm:"column:organisation_id"` }
Contact hold contact information/details for users
func (*Contact) BeforeCreate ¶
BeforeCreate is a hook run before creating a new contact
func (*Contact) BeforeUpdate ¶
BeforeUpdate is a hook called before updating Contact.
type Create ¶
type Create interface { SaveTemporaryUserPin(ctx context.Context, pinPayload *PINData) (bool, error) SavePin(ctx context.Context, pinData *PINData) (bool, error) SaveOTP(ctx context.Context, otpInput *UserOTP) error SaveSecurityQuestionResponse(ctx context.Context, securityQuestionResponse []*SecurityQuestionResponse) error CreateHealthDiaryEntry(ctx context.Context, healthDiaryInput *ClientHealthDiaryEntry) (*ClientHealthDiaryEntry, error) CreateServiceRequest(ctx context.Context, serviceRequestInput *ClientServiceRequest) error CreateStaffServiceRequest(ctx context.Context, serviceRequestInput *StaffServiceRequest) error CreateCommunity(ctx context.Context, community *Community) (*Community, error) GetOrCreateNextOfKin(ctx context.Context, person *RelatedPerson, clientID, contactID string) error GetOrCreateContact(ctx context.Context, contact *Contact) (*Contact, error) CreateAppointment(ctx context.Context, appointment *Appointment) error CreateUser(ctx context.Context, user *User) error CreateClient(ctx context.Context, client *Client, contactID, identifierID string) error CreateIdentifier(ctx context.Context, identifier *Identifier) error CreateNotification(ctx context.Context, notification *Notification) error CreateUserSurveys(ctx context.Context, userSurvey []*UserSurvey) error CreateMetric(ctx context.Context, metric *Metric) error RegisterStaff(ctx context.Context, user *User, contact *Contact, identifier *Identifier, staffProfile *StaffProfile) (*StaffProfile, error) RegisterExistingUserAsStaff(ctx context.Context, identifier *Identifier, staff *StaffProfile) (*StaffProfile, error) SaveFeedback(ctx context.Context, feedback *Feedback) error RegisterClient(ctx context.Context, user *User, contact *Contact, identifier *Identifier, client *Client) (*Client, error) RegisterExistingUserAsClient(ctx context.Context, identifier *Identifier, client *Client) (*Client, error) RegisterCaregiver(ctx context.Context, user *User, contact *Contact, caregiver *Caregiver) error RegisterExistingUserAsCaregiver(ctx context.Context, caregiver *Caregiver) (*Caregiver, error) CreateCaregiver(ctx context.Context, caregiver *Caregiver) error CreateQuestionnaire(ctx context.Context, input *Questionnaire) error CreateScreeningTool(ctx context.Context, input *ScreeningTool) error CreateQuestion(ctx context.Context, input *Question) error CreateQuestionChoice(ctx context.Context, input *QuestionInputChoice) error CreateScreeningToolResponse(ctx context.Context, screeningToolResponse *ScreeningToolResponse, screeningToolQuestionResponses []*ScreeningToolQuestionResponse) (*string, error) AddCaregiverToClient(ctx context.Context, clientCaregiver *CaregiverClient) error CreateProgram(ctx context.Context, program *Program) (*Program, error) CreateOrganisation(ctx context.Context, organization *Organisation) (*Organisation, error) AddFacilityToProgram(ctx context.Context, programID string, facilityIDs []string) error CreateFacilities(ctx context.Context, facilities []*Facility) ([]*Facility, error) CreateSecurityQuestions(ctx context.Context, securityQuestions []*SecurityQuestion) ([]*SecurityQuestion, error) CreateTermsOfService(ctx context.Context, termsOfService *TermsOfService) (*TermsOfService, error) CreateOauthClientJWT(ctx context.Context, jwt *OauthClientJWT) error CreateOauthClient(ctx context.Context, client *OauthClient) error CreateOrUpdateSession(ctx context.Context, session *Session) error CreateAuthorizationCode(ctx context.Context, code *AuthorizationCode) error CreateAccessToken(ctx context.Context, token *AccessToken) error CreateRefreshToken(ctx context.Context, token *RefreshToken) error CreateBooking(ctx context.Context, booking *Booking) (*Booking, error) }
Create contains all the methods used to perform a create operation in DB
type Delete ¶
type Delete interface { DeleteFacility(ctx context.Context, identifier *FacilityIdentifier) (bool, error) DeleteClientProfile(ctx context.Context, clientID string, userID *string) error DeleteStaffProfile(ctx context.Context, staffID string) error DeleteCommunity(ctx context.Context, communityID string) error RemoveFacilitiesFromClientProfile(ctx context.Context, clientID string, facilities []string) error RemoveFacilitiesFromStaffProfile(ctx context.Context, staffID string, facilities []string) error DeleteOrganisation(ctx context.Context, organisation *Organisation) error DeleteAccessToken(ctx context.Context, signature string) error DeleteRefreshToken(ctx context.Context, signature string) error }
Delete represents all `delete` ops to the database
type Facility ¶
type Facility struct { Base FacilityID *string `gorm:"primaryKey;unique;column:id"` Name string `gorm:"column:name;unique;not null"` Active bool `gorm:"column:active;not null"` Country string `gorm:"column:country;not null"` County string `gorm:"column:county;not null"` Address string `gorm:"column:address;not null"` Phone string `gorm:"column:phone"` Description string `gorm:"column:description;not null"` FHIROrganisationID string `gorm:"column:fhir_organization_id"` Identifier []*FacilityIdentifier Latitude float64 `gorm:"column:latitude;not null"` Longitude float64 `gorm:"column:longitude;not null"` }
Facility models the details of healthcare facilities that are on the platform.
e.g CCC clinics, Pharmacies.
func (*Facility) BeforeCreate ¶
BeforeCreate is a hook run before creating a new facility
func (*Facility) BeforeUpdate ¶
BeforeUpdate is a hook called before updating Facility.
type FacilityIdentifier ¶
type FacilityIdentifier struct { Base ID string `gorm:"primaryKey;unique;column:id"` Active bool `gorm:"column:active;not null"` Type string `gorm:"column:identifier_type;not null"` Value string `gorm:"column:identifier_value;not null"` FacilityID string `gorm:"column:facility_id;not null"` }
FacilityIdentifier stores a facilities identifiers
func (*FacilityIdentifier) BeforeCreate ¶
func (f *FacilityIdentifier) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating a new facility
func (*FacilityIdentifier) BeforeUpdate ¶
func (f *FacilityIdentifier) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating FacilityIdentifier.
func (FacilityIdentifier) TableName ¶
func (FacilityIdentifier) TableName() string
TableName customizes how the table name is generated
type Feedback ¶
type Feedback struct { Base ID string `gorm:"primaryKey;column:id"` Active bool `gorm:"column:active"` FeedbackType string `gorm:"column:feedback_type"` SatisfactionLevel int `gorm:"column:satisfaction_level"` ServiceName string `gorm:"column:service_name"` Feedback string `gorm:"column:feedback"` RequiresFollowUp bool `gorm:"column:requires_followup"` PhoneNumber string `gorm:"column:phone_number"` ProgramID string `gorm:"column:program_id"` OrganisationID string `gorm:"column:organisation_id"` UserID string `gorm:"column:user_id"` }
Feedback defines the feedback database model
func (*Feedback) BeforeCreate ¶
BeforeCreate is a hook run before creating an appointment
func (*Feedback) BeforeUpdate ¶
BeforeUpdate is a hook called before updating Feedback.
type Identifier ¶
type Identifier struct { Base ID string `gorm:"primaryKey;column:id;"` Active bool `gorm:"column:active;not null"` Type string `gorm:"column:identifier_type;not null"` Value string `gorm:"column:identifier_value;not null"` Use string `gorm:"column:identifier_use;not null"` Description string `gorm:"column:description;not null"` ValidFrom time.Time `gorm:"column:valid_from;not null"` ValidTo time.Time `gorm:"column:valid_to"` IsPrimaryIdentifier bool `gorm:"column:is_primary_identifier"` OrganisationID string `gorm:"column:organisation_id;not null"` ProgramID string `gorm:"column:program_id;not null"` }
Identifier is the the table used to store a user's identifying documents
func (*Identifier) BeforeCreate ¶
func (i *Identifier) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating authority permission
func (*Identifier) BeforeUpdate ¶
func (i *Identifier) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating Identifier.
func (*Identifier) TableName ¶
func (i *Identifier) TableName() string
TableName references the table that we map data from
type Metric ¶
type Metric struct { Base ID int `gorm:"primaryKey;column:id;autoincrement"` Active bool `gorm:"column:active"` Type enums.MetricType `gorm:"column:metric_type"` Payload string `gorm:"column:payload"` Timestamp time.Time `gorm:"column:timestamp"` UserID *string `gorm:"column:user_id"` }
Metric is a recording of an event that occurs within the platform
func (*Metric) BeforeCreate ¶
BeforeCreate is a hook called before updating Metric.
func (*Metric) BeforeUpdate ¶
BeforeUpdate is a hook called before updating Metric.
type Notification ¶
type Notification struct { Base ID string `gorm:"primaryKey;column:id;"` Active bool `gorm:"column:active;not null"` Title string `gorm:"column:title"` Body string `gorm:"column:body"` Type string `gorm:"column:notification_type"` Flavour feedlib.Flavour `gorm:"column:flavour"` IsRead bool `gorm:"column:is_read"` ProgramID string `gorm:"column:program_id"` UserID *string `gorm:"column:user_id"` FacilityID *string `gorm:"column:facility_id"` OrganisationID string `gorm:"column:organisation_id;not null"` }
Notification represents a single notification
func (*Notification) BeforeCreate ¶
func (n *Notification) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating an appointment
func (*Notification) BeforeUpdate ¶
func (n *Notification) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating Notification.
func (Notification) TableName ¶
func (Notification) TableName() string
TableName references the table that we map data from
type OauthClient ¶
type OauthClient struct { Base ID string `gorm:"primarykey"` Name string `gorm:"column:name"` Active bool `gorm:"column:active"` Secret string `gorm:"column:secret"` RotatedSecrets pq.StringArray `gorm:"type:varchar(256)[];column:rotated_secrets"` Public bool `gorm:"column:public"` RedirectURIs pq.StringArray `gorm:"type:varchar(256)[];column:redirect_uris"` Scopes pq.StringArray `gorm:"type:varchar(256)[];column:scopes"` Audience pq.StringArray `gorm:"type:varchar(256)[];column:audience"` Grants pq.StringArray `gorm:"type:varchar(256)[];column:grants"` ResponseTypes pq.StringArray `gorm:"type:varchar(256)[];column:response_types"` TokenEndpointAuthMethod string `gorm:"column:token_endpoint_auth_method"` }
func (*OauthClient) BeforeCreate ¶
func (a *OauthClient) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating
func (OauthClient) TableName ¶
func (OauthClient) TableName() string
TableName references the table name in the database
type OauthClientJWT ¶
type OauthClientJWT struct { Base ID string `gorm:"primarykey"` Active bool `gorm:"column:active"` JTI string `gorm:"column:jti"` ExpiresAt time.Time `gorm:"column:expires_at"` }
func (*OauthClientJWT) BeforeCreate ¶
func (a *OauthClientJWT) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating
func (OauthClientJWT) TableName ¶
func (OauthClientJWT) TableName() string
TableName references the table name in the database
type Organisation ¶
type Organisation struct { Base ID *string `gorm:"primaryKey;unique;column:id"` Active bool `gorm:"column:active;not null"` Code string `gorm:"column:org_code;not null;unique"` Name string `gorm:"column:name;not null;unique"` Description string `gorm:"column:description"` EmailAddress string `gorm:"column:email_address;not null"` PhoneNumber string `gorm:"column:phone_number;not null"` PostalAddress string `gorm:"column:postal_address;not null"` PhysicalAddress string `gorm:"column:physical_address;not null"` DefaultCountry string `gorm:"column:default_country;not null"` }
Organisation maps the organization table. This will be useful when running integration tests since many models have an organization ID as a foreign key.
func (*Organisation) BeforeCreate ¶
func (o *Organisation) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating a new organisation
func (*Organisation) BeforeUpdate ¶
func (o *Organisation) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating Organisation.
func (Organisation) TableName ¶
func (Organisation) TableName() string
TableName customizes how the table name is generated
type OrganisationUser ¶
type OrganisationUser struct { ID int `gorm:"column:id;primary_key;autoincrement"` OrganisationID string `gorm:"column:organisation_id"` UserID string `gorm:"column:user_id"` }
OrganisationUser models the relationship between a user and an organisation
func (OrganisationUser) TableName ¶
func (OrganisationUser) TableName() string
TableName customizes how the table name is generated
type PGInstance ¶
PGInstance box for postgres client. We use this instead of a global variable
func NewPGInstance ¶
func NewPGInstance() (*PGInstance, error)
NewPGInstance creates a new instance of postgres client
func (*PGInstance) AcceptTerms ¶
AcceptTerms performs the actual modification of the users data for the terms accepted as well as the id of the terms accepted
func (*PGInstance) AddCaregiverToClient ¶
func (db *PGInstance) AddCaregiverToClient(ctx context.Context, clientCaregiver *CaregiverClient) error
AddCaregiverToClient adds a caregiver to a client
func (*PGInstance) AddFacilitiesToClientProfile ¶
func (db *PGInstance) AddFacilitiesToClientProfile(ctx context.Context, clientID string, facilities []string) error
AddFacilitiesToClientProfile enables addition of facilities to a client profile
func (*PGInstance) AddFacilitiesToStaffProfile ¶
func (db *PGInstance) AddFacilitiesToStaffProfile(ctx context.Context, staffID string, facilities []string) error
AddFacilitiesToStaffProfile enables facilities to be added to the staff profile
func (*PGInstance) AddFacilityToProgram ¶
func (db *PGInstance) AddFacilityToProgram(ctx context.Context, programID string, facilityIDs []string) error
AddFacilityToProgram is used to add a facility to a program
func (*PGInstance) CanRecordHeathDiary ¶
CanRecordHeathDiary checks whether a user can record a health diary if the last record is less than 24 hours ago, the user cannot record a new entry if the last record is more than 24 hours ago, the user can record a new entry
func (*PGInstance) CheckAppointmentExistsByExternalID ¶
func (db *PGInstance) CheckAppointmentExistsByExternalID(ctx context.Context, externalID string) (bool, error)
CheckAppointmentExistsByExternalID checks if an appointment with the external id exists
func (PGInstance) CheckCaregiverExists ¶
CheckCaregiverExists checks if there is a caregiver profile that exists for a user
func (PGInstance) CheckClientExists ¶
CheckClientExists checks if there is a client profile that exists for a user
func (*PGInstance) CheckFacilityExistsByIdentifier ¶
func (db *PGInstance) CheckFacilityExistsByIdentifier(ctx context.Context, identifier *FacilityIdentifier) (bool, error)
CheckFacilityExistsByIdentifier checks whether a facility exists using the mfl code. Used to validate existence of a facility
func (*PGInstance) CheckIdentifierExists ¶
func (db *PGInstance) CheckIdentifierExists(ctx context.Context, identifierType string, identifierValue string) (bool, error)
CheckIdentifierExists checks whether an identifier of a certain type and value exists Used to validate uniqueness and prevent duplicates
func (*PGInstance) CheckIfClientExistsInProgram ¶
func (db *PGInstance) CheckIfClientExistsInProgram(ctx context.Context, userID, programID string) (bool, error)
CheckIfClientExistsInProgram checks if a client has been registered to a program
func (*PGInstance) CheckIfClientHasPendingSurveyServiceRequest ¶
func (db *PGInstance) CheckIfClientHasPendingSurveyServiceRequest(ctx context.Context, clientID string, projectID int, formID string) (bool, error)
CheckIfClientHasPendingSurveyServiceRequest returns true if client has a pending survey service request
func (*PGInstance) CheckIfClientHasUnresolvedServiceRequests ¶
func (db *PGInstance) CheckIfClientHasUnresolvedServiceRequests(ctx context.Context, clientID string, serviceRequestType string) (bool, error)
CheckIfClientHasUnresolvedServiceRequests checks whether a client has a pending or in progress service request of the type passed in
func (*PGInstance) CheckIfFacilityExistsInProgram ¶
func (db *PGInstance) CheckIfFacilityExistsInProgram(ctx context.Context, programID, facilityID string) (bool, error)
CheckIfFacilityExistsInProgram checks if a facility belongs to a program
func (*PGInstance) CheckIfPhoneNumberExists ¶
func (db *PGInstance) CheckIfPhoneNumberExists(ctx context.Context, phone string, isOptedIn bool, flavour feedlib.Flavour) (bool, error)
CheckIfPhoneNumberExists checks if phone exists in the database.
func (*PGInstance) CheckIfProgramNameExists ¶
func (db *PGInstance) CheckIfProgramNameExists(ctx context.Context, organisationID string, programName string) (bool, error)
CheckIfProgramNameExists checks if a program exists in the organization the program name should be unique for each program in a given organization
func (*PGInstance) CheckIfStaffHasUnresolvedServiceRequests ¶
func (db *PGInstance) CheckIfStaffHasUnresolvedServiceRequests(ctx context.Context, staffID string, serviceRequestType string) (bool, error)
CheckIfStaffHasUnresolvedServiceRequests returns true if the staff has unresolved service requests
func (*PGInstance) CheckIfSuperUserExists ¶
func (db *PGInstance) CheckIfSuperUserExists(ctx context.Context) (bool, error)
CheckIfSuperUserExists checks if there is a platform super user
func (*PGInstance) CheckIfUsernameExists ¶
CheckIfUsernameExists checks to see whether the provided username exists
func (*PGInstance) CheckOrganisationExists ¶
func (db *PGInstance) CheckOrganisationExists(ctx context.Context, organisationID string) (bool, error)
CheckOrganisationExists checks if the organisation exists
func (*PGInstance) CheckPhoneExists ¶
CheckPhoneExists is used to check if the phone number exists
func (PGInstance) CheckStaffExists ¶
CheckStaffExists checks if there is a staff profile that exists for a user
func (*PGInstance) CheckStaffExistsInProgram ¶
func (db *PGInstance) CheckStaffExistsInProgram(ctx context.Context, userID, programID string) (bool, error)
CheckStaffExistsInProgram checks if a staff has been registered to a program
func (*PGInstance) CheckUserHasPin ¶
CheckUserHasPin performs a look-up on the pins' table to check whether a user has a pin
func (*PGInstance) CompleteOnboardingTour ¶
func (db *PGInstance) CompleteOnboardingTour(ctx context.Context, userID string, flavour feedlib.Flavour) (bool, error)
CompleteOnboardingTour updates the user's pin change required from true to false It also updates the phone_verified, set_pin and set_security_questions to true It'll be used to determine the onboarding journey for a user i.e where to redirect a user after they log in
func (*PGInstance) CreateAccessToken ¶
func (db *PGInstance) CreateAccessToken(ctx context.Context, token *AccessToken) error
CreateAccessToken creates a new access token.
func (*PGInstance) CreateAppointment ¶
func (db *PGInstance) CreateAppointment(ctx context.Context, appointment *Appointment) error
CreateAppointment creates an appointment in the database
func (*PGInstance) CreateAuthorizationCode ¶
func (db *PGInstance) CreateAuthorizationCode(ctx context.Context, code *AuthorizationCode) error
CreateAuthorizationCode creates a new authorization code.
func (*PGInstance) CreateBooking ¶
CreateBooking is used to store a record of any booking made by a user
func (*PGInstance) CreateCaregiver ¶
func (db *PGInstance) CreateCaregiver(ctx context.Context, caregiver *Caregiver) error
CreateCaregiver creates a caregiver record linked to a user
func (*PGInstance) CreateClient ¶
func (db *PGInstance) CreateClient(ctx context.Context, client *Client, contactID, identifierID string) error
CreateClient creates a new client
func (*PGInstance) CreateCommunity ¶
func (db *PGInstance) CreateCommunity(ctx context.Context, community *Community) (*Community, error)
CreateCommunity creates matrix's custom data in the database
func (*PGInstance) CreateFacilities ¶
func (db *PGInstance) CreateFacilities(ctx context.Context, facilities []*Facility) ([]*Facility, error)
CreateFacilities inserts multiple facility records in the database together with the identifiers
func (*PGInstance) CreateHealthDiaryEntry ¶
func (db *PGInstance) CreateHealthDiaryEntry(ctx context.Context, healthDiary *ClientHealthDiaryEntry) (*ClientHealthDiaryEntry, error)
CreateHealthDiaryEntry records the health diary entries from a client. This is necessary for engagement with clients on a day-by-day basis
func (*PGInstance) CreateIdentifier ¶
func (db *PGInstance) CreateIdentifier(ctx context.Context, identifier *Identifier) error
CreateIdentifier creates a new identifier
func (*PGInstance) CreateMetric ¶
func (db *PGInstance) CreateMetric(ctx context.Context, metric *Metric) error
CreateMetric saves a metric to the database
func (*PGInstance) CreateNotification ¶
func (db *PGInstance) CreateNotification(ctx context.Context, notification *Notification) error
CreateNotification saves a notification to the database
func (*PGInstance) CreateOauthClient ¶
func (db *PGInstance) CreateOauthClient(ctx context.Context, client *OauthClient) error
CreateOauthClient creates a new oauth client
func (*PGInstance) CreateOauthClientJWT ¶
func (db *PGInstance) CreateOauthClientJWT(ctx context.Context, jwt *OauthClientJWT) error
CreateOauthClientJWT creates a new oauth jwt client
func (*PGInstance) CreateOrUpdateSession ¶
func (db *PGInstance) CreateOrUpdateSession(ctx context.Context, session *Session) error
CreateOrUpdateSession creates a new session or updates an existing session
func (*PGInstance) CreateOrganisation ¶
func (db *PGInstance) CreateOrganisation(ctx context.Context, organization *Organisation) (*Organisation, error)
CreateOrganisation is used to create an organization into the database
func (*PGInstance) CreateProgram ¶
CreateProgram adds a new program record
func (*PGInstance) CreateQuestion ¶
func (db *PGInstance) CreateQuestion(ctx context.Context, input *Question) error
CreateQuestion saves a question to the database
func (*PGInstance) CreateQuestionChoice ¶
func (db *PGInstance) CreateQuestionChoice(ctx context.Context, input *QuestionInputChoice) error
CreateQuestionChoice saves a question choice to the database
func (*PGInstance) CreateQuestionnaire ¶
func (db *PGInstance) CreateQuestionnaire(ctx context.Context, input *Questionnaire) error
CreateQuestionnaire saves a questionnaire to the database
func (*PGInstance) CreateRefreshToken ¶
func (db *PGInstance) CreateRefreshToken(ctx context.Context, token *RefreshToken) error
CreateRefreshToken creates a new refresh token.
func (*PGInstance) CreateScreeningTool ¶
func (db *PGInstance) CreateScreeningTool(ctx context.Context, input *ScreeningTool) error
CreateScreeningTool saves a screening tool to the database
func (*PGInstance) CreateScreeningToolResponse ¶
func (db *PGInstance) CreateScreeningToolResponse(ctx context.Context, screeningToolResponse *ScreeningToolResponse, screeningToolQuestionResponses []*ScreeningToolQuestionResponse) (*string, error)
CreateScreeningToolResponse saves a screening tool response to the database and returns the response ID
func (*PGInstance) CreateSecurityQuestions ¶
func (db *PGInstance) CreateSecurityQuestions(ctx context.Context, securityQuestions []*SecurityQuestion) ([]*SecurityQuestion, error)
CreateSecurityQuestions inserts multiple screening tool records in the database
func (*PGInstance) CreateServiceRequest ¶
func (db *PGInstance) CreateServiceRequest( ctx context.Context, serviceRequestInput *ClientServiceRequest, ) error
CreateServiceRequest creates a service request entry into the database. This step is reached only IF the client is in a VERY_BAD mood. We get this mood from the mood scale provided by the front end. This operation is done within a transaction to prevent a situation where a health entry can be recorded but a service request is not successfully created.
func (*PGInstance) CreateStaffServiceRequest ¶
func (db *PGInstance) CreateStaffServiceRequest(ctx context.Context, serviceRequestInput *StaffServiceRequest) error
CreateStaffServiceRequest creates a new staff service request
func (*PGInstance) CreateTermsOfService ¶
func (db *PGInstance) CreateTermsOfService(ctx context.Context, termsOfService *TermsOfService) (*TermsOfService, error)
CreateTermsOfService terms of service record in the database
func (*PGInstance) CreateUser ¶
func (db *PGInstance) CreateUser(ctx context.Context, user *User) error
CreateUser creates a new user
func (*PGInstance) CreateUserSurveys ¶
func (db *PGInstance) CreateUserSurveys(ctx context.Context, userSurveys []*UserSurvey) error
CreateUserSurveys saves a user survey details including the survey link
func (*PGInstance) DeleteAccessToken ¶
func (db *PGInstance) DeleteAccessToken(ctx context.Context, signature string) error
DeleteAccessToken retrieves an access token using the signature
func (*PGInstance) DeleteClientProfile ¶
func (db *PGInstance) DeleteClientProfile(ctx context.Context, clientID string, userID *string) error
DeleteClientProfile will permanently delete a client and their information from the database
func (*PGInstance) DeleteCommunity ¶
func (db *PGInstance) DeleteCommunity(ctx context.Context, communityID string) error
DeleteCommunity deletes the specified community from the database
func (*PGInstance) DeleteFacility ¶
func (db *PGInstance) DeleteFacility(ctx context.Context, identifier *FacilityIdentifier) (bool, error)
DeleteFacility will do the actual deletion of a facility from the database This operation perform HARD deletion
func (*PGInstance) DeleteOrganisation ¶
func (db *PGInstance) DeleteOrganisation(ctx context.Context, organisation *Organisation) error
DeleteOrganisation deletes the specified organisation from the database
func (*PGInstance) DeleteRefreshToken ¶
func (db *PGInstance) DeleteRefreshToken(ctx context.Context, signature string) error
DeleteRefreshToken retrieves a refresh token using the signature
func (*PGInstance) DeleteStaffProfile ¶
func (db *PGInstance) DeleteStaffProfile(ctx context.Context, staffID string) error
DeleteStaffProfile will do the actual deletion of a staff profile from the database
func (*PGInstance) FindContacts ¶
func (db *PGInstance) FindContacts(ctx context.Context, contactType, contactValue string) ([]*Contact, error)
FindContacts retrieves all the contacts that match the given contact type and value. Contacts can be shared by users thus the same contact can have multiple records stored
func (*PGInstance) GetAccessToken ¶
func (db *PGInstance) GetAccessToken(ctx context.Context, token AccessToken) (*AccessToken, error)
GetAccessToken retrieves an access token using the signature
func (*PGInstance) GetAllScreeningTools ¶
func (db *PGInstance) GetAllScreeningTools(ctx context.Context, pagination *domain.Pagination) ([]*ScreeningTool, *domain.Pagination, error)
GetAllScreeningTools returns all the available screening tools with pagination
func (*PGInstance) GetAppointment ¶
func (db *PGInstance) GetAppointment(ctx context.Context, params *Appointment) (*Appointment, error)
GetAppointment returns an appointment by provided params
func (*PGInstance) GetAppointmentServiceRequests ¶
func (db *PGInstance) GetAppointmentServiceRequests(ctx context.Context, lastSyncTime time.Time, facilityID string) ([]*ClientServiceRequest, error)
GetAppointmentServiceRequests returns all appointments service requests that have been updated since the last sync time
func (*PGInstance) GetAuthorizationCode ¶
func (db *PGInstance) GetAuthorizationCode(ctx context.Context, code string) (*AuthorizationCode, error)
GetAuthorizationCode retrieves an authorization code using the code
func (*PGInstance) GetAvailableScreeningTools ¶
func (db *PGInstance) GetAvailableScreeningTools(ctx context.Context, clientID string, screeningTool ScreeningTool, screeningToolIDs []string) ([]*ScreeningTool, error)
GetAvailableScreeningTools returns all the available screening tools following the set criteria
func (*PGInstance) GetCaregiverByUserID ¶
GetCaregiverByUserID returns the caregiver record of the provided user ID
func (*PGInstance) GetCaregiverManagedClients ¶
func (db *PGInstance) GetCaregiverManagedClients(ctx context.Context, userID string, pagination *domain.Pagination) ([]*CaregiverClient, *domain.Pagination, error)
GetCaregiverManagedClients lists clients who are managed by the caregivers The clients should have given their consent to be managed by the caregivers
func (*PGInstance) GetCaregiverProfileByCaregiverID ¶
func (db *PGInstance) GetCaregiverProfileByCaregiverID(ctx context.Context, caregiverID string) (*Caregiver, error)
GetCaregiverProfileByCaregiverID retrieves the caregivers profile based on the caregiver ID provided
func (*PGInstance) GetCaregiverProfileByUserID ¶
func (db *PGInstance) GetCaregiverProfileByUserID(ctx context.Context, userID string, organisationID string) (*Caregiver, error)
GetCaregiverProfileByUserID gets the caregiver profile by user ID.
func (*PGInstance) GetCaregiversClient ¶
func (db *PGInstance) GetCaregiversClient(ctx context.Context, caregiverClient CaregiverClient) ([]*CaregiverClient, error)
GetCaregiversClient queries the association table for an occurrence of a caregiver's client
func (*PGInstance) GetClientFacilities ¶
func (db *PGInstance) GetClientFacilities(ctx context.Context, clientFacility ClientFacilities, pagination *domain.Pagination) ([]*ClientFacilities, *domain.Pagination, error)
GetClientFacilities gets facilities belonging to a given client
func (*PGInstance) GetClientHealthDiaryEntries ¶
func (db *PGInstance) GetClientHealthDiaryEntries(ctx context.Context, params map[string]interface{}) ([]*ClientHealthDiaryEntry, error)
GetClientHealthDiaryEntries gets all health diary entries that belong to a specific client
func (*PGInstance) GetClientHealthDiaryQuote ¶
func (db *PGInstance) GetClientHealthDiaryQuote(ctx context.Context, limit int) ([]*ClientHealthDiaryQuote, error)
GetClientHealthDiaryQuote fetches a client's health diary quote. it should be a random quote from the health diary
func (*PGInstance) GetClientIdentifiers ¶
func (db *PGInstance) GetClientIdentifiers(ctx context.Context, clientID string) ([]*Identifier, error)
GetClientIdentifiers retrieves a client's ccc identifier
func (*PGInstance) GetClientJWT ¶
func (db *PGInstance) GetClientJWT(ctx context.Context, jti string) (*OauthClientJWT, error)
GetClientJWT retrieves a JWT by unique JTI
func (*PGInstance) GetClientProfile ¶
func (db *PGInstance) GetClientProfile(ctx context.Context, userID string, programID string) (*Client, error)
GetClientProfile returns the client profile based on the user ID provided
func (*PGInstance) GetClientProfileByClientID ¶
func (db *PGInstance) GetClientProfileByClientID(ctx context.Context, clientID string) (*Client, error)
GetClientProfileByClientID fetches a client from the database
func (*PGInstance) GetClientProfilesByIdentifier ¶
func (db *PGInstance) GetClientProfilesByIdentifier(ctx context.Context, identifierType, value string) ([]*Client, error)
GetProgramClientProfileByIdentifier returns a client profile using the CCC number
func (*PGInstance) GetClientScreeningToolServiceRequestByToolType ¶
func (db *PGInstance) GetClientScreeningToolServiceRequestByToolType(ctx context.Context, clientID, toolType, status string) (*ClientServiceRequest, error)
GetClientScreeningToolServiceRequestByToolType returns a screening tool of type service request by based on tool type
func (*PGInstance) GetClientServiceRequestByID ¶
func (db *PGInstance) GetClientServiceRequestByID(ctx context.Context, serviceRequestID string) (*ClientServiceRequest, error)
GetClientServiceRequestByID returns a service request by ID
func (*PGInstance) GetClientServiceRequests ¶
func (db *PGInstance) GetClientServiceRequests(ctx context.Context, requestType, status, clientID, facilityID string) ([]*ClientServiceRequest, error)
GetClientServiceRequests returns all system generated service requests by status passed in param
func (*PGInstance) GetClientUserPrograms ¶
GetClientUserPrograms retrieves all programs associated with a client user a user can have multiple client profiles for multiple programs
func (*PGInstance) GetClientsByFilterParams ¶
func (db *PGInstance) GetClientsByFilterParams(ctx context.Context, facilityID string, params *dto.ClientFilterParamsInput) ([]*Client, error)
GetClientsByFilterParams returns clients based on the filter params The query is constructed dynamically based on the filterparams passed; empty filters are allowed facility ID is required hence it will be the first query passed, then the rest are optional For filter params, each check will compound to the final query that is being performed on the DB
func (*PGInstance) GetClientsByParams ¶
func (db *PGInstance) GetClientsByParams(ctx context.Context, params Client, lastSyncTime *time.Time) ([]*Client, error)
GetClientsByParams retrieves clients using the parameters provided
func (*PGInstance) GetClientsInAFacility ¶
func (db *PGInstance) GetClientsInAFacility(ctx context.Context, facilityID string) ([]*Client, error)
GetClientsInAFacility returns all the clients registered within a specified facility
func (*PGInstance) GetClientsPendingServiceRequestsCount ¶
func (db *PGInstance) GetClientsPendingServiceRequestsCount(ctx context.Context, facilityID string, programID *string) (*domain.ServiceRequestsCount, error)
GetClientsPendingServiceRequestsCount gets the number of clients service requests
func (*PGInstance) GetClientsSurveyCount ¶
GetClientsSurveyCount retrieves the total number of clients survey
func (*PGInstance) GetClientsSurveyServiceRequest ¶
func (db *PGInstance) GetClientsSurveyServiceRequest(ctx context.Context, facilityID string, projectID int, formID string, pagination *domain.Pagination) ([]*ClientServiceRequest, *domain.Pagination, error)
GetClientsSurveyServiceRequest retrieves a list of clients with a surveys service request
func (*PGInstance) GetCommunityByID ¶
GetCommunityByID fetches the community using its ID
func (*PGInstance) GetContactByUserID ¶
func (db *PGInstance) GetContactByUserID(ctx context.Context, userID *string, contactType string) (*Contact, error)
GetContactByUserID fetches a user's contact using the user ID
func (*PGInstance) GetCurrentTerms ¶
func (db *PGInstance) GetCurrentTerms(ctx context.Context) (*TermsOfService, error)
GetCurrentTerms fetches the most recent terms of service depending on the flavour
func (*PGInstance) GetFacilitiesWithoutFHIRID ¶
func (db *PGInstance) GetFacilitiesWithoutFHIRID(ctx context.Context) ([]*Facility, error)
GetFacilitiesWithoutFHIRID fetches all the healthcare facilities in the platform without FHIR Organisation ID
func (*PGInstance) GetFacilityRespondedScreeningTools ¶
func (db *PGInstance) GetFacilityRespondedScreeningTools(ctx context.Context, facilityID, programID string, pagination *domain.Pagination) ([]*ScreeningTool, *domain.Pagination, error)
GetFacilityRespondedScreeningTools is used to get facility's responded screening tools questions These are screening tools that have red flag service requests and have been resolved
func (PGInstance) GetFacilityStaffs ¶
func (db PGInstance) GetFacilityStaffs(ctx context.Context, facilityID string) ([]*StaffProfile, error)
GetFacilityStaffs returns a list of staff at a particular facility
func (*PGInstance) GetHealthDiaryEntryByID ¶
func (db *PGInstance) GetHealthDiaryEntryByID(ctx context.Context, healthDiaryEntryID string) (*ClientHealthDiaryEntry, error)
GetHealthDiaryEntryByID gets the health diary entry with the given ID
func (*PGInstance) GetNotification ¶
func (db *PGInstance) GetNotification(ctx context.Context, notificationID string) (*Notification, error)
GetNotification retrieve a notification using the provided ID
func (*PGInstance) GetNotificationsCount ¶
func (db *PGInstance) GetNotificationsCount(ctx context.Context, notification Notification) (int, error)
GetNotificationsCount fetches the total number of user's notifications in a given facility
func (*PGInstance) GetOTP ¶
func (db *PGInstance) GetOTP(ctx context.Context, phoneNumber string, flavour feedlib.Flavour) (*UserOTP, error)
GetOTP fetches an OTP from the database
func (*PGInstance) GetOauthClient ¶
func (db *PGInstance) GetOauthClient(ctx context.Context, id string) (*OauthClient, error)
GetOauthClient retrieves a client by ID
func (*PGInstance) GetOrCreateContact ¶
GetOrCreateContact creates a person's contact in the database if they do not exist or gets them if they already exist
func (*PGInstance) GetOrCreateNextOfKin ¶
func (db *PGInstance) GetOrCreateNextOfKin(ctx context.Context, person *RelatedPerson, clientID, contactID string) error
GetOrCreateNextOfKin get or creates a related person in the database The client ID and contact ID are used to link the created person with a client and the associated contact for the person
func (*PGInstance) GetOrganisation ¶
func (db *PGInstance) GetOrganisation(ctx context.Context, id string) (*Organisation, error)
GetOrganisation retrieves an organisation using the provided id
func (*PGInstance) GetProgramByID ¶
GetProgramByID retrieves a program by id
func (*PGInstance) GetProgramClientProfileByIdentifier ¶
func (db *PGInstance) GetProgramClientProfileByIdentifier(ctx context.Context, programID, identifierType, value string) (*Client, error)
GetProgramClientProfileByIdentifier returns a client profile using the CCC number
func (*PGInstance) GetProgramFacilities ¶
func (db *PGInstance) GetProgramFacilities(ctx context.Context, programID string) ([]*ProgramFacility, error)
GetProgramFacilities gets the facilities that belong the program
func (*PGInstance) GetQuestionInputChoicesByQuestionID ¶
func (db *PGInstance) GetQuestionInputChoicesByQuestionID(ctx context.Context, questionID string) ([]*QuestionInputChoice, error)
GetQuestionInputChoicesByQuestionID is used to get question input choices by question ID
func (*PGInstance) GetQuestionnaireByID ¶
func (db *PGInstance) GetQuestionnaireByID(ctx context.Context, id string) (*Questionnaire, error)
GetQuestionnaireByID is used to get a questionnaire by its ID
func (*PGInstance) GetQuestionsByQuestionnaireID ¶
func (db *PGInstance) GetQuestionsByQuestionnaireID(ctx context.Context, questionnaireID string) ([]*Question, error)
GetQuestionsByQuestionnaireID is used to get questions by questionnaire ID
func (*PGInstance) GetRecentHealthDiaryEntries ¶
func (db *PGInstance) GetRecentHealthDiaryEntries(ctx context.Context, lastSyncTime time.Time, clientID string) ([]*ClientHealthDiaryEntry, error)
GetRecentHealthDiaryEntries fetches the health diary entries that were added after the last time the entries were synced to KenyaEMR
func (*PGInstance) GetRefreshToken ¶
func (db *PGInstance) GetRefreshToken(ctx context.Context, token RefreshToken) (*RefreshToken, error)
GetRefreshToken retrieves a refresh token using the signature
func (*PGInstance) GetScreeningToolByID ¶
func (db *PGInstance) GetScreeningToolByID(ctx context.Context, id string) (*ScreeningTool, error)
GetScreeningToolByID is used to get a screening tool by its ID
func (*PGInstance) GetScreeningToolQuestionResponsesByResponseID ¶
func (db *PGInstance) GetScreeningToolQuestionResponsesByResponseID(ctx context.Context, responseID string) ([]*ScreeningToolQuestionResponse, error)
GetScreeningToolQuestionResponsesByResponseID is used to get screening tool question responses by screening tool response ID
func (*PGInstance) GetScreeningToolResponseByID ¶
func (db *PGInstance) GetScreeningToolResponseByID(ctx context.Context, id string) (*ScreeningToolResponse, error)
GetScreeningToolResponseByID is used to get a screening tool response by its ID
func (*PGInstance) GetScreeningToolResponsesWithPendingServiceRequests ¶
func (db *PGInstance) GetScreeningToolResponsesWithPendingServiceRequests(ctx context.Context, clientID, programID string) ([]*ScreeningToolResponse, error)
GetScreeningToolResponsesWithPendingServiceRequests gets the user screening response that have pending service requests
func (*PGInstance) GetScreeningToolResponsesWithin24Hours ¶
func (db *PGInstance) GetScreeningToolResponsesWithin24Hours(ctx context.Context, clientID, programID string) ([]*ScreeningToolResponse, error)
GetScreeningToolResponsesWithin24Hours gets the user screening response that are within 24 hours
func (*PGInstance) GetScreeningToolServiceRequestOfRespondents ¶
func (db *PGInstance) GetScreeningToolServiceRequestOfRespondents(ctx context.Context, facilityID, programID string, screeningToolID string, searchTerm string, pagination *domain.Pagination) ([]*ClientServiceRequest, *domain.Pagination, error)
GetScreeningToolServiceRequestOfRespondents is used to get screening tool service request by respondents the clients who have a pending screening tool service request for the given facility are returned
func (*PGInstance) GetSecurityQuestionByID ¶
func (db *PGInstance) GetSecurityQuestionByID(ctx context.Context, securityQuestionID *string) (*SecurityQuestion, error)
GetSecurityQuestionByID fetches a security question using the security question ID
func (*PGInstance) GetSecurityQuestionResponse ¶
func (db *PGInstance) GetSecurityQuestionResponse(ctx context.Context, questionID string, userID string) (*SecurityQuestionResponse, error)
GetSecurityQuestionResponse returns the security question response
func (*PGInstance) GetSecurityQuestions ¶
func (db *PGInstance) GetSecurityQuestions(ctx context.Context, flavour feedlib.Flavour) ([]*SecurityQuestion, error)
GetSecurityQuestions fetches all the security questions.
func (*PGInstance) GetServiceRequests ¶
func (db *PGInstance) GetServiceRequests(ctx context.Context, requestType, requestStatus *string, facilityID string, programID string, pagination *domain.Pagination) ([]*ClientServiceRequest, *domain.Pagination, error)
GetServiceRequests fetches clients service requests from the database according to the type and or status passed
func (*PGInstance) GetServiceRequestsForKenyaEMR ¶
func (db *PGInstance) GetServiceRequestsForKenyaEMR(ctx context.Context, facilityID string, lastSyncTime time.Time) ([]*ClientServiceRequest, error)
GetServiceRequestsForKenyaEMR gets all the service requests to be used by the KenyaEMR.
func (*PGInstance) GetSharedHealthDiaryEntries ¶
func (db *PGInstance) GetSharedHealthDiaryEntries(ctx context.Context, clientID string, facilityID string) ([]*ClientHealthDiaryEntry, error)
GetSharedHealthDiaryEntries gets the recently shared health diary entry shared by the client to a health care worker and returns the entry. The health care worker will only see the entry as long as they share the same facility with the health care worker
func (*PGInstance) GetStaffFacilities ¶
func (db *PGInstance) GetStaffFacilities(ctx context.Context, staffFacility StaffFacilities, pagination *domain.Pagination) ([]*StaffFacilities, *domain.Pagination, error)
GetStaffFacilities gets facilities belonging to a given staff
func (*PGInstance) GetStaffIdentifiers ¶
func (db *PGInstance) GetStaffIdentifiers(ctx context.Context, staffID string, identifierType *string) ([]*Identifier, error)
GetStaffIdentifiers retrieves a staff's identifier
func (*PGInstance) GetStaffPendingServiceRequestsCount ¶
func (db *PGInstance) GetStaffPendingServiceRequestsCount(ctx context.Context, facilityID string, programID string) (*domain.ServiceRequestsCount, error)
GetStaffPendingServiceRequestsCount gets the number of staffs pending pin reset service requests
func (*PGInstance) GetStaffProfile ¶
func (db *PGInstance) GetStaffProfile(ctx context.Context, userID string, programID string) (*StaffProfile, error)
GetStaffProfile returns the staff profile
func (*PGInstance) GetStaffProfileByStaffID ¶
func (db *PGInstance) GetStaffProfileByStaffID(ctx context.Context, staffID string) (*StaffProfile, error)
GetStaffProfileByStaffID fetches a staff from the database
func (*PGInstance) GetStaffServiceRequestByID ¶
func (db *PGInstance) GetStaffServiceRequestByID(ctx context.Context, serviceRequestID string) (*StaffServiceRequest, error)
GetStaffServiceRequestByID returns a staff service request by ID
func (*PGInstance) GetStaffServiceRequests ¶
func (db *PGInstance) GetStaffServiceRequests(ctx context.Context, requestType, requestStatus *string, facilityID string, pagination *domain.Pagination) ([]*StaffServiceRequest, *domain.Pagination, error)
GetStaffServiceRequests gets all the staff's service requests depending on the provided parameters
func (*PGInstance) GetStaffUserPrograms ¶
GetStaffUserPrograms retrieves all programs associated with a staff user a user can have multiple staff profiles for multiple programs
func (*PGInstance) GetSurveysWithServiceRequests ¶
func (db *PGInstance) GetSurveysWithServiceRequests(ctx context.Context, facilityID, programID string) ([]*UserSurvey, error)
GetSurveysWithServiceRequests is used to retrieve surveys with service requests for a particular facility
func (*PGInstance) GetUserClientProfiles ¶
GetUserClientProfiles gets all user client profiles
func (*PGInstance) GetUserPINByUserID ¶
GetUserPINByUserID fetches a user's pin using the user ID and Flavour
func (*PGInstance) GetUserProfileByPhoneNumber ¶
func (db *PGInstance) GetUserProfileByPhoneNumber(ctx context.Context, phoneNumber string) (*User, error)
GetUserProfileByPhoneNumber retrieves a user profile using their phone number
func (*PGInstance) GetUserProfileByPushToken ¶
func (db *PGInstance) GetUserProfileByPushToken(ctx context.Context, pushToken string) (*User, error)
GetUserProfileByPushToken is used to retrieve user's profile using their device's push token
func (*PGInstance) GetUserProfileByStaffID ¶
GetUserProfileByStaffID returns a user profile using the staff ID
func (*PGInstance) GetUserProfileByUserID ¶
GetUserProfileByUserID fetches a user profile using the user ID
func (*PGInstance) GetUserProfileByUsername ¶
GetUserProfileByUsername retrieves a user using their username
func (*PGInstance) GetUserSecurityQuestionsResponses ¶
func (db *PGInstance) GetUserSecurityQuestionsResponses(ctx context.Context, userID, flavour string) ([]*SecurityQuestionResponse, error)
GetUserSecurityQuestionsResponses fetches the security question responses that the user has responded to
func (*PGInstance) GetUserStaffProfiles ¶
func (db *PGInstance) GetUserStaffProfiles(ctx context.Context, userID string) ([]*StaffProfile, error)
GetUserStaffProfiles gets all user staff profiles
func (*PGInstance) GetUserSurveyForms ¶
func (db *PGInstance) GetUserSurveyForms(ctx context.Context, params map[string]interface{}) ([]*UserSurvey, error)
GetUserSurveyForms retrieves all user survey forms
func (*PGInstance) GetValidClientJWT ¶
func (db *PGInstance) GetValidClientJWT(ctx context.Context, jti string) (*OauthClientJWT, error)
GetValidClientJWT retrieves a JWT that is still valid i.e not expired
func (*PGInstance) InactivateFacility ¶
func (db *PGInstance) InactivateFacility(ctx context.Context, identifier *FacilityIdentifier) (bool, error)
InactivateFacility perfoms the actual inactivation of the facility in the database
func (*PGInstance) InvalidatePIN ¶
InvalidatePIN toggles the valid field of a pin from true to false
func (*PGInstance) ListAppointments ¶
func (db *PGInstance) ListAppointments(ctx context.Context, params *Appointment, filters []*firebasetools.FilterParam, pagination *domain.Pagination) ([]*Appointment, *domain.Pagination, error)
ListAppointments Retrieves appointments using the provided parameters and filters
func (*PGInstance) ListAvailableNotificationTypes ¶
func (db *PGInstance) ListAvailableNotificationTypes(ctx context.Context, params *Notification) ([]enums.NotificationType, error)
ListAvailableNotificationTypes retrieves the distinct notification types available for a user
func (*PGInstance) ListBookings ¶
func (db *PGInstance) ListBookings(ctx context.Context, clientID string, bookingState enums.BookingState, pagination *domain.Pagination) ([]*Booking, *domain.Pagination, error)
ListBookings is used to view a list of booking whether past or upcoming
func (*PGInstance) ListClientsCaregivers ¶
func (db *PGInstance) ListClientsCaregivers(ctx context.Context, clientID string, pagination *domain.Pagination) ([]*CaregiverClient, *domain.Pagination, error)
ListClientsCaregivers retrieves a list of clients caregivers
func (*PGInstance) ListCommunities ¶
func (db *PGInstance) ListCommunities(ctx context.Context, programID string, organisationID string) ([]*Community, error)
ListCommunities is used to list Matrix communities(rooms)
func (*PGInstance) ListFacilities ¶
func (db *PGInstance) ListFacilities(ctx context.Context, searchTerm *string, filter []*domain.FiltersParam, pagination *domain.Pagination) ([]*Facility, *domain.Pagination, error)
ListFacilities fetches facilities by pattern matching against the facility name or identifier
func (*PGInstance) ListNotifications ¶
func (db *PGInstance) ListNotifications(ctx context.Context, params *Notification, filters []*firebasetools.FilterParam, pagination *domain.Pagination) ([]*Notification, *domain.Pagination, error)
ListNotifications retrieves notifications using the provided parameters and filters
func (*PGInstance) ListOrganisations ¶
func (db *PGInstance) ListOrganisations(ctx context.Context, pagination *domain.Pagination) ([]*Organisation, *domain.Pagination, error)
ListOrganisations retrieves all organisations
func (*PGInstance) ListProgramFacilities ¶
func (db *PGInstance) ListProgramFacilities(ctx context.Context, programID, searchTerm *string, filter []*domain.FiltersParam, pagination *domain.Pagination) ([]*Facility, *domain.Pagination, error)
ListProgramFacilities lists all facilities, the results returned are from search, and provided filters. they are also paginated
func (*PGInstance) ListPrograms ¶
func (db *PGInstance) ListPrograms(ctx context.Context, organisationID *string, pagination *domain.Pagination) ([]*Program, *domain.Pagination, error)
ListPrograms returns a list of all the programs
func (*PGInstance) ListSurveyRespondents ¶
func (db *PGInstance) ListSurveyRespondents(ctx context.Context, params *UserSurvey, facilityID string, pagination *domain.Pagination) ([]*UserSurvey, *domain.Pagination, error)
ListSurveyRespondents retrieves survey respondents using the provided parameters. It also paginates the results
func (*PGInstance) ReactivateFacility ¶
func (db *PGInstance) ReactivateFacility(ctx context.Context, identifier *FacilityIdentifier) (bool, error)
ReactivateFacility performs the actual re-activation of the facility in the database
func (*PGInstance) RegisterCaregiver ¶
func (db *PGInstance) RegisterCaregiver(ctx context.Context, user *User, contact *Contact, caregiver *Caregiver) error
RegisterCaregiver registers a new caregiver
func (*PGInstance) RegisterClient ¶
func (db *PGInstance) RegisterClient(ctx context.Context, user *User, contact *Contact, identifier *Identifier, client *Client) (*Client, error)
RegisterClient registers a client with the system
func (*PGInstance) RegisterExistingUserAsCaregiver ¶
func (db *PGInstance) RegisterExistingUserAsCaregiver(ctx context.Context, caregiver *Caregiver) (*Caregiver, error)
RegisterExistingUserAsCaregiver registers an existing user as a caregiver
func (*PGInstance) RegisterExistingUserAsClient ¶
func (db *PGInstance) RegisterExistingUserAsClient(ctx context.Context, identifier *Identifier, client *Client) (*Client, error)
RegisterExistingUserAsClient registers an existing user as a client
func (*PGInstance) RegisterExistingUserAsStaff ¶
func (db *PGInstance) RegisterExistingUserAsStaff(ctx context.Context, identifier *Identifier, staff *StaffProfile) (*StaffProfile, error)
RegisterExistingUserAsStaff creates a staff profile for an existing user.
func (*PGInstance) RegisterStaff ¶
func (db *PGInstance) RegisterStaff(ctx context.Context, user *User, contact *Contact, identifier *Identifier, staffProfile *StaffProfile) (*StaffProfile, error)
RegisterStaff registers a staff member to the database
func (*PGInstance) RemoveFacilitiesFromClientProfile ¶
func (db *PGInstance) RemoveFacilitiesFromClientProfile(ctx context.Context, clientID string, facilities []string) error
RemoveFacilitiesFromClientProfile updates the client profile and removes the specified facilities
func (*PGInstance) RemoveFacilitiesFromStaffProfile ¶
func (db *PGInstance) RemoveFacilitiesFromStaffProfile(ctx context.Context, staffID string, facilities []string) error
RemoveFacilitiesFromStaffProfile updates the client profile and removes the specified facilities
func (*PGInstance) ResolveStaffServiceRequest ¶
func (db *PGInstance) ResolveStaffServiceRequest(ctx context.Context, staffID *string, serviceRequestID *string, verificationStatus string) (bool, error)
ResolveStaffServiceRequest resolves the service request for a given staff
func (*PGInstance) RetrieveFacility ¶
func (db *PGInstance) RetrieveFacility(ctx context.Context, id *string, isActive bool) (*Facility, error)
RetrieveFacility fetches a single facility
func (*PGInstance) RetrieveFacilityByIdentifier ¶
func (db *PGInstance) RetrieveFacilityByIdentifier(ctx context.Context, identifier *FacilityIdentifier, isActive bool) (*Facility, error)
RetrieveFacilityByIdentifier fetches a single facility using MFL Code
func (PGInstance) RetrieveFacilityIdentifiersByFacilityID ¶
func (db PGInstance) RetrieveFacilityIdentifiersByFacilityID(ctx context.Context, facilityID *string) ([]*FacilityIdentifier, error)
RetrieveFacilityIdentifiersByFacilityID gets a facility identifier by facility id
func (*PGInstance) SaveFeedback ¶
func (db *PGInstance) SaveFeedback(ctx context.Context, feedback *Feedback) error
SaveFeedback saves the feedback to the database
func (*PGInstance) SaveOTP ¶
func (db *PGInstance) SaveOTP(ctx context.Context, otpInput *UserOTP) error
SaveOTP saves the generated otp to the database
func (*PGInstance) SaveSecurityQuestionResponse ¶
func (db *PGInstance) SaveSecurityQuestionResponse(ctx context.Context, securityQuestionResponse []*SecurityQuestionResponse) error
SaveSecurityQuestionResponse saves the security question response to the database if it does not exist, otherwise it updates the existing one
func (*PGInstance) SaveTemporaryUserPin ¶
SaveTemporaryUserPin is used to save a temporary user pin
func (*PGInstance) SearchCaregiverUser ¶
func (db *PGInstance) SearchCaregiverUser(ctx context.Context, searchParameter string) ([]*Caregiver, error)
SearchCaregiverUser searches and retrieves caregiver user(s) based on pattern matching against the username, phone number or the caregiver number the results are scoped to the program of the healthcare worker
func (*PGInstance) SearchClientProfile ¶
func (db *PGInstance) SearchClientProfile(ctx context.Context, searchParameter string) ([]*Client, error)
SearchClientProfile is used to query for a client profile. It uses pattern matching against the ccc number, phonenumber or username
func (*PGInstance) SearchClientServiceRequests ¶
func (db *PGInstance) SearchClientServiceRequests(ctx context.Context, searchParameter string, requestType string, facilityID string) ([]*ClientServiceRequest, error)
SearchClientServiceRequests is used to query(search) for client service requests depending on the search parameter and the type of service request passed
func (*PGInstance) SearchOrganisation ¶
func (db *PGInstance) SearchOrganisation(ctx context.Context, searchParameter string) ([]*Organisation, error)
SearchOrganisation searches for organisations from the platform
func (*PGInstance) SearchPlatformCaregivers ¶
func (db *PGInstance) SearchPlatformCaregivers(ctx context.Context, searchParameter string) ([]*Caregiver, error)
SearchPlatformCaregivers searches and retrieves caregiver user(s) based on pattern matching against the username, phone number or the caregiver number the results are scoped to the whole platform
func (*PGInstance) SearchPrograms ¶
func (db *PGInstance) SearchPrograms(ctx context.Context, searchParameter string, organisationID string, pagination *domain.Pagination) ([]*Program, *domain.Pagination, error)
SearchPrograms searches for programs by name
func (*PGInstance) SearchStaffProfile ¶
func (db *PGInstance) SearchStaffProfile(ctx context.Context, searchParameter string, programID *string) ([]*StaffProfile, error)
SearchStaffProfile searches retrieves staff profile(s) based on pattern matching against the username, staff number or the phonenumber.
func (*PGInstance) SearchStaffServiceRequests ¶
func (db *PGInstance) SearchStaffServiceRequests(ctx context.Context, searchParameter string, requestType string, facilityID string) ([]*StaffServiceRequest, error)
SearchStaffServiceRequests is used to query(search) for staff's service requests depending on the search parameter and the type of service request
func (*PGInstance) SetInProgressBy ¶
func (db *PGInstance) SetInProgressBy(ctx context.Context, requestID string, staffID string) (bool, error)
SetInProgressBy updates the staff assigned to a service request
func (*PGInstance) UpdateAccessToken ¶
func (db *PGInstance) UpdateAccessToken(ctx context.Context, code *AccessToken, updateData map[string]interface{}) error
UpdateAccessToken updates the details of a given access token
func (*PGInstance) UpdateAppointment ¶
func (db *PGInstance) UpdateAppointment(ctx context.Context, appointment *Appointment, updateData map[string]interface{}) (*Appointment, error)
UpdateAppointment updates the details of an appointment requires the ID or appointment_uuid to be provided
func (*PGInstance) UpdateAuthorizationCode ¶
func (db *PGInstance) UpdateAuthorizationCode(ctx context.Context, code *AuthorizationCode, updateData map[string]interface{}) error
UpdateAuthorizationCode updates the details of a given code
func (*PGInstance) UpdateBooking ¶
func (db *PGInstance) UpdateBooking(ctx context.Context, booking *Booking, updateData map[string]interface{}) error
UpdateBooking is used to update booking data given the model and data to used to update the record
func (*PGInstance) UpdateCaregiver ¶
func (db *PGInstance) UpdateCaregiver(ctx context.Context, caregiver *Caregiver, updates map[string]interface{}) error
UpdateCaregiver updates the caregiver's information
func (*PGInstance) UpdateCaregiverClient ¶
func (db *PGInstance) UpdateCaregiverClient(ctx context.Context, caregiverClient *CaregiverClient, updateData map[string]interface{}) error
UpdateCaregiverClient updates details for a particular caregiver client
func (*PGInstance) UpdateClient ¶
func (db *PGInstance) UpdateClient(ctx context.Context, client *Client, updates map[string]interface{}) (*Client, error)
UpdateClient updates details for a particular client
func (*PGInstance) UpdateClientIdentifier ¶
func (db *PGInstance) UpdateClientIdentifier(ctx context.Context, clientID string, identifierType string, identifierValue string, programID string) error
UpdateClientIdentifier updates the client identifier
func (*PGInstance) UpdateClientServiceRequest ¶
func (db *PGInstance) UpdateClientServiceRequest(ctx context.Context, clientServiceRequest *ClientServiceRequest, updateData map[string]interface{}) error
UpdateClientServiceRequest updates the client service request
func (*PGInstance) UpdateFacility ¶
func (db *PGInstance) UpdateFacility(ctx context.Context, facility *Facility, updateData map[string]interface{}) error
UpdateFacility updates the facility model
func (*PGInstance) UpdateFailedSecurityQuestionsAnsweringAttempts ¶
func (db *PGInstance) UpdateFailedSecurityQuestionsAnsweringAttempts(ctx context.Context, userID string, failCount int) error
UpdateFailedSecurityQuestionsAnsweringAttempts sets the failed security attempts the reset happens in an instance where: 1. the fail count is less than 3 and the user successfully answers the security questions correctly 2. the fail count is 3, the service request for resetting the pin is resolved (client), the user should set the security questions again 3. verification of the security questions is unsuccessful
func (*PGInstance) UpdateHealthDiary ¶
func (db *PGInstance) UpdateHealthDiary(ctx context.Context, clientHealthDiaryEntry *ClientHealthDiaryEntry, updateData map[string]interface{}) error
UpdateHealthDiary updates the status of the specified health diary entry
func (*PGInstance) UpdateIsCorrectSecurityQuestionResponse ¶
func (db *PGInstance) UpdateIsCorrectSecurityQuestionResponse(ctx context.Context, userID string, isCorrectSecurityQuestionResponse bool) (bool, error)
UpdateIsCorrectSecurityQuestionResponse updates the is_correct_security_question_response field in the database
func (*PGInstance) UpdateNotification ¶
func (db *PGInstance) UpdateNotification(ctx context.Context, notification *Notification, updateData map[string]interface{}) error
UpdateNotification updates a notification with the new data
func (*PGInstance) UpdateProgram ¶
func (db *PGInstance) UpdateProgram(ctx context.Context, program *Program, updateData map[string]interface{}) error
UpdateProgram updates the details of a given program
func (*PGInstance) UpdateRefreshToken ¶
func (db *PGInstance) UpdateRefreshToken(ctx context.Context, code *RefreshToken, updateData map[string]interface{}) error
UpdateRefreshToken updates the details of a given refresh token
func (*PGInstance) UpdateServiceRequests ¶
func (db *PGInstance) UpdateServiceRequests(ctx context.Context, payload []*ClientServiceRequest) (bool, error)
UpdateServiceRequests performs and update to the client service requests
func (*PGInstance) UpdateStaff ¶
func (db *PGInstance) UpdateStaff(ctx context.Context, staff *StaffProfile, updates map[string]interface{}) (*StaffProfile, error)
UpdateStaff updates staff profile information
func (*PGInstance) UpdateUser ¶
func (db *PGInstance) UpdateUser(ctx context.Context, user *User, updateData map[string]interface{}) error
UpdateUser updates the user model
func (*PGInstance) UpdateUserContact ¶
func (db *PGInstance) UpdateUserContact(ctx context.Context, userContact *Contact, updates map[string]interface{}) error
UpdateUserContact updates the user contact information
func (*PGInstance) UpdateUserPinChangeRequiredStatus ¶
func (db *PGInstance) UpdateUserPinChangeRequiredStatus(ctx context.Context, userID string, flavour feedlib.Flavour, status bool) error
UpdateUserPinChangeRequiredStatus updates a user's pin change required status
func (*PGInstance) UpdateUserPinUpdateRequiredStatus ¶
func (db *PGInstance) UpdateUserPinUpdateRequiredStatus(ctx context.Context, userID string, flavour feedlib.Flavour, status bool) error
UpdateUserPinUpdateRequiredStatus updates a user's pin update required status
func (*PGInstance) UpdateUserSurveys ¶
func (db *PGInstance) UpdateUserSurveys(ctx context.Context, survey *UserSurvey, updateData map[string]interface{}) error
UpdateUserSurveys updates the user surveys. The update is performed with regard to the data passed in the survey model.
func (*PGInstance) VerifyOTP ¶
func (db *PGInstance) VerifyOTP(ctx context.Context, payload *dto.VerifyOTPInput) (bool, error)
VerifyOTP checks from the database for the validity of the provided OTP
type PINData ¶
type PINData struct { Base PINDataID *int `gorm:"primaryKey;unique;column:id;autoincrement"` HashedPIN string `gorm:"column:hashed_pin;not null"` ValidFrom time.Time `gorm:"column:valid_from;not null"` ValidTo time.Time `gorm:"column:valid_to;not null"` IsValid bool `gorm:"column:active;not null"` Salt string `gorm:"column:salt;not null"` UserID string `gorm:"column:user_id;not null"` }
PINData is the PIN's gorm data model.
func (*PINData) BeforeCreate ¶
BeforeCreate is a hook run before creating a new PINData
func (*PINData) BeforeUpdate ¶
BeforeUpdate is a hook called before updating PINData.
type PKCE ¶
type PKCE struct { Base ID string `gorm:"primarykey"` Active bool `gorm:"column:active"` Signature string `gorm:"unique;column:signature"` RequestedAt time.Time `gorm:"column:requested_at"` RequestedScopes pq.StringArray `gorm:"type:varchar(256)[];column:requested_scopes"` GrantedScopes pq.StringArray `gorm:"type:varchar(256)[];column:granted_scopes"` Form pgtype.JSONB `gorm:"type:jsonb;column:form;default:'{}'"` RequestedAudience pq.StringArray `gorm:"type:varchar(256)[];column:requested_audience"` GrantedAudience pq.StringArray `gorm:"type:varchar(256)[];column:granted_audience"` SessionID string `gorm:"column:session_id"` Session Session ClientID string `gorm:"column:client_id"` Client OauthClient }
func (*PKCE) BeforeCreate ¶
BeforeCreate is a hook run before creating
type Program ¶
type Program struct { Base ID string `gorm:"primaryKey;column:id"` Active bool `gorm:"column:active"` Name string `gorm:"column:name"` Description string `gorm:"column:description"` OrganisationID string `gorm:"column:organisation_id;not null"` FHIROrganisationID string `gorm:"column:fhir_organisation_id"` }
Program is the database model for a program
func (*Program) BeforeCreate ¶
BeforeCreate is a hook run before creating a program
func (*Program) BeforeUpdate ¶
BeforeUpdate is a hook called before updating a client program.
type ProgramFacility ¶
type ProgramFacility struct { ID int `gorm:"primaryKey;column:id;autoincrement"` ProgramID string `gorm:"column:program_id"` FacilityID string `gorm:"column:facility_id"` }
ProgramFacility models the relationship between a program and a facility
func (ProgramFacility) TableName ¶
func (ProgramFacility) TableName() string
TableName customizes how the table name is generated
type Query ¶
type Query interface { RetrieveFacility(ctx context.Context, id *string, isActive bool) (*Facility, error) RetrieveFacilityByIdentifier(ctx context.Context, identifier *FacilityIdentifier, isActive bool) (*Facility, error) RetrieveFacilityIdentifiersByFacilityID(ctx context.Context, facilityID *string) ([]*FacilityIdentifier, error) ListFacilities(ctx context.Context, searchTerm *string, filter []*domain.FiltersParam, pagination *domain.Pagination) ([]*Facility, *domain.Pagination, error) GetFacilitiesWithoutFHIRID(ctx context.Context) ([]*Facility, error) GetOrganisation(ctx context.Context, id string) (*Organisation, error) ListProgramFacilities(ctx context.Context, programID, searchTerm *string, filter []*domain.FiltersParam, pagination *domain.Pagination) ([]*Facility, *domain.Pagination, error) ListNotifications(ctx context.Context, params *Notification, filters []*firebasetools.FilterParam, pagination *domain.Pagination) ([]*Notification, *domain.Pagination, error) ListSurveyRespondents(ctx context.Context, params *UserSurvey, facilityID string, pagination *domain.Pagination) ([]*UserSurvey, *domain.Pagination, error) ListAvailableNotificationTypes(ctx context.Context, params *Notification) ([]enums.NotificationType, error) ListAppointments(ctx context.Context, params *Appointment, filters []*firebasetools.FilterParam, pagination *domain.Pagination) ([]*Appointment, *domain.Pagination, error) GetUserProfileByUsername(ctx context.Context, username string) (*User, error) GetUserProfileByPhoneNumber(ctx context.Context, phoneNumber string) (*User, error) GetUserPINByUserID(ctx context.Context, userID string) (*PINData, error) GetUserProfileByUserID(ctx context.Context, userID *string) (*User, error) GetCurrentTerms(ctx context.Context) (*TermsOfService, error) GetSecurityQuestions(ctx context.Context, flavour feedlib.Flavour) ([]*SecurityQuestion, error) GetSecurityQuestionByID(ctx context.Context, securityQuestionID *string) (*SecurityQuestion, error) GetSecurityQuestionResponse(ctx context.Context, questionID string, userID string) (*SecurityQuestionResponse, error) CheckIfPhoneNumberExists(ctx context.Context, phone string, isOptedIn bool, flavour feedlib.Flavour) (bool, error) VerifyOTP(ctx context.Context, payload *dto.VerifyOTPInput) (bool, error) CheckStaffExists(ctx context.Context, userID string) (bool, error) CheckClientExists(ctx context.Context, userID string) (bool, error) CheckCaregiverExists(ctx context.Context, userID string) (bool, error) GetClientProfile(ctx context.Context, userID string, programID string) (*Client, error) GetCaregiverByUserID(ctx context.Context, userID string) (*Caregiver, error) GetProgramClientProfileByIdentifier(ctx context.Context, programID, identifierType, value string) (*Client, error) GetClientProfilesByIdentifier(ctx context.Context, identifierType, value string) ([]*Client, error) GetStaffProfile(ctx context.Context, userID string, programID string) (*StaffProfile, error) CheckUserHasPin(ctx context.Context, userID string) (bool, error) GetOTP(ctx context.Context, phoneNumber string, flavour feedlib.Flavour) (*UserOTP, error) GetClientsPendingServiceRequestsCount(ctx context.Context, facilityID string, programID *string) (*domain.ServiceRequestsCount, error) GetStaffPendingServiceRequestsCount(ctx context.Context, facilityID string, programID string) (*domain.ServiceRequestsCount, error) GetUserSecurityQuestionsResponses(ctx context.Context, userID, flavour string) ([]*SecurityQuestionResponse, error) GetContactByUserID(ctx context.Context, userID *string, contactType string) (*Contact, error) FindContacts(ctx context.Context, contactType string, contactValue string) ([]*Contact, error) CanRecordHeathDiary(ctx context.Context, clientID string) (bool, error) GetClientHealthDiaryQuote(ctx context.Context, limit int) ([]*ClientHealthDiaryQuote, error) GetClientHealthDiaryEntries(ctx context.Context, params map[string]interface{}) ([]*ClientHealthDiaryEntry, error) GetClientProfileByClientID(ctx context.Context, clientID string) (*Client, error) GetServiceRequests(ctx context.Context, requestType, requestStatus *string, facilityID string, programID string, pagination *domain.Pagination) ([]*ClientServiceRequest, *domain.Pagination, error) GetStaffServiceRequests(ctx context.Context, requestType, requestStatus *string, facilityID string, pagination *domain.Pagination) ([]*StaffServiceRequest, *domain.Pagination, error) CheckIfUsernameExists(ctx context.Context, username string) (bool, error) GetCommunityByID(ctx context.Context, communityID string) (*Community, error) CheckIdentifierExists(ctx context.Context, identifierType string, identifierValue string) (bool, error) CheckFacilityExistsByIdentifier(ctx context.Context, identifier *FacilityIdentifier) (bool, error) GetClientsInAFacility(ctx context.Context, facilityID string) ([]*Client, error) GetRecentHealthDiaryEntries(ctx context.Context, lastSyncTime time.Time, clientID string) ([]*ClientHealthDiaryEntry, error) GetClientsByParams(ctx context.Context, query Client, lastSyncTime *time.Time) ([]*Client, error) GetClientIdentifiers(ctx context.Context, clientID string) ([]*Identifier, error) SearchClientProfile(ctx context.Context, searchParameter string) ([]*Client, error) SearchStaffProfile(ctx context.Context, searchParameter string, programID *string) ([]*StaffProfile, error) GetServiceRequestsForKenyaEMR(ctx context.Context, facilityID string, lastSyncTime time.Time) ([]*ClientServiceRequest, error) CheckIfClientHasUnresolvedServiceRequests(ctx context.Context, clientID string, serviceRequestType string) (bool, error) GetUserProfileByStaffID(ctx context.Context, staffID string) (*User, error) GetHealthDiaryEntryByID(ctx context.Context, healthDiaryEntryID string) (*ClientHealthDiaryEntry, error) GetClientServiceRequestByID(ctx context.Context, serviceRequestID string) (*ClientServiceRequest, error) GetStaffProfileByStaffID(ctx context.Context, staffID string) (*StaffProfile, error) GetAppointmentServiceRequests(ctx context.Context, lastSyncTime time.Time, facilityID string) ([]*ClientServiceRequest, error) GetClientServiceRequests(ctx context.Context, requestType, status, clientID, facilityID string) ([]*ClientServiceRequest, error) CheckAppointmentExistsByExternalID(ctx context.Context, externalID string) (bool, error) GetClientScreeningToolServiceRequestByToolType(ctx context.Context, clientID, toolType, status string) (*ClientServiceRequest, error) GetAppointment(ctx context.Context, params *Appointment) (*Appointment, error) GetUserSurveyForms(ctx context.Context, params map[string]interface{}) ([]*UserSurvey, error) CheckIfStaffHasUnresolvedServiceRequests(ctx context.Context, staffID string, serviceRequestType string) (bool, error) GetFacilityStaffs(ctx context.Context, facilityID string) ([]*StaffProfile, error) GetNotification(ctx context.Context, notificationID string) (*Notification, error) GetClientsByFilterParams(ctx context.Context, facilityID string, filterParams *dto.ClientFilterParamsInput) ([]*Client, error) SearchClientServiceRequests(ctx context.Context, searchParameter string, requestType string, facilityID string) ([]*ClientServiceRequest, error) SearchStaffServiceRequests(ctx context.Context, searchParameter string, requestType string, facilityID string) ([]*StaffServiceRequest, error) GetScreeningToolByID(ctx context.Context, toolID string) (*ScreeningTool, error) GetQuestionnaireByID(ctx context.Context, questionnaireID string) (*Questionnaire, error) GetQuestionsByQuestionnaireID(ctx context.Context, questionnaireID string) ([]*Question, error) GetQuestionInputChoicesByQuestionID(ctx context.Context, questionID string) ([]*QuestionInputChoice, error) GetAvailableScreeningTools(ctx context.Context, clientID string, screeningTool ScreeningTool, screeningToolIDs []string) ([]*ScreeningTool, error) GetScreeningToolResponsesWithin24Hours(ctx context.Context, clientID, programID string) ([]*ScreeningToolResponse, error) GetAllScreeningTools(ctx context.Context, pagination *domain.Pagination) ([]*ScreeningTool, *domain.Pagination, error) GetScreeningToolResponsesWithPendingServiceRequests(ctx context.Context, clientID, programID string) ([]*ScreeningToolResponse, error) GetFacilityRespondedScreeningTools(ctx context.Context, facilityID, programID string, pagination *domain.Pagination) ([]*ScreeningTool, *domain.Pagination, error) GetScreeningToolServiceRequestOfRespondents(ctx context.Context, facilityID, programID string, screeningToolID string, searchTerm string, pagination *domain.Pagination) ([]*ClientServiceRequest, *domain.Pagination, error) GetScreeningToolResponseByID(ctx context.Context, id string) (*ScreeningToolResponse, error) GetScreeningToolQuestionResponsesByResponseID(ctx context.Context, responseID string) ([]*ScreeningToolQuestionResponse, error) GetSurveysWithServiceRequests(ctx context.Context, facilityID, programID string) ([]*UserSurvey, error) GetClientsSurveyServiceRequest(ctx context.Context, facilityID string, projectID int, formID string, pagination *domain.Pagination) ([]*ClientServiceRequest, *domain.Pagination, error) GetNotificationsCount(ctx context.Context, notification Notification) (int, error) GetStaffFacilities(ctx context.Context, staffFacility StaffFacilities, pagination *domain.Pagination) ([]*StaffFacilities, *domain.Pagination, error) GetClientFacilities(ctx context.Context, clientFacility ClientFacilities, pagination *domain.Pagination) ([]*ClientFacilities, *domain.Pagination, error) GetClientsSurveyCount(ctx context.Context, userID string) (int, error) SearchCaregiverUser(ctx context.Context, searchParameter string) ([]*Caregiver, error) SearchPlatformCaregivers(ctx context.Context, searchParameter string) ([]*Caregiver, error) GetCaregiverManagedClients(ctx context.Context, userID string, pagination *domain.Pagination) ([]*CaregiverClient, *domain.Pagination, error) GetCaregiversClient(ctx context.Context, caregiverClient CaregiverClient) ([]*CaregiverClient, error) GetCaregiverProfileByCaregiverID(ctx context.Context, caregiverID string) (*Caregiver, error) ListClientsCaregivers(ctx context.Context, clientID string, pagination *domain.Pagination) ([]*CaregiverClient, *domain.Pagination, error) CheckOrganisationExists(ctx context.Context, organisationID string) (bool, error) GetStaffUserPrograms(ctx context.Context, userID string) ([]*Program, error) GetClientUserPrograms(ctx context.Context, userID string) ([]*Program, error) CheckIfProgramNameExists(ctx context.Context, organisationID string, programName string) (bool, error) ListOrganisations(ctx context.Context, pagination *domain.Pagination) ([]*Organisation, *domain.Pagination, error) SearchOrganisation(ctx context.Context, searchParameter string) ([]*Organisation, error) GetProgramFacilities(ctx context.Context, programID string) ([]*ProgramFacility, error) GetProgramByID(ctx context.Context, programID string) (*Program, error) SearchPrograms(ctx context.Context, searchParameter string, organisationID string, pagination *domain.Pagination) ([]*Program, *domain.Pagination, error) ListPrograms(ctx context.Context, organisationID *string, pagination *domain.Pagination) ([]*Program, *domain.Pagination, error) CheckIfSuperUserExists(ctx context.Context) (bool, error) GetCaregiverProfileByUserID(ctx context.Context, userID string, organisationID string) (*Caregiver, error) ListCommunities(ctx context.Context, programID string, organisationID string) ([]*Community, error) CheckPhoneExists(ctx context.Context, phone string) (bool, error) GetStaffServiceRequestByID(ctx context.Context, serviceRequestID string) (*StaffServiceRequest, error) GetClientJWT(ctx context.Context, jti string) (*OauthClientJWT, error) GetOauthClient(ctx context.Context, id string) (*OauthClient, error) GetValidClientJWT(ctx context.Context, jti string) (*OauthClientJWT, error) GetAuthorizationCode(ctx context.Context, code string) (*AuthorizationCode, error) GetAccessToken(ctx context.Context, token AccessToken) (*AccessToken, error) GetRefreshToken(ctx context.Context, token RefreshToken) (*RefreshToken, error) CheckIfClientHasPendingSurveyServiceRequest(ctx context.Context, clientID string, projectID int, FormID string) (bool, error) GetUserProfileByPushToken(ctx context.Context, pushToken string) (*User, error) CheckStaffExistsInProgram(ctx context.Context, userID, programID string) (bool, error) CheckIfFacilityExistsInProgram(ctx context.Context, programID, facilityID string) (bool, error) GetStaffIdentifiers(ctx context.Context, staffID string, identifierType *string) ([]*Identifier, error) CheckIfClientExistsInProgram(ctx context.Context, userID, programID string) (bool, error) GetUserClientProfiles(ctx context.Context, userID string) ([]*Client, error) GetUserStaffProfiles(ctx context.Context, userID string) ([]*StaffProfile, error) ListBookings(ctx context.Context, clientID string, bookingState enums.BookingState, pagination *domain.Pagination) ([]*Booking, *domain.Pagination, error) }
Query contains all the db query methods
type Question ¶
type Question struct { Base OrganisationID string `gorm:"column:organisation_id"` ID string `gorm:"primaryKey;column:id"` Active bool `gorm:"column:active"` QuestionnaireID string `gorm:"column:questionnaire_id"` Text string `gorm:"column:text"` QuestionType string `gorm:"column:question_type"` ResponseValueType string `gorm:"column:response_value_type"` SelectMultiple bool `gorm:"column:select_multiple"` Required bool `gorm:"column:required"` Sequence int `gorm:"column:sequence"` ProgramID string `gorm:"column:program_id"` }
Question defines the question database models
func (*Question) BeforeCreate ¶
BeforeCreate is a hook run before creating a question
func (*Question) BeforeUpdate ¶
BeforeUpdate is a hook called before updating a Question.
type QuestionInputChoice ¶
type QuestionInputChoice struct { Base OrganisationID string `gorm:"column:organisation_id"` ID string `gorm:"primaryKey;column:id"` Active bool `gorm:"column:active"` QuestionID string `gorm:"column:question_id"` Choice string `gorm:"column:choice"` Value string `gorm:"column:value"` Score int `gorm:"column:score"` ProgramID string `gorm:"column:program_id"` }
QuestionInputChoice defines the question input choice database models
func (*QuestionInputChoice) BeforeCreate ¶
func (q *QuestionInputChoice) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating a question input choice
func (*QuestionInputChoice) BeforeUpdate ¶
func (q *QuestionInputChoice) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating a QuestionInputChoice.
func (QuestionInputChoice) TableName ¶
func (QuestionInputChoice) TableName() string
TableName references the table that we map data from
type Questionnaire ¶
type Questionnaire struct { Base OrganisationID string `gorm:"column:organisation_id"` ID string `gorm:"primaryKey;column:id"` Active bool `gorm:"column:active"` Name string `gorm:"column:name"` Description string `gorm:"column:description"` ProgramID string `gorm:"column:program_id"` }
Questionnaire defines the questionnaire database models
func (*Questionnaire) BeforeCreate ¶
func (q *Questionnaire) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating a questionnaire
func (*Questionnaire) BeforeUpdate ¶
func (q *Questionnaire) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating a Questionnaire.
func (Questionnaire) TableName ¶
func (Questionnaire) TableName() string
TableName references the table that we map data from
type RefreshToken ¶
type RefreshToken struct { Base ID string `gorm:"primarykey"` Active bool `gorm:"column:active"` Signature string `gorm:"unique;column:signature"` RequestedAt time.Time `gorm:"column:requested_at"` RequestedScopes pq.StringArray `gorm:"type:varchar(256)[];column:requested_scopes"` GrantedScopes pq.StringArray `gorm:"type:varchar(256)[];column:granted_scopes"` Form pgtype.JSONB `gorm:"type:jsonb;column:form;default:'{}'"` RequestedAudience pq.StringArray `gorm:"type:varchar(256)[];column:requested_audience"` GrantedAudience pq.StringArray `gorm:"type:varchar(256)[];column:granted_audience"` ClientID string `gorm:"column:client_id"` Client OauthClient SessionID string `gorm:"column:session_id"` Session Session }
func (*RefreshToken) BeforeCreate ¶
func (a *RefreshToken) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating
func (RefreshToken) TableName ¶
func (RefreshToken) TableName() string
TableName references the table name in the database
type RelatedPerson ¶
type RelatedPerson struct { Base ID string `gorm:"primaryKey;column:id;"` Active bool `gorm:"column:active;not null"` FirstName string `gorm:"column:first_name"` LastName string `gorm:"column:last_name"` OtherName string `gorm:"column:other_name"` Gender string `gorm:"column:gender"` RelationshipType string `gorm:"column:relationship_type"` ProgramID string `gorm:"column:program_id"` OrganisationID string `gorm:"column:organisation_id;not null"` }
RelatedPerson represents information for a person related to another user
func (*RelatedPerson) BeforeCreate ¶
func (r *RelatedPerson) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating a related person
func (*RelatedPerson) BeforeUpdate ¶
func (r *RelatedPerson) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating RelatedPerson.
func (*RelatedPerson) TableName ¶
func (r *RelatedPerson) TableName() string
TableName references the table that we map data from
type RelatedPersonAddresses ¶
type RelatedPersonAddresses struct { ID int `gorm:"primaryKey;column:id;autoincrement"` RelatedPersonID *string `gorm:"column:relatedperson_id"` AddressID *string `gorm:"column:address_id"` }
RelatedPersonAddresses links a related person with their addresses
func (*RelatedPersonAddresses) TableName ¶
func (r *RelatedPersonAddresses) TableName() string
TableName references the table that we map data from
type RelatedPersonContacts ¶
type RelatedPersonContacts struct { ID int `gorm:"primaryKey;column:id;autoincrement"` RelatedPersonID *string `gorm:"column:relatedperson_id"` ContactID *string `gorm:"column:contact_id"` }
RelatedPersonContacts links a related person with their contact
func (*RelatedPersonContacts) TableName ¶
func (r *RelatedPersonContacts) TableName() string
TableName references the table that we map data from
type ScreeningTool ¶
type ScreeningTool struct { Base OrganisationID string `gorm:"column:organisation_id"` ID string `gorm:"primaryKey;column:id"` Active bool `gorm:"column:active"` QuestionnaireID string `gorm:"column:questionnaire_id"` Threshold int `gorm:"column:threshold"` ClientTypes pq.StringArray `gorm:"type:text[];column:client_types"` Genders pq.StringArray `gorm:"type:text[];column:genders"` MinimumAge int `gorm:"column:min_age"` MaximumAge int `gorm:"column:max_age"` ProgramID string `gorm:"column:program_id"` }
ScreeningTool defines the screening tool database models
func (*ScreeningTool) BeforeCreate ¶
func (s *ScreeningTool) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating a screening tool
func (*ScreeningTool) BeforeUpdate ¶
func (s *ScreeningTool) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating a ScreeningTool.
func (ScreeningTool) TableName ¶
func (ScreeningTool) TableName() string
TableName references the table that we map data from
type ScreeningToolQuestionResponse ¶
type ScreeningToolQuestionResponse struct { Base OrganisationID string `gorm:"column:organisation_id"` ID string `gorm:"primaryKey;column:id"` Active bool `gorm:"column:active"` ScreeningToolResponseID string `gorm:"column:screeningtoolresponse_id"` QuestionID string `gorm:"column:question_id"` Response string `gorm:"column:response"` Score int `gorm:"column:score"` ProgramID string `gorm:"column:program_id"` FacilityID string `gorm:"column:facility_id"` }
ScreeningToolQuestionResponse defines the screening tool question response database models
func (*ScreeningToolQuestionResponse) BeforeCreate ¶
func (s *ScreeningToolQuestionResponse) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating a screening tool question response
func (*ScreeningToolQuestionResponse) BeforeUpdate ¶
func (s *ScreeningToolQuestionResponse) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating a screeningtool question response.
func (ScreeningToolQuestionResponse) TableName ¶
func (ScreeningToolQuestionResponse) TableName() string
TableName references the table that we map data from
type ScreeningToolResponse ¶
type ScreeningToolResponse struct { Base OrganisationID string `gorm:"column:organisation_id"` ID string `gorm:"primaryKey;column:id"` Active bool `gorm:"column:active"` ScreeningToolID string `gorm:"column:screeningtool_id"` FacilityID string `gorm:"column:facility_id"` ClientID string `gorm:"column:client_id"` AggregateScore int `gorm:"column:aggregate_score"` ProgramID string `gorm:"column:program_id"` CaregiverID *string `gorm:"column:caregiver_id"` }
ScreeningToolResponse defines the screening tool response database models
func (*ScreeningToolResponse) BeforeCreate ¶
func (s *ScreeningToolResponse) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating a screening tool response
func (*ScreeningToolResponse) BeforeUpdate ¶
func (s *ScreeningToolResponse) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating a ScreeningToolResponse.
func (ScreeningToolResponse) TableName ¶
func (ScreeningToolResponse) TableName() string
TableName references the table that we map data from
type SecurityQuestion ¶
type SecurityQuestion struct { Base SecurityQuestionID *string `gorm:"column:id"` QuestionStem string `gorm:"column:stem"` Description string `gorm:"column:description"` // help text ResponseType enums.SecurityQuestionResponseType `gorm:"column:response_type"` Flavour feedlib.Flavour `gorm:"column:flavour"` Active bool `gorm:"column:active"` Sequence *int `gorm:"column:sequence"` // for sorting }
SecurityQuestion is the gorms security question model
func (*SecurityQuestion) BeforeCreate ¶
func (s *SecurityQuestion) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating security question
func (*SecurityQuestion) BeforeUpdate ¶
func (s *SecurityQuestion) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating SecurityQuestion.
func (SecurityQuestion) TableName ¶
func (SecurityQuestion) TableName() string
TableName customizes how the table name is generated
type SecurityQuestionResponse ¶
type SecurityQuestionResponse struct { Base ResponseID string `gorm:"column:id"` QuestionID string `gorm:"column:question_id"` Active bool `gorm:"column:active"` Response string `gorm:"column:response"` Timestamp time.Time `gorm:"column:timestamp"` IsCorrect bool `gorm:"column:is_correct"` UserID string `gorm:"column:user_id"` }
SecurityQuestionResponse maps the schema for the table that stores the security question responses
func (*SecurityQuestionResponse) BeforeCreate ¶
func (s *SecurityQuestionResponse) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate function is called before creating a security question response It generates the organisation id and response ID
func (*SecurityQuestionResponse) BeforeUpdate ¶
func (s *SecurityQuestionResponse) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating SecurityQuestionResponse.
func (SecurityQuestionResponse) TableName ¶
func (SecurityQuestionResponse) TableName() string
TableName customizes how the table name is generated
type Session ¶
type Session struct { Base ID string `gorm:"primarykey"` ClientID string `gorm:"column:client_id"` Username string `gorm:"column:username"` Subject string `gorm:"column:subject"` ExpiresAt pgtype.JSONB `gorm:"type:jsonb;column:expires_at;default:'{}'"` // Default Extra pgtype.JSONB `gorm:"type:jsonb;column:extra;default:'{}'"` UserID string `gorm:"column:user_id;default:null"` User User }
func (*Session) BeforeCreate ¶
BeforeCreate is a hook run before creating
type StaffFacilities ¶
type StaffFacilities struct { ID int `gorm:"primaryKey;column:id;autoincrement"` StaffID *string `gorm:"column:staff_id"` FacilityID *string `gorm:"column:facility_id"` }
StaffFacilities links a staff with their facilities
func (*StaffFacilities) TableName ¶
func (s *StaffFacilities) TableName() string
TableName references the table that we map data from
type StaffIdentifiers ¶
type StaffIdentifiers struct { ID int `gorm:"primaryKey;column:id;autoincrement"` StaffID *string `gorm:"column:staff_id"` IdentifierID *string `gorm:"column:identifier_id"` }
StaffIdentifiers links a staff with their identifiers
func (*StaffIdentifiers) TableName ¶
func (s *StaffIdentifiers) TableName() string
TableName references the table that we map data from
type StaffProfile ¶
type StaffProfile struct { Base ID *string `gorm:"column:id"` Active bool `gorm:"column:active"` StaffNumber string `gorm:"column:staff_number"` Facilities []Facility `gorm:"ForeignKey:FacilityID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"` // TODO: needs at least one DefaultFacilityID string `gorm:"column:current_facility_id"` // TODO: required, FK to facility OrganisationID string `gorm:"column:organisation_id"` UserID string `gorm:"column:user_id"` // foreign key to user UserProfile User `gorm:"ForeignKey:user_id;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"` ProgramID string `gorm:"column:program_id"` // foreign key to program IsOrganisationAdmin bool `gorm:"column:is_organisation_admin"` }
StaffProfile represents the staff profile model
func (*StaffProfile) BeforeCreate ¶
func (s *StaffProfile) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating a staff profile
func (*StaffProfile) BeforeUpdate ¶
func (s *StaffProfile) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating StaffProfile.
func (StaffProfile) TableName ¶
func (StaffProfile) TableName() string
TableName references the table that we map data from
type StaffServiceRequest ¶
type StaffServiceRequest struct { Base ID *string `gorm:"column:id"` Active bool `gorm:"column:active"` RequestType string `gorm:"column:request_type"` Request string `gorm:"column:request"` Status string `gorm:"column:status"` ResolvedAt *time.Time `gorm:"column:resolved_at"` Meta string `gorm:"column:meta"` StaffID string `gorm:"column:staff_id"` OrganisationID string `gorm:"column:organisation_id"` ResolvedByID *string `gorm:"column:resolved_by_id"` DefaultFacilityID *string `gorm:"column:facility_id"` ProgramID string `gorm:"column:program_id"` }
StaffServiceRequest maps the staffs's service request table. It is used to store the tasks for the healthcare staff on the platform
func (*StaffServiceRequest) BeforeCreate ¶
func (s *StaffServiceRequest) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook called before creating a service request.
func (*StaffServiceRequest) BeforeUpdate ¶
func (s *StaffServiceRequest) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating a service request.
func (StaffServiceRequest) TableName ¶
func (StaffServiceRequest) TableName() string
TableName references the table that we map data from
type TermsOfService ¶
type TermsOfService struct { Base TermsID *int `gorm:"primaryKey;unique;column:id;autoincrement"` Text *string `gorm:"column:text;not null"` ValidFrom *time.Time `gorm:"column:valid_from;not null"` ValidTo *time.Time `gorm:"column:valid_to;not null"` Active bool `gorm:"column:active;not null"` }
TermsOfService is the gorms terms of service model
func (*TermsOfService) BeforeCreate ¶
func (t *TermsOfService) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating a new TermsOfService
func (*TermsOfService) BeforeUpdate ¶
func (t *TermsOfService) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating TermsOfService.
func (TermsOfService) TableName ¶
func (TermsOfService) TableName() string
TableName customizes how the table name is generated
type Update ¶
type Update interface { InactivateFacility(ctx context.Context, identifier *FacilityIdentifier) (bool, error) ReactivateFacility(ctx context.Context, identifier *FacilityIdentifier) (bool, error) UpdateFacility(ctx context.Context, facility *Facility, updateData map[string]interface{}) error AcceptTerms(ctx context.Context, userID *string, termsID *int) (bool, error) CompleteOnboardingTour(ctx context.Context, userID string, flavour feedlib.Flavour) (bool, error) InvalidatePIN(ctx context.Context, userID string) (bool, error) UpdateIsCorrectSecurityQuestionResponse(ctx context.Context, userID string, isCorrectSecurityQuestionResponse bool) (bool, error) SetInProgressBy(ctx context.Context, requestID string, staffID string) (bool, error) ResolveStaffServiceRequest(ctx context.Context, staffID *string, serviceRequestID *string, verificattionStatus string) (bool, error) UpdateAppointment(ctx context.Context, appointment *Appointment, updateData map[string]interface{}) (*Appointment, error) UpdateServiceRequests(ctx context.Context, payload []*ClientServiceRequest) (bool, error) UpdateUserPinChangeRequiredStatus(ctx context.Context, userID string, flavour feedlib.Flavour, status bool) error UpdateClient(ctx context.Context, client *Client, updates map[string]interface{}) (*Client, error) UpdateUserPinUpdateRequiredStatus(ctx context.Context, userID string, flavour feedlib.Flavour, status bool) error UpdateHealthDiary(ctx context.Context, clientHealthDiaryEntry *ClientHealthDiaryEntry, updateData map[string]interface{}) error UpdateFailedSecurityQuestionsAnsweringAttempts(ctx context.Context, userID string, failCount int) error UpdateUserSurveys(ctx context.Context, survey *UserSurvey, updateData map[string]interface{}) error UpdateUser(ctx context.Context, user *User, updateData map[string]interface{}) error UpdateNotification(ctx context.Context, notification *Notification, updateData map[string]interface{}) error UpdateClientServiceRequest(ctx context.Context, clientServiceRequest *ClientServiceRequest, updateData map[string]interface{}) error UpdateStaff(ctx context.Context, staff *StaffProfile, updates map[string]interface{}) (*StaffProfile, error) AddFacilitiesToStaffProfile(ctx context.Context, staffID string, facilities []string) error AddFacilitiesToClientProfile(ctx context.Context, clientID string, facilities []string) error UpdateCaregiverClient(ctx context.Context, caregiverClient *CaregiverClient, updateData map[string]interface{}) error UpdateCaregiver(ctx context.Context, caregiver *Caregiver, updates map[string]interface{}) error UpdateUserContact(ctx context.Context, contact *Contact, updateData map[string]interface{}) error UpdateClientIdentifier(ctx context.Context, clientID string, identifierType string, identifierValue string, programID string) error UpdateProgram(ctx context.Context, program *Program, updateData map[string]interface{}) error UpdateAuthorizationCode(ctx context.Context, code *AuthorizationCode, updateData map[string]interface{}) error UpdateAccessToken(ctx context.Context, code *AccessToken, updateData map[string]interface{}) error UpdateRefreshToken(ctx context.Context, code *RefreshToken, updateData map[string]interface{}) error UpdateBooking(ctx context.Context, booking *Booking, updateData map[string]interface{}) error }
Update represents all `update` operations to the database
type User ¶
type User struct { Base UserID *string `gorm:"primaryKey;unique;column:id"` Username string `gorm:"column:username;unique;not null"` Email *string `gorm:"column:email;unique"` Gender enumutils.Gender `gorm:"column:gender;not null"` Active bool `gorm:"column:active;not null"` Contacts Contact `gorm:"ForeignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"` // TODO: validate, ensure // for the preferred language list, order matters Languages pq.StringArray `gorm:"type:text[];column:languages;not null"` // TODO: turn this into a slice of enums, start small (en, sw) PushTokens pq.StringArray `gorm:"type:text[];column:push_tokens"` // when a user logs in successfully, set this LastSuccessfulLogin *time.Time `gorm:"type:time;column:last_successful_login"` // whenever there is a failed login (e.g bad PIN), set this // reset to null / blank when they succeed at logging in LastFailedLogin *time.Time `gorm:"type:time;column:last_failed_login"` // each time there is a failed login, **increment** this // set to zero after successful login FailedLoginCount int `gorm:"column:failed_login_count"` // calculated each time there is a failed login NextAllowedLogin *time.Time `gorm:"type:time;column:next_allowed_login"` TermsAccepted bool `gorm:"type:bool;column:terms_accepted;not null"` Avatar string `gorm:"column:avatar"` IsSuspended bool `gorm:"column:is_suspended;not null"` PinChangeRequired bool `gorm:"column:pin_change_required"` HasSetPin bool `gorm:"column:has_set_pin"` HasSetSecurityQuestion bool `gorm:"column:has_set_security_questions"` HasSetUsername bool `gorm:"column:has_set_username"` IsPhoneVerified bool `gorm:"column:is_phone_verified"` IsSuperuser bool `gorm:"column:is_superuser"` Name string `gorm:"column:name"` DateOfBirth *time.Time `gorm:"column:date_of_birth"` FailedSecurityCount int `gorm:"column:failed_security_count"` PinUpdateRequired bool `gorm:"column:pin_update_required"` CurrentOrganisationID string `gorm:"column:current_organisation_id"` CurrentProgramID string `gorm:"column:current_program_id"` CurrentUserType string `gorm:"column:current_usertype"` AcceptedTermsID *int `gorm:"column:accepted_terms_of_service_id"` }
User represents the table data structure for a user
func (*User) BeforeCreate ¶
BeforeCreate is a hook run before creating a new user
func (*User) BeforeDelete ¶
BeforeDelete hook is run before deleting a user profile
func (*User) BeforeUpdate ¶
BeforeUpdate is a hook called before updating User.
type UserOTP ¶
type UserOTP struct { Base OTPID int `gorm:"unique;column:id;autoincrement"` Valid bool `gorm:"column:is_valid"` GeneratedAt time.Time `gorm:"column:generated_at"` ValidUntil time.Time `gorm:"column:valid_until"` Channel string `gorm:"column:channel"` Flavour feedlib.Flavour `gorm:"column:flavour"` PhoneNumber string `gorm:"column:phonenumber"` OTP string `gorm:"column:otp"` UserID string `gorm:"column:user_id"` }
UserOTP maps the schema for the table that stores the user's OTP
func (*UserOTP) BeforeCreate ¶
BeforeCreate is a hook called before updating UserOTP.
func (*UserOTP) BeforeUpdate ¶
BeforeUpdate is a hook called before updating UserOTP.
type UserSurvey ¶
type UserSurvey struct { Base ID string `gorm:"id"` Active bool `gorm:"active"` Link string `gorm:"link"` Title string `gorm:"title"` Description string `gorm:"description"` HasSubmitted bool `gorm:"submitted"` FormID string `gorm:"form_id"` ProjectID int `gorm:"project_id"` LinkID int `gorm:"link_id"` Token string `gorm:"token"` SubmittedAt *time.Time `gorm:"submitted_at"` ProgramID string `gorm:"program_id"` UserID string `gorm:"user_id"` OrganisationID string `gorm:"organisation_id"` CaregiverID *string `gorm:"column:caregiver_id"` }
UserSurvey represents a user's surveys database model
func (*UserSurvey) BeforeCreate ¶
func (u *UserSurvey) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate is a hook run before creating a user survey model
func (*UserSurvey) BeforeUpdate ¶
func (u *UserSurvey) BeforeUpdate(tx *gorm.DB) (err error)
BeforeUpdate is a hook called before updating UserSurvey.
func (UserSurvey) TableName ¶
func (UserSurvey) TableName() string
TableName references the table that we map data from