user

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ICaregiversClients

type ICaregiversClients interface {
	GetCaregiverManagedClients(ctx context.Context, userID string, input dto.PaginationsInput) (*dto.ManagedClientOutputPage, error)
}

ICaregiversClients is an interface that contains all the caregiver clients use cases

type IClientCaregiver

type IClientCaregiver interface {
	RegisterCaregiver(ctx context.Context, input dto.CaregiverInput) (*domain.CaregiverProfile, error)
	RegisterClientAsCaregiver(ctx context.Context, clientID string, caregiverNumber string) (*domain.CaregiverProfile, error)
	TransferClientToFacility(ctx context.Context, clientID *string, facilityID *string) (bool, error)
	AssignCaregiver(ctx context.Context, input dto.ClientCaregiverInput) (bool, error)
	ListClientsCaregivers(ctx context.Context, clientID string, pagination *dto.PaginationsInput) (*dto.CaregiverProfileOutputPage, error)
	ConsentToAClientCaregiver(ctx context.Context, clientID string, caregiverID string, consent enums.ConsentState) (bool, error)
	ConsentToManagingClient(ctx context.Context, caregiverID string, clientID string, consent enums.ConsentState) (bool, error)
	SetCaregiverCurrentClient(ctx context.Context, clientID string) (*domain.ClientProfile, error)
	SetCaregiverCurrentFacility(ctx context.Context, caregiverID string, facilityID string) (*domain.Facility, error)
	RegisterExistingUserAsCaregiver(ctx context.Context, userID string, caregiverNumber string) (*domain.CaregiverProfile, error)
}

IClientCaregiver is an interface that contains all the client caregiver use cases

type IClientMedicalHistory

type IClientMedicalHistory interface {
	RegisteredFacilityPatients(ctx context.Context, input dto.PatientSyncPayload) (*dto.PatientSyncResponse, error)
}

IClientMedicalHistory interface defines method signature for dealing with medical history

type IClientProfile

type IClientProfile interface {
	AddFacilitiesToClientProfile(ctx context.Context, clientID string, facilities []string) (bool, error)
	CheckIdentifierExists(ctx context.Context, identifierType enums.UserIdentifierType, identifierValue string) (bool, error)
}

IClientProfile interface contains method signatures related to a client profile

type ICompleteOnboardingTour

type ICompleteOnboardingTour interface {
	CompleteOnboardingTour(ctx context.Context, userID string, flavour feedlib.Flavour) (bool, error)
}

ICompleteOnboardingTour defines a method that is used to complete the onboarding tour

type IDeleteUser

type IDeleteUser interface {
	DeleteClientProfile(ctx context.Context, clientID string) (bool, error)
}

IDeleteUser interface define the method signature that is used to delete user

type ILogin

type ILogin interface {
	Login(ctx context.Context, input *dto.LoginInput) (*dto.LoginResponse, bool)
	InviteUser(ctx context.Context, userID string, phoneNumber string, flavour feedlib.Flavour, reinvite bool) (bool, error)
	FetchContactOrganisations(ctx context.Context, phoneNumber string) ([]*domain.Organisation, error)
}

ILogin is an interface that contans login related methods

type IPIN

type IPIN interface {
	ResetPIN(ctx context.Context, input dto.UserResetPinInput) (bool, error)
	GenerateTemporaryPin(ctx context.Context, userID string, flavour feedlib.Flavour) (string, error)
}

IPIN is an interface that contains all the user use cases for pins

type IRefreshToken

type IRefreshToken interface {
	RefreshToken(ctx context.Context, userID string) (*dto.AuthCredentials, error)
	RegisterPushToken(ctx context.Context, token string) (bool, error)
}

IRefreshToken contains the method refreshing a token

type IRegisterUser

type IRegisterUser interface {
	RegisterClient(ctx context.Context, input *dto.ClientRegistrationInput) (*dto.ClientRegistrationOutput, error)
	RegisterStaff(ctx context.Context, input dto.StaffRegistrationInput) (*dto.StaffRegistrationOutput, error)
	RegisterExistingUserAsClient(ctx context.Context, input dto.ExistingUserClientInput) (*dto.ClientRegistrationOutput, error)
	RegisterExistingUserAsStaff(ctx context.Context, input dto.ExistingUserStaffInput) (*dto.StaffRegistrationOutput, error)
	CreateSuperUser(ctx context.Context, input dto.StaffRegistrationInput) (*dto.StaffRegistrationOutput, error)
	RegisterOrganisationAdmin(ctx context.Context, input dto.StaffRegistrationInput) (*dto.StaffRegistrationOutput, error)
	ClientSignUp(ctx context.Context, input *dto.ClientSelfSignUp) (*dto.ClientRegistrationOutput, error)
}

IRegisterUser interface defines a method signature that is used to register users

type IRequestPinReset

type IRequestPinReset interface {
	RequestPINReset(ctx context.Context, username string, flavour feedlib.Flavour) (string, error)
}

IRequestPinReset defines a method signature that is used to request a pin reset

type ISearchCaregiverUser

type ISearchCaregiverUser interface {
	SearchCaregiverUser(ctx context.Context, searchParameter string) ([]*domain.CaregiverProfile, error)
}

ISearchCaregiverUser interface contain the method used to search for caregiver(s) from the database

type ISearchClientUser

type ISearchClientUser interface {
	SearchClientUser(ctx context.Context, searchParameter string) ([]*domain.ClientProfile, error)
}

ISearchClientUser interface contain the method used to retrieve client(s) from the database

type ISearchStaffUser

type ISearchStaffUser interface {
	SearchStaffUser(ctx context.Context, searchParameter string) ([]*domain.StaffProfile, error)
}

ISearchStaffUser interface contain the method used to retrieve staff(s) from the database

type ISetNickName

type ISetNickName interface {
	SetNickName(ctx context.Context, userID string, nickname string) (bool, error)
}

ISetNickName is used change and or set user nickname

type ISetUserPIN

type ISetUserPIN interface {
	SetUserPIN(ctx context.Context, input dto.PINInput) (bool, error)
}

ISetUserPIN is an interface that contains all the user use cases for pins

type IUserFacility

type IUserFacility interface {
	// SetDefaultFacility enables a client or a staff user to set their default facility from
	// a list of their assigned facilities
	SetStaffDefaultFacility(ctx context.Context, staffID string, facilityID string) (*domain.Facility, error)
	SetClientDefaultFacility(ctx context.Context, clientID string, facilityID string) (*domain.Facility, error)
	AddFacilitiesToStaffProfile(ctx context.Context, staffID string, facilities []string) (bool, error)
	RemoveFacilitiesFromClientProfile(ctx context.Context, clientID string, facilities []string) (bool, error)
	RemoveFacilitiesFromStaffProfile(ctx context.Context, staffID string, facilities []string) (bool, error)
	GetStaffFacilities(ctx context.Context, staffID string, paginationInput dto.PaginationsInput) (*dto.FacilityOutputPage, error)
	GetClientFacilities(ctx context.Context, clientID string, paginationInput dto.PaginationsInput) (*dto.FacilityOutputPage, error)
}

IUserFacility interface represents the user facility usecases

type IUserProfile

type IUserProfile interface {
	GetUserProfile(ctx context.Context, userID string) (*domain.User, error)
	GetStaffProfile(ctx context.Context, userID, programID string) (*domain.StaffProfile, error)
	GetClientProfileByCCCNumber(ctx context.Context, cccNumber string) (*domain.ClientProfile, error)
	CheckSuperUserExists(ctx context.Context) (bool, error)
	CheckIfPhoneExists(ctx context.Context, phoneNumber string) (bool, error)
}

IUserProfile interface contains the methods to retrieve a user profile

type IVerifyPIN

type IVerifyPIN interface {
	VerifyPIN(ctx context.Context, userID string, flavour feedlib.Flavour, pin string) (bool, error)
}

IVerifyPIN is used e.g to check the PIN when accessing sensitive content

type UpdateUserProfile

type UpdateUserProfile interface {
	UpdateUserProfile(ctx context.Context, userID string, cccNumber *string, username *string, phoneNumber *string, programID string, flavour feedlib.Flavour, email *string) (bool, error)
	UpdateOrganisationAdminPermission(ctx context.Context, staffID string, isOrganisationAdmin bool) (bool, error)
}

UpdateUserProfile contains the method signature that is used to update user profile

type UseCasesUserImpl

UseCasesUserImpl represents user implementation object

func NewUseCasesUserImpl

NewUseCasesUserImpl returns a new user service

func (*UseCasesUserImpl) AddFacilitiesToClientProfile

func (us *UseCasesUserImpl) AddFacilitiesToClientProfile(ctx context.Context, clientID string, facilities []string) (bool, error)

AddFacilitiesToClientProfile updates the client facility list

func (*UseCasesUserImpl) AddFacilitiesToStaffProfile

func (us *UseCasesUserImpl) AddFacilitiesToStaffProfile(ctx context.Context, staffID string, facilities []string) (bool, error)

AddFacilitiesToStaffProfile updates the staff facility list

func (*UseCasesUserImpl) AssignCaregiver

func (us *UseCasesUserImpl) AssignCaregiver(ctx context.Context, input dto.ClientCaregiverInput) (bool, error)

AssignCaregiver is used to assign a caregiver to a client

func (*UseCasesUserImpl) CheckIdentifierExists

func (us *UseCasesUserImpl) CheckIdentifierExists(ctx context.Context, identifierType enums.UserIdentifierType, identifierValue string) (bool, error)

CheckIdentifierExists checks whether an identifier of a certain type and value exists Used to validate uniqueness and prevent duplicates

func (*UseCasesUserImpl) CheckIfPhoneExists

func (us *UseCasesUserImpl) CheckIfPhoneExists(ctx context.Context, phoneNumber string) (bool, error)

CheckIfPhoneExists checks whether a user (client or staff) being registered to a program has a unique phone number within the organisation

func (*UseCasesUserImpl) CheckSuperUserExists

func (us *UseCasesUserImpl) CheckSuperUserExists(ctx context.Context) (bool, error)

CheckSuperUserExists returns true if a superuser exists

func (*UseCasesUserImpl) ClientSignUp

ClientSignUp method is used to register clients who are self registering themselves in myCareHub

func (*UseCasesUserImpl) CompleteOnboardingTour

func (us *UseCasesUserImpl) CompleteOnboardingTour(ctx context.Context, userID string, flavour feedlib.Flavour) (bool, error)

CompleteOnboardingTour is used to complete the onboarding tour for first time users. When a new user is set up, their field `pinChangeRequired` is set to true, this will inform the front end to redirect the new user through the process of setting a new pin, accepting terms and setting security questions. After all this is done, the field will be set to false. It will enable the user to be directed to the login page when they log in again.

func (*UseCasesUserImpl) ConsentToAClientCaregiver

func (us *UseCasesUserImpl) ConsentToAClientCaregiver(ctx context.Context, clientID string, caregiverID string, consent enums.ConsentState) (bool, error)

ConsentToAClientCaregiver is used to mark whether the client has acknowledged to having a certain caregiver assigned to them

func (*UseCasesUserImpl) ConsentToManagingClient

func (us *UseCasesUserImpl) ConsentToManagingClient(ctx context.Context, caregiverID string, clientID string, consent enums.ConsentState) (bool, error)

ConsentToManagingClient is used to update caregiver as having consented to offer their service to a caregiver

func (*UseCasesUserImpl) CreateSuperUser

CreateSuperUser is used to register the initial user of the application

func (*UseCasesUserImpl) DeleteClientProfile

func (us *UseCasesUserImpl) DeleteClientProfile(ctx context.Context, clientID string) (bool, error)

DeleteClientProfile gives the client an option to choose to withdraw from the app by withdrawing their consent. their client profile will be deleted

func (*UseCasesUserImpl) FetchContactOrganisations

func (us *UseCasesUserImpl) FetchContactOrganisations(ctx context.Context, phoneNumber string) ([]*domain.Organisation, error)

FetchContactOrganisations fetches organisations associated with a provided phone number Provides the organisation options used during login

TODO: returned errors(verbose/informative)

func (*UseCasesUserImpl) GenerateTemporaryPin

func (us *UseCasesUserImpl) GenerateTemporaryPin(ctx context.Context, userID string, flavour feedlib.Flavour) (string, error)

GenerateTemporaryPin generates a temporary user pin and invalidates the previous user pins

func (*UseCasesUserImpl) GetCaregiverManagedClients

func (us *UseCasesUserImpl) GetCaregiverManagedClients(ctx context.Context, userID string, input dto.PaginationsInput) (*dto.ManagedClientOutputPage, error)

GetCaregiverManagedClients lists clients who are managed by the caregivers The clients should have given their consent to be managed by the caregivers

func (*UseCasesUserImpl) GetClientFacilities

func (us *UseCasesUserImpl) GetClientFacilities(ctx context.Context, clientID string, paginationInput dto.PaginationsInput) (*dto.FacilityOutputPage, error)

GetClientFacilities returns a list of facilities that a client belongs to

func (*UseCasesUserImpl) GetClientProfileByCCCNumber

func (us *UseCasesUserImpl) GetClientProfileByCCCNumber(ctx context.Context, cccNumber string) (*domain.ClientProfile, error)

GetClientProfileByCCCNumber is used to get a client profile by their CCC number

func (*UseCasesUserImpl) GetStaffFacilities

func (us *UseCasesUserImpl) GetStaffFacilities(ctx context.Context, staffID string, paginationInput dto.PaginationsInput) (*dto.FacilityOutputPage, error)

GetStaffFacilities returns a list of facilities that a staff belongs to

func (*UseCasesUserImpl) GetStaffProfile

func (us *UseCasesUserImpl) GetStaffProfile(ctx context.Context, userID, programID string) (*domain.StaffProfile, error)

GetStaffProfile returns a staff profile given the user ID and the program ID that they have a staff profile

func (*UseCasesUserImpl) GetUserProfile

func (us *UseCasesUserImpl) GetUserProfile(ctx context.Context, userID string) (*domain.User, error)

GetUserProfile returns a user profile given the user ID

func (*UseCasesUserImpl) InviteUser

func (us *UseCasesUserImpl) InviteUser(ctx context.Context, userID string, phoneNumber string, flavour feedlib.Flavour, reinvite bool) (bool, error)

InviteUser is used to invite a user to the application. The invite link that is sent to the user will open the app if installed OR goes to the store if not installed.

func (*UseCasesUserImpl) ListClientsCaregivers

func (us *UseCasesUserImpl) ListClientsCaregivers(ctx context.Context, clientID string, pagination *dto.PaginationsInput) (*dto.CaregiverProfileOutputPage, error)

ListClientsCaregivers returns a list of caregivers for a client

func (*UseCasesUserImpl) Login

func (us *UseCasesUserImpl) Login(ctx context.Context, input *dto.LoginInput) (*dto.LoginResponse, bool)

Login is used to login the user into the application

func (*UseCasesUserImpl) NotifyNewFacilityAdded

func (us *UseCasesUserImpl) NotifyNewFacilityAdded(ctx context.Context, assignedFacilities []string, userProfile *domain.User) error

NotifyNewFacilityAdded sends an SMS notification to the user when a new facility/facilities is/are assigned to them

func (*UseCasesUserImpl) RefreshToken

func (us *UseCasesUserImpl) RefreshToken(ctx context.Context, userID string) (*dto.AuthCredentials, error)

RefreshToken takes a user ID and creates a custom Firebase refresh token. It then tries to fetch an ID token and returns auth credentials if successful

func (*UseCasesUserImpl) Register

func (us *UseCasesUserImpl) Register(ctx context.Context, payload *dto.SignUpPayload, selfRegistered bool) (*dto.ClientRegistrationOutput, error)

Register method provides a 'registration agnostic' way of client registration i.e it can be used to register a client in myCareHub who have registered themselves or clients who have been registered by a healthcare worker through an invitation

func (*UseCasesUserImpl) RegisterCaregiver

func (us *UseCasesUserImpl) RegisterCaregiver(ctx context.Context, input dto.CaregiverInput) (*domain.CaregiverProfile, error)

RegisterCaregiver is used to register a caregiver

func (*UseCasesUserImpl) RegisterClient

RegisterClient is used to register a client on our application. When a client is registered, their corresponding user profile, contacts and identifiers are created.

func (*UseCasesUserImpl) RegisterClientAsCaregiver

func (us *UseCasesUserImpl) RegisterClientAsCaregiver(ctx context.Context, clientID string, caregiverNumber string) (*domain.CaregiverProfile, error)

RegisterClientAsCaregiver adds a caregiver profile to a client

func (*UseCasesUserImpl) RegisterExistingUserAsCaregiver

func (us *UseCasesUserImpl) RegisterExistingUserAsCaregiver(ctx context.Context, userID string, caregiverNumber string) (*domain.CaregiverProfile, error)

RegisterExistingUserAsCaregiver is used to create a caregiver profile to an already existing user

func (*UseCasesUserImpl) RegisterExistingUserAsClient

func (us *UseCasesUserImpl) RegisterExistingUserAsClient(ctx context.Context, input dto.ExistingUserClientInput) (*dto.ClientRegistrationOutput, error)

RegisterExistingUserAsClient is used to register an existing user as a client. The trigger to this flow is: Search for an existing user. May be staff or client. From the search results, you can then proceed to register the user as a client if they are not already a client in that program.

func (*UseCasesUserImpl) RegisterExistingUserAsStaff

func (us *UseCasesUserImpl) RegisterExistingUserAsStaff(ctx context.Context, input dto.ExistingUserStaffInput) (*dto.StaffRegistrationOutput, error)

RegisterExistingUserAsStaff is used create a new staff profile for a user in a program

func (*UseCasesUserImpl) RegisterOrganisationAdmin

func (us *UseCasesUserImpl) RegisterOrganisationAdmin(ctx context.Context, input dto.StaffRegistrationInput) (*dto.StaffRegistrationOutput, error)

RegisterOrganisationAdmin is used to register an organisation admin who can create other staff users in their organization

func (*UseCasesUserImpl) RegisterPushToken

func (us *UseCasesUserImpl) RegisterPushToken(ctx context.Context, token string) (bool, error)

RegisterPushToken adds a new push token in the users profile

func (*UseCasesUserImpl) RegisterStaff

RegisterStaff is used to register a staff user in mycarehub

func (*UseCasesUserImpl) RegisterStaffProfile

RegisterStaffProfile is a helper function for staff registration. It is used when registering staff in the same organisation as the logged in user, or a different organisation

func (*UseCasesUserImpl) RegisteredFacilityPatients

func (us *UseCasesUserImpl) RegisteredFacilityPatients(ctx context.Context, input dto.PatientSyncPayload) (*dto.PatientSyncResponse, error)

RegisteredFacilityPatients checks for newly registered clients at a facility from a given time i,e sync time. It is useful to fetch all patient information from Kenya EMR and sync it to mycarehub

func (*UseCasesUserImpl) RemoveFacilitiesFromClientProfile

func (us *UseCasesUserImpl) RemoveFacilitiesFromClientProfile(ctx context.Context, clientID string, facilities []string) (bool, error)

RemoveFacilitiesFromClientProfile updates the client facility list to remove assigned facilities except the default facility

func (*UseCasesUserImpl) RemoveFacilitiesFromStaffProfile

func (us *UseCasesUserImpl) RemoveFacilitiesFromStaffProfile(ctx context.Context, staffID string, facilities []string) (bool, error)

RemoveFacilitiesFromStaffProfile updates the staff facility list to remove assigned facilities except the default facility

func (*UseCasesUserImpl) RequestPINReset

func (us *UseCasesUserImpl) RequestPINReset(ctx context.Context, username string, flavour feedlib.Flavour) (string, error)

RequestPINReset sends an OTP to the phone number that is provided. It begins the workflow of resetting a pin

func (*UseCasesUserImpl) ResetPIN

func (us *UseCasesUserImpl) ResetPIN(ctx context.Context, input dto.UserResetPinInput) (bool, error)

ResetPIN resets the user's PIN when they start the reset pin process. this is a user driven request ensure phone/flavor is verified ensure the OTP for the phone is valid ensure the security questions were answered correctly ensure to invlidate the old PIN save new pin to db and ensure it is not duplicate for the same user return true if the pin was reset successfully

func (*UseCasesUserImpl) SearchCaregiverUser

func (us *UseCasesUserImpl) SearchCaregiverUser(ctx context.Context, searchParameter string) ([]*domain.CaregiverProfile, error)

SearchCaregiverUser is used to search for a caregiver user

func (*UseCasesUserImpl) SearchClientUser

func (us *UseCasesUserImpl) SearchClientUser(ctx context.Context, searchParameter string) ([]*domain.ClientProfile, error)

SearchClientUser is used to search for a client member(s) using either of their phonenumber, username or CCC number.

func (*UseCasesUserImpl) SearchStaffUser

func (us *UseCasesUserImpl) SearchStaffUser(ctx context.Context, searchParameter string) ([]*domain.StaffProfile, error)

SearchStaffUser is used to search for staff member(s) using either their phonenumber, username or staff number. It does this by matching of the strings based on comparison with the search Parameter

func (*UseCasesUserImpl) SetCaregiverCurrentClient

func (us *UseCasesUserImpl) SetCaregiverCurrentClient(ctx context.Context, clientID string) (*domain.ClientProfile, error)

SetCaregiverCurrentClient sets the default client profile. The client should be among the list of clients they manage. The client should have given consent to be managed by the caregiver The client implicitly dictates the current organization and current program for the caregiver

func (*UseCasesUserImpl) SetCaregiverCurrentFacility

func (us *UseCasesUserImpl) SetCaregiverCurrentFacility(ctx context.Context, clientID string, facilityID string) (*domain.Facility, error)

SetCaregiverCurrentFacility sets the current facility on t the caregiver profile

func (*UseCasesUserImpl) SetClientDefaultFacility

func (us *UseCasesUserImpl) SetClientDefaultFacility(ctx context.Context, clientID string, facilityID string) (*domain.Facility, error)

SetClientDefaultFacility enables a client to set the default facility

func (*UseCasesUserImpl) SetNickName

func (us *UseCasesUserImpl) SetNickName(ctx context.Context, userID string, nickname string) (bool, error)

SetNickName is used to set the user's nickname. The nickname is also the username

func (*UseCasesUserImpl) SetStaffDefaultFacility

func (us *UseCasesUserImpl) SetStaffDefaultFacility(ctx context.Context, staffID string, facilityID string) (*domain.Facility, error)

SetStaffDefaultFacility enables a staff to set the default facility

func (*UseCasesUserImpl) SetUserPIN

func (us *UseCasesUserImpl) SetUserPIN(ctx context.Context, input dto.PINInput) (bool, error)

SetUserPIN is used to set the user's PIN

func (*UseCasesUserImpl) TransferClientToFacility

func (us *UseCasesUserImpl) TransferClientToFacility(ctx context.Context, clientID *string, facilityID *string) (bool, error)

TransferClientToFacility moves a client to a new facility A staff member should search for a client by their id and then transfer them to a facility The client profile is updated with the new facility The dependencies that relate to facility are updated with the current facility information The dependencies include: - All pending service requests (they should be updated to the new facility)

func (*UseCasesUserImpl) UpdateOrganisationAdminPermission

func (us *UseCasesUserImpl) UpdateOrganisationAdminPermission(ctx context.Context, staffID string, isOrganisationAdmin bool) (bool, error)

UpdateOrganisationAdminPermission sets or resets a staff permission for organisation administration

func (*UseCasesUserImpl) UpdateUserProfile

func (us *UseCasesUserImpl) UpdateUserProfile(ctx context.Context, userID string, cccNumber *string, username *string, phoneNumber *string, programID string, flavour feedlib.Flavour, email *string) (bool, error)

UpdateUserProfile is used to update a user's informmation such as username, phone and CCC number(on need basis)

func (*UseCasesUserImpl) VerifyPIN

func (us *UseCasesUserImpl) VerifyPIN(ctx context.Context, userID string, flavour feedlib.Flavour, pin string) (bool, error)

VerifyPIN is used to verify the user's PIN when they are acessing e.g. sensitive information such as their health diary

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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