Skip to content

Commit 8efa490

Browse files
committed
close visit checkbox ui fix
1 parent a9f7fda commit 8efa490

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

src/config-schema.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,17 @@ export const configSchema = {
127127
'Enable or disable stock deduction during the dispensing process. Requires the stock management module to be installed and configured.',
128128
_default: false,
129129
},
130-
closeVisitOnDispense: {
130+
endVisitOnDispense: {
131131
enabled: {
132132
_type: Type.Boolean,
133133
_description:
134-
'Enables or disables the automatic closure of the current visit upon medication dispensing. When set to true, the system will attempt to close the visit after a successful medication dispense, subject to the conditions specified in the "visitTypes" config.',
134+
'Enables or disables the ending of the current visit upon medication dispensing. When set to true, the system will attempt to end the visit after a successful medication dispense, subject to the conditions specified in the "visitTypes" config.',
135135
_default: false,
136136
},
137137
visitTypesUuids: {
138138
_type: Type.Array,
139139
_description:
140-
'Specifies a list of visit type UUIDs that are eligible for automatic closure upon medication dispensing. If enabled, only visits of these types will be closed automatically. An empty array means no visit types are eligible for automatic closure. This setting is only relevant when "enabled" is set to true.',
140+
'Specifies a list of visit type UUIDs that are eligible for ending upon medication dispensing. If enabled, only visits of these types will be closed. An empty array means no visit types are eligible for closure. This setting is only relevant when "enabled" is set to true.',
141141
_default: [],
142142
},
143143
},
@@ -183,7 +183,7 @@ export interface PharmacyConfig {
183183
};
184184
};
185185
enableStockDispense: boolean;
186-
closeVisitOnDispense?: {
186+
endVisitOnDispense?: {
187187
enabled: boolean;
188188
visitTypesUuids: Array<string>;
189189
};

src/forms/dispense-form-handler.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ class StockDispenseHandler extends Handler {
9696
}
9797
}
9898

99-
class CloseCurrentVisitHandler extends Handler {
99+
class EndCurrentVisitHandler extends Handler {
100100
async handle(request) {
101101
const { currentVisit, abortController, closeVisitOnDispense, response, t, config } = request;
102102

103103
try {
104104
const visitTypes = await getVisitTypes().toPromise();
105105
const shouldCloseVisit =
106-
shouldCloseVisitOnDispense(currentVisit, visitTypes, response.status, config) && closeVisitOnDispense;
106+
shouldEndVisitOnDispense(currentVisit, visitTypes, response.status, config) && closeVisitOnDispense;
107107

108108
if (shouldCloseVisit) {
109109
const updateResponse = await updateVisit(
@@ -170,7 +170,7 @@ class FinalResponseHandler extends Handler {
170170
const setupChain = () => {
171171
const medicationDispenseHandler = new MedicationDispenseHandler();
172172
const stockDispenseHandler = new StockDispenseHandler();
173-
const closeActiveVisitHandler = new CloseCurrentVisitHandler();
173+
const closeActiveVisitHandler = new EndCurrentVisitHandler();
174174
const finalResponseHandler = new FinalResponseHandler();
175175

176176
medicationDispenseHandler
@@ -195,7 +195,7 @@ export const executeMedicationDispenseChain = (params) => {
195195
* @param {object} config - The configuration object.
196196
* @returns {boolean} - Returns true if the current visit should be closed, false otherwise.
197197
*/
198-
function shouldCloseVisitOnDispense(currentVisit, visitTypes, status, config): boolean {
198+
function shouldEndVisitOnDispense(currentVisit, visitTypes, status, config): boolean {
199199
if (!currentVisit || !visitTypes) return false;
200200

201201
const hasAllowedVisitType = visitTypes.some((vt) => vt.uuid === currentVisit.visitType.uuid);

src/forms/dispense-form.component.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ const DispenseForm: React.FC<DispenseFormProps> = ({
125125
useEffect(checkIsValid, [medicationDispensePayload, quantityRemaining, inventoryItem]);
126126

127127
const isButtonDisabled = (config.enableStockDispense ? !inventoryItem : false) || !isValid || isSubmitting;
128-
const shouldShowCloseVisitCheckbox = useMemo(() => {
128+
const shouldEndCurrentVisitCheckbox = useMemo(() => {
129129
return (
130-
config.closeVisitOnDispense &&
130+
config.endVisitOnDispense &&
131131
currentVisit &&
132-
config.closeVisitOnDispense.visitTypesUuids.includes(currentVisit.visitType.uuid)
132+
config.endVisitOnDispense.visitTypesUuids.includes(currentVisit.visitType.uuid)
133133
);
134-
}, [config.closeVisitOnDispense, currentVisit]);
134+
}, [config.endVisitOnDispense, currentVisit]);
135135

136136
const bannerState = useMemo(() => {
137137
if (patient) {
@@ -178,7 +178,7 @@ const DispenseForm: React.FC<DispenseFormProps> = ({
178178
updateInventoryItem={setInventoryItem}
179179
/>
180180
)}
181-
{shouldShowCloseVisitCheckbox && (
181+
{shouldEndCurrentVisitCheckbox && (
182182
<Layer>
183183
<Checkbox
184184
className={styles.closeVisitCheckBox}

src/forms/forms.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@use '@carbon/styles/scss/spacing';
22
@use '@carbon/styles/scss/type';
3-
@import '~@openmrs/esm-styleguide/src/vars';
3+
@use '@carbon/colors';
4+
@use '~@openmrs/esm-styleguide/src/vars' as *;
45

56
// TO DO Move this styles to style - guide
67
// https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-styleguide/src/_vars.scss
@@ -156,5 +157,7 @@ $color-blue-30: #a6c8ff;
156157
.closeVisitCheckBox {
157158
& label {
158159
@include type.type-style('label-01');
160+
margin-top: spacing.$spacing-05;
161+
color: colors.$gray-70;
159162
}
160163
}

0 commit comments

Comments
 (0)