open_fda_drug_label.shelf

Classes

Shelf

OVERVIEW:

Module Contents

class open_fda_drug_label.shelf.Shelf(capacity: int = 10000)[source]
OVERVIEW:

Shelf is the primary manipulation object to utilize and employ drug objects. Enables optional capacity that dictates the amount of drugs capable of being fit on the shelf. Prevents redundancy of drugs by identifying identical names and preventing addition of same drugs. Enables adding and removing drugs from shelf structure. Enables collection of shelf statistics about total fields, risk score, and other total drug statistics.

This is designed to be useful for individuals storing medicine in their homes, pharmacists keeping track of SKUs and inventory from FDA approved drugs, and to provide a malleable data manipulation object for implementation.

corelist

a list containing all the individual drug items on the shelf.

Type:

list

capacity

total capacity of the shelf (number of drugs) not to be exceeded

Type:

int

USAGE EXAMPLE:
>>> my_shelf = Shelf(capacity=20)
>>> my_shelf.add_drug(Advil) # 1 drug shelf
>>> my_shelf.add_drug(Oxycodone) # 2 drug shelf
>>> my_shelf.remove_drug(Oxycodone.get_name()) # removes based on exact name match
>>> # my_shelf has 1 drug
>>> my_shelf.shelf_stats() # returns the basic descriptive stats for the shelf
corelist = []
capacity = 10000
get_drugs()[source]
OVERVIEW:

Function returns list of all drugs on the shelf

Parameters:

None

RETURN VALUE:

corelist (list): list of all drugs on the shelf

USAGE EXAMPLE:
>>> my_shelf.get_drugs() # returns list of drugs
add_drug(drug)[source]
OVERVIEW:

Function to add a drug to the shelf. Function has a couple of checks; it first ensures that the drug is not already on the list by get_name function, and also ensures that the list is not capacity backed up. After doing so, the function adds the drug to the list.

Parameters:

drug (Drug) – drug to be considered for addition to the list

RETURN VALUE:

None: simply adds drug to the list

USAGE EXAMPLE:
>>> my_shelf = Shelf(capacity=20) # initializes shelf object
>>> my_shelf.add_drug(Advil) # adds advil to the shelf if space/not redundant
remove_drug(name: str)[source]
OVERVIEW:

Function to remove drug from shelf. Takes in string with name of drug and checks entire shelf to see if matching name can be withdrawn. If matching name appears, drug is removed from the list.

Parameters:

name (str) – result of Drug.get_name() for drug desired to be removed

RETURN VALUE:

None

USAGE EXAMPLE:
>>> my_shelf #imagine this is a shelf that has multiple drugs including advil
>>> my_shelf.remove_drug("Advil") # checks get_name for all drugs and removes "Advil"
shelf_stats()[source]
OVERVIEW:

Provides statistics on the shelf, including newest drug, average risk score, average total fields in drug_comprehensive, and percentage_full of the capacity of the shelf in terms of drug count.

Parameters:

None

RETURN VALUE:

shelf_stats (dict): dictionary with 4 key shelf statistics

USAGE EXAMPLE:
>>> my_shelf.shelf_stats() # returns shelf stats if computable for my shelf