diff --git a/packages/esm-patient-forms-app/src/config-schema.ts b/packages/esm-patient-forms-app/src/config-schema.ts index 6138ce566f..5eea4b5b06 100644 --- a/packages/esm-patient-forms-app/src/config-schema.ts +++ b/packages/esm-patient-forms-app/src/config-schema.ts @@ -61,6 +61,11 @@ export const configSchema = { }, ], }, + showHtmlFormEntryForms: { + _type: Type.Boolean, + _default: true, + _description: 'Whether HTML Form Entry forms should be included in lists of forms', + }, }; export interface HtmlFormEntryForm { diff --git a/packages/esm-patient-forms-app/src/hooks/use-forms.ts b/packages/esm-patient-forms-app/src/hooks/use-forms.ts index bcfd22115d..267d362543 100644 --- a/packages/esm-patient-forms-app/src/hooks/use-forms.ts +++ b/packages/esm-patient-forms-app/src/hooks/use-forms.ts @@ -1,13 +1,15 @@ import dayjs from 'dayjs'; import useSWR from 'swr'; -import { openmrsFetch } from '@openmrs/esm-framework'; +import { openmrsFetch, useConfig } from '@openmrs/esm-framework'; import { ListResponse, FormEncounter, EncounterWithFormRef, CompletedFormInfo } from '../types'; import { customEncounterRepresentation, formEncounterUrl } from '../constants'; import { isFormFullyCached } from '../offline-forms/offline-form-helpers'; export function useFormEncounters(cachedOfflineFormsOnly = false) { - return useSWR([formEncounterUrl, cachedOfflineFormsOnly], async () => { - const res = await openmrsFetch>(formEncounterUrl); + const config = useConfig(); + const url = config.showHtmlFormEntryForms ? formEncounterUrl : formEncounterUrl.concat('&q=poc'); + return useSWR([url, cachedOfflineFormsOnly], async () => { + const res = await openmrsFetch>(url); // show published forms and hide component forms const forms = res.data?.results?.filter((form) => form.published && !/component/i.test(form.name)) ?? [];