diff --git a/src/api/types.ts b/src/api/types.ts index 2040d7775..e463f5879 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -124,6 +124,7 @@ export interface OHRIFormFieldProps { value: any, setErrors: (errors: Array) => void, setWarnings: (warnings: Array) => void, + isUnspecified?: boolean, ) => void; handler: SubmissionHandler; // This is of util to components defined out of the engine diff --git a/src/components/encounter/ohri-encounter-form.component.tsx b/src/components/encounter/ohri-encounter-form.component.tsx index 0f7ee5e09..c50d52dd2 100644 --- a/src/components/encounter/ohri-encounter-form.component.tsx +++ b/src/components/encounter/ohri-encounter-form.component.tsx @@ -520,6 +520,7 @@ export const OHRIEncounterForm: React.FC = ({ value: any, setErrors: (errors: Array) => void, setWarnings: (warnings: Array) => void, + isUnspecified: boolean, ) => { const field = fields.find((field) => field.id == fieldName); const validators = Array.isArray(field.validators) @@ -533,14 +534,16 @@ export const OHRIEncounterForm: React.FC = ({ }; const errors = []; const warnings = []; - for (let validatorConfig of validators) { - const errorsAndWarinings = - formFieldValidators[validatorConfig.type].validate(field, value, { - ...basevalidatorConfig, - ...validatorConfig, - }) || []; - errors.push(...errorsAndWarinings.filter((error) => error.resultType == 'error')); - warnings.push(...errorsAndWarinings.filter((error) => error.resultType == 'warning')); + if (!isUnspecified) { + for (let validatorConfig of validators) { + const errorsAndWarinings = + formFieldValidators[validatorConfig.type].validate(field, value, { + ...basevalidatorConfig, + ...validatorConfig, + }) || []; + errors.push(...errorsAndWarinings.filter((error) => error.resultType == 'error')); + warnings.push(...errorsAndWarinings.filter((error) => error.resultType == 'warning')); + } } setErrors?.(errors); setWarnings?.(warnings); diff --git a/src/components/inputs/unspecified/ohri-unspecified.component.tsx b/src/components/inputs/unspecified/ohri-unspecified.component.tsx index 1b7cb20f2..859a8ee86 100644 --- a/src/components/inputs/unspecified/ohri-unspecified.component.tsx +++ b/src/components/inputs/unspecified/ohri-unspecified.component.tsx @@ -57,7 +57,7 @@ export const OHRIUnspecified: React.FC = ({ question, onChan const handleOnChange = useCallback( (value) => { setFieldValue(`${question.id}-unspecified`, value.target.checked); - onChange(question.id, field.value, setErrors, setWarnings); + onChange(question.id, field.value, setErrors, setWarnings, value.target.checked); question.value = handler?.handleFieldSubmission(question, field.value, encounterContext); }, [fields],