Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: purge usecase interactor #374

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pkg/clinical/presentation/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/savannahghi/clinical/pkg/clinical/presentation/graph"
"github.com/savannahghi/clinical/pkg/clinical/presentation/graph/generated"
"github.com/savannahghi/clinical/pkg/clinical/presentation/rest"
"github.com/savannahghi/clinical/pkg/clinical/usecases"
"github.com/savannahghi/clinical/pkg/clinical/usecases/clinical"
"github.com/savannahghi/serverutils"
"google.golang.org/api/healthcare/v1"
)
Expand Down Expand Up @@ -122,13 +122,13 @@ func StartServer(

infrastructure := infrastructure.NewInfrastructureInteractor(baseExtension, fhir, ocl, upload, pubsubSvc, advantageSvc)

usecases := usecases.NewUsecasesInteractor(infrastructure)
usecases := clinical.NewUseCasesClinicalImpl(infrastructure)

r := gin.Default()

memoryStore := persist.NewMemoryStore(60 * time.Minute)

SetupRoutes(r, memoryStore, authclient, usecases, infrastructure)
SetupRoutes(r, memoryStore, authclient, *usecases, infrastructure)

addr := fmt.Sprintf(":%d", port)

Expand All @@ -137,7 +137,7 @@ func StartServer(
}
}

func SetupRoutes(r *gin.Engine, cacheStore persist.CacheStore, authclient *authutils.Client, usecases usecases.Interactor, infra infrastructure.Infrastructure) {
func SetupRoutes(r *gin.Engine, cacheStore persist.CacheStore, authclient *authutils.Client, usecases clinical.UseCasesClinicalImpl, infra infrastructure.Infrastructure) {
r.Use(cors.New(cors.Config{
AllowOrigins: ClinicalAllowedOrigins,
AllowMethods: []string{http.MethodPut, http.MethodPatch, http.MethodGet, http.MethodPost, http.MethodDelete, http.MethodOptions},
Expand Down Expand Up @@ -206,7 +206,7 @@ func SetupRoutes(r *gin.Engine, cacheStore persist.CacheStore, authclient *authu
}

// GQLHandler sets up a GraphQL resolver
func GQLHandler(service usecases.Interactor) gin.HandlerFunc {
func GQLHandler(service clinical.UseCasesClinicalImpl) gin.HandlerFunc {
resolver, err := graph.NewResolver(service)
if err != nil {
log.Panicf("failed to start graph resolver: %s", err)
Expand Down
50 changes: 25 additions & 25 deletions pkg/clinical/presentation/graph/clinical.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/clinical/presentation/graph/resolver.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package graph

import (
"github.com/savannahghi/clinical/pkg/clinical/usecases"
"github.com/savannahghi/clinical/pkg/clinical/usecases/clinical"
)

//go:generate go run github.com/99designs/gqlgen

// Resolver wires up the resolvers needed for the clinical services
type Resolver struct {
usecases usecases.Interactor
usecases clinical.UseCasesClinicalImpl
}

// NewResolver initializes a working top leve Resolver that has been initialized
// with all necessary dependencies
func NewResolver(usecases usecases.Interactor) (*Resolver, error) {
func NewResolver(usecases clinical.UseCasesClinicalImpl) (*Resolver, error) {
return &Resolver{
usecases: usecases,
}, nil
Expand Down
6 changes: 3 additions & 3 deletions pkg/clinical/presentation/rest/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/savannahghi/clinical/pkg/clinical/application/utils"
"github.com/savannahghi/clinical/pkg/clinical/domain"
"github.com/savannahghi/clinical/pkg/clinical/infrastructure/services/advantage"
"github.com/savannahghi/clinical/pkg/clinical/usecases"
"github.com/savannahghi/clinical/pkg/clinical/usecases/clinical"
"github.com/savannahghi/errorcodeutil"
"github.com/savannahghi/pubsubtools"
"github.com/savannahghi/serverutils"
Expand All @@ -26,13 +26,13 @@ type BaseExtension interface {

// PresentationHandlersImpl represents the usecase implementation object
type PresentationHandlersImpl struct {
usecases usecases.Interactor
usecases clinical.UseCasesClinicalImpl
baseExt BaseExtension
advantageService advantage.AdvantageService
}

// NewPresentationHandlers initializes a new rest handlers usecase
func NewPresentationHandlers(usecases usecases.Interactor, extension BaseExtension, advantageSvc advantage.AdvantageService) *PresentationHandlersImpl {
func NewPresentationHandlers(usecases clinical.UseCasesClinicalImpl, extension BaseExtension, advantageSvc advantage.AdvantageService) *PresentationHandlersImpl {
return &PresentationHandlersImpl{
usecases: usecases,
baseExt: extension,
Expand Down
6 changes: 3 additions & 3 deletions pkg/clinical/presentation/rest/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
fakePubSubMock "github.com/savannahghi/clinical/pkg/clinical/infrastructure/services/pubsub/mock"
fakeUploadMock "github.com/savannahghi/clinical/pkg/clinical/infrastructure/services/upload/mock"
"github.com/savannahghi/clinical/pkg/clinical/presentation"
"github.com/savannahghi/clinical/pkg/clinical/usecases"
"github.com/savannahghi/clinical/pkg/clinical/usecases/clinical"
"github.com/savannahghi/interserviceclient"
"github.com/savannahghi/pubsubtools"
"github.com/savannahghi/serverutils"
Expand Down Expand Up @@ -259,7 +259,7 @@ func TestPresentationHandlersImpl_ReceivePubSubPushMessage(t *testing.T) {
fakePubSub := fakePubSubMock.NewPubSubServiceMock()
fakeAdvantage := fakeAdvantageMock.NewFakeAdvantageMock()
infra := infrastructure.NewInfrastructureInteractor(fakeExt, fakeFHIR, fakeOCL, fakeUpload, fakePubSub, fakeAdvantage)
usecases := usecases.NewUsecasesInteractor(infra)
usecases := clinical.NewUseCasesClinicalImpl(infra)

if tt.name == "happy case: publish create patient message" {
msg := dto.PatientPubSubMessage{
Expand Down Expand Up @@ -685,7 +685,7 @@ func TestPresentationHandlersImpl_ReceivePubSubPushMessage(t *testing.T) {
req.Header.Add(k, v)
}

presentation.SetupRoutes(engine, testMemoryStore, authclient, usecases, infra)
presentation.SetupRoutes(engine, testMemoryStore, authclient, *usecases, infra)
engine.ServeHTTP(w, req)

resp := w.Result()
Expand Down
Loading
Loading