diff --git a/pkg/mycarehub/usecases/facility/facility.go b/pkg/mycarehub/usecases/facility/facility.go index 9075a8ab..1f8ce4fe 100644 --- a/pkg/mycarehub/usecases/facility/facility.go +++ b/pkg/mycarehub/usecases/facility/facility.go @@ -140,26 +140,12 @@ func (f *UseCaseFacilityImpl) RetrieveFacility(ctx context.Context, id *string, if id == nil { return nil, fmt.Errorf("facility id cannot be nil") } - output, err := f.Query.RetrieveFacility(ctx, id, isActive) + output, err := f.HealthCRM.GetCRMFacilityByID(ctx, *id) if err != nil { helpers.ReportErrorToSentry(err) return nil, err } - for _, identifier := range output.Identifiers { - if identifier.Type == enums.FacilityIdentifierTypeHealthCRM { - // Get facility Business hours - facilityObj, err := f.HealthCRM.GetCRMFacilityByID(ctx, identifier.Value) - if err != nil { - helpers.ReportErrorToSentry(err) - return nil, err - } - - output.Services = facilityObj.Services - output.BusinessHours = facilityObj.BusinessHours - } - } - return output, nil } diff --git a/pkg/mycarehub/usecases/facility/facility_unit_test.go b/pkg/mycarehub/usecases/facility/facility_unit_test.go index ff6d4a11..904e1984 100644 --- a/pkg/mycarehub/usecases/facility/facility_unit_test.go +++ b/pkg/mycarehub/usecases/facility/facility_unit_test.go @@ -64,20 +64,9 @@ func TestUseCaseFacilityImpl_RetrieveFacility_Unittest(t *testing.T) { }, wantErr: true, }, - { - name: "Sad case - unable to get facility business hours", - args: args{ - ctx: ctx, - id: &ID, - isActive: false, - }, - wantErr: true, - }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - fakeFacility := mock.NewFacilityUsecaseMock() - fakeDB := pgMock.NewPostgresMock() fakePubsub := pubsubMock.NewPubsubServiceMock() fakeExt := extensionMock.NewFakeExtension() @@ -86,19 +75,9 @@ func TestUseCaseFacilityImpl_RetrieveFacility_Unittest(t *testing.T) { f := facility.NewFacilityUsecase(fakeDB, fakeDB, fakeDB, fakeDB, fakePubsub, fakeExt, fakeHealthCRM, fakeServiceRequest) - if tt.name == "Sad case - no id" { - fakeFacility.MockRetrieveFacilityFn = func(ctx context.Context, id *string, isActive bool) (*domain.Facility, error) { - return nil, fmt.Errorf("an error occurred while retrieving facility") - } - } if tt.name == "Sad case - unable to retrieve facility by id" { - fakeDB.MockRetrieveFacilityFn = func(ctx context.Context, id *string, isActive bool) (*domain.Facility, error) { - return nil, fmt.Errorf("error") - } - } - if tt.name == "Sad case - unable to get facility business hours" { fakeHealthCRM.MockGetCRMFacilityByIDFn = func(ctx context.Context, id string) (*domain.Facility, error) { - return nil, fmt.Errorf("error") + return nil, errors.New("error") } }