File tree Expand file tree Collapse file tree 3 files changed +9
-16
lines changed
components/interactive-builder/modals/question/question-form/question Expand file tree Collapse file tree 3 files changed +9
-16
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,9 @@ const Question: React.FC<QuestionProps> = ({ checkIfQuestionIdExists }) => {
97
97
{ ! formField . questionOptions ?. rendering && (
98
98
< SelectItem text = { t ( 'chooseRenderingType' , 'Choose a rendering type' ) } value = "" />
99
99
) }
100
- { formField . type && formField . type !== 'obs' && questionTypes . includes ( formField . type )
100
+ { formField . type &&
101
+ formField . type !== 'obs' &&
102
+ questionTypes . includes ( formField . type as keyof typeof renderTypeOptions )
101
103
? renderTypeOptions [ formField ?. type ] . map ( ( type , key ) => (
102
104
< SelectItem key = { `${ type } -${ key } ` } text = { type } value = { type } />
103
105
) )
Original file line number Diff line number Diff line change @@ -11,7 +11,9 @@ export const questionTypes = [
11
11
'patientIdentifier' ,
12
12
'testOrder' ,
13
13
'programState' ,
14
- ] ;
14
+ ] as const ;
15
+
16
+ export type QuestionType = ( typeof questionTypes ) [ number ] ;
15
17
16
18
export const renderingTypes : Array < RenderType > = [
17
19
'checkbox' ,
@@ -41,7 +43,7 @@ export const renderingTypes: Array<RenderType> = [
41
43
'select-concept-answers' ,
42
44
] ;
43
45
44
- export const renderTypeOptions : Record < string , Array < RenderType > > = {
46
+ export const renderTypeOptions : Record < Exclude < QuestionType , 'obs' > , Array < RenderType > > = {
45
47
control : [ 'text' , 'markdown' ] ,
46
48
encounterDatetime : [ 'date' , 'datetime' ] ,
47
49
encounterLocation : [ 'ui-select-extended' ] ,
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import type {
8
8
RequiredFieldProps ,
9
9
} from '@openmrs/esm-form-engine-lib' ;
10
10
import type { AuditInfo } from './components/audit-details/audit-details.component' ;
11
+ import type { questionTypes } from '@constants' ;
11
12
12
13
export interface Form {
13
14
uuid : string ;
@@ -44,19 +45,7 @@ export interface Resource {
44
45
valueReference : string ;
45
46
}
46
47
47
- export type QuestionType =
48
- | 'complex-obs'
49
- | 'control'
50
- | 'encounterDatetime'
51
- | 'encounterLocation'
52
- | 'encounterProvider'
53
- | 'encounterRole'
54
- | 'obs'
55
- | 'obsGroup'
56
- | 'patientIdentifier'
57
- | 'personAttribute'
58
- | 'testOrder'
59
- | 'programState' ;
48
+ export type QuestionType = ( typeof questionTypes ) [ number ] ;
60
49
61
50
export type DatePickerType = 'both' | 'calendar' | 'timer' ;
62
51
You can’t perform that action at this time.
0 commit comments