Using Macros
Grafana Macros
Grafana macros are predefined placeholders that you can use in your queries, dashboard settings, and other configuration aspects to dynamically insert values or parameters. For more information on Grafana's macros please see this article
In addition to Grafana’s macros, BioT provides one macro called $__biotUser.
This macro is equivalent to the “Get Self Organization User by ID from access token” API call.
Below are all the default accessible BioT macro expressions for a caregiver:
Macro name | Data Type |
---|---|
'$__biotUser(_userType)' | text |
'$__biotUser(_name.firstName)' | text |
'$__biotUser(_name.lastName)' | text |
'$__biotUser(_description)' | text |
'$__biotUser(_email)' | text |
'$__biotUser(_phone)' | test |
'$__biotUser(_locale)' | text |
'$__biotUser(_address.countryCode)' | text |
'$__biotUser(_address.state)' | text |
'$__biotUser(_address.city)' | text |
'$__biotUser(_address.zipCode)' | text |
'$__biotUser(_address.address1)' | text |
'$__biotUser(_address.address2)' | text |
'$__biotUser(_mfa.enabled)' | bool |
'$__biotUser(_mfa.expirationInMinutes)' | numeric |
'$__biotUser(_employeeId)' | text |
'$__biotUser(_degree)' | text |
'$__biotUser(_ownerOrganization.id)' | text |
'$__biotUser(_ownerOrganization.templateId)' | text |
'$__biotUser(_ownerOrganization.parentEntityId)' | text |
'$__biotUser(_ownerOrganization.templateName)' | text |
'$__biotUser(_ownerOrganization.name)' | text |
'$__biotUser(_template.name)' | text |
'$__biotUser(_template.displayName)' | text |
'$__biotUser(_template.id)' | text |
'$__biotUser(_id)' | text |
'$__biotUser(_creationTime)' | timestamp |
'$__biotUser(_lastModifiedTime)' | timestamp |
'$__biotUser(_invitationAccepted)' | bool |
'$__biotUser(_enabled)' | bool |
'$__biotUser(_caption)' | text |
Custom Attributes
If you add custom fields to the caregiver, organization, user, or admin templates, you can access these fields in the same way as the default attributes listed above.
To retrieve all your user details, in this case, the caregiver, you can run the following query:
SELECT '$__biotUser(_userType)' AS userType, '$__biotUser(_name.firstName)' AS firstName, '$__biotUser(_name.lastName)' AS lastName,
'$__biotUser(_description)' AS description, '$__biotUser(_email)' AS email, '$__biotUser(_phone)' AS
phone, '$__biotUser(_locale)' AS locale, '$__biotUser(_address.countryCode)' AS
addressCountryCode, '$__biotUser(_address.state)' AS addressState, '$__biotUser(_address.city)' AS addressCity, '$__biotUser(_address.zipCode)' AS addressZipCode,
'$__biotUser(_address.address1)' AS address1, '$__biotUser(_address.address2)' AS address2,
'$__biotUser(_mfa.enabled)' AS mfaEnabled, '$__biotUser(_mfa.expirationInMinutes)' AS
mfaExpirationInMinutes, '$__biotUser(_employeeId)' AS employeeId, '$__biotUser(_degree)' AS
degree, '$__biotUser(_ownerOrganization.id)' AS ownerOrgId, '$__biotUser(_ownerOrganization.templateId)' AS ownerOrgTemplateId, '$__biotUser(_ownerOrganization.parentEntityId)' AS
ownerOrgParentEntityId, '$__biotUser(_ownerOrganization.templateName)' AS ownerOrgTemplateName,
'$__biotUser(_ownerOrganization.name)' AS ownerOrgName, '$__biotUser(_id)' AS id, '$__biotUser(_creationTime)' AS
creationTime, '$__biotUser(_lastModifiedTime)' AS lastModifiedTime, '$__biotUser(_invitationAccepted)' AS invitationAccepted, '$__biotUser(_template.name)' AS templateName,
'$__biotUser(_template.displayName)' AS templateDisplayName, '$__biotUser(_template.id)' AS templateId,
'$__biotUser(_enabled)' AS enabled, '$__biotUser(_caption)' AS caption
The result as shown:
You can use BioT’s macros to display only relevant information to the user.
For instance, if you are building a dashboard for caregivers and want to display data for patients assigned to them, you can apply the following filters.
Assuming you have heart rate observations for your patients, you can do the following:
SELECT OB."patientId", OB."heart_rate_1", OB."timestamp"
FROM "AnalyticsDB"."Observations_Patient_patient" AS OB,
"AnalyticsDB"."Patient_patient" AS PP,
"AnalyticsDB"."Clinician_caregiver" AS CC
WHERE PP."_caregiver.id" = '$__biotUser(_id)'
AND PP."_id" = OB."patientId"
AND CC."_id" = '$__biotUser(_id)'
This query will return data for patients assigned to the caregiver who is currently viewing the dashboard, excluding any other patients.
Updated 2 months ago