stack
Last updated 30/01/2024
Example One
stack
property on the Five
object in functions.
The function checks if a patient's address has a post code. To find the associated address for the patient we use the PatientKey
(Primary key in the Patient table) in the
stack.
Check if patient details are up to date
function UserDetailsUpToDate(five: Five, context: any, result: FiveError) : FiveError {
const sql = `SELECT PostCode FROM Address WHERE PatientKey=?`;
const results = five.executeQuery(sql, 0, five.stack.Patient.PatientKey);
if (results.isOk() === false) {
return five.createError(results);
}
if (results.recordCount() !== 1) {
return five.createError('Patient not found');
}
if (results.records['PostCode'] === '') {
return five.createError(result, 'Patient records need updating');
}
return five.success(result);
}
Check if patient details are up to date
function UserDetailsUpToDate(five, context, result) {
const sql = `SELECT PostCode FROM Address WHERE PatientKey=?`;
const results = five.executeQuery(sql, 0, five.stack.Patient.PatientKey);
if (results.isOk() === false) {
return five.createError(results);
}
if (results.recordCount() !== 1) {
return five.createError('Patient not found');
}
if (results.records['PostCode'] === '') {
return five.createError(result, 'Patient records need updating');
}
return five.success(result);
}
Example Two
stack
property on the Five
object in a query.
The following syntax retrieves all addresses associated with the selected Restaurant record in the stack. The RestaurantKey
(Primary Key in the Restaurant table) is
used in the stack as a parameter in the query.
Return the Restaurant Addresses
SELECT
AddressKey,
CONCAT(AddressLine1, " ", AddressLine2) AS Address
FROM
Address
WHERE RestaurantKey = ?
The following image demonstrates how to enter the stack
property as a parameter on the Query form.
Figure 1 - Add a parameter using the five.stack property