Skip to content

Commit

Permalink
fix: remove dependency between pubsub and ocl usecase
Browse files Browse the repository at this point in the history
  • Loading branch information
Salaton committed Feb 16, 2023
1 parent 7474228 commit 9bf636a
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 22 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
go get github.com/ory/go-acc
go get golang.org/x/oauth2/internal
go get google.golang.org/api/transport/http
go get -d github.com/99designs/gqlgen@v0.17.24
go get google.golang.org/grpc
go get google.golang.org/grpc/internal/transport
go get cloud.google.com/go/monitoring/apiv3/v2
Expand Down
2 changes: 1 addition & 1 deletion pkg/clinical/application/dto/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type UserInfo struct {
UID string `json:"rawId,omitempty"`
}

// ErrorDetails contains more details about the error that occured while making a REST API call to FHIR servers
// ErrorDetails contains more details about the error that occurred while making a REST API call to FHIR servers
type ErrorDetails struct {
Text string `json:"text"`
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/clinical/domain/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ type Extension struct {
ValueBase64Binary string `json:"valueBase64Binary,omitempty"`
ValueInstant string `json:"valueInstant,omitempty"`
ValueString string `json:"valueString,omitempty"`
ValueUri string `json:"valueUri,omitempty"`
ValueURI string `json:"valueURI,omitempty"`
ValueDate string `json:"valueDate,omitempty"`
ValueDateTime string `json:"valueDateTime,omitempty"`
ValueTime string `json:"valueTime,omitempty"`
ValueCode string `json:"valueCode,omitempty"`
ValueOid string `json:"valueOid,omitempty"`
ValueUuid string `json:"valueUuid,omitempty"`
ValueId string `json:"valueId,omitempty"`
ValueUUID string `json:"valueUUID,omitempty"`
ValueID string `json:"valueID,omitempty"`
ValueUnsignedInt int `json:"valueUnsignedInt,omitempty"`
ValuePositiveInt int `json:"valuePositiveInt,omitempty"`
ValueMarkdown string `json:"valueMarkdown,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/clinical/domain/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package domain

// Meta field in FHIR is used to capture metadata about a resource
type Meta struct {
VersionId string `json:"versionId,omitempty"`
VersionID string `json:"versionID,omitempty"`
LastUpdated string `json:"lastUpdated,omitempty"`
Source string `json:"source,omitempty"`
Profile []string `json:"profile,omitempty"`
Expand Down
4 changes: 0 additions & 4 deletions pkg/clinical/infrastructure/services/pubsub/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/savannahghi/clinical/pkg/clinical/application/extensions"
"github.com/savannahghi/clinical/pkg/clinical/infrastructure"
"github.com/savannahghi/clinical/pkg/clinical/usecases/clinical"
"github.com/savannahghi/clinical/pkg/clinical/usecases/ocl"
"github.com/savannahghi/serverutils"
)

Expand Down Expand Up @@ -60,7 +59,6 @@ type ServicePubSubMessaging struct {
baseExt extensions.BaseExtension
infra infrastructure.Infrastructure
clinical clinical.UseCasesClinical
ocl ocl.UseCasesOCL
}

// NewServicePubSubMessaging returns a new instance of pubsub
Expand All @@ -69,14 +67,12 @@ func NewServicePubSubMessaging(
baseExt extensions.BaseExtension,
infra infrastructure.Infrastructure,
clinical clinical.UseCasesClinical,
ocl ocl.UseCasesOCL,
) (*ServicePubSubMessaging, error) {
s := &ServicePubSubMessaging{
client: client,
baseExt: baseExt,
infra: infra,
clinical: clinical,
ocl: ocl,
}

ctx := context.Background()
Expand Down
2 changes: 0 additions & 2 deletions pkg/clinical/infrastructure/services/pubsub/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@ func InitializeTestPubSub(t *testing.T) (*pubsubmessaging.ServicePubSubMessaging

infrastructure := infrastructure.NewInfrastructureInteractor(baseExtension, fhir, ocl)
usecases := usecases.NewUsecasesInteractor(infrastructure)
oclUseCase := usecases.UseCasesOCL
pubSub, err := pubsubmessaging.NewServicePubSubMessaging(
pubSubClient,
baseExtension,
infrastructure,
usecases,
oclUseCase,
)
if err != nil {
return nil, fmt.Errorf("failed to initialize pubsub messaging service: %w", err)
Expand Down
20 changes: 10 additions & 10 deletions pkg/clinical/infrastructure/services/pubsub/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/savannahghi/clinical/pkg/clinical/application/common"
"github.com/savannahghi/clinical/pkg/clinical/application/dto"
"github.com/savannahghi/clinical/pkg/clinical/domain"
"github.com/savannahghi/clinical/pkg/clinical/usecases/ocl"
"github.com/savannahghi/clinical/pkg/clinical/infrastructure/services/openconceptlab"
"github.com/savannahghi/errorcodeutil"
"github.com/savannahghi/scalarutils"
"github.com/savannahghi/serverutils"
Expand Down Expand Up @@ -286,7 +286,7 @@ func (ps ServicePubSubMessaging) ComposeTestResultInput(ctx context.Context, inp
}
patientName = *patient.PatientRecord.Name[0].Given[0]

observationConcept, err := getCIELConcept(ctx, ps.ocl, *input.ConceptID)
observationConcept, err := getCIELConcept(ctx, ps.infra.OpenConceptLab, *input.ConceptID)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -351,7 +351,7 @@ func (ps ServicePubSubMessaging) ComposeTestResultInput(ctx context.Context, inp

// ComposeVitalsInput composes a vitals observation from data received
func (ps ServicePubSubMessaging) ComposeVitalsInput(ctx context.Context, input dto.CreateVitalSignPubSubMessage) (*domain.FHIRObservationInput, error) {
vitalsConcept, err := getCIELConcept(ctx, ps.ocl, *input.ConceptID)
vitalsConcept, err := getCIELConcept(ctx, ps.infra.OpenConceptLab, *input.ConceptID)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -421,12 +421,12 @@ func (ps ServicePubSubMessaging) ComposeVitalsInput(ctx context.Context, input d

// ComposeMedicationStatementInput composes a medication statement input from received data
func (ps ServicePubSubMessaging) ComposeMedicationStatementInput(ctx context.Context, input dto.CreateMedicationPubSubMessage) (*domain.FHIRMedicationStatementInput, error) {
medicationConcept, err := getCIELConcept(ctx, ps.ocl, *input.ConceptID)
medicationConcept, err := getCIELConcept(ctx, ps.infra.OpenConceptLab, *input.ConceptID)
if err != nil {
return nil, err
}

drugConcept, err := getCIELConcept(ctx, ps.ocl, *input.Drug.ConceptID)
drugConcept, err := getCIELConcept(ctx, ps.infra.OpenConceptLab, *input.Drug.ConceptID)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -542,7 +542,7 @@ func (ps ServicePubSubMessaging) ComposeAllergyIntoleranceInput(ctx context.Cont
Display: patientName,
}

allergenConcept, err := getCIELConcept(ctx, ps.ocl, *input.ConceptID)
allergenConcept, err := getCIELConcept(ctx, ps.infra.OpenConceptLab, *input.ConceptID)
if err != nil {
return nil, err
}
Expand All @@ -567,13 +567,13 @@ func (ps ServicePubSubMessaging) ComposeAllergyIntoleranceInput(ctx context.Cont
// if no reaction use unknown
var manifestationConcept *domain.Concept
if input.Reaction.ConceptID != nil {
manifestationConcept, err = getCIELConcept(ctx, ps.ocl, *input.Reaction.ConceptID)
manifestationConcept, err = getCIELConcept(ctx, ps.infra.OpenConceptLab, *input.Reaction.ConceptID)
if err != nil {
return nil, err
}

} else {
manifestationConcept, err = getCIELConcept(ctx, ps.ocl, unknownConceptID)
manifestationConcept, err = getCIELConcept(ctx, ps.infra.OpenConceptLab, unknownConceptID)
if err != nil {
return nil, err
}
Expand All @@ -595,7 +595,7 @@ func (ps ServicePubSubMessaging) ComposeAllergyIntoleranceInput(ctx context.Cont
reaction.Manifestation = append(reaction.Manifestation, manifestation)

if input.Severity.ConceptID != nil {
severityConcept, err := getCIELConcept(ctx, ps.ocl, *input.Severity.ConceptID)
severityConcept, err := getCIELConcept(ctx, ps.infra.OpenConceptLab, *input.Severity.ConceptID)
if err != nil {
return nil, err
}
Expand All @@ -609,7 +609,7 @@ func (ps ServicePubSubMessaging) ComposeAllergyIntoleranceInput(ctx context.Cont
return allergy, nil
}

func getCIELConcept(ctx context.Context, ocl ocl.UseCasesOCL, conceptID string) (*domain.Concept, error) {
func getCIELConcept(ctx context.Context, ocl openconceptlab.ServiceOCL, conceptID string) (*domain.Concept, error) {
response, err := ocl.GetConcept(
ctx,
"CIEL",
Expand Down
2 changes: 1 addition & 1 deletion pkg/clinical/presentation/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func Router(ctx context.Context) (*mux.Router, error) {
usecases := usecases.NewUsecasesInteractor(infrastructure)
h := rest.NewPresentationHandlers(usecases)

pubSub, err := pubsubmessaging.NewServicePubSubMessaging(pubSubClient, baseExtension, infrastructure, usecases, ocl)
pubSub, err := pubsubmessaging.NewServicePubSubMessaging(pubSubClient, baseExtension, infrastructure, usecases)
if err != nil {
return nil, fmt.Errorf("failed to initialize pubsub messaging service: %v", err)
}
Expand Down

0 comments on commit 9bf636a

Please sign in to comment.