Skip to content

Commit

Permalink
Add default value for refernce search bar column
Browse files Browse the repository at this point in the history
  • Loading branch information
vesnushka committed Dec 10, 2024
1 parent 0b4a65e commit b122366
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/components/SearchBar/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,16 @@ export function useSearchBar(props: SearchBarProps): SearchBarData {
}

if (isReferenceColumn(column)) {
return { column, value: null };
return {
column,
value: column.defaultValue
? {
value: {
Reference: column.defaultValue,
},
}
: null,
};
}

if (isChoiceColumn(column)) {
Expand Down
9 changes: 8 additions & 1 deletion src/components/SearchBar/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { Coding } from 'fhir/r4b';

import { Expression, Resource, QuestionnaireItemChoiceColumn, ValueSet } from '@beda.software/aidbox-types';
import {
Expression,
Resource,
QuestionnaireItemChoiceColumn,
ValueSet,
AidboxReference,
} from '@beda.software/aidbox-types';

import { ValueSetOption } from 'src/services';
import { LoadResourceOption } from 'src/services/questionnaire';
Expand Down Expand Up @@ -41,6 +47,7 @@ export type SearchBarReferenceColumn = SearchBarColumnBase & {
expression: Expression['expression'];
path: QuestionnaireItemChoiceColumn['path'];
placeholder: string;
defaultValue?: AidboxReference;
};
export type SearchBarChoiceColumn = SearchBarColumnBase & {
type: SearchBarColumnType.CHOICE;
Expand Down

0 comments on commit b122366

Please sign in to comment.