import { type OpenmrsResource } from '@openmrs/esm-framework'; import { type FormContextProps } from '../provider/form-provider'; import { type ValueAndDisplay, type FormField, type FormSchema, type FormProcessorContextProps } from '../types'; export type FormProcessorConstructor = new (...args: ConstructorParameters) => FormProcessor; export type GetCustomHooksResponse = { useCustomHooks: (context: Partial) => { data: any; isLoading: boolean; error: any; updateContext: (setContext: React.Dispatch>) => void; }; }; export abstract class FormProcessor { formJson: FormSchema; domainObjectValue: OpenmrsResource; constructor(formJson: FormSchema) { this.formJson = formJson; } getDomainObject() { return this.domainObjectValue; } async loadDependencies( context: Partial, setContext: React.Dispatch>, ): Promise> { return Promise.resolve({}); } abstract getHistoricalValue(field: FormField, context: FormContextProps): Promise; abstract processSubmission(context: FormContextProps, abortController: AbortController): Promise; abstract getInitialValues(context: FormProcessorContextProps): Promise>; abstract getCustomHooks(): GetCustomHooksResponse; abstract prepareFormSchema(schema: FormSchema): FormSchema; }