From 59fac63542bb154a6d20aa47324f33a2877b926e Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Fri, 6 Oct 2023 16:27:35 +0530 Subject: [PATCH 1/5] Allow view only field for visit location in the start visit form --- packages/esm-patient-chart-app/src/config-schema.ts | 6 ++++++ .../src/visit/visit-form/location-selection.component.tsx | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/esm-patient-chart-app/src/config-schema.ts b/packages/esm-patient-chart-app/src/config-schema.ts index e1d36fdb5d..cfae287943 100644 --- a/packages/esm-patient-chart-app/src/config-schema.ts +++ b/packages/esm-patient-chart-app/src/config-schema.ts @@ -112,6 +112,11 @@ 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: [], }, + viewOnlyVisitLocationField: { + _type: Type.Boolean, + _description: 'Whether the visit location field in the start visit form should be view only', + _default: false, + }, }; export interface ChartConfig { @@ -133,6 +138,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..c89d444f3a 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,6 +1,6 @@ import React, { useState } from 'react'; import styles from './visit-form.scss'; -import { Location, OpenmrsResource, useLayoutType, useSession } from '@openmrs/esm-framework'; +import { Location, OpenmrsResource, useConfig, useSession } from '@openmrs/esm-framework'; import { ComboBox, InlineNotification } from '@carbon/react'; import { useDefaultLoginLocation } from '../hooks/useDefaultLocation'; import { useTranslation } from 'react-i18next'; @@ -8,6 +8,7 @@ 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(); @@ -15,6 +16,8 @@ const LocationSelector = () => { 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] @@ -49,6 +52,7 @@ const LocationSelector = () => { onBlur={onBlur} itemToString={(loc: Location) => loc?.display} onInputChange={(loc) => handleSearch(loc)} + disabled={viewOnlyVisitLocationField} /> )} /> From 537cb3f9065dd62de9fcf13a175be627b948071d Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Wed, 11 Oct 2023 20:00:37 +0530 Subject: [PATCH 2/5] Show location name when in view only mode --- .../location-selection.component.tsx | 49 +++++++++++-------- .../src/visit/visit-form/visit-form.scss | 7 ++- 2 files changed, 34 insertions(+), 22 deletions(-) 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 c89d444f3a..072e181b07 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,7 +1,7 @@ import React, { useState } from 'react'; import styles from './visit-form.scss'; import { Location, OpenmrsResource, useConfig, useSession } from '@openmrs/esm-framework'; -import { ComboBox, InlineNotification } from '@carbon/react'; +import { ComboBox } from '@carbon/react'; import { useDefaultLoginLocation } from '../hooks/useDefaultLocation'; import { useTranslation } from 'react-i18next'; import { useLocations } from '../hooks/useLocations'; @@ -12,6 +12,9 @@ import { ChartConfig } from '../../config-schema'; const LocationSelector = () => { const { t } = useTranslation(); + const { + sessionLocation: { display: sessionLocationDisplay }, + } = useSession(); const [searchTerm, setSearchTerm] = useState(''); const selectedSessionLocation = useSession().sessionLocation; const { locations, isLoading: isLoadingLocations, error } = useLocations(searchTerm); @@ -27,7 +30,7 @@ const LocationSelector = () => { ? [selectedSessionLocation] : []; - const { control } = useFormContext(); + const { control, getValues } = useFormContext(); const handleSearch = (searchString) => { setSearchTerm(searchString); @@ -37,25 +40,29 @@ const LocationSelector = () => {
{t('visitLocation', 'Visit Location')}
- ( - onChange(selectedItem)} - onBlur={onBlur} - itemToString={(loc: Location) => loc?.display} - onInputChange={(loc) => handleSearch(loc)} - disabled={viewOnlyVisitLocationField} - /> - )} - /> + {!viewOnlyVisitLocationField ? ( + ( + onChange(selectedItem)} + onBlur={onBlur} + itemToString={(loc: Location) => loc?.display} + onInputChange={(loc) => handleSearch(loc)} + disabled={viewOnlyVisitLocationField} + /> + )} + /> + ) : ( +

{sessionLocationDisplay}

+ )}
); 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 @@ } } } - From 7162b2d5020f38707d34aa0fd8f033287f49b546 Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Wed, 11 Oct 2023 20:48:00 +0530 Subject: [PATCH 3/5] Fixed failing test --- .../src/visit/visit-form/location-selection.component.tsx | 8 +++----- packages/esm-patient-flags-app/translations/es.json | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-) 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 072e181b07..86f28e4d25 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 @@ -12,9 +12,7 @@ import { ChartConfig } from '../../config-schema'; const LocationSelector = () => { const { t } = useTranslation(); - const { - sessionLocation: { display: sessionLocationDisplay }, - } = useSession(); + const session = useSession(); const [searchTerm, setSearchTerm] = useState(''); const selectedSessionLocation = useSession().sessionLocation; const { locations, isLoading: isLoadingLocations, error } = useLocations(searchTerm); @@ -30,7 +28,7 @@ const LocationSelector = () => { ? [selectedSessionLocation] : []; - const { control, getValues } = useFormContext(); + const { control } = useFormContext(); const handleSearch = (searchString) => { setSearchTerm(searchString); @@ -61,7 +59,7 @@ const LocationSelector = () => { )} /> ) : ( -

{sessionLocationDisplay}

+

{session?.sessionLocation?.display}

)} diff --git a/packages/esm-patient-flags-app/translations/es.json b/packages/esm-patient-flags-app/translations/es.json index b491dc0a7e..66992ab93b 100644 --- a/packages/esm-patient-flags-app/translations/es.json +++ b/packages/esm-patient-flags-app/translations/es.json @@ -10,6 +10,7 @@ "editFlags": "Editar banderas", "enabledFlag": "Bandera activada", "enablingFlag": "Activando bandera...", + "flagCountfalsemany": "{count} risk flag{plural}", "flagCountfalseone": "{count} bandera de riesgo", "flagCountfalseother": "{count} banderas de riesgo", "flagDisabled": "Bandera desactivada", @@ -19,6 +20,7 @@ "flagEnabledSuccessfully": "Bandera activada con éxito", "flagEnableError": "Error al activar la bandera", "loading": "Cargando", + "matchesForSearchTermfalsemany": "{count} flag{plural}", "matchesForSearchTermfalseone": "{count} bandera", "matchesForSearchTermfalseother": "{count} banderas", "noFlagsFound": "Lo siento, no se encontraron banderas que coincidan con su búsqueda", From 7f8fc6cf514dc87c42451c002b9f5468577a2522 Mon Sep 17 00:00:00 2001 From: Brandon Istenes Date: Thu, 19 Oct 2023 21:59:51 -0400 Subject: [PATCH 4/5] Apply suggestions from code review --- packages/esm-patient-chart-app/src/config-schema.ts | 4 ++-- .../src/visit/visit-form/location-selection.component.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/esm-patient-chart-app/src/config-schema.ts b/packages/esm-patient-chart-app/src/config-schema.ts index cfae287943..0135ff420e 100644 --- a/packages/esm-patient-chart-app/src/config-schema.ts +++ b/packages/esm-patient-chart-app/src/config-schema.ts @@ -112,9 +112,9 @@ 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: [], }, - viewOnlyVisitLocationField: { + disableChangingVisitLocation: { _type: Type.Boolean, - _description: 'Whether the visit location field in the start visit form should be view only', + _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, }, }; 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 86f28e4d25..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 @@ -54,7 +54,7 @@ const LocationSelector = () => { onBlur={onBlur} itemToString={(loc: Location) => loc?.display} onInputChange={(loc) => handleSearch(loc)} - disabled={viewOnlyVisitLocationField} + readOnly={viewOnlyVisitLocationField} /> )} /> From 6ad1fdc5139da978b01ed0d833eecfa5e4ad5336 Mon Sep 17 00:00:00 2001 From: Brandon Istenes Date: Thu, 19 Oct 2023 22:16:00 -0400 Subject: [PATCH 5/5] Fixup --- packages/esm-patient-chart-app/src/config-schema.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/esm-patient-chart-app/src/config-schema.ts b/packages/esm-patient-chart-app/src/config-schema.ts index 0135ff420e..2e69774f35 100644 --- a/packages/esm-patient-chart-app/src/config-schema.ts +++ b/packages/esm-patient-chart-app/src/config-schema.ts @@ -114,7 +114,8 @@ export const esmPatientChartSchema = { }, 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.', + _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, }, };