Documentation ¶
Index ¶
- type AuthorizationSession
- type MyCareHubHandlersInterfaces
- type MyCareHubHandlersInterfacesImpl
- func (h *MyCareHubHandlersInterfacesImpl) AddPatientsRecords() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) AppointmentsServiceRequests() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) AuthorizeHandler() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) ClientSignUp() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) ContentHandler() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) CreateOrUpdateKenyaEMRAppointments() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) CreatePinResetServiceRequest() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) FetchContactOrganisations() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) GetAllScreeningTools() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) GetAppointmentServiceRequests(ctx context.Context, w http.ResponseWriter, r *http.Request)
- func (h *MyCareHubHandlersInterfacesImpl) GetClientHealthDiaryEntries() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) GetServiceRequestsForKenyaEMR(ctx context.Context, r *http.Request, w http.ResponseWriter)
- func (h *MyCareHubHandlersInterfacesImpl) GetServices() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) GetUserRespondedSecurityQuestions() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) IntrospectionHandler() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) LoginByPhone() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) NotifyHandler() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) Organisations() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) RefreshToken() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) RegisteredFacilityPatients() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) RequestPINReset() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) ResetPIN() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) RevokeHandler() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) SendOTP() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) SendRetryOTP() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) ServiceRequests() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) SyncFacilities() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) TokenHandler() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) UpdateServiceRequests(ctx context.Context, w http.ResponseWriter, r *http.Request)
- func (h *MyCareHubHandlersInterfacesImpl) VerifyOTP() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) VerifyPhone() http.HandlerFunc
- func (h *MyCareHubHandlersInterfacesImpl) VerifySecurityQuestions() http.HandlerFunc
- type OAuth2Provider
- type SessionManager
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 ¶
func (h *MyCareHubHandlersInterfacesImpl) ClientSignUp() http.HandlerFunc
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 ¶
func (h *MyCareHubHandlersInterfacesImpl) GetServices() http.HandlerFunc
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 ¶
func (h *MyCareHubHandlersInterfacesImpl) LoginByPhone() http.HandlerFunc
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 ¶
func (h *MyCareHubHandlersInterfacesImpl) NotifyHandler() http.HandlerFunc
NotifyHandler acts as the entry point to the server's push notification (from Matrix) gateway
func (*MyCareHubHandlersInterfacesImpl) Organisations ¶
func (h *MyCareHubHandlersInterfacesImpl) Organisations() http.HandlerFunc
Organisations lists all organisations
func (*MyCareHubHandlersInterfacesImpl) RefreshToken ¶
func (h *MyCareHubHandlersInterfacesImpl) RefreshToken() http.HandlerFunc
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 ¶
func (h *MyCareHubHandlersInterfacesImpl) ResetPIN() http.HandlerFunc
ResetPIN is an unauthenticated endpoint that resets the user's PIN
func (*MyCareHubHandlersInterfacesImpl) RevokeHandler ¶
func (h *MyCareHubHandlersInterfacesImpl) RevokeHandler() http.HandlerFunc
RevokeHandler expires an existing token which will then no longer be valid
func (*MyCareHubHandlersInterfacesImpl) SendOTP ¶
func (h *MyCareHubHandlersInterfacesImpl) SendOTP() http.HandlerFunc
SendOTP is an unauthenticated endpoint that gets the username and flavour from a user and sends an OTP
func (*MyCareHubHandlersInterfacesImpl) SendRetryOTP ¶
func (h *MyCareHubHandlersInterfacesImpl) SendRetryOTP() http.HandlerFunc
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 ¶
func (h *MyCareHubHandlersInterfacesImpl) TokenHandler() http.HandlerFunc
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 ¶
func (h *MyCareHubHandlersInterfacesImpl) VerifyOTP() http.HandlerFunc
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 ¶
func (h *MyCareHubHandlersInterfacesImpl) VerifyPhone() http.HandlerFunc
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