This module collects all the queries that are dealing with the core data.
- Version:
-
- 1.0
Methods
-
<async, inner> addCarer(json, actionUsername)
-
Add new carer to the database
Parameters:
Name Type Description jsonJSON entry to add actionUsernamestring The user who issued the request. Obligatory properties within JSON Properties:
Name Type Description carer_emailReturns:
result of the query - {success:Boolean}- Type
- JSON
-
<async, inner> addHospital(json, actionUsername)
-
Add new Hospital to the database
Parameters:
Name Type Description jsonJSON entry to add actionUsernamestring The user who issued the request. Obligatory properties within JSON Properties:
Name Type Description hospital_emailReturns:
result of the query - {success:Boolean}- Type
- JSON
-
<async, inner> addPatient(json, actionUsername)
-
Add new patient to the database
Parameters:
Name Type Description jsonJSON entry to add actionUsernamestring The user who issued the request. Obligatory properties within JSON Properties:
Name Type Description patient_noReturns:
result of the query - {success:Boolean}- Type
- JSON
-
<async, inner> addPatientExtended(patientInfo, actionUsername)
-
Add new patient entry to the database with optional carer/hospital
Parameters:
Name Type Description patientInfoJSON entry to add actionUsernamestring The user who issued the request. Returns:
result of the query - {success:Boolean response:{insertedId/problem (+ optional fields)}}- Type
- JSON
-
<async, inner> addTest(json, actionUsername)
-
Add new test to the database
Parameters:
Name Type Description jsonJSON entry to add actionUsernamestring The user who issued the request. Obligatory properties within JSON Properties:
Name Type Description patient_nodue_dateReturns:
result of the query - {success:Boolean}- Type
- JSON
-
<async, inner> addUser(json, actionUsername)
-
Add new user to the database
Parameters:
Name Type Description jsonJSON user actionUsernamestring The user who issued the request. Obligatory properties within JSON Properties:
Name Type Description usernameString hashed_passwordString emailString isAdminstring "yes" | "no" Returns:
result of the query - {success:Boolean}- Type
- JSON
-
<async, inner> changePatientColour(patientNo, newColour)
-
Edit patient colour - quick update.
Parameters:
Name Type Description patientNoString Number of the patient to update newColourstring New colour to be stored. Returns:
-
<async, inner> changeTestColour(testId, newColour)
-
Edit test colour - quick update.
Parameters:
Name Type Description testIdString Id of the test to update newColourstring New colour to be stored. Returns:
-
<async, inner> changeTestDueDate(testId, newDate)
-
Edit test due date - drag & drop method
Parameters:
Name Type Description testIdString Id of the test to update newDateDate new due date Returns:
-
<async, inner> changeTestStatus(test, actionUsername)
-
Change the status of the test in the database
Parameters:
Name Type Description testJSON actionUsernamestring The user who issued the request. Properties:
Name Type Description testIdString id of a test to change Returns:
result of the query - {success:true/false response:Array/Error}- Type
- JSON
-
<async, inner> checkIfPatientsTestsAreEdited()
-
Check if test are edited within the EditTokens database
Returns:
-
{false - If no tests are edited (no tokens)}
- Type
- Boolean
-
{true - If tests are edited (tokens in table)}
- Type
- Boolean
-
{Error response}
- Type
- JSON
-
-
<async, inner> deleteCarer(carerid, actionUsername)
-
Delete Carer entry from database
Parameters:
Name Type Description careridString id of a carer to be deleted actionUsernamestring The user who issued the request. Returns:
result of the query - {success:Boolean response:"Entry deleted"/Error}- Type
- JSON
-
<async, inner> deleteHospital(hospitalid, actionUsername)
-
Delete hospital entry from database
Parameters:
Name Type Description hospitalidString id of a hospital to be deleted actionUsernamestring The user who issued the request. Returns:
result of the query - {success:Boolean response:"Entry deleted"/Error}- Type
- JSON
-
<async, inner> deletePatient(patientid, token, actionUsername)
-
Delete Patient and cancel the patient edit token
Parameters:
Name Type Description patientidString patient_no of a patient tokenString token to be returned with query actionUsernamestring The user who issued the request. Returns:
result of the query - {success:Boolean response:"Entry deleted"/Error}- Type
- JSON
-
<async, inner> deleteTest(testid, actionUsername)
-
Delete test entry from database
Parameters:
Name Type Description testidString id of a test to be deleted actionUsernamestring The user who issued the request. Returns:
result of the query - {success:Boolean response:"Entry deleted"/Error}- Type
- JSON
-
<async, inner> editCarer(newInfo, token, actionUsername)
-
Edit carer query
Parameters:
Name Type Description newInfoJSON All the information of the carer to update tokenThe token that grants edit privileges actionUsernamestring The user who issued the request. Properties:
Name Type Description carer_idString -
<async, inner> editHospital(newInfo, token, actionUsername)
-
Edit hospital query
Parameters:
Name Type Description newInfoJSON All the information of the hospital to update Obligatory fields in JSON tokenThe token that grants edit privileges actionUsernamestring The user who issued the request. Properties:
Name Type Description hospital_idString -
<async, inner> editPatient(newInfo, token, actionUsername)
-
Edit patient query
Parameters:
Name Type Description newInfoJSON All the information of the patient to update Obligatory fields in JSON tokenThe token that grants edit privileges actionUsernamestring The user who issued the request. Properties:
Name Type Description patient_noString -
<async, inner> editPatientExtended(newInfo, token)
-
Edit patient with hospital and carer query
Parameters:
Name Type Description newInfoJSON All the information of the patient/hospital/carer to update tokenThe token that grants edit privileges Returns:
query result {success:Boolean response:{Response of each query as {success:Boolean response:Array/Error/String} or {} }}- Type
- JSON
-
<async, inner> editTest(testId, newInfo, token, actionUsername)
-
Edit test query
Parameters:
Name Type Description testIdThe id of the test to be updated newInfoJSON All the information of the test (new and old) tokenThe token that grants edit privileges actionUsernamestring The user who issued the request. -
<async, inner> editUser(json, actionUsername)
-
Update User in database
Parameters:
Name Type Description jsonJSON user actionUsernamestring The user who issued the request. Obligatory properties: Properties:
Name Type Description usernameString , One of optional properties Optional properties: recovery_emailString hashed_passwordString Returns:
- {success:Boolean response:Array or Error}- Type
- JSON
-
<async, inner> getAllPatients(isAdult)
-
Get all the patients from the database
Parameters:
Name Type Description isAdultBoolean If the records should be displayed for adult users Returns:
result of the query - {success:true/false response:Array/Error}- Type
- JSON
-
<async, inner> getAllUsers()
-
Get all users from database
Returns:
result of the query - {success:true/false response:Array/Error}- Type
- JSON
-
<async, inner> getCarer(carerID)
-
Get the carer given its carer id
Parameters:
Name Type Description carerIDstring the carer id Returns:
- {success:Boolean response:Array or Error}- Type
- JSON
-
<async, inner> getFullPatientInfo(patient_no)
-
Get the info of the patient together with the info of eventual carers and hospitals
Parameters:
Name Type Description patient_nostring the patient number Returns:
- {success:Boolean response:Array or Error}- Type
- JSON
-
<async, inner> getHospital(hospital_id)
-
Get the hospital given its hospital id
Parameters:
Name Type Description hospital_idstring the hospital id Returns:
- {success:Boolean response:Array or Error}- Type
- JSON
-
<inner> getNextDueDate(frequency)
-
Get next due date of a test in "YYYY-MM-DD" format; relative to today
Parameters:
Name Type Description frequencyString frequency of the test as stored in database Returns:
- next due date in "YYYY-MM-DD" format- Type
- String
-
<async, inner> getNextTestsOfPatient(patientId)
-
Get not completed tests from patient
Parameters:
Name Type Description patientIdString id of patient Returns:
result of the query - {success:true/false response:Array/Error}- Type
- JSON
-
<async, inner> 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 isAdultBoolean 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, inner> getPatient(patient_no)
-
Get the patient given its patient number
Parameters:
Name Type Description patient_nostring the patient number Returns:
- {success:Boolean response:Array or Error}- Type
- JSON
-
<async, inner> getReport(date)
-
Collects data from selector queries and returns them.
Parameters:
Name Type Description datedate Returns:
{success:Boolean, response:JSON}- Type
- JSON
-
<async, inner> getTest(test_id)
-
Get test from the database
Parameters:
Name Type Description test_idString id of test Returns:
result of the query - {success:true/false response:Array/Error}- Type
- JSON
-
<async, inner> getTestInfo(test_id)
-
Get test info with patient info from the database
Parameters:
Name Type Description test_idString id of test Returns:
result of the query - {success:true/false response:Array/Error}- Type
- JSON
-
<async, inner> getTestWithinWeek(date, isAdult)
-
Get all tests within the week from the database
Parameters:
Name Type Description dateString any date (from Monday to Friday) within the week to retrieve (format: "YYYY-MM-DD") isAdultBoolean If the records should be displayed for adult users Returns:
result of the query - {success:true/false response:Array/Error}- Type
- JSON
-
<async, inner> getUser(username)
-
Get user from database
Parameters:
Name Type Description usernameString username to retrieve Returns:
result of the query - {success:true/false response:Array/Error}- Type
- JSON
-
<async, inner> requestEditing(table, id, actionUsername)
-
Request editing of an entry in table
Parameters:
Name Type Description tableString Table to edit idString id to edit actionUsernamestring The user who issued the request. Returns:
token- Type
- String
-
<async, inner> returnToken(table, id, token, actionUsername)
-
Cancel editing on an entry
Parameters:
Name Type Description tableString Table of an entry idString id value of an entry tokenString token to return actionUsernamestring The user who issued the request. Returns:
result - {success:Boolean response:"Token cancelled"/Error}- Type
- JSON
-
<async, inner> scheduleNextTest(testId, actionUsername, newInfo)
-
Schedule next blood test based on information in database and/or new information provided New information have priority over stored in database (new info > database info)
Parameters:
Name Type Description testIdString id of a string from which to take the info actionUsernamestring The user who issued the request. newInfoJSON (optional) new info to add into database with new test Returns:
- result of query {success:true/false reply:(optional;when no new entry inserted due to finished range of tests)}- Type
- JSON
-
<inner> sortPatinetProperties(patientInfo)
-
Sort patient properties into patient,carer and hospital information
Parameters:
Name Type Description patientInfoJSON information to be sorted Returns:
Sorted information: {patient: hospital: carer:}- Type
- JSON
-
<async, inner> unscheduleTest(testid, token, actionUsername)
-
Unschedule test
Parameters:
Name Type Description testidString id of the test to delete tokenString token to realease with the unscheduling actionUsernameString username that triggered the action -
<async, inner> updateLastReminder(testId, token, actionUsername)
-
Update when the last reminder for this test was sent.
Parameters:
Name Type Description testIdstring id of a test to change tokenstring The token that grants edit privileges. actionUsernamestring The user who issued the request. Returns:
result of the query - {success:true/false response:Array/Error}- Type
- JSON
Type Definitions
-
getSortedOverdueWeeks
-
Get all the overdue tests from the database plus additional info about time difference
Type:
- SortedWeek
Properties:
Name Type Description classString monday of the week, format: 'Mon Mar 04 2019 00:00:00 GMT+0000 (GMT)'