-
<async> addCarer(json, actionUsername)
-
Add new carer to the database
Parameters:
Name |
Type |
Description |
json |
JSON
|
entry to add |
actionUsername |
string
|
The user who issued the request.
Obligatory properties within JSON |
Properties:
Name |
Type |
Description |
carer_email |
|
|
Returns:
result of the query - {success:Boolean}
-
Type
-
JSON
-
<async> addHospital(json, actionUsername)
-
Add new Hospital to the database
Parameters:
Name |
Type |
Description |
json |
JSON
|
entry to add |
actionUsername |
string
|
The user who issued the request.
Obligatory properties within JSON |
Properties:
Name |
Type |
Description |
hospital_email |
|
|
Returns:
result of the query - {success:Boolean}
-
Type
-
JSON
-
<async> addPatient(json, actionUsername)
-
Add new patient to the database
Parameters:
Name |
Type |
Description |
json |
JSON
|
entry to add |
actionUsername |
string
|
The user who issued the request.
Obligatory properties within JSON |
Properties:
Name |
Type |
Description |
patient_no |
|
|
patient_name |
|
|
patient_surname |
|
|
hospital_id |
|
|
carer_id |
|
|
Returns:
result of the query - {success:Boolean}
-
Type
-
JSON
-
<async> addTest(json, actionUsername)
-
Add new test to the database
Parameters:
Name |
Type |
Description |
json |
JSON
|
entry to add |
actionUsername |
string
|
The user who issued the request.
Obligatory properties within JSON |
Properties:
Name |
Type |
Description |
patient_no |
|
|
due_date |
|
|
Returns:
result of the query - {success:Boolean}
-
Type
-
JSON
-
<async> addUser(json, actionUsername)
-
Add new user to the database
Parameters:
Name |
Type |
Description |
json |
JSON
|
user |
actionUsername |
string
|
The user who issued the request.
Obligatory properties within JSON |
Properties:
Name |
Type |
Description |
username |
String
|
|
hashed_password |
String
|
|
email |
String
|
|
isAdmin |
string
|
"yes" | "no" |
Returns:
result of the query - {success:Boolean}
-
Type
-
JSON
-
arraysOfDatesEqual(_arr1, _arr2)
-
Check if two arrays containing dates have
the same values
Parameters:
Name |
Type |
Description |
_arr1 |
array1
|
|
_arr2 |
array2
|
|
-
callCommand(command, logger)
-
Call a logger command
Parameters:
Name |
Type |
Description |
command |
string
|
the command to call |
logger |
JSON
|
the logger module object |
-
<async> changePatientColour(patientNo, newColour)
-
Edit patient colour - quick update.
Parameters:
Name |
Type |
Description |
patientNo |
String
|
Number of the patient to update |
newColour |
string
|
New colour to be stored. |
Returns:
-
<async> changeTestStatus(test, actionUsername)
-
Change the status of the test in the database
Parameters:
Name |
Type |
Description |
test |
JSON
|
|
actionUsername |
string
|
The user who issued the request. |
Properties:
Name |
Type |
Description |
testId |
String
|
id of a test to change |
|
|
|
Returns:
result of the query - {success:true/false response:Array/Error}
-
Type
-
JSON
-
characterCheck(input)
-
Checks if input contains only characters
Parameters:
Name |
Type |
Description |
input |
|
String of some value |
Returns:
Match with regular expression
-
Type
-
boolean
-
checkMultipleQueriesStatus(queries)
-
Run multiple queries on the database
Parameters:
Name |
Type |
Description |
queries |
Array
|
array of queries to run |
Returns:
result of the query - {success:true/false response:Array/String}
-
Type
-
JSON
-
checkValues()
-
Checks if year is valid.
Returns:
if values are correct and message to display if not
-
Type
-
*
-
createFileName()
-
Creates FileName depending on user choice of month/year combination.
-
<async> deleteCarer(carerid, actionUsername)
-
Delete Carer entry from database
Parameters:
Name |
Type |
Description |
carerid |
String
|
id of a carer to be deleted |
actionUsername |
string
|
The user who issued the request. |
Returns:
result of the query - {success:Boolean response:"Entry deleted"/Error}
-
Type
-
JSON
-
<async> deleteHospital(hospitalid, actionUsername)
-
Delete hospital entry from database
Parameters:
Name |
Type |
Description |
hospitalid |
String
|
id of a hospital to be deleted |
actionUsername |
string
|
The user who issued the request. |
Returns:
result of the query - {success:Boolean response:"Entry deleted"/Error}
-
Type
-
JSON
-
<async> deletePatient(patientid, actionUsername)
-
Delete Patient from database
Parameters:
Name |
Type |
Description |
patientid |
String
|
patient_no of a patient |
actionUsername |
string
|
The user who issued the request. |
Returns:
result of the query - {success:Boolean response:"Entry deleted"/Error}
-
Type
-
JSON
-
<async> deleteQueryDatabase(table, id, sql, actionUsername)
-
Run DELETE query on the database
Parameters:
Name |
Type |
Description |
table |
String
|
Table to edit |
id |
String
|
id to edit |
sql |
String
|
SQL query |
actionUsername |
string
|
The user who issued the request. |
Returns:
result of the query - {success:Boolean response:"Entry deleted"/Error}
-
Type
-
JSON
-
<async> deleteTest(testid, actionUsername)
-
Delete test entry from database
Parameters:
Name |
Type |
Description |
testid |
String
|
id of a test to be deleted |
actionUsername |
string
|
The user who issued the request. |
Returns:
result of the query - {success:Boolean response:"Entry deleted"/Error}
-
Type
-
JSON
-
<async> editCarer(newInfo, token, actionUsername)
-
Edit carer query
Parameters:
Name |
Type |
Description |
newInfo |
JSON
|
All the information of the carer to update |
token |
|
The token that grants edit privileges |
actionUsername |
string
|
The user who issued the request. |
Properties:
Name |
Type |
Description |
carer_id |
String
|
|
-
<async> editHospital(newInfo, token, actionUsername)
-
Edit hospital query
Parameters:
Name |
Type |
Description |
newInfo |
JSON
|
All the information of the hospital to update
Obligatory fields in JSON |
token |
|
The token that grants edit privileges |
actionUsername |
string
|
The user who issued the request. |
Properties:
Name |
Type |
Description |
hospital_id |
String
|
|
-
<async> editPatient(newInfo, token, actionUsername)
-
Edit patient query
Parameters:
Name |
Type |
Description |
newInfo |
JSON
|
All the information of the patient to update
Obligatory fields in JSON |
token |
|
The token that grants edit privileges |
actionUsername |
string
|
The user who issued the request. |
Properties:
Name |
Type |
Description |
patient_no |
String
|
|
-
<async> editTest(testId, newInfo, token, actionUsername)
-
Edit test query
Parameters:
Name |
Type |
Description |
testId |
|
The id of the test to be updated |
newInfo |
JSON
|
All the information of the test (new and old) |
token |
|
The token that grants edit privileges |
actionUsername |
string
|
The user who issued the request. |
-
<async> editUser(json, actionUsername)
-
Update User in database
Parameters:
Name |
Type |
Description |
json |
JSON
|
user |
actionUsername |
string
|
The user who issued the request.
Obligatory properties: |
Properties:
Name |
Type |
Description |
username |
String
|
,
One of optional properties
Optional properties: |
recovery_email |
String
|
|
hashed_password |
String
|
|
Returns:
- {success:Boolean response:Array or Error}
-
Type
-
JSON
-
emailCheck(input)
-
Checks if input is an email address or empty
This is not a complete check some invalid emails will still return true
Parameters:
Name |
Type |
Description |
input |
|
String of some value |
Returns:
Match with regular expression
-
Type
-
boolean
-
emptyCheck(input)
-
Checks if input is empty or undefined
Parameters:
Name |
Type |
Description |
input |
|
Some string value |
Returns:
-
Type
-
boolean
-
<async> getAllPatients(isAdult)
-
Get all the patients from the database
Parameters:
Name |
Type |
Description |
isAdult |
Boolean
|
If the records should be displayed for adult users |
Returns:
result of the query - {success:true/false response:Array/Error}
-
Type
-
JSON
-
<async> getAllUsers()
-
Get all users from database
Returns:
result of the query - {success:true/false response:Array/Error}
-
Type
-
JSON
-
<async> getCarer(carerID)
-
Get the carer given its carer id
Parameters:
Name |
Type |
Description |
carerID |
string
|
the carer id |
Returns:
- {success:Boolean response:Array or Error}
-
Type
-
JSON
-
<async> getCompletedLate(isMonthly, data)
-
Get number of completed tests in month
Parameters:
Name |
Type |
Description |
isMonthly |
Boolean
|
is the report monthly (true) or yearly (false) |
data |
String
|
date for data to be retrived |
Returns:
result of query {success:Boolean response: if true -> {[{Number}]}} else {Error}
-
Type
-
JSON
-
<async> getCompletedOnTime(isMonthly, data)
-
Get number of completed tests on time in month
Parameters:
Name |
Type |
Description |
isMonthly |
Boolean
|
is the report monthly (true) or yearly (false) |
data |
String
|
date for data to be retrived |
Returns:
result of query {success:Boolean response: if true -> {[{Number}]}} else {Error}
-
Type
-
JSON
-
<async> getDueTests(isMonthly, data)
-
Get number of test due in month
Parameters:
Name |
Type |
Description |
isMonthly |
Boolean
|
is the report monthly (true) or yearly (false) |
data |
String
|
date for data to be retrived |
Returns:
result of query {success:Boolean response: if true -> {[{Number}]}} else {Error}
-
Type
-
JSON
-
<async> getFullPatientInfo(patient_no)
-
Get the info of the patient together with the info of eventual carers and hospitals
Parameters:
Name |
Type |
Description |
patient_no |
string
|
the patient number |
Returns:
- {success:Boolean response:Array or Error}
-
Type
-
JSON
-
<async> getHospital(hospital_id)
-
Get the hospital given its hospital id
Parameters:
Name |
Type |
Description |
hospital_id |
string
|
the hospital id |
Returns:
- {success:Boolean response:Array or Error}
-
Type
-
JSON
-
getLastLineOfFile(fileName)
-
Return the last line of a file.
Adapted from https://bit.ly/2Hz2lPO.
Parameters:
Name |
Type |
Description |
fileName |
string
|
the path of the file to read |
-
getMonthAndYear(date:)
-
Return month and year from the received date as string.
(Mon Mar 04 2019 ... = March 2019)
Parameters:
Name |
Type |
Description |
date: |
Date
|
date |
Returns:
Month and Year as string
-
Type
-
string
-
getMonthName(date:)
-
Return the full name of the month from the received date
Parameters:
Name |
Type |
Description |
date: |
Date
|
date |
Returns:
The name of date's month
-
Type
-
string
-
<async> getNextTestsOfPatient(patientId)
-
Get not completed tests from patient
Parameters:
Name |
Type |
Description |
patientId |
String
|
id of patient |
Returns:
result of the query - {success:true/false response:Array/Error}
-
Type
-
JSON
-
-
Get sum of all reminders send in month
Parameters:
Name |
Type |
Description |
isMonthly |
Boolean
|
is the report monthly (true) or yearly (false) |
data |
String
|
date for data to be retrived |
Returns:
result of query {success:Boolean response: if true -> {[{Number}]}} else {Error}
-
Type
-
JSON
-
<async> getOverdueReminderGroups(isAdult)
-
Returns overdue tests that are separated into two groups. One group are the tests that haven't been
sent a reminder. The other group are the tests that have already been sent a reminder.
Response includes some basic info about the test.
Parameters:
Name |
Type |
Description |
isAdult |
Boolean
|
If the records should be displayed for adult users |
Returns:
{
success: true|false,
response: {
notReminded: [{
test_id:
due_date:
patient_no:
patient_name:
patient_surname:
}, ...]
reminded: [{
test_id:
due_date:
patient_no:
patient_name:
patient_surname:
last_reminder:
reminders_sent:
}, ...]
}
}
-
Type
-
JSON
-
<async> getPatient(patient_no)
-
Get the patient given its patient number
Parameters:
Name |
Type |
Description |
patient_no |
string
|
the patient number |
Returns:
- {success:Boolean response:Array or Error}
-
Type
-
JSON
-
<async> getPatientEditedTests(patient_no)
-
Get patient edited tests at the moment
Parameters:
Name |
Type |
Description |
patient_no |
string
|
the patient number |
Returns:
- {success:Boolean response:Array or Error}
-
Type
-
JSON
-
<async> getPatientsNumber(isAdult)
-
Get number of patients in database
Parameters:
Name |
Type |
Description |
isAdult |
Boolean
|
if the number of patients to be retrived should be for adult patients |
Returns:
result of query {success:Boolean response: if true -> {[{Number}]}} else {Error}
-
Type
-
JSON
-
<async> getTest(test_id)
-
Get test from the database
Parameters:
Name |
Type |
Description |
test_id |
String
|
id of test |
Returns:
result of the query - {success:true/false response:Array/Error}
-
Type
-
JSON
-
<async> getTestInfo(test_id)
-
Get test info with patient info from the database
Parameters:
Name |
Type |
Description |
test_id |
String
|
id of test |
Returns:
result of the query - {success:true/false response:Array/Error}
-
Type
-
JSON
-
getTestsDuringTheWeek(date, isAdult)
-
Produce multiple queries on the database to retrieve test within the week
Parameters:
Name |
Type |
Description |
date |
String
|
date in the week to retrieve tests (format: "YYYY-MM-DD") |
isAdult |
Boolean
|
If the records should be displayed for adult users |
Returns:
array of queries to run
-
Type
-
Array
-
<async> getTestWithinWeek(date, isAdult)
-
Get all tests within the week from the database
Parameters:
Name |
Type |
Description |
date |
String
|
any date (from Monday to Friday) within the week to retrieve (format: "YYYY-MM-DD") |
isAdult |
Boolean
|
If the records should be displayed for adult users |
Returns:
result of the query - {success:true/false response:Array/Error}
-
Type
-
JSON
-
<async> getUser(username)
-
Get user from database
Parameters:
Name |
Type |
Description |
username |
String
|
username to retrieve |
Returns:
result of the query - {success:true/false response:Array/Error}
-
Type
-
JSON
-
-
Retrieves data from input element.
Parameters:
-
handleSelectChange(e)
-
Retrieves data from select element.
Parameters:
-
<async> insertQueryDatabase(sql, tableName, id, actionUsername)
-
Run INSERT query on the database
Parameters:
Name |
Type |
Description |
sql |
String
|
SQL query |
tableName |
string
|
Name of the table which we are inserting into. |
id |
string
|
Specify new entry's ID, unless the ID is auto generated. |
actionUsername |
string
|
The user who issued the request. |
Returns:
result of the query - {success:Boolean}
-
Type
-
JSON
-
integerCheck(input)
-
Checks if input contains only non-negative numbers
Parameters:
Name |
Type |
Description |
input |
|
String of some value |
Returns:
Match with regular expression
-
Type
-
boolean
-
prepareDeleteSQL(table, idProperty, id)
-
Prepare DELETE query on the database
Parameters:
Name |
Type |
Description |
table |
String
|
Table in which to insert an entry |
idProperty |
String
|
property, that the entry can be identified with |
id |
String
|
value of idProperty |
Returns:
SQL query
-
Type
-
String
-
prepareInsertSQL(table, object)
-
Prepare INSERT query on the database
Parameters:
Name |
Type |
Description |
table |
String
|
Table in which to insert an entry |
object |
JSON
|
JSON, which is being entered |
Returns:
SQL query
-
Type
-
String
-
prepareUpdateSQL(table, object, idProperty)
-
Prepare UPDATE query on the database
Parameters:
Name |
Type |
Description |
table |
String
|
Table in which to insert an entry |
object |
JSON
|
JSON, which is being entered |
idProperty |
String
|
property, that the entry can be identified with |
Returns:
SQL query
-
Type
-
String
-
<async> requestEditing(table, id, actionUsername)
-
Request editing of an entry in table
Parameters:
Name |
Type |
Description |
table |
String
|
Table to edit |
id |
String
|
id to edit |
actionUsername |
string
|
The user who issued the request. |
Returns:
token
-
Type
-
String
-
<async> returnToken(table, id, token, actionUsername)
-
Cancel editing on an entry
Parameters:
Name |
Type |
Description |
table |
String
|
Table of an entry |
id |
String
|
id value of an entry |
token |
String
|
token to return |
actionUsername |
string
|
The user who issued the request. |
Returns:
result - {success:Boolean response:"Token cancelled"/Error}
-
Type
-
JSON
-
<async> selectQueryDatabase(sql)
-
Run SELECT query on the database
Parameters:
Name |
Type |
Description |
sql |
String
|
SQL query |
Returns:
result of the query - {success:Boolean response:Array/Error}
-
Type
-
JSON
-
sleep(ms)
-
Await for this function to pause execution for a certain time.
Parameters:
Name |
Type |
Description |
ms |
number
|
Time in milliseconds |
Returns:
-
Type
-
Promise
-
<async> updateLastReminder(testId, token, actionUsername)
-
Update when the last reminder for this test was sent.
Parameters:
Name |
Type |
Description |
testId |
string
|
id of a test to change |
token |
string
|
The token that grants edit privileges. |
actionUsername |
string
|
The user who issued the request. |
Returns:
result of the query - {success:true/false response:Array/Error}
-
Type
-
JSON
-
<async> updateQueryDatabase(table, id, sql, token, actionUsername)
-
Run UPDATE query on the database
Parameters:
Name |
Type |
Description |
table |
String
|
Table to edit |
id |
String
|
id to edit |
sql |
String
|
SQL query |
token |
string
|
token to access entry |
actionUsername |
string
|
The user who issued the request. |
Returns:
result of the query - {success:Boolean response:Array/Error}
-
Type
-
JSON