Package sc2002.repositories
Class MedicationInventoryDB
java.lang.Object
sc2002.repositories.MedicationInventoryDB
The MedicationInventoryDB class provides methods for managing medication inventory,
including retrieving, adding, removing, updating stock levels, and setting low stock alerts.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddMedication(MedicationInventory newMedication) Adds a new medication to the inventory.static intfindMedicine(String medicine) Finds if a specific medication exists in the inventory.static List<MedicationInventory>Retrieves the list of all medications in the inventory.static StringReturns a list of medicines that have low stock levels.static voidremoveMedication(String medicineName) Removes a medication from the inventory based on the medicine name.static voidupdateLowAlert(String medicineName, int updatedLowLevelAlert) Updates the low stock alert level of a specified medication.static voidupdateStockLevel(String medicineName, int restockAmount) Updates the stock level of a specified medication.
-
Constructor Details
-
MedicationInventoryDB
public MedicationInventoryDB()
-
-
Method Details
-
getMedicationInventory
Retrieves the list of all medications in the inventory.- Returns:
- a list of MedicationInventory objects
- Throws:
IOException- if an error occurs while reading the file
-
addMedication
Adds a new medication to the inventory.- Parameters:
newMedication- the MedicationInventory object to add- Throws:
IOException- if an error occurs while updating the file
-
removeMedication
Removes a medication from the inventory based on the medicine name.- Parameters:
medicineName- the name of the medicine to remove- Throws:
IOException- if an error occurs while updating the file
-
updateStockLevel
Updates the stock level of a specified medication.- Parameters:
medicineName- the name of the medicationrestockAmount- the amount to add to the current stock- Throws:
IOException- if an error occurs while updating the file
-
updateLowAlert
Updates the low stock alert level of a specified medication.- Parameters:
medicineName- the name of the medicationupdatedLowLevelAlert- the new low stock level alert- Throws:
IOException- if an error occurs while updating the file
-
findMedicine
Finds if a specific medication exists in the inventory.- Parameters:
medicine- the name of the medicine to find- Returns:
- 1 if the medicine is found, 0 otherwise
-
lowStockLevelAlert
Returns a list of medicines that have low stock levels.- Returns:
- a comma-separated string of medicines with low stock or "NO" if none
- Throws:
IOException- if an error occurs while reading the file
-