Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) O3-3375: Align visit form queue fields to work in visit start form on patient chart #1860

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,19 @@ export async function generateVisitQueueNumber(
);
}

export function removeQueuedPatient(queueUuid: string, queueEntryUuid: string, abortController: AbortController) {
export function removeQueuedPatient(
queueUuid: string,
queueEntryUuid: string,
abortController: AbortController,
endedAt?: Date,
) {
return openmrsFetch(`${restBaseUrl}/queue/${queueUuid}/entry/${queueEntryUuid}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: {
endedAt: toDateObjectStrict(toOmrsIsoString(new Date())),
endedAt: toDateObjectStrict(toOmrsIsoString(endedAt) ?? toOmrsIsoString(new Date())),
},
signal: abortController.signal,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ const StartVisitForm: React.FC<StartVisitFormProps> = ({
const { mutate: mutateQueueEntry } = useVisitQueueEntry(patientUuid, visitUuid);
const { visitAttributeTypes } = useVisitAttributeTypes();
const [extraVisitInfo, setExtraVisitInfo] = useState(null);
const [{ service, priority, status, sortWeight, queueLocation }, setVisitFormFields] = useState({
service: null,
priority: null,
status: null,
sortWeight: null,
queueLocation: null,
});

const displayVisitStopDateTimeFields = useMemo(
() => visitToEdit?.stopDatetime || showVisitEndDateTimeFields,
Expand Down Expand Up @@ -459,15 +466,10 @@ const StartVisitForm: React.FC<StartVisitFormProps> = ({
if (config.showServiceQueueFields) {
// retrieve values from the queue extension
setVisitUuid(response.data.uuid);
const queueLocation = event.target['queueLocation']?.value;
const serviceUuid = event.target['service']?.value;
const priority = event.target['priority']?.value;
const status = event.target['status']?.value;
const sortWeight = event.target['sortWeight']?.value;

saveQueueEntry(
response.data.uuid,
serviceUuid,
service,
patientUuid,
priority,
status,
Expand Down Expand Up @@ -622,6 +624,11 @@ const StartVisitForm: React.FC<StartVisitFormProps> = ({
mutateQueueEntry,
mutateVisits,
patientUuid,
priority,
queueLocation,
service,
sortWeight,
status,
t,
upcomingAppointment,
validateVisitStartStopDatetime,
Expand Down Expand Up @@ -804,7 +811,7 @@ const StartVisitForm: React.FC<StartVisitFormProps> = ({
<section>
<div className={styles.sectionTitle}></div>
<div className={styles.sectionField}>
<ExtensionSlot name="add-queue-entry-slot" />
<ExtensionSlot name="visit-form-queue-slot" state={{ setFormFields: setVisitFormFields }} />
</div>
</section>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ const EndVisitDialog: React.FC<EndVisitDialogProps> = ({ patientUuid, closeModal
(response) => {
if (response.status === 200) {
if (queueEntry) {
removeQueuedPatient(queueEntry.queue.uuid, queueEntry.queueEntryUuid, abortController);
removeQueuedPatient(
queueEntry.queue.uuid,
queueEntry.queueEntryUuid,
abortController,
response?.data.stopDatetime,
);
}
mutate();
closeModal();
Expand Down
Loading