diff --git a/src/adapters/obs-adapter.ts b/src/adapters/obs-adapter.ts index 71fecd48..969478dc 100644 --- a/src/adapters/obs-adapter.ts +++ b/src/adapters/obs-adapter.ts @@ -7,6 +7,7 @@ import { type AttachmentResponse, type Attachment, type ValueAndDisplay, + type FormFieldValueAdapter, } from '../types'; import { hasRendering, @@ -17,7 +18,6 @@ import { formatDateAsDisplayString, } from '../utils/common-utils'; import { type FormContextProps } from '../provider/form-provider'; -import { type FormFieldValueAdapter } from '../types'; import { isEmpty } from '../validators/form-validator'; import { getAttachmentByUuid } from '../api'; import { formatDate, restBaseUrl } from '@openmrs/esm-framework'; diff --git a/src/components/renderer/field/fieldLogic.ts b/src/components/renderer/field/fieldLogic.ts index 285a19e9..adc18c27 100644 --- a/src/components/renderer/field/fieldLogic.ts +++ b/src/components/renderer/field/fieldLogic.ts @@ -6,6 +6,7 @@ import { hasRendering } from '../../../utils/common-utils'; import { evaluateAsyncExpression, evaluateExpression } from '../../../utils/expression-runner'; import { evalConditionalRequired, evaluateDisabled, evaluateHide } from '../../../utils/form-helper'; import { isEmpty } from '../../../validators/form-validator'; +import { reportError } from '../../../utils/error-utils'; export function handleFieldLogic(field: FormField, context: FormContextProps) { const { @@ -80,6 +81,8 @@ function evaluateFieldDependents(field: FormField, values: any, context: FormCon context.formFieldAdapters[dependent.type].transformFieldValue(dependent, result, context); } updateFormField(dependent); + }).catch((error) => { + reportError(error, 'Error evaluating calculate expression'); }); } // evaluate hide diff --git a/src/components/renderer/field/form-field-renderer.component.tsx b/src/components/renderer/field/form-field-renderer.component.tsx index 0bdd9580..0c25b1ca 100644 --- a/src/components/renderer/field/form-field-renderer.component.tsx +++ b/src/components/renderer/field/form-field-renderer.component.tsx @@ -2,10 +2,8 @@ import React, { useEffect, useMemo, useState } from 'react'; import { type FormField, type FormFieldInputProps, - type FormFieldValidator, type FormFieldValueAdapter, type RenderType, - type SessionMode, type ValidationResult, type ValueAndDisplay, } from '../../../types'; diff --git a/src/processors/encounter/encounter-form-processor.ts b/src/processors/encounter/encounter-form-processor.ts index 2ff47387..bdd437ef 100644 --- a/src/processors/encounter/encounter-form-processor.ts +++ b/src/processors/encounter/encounter-form-processor.ts @@ -318,7 +318,7 @@ export class EncounterFormProcessor extends FormProcessor { patient: patient, previousEncounter: previousDomainObjectValue, }); - return extractObsValueAndDisplay(field, value); + return value ? extractObsValueAndDisplay(field, value) : null; } if (previousDomainObjectValue && field.questionOptions.enablePreviousValue) { return await adapter.getPreviousValue(field, previousDomainObjectValue, context);