diff --git a/.eslintrc b/.eslintrc index 196a64f0c..d50babfbf 100644 --- a/.eslintrc +++ b/.eslintrc @@ -8,9 +8,7 @@ "project": true, "tsconfigRootDir": "__dirname" }, - "plugins": [ - "@typescript-eslint" - ], + "plugins": ["@typescript-eslint"], "root": true, "rules": { "@typescript-eslint/ban-types": "off", @@ -24,7 +22,7 @@ "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/unbound-method": "off", "@typescript-eslint/consistent-type-imports": [ - "off", + "error", { "fixStyle": "inline-type-imports" } diff --git a/src/api/api.ts b/src/api/api.ts index db4a380a6..8ce1394c8 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -1,6 +1,6 @@ import { fhirBaseUrl, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework'; import { encounterRepresentation } from '../constants'; -import { OpenmrsForm, PatientIdentifier, ProgramEnrollmentPayload } from '../types'; +import { type OpenmrsForm, type PatientIdentifier, type ProgramEnrollmentPayload } from '../types'; import { isUuid } from '../utils/boolean-utils'; export function saveEncounter(abortController: AbortController, payload, encounterUuid?: string) { @@ -190,7 +190,7 @@ export function updateProgramEnrollment( }); } -export function savePatientIdentifier(patientIdentifier:PatientIdentifier, patientUuid: string){ +export function savePatientIdentifier(patientIdentifier: PatientIdentifier, patientUuid: string) { let url: string; if (patientIdentifier.uuid) { @@ -207,5 +207,3 @@ export function savePatientIdentifier(patientIdentifier:PatientIdentifier, patie body: JSON.stringify(patientIdentifier), }); } - - diff --git a/src/components/encounter/encounter-form.component.tsx b/src/components/encounter/encounter-form.component.tsx index da5af7a5d..b567afadc 100644 --- a/src/components/encounter/encounter-form.component.tsx +++ b/src/components/encounter/encounter-form.component.tsx @@ -1,7 +1,7 @@ -import React, { Dispatch, SetStateAction, useCallback, useEffect, useMemo, useState } from 'react'; -import { SessionLocation, showToast, showSnackbar, useLayoutType, Visit } from '@openmrs/esm-framework'; +import React, { type Dispatch, type SetStateAction, useCallback, useEffect, useMemo, useState } from 'react'; +import { type SessionLocation, showToast, showSnackbar, useLayoutType, type Visit } from '@openmrs/esm-framework'; import { codedTypes, ConceptFalse, ConceptTrue } from '../../constants'; -import { +import type { FormField, FormPage as FormPageProps, FormSchema, @@ -22,7 +22,7 @@ import { voidObsValueOnFieldHidden, } from '../../utils/form-helper'; import { InstantEffect } from '../../utils/instant-effect'; -import { FormSubmissionHandler } from '../../form-engine.component'; +import { type FormSubmissionHandler } from '../../form-engine.component'; import { evaluateAsyncExpression, evaluateExpression } from '../../utils/expression-runner'; import { getPreviousEncounter, saveAttachment, saveEncounter } from '../../api/api'; import { isTrue } from '../../utils/boolean-utils'; diff --git a/src/components/extension/extension-parcel.component.tsx b/src/components/extension/extension-parcel.component.tsx index 1f02f72f9..7e5658491 100644 --- a/src/components/extension/extension-parcel.component.tsx +++ b/src/components/extension/extension-parcel.component.tsx @@ -2,7 +2,7 @@ import React, { useContext, useEffect, useMemo } from 'react'; import { BehaviorSubject } from 'rxjs'; import { attach, ExtensionSlot } from '@openmrs/esm-framework'; import { FormContext } from '../../form-context'; -import { FormFieldProps } from '../../types'; +import { type FormFieldProps } from '../../types'; const ExtensionParcel: React.FC = ({ question }) => { const { encounterContext, isSubmitting } = useContext(FormContext); diff --git a/src/components/group/obs-group.component.tsx b/src/components/group/obs-group.component.tsx index 54e362a7d..b11a4f853 100644 --- a/src/components/group/obs-group.component.tsx +++ b/src/components/group/obs-group.component.tsx @@ -2,7 +2,7 @@ import React, { useContext, useEffect, useState } from 'react'; import classNames from 'classnames'; import { useField } from 'formik'; import { FormContext } from '../../form-context'; -import { FormFieldProps } from '../../types'; +import { type FormFieldProps } from '../../types'; import { getFieldControlWithFallback, isUnspecifiedSupported } from '../section/helpers'; import { UnspecifiedField } from '../inputs/unspecified/unspecified.component'; import { Tooltip } from '../inputs/tooltip/tooltip.component'; diff --git a/src/components/inputs/content-switcher/content-switcher.component.tsx b/src/components/inputs/content-switcher/content-switcher.component.tsx index eaede4b3b..46cf9f160 100644 --- a/src/components/inputs/content-switcher/content-switcher.component.tsx +++ b/src/components/inputs/content-switcher/content-switcher.component.tsx @@ -7,7 +7,7 @@ import { isEmpty } from '../../../validators/form-validator'; import { isTrue } from '../../../utils/boolean-utils'; import { FieldValueView } from '../../value/view/field-value-view.component'; import { FormContext } from '../../../form-context'; -import { FormFieldProps } from '../../../types'; +import { type FormFieldProps } from '../../../types'; import styles from './content-switcher.scss'; import { useTranslation } from 'react-i18next'; diff --git a/src/components/inputs/content-switcher/content-switcher.test.tsx b/src/components/inputs/content-switcher/content-switcher.test.tsx index 6a6d3a937..13ccf53eb 100644 --- a/src/components/inputs/content-switcher/content-switcher.test.tsx +++ b/src/components/inputs/content-switcher/content-switcher.test.tsx @@ -2,8 +2,8 @@ import React from 'react'; import { render, fireEvent, screen, cleanup, act, waitFor } from '@testing-library/react'; import { Formik } from 'formik'; import { ContentSwitcher } from './content-switcher.component'; -import { EncounterContext, FormContext } from '../../../form-context'; -import { FormField } from '../../../types'; +import { type EncounterContext, FormContext } from '../../../form-context'; +import { type FormField } from '../../../types'; import { ObsSubmissionHandler } from '../../../submission-handlers/base-handlers'; const question: FormField = { diff --git a/src/components/inputs/date/date.component.tsx b/src/components/inputs/date/date.component.tsx index c4141de29..fec7abf20 100644 --- a/src/components/inputs/date/date.component.tsx +++ b/src/components/inputs/date/date.component.tsx @@ -6,7 +6,7 @@ import { useField } from 'formik'; import { DatePicker, DatePickerInput, Layer, TimePicker } from '@carbon/react'; import { formatDate } from '@openmrs/esm-framework'; import { isTrue } from '../../../utils/boolean-utils'; -import { FormFieldProps } from '../../../types'; +import { type FormFieldProps } from '../../../types'; import { isInlineView } from '../../../utils/form-helper'; import { FieldValueView } from '../../value/view/field-value-view.component'; import { fieldRequiredErrCode, isEmpty } from '../../../validators/form-validator'; diff --git a/src/components/inputs/file/file.component.tsx b/src/components/inputs/file/file.component.tsx index 17985078a..dd4b3d514 100644 --- a/src/components/inputs/file/file.component.tsx +++ b/src/components/inputs/file/file.component.tsx @@ -6,7 +6,7 @@ import Camera from '../camera/camera.component'; import { Close, DocumentPdf } from '@carbon/react/icons'; import styles from './file.scss'; import { createAttachment } from '../../../utils/common-utils'; -import { FormFieldProps } from '../../../types'; +import { type FormFieldProps } from '../../../types'; import { FormContext } from '../../../form-context'; import { isInlineView } from '../../../utils/form-helper'; diff --git a/src/components/inputs/fixed-value/fixed-value.component.tsx b/src/components/inputs/fixed-value/fixed-value.component.tsx index 0f759c716..eea10252c 100644 --- a/src/components/inputs/fixed-value/fixed-value.component.tsx +++ b/src/components/inputs/fixed-value/fixed-value.component.tsx @@ -3,7 +3,7 @@ import isObject from 'lodash-es/isObject'; import { isEmpty } from '../../../validators/form-validator'; import { isTrue } from '../../../utils/boolean-utils'; import { FormContext } from '../../../form-context'; -import { FormFieldProps } from '../../../types'; +import { type FormFieldProps } from '../../../types'; const FixedValue: React.FC = ({ question, handler }) => { const { encounterContext, isFieldInitializationComplete } = React.useContext(FormContext); diff --git a/src/components/inputs/location/encounter-location.component.tsx b/src/components/inputs/location/encounter-location.component.tsx index 665c52ca0..2182dfe05 100644 --- a/src/components/inputs/location/encounter-location.component.tsx +++ b/src/components/inputs/location/encounter-location.component.tsx @@ -6,7 +6,7 @@ import { createErrorHandler } from '@openmrs/esm-framework'; import { getAllLocations, getLocationsByTag } from '../../../api/api'; import { isInlineView } from '../../../utils/form-helper'; import { isTrue } from '../../../utils/boolean-utils'; -import { FormField } from '../../../types'; +import { type FormField } from '../../../types'; import { FormContext } from '../../../form-context'; import { FieldValueView } from '../../value/view/field-value-view.component'; import styles from './encounter-location.scss'; diff --git a/src/components/inputs/markdown/markdown.component.tsx b/src/components/inputs/markdown/markdown.component.tsx index fb0d581ed..e9fe7a036 100644 --- a/src/components/inputs/markdown/markdown.component.tsx +++ b/src/components/inputs/markdown/markdown.component.tsx @@ -1,6 +1,6 @@ import React from 'react'; import MarkdownWrapper from './markdown-wrapper.component'; -import { FormFieldProps } from '../../../types'; +import { type FormFieldProps } from '../../../types'; const Markdown: React.FC = ({ question }) => { return !question.isHidden && ; diff --git a/src/components/inputs/multi-select/multi-select-component.test.tsx b/src/components/inputs/multi-select/multi-select-component.test.tsx index ace5e3e2e..136192d6b 100644 --- a/src/components/inputs/multi-select/multi-select-component.test.tsx +++ b/src/components/inputs/multi-select/multi-select-component.test.tsx @@ -5,7 +5,7 @@ import { mockVisit } from '../../../../__mocks__/visit.mock'; import multiSelectFormSchema from '../../../../__mocks__/forms/rfe-forms/multi-select-form.json'; import { mockPatient } from '../../../../__mocks__/patient.mock'; import { mockSessionDataResponse } from '../../../../__mocks__/session.mock'; -import { FormSchema } from '../../../types'; +import { type FormSchema } from '../../../types'; import FormEngine from '../../../form-engine.component'; const mockOpenmrsFetch = jest.fn(); diff --git a/src/components/inputs/multi-select/multi-select.component.tsx b/src/components/inputs/multi-select/multi-select.component.tsx index a552259f5..5e917bdac 100644 --- a/src/components/inputs/multi-select/multi-select.component.tsx +++ b/src/components/inputs/multi-select/multi-select.component.tsx @@ -5,7 +5,7 @@ import { useField } from 'formik'; import { useTranslation } from 'react-i18next'; import { FieldValueView } from '../../value/view/field-value-view.component'; import { FormContext } from '../../../form-context'; -import { FormFieldProps } from '../../../types'; +import { type FormFieldProps } from '../../../types'; import { ValueEmpty } from '../../value/value.component'; import { fieldRequiredErrCode, isEmpty } from '../../../validators/form-validator'; import { isInlineView } from '../../../utils/form-helper'; diff --git a/src/components/inputs/number/number.component.tsx b/src/components/inputs/number/number.component.tsx index 545a2670f..670215dc8 100644 --- a/src/components/inputs/number/number.component.tsx +++ b/src/components/inputs/number/number.component.tsx @@ -6,7 +6,7 @@ import { isTrue } from '../../../utils/boolean-utils'; import { fieldRequiredErrCode, isEmpty } from '../../../validators/form-validator'; import { isInlineView } from '../../../utils/form-helper'; import { FieldValueView } from '../../value/view/field-value-view.component'; -import { FormFieldProps } from '../../../types'; +import { type FormFieldProps } from '../../../types'; import { FormContext } from '../../../form-context'; import RequiredFieldLabel from '../../required-field-label/required-field-label.component'; import styles from './number.scss'; diff --git a/src/components/inputs/radio/radio.component.tsx b/src/components/inputs/radio/radio.component.tsx index 82385d555..162e851e2 100644 --- a/src/components/inputs/radio/radio.component.tsx +++ b/src/components/inputs/radio/radio.component.tsx @@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useState } from 'react'; import classNames from 'classnames'; import { useTranslation } from 'react-i18next'; import { FormGroup, RadioButtonGroup, RadioButton } from '@carbon/react'; -import { FormFieldProps } from '../../../types'; +import { type FormFieldProps } from '../../../types'; import { useField } from 'formik'; import { FormContext } from '../../../form-context'; import { isTrue } from '../../../utils/boolean-utils'; diff --git a/src/components/inputs/select/dropdown.component.tsx b/src/components/inputs/select/dropdown.component.tsx index b386f8cec..d772d8958 100644 --- a/src/components/inputs/select/dropdown.component.tsx +++ b/src/components/inputs/select/dropdown.component.tsx @@ -8,7 +8,7 @@ import { isInlineView } from '../../../utils/form-helper'; import { isTrue } from '../../../utils/boolean-utils'; import { FieldValueView } from '../../value/view/field-value-view.component'; import { FormContext } from '../../../form-context'; -import { FormFieldProps } from '../../../types'; +import { type FormFieldProps } from '../../../types'; import RequiredFieldLabel from '../../required-field-label/required-field-label.component'; import styles from './dropdown.scss'; diff --git a/src/components/inputs/select/dropdown.test.tsx b/src/components/inputs/select/dropdown.test.tsx index 309af16a2..1675f2b4e 100644 --- a/src/components/inputs/select/dropdown.test.tsx +++ b/src/components/inputs/select/dropdown.test.tsx @@ -1,9 +1,9 @@ import React from 'react'; import { render, fireEvent, screen, cleanup, act } from '@testing-library/react'; import { Formik } from 'formik'; -import { EncounterContext, FormContext } from '../../../form-context'; +import { type EncounterContext, FormContext } from '../../../form-context'; import Dropdown from './dropdown.component'; -import { FormField } from '../../../types'; +import { type FormField } from '../../../types'; import { ObsSubmissionHandler } from '../../../submission-handlers/base-handlers'; const question: FormField = { diff --git a/src/components/inputs/text-area/text-area.component.tsx b/src/components/inputs/text-area/text-area.component.tsx index 7737970c9..b95823ec3 100644 --- a/src/components/inputs/text-area/text-area.component.tsx +++ b/src/components/inputs/text-area/text-area.component.tsx @@ -7,7 +7,7 @@ import { isInlineView } from '../../../utils/form-helper'; import { isTrue } from '../../../utils/boolean-utils'; import { FieldValueView } from '../../value/view/field-value-view.component'; import { FormContext } from '../../../form-context'; -import { FormFieldProps } from '../../../types'; +import { type FormFieldProps } from '../../../types'; import RequiredFieldLabel from '../../required-field-label/required-field-label.component'; import styles from './text-area.scss'; import { useTranslation } from 'react-i18next'; diff --git a/src/components/inputs/text/text.component.tsx b/src/components/inputs/text/text.component.tsx index 04dfc9842..49dea0a62 100644 --- a/src/components/inputs/text/text.component.tsx +++ b/src/components/inputs/text/text.component.tsx @@ -3,7 +3,7 @@ import classNames from 'classnames'; import isEmpty from 'lodash-es/isEmpty'; import { Layer, TextInput } from '@carbon/react'; import { useField } from 'formik'; -import { FormFieldProps } from '../../../types'; +import { type FormFieldProps } from '../../../types'; import { FormContext } from '../../../form-context'; import { fieldRequiredErrCode } from '../../../validators/form-validator'; import { isTrue } from '../../../utils/boolean-utils'; diff --git a/src/components/inputs/toggle/toggle.component.tsx b/src/components/inputs/toggle/toggle.component.tsx index 64be2e141..13e4fd70a 100644 --- a/src/components/inputs/toggle/toggle.component.tsx +++ b/src/components/inputs/toggle/toggle.component.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useMemo, useState } from 'react'; import { Toggle as ToggleInput } from '@carbon/react'; -import { FormFieldProps } from '../../../types'; +import { type FormFieldProps } from '../../../types'; import { useField } from 'formik'; import { FormContext } from '../../../form-context'; import { isTrue } from '../../../utils/boolean-utils'; diff --git a/src/components/inputs/tooltip/tooltip.component.tsx b/src/components/inputs/tooltip/tooltip.component.tsx index a006465c2..f4897b7d4 100644 --- a/src/components/inputs/tooltip/tooltip.component.tsx +++ b/src/components/inputs/tooltip/tooltip.component.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { Tooltip as CarbonTooltip } from '@carbon/react'; import { Information } from '@carbon/react/icons'; -import { FormField } from '../../../types'; +import { type FormField } from '../../../types'; import styles from './tooltip.scss'; import { useTranslation } from 'react-i18next'; diff --git a/src/components/inputs/ui-select-extended/ui-select-extended.component.tsx b/src/components/inputs/ui-select-extended/ui-select-extended.component.tsx index 32b09569f..1dd167059 100644 --- a/src/components/inputs/ui-select-extended/ui-select-extended.component.tsx +++ b/src/components/inputs/ui-select-extended/ui-select-extended.component.tsx @@ -9,7 +9,7 @@ import { useTranslation } from 'react-i18next'; import { getRegisteredDataSource } from '../../../registry/registry'; import { getControlTemplate } from '../../../registry/inbuilt-components/control-templates'; import { FormContext } from '../../../form-context'; -import { FormFieldProps } from '../../../types'; +import { type FormFieldProps } from '../../../types'; import { fieldRequiredErrCode, isEmpty } from '../../../validators/form-validator'; import { isInlineView } from '../../../utils/form-helper'; import RequiredFieldLabel from '../../required-field-label/required-field-label.component'; diff --git a/src/components/inputs/ui-select-extended/ui-select-extended.test.tsx b/src/components/inputs/ui-select-extended/ui-select-extended.test.tsx index 886f197d2..00fa21742 100644 --- a/src/components/inputs/ui-select-extended/ui-select-extended.test.tsx +++ b/src/components/inputs/ui-select-extended/ui-select-extended.test.tsx @@ -1,10 +1,10 @@ import React from 'react'; import { render, fireEvent, waitFor, act, screen } from '@testing-library/react'; import UiSelectExtended from './ui-select-extended.component'; -import { EncounterContext, FormContext } from '../../../form-context'; +import { type EncounterContext, FormContext } from '../../../form-context'; import { Formik } from 'formik'; import { ObsSubmissionHandler } from '../../../submission-handlers/base-handlers'; -import { FormField } from '../../../types'; +import { type FormField } from '../../../types'; const question: FormField = { label: 'Transfer Location', diff --git a/src/components/inputs/unspecified/unspecified.component.tsx b/src/components/inputs/unspecified/unspecified.component.tsx index 00d946628..df9cf0b98 100644 --- a/src/components/inputs/unspecified/unspecified.component.tsx +++ b/src/components/inputs/unspecified/unspecified.component.tsx @@ -4,7 +4,7 @@ import { useField } from 'formik'; import { useTranslation } from 'react-i18next'; import { FormContext } from '../../../form-context'; import { FieldValidator } from '../../../validators/form-validator'; -import { FormFieldProps } from '../../../types'; +import { type FormFieldProps } from '../../../types'; import { isTrue } from '../../../utils/boolean-utils'; import styles from './unspecified.scss'; diff --git a/src/components/inputs/unspecified/unspecified.test.tsx b/src/components/inputs/unspecified/unspecified.test.tsx index f2a5a412e..f047e5271 100644 --- a/src/components/inputs/unspecified/unspecified.test.tsx +++ b/src/components/inputs/unspecified/unspecified.test.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { fireEvent, render, screen } from '@testing-library/react'; import { Formik } from 'formik'; -import { FormField, EncounterContext, FormContext } from '../../..'; +import { type FormField, type EncounterContext, FormContext } from '../../..'; import { ObsSubmissionHandler } from '../../../submission-handlers/base-handlers'; import { UnspecifiedField } from './unspecified.component'; import { findTextOrDateInput } from '../../../utils/test-utils'; diff --git a/src/components/inputs/workspace-launcher/workspace-launcher.component.tsx b/src/components/inputs/workspace-launcher/workspace-launcher.component.tsx index 6f38872bd..793d84593 100644 --- a/src/components/inputs/workspace-launcher/workspace-launcher.component.tsx +++ b/src/components/inputs/workspace-launcher/workspace-launcher.component.tsx @@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next'; import { showSnackbar } from '@openmrs/esm-framework'; import { useLaunchWorkspaceRequiringVisit } from '@openmrs/esm-patient-common-lib'; import { Button } from '@carbon/react'; -import { FormFieldProps } from '../../../types'; +import { type FormFieldProps } from '../../../types'; import styles from './workspace-launcher.scss'; const WorkspaceLauncher: React.FC = ({ question }) => { diff --git a/src/components/repeat/helpers.ts b/src/components/repeat/helpers.ts index fe5ec69b7..5765511ec 100644 --- a/src/components/repeat/helpers.ts +++ b/src/components/repeat/helpers.ts @@ -1,5 +1,5 @@ import { cloneDeep } from 'lodash-es'; -import { FormField } from '../../types'; +import { type FormField } from '../../types'; export function cloneObsGroup(srcField: FormField, obsGroup: any, idSuffix: number) { const originalGroupMembersIds: string[] = []; diff --git a/src/components/repeat/repeat.component.tsx b/src/components/repeat/repeat.component.tsx index f82f56f8e..97735c0bf 100644 --- a/src/components/repeat/repeat.component.tsx +++ b/src/components/repeat/repeat.component.tsx @@ -3,7 +3,7 @@ import { FormGroup, Button } from '@carbon/react'; import { Add, TrashCan } from '@carbon/react/icons'; import { useFormikContext } from 'formik'; import { useTranslation } from 'react-i18next'; -import { FormField, FormFieldProps } from '../../types'; +import { type FormField, type FormFieldProps } from '../../types'; import { evaluateAsyncExpression, evaluateExpression } from '../../utils/expression-runner'; import { ObsGroup } from '../group/obs-group.component'; import { isEmpty } from '../../validators/form-validator'; @@ -20,12 +20,7 @@ const Repeat: React.FC = ({ question, onChange }) => { const { t } = useTranslation(); const id = useId(); - const { - fields: allFormFields, - encounterContext, - obsGroupsToVoid, - formFieldHandlers, - } = React.useContext(FormContext); + const { fields: allFormFields, encounterContext, obsGroupsToVoid, formFieldHandlers } = React.useContext(FormContext); const { values, setValues } = useFormikContext(); const [counter, setCounter] = useState(1); const [obsGroups, setObsGroups] = useState([]); diff --git a/src/components/section/form-section.component.tsx b/src/components/section/form-section.component.tsx index ca5f6de2f..e05c6ef74 100644 --- a/src/components/section/form-section.component.tsx +++ b/src/components/section/form-section.component.tsx @@ -2,15 +2,15 @@ import React, { useEffect, useState } from 'react'; import classNames from 'classnames'; import { useTranslation } from 'react-i18next'; import { useField } from 'formik'; +import type { FormField, FormFieldProps, previousValue, SubmissionHandler } from '../../types'; import { ErrorBoundary } from 'react-error-boundary'; import { ToastNotification } from '@carbon/react'; -import { getRegisteredFieldSubmissionHandler } from '../../registry/registry'; import { formatPreviousValueDisplayText, getFieldControlWithFallback, isUnspecifiedSupported } from './helpers'; -import { PreviousValueReview } from '../previous-value-review/previous-value-review.component'; +import { getRegisteredFieldSubmissionHandler } from '../../registry/registry'; import { isTrue } from '../../utils/boolean-utils'; import { UnspecifiedField } from '../inputs/unspecified/unspecified.component'; -import { FormField, FormFieldProps, previousValue, SubmissionHandler } from '../../types'; import { FormContext } from '../../form-context'; +import { PreviousValueReview } from '../previous-value-review/previous-value-review.component'; import { Tooltip } from '../inputs/tooltip/tooltip.component'; import styles from './form-section.scss'; diff --git a/src/components/section/helpers.ts b/src/components/section/helpers.ts index 660d413f8..93e1d55d0 100644 --- a/src/components/section/helpers.ts +++ b/src/components/section/helpers.ts @@ -1,7 +1,7 @@ import { formatDate } from '@openmrs/esm-framework'; import { getRegisteredControl } from '../../registry/registry'; import { isTrue } from '../../utils/boolean-utils'; -import { FormField } from '../../types'; +import { type FormField } from '../../types'; /** * Retrieves the appropriate field control for a question, considering missing concepts. diff --git a/src/components/sidebar/sidebar.component.tsx b/src/components/sidebar/sidebar.component.tsx index bd95fd226..1e83e9bb1 100644 --- a/src/components/sidebar/sidebar.component.tsx +++ b/src/components/sidebar/sidebar.component.tsx @@ -6,7 +6,7 @@ import { isEmpty } from '../../validators/form-validator'; import { scrollIntoView } from '../../utils/scroll-into-view'; import styles from './sidebar.scss'; -function Sidebar({ +const Sidebar = ({ isFormSubmitting, pagesWithErrors, scrollablePages, @@ -18,7 +18,7 @@ function Sidebar({ setValues, allowUnspecifiedAll, defaultPage, -}) { +}) => { const { t } = useTranslation(); const [activeLink, setActiveLink] = useState(selectedPage); @@ -120,6 +120,6 @@ function Sidebar({ ); -} +}; export default Sidebar; diff --git a/src/datasources/data-source.ts b/src/datasources/data-source.ts index 2f71f1a3f..9ae36e8d2 100644 --- a/src/datasources/data-source.ts +++ b/src/datasources/data-source.ts @@ -1,5 +1,5 @@ -import { openmrsFetch, OpenmrsResource } from '@openmrs/esm-framework'; -import { DataSource } from '../types'; +import { openmrsFetch, type OpenmrsResource } from '@openmrs/esm-framework'; +import { type DataSource } from '../types'; export class BaseOpenMRSDataSource implements DataSource { url: string; diff --git a/src/form-context.tsx b/src/form-context.tsx index 995d96a54..25a6e666f 100644 --- a/src/form-context.tsx +++ b/src/form-context.tsx @@ -1,6 +1,12 @@ import React from 'react'; -import { LayoutType } from '@openmrs/esm-framework'; -import { FormField, OpenmrsEncounter, PatientIdentifier, SessionMode, SubmissionHandler } from './types'; +import { type LayoutType } from '@openmrs/esm-framework'; +import { + type FormField, + type OpenmrsEncounter, + type PatientIdentifier, + type SessionMode, + type SubmissionHandler, +} from './types'; type FormContextProps = { values: Record; diff --git a/src/form-engine.component.tsx b/src/form-engine.component.tsx index 4cc9831fa..6aff98136 100644 --- a/src/form-engine.component.tsx +++ b/src/form-engine.component.tsx @@ -4,12 +4,12 @@ import classNames from 'classnames'; import { Button, ButtonSet, InlineLoading } from '@carbon/react'; import { I18nextProvider, useTranslation } from 'react-i18next'; import * as Yup from 'yup'; -import { showSnackbar, useSession, Visit } from '@openmrs/esm-framework'; +import { showSnackbar, useSession, type Visit } from '@openmrs/esm-framework'; import LinearLoader from './components/loaders/linear-loader.component'; import LoadingIcon from './components/loaders/loading.component'; import Sidebar from './components/sidebar/sidebar.component'; import { init, teardown } from './lifecycle'; -import { FormSchema, SessionMode, FormPage as FormPageProps } from './types'; +import type { FormSchema, SessionMode, FormPage as FormPageProps } from './types'; import { PatientBanner } from './components/patient-banner/patient-banner.component'; import { extractErrorMessagesFromResponse, reportError } from './utils/error-utils'; import { useFormJson } from './hooks/useFormJson'; diff --git a/src/hooks/useClobData.tsx b/src/hooks/useClobData.tsx index d1874836f..4b9a4a1f5 100644 --- a/src/hooks/useClobData.tsx +++ b/src/hooks/useClobData.tsx @@ -1,6 +1,6 @@ import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework'; import { useMemo } from 'react'; -import { FormSchema, OpenmrsForm } from '../types'; +import { type FormSchema, type OpenmrsForm } from '../types'; import useSWRImmutable from 'swr/immutable'; export function useClobData(form: OpenmrsForm) { diff --git a/src/hooks/useConcepts.tsx b/src/hooks/useConcepts.tsx index 46170e690..6d622dc3b 100644 --- a/src/hooks/useConcepts.tsx +++ b/src/hooks/useConcepts.tsx @@ -1,6 +1,6 @@ -import useSWRInfinite from 'swr/infinite'; -import { FetchResponse, openmrsFetch, OpenmrsResource, restBaseUrl } from '@openmrs/esm-framework'; import { useMemo } from 'react'; +import { type FetchResponse, type OpenmrsResource, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework'; +import useSWRInfinite from 'swr/infinite'; const conceptRepresentation = 'custom:(uuid,display,conceptClass:(uuid,display),answers:(uuid,display),conceptMappings:(conceptReferenceTerm:(conceptSource:(name),code)))'; diff --git a/src/hooks/useEncounter.tsx b/src/hooks/useEncounter.tsx index 30c91303e..1495fefdb 100644 --- a/src/hooks/useEncounter.tsx +++ b/src/hooks/useEncounter.tsx @@ -1,6 +1,6 @@ import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework'; import useSWR from 'swr'; -import { FormSchema, OpenmrsEncounter } from '../types'; +import { type FormSchema, type OpenmrsEncounter } from '../types'; import { encounterRepresentation } from '../constants'; export function useEncounter(formJson: FormSchema) { diff --git a/src/hooks/useEncounterRole.tsx b/src/hooks/useEncounterRole.tsx index ff5db2426..3aeaee85d 100644 --- a/src/hooks/useEncounterRole.tsx +++ b/src/hooks/useEncounterRole.tsx @@ -1,4 +1,4 @@ -import { OpenmrsResource, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework'; +import { type OpenmrsResource, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework'; import useSWRImmutable from 'swr/immutable'; export function useEncounterRole() { diff --git a/src/hooks/useFormFieldHandlers.tsx b/src/hooks/useFormFieldHandlers.tsx index 19e8e625d..dc8199c13 100644 --- a/src/hooks/useFormFieldHandlers.tsx +++ b/src/hooks/useFormFieldHandlers.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react'; -import { FormField, getRegisteredFieldSubmissionHandler, SubmissionHandler } from '..'; +import { type FormField, getRegisteredFieldSubmissionHandler, type SubmissionHandler } from '..'; export function useFormFieldHandlers(fields: FormField[]) { const [formFieldHandlers, setFormFieldHandlers] = useState>({}); diff --git a/src/hooks/useFormFieldValidators.ts b/src/hooks/useFormFieldValidators.ts index e120abbbd..f4e1e3950 100644 --- a/src/hooks/useFormFieldValidators.ts +++ b/src/hooks/useFormFieldValidators.ts @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react'; import { getRegisteredValidator } from '../registry/registry'; -import { FormField, FormFieldValidator } from '../types'; +import { type FormField, type FormFieldValidator } from '../types'; export function useFormFieldValidators(fields: FormField[]) { const [validators, setValidators] = useState>(); diff --git a/src/hooks/useFormJson.tsx b/src/hooks/useFormJson.tsx index 96c51c5c7..327e41358 100644 --- a/src/hooks/useFormJson.tsx +++ b/src/hooks/useFormJson.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react'; -import { FormSchemaTransformer, FormSchema, FormSection, ReferencedForm } from '../types'; +import { type FormSchemaTransformer, type FormSchema, type FormSection, type ReferencedForm } from '../types'; import { isTrue } from '../utils/boolean-utils'; import { applyFormIntent } from '../utils/forms-loader'; import { fetchOpenMRSForm, fetchClobData } from '../api/api'; diff --git a/src/hooks/useInitialValues.test.ts b/src/hooks/useInitialValues.test.ts index 09006666e..debdff323 100644 --- a/src/hooks/useInitialValues.test.ts +++ b/src/hooks/useInitialValues.test.ts @@ -3,7 +3,7 @@ import { useInitialValues } from './useInitialValues'; import testEncounter from '../../__mocks__/use-initial-values/encounter.mock.json'; import testPatient from '../../__mocks__/use-initial-values/patient.mock.json'; import { ObsSubmissionHandler } from '../submission-handlers/base-handlers'; -import { FormField, OpenmrsEncounter } from '../types'; +import { type FormField, type OpenmrsEncounter } from '../types'; const obsGroupMembers: Array = [ { diff --git a/src/hooks/useInitialValues.ts b/src/hooks/useInitialValues.ts index 366f69a98..1d18ec3be 100644 --- a/src/hooks/useInitialValues.ts +++ b/src/hooks/useInitialValues.ts @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react'; -import { EncounterContext, inferInitialValueFromDefaultFieldValue, isEmpty } from '..'; -import { FormField, OpenmrsEncounter, SubmissionHandler } from '../types'; +import { type EncounterContext, inferInitialValueFromDefaultFieldValue, isEmpty } from '..'; +import { type FormField, type OpenmrsEncounter, type SubmissionHandler } from '../types'; import { evaluateAsyncExpression } from '../utils/expression-runner'; import { cloneObsGroup } from '../components/repeat/helpers'; import { assignedObsIds } from '../submission-handlers/base-handlers'; @@ -18,7 +18,12 @@ export function useInitialValues( const [isEncounterBindingComplete, setIsEncounterBindingComplete] = useState( encounterContext.sessionMode === 'enter', ); - const encounterContextInitializableTypes = ['encounterProvider', 'encounterDatetime', 'encounterLocation', 'patientIdentifier']; + const encounterContextInitializableTypes = [ + 'encounterProvider', + 'encounterDatetime', + 'encounterLocation', + 'patientIdentifier', + ]; useEffect(() => { const asyncItemsKeys = Object.keys(asyncInitValues ?? {}); @@ -63,7 +68,12 @@ export function useInitialValues( !field.questionOptions.repeatOptions?.isCloned && repeatableFields.push(field); return; } - let existingVal = formFieldHandlers[field.type]?.getInitialValue(encounter, field, formFields, encounterContext); + let existingVal = formFieldHandlers[field.type]?.getInitialValue( + encounter, + field, + formFields, + encounterContext, + ); if (isEmpty(existingVal) && !isEmpty(field.questionOptions.defaultValue)) { existingVal = inferInitialValueFromDefaultFieldValue( diff --git a/src/hooks/usePostSubmissionAction.tsx b/src/hooks/usePostSubmissionAction.tsx index c7423cadf..17b605b6e 100644 --- a/src/hooks/usePostSubmissionAction.tsx +++ b/src/hooks/usePostSubmissionAction.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react'; import { getRegisteredPostSubmissionAction } from '../registry/registry'; -import { PostSubmissionAction } from '../types'; +import { type PostSubmissionAction } from '../types'; export function usePostSubmissionAction( actionRefs: Array<{ actionId: string; enabled?: string; config?: Record }>, diff --git a/src/post-submission-actions/program-enrollment-action.ts b/src/post-submission-actions/program-enrollment-action.ts index 7cab64cf6..e56ee9d87 100644 --- a/src/post-submission-actions/program-enrollment-action.ts +++ b/src/post-submission-actions/program-enrollment-action.ts @@ -1,7 +1,7 @@ import { showToast } from '@openmrs/esm-framework'; import { createProgramEnrollment, getPatientEnrolledPrograms, updateProgramEnrollment } from '../api/api'; import dayjs from 'dayjs'; -import { PostSubmissionAction, ProgramEnrollmentPayload } from '../types'; +import { type PostSubmissionAction, type ProgramEnrollmentPayload } from '../types'; export const ProgramEnrollmentSubmissionAction: PostSubmissionAction = { applyAction: async function ({ patient, encounters, sessionMode }, config) { diff --git a/src/registry/inbuilt-components/InbuiltPostSubmissionActions.ts b/src/registry/inbuilt-components/InbuiltPostSubmissionActions.ts index f71f0c3e6..03e149f07 100644 --- a/src/registry/inbuilt-components/InbuiltPostSubmissionActions.ts +++ b/src/registry/inbuilt-components/InbuiltPostSubmissionActions.ts @@ -1,5 +1,5 @@ -import { PostSubmissionAction } from '../../types'; -import { ComponentRegistration } from '../registry'; +import { type PostSubmissionAction } from '../../types'; +import { type ComponentRegistration } from '../registry'; export const inbuiltPostSubmissionActions: Array> = [ { diff --git a/src/registry/inbuilt-components/control-templates.ts b/src/registry/inbuilt-components/control-templates.ts index 068a2b58e..79e9baf04 100644 --- a/src/registry/inbuilt-components/control-templates.ts +++ b/src/registry/inbuilt-components/control-templates.ts @@ -1,4 +1,4 @@ -import { ControlTemplate } from '../../types'; +import { type ControlTemplate } from '../../types'; export const controlTemplates: Array = [ { diff --git a/src/registry/inbuilt-components/inbuiltControls.ts b/src/registry/inbuilt-components/inbuiltControls.ts index 6cf625844..cb9798a3c 100644 --- a/src/registry/inbuilt-components/inbuiltControls.ts +++ b/src/registry/inbuilt-components/inbuiltControls.ts @@ -1,8 +1,8 @@ import File from '../../components/inputs/file/file.component'; -import { RegistryItem } from '../registry'; +import { type RegistryItem } from '../registry'; import { controlTemplates } from './control-templates'; import { templateToComponentMap } from './template-component-map'; -import { FormFieldProps } from '../../types'; +import { type FormFieldProps } from '../../types'; import DateField from '../../components/inputs/date/date.component'; import Radio from '../../components/inputs/radio/radio.component'; import NumberField from '../../components/inputs/number/number.component'; diff --git a/src/registry/inbuilt-components/inbuiltDataSources.ts b/src/registry/inbuilt-components/inbuiltDataSources.ts index 7a847044d..d32d67d74 100644 --- a/src/registry/inbuilt-components/inbuiltDataSources.ts +++ b/src/registry/inbuilt-components/inbuiltDataSources.ts @@ -1,5 +1,5 @@ -import { DataSource } from '../../types'; -import { RegistryItem } from '../registry'; +import { type DataSource } from '../../types'; +import { type RegistryItem } from '../registry'; import { ConceptDataSource } from '../../datasources/concept-data-source'; import { LocationDataSource } from '../../datasources/location-data-source'; import { ProviderDataSource } from '../../datasources/provider-datasource'; diff --git a/src/registry/inbuilt-components/inbuiltFieldSubmissionHandlers.ts b/src/registry/inbuilt-components/inbuiltFieldSubmissionHandlers.ts index 3c0501f86..23960039c 100644 --- a/src/registry/inbuilt-components/inbuiltFieldSubmissionHandlers.ts +++ b/src/registry/inbuilt-components/inbuiltFieldSubmissionHandlers.ts @@ -2,9 +2,9 @@ import { ObsSubmissionHandler } from '../../submission-handlers/base-handlers'; import { EncounterDatetimeHandler } from '../../submission-handlers/encounterDatetimeHandler'; import { EncounterLocationSubmissionHandler } from '../../submission-handlers/encounterLocationHandler'; import { EncounterProviderHandler } from '../../submission-handlers/encounterProviderHandler'; -import { SubmissionHandler } from '../../types'; +import { type SubmissionHandler } from '../../types'; import { PatientIdentifierHandler } from '../../submission-handlers/patientIdentifierHandler'; -import { RegistryItem } from '../registry'; +import { type RegistryItem } from '../registry'; /** * @internal diff --git a/src/registry/inbuilt-components/inbuiltTransformers.ts b/src/registry/inbuilt-components/inbuiltTransformers.ts index 892304e6f..db22745f8 100644 --- a/src/registry/inbuilt-components/inbuiltTransformers.ts +++ b/src/registry/inbuilt-components/inbuiltTransformers.ts @@ -1,6 +1,6 @@ import { AngularFormEngineSchemaTransformer } from '../../transformers/angular-fe-schema-transformer'; -import { FormSchemaTransformer } from '../../types'; -import { RegistryItem } from '../registry'; +import { type FormSchemaTransformer } from '../../types'; +import { type RegistryItem } from '../registry'; export const inbuiltFormTransformers: Array> = [ { diff --git a/src/registry/inbuilt-components/inbuiltValidators.ts b/src/registry/inbuilt-components/inbuiltValidators.ts index 5d4db731e..84a85730b 100644 --- a/src/registry/inbuilt-components/inbuiltValidators.ts +++ b/src/registry/inbuilt-components/inbuiltValidators.ts @@ -1,8 +1,8 @@ -import { FormFieldValidator } from '../../types'; +import { type FormFieldValidator } from '../../types'; import { DateValidator } from '../../validators/date-validator'; import { DefaultFieldValueValidator } from '../../validators/default-value-validator'; import { ExpressionValidator } from '../../validators/js-expression-validator'; -import { RegistryItem } from '../registry'; +import { type RegistryItem } from '../registry'; /** * @internal diff --git a/src/registry/registry.ts b/src/registry/registry.ts index bb0ab7296..71b10c4a2 100644 --- a/src/registry/registry.ts +++ b/src/registry/registry.ts @@ -1,10 +1,10 @@ import { - DataSource, - FormFieldValidator, - FormSchemaTransformer, - FormFieldProps, - PostSubmissionAction, - SubmissionHandler, + type DataSource, + type FormFieldValidator, + type FormSchemaTransformer, + type FormFieldProps, + type PostSubmissionAction, + type SubmissionHandler, } from '../types'; import { getGlobalStore } from '@openmrs/esm-framework'; import { FormsStore } from '../constants'; diff --git a/src/submission-handlers/base-handlers.test.ts b/src/submission-handlers/base-handlers.test.ts index 8f6440aa7..d3fb7c67c 100644 --- a/src/submission-handlers/base-handlers.test.ts +++ b/src/submission-handlers/base-handlers.test.ts @@ -1,6 +1,6 @@ import { Observable } from 'rxjs'; -import { EncounterContext } from '../form-context'; -import { FormField } from '../types'; +import { type EncounterContext } from '../form-context'; +import { type FormField } from '../types'; import { findObsByFormField, ObsSubmissionHandler } from './base-handlers'; const encounterContext: EncounterContext = { diff --git a/src/submission-handlers/base-handlers.ts b/src/submission-handlers/base-handlers.ts index d4f98d94c..19418b340 100644 --- a/src/submission-handlers/base-handlers.ts +++ b/src/submission-handlers/base-handlers.ts @@ -1,8 +1,8 @@ import dayjs from 'dayjs'; import { getConcept, getAttachmentByUuid } from '../api/api'; import { ConceptTrue } from '../constants'; -import { EncounterContext } from '../form-context'; -import { FormField, OpenmrsEncounter, OpenmrsObs, SubmissionHandler } from '../types'; +import { type EncounterContext } from '../form-context'; +import { type FormField, type OpenmrsEncounter, type OpenmrsObs, type SubmissionHandler } from '../types'; import { parseToLocalDateTime } from '../utils/form-helper'; import { flattenObsList, hasRendering } from '../utils/common-utils'; diff --git a/src/submission-handlers/encounterDatetimeHandler.ts b/src/submission-handlers/encounterDatetimeHandler.ts index 368840c51..8a0f401f9 100644 --- a/src/submission-handlers/encounterDatetimeHandler.ts +++ b/src/submission-handlers/encounterDatetimeHandler.ts @@ -1,6 +1,6 @@ -import { SubmissionHandler } from '..'; -import { OpenmrsEncounter, FormField } from '../types'; -import { EncounterContext } from '../form-context'; +import { type SubmissionHandler } from '..'; +import { type OpenmrsEncounter, type FormField } from '../types'; +import { type EncounterContext } from '../form-context'; export const EncounterDatetimeHandler: SubmissionHandler = { handleFieldSubmission: (field: FormField, value: any, context: EncounterContext) => { diff --git a/src/submission-handlers/encounterLocationHandler.ts b/src/submission-handlers/encounterLocationHandler.ts index a583e48c9..2bb19377f 100644 --- a/src/submission-handlers/encounterLocationHandler.ts +++ b/src/submission-handlers/encounterLocationHandler.ts @@ -1,4 +1,4 @@ -import { EncounterContext, FormField, SubmissionHandler } from '..'; +import { type EncounterContext, type FormField, type SubmissionHandler } from '..'; import { getAllLocations } from '../api/api'; export const EncounterLocationSubmissionHandler: SubmissionHandler = { diff --git a/src/submission-handlers/encounterProviderHandler.ts b/src/submission-handlers/encounterProviderHandler.ts index 9a47f4133..488d7f280 100644 --- a/src/submission-handlers/encounterProviderHandler.ts +++ b/src/submission-handlers/encounterProviderHandler.ts @@ -1,4 +1,4 @@ -import { EncounterContext, FormField, OpenmrsEncounter, SubmissionHandler } from '..'; +import { type EncounterContext, type FormField, type OpenmrsEncounter, type SubmissionHandler } from '..'; export const EncounterProviderHandler: SubmissionHandler = { handleFieldSubmission: (field: FormField, value: any, context: EncounterContext) => { diff --git a/src/submission-handlers/patientIdentifierHandler.ts b/src/submission-handlers/patientIdentifierHandler.ts index cd87e0536..2f80f63d1 100644 --- a/src/submission-handlers/patientIdentifierHandler.ts +++ b/src/submission-handlers/patientIdentifierHandler.ts @@ -1,13 +1,13 @@ -import { EncounterContext, FormField, OpenmrsEncounter, SubmissionHandler } from '..'; +import { type EncounterContext, type FormField, type OpenmrsEncounter, type SubmissionHandler } from '..'; import { getPatientLatestIdentifier } from '../utils/patient-identifier-helper'; export const PatientIdentifierHandler: SubmissionHandler = { handleFieldSubmission: (field: FormField, value: any, context: EncounterContext) => { return value; }, - getInitialValue: ( + getInitialValue: ( encounter: OpenmrsEncounter, - field: FormField, + field: FormField, allFormFields: Array, context: EncounterContext, ) => { @@ -21,5 +21,4 @@ export const PatientIdentifierHandler: SubmissionHandler = { getPreviousValue: (field: FormField, encounter: OpenmrsEncounter, allFormFields: Array) => { return null; }, - }; diff --git a/src/transformers/angular-fe-schema-transformer.ts b/src/transformers/angular-fe-schema-transformer.ts index 37808ae24..cafb973d2 100644 --- a/src/transformers/angular-fe-schema-transformer.ts +++ b/src/transformers/angular-fe-schema-transformer.ts @@ -1,4 +1,4 @@ -import { FormField, FormSchemaTransformer, FormSchema } from '../types'; +import { type FormField, type FormSchemaTransformer, type FormSchema } from '../types'; export const AngularFormEngineSchemaTransformer: FormSchemaTransformer = { transform: (form: FormSchema) => { diff --git a/src/types.ts b/src/types.ts index c34be81c9..0e81ac151 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,6 +1,6 @@ -import { OpenmrsResource } from '@openmrs/esm-framework'; -import { FieldHelperProps, FieldInputProps, FieldMetaProps } from 'formik'; -import { EncounterContext } from './form-context'; +import { type OpenmrsResource } from '@openmrs/esm-framework'; +import { type FieldHelperProps, type FieldInputProps, type FieldMetaProps } from 'formik'; +import { type EncounterContext } from './form-context'; /** * Defines logic that processes field submission and value binding while in edit mode diff --git a/src/utils/common-expression-helpers.ts b/src/utils/common-expression-helpers.ts index 8f4a9e81d..e50390280 100644 --- a/src/utils/common-expression-helpers.ts +++ b/src/utils/common-expression-helpers.ts @@ -6,8 +6,8 @@ import filter from 'lodash/filter'; import first from 'lodash/first'; import forEach from 'lodash/forEach'; import last from 'lodash/last'; -import { FormField } from '../types'; -import { FormNode } from './expression-runner'; +import { type FormField } from '../types'; +import { type FormNode } from './expression-runner'; import { isEmpty as isValueEmpty } from '../validators/form-validator'; import * as apiFunctions from '../api/api'; import { getZRefByGenderAndAge } from './zscore-service'; diff --git a/src/utils/common-utils.ts b/src/utils/common-utils.ts index fde8d643e..19ee7ee25 100644 --- a/src/utils/common-utils.ts +++ b/src/utils/common-utils.ts @@ -1,5 +1,5 @@ import { formatDate, restBaseUrl } from '@openmrs/esm-framework'; -import { Attachment, AttachmentResponse, FormField, OpenmrsObs, RenderType } from '../types'; +import { type Attachment, type AttachmentResponse, type FormField, type OpenmrsObs, type RenderType } from '../types'; export function flattenObsList(obsList: OpenmrsObs[]): OpenmrsObs[] { const flattenedList: OpenmrsObs[] = []; diff --git a/src/utils/expression-parser.test.ts b/src/utils/expression-parser.test.ts index 77a1e7ba6..e4b8e9bfd 100644 --- a/src/utils/expression-parser.test.ts +++ b/src/utils/expression-parser.test.ts @@ -1,4 +1,4 @@ -import { FormField } from '../types'; +import { type FormField } from '../types'; import { ConceptFalse } from '../constants'; import { findAndRegisterReferencedFields, diff --git a/src/utils/expression-parser.ts b/src/utils/expression-parser.ts index 29be5a8fa..8243e7254 100644 --- a/src/utils/expression-parser.ts +++ b/src/utils/expression-parser.ts @@ -1,7 +1,7 @@ -import { FormField } from '../types'; +import { type FormField } from '../types'; import { ConceptFalse, ConceptTrue } from '../constants'; import { registerDependency } from './common-expression-helpers'; -import { FormNode } from './expression-runner'; +import { type FormNode } from './expression-runner'; /** * Parses a complex expression string into an array of tokens, ignoring operators found within quotes and within parentheses. @@ -138,7 +138,7 @@ export function replaceFieldRefWithValuePath(field: FormField, value: any, token * @param fields All fields */ export function findAndRegisterReferencedFields(fieldNode: FormNode, tokens: string[], fields: Array): void { - tokens.forEach(token => { + tokens.forEach((token) => { if (hasParentheses(token)) { extractArgs(token).forEach((arg) => { registerDependency(fieldNode, findReferencedFieldIfExists(arg, fields)); diff --git a/src/utils/expression-runner.test.ts b/src/utils/expression-runner.test.ts index 66d6b49e1..1ac85b71d 100644 --- a/src/utils/expression-runner.test.ts +++ b/src/utils/expression-runner.test.ts @@ -1,7 +1,7 @@ import { registerExpressionHelper } from '..'; -import { FormField } from '../types'; +import { type FormField } from '../types'; import { CommonExpressionHelpers } from './common-expression-helpers'; -import { checkReferenceToResolvedFragment, evaluateExpression, ExpressionContext } from './expression-runner'; +import { checkReferenceToResolvedFragment, evaluateExpression, type ExpressionContext } from './expression-runner'; export const testFields: Array = [ { diff --git a/src/utils/expression-runner.ts b/src/utils/expression-runner.ts index bfb43acf9..8fbc0c372 100644 --- a/src/utils/expression-runner.ts +++ b/src/utils/expression-runner.ts @@ -1,5 +1,5 @@ import { getRegisteredExpressionHelpers } from '../registry/registry'; -import { FormField, FormPage, FormSection } from '../types'; +import { type FormField, type FormPage, type FormSection } from '../types'; import { CommonExpressionHelpers } from './common-expression-helpers'; import { findAndRegisterReferencedFields, linkReferencedFieldValues, parseExpression } from './expression-parser'; diff --git a/src/utils/form-helper.ts b/src/utils/form-helper.ts index a5421bb7d..99dde2904 100644 --- a/src/utils/form-helper.ts +++ b/src/utils/form-helper.ts @@ -1,8 +1,8 @@ import dayjs from 'dayjs'; -import { LayoutType } from '@openmrs/esm-framework'; +import { type LayoutType } from '@openmrs/esm-framework'; import { ConceptTrue } from '../constants'; -import { EncounterContext } from '../form-context'; -import { FormField, FormPage, FormSection, SessionMode, SubmissionHandler } from '../types'; +import { type EncounterContext } from '../form-context'; +import { type FormField, type FormPage, type FormSection, type SessionMode, type SubmissionHandler } from '../types'; import { DefaultFieldValueValidator } from '../validators/default-value-validator'; import { isEmpty } from '../validators/form-validator'; import { isTrue } from './boolean-utils'; diff --git a/src/utils/forms-loader.test.ts b/src/utils/forms-loader.test.ts index d402fb45d..06c1f6bf0 100644 --- a/src/utils/forms-loader.test.ts +++ b/src/utils/forms-loader.test.ts @@ -1,4 +1,4 @@ -import { FormJsonFile, getForm, getFormByVersion, getLatestFormVersion, applyFormIntent } from './forms-loader'; +import { type FormJsonFile, getForm, getFormByVersion, getLatestFormVersion, applyFormIntent } from './forms-loader'; import formsRegistry from '../../__mocks__/packages/test-forms-registry'; import { htsHivtestResultingSchemaV2, diff --git a/src/utils/forms-loader.ts b/src/utils/forms-loader.ts index df2b96aa2..79ebf3ebb 100644 --- a/src/utils/forms-loader.ts +++ b/src/utils/forms-loader.ts @@ -1,5 +1,5 @@ import * as semver from 'semver'; -import { FormField } from '../types'; +import { type FormField } from '../types'; let baseRegistry = {}; export interface FormJsonFile { diff --git a/src/utils/patient-identifier-helper.ts b/src/utils/patient-identifier-helper.ts index ec7673f0c..74845bd59 100644 --- a/src/utils/patient-identifier-helper.ts +++ b/src/utils/patient-identifier-helper.ts @@ -1,21 +1,21 @@ -import { savePatientIdentifier} from "../api/api"; -import { PatientIdentifier } from "../types"; +import { savePatientIdentifier } from '../api/api'; +import { type PatientIdentifier } from '../types'; -export const saveIdentifier = (patient: fhir.Patient, patientIdentifier:PatientIdentifier) =>{ - const identifier = getPatientLatestIdentifier(patient, patientIdentifier.identifierType); - if(identifier){ - patientIdentifier.uuid = identifier.id; - } +export const saveIdentifier = (patient: fhir.Patient, patientIdentifier: PatientIdentifier) => { + const identifier = getPatientLatestIdentifier(patient, patientIdentifier.identifierType); + if (identifier) { + patientIdentifier.uuid = identifier.id; + } - return savePatientIdentifier(patientIdentifier, patient.id); -} + return savePatientIdentifier(patientIdentifier, patient.id); +}; -export const getPatientLatestIdentifier = (patient: fhir.Patient, identifierType: string) => { - const patientIdentifiers = patient.identifier; - return patientIdentifiers.find(identifier => { - if (identifier.type.coding && identifier.type.coding[0].code === identifierType) { - return true; - } - return false; - }); -} \ No newline at end of file +export const getPatientLatestIdentifier = (patient: fhir.Patient, identifierType: string) => { + const patientIdentifiers = patient.identifier; + return patientIdentifiers.find((identifier) => { + if (identifier.type.coding && identifier.type.coding[0].code === identifierType) { + return true; + } + return false; + }); +}; diff --git a/src/validators/date-validator.test.ts b/src/validators/date-validator.test.ts index d3428371b..7cc47fb04 100644 --- a/src/validators/date-validator.test.ts +++ b/src/validators/date-validator.test.ts @@ -1,4 +1,4 @@ -import { FormField } from '../types'; +import { type FormField } from '../types'; import { DateValidator } from './date-validator'; describe('DateValidator - validate', () => { diff --git a/src/validators/date-validator.ts b/src/validators/date-validator.ts index 519e77cd8..8eec8d4ab 100644 --- a/src/validators/date-validator.ts +++ b/src/validators/date-validator.ts @@ -1,4 +1,4 @@ -import { FormFieldValidator, FormField } from '../types'; +import { type FormFieldValidator, type FormField } from '../types'; import { isTrue } from '../utils/boolean-utils'; import { FieldValidator } from './form-validator'; diff --git a/src/validators/default-value-validator.test.ts b/src/validators/default-value-validator.test.ts index 3c41e51c1..13674a9cb 100644 --- a/src/validators/default-value-validator.test.ts +++ b/src/validators/default-value-validator.test.ts @@ -1,4 +1,4 @@ -import { FormField } from '../types'; +import { type FormField } from '../types'; import { DefaultFieldValueValidator } from './default-value-validator'; describe('DefaultFieldValueValidator - validate', () => { diff --git a/src/validators/default-value-validator.ts b/src/validators/default-value-validator.ts index c7c0cba3c..9c9b85930 100644 --- a/src/validators/default-value-validator.ts +++ b/src/validators/default-value-validator.ts @@ -1,5 +1,5 @@ import dayjs from 'dayjs'; -import { FormFieldValidator, FormField } from '../types'; +import { type FormFieldValidator, type FormField } from '../types'; import { codedTypes } from '../constants'; export const DefaultFieldValueValidator: FormFieldValidator = { diff --git a/src/validators/form-validator.test.ts b/src/validators/form-validator.test.ts index 29870fbd7..8323708c0 100644 --- a/src/validators/form-validator.test.ts +++ b/src/validators/form-validator.test.ts @@ -1,4 +1,4 @@ -import { FormField } from '../types'; +import { type FormField } from '../types'; import { FieldValidator } from './form-validator'; describe('FieldValidator - validate', () => { diff --git a/src/validators/form-validator.ts b/src/validators/form-validator.ts index 061a980ce..b3fbfbee3 100644 --- a/src/validators/form-validator.ts +++ b/src/validators/form-validator.ts @@ -1,4 +1,4 @@ -import { FormFieldValidator, FormField } from '../types'; +import { type FormFieldValidator, type FormField } from '../types'; import { isTrue } from '../utils/boolean-utils'; export const fieldRequiredErrCode = 'field.required'; diff --git a/src/validators/js-expression-validator.test.ts b/src/validators/js-expression-validator.test.ts index ef52b06e8..eeadafc78 100644 --- a/src/validators/js-expression-validator.test.ts +++ b/src/validators/js-expression-validator.test.ts @@ -1,6 +1,6 @@ import dayjs from 'dayjs'; -import { FormField } from '../types'; -import { ExpressionContext } from '../utils/expression-runner'; +import { type FormField } from '../types'; +import { type ExpressionContext } from '../utils/expression-runner'; import { testFields } from '../utils/expression-runner.test'; import { ExpressionValidator } from './js-expression-validator'; diff --git a/src/validators/js-expression-validator.ts b/src/validators/js-expression-validator.ts index 43acdd452..5ce944433 100644 --- a/src/validators/js-expression-validator.ts +++ b/src/validators/js-expression-validator.ts @@ -1,5 +1,5 @@ -import { FormFieldValidator, FormField } from '../types'; -import { evaluateExpression, ExpressionContext } from '../utils/expression-runner'; +import { type FormFieldValidator, type FormField } from '../types'; +import { evaluateExpression, type ExpressionContext } from '../utils/expression-runner'; interface ExpressionValidatorConfig { failsWhenExpression?: string; @@ -11,7 +11,7 @@ interface ExpressionValidatorConfig { } export const ExpressionValidator: FormFieldValidator = { - validate: function(field: FormField, value: any, config: ExpressionValidatorConfig) { + validate: function (field: FormField, value: any, config: ExpressionValidatorConfig) { const INVALID_VALUE_ERR_CODE = 'value.invalid'; const INVALID_VALUE_ERR_MESSAGE = 'Invalid value'; const FIELD_HAS_WARNINGS_MESSAGE = 'Field has warnings';