plugin

package
v0.0.0-...-e2cfa69 Latest Latest
Warning

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

Go to latest
Published: May 6, 2016 License: Apache-2.0 Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortEventsByDate

func SortEventsByDate(events []Event)

SortEventsByDate sorts the events by their date

func SortResultsByAsOfDate

func SortResultsByAsOfDate(results []RiskServiceCalculationResult)

SortResultsByAsOfDate sorts the results by their as-of date

Types

type Event

type Event struct {
	Date  time.Time
	Type  string
	End   bool
	Value interface{}
}

Event represents an event that may be of importance to a risk calculation

type EventStream

type EventStream struct {
	Patient *models.Patient
	Events  []Event
}

EventStream represents a patient and an ordered stream of events

func NewEventStream

func NewEventStream(patient *models.Patient) *EventStream

NewEventStream creates a new EventStream for the given patient, initialized to 0 events

func (*EventStream) Clone

func (es *EventStream) Clone() *EventStream

Clone does a shallow copy of the EventStream. This is most helpful in case plugins modify the event stream.

type NotApplicableError

type NotApplicableError struct {
	// contains filtered or unexported fields
}

NotApplicableError indicates that the given algorithm is not applicable for the requested patient. It would be inappropriate to return a score.

func NewNotApplicableError

func NewNotApplicableError(msg string) NotApplicableError

NewNotApplicableError returns a new NotApplicableError with the given message.

func (NotApplicableError) Error

func (e NotApplicableError) Error() string

type Pie

type Pie struct {
	Id      bson.ObjectId `bson:"_id" json:"id"`
	Slices  []Slice       `json:"slices"`
	Patient string        `json:"patient"`
	Created time.Time     `json:"created"`
}

Pie represents the chart in Intervention Engine. Since the chart can't be represented in FHIR, the RiskAssessment basis will point back to one of these.

func NewPie

func NewPie(patientUrl string) *Pie

NewPie constructs a new pie for the given patient, sets the Create time to now, and generates a new ID. Slices are initially empty.

func (*Pie) Clone

func (p *Pie) Clone(generateNewID bool) *Pie

Clone creates a copy of the pie. If generateNewID is true, it will give the clone a new identity. Slices of the clone can be modified without affecting the original.

func (*Pie) TotalValues

func (p *Pie) TotalValues() int

TotalValues sums up all the values in the slices.

func (*Pie) UpdateSliceValue

func (p *Pie) UpdateSliceValue(name string, value int)

UpdateSliceValue is a convenience function that finds the slice with the given name and updates its value.

type RiskServiceCalculationResult

type RiskServiceCalculationResult struct {
	AsOf               time.Time
	Score              *int
	ProbabilityDecimal *float64
	Pie                *Pie
}

RiskServiceCalculationResult represents risk assessment info for a given point in time. The Score indicates a raw score from the algorithm (if applicable), while the ProbabilityDecimal represents a percentage probability of the predicted outcome. Since it is a percentage, the value should never exceed 100.

func (*RiskServiceCalculationResult) GetProbabilityDecimalOrScore

func (r *RiskServiceCalculationResult) GetProbabilityDecimalOrScore() *float64

GetProbabilityDecimalOrScore returns the ProbabilityDecimal value if it exists, otherwise it returns the score. This approach preserves backwards compatibility with existing code, but should be reconsidered.

func (*RiskServiceCalculationResult) ToRiskAssessment

func (r *RiskServiceCalculationResult) ToRiskAssessment(patientId string, basisPieURL string, config RiskServicePluginConfig) *models.RiskAssessment

ToRiskAssessment converts the RiskServiceCalculationResult to a FHIR RiskAssessment.

type RiskServicePlugin

type RiskServicePlugin interface {
	// Config returns the configuration information for the risk service plugin
	Config() RiskServicePluginConfig
	// Calculate accepts an EventStream and returns the slice of
	// RiskServiceCalculationResults that corresponds to the event stream.  This
	// results slice represents risks over time, with the last element being the
	// most recent risk assessment.
	Calculate(es *EventStream, fhirEndpointURL string) ([]RiskServiceCalculationResult, error)
}

RiskServicePlugin provides the interface that risk service plugins should adhere to. This pertains only to this implementation -- as the only real interface that matters is the FHIR API. But... this provides an easy entry point for Go-based risk services.

type RiskServicePluginConfig

type RiskServicePluginConfig struct {
	Name                  string
	Method                models.CodeableConcept
	PredictedOutcome      models.CodeableConcept
	DefaultPieSlices      []Slice
	RequiredResourceTypes []string
	SignificantBirthdays  []int
}

RiskServicePluginConfig represents key information about the risk service plugin.

type Slice

type Slice struct {
	Name     string `json:"name"`
	Weight   int    `json:"weight"`
	Value    int    `json:"value"`
	MaxValue int    `json:"maxValue,omitempty"`
}

Slice represents a component that factors into the overall risk assessment algorithm. In the chart, it appears as a slice in the pie.

Jump to

Keyboard shortcuts

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