Skip to main content

Frequently Asked Questions (FAQ)

How do I format the date from a datasource?

You can use the FORMAT_DATE function that is in the expression assistant. When binding a date value to a rich text field for example, use the expression assistant to add the FORMAT_DATE function, in the brackets add the date from the datasource and after the comma in single quotation marks enter the desired format. The format needs to be compliant to the documentation of the date-fns library - Date formats

Format date assistant

How do I copy a form or summary from one project to another?

To copy a form or summary to another project, you can simply use the menu button of the form in the select screen and click on "Copy to another project" button.

Copy form to another project

A modal window will pop up asking you to select a project where you want to copy the form to. After you select the project you will be notified about the missing resources that are needed for the form to work on the destination project. If the project you have selected does not have the template(s) used on the form you will be asked if you also want to copy the templates. In this case this option will be defaulted to "yes" since the form is not valid without them. If the project you have selected does already have the template(s) you will be asked if you want to override them with the ones from the form. The default for this will be "no", but you can opt to override the templates on that project. This is because many times templates have changed, and they might not be the same on the current project than on the target project.

Copy form modal

Similarly, when copying a summary you will be prompted if you want to copy the forms and templates used, if the target project does not have them. If the templates or forms exist, you will also have the option to view the information about who and when it was created on that project.

Copy summary modal

Can I let the user select one of the past measurements from a list?

Sure, in this example we will use a AQL vriable to query the last 5 weight results from the selected patient, show them in a column list and let the user select one to fill it into the template field.

Let's start with the AQL variable. On the left go to the variables panel, click "Add variable" and select a variable name. For the source, select "AQL" and in the AQL value, click on the "+" sign to add a query. You will be redirected to the AQL builder, when you can build the query. Find the desired template and specific field from the left panel. In this example we also want to add the information about when this data was recorded. We can find this information in the "Predefined objects" panel under Composition and composition -> start time -> value. Once we have these two fields, we can also limit them to the selected ehrId. We do this by adding the following line in the bottom before the last line when we set the LIMIT:

WHERE e/ehr_id/value = :ehrId

This will limit the results to the value of out external variable ehrId.

Below is an example of the AQL query which returns the last five weights and when they were recorded for a specific template and EHR ID:

SELECT m/data[at0002]/events[at0003]/data[at0001]/items[at0004]/value AS weight,
c/context/start_time/value AS composition_context_start_time_value
WHERE e/ehr_id/value = :ehrId

Now to initialize this properly within the form builder, we need to add a test value to the ehrId external variable. Preferably one that has some composition data to it.

After we have this, let's put a weight field from the template to the form and add a column list to it as well. Set the column list datasource to the AQL variable we created. In the first row lets display the date. We can format it using FORMAT_DATE. On the second let's concat the weight magnitude and weight units. Here we will also put in a hidden numeric field. Set this field to the weight magnitude and hide it, we will be using it later.

Now let's create a new dependency that will use the weight magnitude from the hidden field and set it to the template weight field, when the row is clicked. It should look something like this:

Select from datalist to field

When we go to preview, the user can simply click a row of the column list and the weight will automatically be set with that value.

Select from datalist to field preview

See the video example here:

Can I validate an email and only allow users to save the composition if it is in a valid format?

Yes you can, after you added your text field, go to the property panel on the right-hand side and search in the "Content" tab for the "Field validation" section. Here you can choose from one of the predefined patterns and select "Email" (if you want you can also provide your own pattern that needs to follow the regEx standard). You can also set your own error message if the pattern is not valid and if you have a multilingual form you can set the translations here too.

How do I update a composition instead of creating a new one?

To update a composition you need to have a compositionId which you want to update. In the Studio you can do that on preview or the playground simply by selecting a compositionId from the dropdown on the left.

Selecting compositionId

If you are building your own application using the form renderer, you need to provide it by setting the "compositionId" variable.

const environment = {
variables: [
name: 'ehrId',
value: '000-92ac-4bf6-bfed-f0d4b9f6'
const compositionId = 'f8805e7e-0000-1111-222c-74ca6b0a53e9::test::1';

fr.formEnvironment = environment;
fr.compositionId = compositionId;

The same will also be achieved if you are using the "auto prefill" functionality, since this also sets the form with a composition. After you have your compositionId set and the form is prefilled, you simply use the "Save composition" button in your preview / playground, or if you want button with a dependency on it that saves the composition. Saving like this will automatically update the composition instead of creating a new one.

Be careful that the composition you inserted doesn't already have an update, in that case a error will display that the composition provided cannot be updated since it already has an updated version.