Configuring renderer with EhrFormContext
EhrFormContext is an object containing configuration properties for form renderer. It contains attributes like language, theme, different placeholder formats and even attributes for disabling validation. To learn how to pass context object to renderer head to Usage.
Full list of configuration attributes
Key | Type | Required | Default | Description |
---|---|---|---|---|
language | string | false | - | Specifies the language that the whole form renderer uses. If none is provided it will take default language from form-description. |
territory | string | false | SI | Provides the form with a territory code, usually in the ISO 3166 standard. If territory is not provided, the language code will be used. |
readonly | boolean | false | - | Specifies whether the form and all of its fields will be in read only mode. |
dateFormat | string | false | dd/MM/yyyy | Specifies the date format for DV_DATE and DV_DATE_TIME fields. Accepts Date formats |
validationDisabled | boolean | false | false | Specifies whether completely disable validation on form-renderer. |
timePlaceholder | MrdTimePlaceholderFormat | false | - | Specifies placeholders for hours and minutes on DV_TIME and DV_DATE_TIME. |
datePlaceholder | string | false | - | Priority for date placeholder: 1. checks in there is placeholder annotation, 2. checks if there is datePlaceholder in EhrFormContext, 3. Shows format of date. applicable for DV_DATE & DV_DATE_TIME. |
showNumericRangePlaceholder | boolean | false | false | If set to true, and there is not specific placeholder for specific field of type DV_COUNT, DV_PROPORTION, DV_QUANTITY and this field has restriction which values are possible, you will get this as a placeholder. If, for example limit for field is between 1 and 10, placeholder will show "Insert value from 1 to 10". |
displayValidationMessagesOnTouched | boolean | false | false | By default, touching field and then selecting some other element wont automatically show you validation error if the field is not valid. By setting this property to true you will get validation errors also when touching/clicking on field. |
terminologyUrl | string | false | - | Form-description can already have it’s own terminology specified, if it doesn't or you would like to override it you can provide your own terminology url, where fields that use terminology will connect to get values. |
dropdownPresentationMinItems | number | false | - | When this is set as number n >= 0, presentation dropdown will, if number of selectable elements ⇐ n change from dropdown into checkboxes/radio buttons. |
displayDateInputMask | boolean | false | false | Input for date can be enriched by immediately showing you mask of date format. If for example your date format is YYYY-MM-DD you will immediately see -- in input and when writing value you don’t have to write dashes (-), only numbers. |
disableFormScript | boolean | false | false | Completely disable any form script/dependencies. Useful primarily for Form Builder. |
textareaAutosize | boolean | false | false | Text field can autosize by default if it has many lines provided. |
disableScriptRunOnInitialization | boolean | false | false | Specifies whether the script will run on initial load (when form is rendered). |
presentationMode | boolean | false | false | shows form in a read only compact presentation mode. |
showAllPages | boolean | false | false | shows all pages at once (that are not specifically excluded via multi paging). This property relates to presentation mode. |
theme | string | false | "DEFAULT" | renderer comes with two predefined themes: DEFAULT and WHITE (white background) |
showFieldsRequiredIndicator | boolean | false | false | Specifies whether marks for the required fields should be displayed on form. |
autoPrefill | object | false | {enabled: false, mode: 'LATEST_COMPOSITION'} | The user can specify with a boolean if he wants autoPrefill enabled or not, this will automatically prefill the field values. The second parameter can be either LATEST_COMPOSITION which will fill the fields with the latest composition of the provided ehrId or LATEST_COMPLETED_COMPOSITION which will fill the fields with the latest composition with the lifecycle: completed tag of the provided ehrId. ehrId is a mandatory variable when using this property. |
cspSettings | { enabled: boolean, nonce?: string } | false | - | Content Security Policy (CSP) is an added layer of security that helps to detect and mitigate certain types of attacks, including Cross-Site Scripting (XSS) and data injection attacks. These attacks are used for everything from data theft, to site defacement, to malware distribution. |
uploadUrl | string | false | - | URL used for uploading a files through multimedia form inputs |
disableDefaultAttachmentDownload | boolean | false | false | When set to true, disables the default download behavior in the renderer, requiring the user to handle the ATTACHMENT_DOWNLOAD_INITIATED event and implement custom download logic |
attachmentUrlFormat | 'absolute' \| 'relative' | false | 'absolute' | When set to 'relative', multimedia attachments can be downloaded or previewed using the relative part of the URL stored in the composition. It will construct a URL to fetch the attachment from the base URL where the application/renderer is included. This applies only if the attachment is stored on Better Store or if a URL follows the same pattern as the Better Store API (/store/rest/:id). If URL does not follow this pattern the first / in URL will be used as a separator for relative part |
decimalSeparator | '.' \| ',' | false | '.' | Specifies the character used as the decimal point in number formatting. This separator is applied only to the value displayed in the input field. The value stored in the model is always a number with a decimal dot. |
Auto prefill
The user can provide an option to prefill document from already persisted data.
If enabled, there are multiple options to choose from:
- LATEST_COMPOSITION - will load latest persisted composition for given template
- LATEST_COMPLETED_COMPOSITION- will load latest completed composition for given template
- CUSTOM_AQL_VIEW - will load composition provided by the user selected AQL view Usage
How this settings can be provided you can see it here Usage.
Custom AQL view
There are two options to provide custom AQL view. If user provides AQL view of type webTemplate than this view will load composition by default, the other way of doing it is to provide custom AQL view of any other type, but in this case the result should have a single uid provided as a result.
Example of webTemplate AQL view
Type
Freemarker AQL - WEB Template FLAT or STRUCTURED format
Meta data
{
"properties": {
"meta": "false",
"format": "STRUCTURED"
},
"parameters": [
{
"name": "ehrId",
"description": "",
"type": "string"
},
{
"name": "templateId",
"description": "",
"type": "string"
}
]
}
Data
SELECT c FROM EHR e[ehr_id/value=:ehrId]
CONTAINS VERSION v
CONTAINS COMPOSITION c
WHERE c/archetype_details/template_id/value = :templateId
AND v/lifecycle_state matches {'complete', 'incomplete'}
ORDER BY v/commit_audit/time_committed DESC
FETCH 1
Example of custom AQL view:
AQL view that returns uid value of the latest composition saved for the template id and is either in complete or incomplete status:
SELECT c/uid/value as uid
FROM EHR e[ehr_id/value=:ehrId]
CONTAINS VERSION v
CONTAINS COMPOSITION c
WHERE c/archetype_details/template_id/value = :templateId
AND v/lifecycle_state matches {'complete', 'incomplete'}
ORDER BY v/commit_audit/time_committed DESC
FETCH 1
Result should return single uid value for queried data:
[
{
"uid": "ac3981b6-64eb-4cfc-bd91-2b33fde0897b::studio-user::1"
}
]