Checks your pharmacy inventory sheet every morning and emails the medicines running low or near expiry, marking each in the sheet.
Uses
Gmail
Google Sheets
Low stock and expiry alerts for your pharmacy
inventorySheetUrl to blank.Set inventorySheetUrl to blank.inventoryTab to Inventory.Set inventoryTab to Inventory.pharmacistEmail to blank.Set pharmacistEmail to blank.lowStockThreshold to 10.Set lowStockThreshold to 10.expiryWarningDays to 30.Set expiryWarningDays to 30.datesAreDayFirst to false.Set datesAreDayFirst to false.inventorySheetUrl. Save it as inventory.Read the rows of inventorySheetUrl. Save it as inventory.rows to inventory.rows.Set rows to inventory.rows.headers to inventory.headers.Set headers to inventory.headers.rows is emptyIf rows is emptyYes
No
No steps
rows, headers, today, low_stock_threshold, expiry_warning_days, and dates_are_day_first and save it as analysis.Run Python code on rows, headers, today, low_stock_threshold, expiry_warning_days, and dates_are_day_first and save it as analysis.analysis.error isn't emptyIf analysis.error isn't emptyYes
analysis.error.Stop and report a problem: analysis.error.No
No steps
analysis.has_alerts is yesIf analysis.has_alerts is yesYes
pharmacistEmail.Send an email to pharmacistEmail.
Subject: analysis.email_subjectanalysis.email_bodyNo
No steps
failedUpdates to an empty list.Set failedUpdates to an empty list.update in analysis.updates:For each update in analysis.updates:writeFailedIf a step below fails, save the error as writeFailedTry
update.row_number of inventoryTab in inventorySheetUrl.Overwrite row update.row_number of inventoryTab in inventorySheetUrl.On error
update.row_number (update.medicine): writeFailed.message to the end of failedUpdates and save it as failedUpdates.Add row update.row_number (update.medicine): writeFailed.message to the end of failedUpdates and save it as failedUpdates.failedUpdates isn't emptyIf failedUpdates isn't emptyYes
failedUpdates joined by ; . Any alert email due today was already sent; these medicines will be reported as new again on the next run.Stop and report a problem: The Alert Status column could not be updated for failedUpdates joined by ; . Any alert email due today was already sent; these medicines will be reported as new again on the next run.No
No steps
analysis.has_alerts is yesIf analysis.has_alerts is yesYes
pharmacistEmail and updated the Alert Status of the length of analysis.updates rows.Finish the run: Sent '@analysis.email_subject' to pharmacistEmail and updated the Alert Status of the length of analysis.updates rows.No
analysis.checked) are stocked and in date. Nothing was sent.Finish the run: All medicines checked (analysis.checked) are stocked and in date. Nothing was sent.