Skip to content

Commit

Permalink
(feat) O3-4200 Make visit form usable in other apps (#2134)
Browse files Browse the repository at this point in the history
* (feat) O3-4200 Make visit form usable in other apps

* rename slot names

* minor reword
  • Loading branch information
chibongho authored Dec 7, 2024
1 parent 14c1f1f commit 6382382
Show file tree
Hide file tree
Showing 18 changed files with 389 additions and 433 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ const StartVisitOverflowMenuItem: React.FC<StartVisitOverflowMenuItemProps> = ({
const { currentVisit } = useVisit(patient?.id);
const isDeceased = Boolean(patient?.deceasedDateTime);

const handleLaunchModal = useCallback(() => launchPatientWorkspace('start-visit-workspace-form'), []);
const handleLaunchModal = useCallback(() => launchPatientWorkspace('start-visit-workspace-form', {
openedFrom: "patient-chart-start-visit",
}), []);

return (
!currentVisit &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ describe('StartVisitOverflowMenuItem', () => {

await user.click(startVisitButton);
expect(launchPatientWorkspace).toHaveBeenCalledTimes(1);
expect(launchPatientWorkspace).toHaveBeenCalledWith('start-visit-workspace-form');
expect(launchPatientWorkspace).toHaveBeenCalledWith('start-visit-workspace-form', {
openedFrom: 'patient-chart-start-visit',
});
});

it('should not show start visit button for a deceased patient', () => {
Expand Down
10 changes: 2 additions & 8 deletions packages/esm-patient-chart-app/src/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,6 @@ export const esmPatientChartSchema = {
_default: '159947AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
_type: Type.ConceptUuid,
},
visitQueueNumberAttributeUuid: {
_type: Type.ConceptUuid,
_description: 'The UUID of the visit attribute that contains the visit queue number.',
_default: 'c61ce16f-272a-41e7-9924-4c555d0932c5',
},
visitTypeResourceUrl: {
_type: Type.String,
_default: '/etl-latest/etl/patient/',
Expand All @@ -156,9 +151,8 @@ export interface ChartConfig {
showAllEncountersTab: boolean;
showExtraVisitAttributesSlot: boolean;
showRecommendedVisitTypeTab: boolean;
showServiceQueueFields: boolean;
showUpcomingAppointments: boolean;
visitQueueNumberAttributeUuid: string;
showServiceQueueFields: boolean; // used by extension from esm-service-queues-app
showUpcomingAppointments: boolean; // used by extension from esm-appointments-app
visitTypeResourceUrl: string;
visitAttributeTypes: Array<{
displayInThePatientBanner: boolean;
Expand Down
1 change: 1 addition & 0 deletions packages/esm-patient-chart-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
},
{
"name": "start-visit-workspace-form",
"slot": "start-visit-workspace-form-slot",
"component": "startVisitForm",
"meta": {
"title": "Start a visit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const PatientInfo: React.FC<PatientInfoProps> = ({ patient }) => {
};

function launchStartVisitForm() {
launchPatientWorkspace('start-visit-workspace-form');
launchPatientWorkspace('start-visit-workspace-form', {openedFrom: "patient-chart-start-visit"});
}

const VisitHeader: React.FC<{ patient: fhir.Patient }> = ({ patient }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ describe('Visit header', () => {
expect(startVisitButton).toBeInTheDocument();

await user.click(startVisitButton);
expect(launchPatientWorkspace).toHaveBeenCalledWith('start-visit-workspace-form');
expect(launchPatientWorkspace).toHaveBeenCalledWith('start-visit-workspace-form', {
openedFrom: 'patient-chart-start-visit',
});
});

test('should display a truncated name when the patient name is very long', async () => {
Expand Down

This file was deleted.

56 changes: 0 additions & 56 deletions packages/esm-patient-chart-app/src/visit/hooks/useServiceQueue.tsx
Original file line number Diff line number Diff line change
@@ -1,61 +1,5 @@
import { openmrsFetch, restBaseUrl, toDateObjectStrict, toOmrsIsoString } from '@openmrs/esm-framework';

export async function saveQueueEntry(
visitUuid: string,
queueUuid: string,
patientUuid: string,
priority: string,
status: string,
sortWeight: number,
locationUuid: string,
visitQueueNumberAttributeUuid: string,
abortController?: AbortController,
) {
await Promise.all([
generateVisitQueueNumber(locationUuid, visitUuid, queueUuid, visitQueueNumberAttributeUuid, abortController),
]);

return openmrsFetch(`${restBaseUrl}/visit-queue-entry`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: {
visit: { uuid: visitUuid },
queueEntry: {
status: {
uuid: status,
},
priority: {
uuid: priority,
},
queue: {
uuid: queueUuid,
},
patient: {
uuid: patientUuid,
},
startedAt: toDateObjectStrict(toOmrsIsoString(new Date())),
sortWeight: sortWeight,
},
},
signal: abortController?.signal,
});
}

export async function generateVisitQueueNumber(
location: string,
visitUuid: string,
queueUuid: string,
visitQueueNumberAttributeUuid: string,
abortController?: AbortController,
) {
await openmrsFetch(
`${restBaseUrl}/queue-entry-number?location=${location}&queue=${queueUuid}&visit=${visitUuid}&visitAttributeType=${visitQueueNumberAttributeUuid}`,
{ signal: abortController?.signal },
);
}

export function removeQueuedPatient(
queueUuid: string,
queueEntryUuid: string,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { Button } from '@carbon/react';
import { launchPatientChartWithWorkspaceOpen } from '@openmrs/esm-patient-common-lib';
import { navigate } from '@openmrs/esm-framework';
import React, { useCallback } from 'react';
import { useTranslation } from 'react-i18next';

const StartVisitButton = ({ patientUuid }) => {
const { t } = useTranslation();
Expand All @@ -11,6 +10,9 @@ const StartVisitButton = ({ patientUuid }) => {
launchPatientChartWithWorkspaceOpen({
patientUuid,
workspaceName: 'start-visit-workspace-form',
additionalProps: {
openedFrom: 'patient-chart-start-visit'
}
});
}, [patientUuid]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const EditVisitDetailsActionItem: React.FC<EditVisitDetailsActionItemProps> = ({
launchPatientWorkspace('start-visit-workspace-form', {
workspaceTitle: t('editVisitDetails', 'Edit visit details'),
visitToEdit: visit,
openedFrom: 'patient-chart-edit-visit'
});
};

Expand Down
Loading

0 comments on commit 6382382

Please sign in to comment.