Skip to content
Open
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
2 changes: 1 addition & 1 deletion appvalidate/challenge.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/tidepool-org/platform/structure"
)

//go:generate mockgen -source=challenge.go -destination=test/challenge_mocks.go -package=test -typed
//go:generate go tool go.uber.org/mock/mockgen -source=challenge.go -destination=test/challenge_mocks.go -package=test -typed

// ChallengeCreate is the expected request body used to create an attestation
// or assertion challenge.
Expand Down
2 changes: 1 addition & 1 deletion appvalidate/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/tidepool-org/platform/errors"
)

//go:generate mockgen -source=repository.go -destination=test/repository_mocks.go -package=test -typed
//go:generate go tool go.uber.org/mock/mockgen -source=repository.go -destination=test/repository_mocks.go -package=test -typed

var (
ErrDuplicateKeyId = errors.New("duplicate key id")
Expand Down
2 changes: 1 addition & 1 deletion auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/tidepool-org/platform/request"
)

//go:generate mockgen -source=auth.go -destination=test/auth_mocks.go -package=test -typed
//go:generate go tool go.uber.org/mock/mockgen -source=auth.go -destination=test/auth_mocks.go -package=test -typed

const (
TidepoolServiceSecretHeaderKey = "X-Tidepool-Service-Secret"
Expand Down
2 changes: 1 addition & 1 deletion auth/providersession/provider_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package providersession

import "github.com/tidepool-org/platform/auth"

//go:generate mockgen -destination=test/provider_session_mocks.go -package=test -typed -mock_names=ProviderSessionClient=MockClient github.com/tidepool-org/platform/auth ProviderSessionClient
//go:generate go tool go.uber.org/mock/mockgen -destination=test/provider_session_mocks.go -package=test -typed -mock_names=ProviderSessionClient=MockClient github.com/tidepool-org/platform/auth ProviderSessionClient

type Client auth.ProviderSessionClient
2 changes: 1 addition & 1 deletion auth/providersession/work/mixin.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/tidepool-org/platform/work"
)

//go:generate mockgen -source=mixin.go -destination=test/mixin_mocks.go -package=test -typed
//go:generate go tool go.uber.org/mock/mockgen -source=mixin.go -destination=test/mixin_mocks.go -package=test -typed

const MetadataKeyProviderSessionID = "providerSessionId"

Expand Down
2 changes: 1 addition & 1 deletion clinics/clinician.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
api "github.com/tidepool-org/clinic/client"
)

func IsPrescriber(clinician *api.Clinician) bool {
func IsPrescriber(clinician *api.ClinicianV1) bool {
if clinician == nil {
return false
}
Expand Down
59 changes: 37 additions & 22 deletions clinics/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@ import (
"net/http"
"net/url"

"github.com/tidepool-org/platform/errors"

"github.com/tidepool-org/platform/pointer"

"github.com/kelseyhightower/envconfig"
clinic "github.com/tidepool-org/clinic/client"
"go.uber.org/fx"

clinic "github.com/tidepool-org/clinic/client"

"github.com/tidepool-org/platform/auth"
"github.com/tidepool-org/platform/errors"
"github.com/tidepool-org/platform/pointer"
)

//go:generate mockgen -source=service.go -destination=test/service_mocks.go -package=test -typed
//go:generate go tool go.uber.org/mock/mockgen -source=service.go -destination=test/service_mocks.go -package=test -typed

const ErrorCodeClinicClientFailure = "clinic-client-failure"

var ClientModule = fx.Provide(NewClient)

type Client interface {
GetClinic(ctx context.Context, clinicID string) (*clinic.Clinic, error)
GetClinician(ctx context.Context, clinicID, clinicianID string) (*clinic.Clinician, error)
GetEHRSettings(ctx context.Context, clinicId string) (*clinic.EHRSettings, error)
SharePatientAccount(ctx context.Context, clinicID, patientID string) (*clinic.Patient, error)
ListEHREnabledClinics(ctx context.Context) ([]clinic.Clinic, error)
GetClinic(ctx context.Context, clinicID string) (*clinic.ClinicV1, error)
GetClinician(ctx context.Context, clinicID, clinicianID string) (*clinic.ClinicianV1, error)
GetEHRSettings(ctx context.Context, clinicId string) (*clinic.EhrSettingsV1, error)
SharePatientAccount(ctx context.Context, clinicID, patientID string) (*clinic.PatientV1, error)
ListEHREnabledClinics(ctx context.Context) ([]clinic.ClinicV1, error)
SyncEHRData(ctx context.Context, clinicID string) error
GetPatients(ctx context.Context, clinicId string, userToken string, params *clinic.ListPatientsParams, injectedParams url.Values) ([]clinic.Patient, error)
GetPatient(ctx context.Context, clinicID, patientID string) (*clinic.Patient, error)
UpdateDeviceIssues(ctx context.Context) error
GetPatients(ctx context.Context, clinicId string, userToken string, params *clinic.ListPatientsParams, injectedParams url.Values) ([]clinic.PatientV1, error)
GetPatient(ctx context.Context, clinicID, patientID string) (*clinic.PatientV1, error)
}

type config struct {
Expand Down Expand Up @@ -75,7 +75,7 @@ func NewClient(authClient auth.ExternalAccessor) (Client, error) {
}, nil
}

func (d *defaultClient) GetClinician(ctx context.Context, clinicID, clinicianID string) (*clinic.Clinician, error) {
func (d *defaultClient) GetClinician(ctx context.Context, clinicID, clinicianID string) (*clinic.ClinicianV1, error) {
response, err := d.httpClient.GetClinicianWithResponse(ctx, clinic.ClinicId(clinicID), clinic.ClinicianId(clinicianID))
if err != nil {
return nil, err
Expand All @@ -93,7 +93,7 @@ func (d *defaultClient) GetClinician(ctx context.Context, clinicID, clinicianID
return response.JSON200, nil
}

func (d *defaultClient) GetClinic(ctx context.Context, clinicID string) (*clinic.Clinic, error) {
func (d *defaultClient) GetClinic(ctx context.Context, clinicID string) (*clinic.ClinicV1, error) {
response, err := d.httpClient.GetClinicWithResponse(ctx, clinic.ClinicId(clinicID))
if err != nil {
return nil, err
Expand All @@ -111,11 +111,11 @@ func (d *defaultClient) GetClinic(ctx context.Context, clinicID string) (*clinic
return response.JSON200, nil
}

func (d *defaultClient) ListEHREnabledClinics(ctx context.Context) ([]clinic.Clinic, error) {
func (d *defaultClient) ListEHREnabledClinics(ctx context.Context) ([]clinic.ClinicV1, error) {
offset := 0
batchSize := 1000

clinics := make([]clinic.Clinic, 0)
clinics := make([]clinic.ClinicV1, 0)
for {
response, err := d.httpClient.ListClinicsWithResponse(ctx, &clinic.ListClinicsParams{
EhrEnabled: pointer.FromBool(true),
Expand Down Expand Up @@ -147,7 +147,7 @@ func (d *defaultClient) ListEHREnabledClinics(ctx context.Context) ([]clinic.Cli
return clinics, nil
}

func (d *defaultClient) GetEHRSettings(ctx context.Context, clinicId string) (*clinic.EHRSettings, error) {
func (d *defaultClient) GetEHRSettings(ctx context.Context, clinicId string) (*clinic.EhrSettingsV1, error) {
response, err := d.httpClient.GetEHRSettingsWithResponse(ctx, clinicId)
if err != nil {
return nil, err
Expand All @@ -162,10 +162,10 @@ func (d *defaultClient) GetEHRSettings(ctx context.Context, clinicId string) (*c
return response.JSON200, nil
}

func (d *defaultClient) SharePatientAccount(ctx context.Context, clinicID, patientID string) (*clinic.Patient, error) {
func (d *defaultClient) SharePatientAccount(ctx context.Context, clinicID, patientID string) (*clinic.PatientV1, error) {
permission := make(map[string]interface{}, 0)
body := clinic.CreatePatientFromUserJSONRequestBody{
Permissions: &clinic.PatientPermissions{
Permissions: &clinic.PatientPermissionsV1{
Note: &permission,
View: &permission,
},
Expand Down Expand Up @@ -203,7 +203,22 @@ func (d *defaultClient) SyncEHRData(ctx context.Context, clinicID string) error
return nil
}

func (d *defaultClient) GetPatient(ctx context.Context, clinicID, patientID string) (*clinic.Patient, error) {
func (d *defaultClient) UpdateDeviceIssues(ctx context.Context) error {
response, err := d.httpClient.UpdateDeviceIssuesWithResponse(ctx)
if err != nil {
return err
}
if response.StatusCode() < http.StatusOK || response.StatusCode() >= http.StatusMultipleChoices {
err = errors.Preparedf(ErrorCodeClinicClientFailure,
"Unexpected status code from clinic service",
"unexpected response status code %v from %v", response.StatusCode(), response.HTTPResponse.Request.URL)
err = errors.WithMeta(err, response.HTTPResponse)
return err
}
return nil
}

func (d *defaultClient) GetPatient(ctx context.Context, clinicID, patientID string) (*clinic.PatientV1, error) {
response, err := d.httpClient.GetPatientWithResponse(ctx, clinic.ClinicId(clinicID), clinic.PatientId(patientID))
if err != nil {
return nil, err
Expand All @@ -218,7 +233,7 @@ func (d *defaultClient) GetPatient(ctx context.Context, clinicID, patientID stri
return response.JSON200, nil
}

func (d *defaultClient) GetPatients(ctx context.Context, clinicId string, userToken string, params *clinic.ListPatientsParams, injectedParams url.Values) ([]clinic.Patient, error) {
func (d *defaultClient) GetPatients(ctx context.Context, clinicId string, userToken string, params *clinic.ListPatientsParams, injectedParams url.Values) ([]clinic.PatientV1, error) {
response, err := d.httpClient.ListPatientsWithResponse(ctx, clinicId, params, func(ctx context.Context, req *http.Request) error {
if len(injectedParams) != 0 {
q := req.URL.Query()
Expand Down
22 changes: 11 additions & 11 deletions clinics/test/clinics.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ import (
"github.com/tidepool-org/platform/test"
)

func NewRandomClinic() api.Clinic {
return api.Clinic{
func NewRandomClinic() api.ClinicV1 {
return api.ClinicV1{
Address: pointer.FromAny(faker.Address().StreetAddress()),
CanMigrate: pointer.FromAny(test.RandomBool()),
City: pointer.FromAny(faker.Address().City()),
ClinicType: pointer.FromAny(test.RandomChoice([]api.ClinicClinicType{api.HealthcareSystem, api.VeterinaryClinic, api.Other})),
ClinicType: pointer.FromAny(test.RandomChoice([]api.ClinicV1ClinicType{api.ClinicV1ClinicTypeHealthcareSystem, api.ClinicV1ClinicTypeVeterinaryClinic, api.ClinicV1ClinicTypeOther})),
Country: pointer.FromAny(faker.Address().Country()),
CreatedTime: pointer.FromAny(test.RandomTime()),
Id: pointer.FromAny(primitive.NewObjectIDFromTimestamp(test.RandomTime()).Hex()),
Name: faker.Company().Name(),
PhoneNumbers: pointer.FromAny([]api.PhoneNumber{{Number: faker.PhoneNumber().PhoneNumber()}}),
PhoneNumbers: pointer.FromAny([]api.PhoneNumberV1{{Number: faker.PhoneNumber().PhoneNumber()}}),
PostalCode: pointer.FromAny(faker.Address().ZipCode()),
PreferredBgUnits: test.RandomChoice([]api.ClinicPreferredBgUnits{api.MgdL, api.MmolL}),
PreferredBgUnits: test.RandomChoice([]api.ClinicV1PreferredBgUnits{api.ClinicV1PreferredBgUnitsMgdL, api.ClinicV1PreferredBgUnitsMmolL}),
ShareCode: pointer.FromAny(faker.RandomString(15)),
State: pointer.FromAny(faker.Address().State()),
Tier: pointer.FromAny(test.RandomChoice([]string{"tier1000", "tier2000"})),
Expand All @@ -31,26 +31,26 @@ func NewRandomClinic() api.Clinic {
}
}

func NewRandomEHRSettings() *api.EHRSettings {
return &api.EHRSettings{
DestinationIds: &api.EHRDestinationIds{
func NewRandomEHRSettings() *api.EhrSettingsV1 {
return &api.EhrSettingsV1{
DestinationIds: &api.EhrDestinationsV1{
Flowsheet: faker.RandomString(16),
Notes: faker.RandomString(16),
Results: faker.RandomString(16),
},
Enabled: true,
MrnIdType: "MRN",
ProcedureCodes: api.EHRProcedureCodes{
ProcedureCodes: api.EhrProceduresV1{
CreateAccount: pointer.FromAny(faker.RandomString(5)),
CreateAccountAndEnableReports: pointer.FromAny(faker.RandomString(5)),
DisableSummaryReports: pointer.FromAny(faker.RandomString(5)),
EnableSummaryReports: pointer.FromAny(faker.RandomString(5)),
},
Provider: "redox",
ScheduledReports: api.ScheduledReports{
ScheduledReports: api.ScheduledReportsV1{
Cadence: api.N14d,
OnUploadEnabled: true,
OnUploadNoteEventType: pointer.FromAny(api.ScheduledReportsOnUploadNoteEventTypeNew),
OnUploadNoteEventType: pointer.FromAny(api.ScheduledReportsV1OnUploadNoteEventTypeNew),
},
SourceId: faker.RandomString(16),
}
Expand Down
Loading
Loading