2022-08-25 19:26:29 -06:00
|
|
|
package database
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-08-29 05:19:27 -06:00
|
|
|
|
2023-08-27 18:09:46 -06:00
|
|
|
"github.com/fastenhealth/fasten-onprem/backend/pkg"
|
|
|
|
"github.com/fastenhealth/fasten-onprem/backend/pkg/models"
|
2022-12-02 20:40:58 -07:00
|
|
|
sourcePkg "github.com/fastenhealth/fasten-sources/clients/models"
|
2023-08-24 13:28:57 -06:00
|
|
|
"github.com/google/uuid"
|
2022-08-25 19:26:29 -06:00
|
|
|
)
|
|
|
|
|
2022-08-31 20:06:12 -06:00
|
|
|
//go:generate mockgen -source=interface.go -destination=mock/mock_database.go
|
2022-08-25 19:26:29 -06:00
|
|
|
type DatabaseRepository interface {
|
|
|
|
Close() error
|
2022-12-03 13:48:35 -07:00
|
|
|
Migrate() error
|
2022-09-11 21:59:13 -06:00
|
|
|
|
|
|
|
CreateUser(context.Context, *models.User) error
|
2024-02-15 12:19:04 -07:00
|
|
|
GetUserCount(context.Context) (int, error)
|
2022-12-03 13:48:35 -07:00
|
|
|
GetUserByUsername(context.Context, string) (*models.User, error)
|
2023-01-15 12:07:41 -07:00
|
|
|
GetCurrentUser(ctx context.Context) (*models.User, error)
|
2024-01-11 14:31:36 -07:00
|
|
|
DeleteCurrentUser(ctx context.Context) error
|
2024-08-29 05:19:27 -06:00
|
|
|
GetUsers(ctx context.Context) ([]models.User, error)
|
2022-12-02 20:40:58 -07:00
|
|
|
|
|
|
|
GetSummary(ctx context.Context) (*models.Summary, error)
|
|
|
|
|
2023-07-08 08:43:30 -06:00
|
|
|
GetResourceByResourceTypeAndId(context.Context, string, string) (*models.ResourceBase, error)
|
|
|
|
GetResourceBySourceId(context.Context, string, string) (*models.ResourceBase, error)
|
2023-08-14 17:11:04 -06:00
|
|
|
QueryResources(ctx context.Context, query models.QueryResource) (interface{}, error)
|
2023-07-08 08:43:30 -06:00
|
|
|
ListResources(context.Context, models.ListResourceQueryOptions) ([]models.ResourceBase, error)
|
|
|
|
GetPatientForSources(ctx context.Context) ([]models.ResourceBase, error)
|
2022-12-17 16:10:19 -07:00
|
|
|
AddResourceAssociation(ctx context.Context, source *models.SourceCredential, resourceType string, resourceId string, relatedSource *models.SourceCredential, relatedResourceType string, relatedResourceId string) error
|
|
|
|
RemoveResourceAssociation(ctx context.Context, source *models.SourceCredential, resourceType string, resourceId string, relatedSource *models.SourceCredential, relatedResourceType string, relatedResourceId string) error
|
2023-07-08 08:43:30 -06:00
|
|
|
FindResourceAssociationsByTypeAndId(ctx context.Context, source *models.SourceCredential, resourceType string, resourceId string) ([]models.RelatedResource, error)
|
2023-11-23 09:51:01 -07:00
|
|
|
GetFlattenedResourceGraph(ctx context.Context, graphType pkg.ResourceGraphType, options models.ResourceGraphOptions) (map[string][]*models.ResourceBase, error)
|
2023-12-03 19:40:16 -07:00
|
|
|
|
|
|
|
// Deprecated:This method has been deprecated. It has been replaced in favor of Fasten SourceCredential & associations
|
2023-07-08 08:43:30 -06:00
|
|
|
AddResourceComposition(ctx context.Context, compositionTitle string, resources []*models.ResourceBase) error
|
2022-12-02 20:40:58 -07:00
|
|
|
//UpsertProfile(context.Context, *models.Profile) error
|
|
|
|
//UpsertOrganziation(context.Context, *models.Organization) error
|
|
|
|
|
|
|
|
CreateSource(context.Context, *models.SourceCredential) error
|
|
|
|
GetSource(context.Context, string) (*models.SourceCredential, error)
|
|
|
|
GetSourceSummary(context.Context, string) (*models.SourceSummary, error)
|
|
|
|
GetSources(context.Context) ([]models.SourceCredential, error)
|
2023-07-20 22:43:37 -06:00
|
|
|
UpdateSource(ctx context.Context, sourceCreds *models.SourceCredential) error
|
2023-10-11 08:54:18 -06:00
|
|
|
DeleteSource(ctx context.Context, sourceId string) (int64, error)
|
2022-12-02 20:40:58 -07:00
|
|
|
|
2023-03-21 09:04:43 -06:00
|
|
|
CreateGlossaryEntry(ctx context.Context, glossaryEntry *models.Glossary) error
|
|
|
|
GetGlossaryEntry(ctx context.Context, code string, codeSystem string) (*models.Glossary, error)
|
|
|
|
|
2023-10-08 17:29:26 -06:00
|
|
|
//background jobs
|
|
|
|
CreateBackgroundJob(ctx context.Context, backgroundJob *models.BackgroundJob) error
|
|
|
|
GetBackgroundJob(ctx context.Context, backgroundJobId string) (*models.BackgroundJob, error)
|
|
|
|
UpdateBackgroundJob(ctx context.Context, backgroundJob *models.BackgroundJob) error
|
|
|
|
ListBackgroundJobs(ctx context.Context, queryOptions models.BackgroundJobQueryOptions) ([]models.BackgroundJob, error)
|
|
|
|
|
2023-08-24 13:28:57 -06:00
|
|
|
//settings
|
2024-02-09 10:10:06 -07:00
|
|
|
LoadSystemSettings(ctx context.Context) (*models.SystemSettings, error)
|
|
|
|
SaveSystemSettings(ctx context.Context, newSettings *models.SystemSettings) error
|
2023-08-24 13:28:57 -06:00
|
|
|
LoadUserSettings(ctx context.Context) (*models.UserSettings, error)
|
|
|
|
SaveUserSettings(context.Context, *models.UserSettings) error
|
|
|
|
PopulateDefaultUserSettings(ctx context.Context, userId uuid.UUID) error
|
|
|
|
|
2023-03-21 09:04:43 -06:00
|
|
|
//used by fasten-sources Clients
|
2023-10-08 17:29:26 -06:00
|
|
|
BackgroundJobCheckpoint(ctx context.Context, checkpointData map[string]interface{}, errorData map[string]interface{})
|
2023-12-03 19:40:16 -07:00
|
|
|
UpsertRawResource(ctx context.Context, sourceCredentials sourcePkg.SourceCredential, rawResource sourcePkg.RawResourceFhir) (bool, error)
|
|
|
|
UpsertRawResourceAssociation(
|
|
|
|
ctx context.Context,
|
|
|
|
sourceId string,
|
|
|
|
sourceResourceType string,
|
|
|
|
sourceResourceId string,
|
|
|
|
targetSourceId string,
|
|
|
|
targetResourceType string,
|
|
|
|
targetResourceId string,
|
|
|
|
) error
|
2022-08-25 19:26:29 -06:00
|
|
|
}
|