Skip to content

Commit

Permalink
Fix/service queue error
Browse files Browse the repository at this point in the history
Fix/service queue error
  • Loading branch information
Michaelndula authored Dec 12, 2024
2 parents b144e5e + 46b4802 commit b4afa6a
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 104 deletions.
4 changes: 2 additions & 2 deletions packages/esm-service-queues-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ehospital/esm-service-queues-app",
"version": "1.0.1",
"version": "1.0.2",
"description": "Outpatient front-end module for the OpenMRS SPA",
"browser": "dist/sjthc-esm-service-queues-app.js",
"main": "src/index.ts",
Expand Down Expand Up @@ -54,5 +54,5 @@
"devDependencies": {
"webpack": "^5.74.0"
},
"gitHead": "b6304f1acad784ecdf3f39838e50f62ece78f140"
"gitHead": "b97c995097838922bedd0f3074f04bbc93fb0179"
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,58 +116,46 @@ const ScheduledVisitsForVisitType: React.FC<{
const abortController = new AbortController();

saveVisit(payload, abortController)
.pipe(first())
.subscribe(
(response) => {
if (response.status === 201) {
addQueueEntry(
response.data.uuid,
patientId,
priority,
defaultStatus,
service,
appointment,
selectedQueueLocation,
visitQueueNumberAttributeUuid,
).then(
({ status }) => {
if (status === 201) {
showSnackbar({
kind: 'success',
title: t('startAVisit', 'Start a visit'),
subtitle: t(
'startVisitQueueSuccessfully',
'Patient has been added to active visits list and queue.',
`${hours} : ${minutes}`,
),
});
closeWorkspace();
setIsSubmitting(false);
mutateQueueEntries();
}
},
(error) => {
showSnackbar({
title: t('queueEntryError', 'Error adding patient to the queue'),
kind: 'error',
isLowContrast: false,
subtitle: error?.message,
});
setIsSubmitting(false);
},
);
}
},
(error) => {
showSnackbar({
title: t('startVisitError', 'Error starting visit'),
kind: 'error',
isLowContrast: false,
subtitle: error?.message,
});
setIsSubmitting(false);
},
);
.then((response) => {
if (response.status === 201) {
return addQueueEntry(
response.data.uuid,
patientId,
priority,
defaultStatus,
service,
appointment,
selectedQueueLocation,
visitQueueNumberAttributeUuid,
);
} else {
throw new Error(t('saveVisitFailed', 'Failed to save the visit.'));
}
})
.then(({ status }) => {
if (status === 201) {
showSnackbar({
kind: 'success',
title: t('startAVisit', 'Start a visit'),
subtitle: t(
'startVisitQueueSuccessfully',
'Patient has been added to active visits list and queue.',
`${hours} : ${minutes}`,
),
});
closeWorkspace();
mutateQueueEntries();
}
})
.catch((error) => {
showSnackbar({
title: t('queueEntryError', 'Error adding patient to the queue'),
kind: 'error',
isLowContrast: false,
subtitle: error.message,
});
})
.finally(() => setIsSubmitting(false));
}
},
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,56 +123,54 @@ const VisitForm: React.FC<VisitFormProps> = ({ patientUuid, toggleSearchType, cl
const abortController = new AbortController();

saveVisit(payload, abortController)
.pipe(first())
.subscribe(
(response) => {
if (response.status === 201) {
// add new queue entry if visit created successfully
addQueueEntry(
response.data.uuid,
serviceUuid,
patientUuid,
priority,
status,
sortWeight,
queueLocation,
visitQueueNumberAttributeUuid,
).then(
({ status, data }) => {
if (status === 201) {
showSnackbar({
kind: 'success',
isLowContrast: true,
title: t('startAVisit', 'Start a visit'),
subtitle: t(
'startVisitQueueSuccessfully',
'Patient has been added to active visits list and queue.',
`${hours} : ${minutes}`,
),
});
closePanel();
emitRefetchQueuesEvent(data?.uuid)
}
},
(error) => {
showSnackbar({
title: t('queueEntryError', 'Error adding patient to the queue'),
kind: 'error',
subtitle: error?.message,
});
},
);
}
},
(error) => {
showSnackbar({
title: t('startVisitError', 'Error starting visit'),
kind: 'error',
subtitle: error?.message,
});
},
);
},
.then((response) => {
if (response.status === 201) {
// add new queue entry if visit created successfully
addQueueEntry(
response.data.uuid,
serviceUuid,
patientUuid,
priority,
status,
sortWeight,
queueLocation,
visitQueueNumberAttributeUuid,
).then(
({ status, data }) => {
if (status === 201) {
showSnackbar({
kind: 'success',
isLowContrast: true,
title: t('startAVisit', 'Start a visit'),
subtitle: t(
'startVisitQueueSuccessfully',
'Patient has been added to active visits list and queue.',
`${hours} : ${minutes}`,
),
});
closePanel();
emitRefetchQueuesEvent(data?.uuid);
}
},
(error) => {
showSnackbar({
title: t('queueEntryError', 'Error adding patient to the queue'),
kind: 'error',
subtitle: error?.message,
});
},
);
}
})
.catch((error) => {
showSnackbar({
title: t('startVisitError', 'Error starting visit'),
kind: 'error',
subtitle: error?.message,
});
})
.finally(() => setIsSubmitting(false));
},
[
closePanel,
patientUuid,
Expand Down

0 comments on commit b4afa6a

Please sign in to comment.