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
| State | Behavior |
|---|---|
| Idle | When valueSetRef is missing or has empty id/url, the component shows noValueSetLabel in an error-style box. No request is sent. |
| Loading | Spinner plus loadingLabel until the ValueSet is fetched and expanded. |
| Error | Shown when the load fails: no fhirBaseUrl, network/server error, or ValueSet has no expansion. Displays the server message or errorLabel. |
| Loaded | Renders 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 optionallyfhirCredentialswhen 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
fhirBaseUrlinto the renderer, which forwards it to choice items that useanswerValueSet.
Inputs (summary)
| Input | Type | Default | Purpose |
|---|---|---|---|
valueSetRef | { id: string } | { url: string } | undefined | — | Reference 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. |
fhirBaseUrl | string | undefined | — | Required to load options. FHIR server base URL (e.g. https://hapi.fhir.org/baseR4). |
fhirCredentials | string | undefined | — | Optional 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 }). |
label | string | undefined | — | Label text above the field. |
placeholderLabel | string | 'Select…' | Placeholder text for the closed combobox trigger. |
placeholderSearchLabel | string | 'Type to filter…' | Placeholder for the search input inside the dropdown when no override is set. |
filterPlaceholderLabel | string | undefined | — | When set, overrides placeholderSearchLabel for the search input in the dropdown. |
loadingLabel | string | 'Loading options…' | Shown next to the spinner while the ValueSet is loading (i18n). |
errorLabel | string | 'Could not load options.' | Fallback message when the ValueSet load fails (i18n or server message). |
noValueSetLabel | string | 'No ValueSet specified. Provide a valid valueSetRef (id or url).' | Shown when valueSetRef is missing or has no valid id/url. |
required | boolean | undefined | — | When true, shows required indicator and can be used with validators. |
controlErrors | Record<string, unknown> | null | null | Validation errors object for mona-field-error. |
controlStatus | FormControlStatus | null | null | Control status for mona-field-error. |
errorMessages | Record<string, string> | {} | Map of error key → message for validation errors (e.g. required). |
Use cases
- Questionnaires: Bind to
item.answerValueSetso choice options are loaded from the referenced ValueSet. The questionnaire renderer passesfhirBaseUrl(and optionallyfhirCredentials) from the host; usevalueShape="valueCoding"for the response format. - Standalone forms: Any form field driven by a ValueSet (e.g. allergy reaction severity, condition code). Provide
fhirBaseUrlandvalueSetRef.
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.