diff --git a/backend/__pycache__/main.cpython-310.pyc b/backend/__pycache__/main.cpython-310.pyc index 9cabeed1..6d4f8663 100644 Binary files a/backend/__pycache__/main.cpython-310.pyc and b/backend/__pycache__/main.cpython-310.pyc differ diff --git a/backend/routers/__pycache__/medicine.cpython-310.pyc b/backend/routers/__pycache__/medicine.cpython-310.pyc new file mode 100644 index 00000000..227323e2 Binary files /dev/null and b/backend/routers/__pycache__/medicine.cpython-310.pyc differ diff --git a/backend/routers/medicine.py b/backend/routers/medicine.py index 34c26d7f..33752488 100644 --- a/backend/routers/medicine.py +++ b/backend/routers/medicine.py @@ -10,13 +10,17 @@ class medicine(BaseModel): name: str unit: str -#get user by email & doc Office ID +#get all medicines @router.get("/users/medicine/all", tags="medicine") async def read_all_medicine(): - - return getMedicineData() + return getMedicineData("") -def getMedicineData(): +#get all medicines by search +@router.get("/users/medicine/{medSearch}", tags="medicine") +async def read_all_medicine(medSearch: str): + return getMedicineData(medSearch) + +def getMedicineData(medsearch: str): path = os.getcwd() parentDir = os.path.abspath(os.path.join(path, os.pardir)) filePath = os.path.join(path, "backend/medicines", "Database-Of-Medicine-Prices-31-May-2024.xls") @@ -24,7 +28,8 @@ def getMedicineData(): sh = book.sheet_by_index(0) medlist = [] for rx in range(1,sh.nrows): - if(str(sh.cell_value(rx, 6)).strip() != ""): + if(str(sh.cell_value(rx, 6)).strip() != "" and + medsearch.lower() in str(sh.cell_value(rx, 6)).strip().lower()): medlist.append({ "name": str(sh.cell_value(rx, 6)).strip(), "unit": str(sh.cell_value(rx, 9)).strip(),