Skip to main content

ValueSet Select

The ValueSet select (mona-value-set-select) is used when options must come from a FHIR ValueSet — for example in questionnaires (via answerValueSet) or in any form that references a ValueSet (e.g. allergy reaction severity). It uses the same combobox UI as the combobox form field, with loading and error states while the ValueSet is fetched and expanded. It follows the same form field base patterns (label, errors, disabled state).

Behavior overview

StateBehavior
IdleWhen valueSetRef is missing or has empty id/url, the component shows noValueSetLabel in an error-style box. No request is sent.
LoadingSpinner plus loadingLabel until the ValueSet is fetched and expanded.
ErrorShown when the load fails: no fhirBaseUrl, network/server error, or ValueSet has no expansion. Displays the server message or errorLabel.
LoadedRenders mona-combobox with search/filter and options from the ValueSet expansion.

FHIR server configuration

The component requires a FHIR base URL to resolve and expand the ValueSet. Without it, the error state shows “FHIR base URL is not configured.”

  • Per instance: Pass fhirBaseUrl (required for loading) and optionally fhirCredentials when using a specific server (e.g. from scenario or tenant config).
  • In the questionnaire renderer, the host (e.g. Form Applet or Select Wrapper) passes fhirBaseUrl into the renderer, which forwards it to choice items that use answerValueSet.

Inputs (summary)

InputTypeDefaultPurpose
valueSetRef{ id: string } | { url: string } | undefinedReference to the ValueSet. Use url for canonical URL (e.g. http://hl7.org/fhir/ValueSet/reaction-event-severity) or id for logical id on the given FHIR server. If missing or empty, the component shows noValueSetLabel.
fhirBaseUrlstring | undefinedRequired to load options. FHIR server base URL (e.g. https://hapi.fhir.org/baseR4).
fhirCredentialsstring | undefinedOptional credentials for the FHIR server (e.g. Basic … or Bearer …).
valueShape'coding' | 'valueCoding''coding'Emitted value shape. Use 'valueCoding' for questionnaire choice answers (wraps the coding in { valueCoding: Coding }).
labelstring | undefinedLabel text above the field.
placeholderLabelstring'Select…'Placeholder text for the closed combobox trigger.
placeholderSearchLabelstring'Type to filter…'Placeholder for the search input inside the dropdown when no override is set.
filterPlaceholderLabelstring | undefinedWhen set, overrides placeholderSearchLabel for the search input in the dropdown.
loadingLabelstring'Loading options…'Shown next to the spinner while the ValueSet is loading (i18n).
errorLabelstring'Could not load options.'Fallback message when the ValueSet load fails (i18n or server message).
noValueSetLabelstring'No ValueSet specified. Provide a valid valueSetRef (id or url).'Shown when valueSetRef is missing or has no valid id/url.
requiredboolean | undefinedWhen true, shows required indicator and can be used with validators.
controlErrorsRecord<string, unknown> | nullnullValidation errors object for mona-field-error.
controlStatusFormControlStatus | nullnullControl status for mona-field-error.
errorMessagesRecord<string, string>{}Map of error key → message for validation errors (e.g. required).

Use cases

  • Questionnaires: Bind to item.answerValueSet so choice options are loaded from the referenced ValueSet. The questionnaire renderer passes fhirBaseUrl (and optionally fhirCredentials) from the host; use valueShape="valueCoding" for the response format.
  • Standalone forms: Any form field driven by a ValueSet (e.g. allergy reaction severity, condition code). Provide fhirBaseUrl and valueSetRef.

Example usage

Minimal example (requires fhirBaseUrl for options to load):

<mona-value-set-select
formControlName="reactionSeverity"
[valueSetRef]="{ url: 'http://hl7.org/fhir/ValueSet/reaction-event-severity' }"
[fhirBaseUrl]="fhirBaseUrl"
[label]="'Reaction severity'"
[loadingLabel]="'Loading options...'"
[errorLabel]="'Failed to load options'"
[noValueSetLabel]="'No value set configured'"
[placeholderLabel]="'Select severity'"
/>

With a scenario-specific FHIR server and credentials:

<mona-value-set-select
formControlName="answer"
[valueSetRef]="item.answerValueSet"
[fhirBaseUrl]="scenarioFhirBaseUrl()"
[fhirCredentials]="scenarioFhirCredentials()"
valueShape="valueCoding"
[loadingLabel]="'VALUE_SET.LOADING' | transloco"
[errorLabel]="'VALUE_SET.ERROR' | transloco"
[noValueSetLabel]="'VALUE_SET.NO_REF' | transloco"
[placeholderLabel]="'VALUE_SET.PLACEHOLDER' | transloco"
/>

Integration with form fields

The ValueSet select follows the same form field structure: optional label, control area (trigger + popover with search), and error output via mona-field-error. Use errorMessages for validation errors (e.g. required); use loadingLabel, errorLabel, and noValueSetLabel for ValueSet loading and configuration errors. It implements ControlValueAccessor and works with formControlName / reactive forms.