ct

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BRAND_JSON_FILENAME = "us_ct_brands.json"
	BRAND_CSV_FILENAME  = "us_ct_brands.csv"
	// CTBrandsURL is the URL to fetch the CT cannabis brands data
	BrandsURL = "https://data.ct.gov/resource/egd5-wb6r.json"
)

Variables

This section is empty.

Functions

func CSVString

func CSVString(str string) string

CSVString internally santizes a string for use in a CSV file field

func IsBrandErroneous

func IsBrandErroneous(b *Brand) bool

IsBrandErroneous checks if the brand is erroneous, returning true if it is

func IsEmptyMeasurement

func IsEmptyMeasurement(str string) bool

IsEmptyMeasurement returns true if the string is considered a trace measure Examples are: "" and "<0.1"

func IsErrorMeasurement

func IsErrorMeasurement(str string) bool

IsErrorMeasurement returns true if the string is considered to be erroneous Examples are:

func IsTraceMeasurement

func IsTraceMeasurement(str string) bool

IsTraceMeasurement returns true if the string is considered a trace measure Examples are: "TRC" "<LOQ" and "<0.1"

func RegisterMCP

func RegisterMCP(mcpServer *mcp_server.MCPServer, conn *sql.DB) error

RegisterMCP registers CT MCP tools with the MCPServer

Types

type Brand

type Brand struct {
	BrandName                    string       `csv:"BRAND-NAME" json:"brand_name"`
	DosageForm                   string       `csv:"DOSAGE-FORM" json:"dosage_form"`
	BrandingEntity               string       `csv:"BRANDING-ENTITY" json:"branding_entity"`
	ProductImage                 Image        `csv:"PRODUCT-IMAGE" json:"product_image"`
	LabelImage                   Image        `csv:"LABEL-IMAGE" json:"label_image"`
	LabAnalysis                  Image        `csv:"LAB-ANALYSIS" json:"lab_analysis"`
	ApprovalDate                 iso8601.Time `csv:"APPROVAL-DATE" json:"approval_date"`
	RegistrationNumber           string       `csv:"REGISTRATION-NUMBER" json:"registration_number"`
	TetrahydrocannabinolThc      Measure      `csv:"TETRAHYDROCANNABINOL-THC" json:"tetrahydrocannabinol_thc"`
	TetrahydrocannabinolAcidThca Measure      `csv:"TETRAHYDROCANNABINOL-ACID-THCA" json:"tetrahydrocannabinol_acid_thca"`
	CannabidiolsCbd              Measure      `csv:"CANNABIDIOLS-CBD" json:"cannabidiols_cbd"`
	CannabidiolAcidCbda          Measure      `csv:"CANNABIDIOL-ACID-CBDA" json:"cannabidiol_acid_cbda"`
	APinene                      Measure      `csv:"A-PINENE" json:"a_pinene"`
	BMyrcene                     Measure      `csv:"B-MYRCENE" json:"b_myrcene"`
	BCaryophyllene               Measure      `csv:"B-CARYOPHYLLENE" json:"b_caryophyllene"`
	BPinene                      Measure      `csv:"B-PINENE" json:"b_pinene"`
	Limonene                     Measure      `csv:"LIMONENE" json:"limonene"`
	Ocimene                      Measure      `csv:"OCIMENE" json:"ocimene"`
	LinaloolLin                  Measure      `csv:"LINALOOL-LIN" json:"linalool_lin"`
	HumuleneHum                  Measure      `csv:"HUMULENE-HUM" json:"humulene_hum"`
	Cbg                          Measure      `csv:"CBG" json:"cbg"`
	CbgA                         Measure      `csv:"CBG-A" json:"cbg_a"`
	CannabavarinCbdv             Measure      `csv:"CANNABAVARIN-CBDV" json:"cannabavarin_cbdv"`
	CannabichromeneCbc           Measure      `csv:"CANNABICHROMENE-CBC" json:"cannabichromene_cbc"`
	CannbinolCbn                 Measure      `csv:"CANNBINO-CBN" json:"cannbinol_cbn"`
	TetrahydrocannabivarinThcv   Measure      `csv:"TETRAHYDROCANNABIVARIN-THCV" json:"tetrahydrocannabivarin_thcv"`
	ABisabolol                   Measure      `csv:"A-BISABOLOL" json:"a_bisabolol"`
	APhellandrene                Measure      `csv:"A-PHELLANDRENE" json:"a_phellandrene"`
	ATerpinene                   Measure      `csv:"A-TERPINENE" json:"a_terpinene"`
	BEudesmol                    Measure      `csv:"B-EUDESMOL" json:"b_eudesmol"`
	BTerpinene                   Measure      `csv:"B-TERPINENE" json:"b_terpinene"`
	Fenchone                     Measure      `csv:"FENCHONE" json:"fenchone"`
	Pulegol                      Measure      `csv:"PULEGOL" json:"pulegol"`
	Borneol                      Measure      `csv:"BORNEOL" json:"borneol"`
	Isopulegol                   Measure      `csv:"ISOPULEGOL" json:"isopulegol"`
	Carene                       Measure      `csv:"CARENE" json:"carene"`
	Camphene                     Measure      `csv:"CAMPHENE" json:"camphene"`
	Camphor                      Measure      `csv:"CAMPHOR" json:"camphor"`
	CaryophylleneOxide           Measure      `csv:"CARYOPHYLLENE_OXIDE" json:"caryophyllene_oxide"`
	Cedrol                       Measure      `csv:"CEDROL" json:"cedrol"`
	Eucalyptol                   Measure      `csv:"EUCALYPTOL" json:"eucalyptol"`
	Geraniol                     Measure      `csv:"GERANIOL" json:"geraniol"`
	Guaiol                       Measure      `csv:"GUAIOL" json:"guaiol"`
	GeranylAcetate               Measure      `csv:"GERANYL_ACETATE" json:"geranyl_acetate"`
	Isoborneol                   Measure      `csv:"ISOBORNEOL" json:"isoborneol"`
	Menthol                      Measure      `csv:"MENTHOL" json:"menthol"`
	LFenchone                    Measure      `csv:"L-FENCHONE" json:"l_fenchone"`
	Nerol                        Measure      `csv:"NEROL" json:"nerol"`
	Sabinene                     Measure      `csv:"SABINENE" json:"sabinene"`
	Terpineol                    Measure      `csv:"TERPINEOL" json:"terpineol"`
	Terpinolene                  Measure      `csv:"TERPINOLENE" json:"terpinolene"`
	TransBFarnesene              Measure      `csv:"TRANS-B-FARNESENE" json:"trans_b_farnesene"`
	Valencene                    Measure      `csv:"VALENCENE" json:"valencene"`
	ACedrene                     Measure      `csv:"A-CEDRENE" json:"a_cedrene"`
	AFarnesene                   Measure      `csv:"A-FARNESENE" json:"a_farnesene"`
	BFarnesene                   Measure      `csv:"B-FARNESENE" json:"b_farnesene"`
	CisNerolidol                 Measure      `csv:"CIS-NEROLIDOL" json:"cis_nerolidol"`
	Fenchol                      Measure      `csv:"FENCHOL" json:"fenchol"`
	TransNerolidol               Measure      `csv:"TRANS-NEROLIDOL" json:"trans_nerolidol"`
	Market                       string       `csv:"Market" json:"market"`
	Chemotype                    string       `csv:"Chemotype" json:"chemotype"`
	ProcessingTechnique          string       `csv:"Processing Technique" json:"processing_technique"`
	SolventsUsed                 string       `csv:"Solvents Used" json:"solvents_used"`
	NationalDrugCode             string       `csv:"National Drug Code" json:"national_drug_code"`
}

Raw Cannabis Brand Record

func CleanBrands

func CleanBrands(bs []Brand) []Brand

CleanBrands modifies the passed brand slice in place, filtering out bad Brand samples using IsBrandErroneous(). It returns the cleaned slice.

func FetchBrands

func FetchBrands(appToken string, maxCacheAge time.Duration) ([]Brand, error)

FetchBrands fetches all the CT cannabis brands data from the CT API

func (Brand) CSVHeaders

func (b Brand) CSVHeaders() string

CSVHeaders returns the CSV headers for the Brand struct

func (Brand) CSVValue

func (b Brand) CSVValue() string

CSVValue returns the CSV value for the Brand struct

func (Brand) DBInsert

func (b Brand) DBInsert(conn *sql.DB) error

type Image

type Image struct {
	URL         string `csv:"url" json:"url"`          // URL is the URL to the image
	Description string `csv:"desc" json:"description"` // Description is the description of the image
}

type Measure

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

Measure tracks a a measurement, with special flags for no-measurment and trace measurement

func NewEmptyMeasure

func NewEmptyMeasure() Measure

NewEmptyMeasure creates a new "empty" measure. This may also be created through nil-initialization Measure{}

func NewErrorMeasure

func NewErrorMeasure() Measure

NewErrorMeasure creates a new "error" measure.

func NewMeasure

func NewMeasure(amount float64) Measure

NewMeasure creates a new measure with the given amount. Any amount < 0, will be treated as a trace measurement. To create an "empty" Measure object, use nil-initialization Measure{} or NewEmptyMeasure

func NewTraceMeasure

func NewTraceMeasure() Measure

NewTraceMeasure creates a new "trace amount" measure.

func (Measure) Amount

func (m Measure) Amount() (result float64, trace bool, empty bool)

Amount returns the value, isTrace, isEmpty If it is a trace amount, result will be 0 and isTrace will be true If it is an empty value, result will be 0 and isEmpty will be true

func (Measure) AsCSV

func (m Measure) AsCSV() string

AsCSV converts the measure to "" or "<amount>". Trace is converted to "".

func (Measure) AsSQL

func (m Measure) AsSQL() string

AsSQL converts the measure to "NULL" or "<amount>". Trace is converted to NULL.

func (*Measure) FromString

func (m *Measure) FromString(str string) error

FromString modifies the given measure based on the passed string It undergoes some cleaning and Trace and Empty detection

func (Measure) IsEmpty

func (m Measure) IsEmpty() bool

IsEmpty returns true if the measure is empty (no measurement) Same as IsNil

func (Measure) IsEqual

func (m Measure) IsEqual(other Measure) bool

func (Measure) IsNil

func (m Measure) IsNil() bool

IsNil returns true if the measure is empty (no measurement) Same as IsEmpty

func (Measure) IsTrace

func (m Measure) IsTrace() bool

IsTrace returns true if the measure is a trace amount

func (Measure) IsValidPercent

func (m Measure) IsValidPercent() bool

IsValidPercent returns true if the measure is a valid percentage (0-100)

func (Measure) IsZero

func (m Measure) IsZero() bool

IsEmpty returns true if the measure has an initialized, but zero value

func (Measure) MarshalCSV

func (m Measure) MarshalCSV() (string, error)

MarshalCSV marshals the measure to a CSV string

func (*Measure) MarshalJSON

func (m *Measure) MarshalJSON() ([]byte, error)

MarshalJSON converts the measure to JSON, which is a string

func (*Measure) UnmarshalCSV

func (m *Measure) UnmarshalCSV(value string) error

UnmarshalCSV unmarshals the measure from a CSV string

func (*Measure) UnmarshalJSON

func (m *Measure) UnmarshalJSON(b []byte) error

MarshalJSON converts the measure from JSON, which can be string or number

func (Measure) Value

func (m Measure) Value() (driver.Value, error)

Value implements the driver.Valuer interface for inserting into SQL

Jump to

Keyboard shortcuts

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