Classes
- UserProfile
Class representing a user profile.
- Medicine
Class representing a drug (medicine).
Functions
- displayProfiles()
Creates table with user profiles.
- saveProfileToLocalStorage()
Saves profile data to local storage properly.
- replaceProfileToLocalStorage()
Saves profile data to local storage properly.
- deleteProfileFromLocalStorage()
Deletes profile data from local storage.
- createProfileElement(profile) ⇒
Element
Create new profile, given a user profile object.
- createDeleteButton(medicineSection, medicineName)
Creates a delete button for existing user profile (section).
- createModifyButton(profileSection)
Creates a modification button for existing profile (section).
- showCreateProfileSection()
Shows profile creation div when user clicks the add profile button.
- profileExists(profileName) ⇒
Checks if profile already exists in localstorage.
- saveLastUpdated(profileName)
Saves the last updated timestamp.
- showModificationWindow(profileSection)
Shows the medicine modification window. Triggered when the user clicks the modify button.
- createSection(headerStr, categoryIconSrc, categoryIconAltTxt) ⇒
Element
Creates a section, along with its header and icon.
- setTheme()
Sets the apropriate theme. Checks to see if a relative record exists in localstorage, else checks the user's operating system theme.
- arrayToCsv()
Convert an array into a CSV string
- createImportExportDiv() ⇒
Creates a div element for the import/export buttons.
- uploadCSV()
Triggers the hidden input element. Triggered each time user presses the 'upload' button.
- downloadCSV()
Prepares a CSV file and starts the download. Triggered each time user presses the 'download' button.
- parse(data)
Parses CSV and sets the new data (medicine list).
- displayMedicine(sortBy)
Creates table with user's medicine.
- deleteAllMedicineSection()
Deletes the section with all medicine (list).
- deleteAddMedicineButton()
Deletes 'add medicine' button.
- createAddMedicineButton()
Creates the 'add medicine' button.
- markMedicineByExpirationDate(medicineSection)
Marks each medicine accourding to their expiration date. Red: expired or expires today Yellow: expires soon Green: ahead of expiration time
- showModificationWindow(medicineSection)
Shows the medicine modification window. Triggered when the user clicks the modify button.
- saveMedicineToLocalStorage()
Saves medicine data to local storage properly.
- prepareNewProfileList(newMedicineInstance) ⇒
Array
Prepares the new profile list (along with all the medicine lists). Triggered when the user creates new medicine or modifies an existing one.
- deleteMedicineFromLocalStorage()
Deletes medicine data from local storage.
- createMedicineElement(medicine) ⇒
Element
Creates new medicine, given a medicine object.
- createDeleteButton(medicineSection, medicineName)
Creates a delete button for existing medicine (section).
- createModifyButton(medicineSection)
Creates a modification button for existing medicine (section).
- createSearchInput() ⇒
Element
Creates a new search input (text area).
- search()
Performs search among medicine.
- isSearchResult(labels) ⇒
boolean
Checks if a medicine element is a search result based on a filter
- createSortByElements(index) ⇒
Element
Creates a sort by div area.
- showCreateMedicineSection(nameTxt, expirationDateTxt, stockCount, barcodeTxt, remarksTxt, editableMedicineDiv)
Shows medicine creation div when user clicks the add medicine button. Parameters are only needed when the function is triggered due to modification.
- medicineExists(name, expirationDate, barcode) ⇒
Checks if a medicine already exists in the profile. Distinct key: (name, expiration date, barcode)
- saveLastUpdated()
Saves the last updated timestamp.
- startScanner()
Starts barcode scanner.
- getProfileInstance() ⇒
UserProfile
Gets profile instance from localstorage.
- findProfileByName() ⇒
UserProfile
Returns profile instance from localstorage.
- getProfileName() ⇒
UserProfile
Returns profile name from localstorage.
- setTheme()
Sets theme according to user's preference. Dark theme is applied by default
- createSection(headerStr, categoryIconSrc, categoryIconAltTxt) ⇒
Element
Creates a section, along with its header and icon.
UserProfile
Class representing a user profile.
new UserProfile(name)
Creates a user profile instance
Param | Type | Description |
---|---|---|
name | string |
Profile's complete name |
Medicine
Class representing a drug (medicine).
new Medicine(name, expirationDate, stock, barcode, remarks)
Creates a medicine instance
Param | Type | Description |
---|---|---|
name | string |
Medicine's complete name |
expirationDate | string |
Medicine's expiration date |
stock | int |
Medicine's stock |
barcode | string |
Medicine's barcode |
remarks | string |
Medicine's potential remarks |
displayProfiles()
Creates table with user profiles.
saveProfileToLocalStorage()
Saves profile data to local storage properly.
replaceProfileToLocalStorage()
Saves profile data to local storage properly.
deleteProfileFromLocalStorage()
Deletes profile data from local storage.
Element
createProfileElement(profile) ⇒ Create new profile, given a user profile object.
Kind: global function
Returns: Element
- a div element (profile's new div)
Param | Type | Description |
---|---|---|
profile | UserProfile |
Profile's instance |
createDeleteButton(medicineSection, medicineName)
Creates a delete button for existing user profile (section).
Kind: global function
Param | Type | Description |
---|---|---|
medicineSection | Element |
Profile's section |
medicineName | string |
Profile's complete name |
createModifyButton(profileSection)
Creates a modification button for existing profile (section).
Kind: global function
Param | Type | Description |
---|---|---|
profileSection | Element |
Profiles's section |
showCreateProfileSection()
Shows profile creation div when user clicks the add profile button.
profileExists(profileName) ⇒
Checks if profile already exists in localstorage.
Kind: global function
Returns: true if already exists, false otherwise.
Param | Description |
---|---|
profileName | the name of the profile we are checking |
saveLastUpdated(profileName)
Saves the last updated timestamp.
Kind: global function
Param | Description |
---|---|
profileName | the name of the profile updated. |
showModificationWindow(profileSection)
Shows the medicine modification window. Triggered when the user clicks the modify button.
Kind: global function
Param | Type | Description |
---|---|---|
profileSection | Element |
medicine to be marked |
Element
createSection(headerStr, categoryIconSrc, categoryIconAltTxt) ⇒ Creates a section, along with its header and icon.
Kind: global function
Returns: Element
- Section's element
Param | Type | Description |
---|---|---|
headerStr | string |
The header's string |
categoryIconSrc | string |
Icon's src |
categoryIconAltTxt | string |
Icon's alternative text |
setTheme()
Sets the apropriate theme. Checks to see if a relative record exists in localstorage, else checks the user's operating system theme.
arrayToCsv()
Convert an array into a CSV string
createImportExportDiv() ⇒
Creates a div element for the import/export buttons.
Kind: global function
Returns: the division element
uploadCSV()
Triggers the hidden input element. Triggered each time user presses the 'upload' button.
downloadCSV()
Prepares a CSV file and starts the download. Triggered each time user presses the 'download' button.
parse(data)
Parses CSV and sets the new data (medicine list).
Kind: global function
Param | Description |
---|---|
data | csv data uploaded |
displayMedicine(sortBy)
Creates table with user's medicine.
Kind: global function
Param | Default | Description |
---|---|---|
sortBy | name-asc |
string that represents the sort criteria |
deleteAllMedicineSection()
Deletes the section with all medicine (list).
deleteAddMedicineButton()
Deletes 'add medicine' button.
createAddMedicineButton()
Creates the 'add medicine' button.
markMedicineByExpirationDate(medicineSection)
Marks each medicine accourding to their expiration date. Red: expired or expires today Yellow: expires soon Green: ahead of expiration time
Kind: global function
Param | Type | Description |
---|---|---|
medicineSection | Element |
medicine to be marked |
showModificationWindow(medicineSection)
Shows the medicine modification window. Triggered when the user clicks the modify button.
Kind: global function
Param | Type | Description |
---|---|---|
medicineSection | Element |
medicine to be marked |
saveMedicineToLocalStorage()
Saves medicine data to local storage properly.
Array
prepareNewProfileList(newMedicineInstance) ⇒ Prepares the new profile list (along with all the medicine lists). Triggered when the user creates new medicine or modifies an existing one.
Kind: global function
Returns: Array
- the new profile list
Param | Type | Description |
---|---|---|
newMedicineInstance | Element |
medicine instance to be upserted |
deleteMedicineFromLocalStorage()
Deletes medicine data from local storage.
Element
createMedicineElement(medicine) ⇒ Creates new medicine, given a medicine object.
Kind: global function
Returns: Element
- a div element (profile's new div)
Param | Type | Description |
---|---|---|
medicine | Medicine |
Medicine's complete name |
createDeleteButton(medicineSection, medicineName)
Creates a delete button for existing medicine (section).
Kind: global function
Param | Type | Description |
---|---|---|
medicineSection | Element |
Medicine's section |
medicineName | string |
Medicine's complete name |
createModifyButton(medicineSection)
Creates a modification button for existing medicine (section).
Kind: global function
Param | Type | Description |
---|---|---|
medicineSection | Element |
Medicine's section |
Element
createSearchInput() ⇒ Creates a new search input (text area).
Kind: global function
Returns: Element
- a search input element
search()
Performs search among medicine.
boolean
isSearchResult(labels) ⇒ Checks if a medicine element is a search result based on a filter
Kind: global function
Returns: boolean
- true if the medicine must be returned as a search result, false otherwise.
Param | Type | Description |
---|---|---|
labels | Array |
the labels within the medicine element |
Element
createSortByElements(index) ⇒ Creates a sort by div area.
Kind: global function
Returns: Element
- sort by div area.
Param | Type | Default | Description |
---|---|---|---|
index | int |
0 |
the starting index of dropdown list |
showCreateMedicineSection(nameTxt, expirationDateTxt, stockCount, barcodeTxt, remarksTxt, editableMedicineDiv)
Shows medicine creation div when user clicks the add medicine button. Parameters are only needed when the function is triggered due to modification.
Kind: global function
Param | Type | Default | Description |
---|---|---|---|
nameTxt | string |
medicine's full name | |
expirationDateTxt | string |
medicine's expiration date | |
stockCount | int |
1 |
medicine's stock count |
barcodeTxt | string |
medicine's barcode | |
remarksTxt | string |
remarks' text | |
editableMedicineDiv | Element |
|
non null only when is triggered due to modification |
medicineExists(name, expirationDate, barcode) ⇒
Checks if a medicine already exists in the profile. Distinct key: (name, expiration date, barcode)
Kind: global function
Returns: true if already exists in the profile, false otherwise.
Param | Description |
---|---|
name | the name of the medicine |
expirationDate | the expiration date of the medicine |
barcode | the medicine's barcode |
saveLastUpdated()
Saves the last updated timestamp.
startScanner()
Starts barcode scanner.
UserProfile
getProfileInstance() ⇒ Gets profile instance from localstorage.
Kind: global function
Returns: UserProfile
- user profile instance
UserProfile
findProfileByName() ⇒ Returns profile instance from localstorage.
Kind: global function
Returns: UserProfile
- user profile instance
UserProfile
getProfileName() ⇒ Returns profile name from localstorage.
Kind: global function
Returns: UserProfile
- user profile instance
setTheme()
Sets theme according to user's preference. Dark theme is applied by default
Element
createSection(headerStr, categoryIconSrc, categoryIconAltTxt) ⇒ Creates a section, along with its header and icon.
Kind: global function
Returns: Element
- Section's element
Param | Type | Description |
---|---|---|
headerStr | string |
The header's string |
categoryIconSrc | string |
Icon's src |
categoryIconAltTxt | string |
Icon's alternative text |