Documentation ¶
Index ¶
- Constants
- type Events
- type ExploreQuery
- type OntologyElement
- type PostgresDatabase
- func (db PostgresDatabase) AddCohort(userID, cohortName, exploreQueryID, projectID string) (err error)
- func (db PostgresDatabase) AddExploreQuery(userID, queryID, queryDefinition string) (err error)
- func (db PostgresDatabase) BuildTimePoints(patientSetID int64, startConceptCodes []string, startModifierCodes []string, ...) (eventAggregates map[int64]*Events, patientsWithStartEvent int64, ...)
- func (db PostgresDatabase) DeleteCohort(userID, cohortName, exploreQueryID string) (err error)
- func (db PostgresDatabase) GetCohort(userID, exploreQueryID string) (cohort *SavedCohort, err error)
- func (db PostgresDatabase) GetCohorts(userID, projectID string, limit int) (cohorts []SavedCohort, err error)
- func (db PostgresDatabase) GetConceptCodes(path string) ([]string, error)
- func (db PostgresDatabase) GetExploreQuery(userID, id string) (query *ExploreQuery, err error)
- func (db PostgresDatabase) GetModifierCodes(path string, appliedPath string) ([]string, error)
- func (db PostgresDatabase) RetrieveObservationsForConcept(code string, patientSetID, minObservations int64) (statsObservations []StatsObservation, err error)
- func (db PostgresDatabase) RetrieveObservationsForModifier(code string, patientSetID, minObservations int64) (statsObservations []StatsObservation, err error)
- func (db PostgresDatabase) SearchOntology(searchString, limit string) (ontologyElements []OntologyElement, err error)
- func (db PostgresDatabase) SetExploreQueryError(userID, queryID string) error
- func (db PostgresDatabase) SetExploreQueryRunning(userID, queryID string) error
- func (db PostgresDatabase) SetExploreQuerySuccess(...) error
- func (db PostgresDatabase) TestCleanUp() error
- func (db PostgresDatabase) TestLoadData() error
- type PostgresDatabaseConfig
- type SavedCohort
- type StatsObservation
Constants ¶
const TestSchemaName = "gecodatasourcetest"
TestSchemaName defines the database schema name used for tests.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Events ¶
Events contains the number of events of interest and censoring events occurring at the same relative time.
type ExploreQuery ¶
type ExploreQuery struct { ID string CreateDate string UserID string Status string Definition string ResultI2b2PatientSetID sql.NullInt64 }
ExploreQuery is an explore query such as stored in the database.
type OntologyElement ¶
type OntologyElement struct { FullName string Name string VisualAttributes string BaseCode string MetaDataXML sql.NullString Comment sql.NullString AppliedPath string ID int }
OntologyElement is an i2b2 ontology element as stored in the database.
type PostgresDatabase ¶
type PostgresDatabase struct { PostgresDatabaseConfig Ctx *context.Context // For telemetry // contains filtered or unexported fields }
PostgresDatabase wraps the Postgres database of the data source.
func NewPostgresDatabase ¶
func NewPostgresDatabase(ctx *context.Context, logger logrus.FieldLogger, config PostgresDatabaseConfig, dbHandle *sql.DB) (db *PostgresDatabase, err error)
NewPostgresDatabase initializes a connection to a postgres database, and loads its structure if not present.
func (PostgresDatabase) AddCohort ¶
func (db PostgresDatabase) AddCohort(userID, cohortName, exploreQueryID, projectID string) (err error)
AddCohort adds a saved cohort for a user. Returns an error (due to foreign key violation) if the explore query does not exist, or if the provided user does not match.
func (PostgresDatabase) AddExploreQuery ¶
func (db PostgresDatabase) AddExploreQuery(userID, queryID, queryDefinition string) (err error)
AddExploreQuery adds an explore query with the requested status.
func (PostgresDatabase) BuildTimePoints ¶
func (db PostgresDatabase) BuildTimePoints( patientSetID int64, startConceptCodes []string, startModifierCodes []string, startEarliest bool, endConceptCodes []string, endModifierCodes []string, endEarliest bool, maxLimit int64, ) ( eventAggregates map[int64]*Events, patientsWithStartEvent int64, patientsWithoutAnyEndEvent map[int64]struct{}, err error, )
BuildTimePoints runs the SQL queries, process their results to build sequential data and aggregate them.
func (PostgresDatabase) DeleteCohort ¶
func (db PostgresDatabase) DeleteCohort(userID, cohortName, exploreQueryID string) (err error)
DeleteCohort deletes a saved cohort for a user.
func (PostgresDatabase) GetCohort ¶
func (db PostgresDatabase) GetCohort(userID, exploreQueryID string) (cohort *SavedCohort, err error)
GetCohort retrieves a saved cohort from the database. Returns nil (not an error) if cohort does not exist.
func (PostgresDatabase) GetCohorts ¶
func (db PostgresDatabase) GetCohorts(userID, projectID string, limit int) (cohorts []SavedCohort, err error)
GetCohorts retrieves the saved cohorts of a user from the database.
func (PostgresDatabase) GetConceptCodes ¶
func (db PostgresDatabase) GetConceptCodes(path string) ([]string, error)
GetConceptCodes returns all concept codes for a given path and its descendants.
func (PostgresDatabase) GetExploreQuery ¶
func (db PostgresDatabase) GetExploreQuery(userID, id string) (query *ExploreQuery, err error)
GetExploreQuery retrieves an explore query from the database. Returns nil (not an error) if query does not exist.
func (PostgresDatabase) GetModifierCodes ¶
func (db PostgresDatabase) GetModifierCodes(path string, appliedPath string) ([]string, error)
GetModifierCodes returns all modifier codes for a given path and its descendants, and exactly matching the appliedPath.
func (PostgresDatabase) RetrieveObservationsForConcept ¶
func (db PostgresDatabase) RetrieveObservationsForConcept(code string, patientSetID, minObservations int64) (statsObservations []StatsObservation, err error)
RetrieveObservationsForConcept returns the numerical values that correspond to the concept passed as argument for the specified cohort.
func (PostgresDatabase) RetrieveObservationsForModifier ¶
func (db PostgresDatabase) RetrieveObservationsForModifier(code string, patientSetID, minObservations int64) (statsObservations []StatsObservation, err error)
RetrieveObservationsForModifier returns the numerical values that correspond to the modifier passed as argument for the specified cohort.
func (PostgresDatabase) SearchOntology ¶
func (db PostgresDatabase) SearchOntology(searchString, limit string) (ontologyElements []OntologyElement, err error)
SearchOntology retrieves the elements (both concepts and modifiers, at most @limit, default 10) of the ontology whose names contains @searchString.
func (PostgresDatabase) SetExploreQueryError ¶
func (db PostgresDatabase) SetExploreQueryError(userID, queryID string) error
SetExploreQueryError sets the error status to an explore query.
func (PostgresDatabase) SetExploreQueryRunning ¶
func (db PostgresDatabase) SetExploreQueryRunning(userID, queryID string) error
SetExploreQueryRunning sets the running status to an explore query.
func (PostgresDatabase) SetExploreQuerySuccess ¶
func (db PostgresDatabase) SetExploreQuerySuccess(userID, queryID, i2b2PatientSetID, gecoSharedIDCount, gecoSharedIDPatientList string) error
SetExploreQuerySuccess sets the success status to an explore query and stores its results.
func (PostgresDatabase) TestCleanUp ¶
func (db PostgresDatabase) TestCleanUp() error
TestCleanUp deletes ALL test data and structure of the data source. Use with caution!
func (PostgresDatabase) TestLoadData ¶
func (db PostgresDatabase) TestLoadData() error
TestLoadData loads test data into the database. For usage with tests.
type PostgresDatabaseConfig ¶
type PostgresDatabaseConfig struct { Host string Port string Database string Schema string User string Password string }
PostgresDatabaseConfig is the config used to connect to the postgres database
func (PostgresDatabaseConfig) DataSourceName ¶
func (conf PostgresDatabaseConfig) DataSourceName() string
DataSourceName should return the connection string to the db: postgres example "host=localhost port=5432 user=test password=test dbname=test sslmode=disable"
func (PostgresDatabaseConfig) Driver ¶
func (conf PostgresDatabaseConfig) Driver() driver.Driver
Driver Should return the database driver
func (PostgresDatabaseConfig) DriverName ¶
func (conf PostgresDatabaseConfig) DriverName() string
DriverName returns "postgres"
func (PostgresDatabaseConfig) Name ¶
func (conf PostgresDatabaseConfig) Name() string
Name should return the name of the connected database
type SavedCohort ¶
type SavedCohort struct { Name string ProjectID string CreateDate string ExploreQuery ExploreQuery }
SavedCohort is a cohort such as stored in the database.
type StatsObservation ¶
StatsObservation contains a patient observation.