The Inventory page is the core workspace of PharmaVault. It lets you maintain a personal list of the medications you currently own — recording quantities, purchase dates, expiration dates, and any prescription notes for each item. Every entry is tied to a record in the medicine catalog so that drug metadata (name, form, dosage) is managed centrally rather than duplicated across your stock.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/JReyna217/PharmaVault/llms.txt
Use this file to discover all available pages before exploring further.
The InventoryItemDto Model
When the inventory list is fetched from the database, each row is mapped to an InventoryItemDto. This read-optimised projection joins the inventory and medicine_catalog tables so the UI receives everything it needs in a single round-trip.
- Identity fields
- Medicine metadata
- Stock fields
The Inventory Model
The write-side model used for insert and update operations carries validation attributes that are enforced by Blazor’s EditForm before any database call is made.
CRUD Operations
View Inventory — GetUserInventoryAsync
View Inventory — GetUserInventoryAsync
Returns all inventory rows for a given user, ordered by The underlying SQL performs an
expiration_date ASC so the items closest to expiry appear at the top of the list.Interface signature:INNER JOIN with medicine_catalog to populate the medicine name, pharmaceutical form, and dosage on each InventoryItemDto. The ::timestamp casts ensure that PostgreSQL date columns are mapped correctly to C# DateTime properties.Called from: Inventory.razor.cs → LoadInventoryAsync() during OnInitializedAsync and after every write operation.Add Item — AddToInventoryAsync
Add Item — AddToInventoryAsync
Inserts a new row into the The
inventory table and returns the newly generated primary key.Interface signature:UserId is always taken from the authenticated session — it is never accepted from user-supplied form input. The new inventory_id is returned via PostgreSQL’s RETURNING clause.Returns: The int primary key (inventory_id) of the inserted row.Edit Item — UpdateInventoryAsync
Edit Item — UpdateInventoryAsync
Updates mutable fields on an existing inventory row and returns The
Returns:
true if one row was affected.Interface signature:UPDATE statement targets inventory_id AND user_id, so a user can only modify their own rows. The following fields can be changed on edit:| Field | Notes |
|---|---|
Quantity | New unit count (1–10,000) |
PurchaseDate | May be set to null |
ExpirationDate | Required; cannot be cleared |
PrescriptionNotes | May be set to null or up to 500 chars |
CatalogId (the linked medicine) cannot be changed after an inventory item is created. To associate a different medicine, delete the existing entry and add a new one.true if the row was found and updated; false if no matching row existed (e.g., wrong userId).Delete Item — DeleteFromInventoryAsync
Delete Item — DeleteFromInventoryAsync
Removes a single inventory row permanently.Interface signature:The
WHERE clause requires both inventory_id = @InventoryId AND user_id = @UserId. This dual-condition check prevents one authenticated user from deleting another user’s inventory rows, even if they know the target inventoryId.Returns: true if the row was deleted; false if no matching row was found.Dashboard Stats — GetDashboardStatsAsync
Dashboard Stats — GetDashboardStatsAsync
Aggregates a user’s inventory quantities into four buckets used by the dashboard counters and pie chart.Interface signature:The underlying PostgreSQL query uses
CASE expressions evaluated against CURRENT_DATE to distribute each row’s quantity into the correct bucket — expired, expiring soon, or good — in a single round-trip. COALESCE(..., 0) ensures users with no inventory rows receive zeroes rather than NULL.Returns: A populated DashboardStatsDto with TotalStock, ExpiredStock, ExpiringSoonStock, and GoodStock counters. Returns a default (all-zero) instance if no rows exist.Called from: Dashboard.razor.cs → OnInitializedAsync().Real-Time Search
The inventory list supports instant, client-side filtering via theFilteredInventory computed property. No additional database round-trip is made — filtering runs over the in-memory _inventoryItems collection that was loaded on page initialisation.
- MedicineName — the drug name from the catalog (e.g., searching
"para"matches Paracetamol). - PharmaceuticalForm — the dosage form (e.g., searching
"tablet"filters to all tablet entries).
_searchTerm, so the list updates on every keystroke without requiring a button press.
Link to the Medicine Catalog
Every inventory item must reference a validcatalog_id from the medicine catalog. The inventory form populates its medicine dropdown by calling IMedicineCatalogDao.GetAllAsync(), which returns all catalog records ordered by name. Only medicines with IsActive = true will be surfaced in the dropdown — inactive catalog entries cannot be added to new inventory rows.