diff --git a/packages/esm-patient-chart-app/src/config-schema.ts b/packages/esm-patient-chart-app/src/config-schema.ts index e1d36fdb5d..2e69774f35 100644 --- a/packages/esm-patient-chart-app/src/config-schema.ts +++ b/packages/esm-patient-chart-app/src/config-schema.ts @@ -112,6 +112,12 @@ export const esmPatientChartSchema = { 'An array of concept UUIDs. If an observation has a concept UUID that matches any of the ones in this array, it will be hidden from the observations list in the Encounters summary table.', _default: [], }, + disableChangingVisitLocation: { + _type: Type.Boolean, + _description: + "Whether the visit location field in the Start Visit form should be view-only. If so, the visit location will always be set to the user's login location.", + _default: false, + }, }; export interface ChartConfig { @@ -133,6 +139,7 @@ export interface ChartConfig { alt: string; name: string; }; + viewOnlyVisitLocationField: boolean; } export const configSchema = { diff --git a/packages/esm-patient-chart-app/src/visit/visit-form/location-selection.component.tsx b/packages/esm-patient-chart-app/src/visit/visit-form/location-selection.component.tsx index 73855ae738..d5c845f3e1 100644 --- a/packages/esm-patient-chart-app/src/visit/visit-form/location-selection.component.tsx +++ b/packages/esm-patient-chart-app/src/visit/visit-form/location-selection.component.tsx @@ -1,20 +1,24 @@ import React, { useState } from 'react'; import styles from './visit-form.scss'; -import { Location, OpenmrsResource, useLayoutType, useSession } from '@openmrs/esm-framework'; -import { ComboBox, InlineNotification } from '@carbon/react'; +import { Location, OpenmrsResource, useConfig, useSession } from '@openmrs/esm-framework'; +import { ComboBox } from '@carbon/react'; import { useDefaultLoginLocation } from '../hooks/useDefaultLocation'; import { useTranslation } from 'react-i18next'; import { useLocations } from '../hooks/useLocations'; import isEmpty from 'lodash/isEmpty'; import { useFormContext, Controller } from 'react-hook-form'; import { VisitFormData } from './visit-form.component'; +import { ChartConfig } from '../../config-schema'; const LocationSelector = () => { const { t } = useTranslation(); + const session = useSession(); const [searchTerm, setSearchTerm] = useState(''); const selectedSessionLocation = useSession().sessionLocation; const { locations, isLoading: isLoadingLocations, error } = useLocations(searchTerm); const { defaultFacility, isLoading: loadingDefaultFacility } = useDefaultLoginLocation(); + const config = useConfig() as ChartConfig; + const viewOnlyVisitLocationField = config?.viewOnlyVisitLocationField; const locationsToShow: Array = !loadingDefaultFacility && !isEmpty(defaultFacility) ? [defaultFacility] @@ -34,24 +38,29 @@ const LocationSelector = () => {
{t('visitLocation', 'Visit Location')}
- ( - onChange(selectedItem)} - onBlur={onBlur} - itemToString={(loc: Location) => loc?.display} - onInputChange={(loc) => handleSearch(loc)} - /> - )} - /> + {!viewOnlyVisitLocationField ? ( + ( + onChange(selectedItem)} + onBlur={onBlur} + itemToString={(loc: Location) => loc?.display} + onInputChange={(loc) => handleSearch(loc)} + readOnly={viewOnlyVisitLocationField} + /> + )} + /> + ) : ( +

{session?.sessionLocation?.display}

+ )}
); diff --git a/packages/esm-patient-chart-app/src/visit/visit-form/visit-form.scss b/packages/esm-patient-chart-app/src/visit/visit-form/visit-form.scss index 3c6f558e55..3f1991cb8c 100644 --- a/packages/esm-patient-chart-app/src/visit/visit-form/visit-form.scss +++ b/packages/esm-patient-chart-app/src/visit/visit-form/visit-form.scss @@ -1,6 +1,7 @@ @use '@carbon/styles/scss/spacing'; @use '@carbon/styles/scss/type'; @import '~@openmrs/esm-styleguide/src/vars'; +@import '../../root.scss'; .container { margin: spacing.$spacing-05; @@ -81,6 +82,11 @@ margin-top: spacing.$spacing-04; } +.label { + @include type.type-style("label-01"); + color: $text-02; +} + :global(.omrs-breakpoint-lt-desktop) { .container { & section { @@ -99,4 +105,3 @@ } } } -