Documentation
¶
Overview ¶
Package rxnorm is the library behind the rxnorm command line: the HTTP client, request shaping, and the typed data models for the NLM RxNorm drug terminology API at rxnav.nlm.nih.gov/REST.
The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public API throws under load.
Index ¶
- Constants
- type Client
- func (c *Client) DrugProperties(ctx context.Context, rxcui string) (name, tty string, err error)
- func (c *Client) Drugs(ctx context.Context, drugName string) ([]*Drug, error)
- func (c *Client) Get(ctx context.Context, rawURL string) ([]byte, error)
- func (c *Client) Interactions(ctx context.Context, names []string) ([]*Interaction, error)
- func (c *Client) Lookup(ctx context.Context, drugName string) ([]*Drug, error)
- func (c *Client) ResolveName(ctx context.Context, name string) ([]string, error)
- type Domain
- type Drug
- type Interaction
Constants ¶
const BaseURL = "https://" + Host + "/REST"
BaseURL is the root every request is built from.
const DefaultUserAgent = "rxnorm-cli/0.1 (tamnd87@gmail.com)"
DefaultUserAgent identifies the client to the NLM API. A real, honest User-Agent is both polite and less likely to get blocked.
const Host = "rxnav.nlm.nih.gov"
Host is the API host this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
HTTP *http.Client
UserAgent string
// Rate is the minimum gap between requests. Zero means no pacing.
Rate time.Duration
Retries int
// contains filtered or unexported fields
}
Client talks to the RxNorm REST API over HTTPS.
func NewClient ¶
func NewClient() *Client
NewClient returns a Client with sensible defaults: a 15s timeout, a 300ms minimum gap between requests, and three retries on transient errors.
func (*Client) DrugProperties ¶
DrugProperties calls /rxcui/{id}/properties.json and returns the canonical name and TTY for the given RxCUI.
func (*Client) Drugs ¶
Drugs searches for drugs by name using /drugs.json and returns one Drug record per concept in every concept group. Returns an error if nothing is found.
func (*Client) Get ¶
Get fetches rawURL and returns the response body. It paces and retries according to the client's settings. The caller owns nothing extra; the body is read fully and closed here.
func (*Client) Interactions ¶
Interactions resolves each name to a RxCUI, then calls /interaction/list.json to find all drug-drug interactions among them. At least 2 names must resolve; returns an error otherwise.
type Domain ¶
type Domain struct{}
Domain is the rxnorm driver. It carries no state; the per-run client is built by the factory Register hands kit.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.