Skip to main content

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

KeyTypeRequiredDefaultDescription
languagestringfalse-Specifies the language that the whole form renderer uses. If none is provided it will take default language from form-description.
territorystringfalseSIProvides the form with a territory code, usually in the ISO 3166 standard. If territory is not provided, the language code will be used.
readonlybooleanfalse-Specifies whether the form and all of its fields will be in read only mode.
dateFormatstringfalsedd/MM/yyyySpecifies the date format for DV_DATE and DV_DATE_TIME fields. Accepts Date formats
validationDisabledbooleanfalsefalseSpecifies whether completely disable validation on form-renderer.
timePlaceholderMrdTimePlaceholderFormatfalse-Specifies placeholders for hours and minutes on DV_TIME and DV_DATE_TIME.
datePlaceholderstringfalse-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.
showNumericRangePlaceholderbooleanfalsefalseIf 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".
displayValidationMessagesOnTouchedbooleanfalsefalseBy 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.
terminologyUrlstringfalse-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.
dropdownPresentationMinItemsnumberfalse-When this is set as number n >= 0, presentation dropdown will, if number of selectable elements ⇐ n change from dropdown into checkboxes/radio buttons.
displayDateInputMaskbooleanfalsefalseInput 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.
disableFormScriptbooleanfalsefalseCompletely disable any form script/dependencies. Useful primarily for Form Builder.
textareaAutosizebooleanfalsefalseText field can autosize by default if it has many lines provided.
disableScriptRunOnInitializationbooleanfalsefalseSpecifies whether the script will run on initial load (when form is rendered).
presentationModebooleanfalsefalseshows form in a read only compact presentation mode.
showAllPagesbooleanfalsefalseshows all pages at once (that are not specifically excluded via multi paging). This property relates to presentation mode.
themestringfalse"DEFAULT"renderer comes with two predefined themes: DEFAULT and WHITE (white background)
showFieldsRequiredIndicatorbooleanfalsefalseSpecifies whether marks for the required fields should be displayed on form.
autoPrefillobjectfalse{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.
uploadUrlstringfalse-URL used for uploading a files through multimedia form inputs
disableDefaultAttachmentDownloadbooleanfalsefalseWhen 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
warning
If custom aql view option is provided, it will have a priority over mode setting

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"
}
]