fdc

package
v0.0.0-...-c042da3 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2021 License: GPL-3.0 Imports: 5 Imported by: 10

Documentation

Overview

Package fdc describes food products data model

Package fdc describes food products data model

Index

Constants

View Source
const (
	FULL      = "full"
	META      = "meta"
	SERVING   = "servings"
	NUTRIENTS = "nutrients"
)

FULL etc define values for Foods formats

View Source
const (
	PHRASE   = "PHRASE"
	WILDCARD = "WILDCARD"
	REGEX    = "REGEX"
)

PHRASE etc defines values for Search Types

Variables

This section is empty.

Functions

This section is empty.

Types

type Aws

type Aws struct {
	Table  string // AWS DynamoDb table name
	Region string // AWS region
}

Aws DynamoDB configuration for connecting, reading and writing Amazon DynamoDB tables

type BrowseNutrientReport

type BrowseNutrientReport struct {
	Request NutrientReportRequest `json:"request"`
	Items   []interface{}         `json:"foods"`
}

BrowseNutrientReport is returned from the nutrients report endpoing

type BrowseNutrients

type BrowseNutrients struct {
	FdcID     string         `json:"fdcId" binding:"required"`
	Nutrients []NutrientData `json:"nutrients"`
}

BrowseNutrients is returned from the browse endpoints

type BrowseResult

type BrowseResult struct {
	Count int32         `json:"count"`
	Start int32         `json:"start"`
	Max   int32         `json:"max"`
	Items []interface{} `json:"items"`
}

BrowseResult is returned from the browse endpoints

type BrowseServings

type BrowseServings struct {
	FdcID    string    `json:"fdcId" binding:"required"`
	Servings []Serving `json:"servingSizes"`
}

BrowseServings is returned from the browse endpoints

type Config

type Config struct {
	CouchDb CouchDb
	Aws     Aws
}

Config provides basic configuration properties for API services. Properties are normally read in from a YAML file or the environment Each datastore should have it's own type

func (*Config) Defaults

func (cs *Config) Defaults()

Defaults sets values for CouchBase configuration properties if none have been provided.

func (*Config) GetConfig

func (cs *Config) GetConfig(c *string)

GetConfig reads config from a file

type CouchDb

type CouchDb struct {
	URL    string
	Bucket string
	Fts    string
	User   string
	Pwd    string
}

CouchDb configuration for connecting, reading and writing Couchbase nodes

type Derivation

type Derivation struct {
	ID          int32  `json:"id" binding:"required"`
	Code        string `json:"code" binding:"required"`
	Description string `json:"description"`
	Type        string `json:"type"`
}

Derivation is a code for describing how nutrient values are derived A subdocument of NutrientData

type DocType

type DocType int

DocType provides a list of document types

const (
	SR DocType = iota
	FGSR
	FNDDS
	FGFNDDS
	FGGPC
	BFPD
	UNIT
	NUT
	DERV
	FOOD
	USER
	NUTDATA
)

SR is standard reference

func (*DocType) ToDocType

func (dt *DocType) ToDocType(t string) DocType

ToDocType -- convert a string to a DocType

func (*DocType) ToString

func (dt *DocType) ToString(t DocType) string

ToString -- convert a DocType to a string

type Food

type Food struct {
	ID              string      `json:"_id,omitempty"`
	Rev             string      `json:"_rev,omitempty"`
	UpdatedAt       time.Time   `json:"lastChangeDateTime,omitempty"`
	FdcID           string      `json:"fdcId" binding:"required"`
	NdbNo           string      `json:"ndbno,omitempty"`
	Upc             string      `json:"upc,omitempty"`
	Description     string      `json:"foodDescription" binding:"required"`
	Source          string      `json:"dataSource"`
	PublicationDate time.Time   `json:"publicationDateTime"`
	ModifiedDate    time.Time   `json:"modifiedDate,omitempty"`
	AvailableDate   time.Time   `json:"availableDate,omitempty"`
	DiscontinueDate time.Time   `json:"discontinueDate,omitempty"`
	Ingredients     string      `json:"ingredients,omitempty"`
	Manufacturer    string      `json:"company,omitempty"`
	Group           *FoodGroup  `json:"foodGroup,omitempty"`
	Servings        []Serving   `json:"servingSizes,omitempty"`
	Type            string      `json:"type" binding:"required"`
	Country         string      `json:"marketCountry,omitempty"`
	InputFoods      []InputFood `json:"inputfoods,omitempty"`
}

Food reflects JSON used to transfer BFPD foods data from USDA csv

type FoodGroup

type FoodGroup struct {
	ID          int32  `json:"id" binding:"required"`
	Code        string `json:"code,omitempty"`
	Description string `json:"description" binding:"required"`
	LastUpdate  string `json:"lastUpdate,omitempty"`
	Type        string `json:"type" binding:"required"`
}

FoodGroup is the dictionary of FNDDS and SR food groups

type FoodMeta

type FoodMeta struct {
	FdcID        string `json:"fdcId" binding:"required"`
	Upc          string `json:"upc"`
	Description  string `json:"foodDescription" binding:"required"`
	Ingredients  string `json:"ingredients,omitempty"`
	Source       string `json:"dataSource"`
	Manufacturer string `json:"company,omitempty"`
	Type         string `json:"type"`
	Category     string `json:"foodgroup.description,omitempty"`
}

FoodMeta abbreviated Food containing only meta-data

type InputFood

type InputFood struct {
	Description        string  `json:"foodDescription" binding:"required"`
	SeqNo              int     `json:"seq"`
	Amount             float32 `json:"amount"`
	SrCode             int     `json:"srcode,omitempty"`
	Unit               string  `json:"unit"`
	Portion            string  `json:"portion,omitempty"`
	PortionDescription string  `json:"portionDescription,omitempty"`
	Weight             float32 `json:"weight"`
}

InputFood describes an FNDDS Input Food

type Nutrient

type Nutrient struct {
	NutrientID uint   `json:"id" binding:"required"`
	Nutrientno int    `json:"nutrientno" binding:"required"`
	Tagname    string `json:"tagname,omitempty"`
	Name       string `json:"name"  binding:"required"`
	Unit       string `json:"unit"  binding:"required"`
	Type       string `json:"type"  binding:"required"`
}

Nutrient is metadata abount nutrients usually in a nutrients collection

type NutrientData

type NutrientData struct {
	ID           string      `json:"_id" binding:"required"`
	Rev          string      `json:"_rev,omitempty"`
	FdcID        string      `json:"fdcId" binding:"required"`
	Upc          string      `json:"upc,omitempty"`
	Description  string      `json:"foodDescription" binding:"required"`
	Manufacturer string      `json:"company,omitempty"`
	Category     string      `json:"category,omitempty"`
	Source       string      `json:"Datasource"`
	Type         string      `json:"type"`
	Value        float64     `json:"valuePer100UnitServing"`
	Portion      string      `json:"portion,omitempty"`
	PortionValue float64     `json:"portionValue,omitempty"`
	Unit         string      `json:"unit"  binding:"required"`
	Derivation   *Derivation `json:"derivation,omitempty"`
	Nutrientno   int         `json:"nutrientNumber"`
	Nutrient     string      `json:"nutrientName"`
	Datapoints   int         `json:"datapoints,omitempty"`
	Min          float32     `json:"min,omitempty"`
	Max          float32     `json:"max,omitempty"`
}

NutrientData is the list of nutrient values A document of type NUTDATA

type NutrientFoodBrowse

type NutrientFoodBrowse struct {
	FdcID        string                   `json:"fdcId" binding:"required"`
	Upc          string                   `json:"upc,omitempty"`
	Description  string                   `json:"foodDescription" binding:"required"`
	Manufacturer string                   `json:"company,omitempty"`
	Category     string                   `json:"category,omitempty"`
	Portion      string                   `json:"portion,omitempty"`
	Nutrients    []NutrientFoodBrowseItem `json:"nutrients"`
}

NutrientFoodBrowse is returned from the food nutrient endpoints

type NutrientFoodBrowseItem

type NutrientFoodBrowseItem struct {
	Value        float64     `json:"valuePer100UnitServing"`
	Unit         string      `json:"unit"  binding:"required"`
	Derivation   *Derivation `json:"derivation,omitempty"`
	Nutrientno   int         `json:"nutrientNumber"`
	Nutrient     string      `json:"nutrientName"`
	PortionValue float64     `json:"valuePerPortion"`
}

NutrientFoodBrowseItem is the list of nutrient data returned by the food nutrient endpoints

type NutrientReportData

type NutrientReportData struct {
	FdcID           string  `json:"fdcId" binding:"required"`
	Upc             string  `json:"upc"`
	FoodDescription string  `json:"foodDescription"`
	Value           float64 `json:"valuePer100UnitServing"`
	Portion         string  `json:"portion,omitempty"`
	PortionValue    float64 `json:"valuePerPortion"`
	Unit            string  `json:"unit"`
	Type            string  `json:"type"`
}

NutrientReportData is an item returned in a nutrient report

type NutrientReportRequest

type NutrientReportRequest struct {
	Page      int     `json:"page"`
	Max       int     `json:"max"`
	Nutrient  int     `json:"nutrientno" binding:"required"`
	FoodGroup string  `json:"foodGroup,omitEmpty"`
	Sort      string  `json:"sort,omitEmpty"`
	Order     string  `json:"order,omitEmpty"`
	ValueGTE  float64 `json:"valueGTE"`
	ValueLTE  float64 `json:"valueLTE"`
}

NutrientReportRequest wraps a POST nutrient report

type SearchNutrients

type SearchNutrients struct {
	Food      FoodMeta       `json:"foodMeta"`
	Nutrients []NutrientData `json:"nutrients"`
}

SearchNutrients is returned from the search endpoints when format=nutrients

type SearchRequest

type SearchRequest struct {
	Query       string `json:"q" binding:"required"`
	SearchField string `json:"searchfield,omitEmpty"`
	Page        int    `json:"page"`
	Max         int    `json:"max"`
	Sort        string `json:"sort,omitEmpty"`
	SearchType  string `json:"searchtype,omitEmpty"`
	FoodGroup   string `json:"foodgroup,omitEmpty"`
	IndexName   string `json:"indexname"`
}

SearchRequest wraps a POST search

type SearchResult

type SearchResult struct {
	Food      FoodMeta       `json:"foodMeta"`
	Servings  []Serving      `json:"servingSizes"`
	Nutrients []NutrientData `json:"nutrients"`
}

SearchResult is returned from the search endpoints

type SearchServings

type SearchServings struct {
	Food     FoodMeta  `json:"foodMeta"`
	Servings []Serving `json:"servingSizes"`
}

SearchServings is returned from the search endpoints when format=servings

type Serving

type Serving struct {
	Nutrientbasis string  `json:"nutrientBasis,omitempty"`
	Description   string  `json:"servingUnit"`
	Servingstate  string  `json:"servingState,omitempty"`
	Weight        float32 `json:"weight"`
	Servingamount float32 `json:"value,omitempty"`
	Datapoints    int32   `json:"dataPoints,omitempty"`
}

Serving describes a list nutrients for a given state, weight and amount A subdocument of Food

Jump to

Keyboard shortcuts

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