From 589b6c8f68aed762d02e6294ab04737068436537 Mon Sep 17 00:00:00 2001 From: jabahum Date: Wed, 28 May 2025 15:00:11 +0300 Subject: [PATCH 1/3] add support for RDE --- .../form-editor/form-editor.component.tsx | 130 +++++++++++------- src/config-schema.ts | 6 + 2 files changed, 88 insertions(+), 48 deletions(-) diff --git a/src/components/form-editor/form-editor.component.tsx b/src/components/form-editor/form-editor.component.tsx index 77b498341..65a44892e 100644 --- a/src/components/form-editor/form-editor.component.tsx +++ b/src/components/form-editor/form-editor.component.tsx @@ -65,7 +65,7 @@ const ErrorNotification = ({ error, title }: ErrorProps) => { const FormEditorContent: React.FC = ({ t }) => { const defaultEnterDelayInMs = 300; const { formUuid } = useParams<{ formUuid: string }>(); - const { blockRenderingWithErrors, dataTypeToRenderingMap } = useConfig(); + const { blockRenderingWithErrors, dataTypeToRenderingMap, enableRDESection } = useConfig(); const isNewSchema = !formUuid; const [schema, setSchema] = useState(); const { form, formError, isLoadingForm } = useForm(formUuid); @@ -142,7 +142,86 @@ const FormEditorContent: React.FC = ({ t }) => { } }; + const buildRdeSection = () => ({ + label: 'Encounter Details', + isExpanded: 'false', + questions: [ + { + id: 'encounterDateTime', + label: 'Encounter Date & Time', + type: 'encounterDateTime', + questionOptions: { + rendering: 'date', + concept: 'a-system-defined-concept-uuid', + }, + }, + { + id: 'encounterProvider', + label: 'Encounter Provider', + type: 'encounterProvider', + questionOptions: { + rendering: 'ui-select-extended', + concept: 'a-system-defined-concept-uuid', + }, + }, + ], + }); + const inputDummySchema = useCallback(() => { + const sections = []; + + // Conditionally insert RDE section + if (enableRDESection) { + sections.push(buildRdeSection()); + } + + sections.push( + { + label: 'A Section', + isExpanded: 'true', + questions: [ + { + id: 'sampleQuestion', + label: 'A Question of type obs that renders a text input', + type: 'obs', + questionOptions: { + rendering: 'text', + concept: 'a-system-defined-concept-uuid', + }, + }, + ], + }, + { + label: 'Another Section', + isExpanded: 'true', + questions: [ + { + id: 'anotherSampleQuestion', + label: 'Another Question of type obs whose answers get rendered as radio inputs', + type: 'obs', + questionOptions: { + rendering: 'radio', + concept: 'system-defined-concept-uuid', + answers: [ + { + concept: 'another-system-defined-concept-uuid', + label: 'Choice 1', + }, + { + concept: 'yet-another-system-defined-concept-uuid', + label: 'Choice 2', + }, + { + concept: 'yet-one-more-system-defined-concept-uuid', + label: 'Choice 3', + }, + ], + }, + }, + ], + }, + ); + const dummySchema: FormSchema = { encounterType: '', name: 'Sample Form', @@ -153,59 +232,14 @@ const FormEditorContent: React.FC = ({ t }) => { pages: [ { label: 'First Page', - sections: [ - { - label: 'A Section', - isExpanded: 'true', - questions: [ - { - id: 'sampleQuestion', - label: 'A Question of type obs that renders a text input', - type: 'obs', - questionOptions: { - rendering: 'text', - concept: 'a-system-defined-concept-uuid', - }, - }, - ], - }, - { - label: 'Another Section', - isExpanded: 'true', - questions: [ - { - id: 'anotherSampleQuestion', - label: 'Another Question of type obs whose answers get rendered as radio inputs', - type: 'obs', - questionOptions: { - rendering: 'radio', - concept: 'system-defined-concept-uuid', - answers: [ - { - concept: 'another-system-defined-concept-uuid', - label: 'Choice 1', - }, - { - concept: 'yet-another-system-defined-concept-uuid', - label: 'Choice 2', - }, - { - concept: 'yet-one-more-system-defined-concept-uuid', - label: 'Choice 3', - }, - ], - }, - }, - ], - }, - ], + sections: sections, }, ], }; setStringifiedSchema(JSON.stringify(dummySchema, null, 2)); updateSchema({ ...dummySchema }); - }, [updateSchema]); + }, [updateSchema, enableRDESection]); const renderSchemaChanges = useCallback(() => { resetErrorMessage(); diff --git a/src/config-schema.ts b/src/config-schema.ts index a62279d35..572bc3357 100644 --- a/src/config-schema.ts +++ b/src/config-schema.ts @@ -90,6 +90,11 @@ export const configSchema = { _default: false, _description: 'Whether to enable form validation', }, + enableRDESection: { + _type: Type.Boolean, + _default: false, + _description: 'Whether to enable the RDE section in the form builder', + }, }; export interface ConfigObject { @@ -99,4 +104,5 @@ export interface ConfigObject { dataTypeToRenderingMap: Record>; enableFormValidation: boolean; blockRenderingWithErrors: boolean; + enableRDESection: boolean; } From cda7420f8d1e350484ff0ed3a73118f2d7600724 Mon Sep 17 00:00:00 2001 From: jabahum Date: Thu, 29 May 2025 17:58:40 +0300 Subject: [PATCH 2/3] remove concept attribute from fields --- src/components/form-editor/form-editor.component.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/form-editor/form-editor.component.tsx b/src/components/form-editor/form-editor.component.tsx index 65a44892e..4358ade16 100644 --- a/src/components/form-editor/form-editor.component.tsx +++ b/src/components/form-editor/form-editor.component.tsx @@ -152,7 +152,6 @@ const FormEditorContent: React.FC = ({ t }) => { type: 'encounterDateTime', questionOptions: { rendering: 'date', - concept: 'a-system-defined-concept-uuid', }, }, { @@ -161,7 +160,6 @@ const FormEditorContent: React.FC = ({ t }) => { type: 'encounterProvider', questionOptions: { rendering: 'ui-select-extended', - concept: 'a-system-defined-concept-uuid', }, }, ], From 0f43c2a860a6ab9f885b1b016602987da2df45f1 Mon Sep 17 00:00:00 2001 From: jabahum Date: Thu, 29 May 2025 17:59:29 +0300 Subject: [PATCH 3/3] improve config-schema attribute description --- src/config-schema.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/config-schema.ts b/src/config-schema.ts index 572bc3357..e2bd5aac5 100644 --- a/src/config-schema.ts +++ b/src/config-schema.ts @@ -93,7 +93,8 @@ export const configSchema = { enableRDESection: { _type: Type.Boolean, _default: false, - _description: 'Whether to enable the RDE section in the form builder', + _description: + 'Whether to add an Encounter Details section for retrospective data entry, which includes encounter date/time and provider fields', }, };