utils

package
v0.0.0-...-be83552 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSpecificTimeoutToQuery

func AddSpecificTimeoutToQuery(query *gorm.DB, timeout time.Duration) (*gorm.DB, context.CancelFunc)

Adds a specific timeout to a query

func AddTimeoutToQuery

func AddTimeoutToQuery(query *gorm.DB) (*gorm.DB, context.CancelFunc)

Adds a default timeout to a query

func Contains

func Contains(list []int, value int) bool

func ContainsNonNil

func ContainsNonNil(errors []error) bool

func ContainsString

func ContainsString(list []string, value string) bool

func FreedmanDiaconis

func FreedmanDiaconis(values []float64) float64

This function returns the bin width upon the Freedman Diaconis formula: https://en.wikipedia.org/wiki/Freedman%E2%80%93Diaconis_rule Can return 0 if IQR(values) is 0.

func GenerateDsn

func GenerateDsn(sourceConnectionString string) string

func GetBinsAndWidthUsingFreedmanDiaconisAndSortValues

func GetBinsAndWidthUsingFreedmanDiaconisAndSortValues(values []float64) (int, float64)

Sorts the given values, and returns the number of bins, the width of the bins using FreedmanDiaconis

func GetCohortPairKey

func GetCohortPairKey(firstCohortDefinitionId int, secondCohortDefinitionId int) string

func GetUniqueCohortDefinitionIdsList

func GetUniqueCohortDefinitionIdsList(cohortDefinitionIds []int, filterCohortPairs []CustomDichotomousVariableDef) []int

Utility function to parse out the cohort definition ids from a specific structure in which they can be found (in this case deep inside CustomDichotomousVariableDef items) and concatenate them with another given list of ids, removing duplicate ids (if any).

func IQR

func IQR(values []float64) float64

func MakeUnique

func MakeUnique(input []int) []int

func ParseBigNumericArg

func ParseBigNumericArg(c *gin.Context, paramName string) (int64, error)

func ParseConceptIdsAndDichotomousDefsAsSingleList

func ParseConceptIdsAndDichotomousDefsAsSingleList(c *gin.Context) ([]interface{}, error)

This method expects a request body with a payload similar to the following example: {"variables": [

{variable_type: "concept", concept_id: 2000000324},
{variable_type: "concept", concept_id: 2000006885},
{variable_type: "custom_dichotomous", provided_name: "name1", cohort_ids: [cohortX_id, cohortY_id]},
{variable_type: "custom_dichotomous", provided_name: "name2", cohort_ids: [cohortM_id, cohortN_id]},
    ...

]} It returns the list with all concept_id values and custom dichotomous variable definitions.

func ParseInt64

func ParseInt64(strValue string) int64

func ParseNumericArg

func ParseNumericArg(c *gin.Context, paramName string) (int, error)

func ParseSourceAndCohortId

func ParseSourceAndCohortId(c *gin.Context) (int, int, error)

func ParseSourceIdAndCohortIdAndConceptIds

func ParseSourceIdAndCohortIdAndConceptIds(c *gin.Context) (int, int, []int64, error)

func ParseSourceIdAndCohortIdAndVariablesAsSingleList

func ParseSourceIdAndCohortIdAndVariablesAsSingleList(c *gin.Context) (int, int, []interface{}, error)

returns sourceid, cohortid, list of variables (formed by concept ids and/or of cohort tuples which are also known as custom dichotomous variables)

func ParseSourceIdAndConceptIds

func ParseSourceIdAndConceptIds(c *gin.Context) (int, []int64, error)

func ParseSourceIdAndConceptTypes

func ParseSourceIdAndConceptTypes(c *gin.Context) (int, []string, error)

func Pos

func Pos(value int64, list []int64) int

func SliceAtoi

func SliceAtoi(stringValues []string) ([]int64, error)

Takes in a list of strings and attempts to transform them to int64, returning the resulting list of int64 values. Will fail if any of the strings cannot be parsed as a number.

Types

type ConceptIds

type ConceptIds struct {
	ConceptIds []int64
}

type ConceptTypes

type ConceptTypes struct {
	ConceptTypes []string
}

type CustomDichotomousVariableDef

type CustomDichotomousVariableDef struct {
	CohortDefinitionId1 int
	CohortDefinitionId2 int
	ProvidedName        string
}

fields that define a custom dichotomous variable:

func GetConceptIdsAndCohortPairsAsSeparateLists

func GetConceptIdsAndCohortPairsAsSeparateLists(conceptIdsAndCohortPairs []interface{}) ([]int64, []CustomDichotomousVariableDef)

separates a conceptIdsAndCohortPairs into a conceptIds list and a cohortPairs list

func ParseConceptIdsAndDichotomousDefs

func ParseConceptIdsAndDichotomousDefs(c *gin.Context) ([]int64, []CustomDichotomousVariableDef, error)

deprecated: for backwards compatibility

func ParseSourceIdAndCohortIdAndVariablesList

func ParseSourceIdAndCohortIdAndVariablesList(c *gin.Context) (int, int, []int64, []CustomDichotomousVariableDef, error)

deprecated: returns the conceptIds and cohortPairs as separate lists (for backwards compatibility)

type DbAndSchema

type DbAndSchema struct {
	Db     *gorm.DB
	Schema string
	Vendor string
}

func GetDataSourceDB

func GetDataSourceDB(sourceConnectionString string, dbSchema string) *DbAndSchema

func (DbAndSchema) GetViewDirective

func (h DbAndSchema) GetViewDirective() string

Returns extra DB dialect specific directives to optimize performance when using views:

type HistogramColumn

type HistogramColumn struct {
	Start          float64 `json:"start"`
	End            float64 `json:"end"`
	NumberOfPeople int     `json:"nr_persons"`
}

func GenerateHistogramData

func GenerateHistogramData(conceptValues []float64) []HistogramColumn

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL