rest

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: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizationSession

type AuthorizationSession struct {
	Page           string
	User           domain.User
	Program        domain.Program
	Facility       domain.Facility
	QueryParams    url.Values
	LoggedInUserID string
}

AuthorizationSession is an object that represents a session that helps in decision making when logging in with OAuth

type MyCareHubHandlersInterfaces

type MyCareHubHandlersInterfaces interface {
	VerifyOTP() http.HandlerFunc
	LoginByPhone() http.HandlerFunc
	VerifySecurityQuestions() http.HandlerFunc
	VerifyPhone() http.HandlerFunc
	SendOTP() http.HandlerFunc
	RequestPINReset() http.HandlerFunc
	SendRetryOTP() http.HandlerFunc
	GetUserRespondedSecurityQuestions() http.HandlerFunc
	ResetPIN() http.HandlerFunc
	RefreshToken() http.HandlerFunc
	GetClientHealthDiaryEntries() http.HandlerFunc
	RegisteredFacilityPatients() http.HandlerFunc
	ServiceRequests() http.HandlerFunc
	CreateOrUpdateKenyaEMRAppointments() http.HandlerFunc
	CreatePinResetServiceRequest() http.HandlerFunc
	AddPatientsRecords() http.HandlerFunc
	SyncFacilities() http.HandlerFunc
	GetServices() http.HandlerFunc
	AppointmentsServiceRequests() http.HandlerFunc
	GetAllScreeningTools() http.HandlerFunc
	// DeleteUser() http.HandlerFunc
	FetchContactOrganisations() http.HandlerFunc
	Organisations() http.HandlerFunc
	AuthorizeHandler() http.HandlerFunc
	TokenHandler() http.HandlerFunc
	RevokeHandler() http.HandlerFunc
	IntrospectionHandler() http.HandlerFunc
	NotifyHandler() http.HandlerFunc
	ContentHandler() http.HandlerFunc
	ClientSignUp() http.HandlerFunc
}

MyCareHubHandlersInterfaces represents all the REST API logic

func NewMyCareHubHandlersInterfaces

func NewMyCareHubHandlersInterfaces(usecase usecases.MyCareHub, sessionManager SessionManager) MyCareHubHandlersInterfaces

NewMyCareHubHandlersInterfaces initializes a new rest handlers usecase

type MyCareHubHandlersInterfacesImpl

type MyCareHubHandlersInterfacesImpl struct {
	// contains filtered or unexported fields
}

MyCareHubHandlersInterfacesImpl represents the usecase implementation object

func (*MyCareHubHandlersInterfacesImpl) AddPatientsRecords

func (h *MyCareHubHandlersInterfacesImpl) AddPatientsRecords() http.HandlerFunc

AddPatientsRecords handles bulk creation of patient records

func (*MyCareHubHandlersInterfacesImpl) AppointmentsServiceRequests

func (h *MyCareHubHandlersInterfacesImpl) AppointmentsServiceRequests() http.HandlerFunc

AppointmentsServiceRequests is used to check for the oncoming request and routes it to the correct handler. If the method is POST, we update the appointment service request and if it's a GET, we return all the appointment service requests from the last time syncing occurred between the two platforms

func (*MyCareHubHandlersInterfacesImpl) AuthorizeHandler

func (h *MyCareHubHandlersInterfacesImpl) AuthorizeHandler() http.HandlerFunc

AuthorizeHandler contains the OAuth logic for authorization. it follows the following steps: 0. get or create http session 1. Get the client. Determine if its PRO or CONSUMER Login. (Currently supporting PRO) 2. Present the user with the username/PIN login page 3. Present user with program chooser page. 4. Use selected program to retrieve staff profile and add to session 5. Present user with facility chooser page. 6. Add selected facility to session 7. If successful, Initialize an oauth session with the user ID 8. Return success

func (*MyCareHubHandlersInterfacesImpl) ClientSignUp

ClientSignUp is an endpoint meant to be used by clients who are self-onboarding themselves in MCH

func (*MyCareHubHandlersInterfacesImpl) ContentHandler

func (h *MyCareHubHandlersInterfacesImpl) ContentHandler() http.HandlerFunc

ContentHandler is used to fetch content for the landing page

func (*MyCareHubHandlersInterfacesImpl) CreateOrUpdateKenyaEMRAppointments

func (h *MyCareHubHandlersInterfacesImpl) CreateOrUpdateKenyaEMRAppointments() http.HandlerFunc

CreateOrUpdateKenyaEMRAppointments is tha handler used to sync appointments from Kenya EMR The appointment can be a POST, handled as a create or PUT handled as an update to existing appointment

func (*MyCareHubHandlersInterfacesImpl) CreatePinResetServiceRequest

func (h *MyCareHubHandlersInterfacesImpl) CreatePinResetServiceRequest() http.HandlerFunc

CreatePinResetServiceRequest is used to create a "PIN_RESET" service request. This is trigerred when a user has failed loggin in to the app and requests for help. The service request will be viewed by the healthcare worker and either approved/rejected

func (*MyCareHubHandlersInterfacesImpl) FetchContactOrganisations

func (h *MyCareHubHandlersInterfacesImpl) FetchContactOrganisations() http.HandlerFunc

FetchContactOrganisations fetches organisations associated with the provided contact

func (*MyCareHubHandlersInterfacesImpl) GetAllScreeningTools

func (h *MyCareHubHandlersInterfacesImpl) GetAllScreeningTools() http.HandlerFunc

GetAllScreeningTools is an unauthenticated endpoint that returns a list of services

func (*MyCareHubHandlersInterfacesImpl) GetAppointmentServiceRequests

func (h *MyCareHubHandlersInterfacesImpl) GetAppointmentServiceRequests(ctx context.Context, w http.ResponseWriter, r *http.Request)

GetAppointmentServiceRequests handler for syncing red-flags from the my carehub endpoint to Kenya EMR for display

func (*MyCareHubHandlersInterfacesImpl) GetClientHealthDiaryEntries

func (h *MyCareHubHandlersInterfacesImpl) GetClientHealthDiaryEntries() http.HandlerFunc

GetClientHealthDiaryEntries fetches and returns the health diary entries that were recorded in the specified facility.

func (*MyCareHubHandlersInterfacesImpl) GetServiceRequestsForKenyaEMR

func (h *MyCareHubHandlersInterfacesImpl) GetServiceRequestsForKenyaEMR(ctx context.Context, r *http.Request, w http.ResponseWriter)

GetServiceRequestsForKenyaEMR gets all the service requests from MyCareHub

func (*MyCareHubHandlersInterfacesImpl) GetServices

GetServices is an unauthenticated endpoint that returns a list of services

func (*MyCareHubHandlersInterfacesImpl) GetUserRespondedSecurityQuestions

func (h *MyCareHubHandlersInterfacesImpl) GetUserRespondedSecurityQuestions() http.HandlerFunc

GetUserRespondedSecurityQuestions is an unauthenticated endpoint that gets the user id and returns the security questions associated with the user.

func (*MyCareHubHandlersInterfacesImpl) IntrospectionHandler

func (h *MyCareHubHandlersInterfacesImpl) IntrospectionHandler() http.HandlerFunc

IntrospectionHandler returns the content of a given token

func (*MyCareHubHandlersInterfacesImpl) LoginByPhone

LoginByPhone is an unauthenticated endpoint that gets the phonenumber and pin from a user, checks whether they exist, if present, we fetch the pin and if they match, we return the user profile and auth credentials to allow the user to login

func (*MyCareHubHandlersInterfacesImpl) NotifyHandler

NotifyHandler acts as the entry point to the server's push notification (from Matrix) gateway

func (*MyCareHubHandlersInterfacesImpl) Organisations

Organisations lists all organisations

func (*MyCareHubHandlersInterfacesImpl) RefreshToken

RefreshToken is an unauthenticated endpoint that 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 Otherwise, an error is returned

func (*MyCareHubHandlersInterfacesImpl) RegisteredFacilityPatients

func (h *MyCareHubHandlersInterfacesImpl) RegisteredFacilityPatients() http.HandlerFunc

RegisteredFacilityPatients handler for syncing newly registered patients for a facility

func (*MyCareHubHandlersInterfacesImpl) RequestPINReset

func (h *MyCareHubHandlersInterfacesImpl) RequestPINReset() http.HandlerFunc

RequestPINReset exposes an endpoint that takes in a user username and the flavour. It then sends an OTP to the phone number that requests a PIN reset

func (*MyCareHubHandlersInterfacesImpl) ResetPIN

ResetPIN is an unauthenticated endpoint that resets the user's PIN

func (*MyCareHubHandlersInterfacesImpl) RevokeHandler

RevokeHandler expires an existing token which will then no longer be valid

func (*MyCareHubHandlersInterfacesImpl) SendOTP

SendOTP is an unauthenticated endpoint that gets the username and flavour from a user and sends an OTP

func (*MyCareHubHandlersInterfacesImpl) SendRetryOTP

SendRetryOTP is an unauthenticated request that takes in a username generates an OTP and sends the OTP to the phone number of the user

func (*MyCareHubHandlersInterfacesImpl) ServiceRequests

func (h *MyCareHubHandlersInterfacesImpl) ServiceRequests() http.HandlerFunc

ServiceRequests is the endpoint used to sync service requests from MyCareHub to KenyaEMR

func (*MyCareHubHandlersInterfacesImpl) SyncFacilities

func (h *MyCareHubHandlersInterfacesImpl) SyncFacilities() http.HandlerFunc

SyncFacilities is an unauthenticated endpoint that returns a list of facilities that do not have an FHIR organisation ID

func (*MyCareHubHandlersInterfacesImpl) TokenHandler

TokenHandler generates a token for the given client

func (*MyCareHubHandlersInterfacesImpl) UpdateServiceRequests

func (h *MyCareHubHandlersInterfacesImpl) UpdateServiceRequests(ctx context.Context, w http.ResponseWriter, r *http.Request)

UpdateServiceRequests is an endpoint used to update service requests from KenyaEMR to MyCareHub

func (*MyCareHubHandlersInterfacesImpl) VerifyOTP

VerifyOTP is an unauthenticated endpoint that gets the phonenumber and flavour from a user, checks whether the provided otp matches. If they match, return true, otherwise false.

func (*MyCareHubHandlersInterfacesImpl) VerifyPhone

VerifyPhone is an unauthenticated endpoint that does a check on the provided username, performs a check to ascertain whether the user exists. it verifies whether the user also has a phone number where the otp will be sent

func (*MyCareHubHandlersInterfacesImpl) VerifySecurityQuestions

func (h *MyCareHubHandlersInterfacesImpl) VerifySecurityQuestions() http.HandlerFunc

VerifySecurityQuestions get the user ID, question ID and the security question response from the payload and looks up the saved responses to determine whether the answers match to what has been stored. All of them must match. This is a security layer that will be used when a user attempts to reset their pin

type OAuth2Provider

type OAuth2Provider interface {
	NewAuthorizeRequest(ctx context.Context, req *http.Request) (fosite.AuthorizeRequester, error)
	NewAuthorizeResponse(ctx context.Context, requester fosite.AuthorizeRequester, session fosite.Session) (fosite.AuthorizeResponder, error)
	WriteAuthorizeError(ctx context.Context, rw http.ResponseWriter, requester fosite.AuthorizeRequester, err error)
	WriteAuthorizeResponse(ctx context.Context, rw http.ResponseWriter, requester fosite.AuthorizeRequester, responder fosite.AuthorizeResponder)

	NewAccessRequest(ctx context.Context, req *http.Request, session fosite.Session) (fosite.AccessRequester, error)
	NewAccessResponse(ctx context.Context, requester fosite.AccessRequester) (fosite.AccessResponder, error)
	WriteAccessResponse(ctx context.Context, rw http.ResponseWriter, requester fosite.AccessRequester, responder fosite.AccessResponder)
	WriteAccessError(ctx context.Context, rw http.ResponseWriter, requester fosite.AccessRequester, err error)

	NewRevocationRequest(ctx context.Context, r *http.Request) error
	WriteRevocationResponse(ctx context.Context, rw http.ResponseWriter, err error)

	NewIntrospectionRequest(ctx context.Context, r *http.Request, session fosite.Session) (fosite.IntrospectionResponder, error)
	WriteIntrospectionResponse(ctx context.Context, rw http.ResponseWriter, r fosite.IntrospectionResponder)
	WriteIntrospectionError(ctx context.Context, rw http.ResponseWriter, err error)
}

OAuth2Provider is a consumer interface that contains the methods we need from fosite.OAuth2Provider interface

type SessionManager

type SessionManager interface {
	Put(ctx context.Context, key string, val interface{})
	Destroy(ctx context.Context) error
	Exists(ctx context.Context, key string) bool
	GetBytes(ctx context.Context, key string) []byte
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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