diff --git a/.eslintignore b/.eslintignore index 84c29a0d4..adefaa5ca 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1,2 @@ +**/*.d.ts **/node_modules/**/* diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 549443ba2..d02dc0325 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,38 +104,3 @@ jobs: - run: yarn config set npmAuthToken "${NODE_AUTH_TOKEN}" && yarn npm publish --access public --tag latest env: NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - - bump-form-engine_ohri: - runs-on: ubuntu-latest - - needs: pre_release - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - repository: UCSF-IGHS/openmrs-esm-ohri - ref: dev - - - name: Install dependencies - run: yarn - - - name: Bump form engine - run: yarn ci:bump-form-engine-lib - - - name: Commit changes - run: | - git config user.email "github-actions@github.com" - git config user.name "GitHub Actions" - git add yarn.lock - git commit -m "(chore) bump-form-engine" - - - name: Create PR - uses: peter-evans/create-pull-request@v6 - with: - token: ${{ secrets.ACTIONS_OHRI_PAT }} - commit-message: "(chore) Bump `@openmrs/openmrs-form-engine-lib`" - title: "(chore) Bump `@openmrs/openmrs-form-engine-lib`" - body: "This is an automated PR that bumps the [form engine library](https://github.com/openmrs/openmrs-form-engine-lib) to the newest available version tagged `next`." - branch: chore/bump-form-engine - base: dev diff --git a/README.md b/README.md index ea03dcd5f..d02bef1d0 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@
-:wave: *New to O3? Be sure to review the [OpenMRS 3 Frontend Developer Documentation](https://openmrs.github.io/openmrs-esm-core/#/). You may find the [Map of the Project](https://openmrs.github.io/openmrs-esm-core/#/main/map) especially helpful.* :teacher: +:wave: *New to O3? Be sure to review the [OpenMRS 3 Frontend Developer Documentation](https://openmrs.github.io/openmrs-esm-core/#/). You may find the [Map of the Project](https://openmrs.github.io/openmrs-esm-core/#/main/map) especially helpful.* :teacher: -[![Form-engine-CI](https://github.com/UCSF-IGHS/openmrs-ohri-form-engine-lib/actions/workflows/node.js.yml/badge.svg)](https://github.com/UCSF-IGHS/openmrs-ohri-form-engine-lib/actions/workflows/node.js.yml) # OpenMRS Form Engine @@ -48,10 +47,10 @@ yarn add @openmrs/openmrs-form-engine-lib@latest ### Local Development -#### Install Dependencies +#### Install Dependencies ```bash -yarn +yarn ``` #### Build the library diff --git a/__mocks__/forms/omrs-forms/component_art.json b/__mocks__/forms/omrs-forms/component_art.json index 9cf5347f8..a365587cd 100644 --- a/__mocks__/forms/omrs-forms/component_art.json +++ b/__mocks__/forms/omrs-forms/component_art.json @@ -16,7 +16,7 @@ "links": [ { "rel": "self", - "uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f", + "uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f", "resourceAlias": "user" } ] diff --git a/__mocks__/forms/omrs-forms/component_preclinic-review.json b/__mocks__/forms/omrs-forms/component_preclinic-review.json index 4baf29ce4..8f61d369f 100644 --- a/__mocks__/forms/omrs-forms/component_preclinic-review.json +++ b/__mocks__/forms/omrs-forms/component_preclinic-review.json @@ -16,7 +16,7 @@ "links": [ { "rel": "self", - "uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f", + "uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f", "resourceAlias": "user" } ] diff --git a/__mocks__/forms/omrs-forms/demo_hts-form.json b/__mocks__/forms/omrs-forms/demo_hts-form.json index ffa0dd428..de2a2b473 100644 --- a/__mocks__/forms/omrs-forms/demo_hts-form.json +++ b/__mocks__/forms/omrs-forms/demo_hts-form.json @@ -16,7 +16,7 @@ "links": [ { "rel": "self", - "uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f", + "uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f", "resourceAlias": "user" } ] @@ -34,17 +34,17 @@ "links": [ { "rel": "value", - "uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/form/955ab92f-f93e-4dc0-9c68-b7b2346def55/resource/f12989b8-b8cb-47a2-b115-24a7ebe6d7f0/value", + "uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/form/955ab92f-f93e-4dc0-9c68-b7b2346def55/resource/f12989b8-b8cb-47a2-b115-24a7ebe6d7f0/value", "resourceAlias": "resource" }, { "rel": "self", - "uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/form/955ab92f-f93e-4dc0-9c68-b7b2346def55/resource/f12989b8-b8cb-47a2-b115-24a7ebe6d7f0", + "uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/form/955ab92f-f93e-4dc0-9c68-b7b2346def55/resource/f12989b8-b8cb-47a2-b115-24a7ebe6d7f0", "resourceAlias": "resource" }, { "rel": "full", - "uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/form/955ab92f-f93e-4dc0-9c68-b7b2346def55/resource/f12989b8-b8cb-47a2-b115-24a7ebe6d7f0?v=full", + "uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/form/955ab92f-f93e-4dc0-9c68-b7b2346def55/resource/f12989b8-b8cb-47a2-b115-24a7ebe6d7f0?v=full", "resourceAlias": "resource" } ], @@ -54,9 +54,9 @@ "links": [ { "rel": "self", - "uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/form/955ab92f-f93e-4dc0-9c68-b7b2346def55", + "uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/form/955ab92f-f93e-4dc0-9c68-b7b2346def55", "resourceAlias": "form" } ], "resourceVersion": "1.9" -} \ No newline at end of file +} diff --git a/__mocks__/forms/omrs-forms/form-component.json b/__mocks__/forms/omrs-forms/form-component.json index 0797be7e3..81b53689c 100644 --- a/__mocks__/forms/omrs-forms/form-component.json +++ b/__mocks__/forms/omrs-forms/form-component.json @@ -16,7 +16,7 @@ "links": [ { "rel": "self", - "uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f", + "uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f", "resourceAlias": "user" } ] diff --git a/__mocks__/forms/omrs-forms/nested-form1.json b/__mocks__/forms/omrs-forms/nested-form1.json index f5a6eaa5a..0d2a304fb 100644 --- a/__mocks__/forms/omrs-forms/nested-form1.json +++ b/__mocks__/forms/omrs-forms/nested-form1.json @@ -16,7 +16,7 @@ "links": [ { "rel": "self", - "uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f", + "uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f", "resourceAlias": "user" } ] @@ -35,4 +35,4 @@ } ], "resourceVersion": "1.9" -} \ No newline at end of file +} diff --git a/__mocks__/forms/omrs-forms/nested-form2.json b/__mocks__/forms/omrs-forms/nested-form2.json index d08a7e639..d4c0b8d22 100644 --- a/__mocks__/forms/omrs-forms/nested-form2.json +++ b/__mocks__/forms/omrs-forms/nested-form2.json @@ -16,7 +16,7 @@ "links": [ { "rel": "self", - "uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f", + "uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f", "resourceAlias": "user" } ] @@ -35,4 +35,4 @@ } ], "resourceVersion": "1.9" -} \ No newline at end of file +} diff --git a/__mocks__/forms/ohri-forms/age-validation-form.json b/__mocks__/forms/rfe-forms/age-validation-form.json similarity index 100% rename from __mocks__/forms/ohri-forms/age-validation-form.json rename to __mocks__/forms/rfe-forms/age-validation-form.json diff --git a/__mocks__/forms/ohri-forms/bmi-test-form.json b/__mocks__/forms/rfe-forms/bmi-test-form.json similarity index 100% rename from __mocks__/forms/ohri-forms/bmi-test-form.json rename to __mocks__/forms/rfe-forms/bmi-test-form.json diff --git a/__mocks__/forms/ohri-forms/bsa-test-form.json b/__mocks__/forms/rfe-forms/bsa-test-form.json similarity index 100% rename from __mocks__/forms/ohri-forms/bsa-test-form.json rename to __mocks__/forms/rfe-forms/bsa-test-form.json diff --git a/__mocks__/forms/ohri-forms/component_art.json b/__mocks__/forms/rfe-forms/component_art.json similarity index 100% rename from __mocks__/forms/ohri-forms/component_art.json rename to __mocks__/forms/rfe-forms/component_art.json diff --git a/__mocks__/forms/ohri-forms/component_preclinic-review.json b/__mocks__/forms/rfe-forms/component_preclinic-review.json similarity index 100% rename from __mocks__/forms/ohri-forms/component_preclinic-review.json rename to __mocks__/forms/rfe-forms/component_preclinic-review.json diff --git a/__mocks__/forms/ohri-forms/demo_hts-form.json b/__mocks__/forms/rfe-forms/demo_hts-form.json similarity index 100% rename from __mocks__/forms/ohri-forms/demo_hts-form.json rename to __mocks__/forms/rfe-forms/demo_hts-form.json diff --git a/__mocks__/forms/ohri-forms/edd-test-form.json b/__mocks__/forms/rfe-forms/edd-test-form.json similarity index 100% rename from __mocks__/forms/ohri-forms/edd-test-form.json rename to __mocks__/forms/rfe-forms/edd-test-form.json diff --git a/__mocks__/forms/ohri-forms/external_data_source_form.json b/__mocks__/forms/rfe-forms/external_data_source_form.json similarity index 100% rename from __mocks__/forms/ohri-forms/external_data_source_form.json rename to __mocks__/forms/rfe-forms/external_data_source_form.json diff --git a/__mocks__/forms/ohri-forms/filter-answer-options-test-form.json b/__mocks__/forms/rfe-forms/filter-answer-options-test-form.json similarity index 100% rename from __mocks__/forms/ohri-forms/filter-answer-options-test-form.json rename to __mocks__/forms/rfe-forms/filter-answer-options-test-form.json diff --git a/__mocks__/forms/ohri-forms/form-component.json b/__mocks__/forms/rfe-forms/form-component.json similarity index 100% rename from __mocks__/forms/ohri-forms/form-component.json rename to __mocks__/forms/rfe-forms/form-component.json diff --git a/__mocks__/forms/ohri-forms/forms-loader.test.schema.ts b/__mocks__/forms/rfe-forms/forms-loader.test.schema.ts similarity index 100% rename from __mocks__/forms/ohri-forms/forms-loader.test.schema.ts rename to __mocks__/forms/rfe-forms/forms-loader.test.schema.ts diff --git a/__mocks__/forms/ohri-forms/labour_and_delivery_test_form.json b/__mocks__/forms/rfe-forms/labour_and_delivery_test_form.json similarity index 100% rename from __mocks__/forms/ohri-forms/labour_and_delivery_test_form.json rename to __mocks__/forms/rfe-forms/labour_and_delivery_test_form.json diff --git a/__mocks__/forms/ohri-forms/mini-form.json b/__mocks__/forms/rfe-forms/mini-form.json similarity index 100% rename from __mocks__/forms/ohri-forms/mini-form.json rename to __mocks__/forms/rfe-forms/mini-form.json diff --git a/__mocks__/forms/ohri-forms/months-on-art-form.json b/__mocks__/forms/rfe-forms/months-on-art-form.json similarity index 100% rename from __mocks__/forms/ohri-forms/months-on-art-form.json rename to __mocks__/forms/rfe-forms/months-on-art-form.json diff --git a/__mocks__/forms/ohri-forms/nested-form1.json b/__mocks__/forms/rfe-forms/nested-form1.json similarity index 100% rename from __mocks__/forms/ohri-forms/nested-form1.json rename to __mocks__/forms/rfe-forms/nested-form1.json diff --git a/__mocks__/forms/ohri-forms/nested-form2.json b/__mocks__/forms/rfe-forms/nested-form2.json similarity index 100% rename from __mocks__/forms/ohri-forms/nested-form2.json rename to __mocks__/forms/rfe-forms/nested-form2.json diff --git a/__mocks__/forms/ohri-forms/next-visit-test-form.json b/__mocks__/forms/rfe-forms/next-visit-test-form.json similarity index 100% rename from __mocks__/forms/ohri-forms/next-visit-test-form.json rename to __mocks__/forms/rfe-forms/next-visit-test-form.json diff --git a/__mocks__/forms/ohri-forms/obs-group-test_form.json b/__mocks__/forms/rfe-forms/obs-group-test_form.json similarity index 100% rename from __mocks__/forms/ohri-forms/obs-group-test_form.json rename to __mocks__/forms/rfe-forms/obs-group-test_form.json diff --git a/__mocks__/forms/ohri-forms/post-submission-test-form.json b/__mocks__/forms/rfe-forms/post-submission-test-form.json similarity index 100% rename from __mocks__/forms/ohri-forms/post-submission-test-form.json rename to __mocks__/forms/rfe-forms/post-submission-test-form.json diff --git a/__mocks__/forms/ohri-forms/reference-by-mapping-form.json b/__mocks__/forms/rfe-forms/reference-by-mapping-form.json similarity index 100% rename from __mocks__/forms/ohri-forms/reference-by-mapping-form.json rename to __mocks__/forms/rfe-forms/reference-by-mapping-form.json diff --git a/__mocks__/forms/ohri-forms/sample_fields.json b/__mocks__/forms/rfe-forms/sample_fields.json similarity index 100% rename from __mocks__/forms/ohri-forms/sample_fields.json rename to __mocks__/forms/rfe-forms/sample_fields.json diff --git a/__mocks__/forms/ohri-forms/test-enrolment-form.json b/__mocks__/forms/rfe-forms/test-enrolment-form.json similarity index 100% rename from __mocks__/forms/ohri-forms/test-enrolment-form.json rename to __mocks__/forms/rfe-forms/test-enrolment-form.json diff --git a/__mocks__/forms/ohri-forms/treatment-end-date-test-form.json b/__mocks__/forms/rfe-forms/treatment-end-date-test-form.json similarity index 100% rename from __mocks__/forms/ohri-forms/treatment-end-date-test-form.json rename to __mocks__/forms/rfe-forms/treatment-end-date-test-form.json diff --git a/__mocks__/forms/ohri-forms/viral-load-status-form.json b/__mocks__/forms/rfe-forms/viral-load-status-form.json similarity index 100% rename from __mocks__/forms/ohri-forms/viral-load-status-form.json rename to __mocks__/forms/rfe-forms/viral-load-status-form.json diff --git a/__mocks__/forms/ohri-forms/zscore-bmi-for-age-form.json b/__mocks__/forms/rfe-forms/zscore-bmi-for-age-form.json similarity index 100% rename from __mocks__/forms/ohri-forms/zscore-bmi-for-age-form.json rename to __mocks__/forms/rfe-forms/zscore-bmi-for-age-form.json diff --git a/__mocks__/forms/ohri-forms/zscore-height-for-age-form.json b/__mocks__/forms/rfe-forms/zscore-height-for-age-form.json similarity index 100% rename from __mocks__/forms/ohri-forms/zscore-height-for-age-form.json rename to __mocks__/forms/rfe-forms/zscore-height-for-age-form.json diff --git a/__mocks__/forms/ohri-forms/zscore-weight-height-form.json b/__mocks__/forms/rfe-forms/zscore-weight-height-form.json similarity index 100% rename from __mocks__/forms/ohri-forms/zscore-weight-height-form.json rename to __mocks__/forms/rfe-forms/zscore-weight-height-form.json diff --git a/__mocks__/use-initial-values/encounter.mock.json b/__mocks__/use-initial-values/encounter.mock.json index b476eba95..b8583f5b9 100644 --- a/__mocks__/use-initial-values/encounter.mock.json +++ b/__mocks__/use-initial-values/encounter.mock.json @@ -214,8 +214,8 @@ "voided": false, "value": "Mother is in perfect condition", "valueModifier": null, - "formFieldPath": "ohri-forms-notes", - "formFieldNamespace": "ohri-forms", + "formFieldPath": "rfe-forms-notes", + "formFieldNamespace": "rfe-forms", "status": "FINAL", "interpretation": null, "links": [ @@ -329,8 +329,8 @@ "voided": false, "value": "2023-07-24T00:00:00.000+0000", "valueModifier": null, - "formFieldPath": "ohri-forms-date_of_birth", - "formFieldNamespace": "ohri-forms", + "formFieldPath": "rfe-forms-date_of_birth", + "formFieldNamespace": "rfe-forms", "status": "FINAL", "interpretation": null, "links": [ @@ -414,8 +414,8 @@ "voided": false, "value": "TBD", "valueModifier": null, - "formFieldPath": "ohri-forms-infant_name", - "formFieldNamespace": "ohri-forms", + "formFieldPath": "rfe-forms-infant_name", + "formFieldNamespace": "rfe-forms", "status": "FINAL", "interpretation": null, "links": [ @@ -575,8 +575,8 @@ "voided": false, "value": " TDB II", "valueModifier": null, - "formFieldPath": "ohri-forms-infant_name_2", - "formFieldNamespace": "ohri-forms", + "formFieldPath": "rfe-forms-infant_name_2", + "formFieldNamespace": "rfe-forms", "status": "FINAL", "interpretation": null, "links": [ @@ -660,8 +660,8 @@ "voided": false, "value": "2023-07-24T00:00:00.000+0000", "valueModifier": null, - "formFieldPath": "ohri-forms-date_of_birth_2", - "formFieldNamespace": "ohri-forms", + "formFieldPath": "rfe-forms-date_of_birth_2", + "formFieldNamespace": "rfe-forms", "status": "FINAL", "interpretation": null, "links": [ @@ -781,8 +781,8 @@ "voided": false, "value": 2, "valueModifier": null, - "formFieldPath": "ohri-forms-number_of_babies", - "formFieldNamespace": "ohri-forms", + "formFieldPath": "rfe-forms-number_of_babies", + "formFieldNamespace": "rfe-forms", "status": "FINAL", "interpretation": null, "links": [ @@ -864,4 +864,4 @@ } ], "resourceVersion": "2.2" -} \ No newline at end of file +} diff --git a/src/api/api.ts b/src/api/api.ts index dc28bf1c2..249fe76f2 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -1,8 +1,8 @@ -import { openmrsFetch, openmrsObservableFetch } from '@openmrs/esm-framework'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; +import { openmrsFetch, openmrsObservableFetch } from '@openmrs/esm-framework'; import { encounterRepresentation } from '../constants'; -import { OpenmrsForm, ProgramEnrollmentPayload } from './types'; +import { OpenmrsForm, ProgramEnrollmentPayload } from '../types'; import { isUuid } from '../utils/boolean-utils'; const BASE_WS_API_URL = '/ws/rest/v1/'; @@ -121,7 +121,7 @@ export async function fetchOpenMRSForm(nameOrUUID: string): Promise} - A Promise that resolves to the fetched ClobData or null if not found. */ -export async function fetchClobData(form: OpenmrsForm): Promise { +export async function fetchClobdata(form: OpenmrsForm): Promise { if (!form) { return null; } diff --git a/src/components/encounter/ohri-encounter-form.component.tsx b/src/components/encounter/encounter-form.component.tsx similarity index 95% rename from src/components/encounter/ohri-encounter-form.component.tsx rename to src/components/encounter/encounter-form.component.tsx index c09532aaa..3147a7dd8 100644 --- a/src/components/encounter/ohri-encounter-form.component.tsx +++ b/src/components/encounter/encounter-form.component.tsx @@ -1,31 +1,31 @@ import React, { Dispatch, SetStateAction, useCallback, useEffect, useMemo, useState } from 'react'; import { SessionLocation, showToast, useLayoutType, Visit } from '@openmrs/esm-framework'; -import { ConceptFalse, ConceptTrue, codedTypes } from '../../constants'; +import { codedTypes, ConceptFalse, ConceptTrue } from '../../constants'; import { - OHRIFormField, - OHRIFormPage as OHRIFormPageProps, - OHRIFormSchema, + FormField, + FormPage as FormPageProps, + FormSchema, OpenmrsEncounter, SessionMode, ValidationResult, RepeatObsGroupCounter, -} from '../../api/types'; -import OHRIFormPage from '../page/ohri-form-page.component'; -import { OHRIFormContext } from '../../ohri-form-context'; +} from '../../types'; +import FormPage from '../page/form-page.component'; +import { FormContext } from '../../form-context'; import { cascadeVisibityToChildFields, evaluateFieldReadonlyProp, findConceptByReference, findPagesWithErrors, voidObsValueOnFieldHidden, -} from '../../utils/ohri-form-helper'; -import { isEmpty, isEmpty as isValueEmpty, OHRIFieldValidator } from '../../validators/ohri-form-validator'; +} from '../../utils/form-helper'; import { InstantEffect } from '../../utils/instant-effect'; -import { FormSubmissionHandler } from '../../ohri-form.component'; +import { 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'; -import { scrollIntoView } from '../../utils/ohri-sidebar'; +import { isEmpty, isEmpty as isValueEmpty, FieldValidator } from '../../validators/form-validator'; +import { scrollIntoView } from '../../utils/scroll-into-view'; import { useEncounter } from '../../hooks/useEncounter'; import { useInitialValues } from '../../hooks/useInitialValues'; import { useEncounterRole } from '../../hooks/useEncounterRole'; @@ -33,8 +33,8 @@ import { useConcepts } from '../../hooks/useConcepts'; import { useFormFieldHandlers } from '../../hooks/useFormFieldHandlers'; import { useFormFieldValidators } from '../../hooks/useFormFieldValidators'; -interface OHRIEncounterFormProps { - formJson: OHRIFormSchema; +interface EncounterFormProps { + formJson: FormSchema; patient: any; formSessionDate: Date; provider: string; @@ -43,12 +43,12 @@ interface OHRIEncounterFormProps { values: Record; isFormExpanded: boolean; sessionMode: SessionMode; - scrollablePages: Set; + scrollablePages: Set; handlers: Map; allInitialValues: Record; workspaceLayout: 'minimized' | 'maximized'; setAllInitialValues: (values: Record) => void; - setScrollablePages: (pages: Set) => void; + setScrollablePages: (pages: Set) => void; setPagesWithErrors: (pages: string[]) => void; setIsLoadingFormDependencies?: (value: boolean) => void; setFieldValue: (field: string, value: any, shouldValidate?: boolean) => void; @@ -57,7 +57,7 @@ interface OHRIEncounterFormProps { setIsSubmitting?: Dispatch>; } -export const OHRIEncounterForm: React.FC = ({ +export const EncounterForm: React.FC = ({ formJson, patient, formSessionDate, @@ -80,14 +80,14 @@ export const OHRIEncounterForm: React.FC = ({ isSubmitting, setIsSubmitting, }) => { - const [fields, setFields] = useState>([]); + const [fields, setFields] = useState>([]); const [encounterLocation, setEncounterLocation] = useState(null); const [encounterDate, setEncounterDate] = useState(formSessionDate); const [encounterProvider, setEncounterProvider] = useState(provider); const { encounter, isLoading: isLoadingEncounter } = useEncounter(formJson); const [previousEncounter, setPreviousEncounter] = useState(null); const [isLoadingPreviousEncounter, setIsLoadingPreviousEncounter] = useState(true); - const [form, setForm] = useState(formJson); + const [form, setForm] = useState(formJson); const [obsGroupsToVoid, setObsGroupsToVoid] = useState([]); const [isFieldInitializationComplete, setIsFieldInitializationComplete] = useState(false); const [invalidFields, setInvalidFields] = useState([]); @@ -333,7 +333,7 @@ export const OHRIEncounterForm: React.FC = ({ } }, [isLoadingEncounter, isLoadingPreviousEncounter]); - const evalHide = (node, allFields: OHRIFormField[], allValues: Record) => { + const evalHide = (node, allFields: FormField[], allValues: Record) => { const { value, type } = node; const isHidden = evaluateExpression(value['hide']?.hideWhenExpression, node, allFields, allValues, { mode: sessionMode, @@ -422,7 +422,7 @@ export const OHRIEncounterForm: React.FC = ({ .filter((field) => field['submission']?.unspecified != true) .forEach((field) => { const errors = - OHRIFieldValidator.validate(field, values[field.id]).filter((error) => error.resultType == 'error') ?? []; + FieldValidator.validate(field, values[field.id]).filter((error) => error.resultType == 'error') ?? []; if (errors.length) { errorFields.push(field); field['submission'] = { @@ -728,7 +728,7 @@ export const OHRIEncounterForm: React.FC = ({ handlers.set(form.name, { validate: validate, submit: handleFormSubmit }); } return ( - = ({ return null; } return ( - = ({ ); } return ( - = ({ /> ); })} - + ); }; diff --git a/src/components/extension/ohri-extension-parcel.component.tsx b/src/components/extension/extension-parcel.component.tsx similarity index 76% rename from src/components/extension/ohri-extension-parcel.component.tsx rename to src/components/extension/extension-parcel.component.tsx index 9239acc02..1f02f72f9 100644 --- a/src/components/extension/ohri-extension-parcel.component.tsx +++ b/src/components/extension/extension-parcel.component.tsx @@ -1,11 +1,11 @@ import React, { useContext, useEffect, useMemo } from 'react'; import { BehaviorSubject } from 'rxjs'; import { attach, ExtensionSlot } from '@openmrs/esm-framework'; -import { OHRIFormContext } from '../../ohri-form-context'; -import { OHRIFormFieldProps } from '../../api/types'; +import { FormContext } from '../../form-context'; +import { FormFieldProps } from '../../types'; -const OHRIExtensionParcel: React.FC = ({ question }) => { - const { encounterContext, isSubmitting } = useContext(OHRIFormContext); +const ExtensionParcel: React.FC = ({ question }) => { + const { encounterContext, isSubmitting } = useContext(FormContext); const submissionNotifier = useMemo(() => new BehaviorSubject<{ isSubmitting: boolean }>({ isSubmitting: false }), []); const state = useMemo( @@ -32,4 +32,4 @@ const OHRIExtensionParcel: React.FC = ({ question }) => { ); }; -export default OHRIExtensionParcel; +export default ExtensionParcel; diff --git a/src/components/group/ohri-obs-group.component.tsx b/src/components/group/obs-group.component.tsx similarity index 72% rename from src/components/group/ohri-obs-group.component.tsx rename to src/components/group/obs-group.component.tsx index c5faaa904..87f1d7564 100644 --- a/src/components/group/ohri-obs-group.component.tsx +++ b/src/components/group/obs-group.component.tsx @@ -1,20 +1,20 @@ import React, { useContext, useEffect, useState } from 'react'; import classNames from 'classnames'; -import { OHRIFormContext } from '../../ohri-form-context'; -import { OHRIFormFieldProps } from '../../api/types'; -import { OHRIUnspecified } from '../inputs/unspecified/ohri-unspecified.component'; import { useField } from 'formik'; +import { FormContext } from '../../form-context'; +import { FormFieldProps } from '../../types'; import { getFieldControlWithFallback, isUnspecifiedSupported } from '../section/helpers'; -import { OHRITooltip } from '../inputs/tooltip/ohri-tooltip.component'; -import styles from '../section/ohri-form-section.scss'; +import { UnspecifiedField } from '../inputs/unspecified/unspecified.component'; +import { Tooltip } from '../inputs/tooltip/tooltip.component'; +import styles from '../section/form-section.scss'; -export interface ObsGroupProps extends OHRIFormFieldProps { +export interface ObsGroupProps extends FormFieldProps { deleteControl?: any; } -export const OHRIObsGroup: React.FC = ({ question, onChange, deleteControl }) => { +export const ObsGroup: React.FC = ({ question, onChange, deleteControl }) => { const [groupMembersControlMap, setGroupMembersControlMap] = useState([]); - const { formFieldHandlers } = useContext(OHRIFormContext); + const { encounterContext, formFieldHandlers } = useContext(FormContext); useEffect(() => { if (question.questions) { @@ -52,9 +52,9 @@ export const OHRIObsGroup: React.FC = ({ question, onChange, dele [styles.tooltip]: !isUnspecifiedSupported(field), })}> {isUnspecifiedSupported(field) && ( - + )} - {field.questionInfo && } + {field.questionInfo && } diff --git a/src/components/inputs/content-switcher/ohri-content-switcher.component.tsx b/src/components/inputs/content-switcher/content-switcher.component.tsx similarity index 79% rename from src/components/inputs/content-switcher/ohri-content-switcher.component.tsx rename to src/components/inputs/content-switcher/content-switcher.component.tsx index 873de17dd..d5fb55c49 100644 --- a/src/components/inputs/content-switcher/ohri-content-switcher.component.tsx +++ b/src/components/inputs/content-switcher/content-switcher.component.tsx @@ -1,18 +1,18 @@ import React, { useEffect, useMemo, useState } from 'react'; import classNames from 'classnames'; -import { FormGroup, ContentSwitcher, Switch } from '@carbon/react'; +import { FormGroup, ContentSwitcher as Switcher, Switch } from '@carbon/react'; import { useField } from 'formik'; -import { isInlineView } from '../../../utils/ohri-form-helper'; +import { isInlineView } from '../../../utils/form-helper'; +import { isEmpty } from '../../../validators/form-validator'; import { isTrue } from '../../../utils/boolean-utils'; -import { OHRIFieldValueView } from '../../value/view/ohri-field-value-view.component'; -import { OHRIFormContext } from '../../../ohri-form-context'; -import { OHRIFormFieldProps } from '../../../api/types'; -import styles from './ohri-content-switcher.scss'; -import { isEmpty } from '../../../validators/ohri-form-validator'; +import { FieldValueView } from '../../value/view/field-value-view.component'; +import { FormContext } from '../../../form-context'; +import { FormFieldProps } from '../../../types'; +import styles from './content-switcher.scss'; -export const OHRIContentSwitcher: React.FC = ({ question, onChange, handler, previousValue }) => { +export const ContentSwitcher: React.FC = ({ question, onChange, handler, previousValue }) => { const [field, meta] = useField(question.id); - const { setFieldValue, encounterContext, layoutType, workspaceLayout } = React.useContext(OHRIFormContext); + const { setFieldValue, encounterContext, layoutType, workspaceLayout } = React.useContext(FormContext); const [errors, setErrors] = useState([]); useEffect(() => { @@ -52,7 +52,7 @@ export const OHRIContentSwitcher: React.FC = ({ question, on encounterContext.sessionMode == 'embedded-view' || isTrue(question.readonly) ? (
- = ({ question, on [styles.errorLegend]: errors.length > 0, [styles.boldedLegend]: errors.length === 0, })}> - = ({ question, on disabled={question.disabled} /> ))} - + ) ); diff --git a/src/components/inputs/content-switcher/content-switcher.scss b/src/components/inputs/content-switcher/content-switcher.scss new file mode 100644 index 000000000..14a4032b5 --- /dev/null +++ b/src/components/inputs/content-switcher/content-switcher.scss @@ -0,0 +1,49 @@ +@use '@carbon/colors'; + +.formField { + margin-top: 0.625rem; +} + +.formField > div > div > label { + color: colors.$gray-70; +} + +.textContainer { + label { + font-size: 0.875rem !important; + } +} + +.errorLegend legend, .errorLabel label { + color: colors.$red-60 !important; +} + +.selectedOption { + border-radius: 4px; + width: 15rem; + + button { + background-color: colors.$gray-10; + + &:before { + display: none !important; + } + } +} + +.switchOverrides { + background-color: colors.$blue-10 !important; + border: 1px solid colors.$blue-60 !important; + color: colors.$blue-60 !important; + padding: 0 0 0 1rem; + + button:focus { + border: none !important; + } +} + +.sansSwitchOverrides { + border: solid 1px colors.$blue-30 !important; + background-color: colors.$gray-10 !important; + padding: 0 0 0 1rem; +} diff --git a/src/components/inputs/content-switcher/ohri-content-switcher.test.tsx b/src/components/inputs/content-switcher/content-switcher.test.tsx similarity index 89% rename from src/components/inputs/content-switcher/ohri-content-switcher.test.tsx rename to src/components/inputs/content-switcher/content-switcher.test.tsx index bd2de0a39..16a22c0e4 100644 --- a/src/components/inputs/content-switcher/ohri-content-switcher.test.tsx +++ b/src/components/inputs/content-switcher/content-switcher.test.tsx @@ -1,12 +1,12 @@ import React from 'react'; import { render, fireEvent, screen, cleanup, act, waitFor } from '@testing-library/react'; import { Form, Formik } from 'formik'; -import { EncounterContext, OHRIFormContext } from '../../../ohri-form-context'; -import { OHRIFormField } from '../../../api/types'; +import { ContentSwitcher } from './content-switcher.component'; +import { EncounterContext, FormContext } from '../../../form-context'; +import { FormField } from '../../../types'; import { ObsSubmissionHandler } from '../../../submission-handlers/base-handlers'; -import { OHRIContentSwitcher } from './ohri-content-switcher.component'; -const question: OHRIFormField = { +const question: FormField = { label: 'Patient past program', type: 'obs', questionOptions: { @@ -56,7 +56,7 @@ const renderForm = (intialValues) => { {(props) => (
- { isSubmitting: false, formFieldHandlers: { obs: ObsSubmissionHandler }, }}> - - + + )}
, @@ -106,8 +106,8 @@ describe('content-switcher input field', () => { order: null, groupMembers: [], voided: false, - formFieldNamespace: 'ohri-forms', - formFieldPath: 'ohri-forms-patient-past-program', + formFieldNamespace: 'rfe-forms', + formFieldPath: 'rfe-forms-patient-past-program', value: '12f7be3d-fb5d-47dc-b5e3-56c501be80a6', }); }); diff --git a/src/components/inputs/content-switcher/ohri-content-switcher.scss b/src/components/inputs/content-switcher/ohri-content-switcher.scss deleted file mode 100644 index b060c46c1..000000000 --- a/src/components/inputs/content-switcher/ohri-content-switcher.scss +++ /dev/null @@ -1,11 +0,0 @@ -@use '@carbon/colors'; - -.errorLegend legend { - color: colors.$red-60 !important; - font-weight: 600; -} - -.boldedLegend legend { - color: colors.$black-100 !important; - font-weight: 600; -} diff --git a/src/components/inputs/date/ohri-date.component.tsx b/src/components/inputs/date/date.component.tsx similarity index 93% rename from src/components/inputs/date/ohri-date.component.tsx rename to src/components/inputs/date/date.component.tsx index 8fc22aba6..a7651bd44 100644 --- a/src/components/inputs/date/ohri-date.component.tsx +++ b/src/components/inputs/date/date.component.tsx @@ -5,21 +5,21 @@ import { useTranslation } from 'react-i18next'; import { useField } from 'formik'; import { DatePicker, DatePickerInput, Layer, TimePicker } from '@carbon/react'; import { formatDate } from '@openmrs/esm-framework'; -import { fieldRequiredErrCode, isEmpty } from '../../../validators/ohri-form-validator'; -import { isInlineView } from '../../../utils/ohri-form-helper'; import { isTrue } from '../../../utils/boolean-utils'; -import { OHRIFormFieldProps } from '../../../api/types'; -import { OHRIFormContext } from '../../../ohri-form-context'; -import { OHRIFieldValueView } from '../../value/view/ohri-field-value-view.component'; -import styles from './ohri-date.scss'; +import { 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'; +import { FormContext } from '../../../form-context'; +import styles from './date.scss'; const locale = window.i18next.language == 'en' ? 'en-GB' : window.i18next.language; const dateFormatter = new Intl.DateTimeFormat(locale); -const OHRIDate: React.FC = ({ question, onChange, handler, previousValue }) => { +const DateField: React.FC = ({ question, onChange, handler, previousValue }) => { const { t } = useTranslation(); const [field, meta] = useField(question.id); - const { setFieldValue, encounterContext, layoutType, workspaceLayout, fields } = React.useContext(OHRIFormContext); + const { setFieldValue, encounterContext, layoutType, workspaceLayout, fields } = React.useContext(FormContext); const [errors, setErrors] = useState([]); const [warnings, setWarnings] = useState([]); const isFieldRequiredError = useMemo(() => errors[0]?.errCode == fieldRequiredErrCode, [errors]); @@ -141,7 +141,7 @@ const OHRIDate: React.FC = ({ question, onChange, handler, p }, [field.value, time]); return encounterContext.sessionMode == 'view' || encounterContext.sessionMode == 'embedded-view' ? ( - = ({ question, onChange, handler }) => { +const File: React.FC = ({ question, handler }) => { const { t } = useTranslation(); const [cameraWidgetVisible, setCameraWidgetVisible] = useState(false); - const [field, meta] = useField(question.id); - const { setFieldValue, encounterContext, layoutType, workspaceLayout } = React.useContext(OHRIFormContext); + const { setFieldValue, encounterContext, layoutType, workspaceLayout } = React.useContext(FormContext); const [selectedFiles, setSelectedFiles] = useState(null); // Add state for selected files const [imagePreview, setImagePreview] = useState(null); const [uploadMode, setUploadMode] = useState(''); diff --git a/src/components/inputs/fixed-value/ohri-fixed-value.component.tsx b/src/components/inputs/fixed-value/fixed-value.component.tsx similarity index 80% rename from src/components/inputs/fixed-value/ohri-fixed-value.component.tsx rename to src/components/inputs/fixed-value/fixed-value.component.tsx index e2753dbc6..0f759c716 100644 --- a/src/components/inputs/fixed-value/ohri-fixed-value.component.tsx +++ b/src/components/inputs/fixed-value/fixed-value.component.tsx @@ -1,12 +1,12 @@ import React, { useEffect } from 'react'; import isObject from 'lodash-es/isObject'; -import { isEmpty } from '../../../validators/ohri-form-validator'; +import { isEmpty } from '../../../validators/form-validator'; import { isTrue } from '../../../utils/boolean-utils'; -import { OHRIFormContext } from '../../../ohri-form-context'; -import { OHRIFormFieldProps } from '../../../api/types'; +import { FormContext } from '../../../form-context'; +import { FormFieldProps } from '../../../types'; -const OHRIFixedValue: React.FC = ({ question, handler }) => { - const { encounterContext, isFieldInitializationComplete } = React.useContext(OHRIFormContext); +const FixedValue: React.FC = ({ question, handler }) => { + const { encounterContext, isFieldInitializationComplete } = React.useContext(FormContext); useEffect(() => { if (question.value && typeof question.value == 'string' && isFieldInitializationComplete) { delete question.value; @@ -29,4 +29,4 @@ const OHRIFixedValue: React.FC = ({ question, handler }) => function obsValueEqualTo(value: string, obs: any) { return isObject(obs.value) ? obs.value?.uuid == value : obs.value == value; } -export default OHRIFixedValue; +export default FixedValue; diff --git a/src/components/inputs/location/ohri-encounter-location.component.tsx b/src/components/inputs/location/encounter-location.component.tsx similarity index 83% rename from src/components/inputs/location/ohri-encounter-location.component.tsx rename to src/components/inputs/location/encounter-location.component.tsx index e66acb393..2f433fee9 100644 --- a/src/components/inputs/location/ohri-encounter-location.component.tsx +++ b/src/components/inputs/location/encounter-location.component.tsx @@ -3,21 +3,19 @@ import { ComboBox } from '@carbon/react'; import classNames from 'classnames'; import { useField } from 'formik'; import { createErrorHandler } from '@openmrs/esm-framework'; -import { isInlineView } from '../../../utils/ohri-form-helper'; import { getAllLocations, getLocationsByTag } from '../../../api/api'; +import { isInlineView } from '../../../utils/form-helper'; import { isTrue } from '../../../utils/boolean-utils'; -import { OHRIFormField } from '../../../api/types'; -import { OHRIFormContext } from '../../../ohri-form-context'; -import { OHRIFieldValueView } from '../../value/view/ohri-field-value-view.component'; -import styles from './ohri-encounter-location.scss'; +import { FormField } from '../../../types'; +import { FormContext } from '../../../form-context'; +import { FieldValueView } from '../../value/view/field-value-view.component'; +import styles from './encounter-location.scss'; -export const OHRIEncounterLocationPicker: React.FC<{ question: OHRIFormField; onChange: any }> = ({ question }) => { +export const EncounterLocationPicker: React.FC<{ question: FormField; onChange: any }> = ({ question }) => { const [field, meta] = useField(question.id); - const { setEncounterLocation, setFieldValue, layoutType, workspaceLayout, encounterContext } = - useContext(OHRIFormContext); + const { setEncounterLocation, setFieldValue, layoutType, workspaceLayout, encounterContext } = useContext(FormContext); const [locations, setLocations] = useState([]); const isProcessingSelection = useRef(false); - const [inputValue, setInputValue] = useState(''); useEffect(() => { const fetchLocations = () => { @@ -44,7 +42,7 @@ export const OHRIEncounterLocationPicker: React.FC<{ question: OHRIFormField; on return encounterContext.sessionMode == 'view' || encounterContext.sessionMode == 'embedded-view' ? (
- = ({ question }) => { +const Markdown: React.FC = ({ question }) => { return !question.isHidden && ; }; -export default OHRIMarkdown; +export default Markdown; diff --git a/src/components/inputs/multi-select/ohri-multi-select.component.tsx b/src/components/inputs/multi-select/multi-select.component.tsx similarity index 86% rename from src/components/inputs/multi-select/ohri-multi-select.component.tsx rename to src/components/inputs/multi-select/multi-select.component.tsx index 1e791ec57..4ced8eee8 100644 --- a/src/components/inputs/multi-select/ohri-multi-select.component.tsx +++ b/src/components/inputs/multi-select/multi-select.component.tsx @@ -3,19 +3,19 @@ import { FilterableMultiSelect, Layer, UnorderedList } from '@carbon/react'; import classNames from 'classnames'; import { useField } from 'formik'; import { useTranslation } from 'react-i18next'; -import { OHRIFieldValueView } from '../../value/view/ohri-field-value-view.component'; -import { OHRIFormContext } from '../../../ohri-form-context'; -import { OHRIFormFieldProps } from '../../../api/types'; -import { OHRIValueEmpty } from '../../value/ohri-value.component'; -import { fieldRequiredErrCode, isEmpty } from '../../../validators/ohri-form-validator'; -import { isInlineView } from '../../../utils/ohri-form-helper'; +import { FieldValueView } from '../../value/view/field-value-view.component'; +import { FormContext } from '../../../form-context'; +import { FormFieldProps } from '../../../types'; +import { ValueEmpty } from '../../value/value.component'; +import { fieldRequiredErrCode, isEmpty } from '../../../validators/form-validator'; +import { isInlineView } from '../../../utils/form-helper'; import { isTrue } from '../../../utils/boolean-utils'; -import styles from './ohri-multi-select.scss'; +import styles from './multi-select.scss'; -export const OHRIMultiSelect: React.FC = ({ question, onChange, handler, previousValue }) => { +export const MultiSelect: React.FC = ({ question, onChange, handler, previousValue }) => { const { t } = useTranslation(); const [field, meta] = useField(question.id); - const { setFieldValue, encounterContext, layoutType, workspaceLayout } = React.useContext(OHRIFormContext); + const { setFieldValue, encounterContext, layoutType, workspaceLayout } = React.useContext(FormContext); const [errors, setErrors] = useState([]); const [warnings, setWarnings] = useState([]); const [counter, setCounter] = useState(0); @@ -51,7 +51,7 @@ export const OHRIMultiSelect: React.FC = ({ question, onChan })); const initiallySelectedQuestionItems = []; - questionItems.forEach((item) => { + questionItems.forEach(item => { if (field.value?.includes(item.concept)) { initiallySelectedQuestionItems.push(item); } @@ -83,7 +83,7 @@ export const OHRIMultiSelect: React.FC = ({ question, onChan return encounterContext.sessionMode == 'view' || encounterContext.sessionMode == 'embedded-view' ? (
- = ({ question, onChan
{field.value?.length ? ( - - {handler?.getDisplayValue(question, field.value)?.map((displayValue) => displayValue + ', ')} + + {handler?.getDisplayValue(question, field.value)?.map(displayValue => displayValue + ', ')} ) : ( - + )}
diff --git a/src/components/inputs/multi-select/ohri-multi-select.scss b/src/components/inputs/multi-select/multi-select.scss similarity index 100% rename from src/components/inputs/multi-select/ohri-multi-select.scss rename to src/components/inputs/multi-select/multi-select.scss diff --git a/src/components/inputs/number/ohri-number.component.tsx b/src/components/inputs/number/number.component.tsx similarity index 85% rename from src/components/inputs/number/ohri-number.component.tsx rename to src/components/inputs/number/number.component.tsx index 493b911da..ae1484d21 100644 --- a/src/components/inputs/number/ohri-number.component.tsx +++ b/src/components/inputs/number/number.component.tsx @@ -3,16 +3,16 @@ import { Layer, NumberInput } from '@carbon/react'; import classNames from 'classnames'; import { useField } from 'formik'; import { isTrue } from '../../../utils/boolean-utils'; -import { fieldRequiredErrCode, isEmpty } from '../../../validators/ohri-form-validator'; -import { isInlineView } from '../../../utils/ohri-form-helper'; -import { OHRIFieldValueView } from '../../value/view/ohri-field-value-view.component'; -import { OHRIFormFieldProps } from '../../../api/types'; -import { OHRIFormContext } from '../../../ohri-form-context'; -import styles from './ohri-number.scss'; +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 { FormContext } from '../../../form-context'; +import styles from './number.scss'; -const OHRINumber: React.FC = ({ question, onChange, handler, previousValue }) => { +const NumberField: React.FC = ({ question, onChange, handler, previousValue }) => { const [field, meta] = useField(question.id); - const { setFieldValue, encounterContext, layoutType, workspaceLayout, fields } = React.useContext(OHRIFormContext); + const { setFieldValue, encounterContext, layoutType, workspaceLayout, fields } = React.useContext(FormContext); const [errors, setErrors] = useState([]); const isFieldRequiredError = useMemo(() => errors[0]?.errCode == fieldRequiredErrCode, [errors]); const [warnings, setWarnings] = useState([]); @@ -57,7 +57,7 @@ const OHRINumber: React.FC = ({ question, onChange, handler, return encounterContext.sessionMode == 'view' || encounterContext.sessionMode == 'embedded-view' ? (
- = ({ question, onChange, handler, ); }; -export default OHRINumber; +export default NumberField; diff --git a/src/components/inputs/number/ohri-number.scss b/src/components/inputs/number/number.scss similarity index 100% rename from src/components/inputs/number/ohri-number.scss rename to src/components/inputs/number/number.scss diff --git a/src/components/inputs/radio/ohri-radio.component.tsx b/src/components/inputs/radio/radio.component.tsx similarity index 86% rename from src/components/inputs/radio/ohri-radio.component.tsx rename to src/components/inputs/radio/radio.component.tsx index 461579b3e..f51999818 100644 --- a/src/components/inputs/radio/ohri-radio.component.tsx +++ b/src/components/inputs/radio/radio.component.tsx @@ -1,18 +1,18 @@ import React, { useEffect, useMemo, useState } from 'react'; import classNames from 'classnames'; import { FormGroup, RadioButtonGroup, RadioButton } from '@carbon/react'; -import { OHRIFormFieldProps } from '../../../api/types'; +import { FormFieldProps } from '../../../types'; import { useField } from 'formik'; -import { OHRIFormContext } from '../../../ohri-form-context'; +import { FormContext } from '../../../form-context'; import { isTrue } from '../../../utils/boolean-utils'; -import { isInlineView } from '../../../utils/ohri-form-helper'; -import { fieldRequiredErrCode, isEmpty } from '../../../validators/ohri-form-validator'; -import { OHRIFieldValueView } from '../../value/view/ohri-field-value-view.component'; -import styles from './ohri-radio.scss'; +import { isInlineView } from '../../../utils/form-helper'; +import { fieldRequiredErrCode, isEmpty } from '../../../validators/form-validator'; +import { FieldValueView } from '../../value/view/field-value-view.component'; +import styles from './radio.scss'; -const OHRIRadio: React.FC = ({ question, onChange, handler, previousValue }) => { +const Radio: React.FC = ({ question, onChange, handler, previousValue }) => { const [field, meta] = useField(question.id); - const { setFieldValue, encounterContext, layoutType, workspaceLayout, fields } = React.useContext(OHRIFormContext); + const { setFieldValue, encounterContext, layoutType, workspaceLayout, fields } = React.useContext(FormContext); const [errors, setErrors] = useState([]); const isFieldRequiredError = useMemo(() => errors[0]?.errCode == fieldRequiredErrCode, [errors]); const [warnings, setWarnings] = useState([]); @@ -49,7 +49,7 @@ const OHRIRadio: React.FC = ({ question, onChange, handler, return encounterContext.sessionMode == 'view' || encounterContext.sessionMode == 'embedded-view' || isTrue(question.readonly) ? ( - = ({ question, onChange, handler, ); }; -export default OHRIRadio; +export default Radio; diff --git a/src/components/inputs/radio/ohri-radio.scss b/src/components/inputs/radio/radio.scss similarity index 100% rename from src/components/inputs/radio/ohri-radio.scss rename to src/components/inputs/radio/radio.scss diff --git a/src/components/inputs/select/ohri-dropdown.component.tsx b/src/components/inputs/select/dropdown.component.tsx similarity index 85% rename from src/components/inputs/select/ohri-dropdown.component.tsx rename to src/components/inputs/select/dropdown.component.tsx index b0c49db67..81ecd66ba 100644 --- a/src/components/inputs/select/ohri-dropdown.component.tsx +++ b/src/components/inputs/select/dropdown.component.tsx @@ -1,20 +1,21 @@ import React, { useEffect, useMemo, useState } from 'react'; import classNames from 'classnames'; import { useTranslation } from 'react-i18next'; -import { Dropdown, Layer } from '@carbon/react'; +import { Dropdown as DropdownInput, Layer } from '@carbon/react'; import { useField } from 'formik'; -import { fieldRequiredErrCode, isEmpty } from '../../../validators/ohri-form-validator'; -import { isInlineView } from '../../../utils/ohri-form-helper'; +import { fieldRequiredErrCode, isEmpty } from '../../../validators/form-validator'; +import { isInlineView } from '../../../utils/form-helper'; import { isTrue } from '../../../utils/boolean-utils'; -import { OHRIFieldValueView } from '../../value/view/ohri-field-value-view.component'; -import { OHRIFormContext } from '../../../ohri-form-context'; -import { OHRIFormFieldProps } from '../../../api/types'; -import styles from './ohri-dropdown.scss'; +import { FieldValueView } from '../../value/view/field-value-view.component'; +import { FormContext } from '../../../form-context'; +import { FormFieldProps } from '../../../types'; +import styles from './dropdown.scss'; -const OHRIDropdown: React.FC = ({ question, onChange, handler, previousValue }) => { + +const Dropdown: React.FC = ({ question, onChange, handler, previousValue }) => { const { t } = useTranslation(); const [field, meta] = useField(question.id); - const { setFieldValue, encounterContext, layoutType, workspaceLayout, fields } = React.useContext(OHRIFormContext); + const { setFieldValue, encounterContext, layoutType, workspaceLayout, fields } = React.useContext(FormContext); const [items, setItems] = React.useState([]); const [errors, setErrors] = useState([]); const isFieldRequiredError = useMemo(() => errors[0]?.errCode == fieldRequiredErrCode, [errors]); @@ -62,7 +63,7 @@ const OHRIDropdown: React.FC = ({ question, onChange, handle }, [encounterContext.sessionMode, question.readonly, question.inlineRendering, layoutType, workspaceLayout]); return encounterContext.sessionMode == 'view' || encounterContext.sessionMode == 'embedded-view' ? ( - = ({ question, onChange, handle !question.isHidden && (
- = ({ question, onChange, handle ); }; -export default OHRIDropdown; +export default Dropdown; diff --git a/src/components/inputs/select/ohri-dropdown.scss b/src/components/inputs/select/dropdown.scss similarity index 100% rename from src/components/inputs/select/ohri-dropdown.scss rename to src/components/inputs/select/dropdown.scss diff --git a/src/components/inputs/select/ohri-dropdown.test.tsx b/src/components/inputs/select/dropdown.test.tsx similarity index 89% rename from src/components/inputs/select/ohri-dropdown.test.tsx rename to src/components/inputs/select/dropdown.test.tsx index 09e380369..d8e68d36f 100644 --- a/src/components/inputs/select/ohri-dropdown.test.tsx +++ b/src/components/inputs/select/dropdown.test.tsx @@ -1,12 +1,12 @@ import React from 'react'; import { render, fireEvent, screen, cleanup, act } from '@testing-library/react'; import { Form, Formik } from 'formik'; -import { EncounterContext, OHRIFormContext } from '../../../ohri-form-context'; -import OHRIDropdown from './ohri-dropdown.component'; -import { OHRIFormField } from '../../../api/types'; +import { EncounterContext, FormContext } from '../../../form-context'; +import Dropdown from './dropdown.component'; +import { FormField } from '../../../types'; import { ObsSubmissionHandler } from '../../../submission-handlers/base-handlers'; -const question: OHRIFormField = { +const question: FormField = { label: 'Patient past program.', type: 'obs', questionOptions: { @@ -55,7 +55,7 @@ const renderForm = (intialValues) => { {(props) => (
- { isSubmitting: false, formFieldHandlers: { obs: ObsSubmissionHandler }, }}> - - + + )}
, @@ -107,8 +107,8 @@ describe('dropdown input field', () => { order: null, groupMembers: [], voided: false, - formFieldNamespace: 'ohri-forms', - formFieldPath: 'ohri-forms-patient-past-program', + formFieldNamespace: 'rfe-forms', + formFieldPath: 'rfe-forms-patient-past-program', value: '14cd2628-8a33-4b93-9c10-43989950bba0', }); }); diff --git a/src/components/inputs/text-area/ohri-text-area.component.tsx b/src/components/inputs/text-area/text-area.component.tsx similarity index 82% rename from src/components/inputs/text-area/ohri-text-area.component.tsx rename to src/components/inputs/text-area/text-area.component.tsx index ecc431091..36cb16df7 100644 --- a/src/components/inputs/text-area/ohri-text-area.component.tsx +++ b/src/components/inputs/text-area/text-area.component.tsx @@ -1,23 +1,18 @@ import React, { useEffect, useMemo, useState } from 'react'; import classNames from 'classnames'; -import { Layer, TextArea } from '@carbon/react'; +import { Layer, TextArea as TextAreaInput } from '@carbon/react'; import { useField } from 'formik'; -import { fieldRequiredErrCode, isEmpty } from '../../../validators/ohri-form-validator'; -import { isInlineView } from '../../../utils/ohri-form-helper'; +import { fieldRequiredErrCode, isEmpty } from '../../../validators/form-validator'; +import { isInlineView } from '../../../utils/form-helper'; import { isTrue } from '../../../utils/boolean-utils'; -import { OHRIFieldValueView } from '../../value/view/ohri-field-value-view.component'; -import { OHRIFormContext } from '../../../ohri-form-context'; -import { OHRIFormFieldProps } from '../../../api/types'; -import styles from './ohri-text-area.scss'; +import { FieldValueView } from '../../value/view/field-value-view.component'; +import { FormContext } from '../../../form-context'; +import { FormFieldProps } from '../../../types'; +import styles from './text-area.scss'; -const OHRITextArea: React.FC = ({ - question, - onChange, - handler, - previousValue: previousValueProp, -}) => { +const TextArea: React.FC = ({ question, onChange, handler, previousValue: previousValueProp, }) => { const [field, meta] = useField(question.id); - const { setFieldValue, encounterContext, layoutType, workspaceLayout } = React.useContext(OHRIFormContext); + const { setFieldValue, encounterContext, layoutType, workspaceLayout } = React.useContext(FormContext); const [previousValue, setPreviousValue] = useState(); const [errors, setErrors] = useState([]); const isFieldRequiredError = useMemo(() => errors[0]?.errCode == fieldRequiredErrCode, [errors]); @@ -56,7 +51,7 @@ const OHRITextArea: React.FC = ({ }, [encounterContext.sessionMode, question.readonly, question.inlineRendering, layoutType, workspaceLayout]); return encounterContext.sessionMode == 'view' || encounterContext.sessionMode == 'embedded-view' ? ( - = ({ [styles.boldedLabel]: !isFieldRequiredError, })}> -