Skip to content

Commit

Permalink
(fix) allow for launching editing and discontinuing enrollments witho…
Browse files Browse the repository at this point in the history
…ut active visits (#272)

* (fix) allow for launching editting and dicontinuation without active visit

* (chore) add translation
  • Loading branch information
donaldkibet authored Jul 15, 2024
1 parent 1c97737 commit afe6d23
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import {
import styles from './program-enrollment.scss';
import isEmpty from 'lodash/isEmpty';
import dayjs from 'dayjs';
import { formatDate } from '@openmrs/esm-framework';
import { formatDate, useVisit } from '@openmrs/esm-framework';
import orderBy from 'lodash/orderBy';
import { mutate } from 'swr';
import { launchPatientWorkspace } from '@openmrs/esm-patient-common-lib';
import { getPatientUuidFromUrl, launchPatientWorkspace } from '@openmrs/esm-patient-common-lib';

export interface ProgramEnrollmentProps {
patientUuid: string;
Expand Down Expand Up @@ -66,6 +66,7 @@ const programDetailsMap = {

const ProgramEnrollment: React.FC<ProgramEnrollmentProps> = ({ enrollments = [], programName }) => {
const { t } = useTranslation();
const { currentVisit } = useVisit(getPatientUuidFromUrl());
const orderedEnrollments = orderBy(enrollments, 'dateEnrolled', 'desc');
const headers = useMemo(
() =>
Expand Down Expand Up @@ -101,6 +102,8 @@ const ProgramEnrollment: React.FC<ProgramEnrollmentProps> = ({ enrollments = [],
},
formInfo: {
encounterUuid: '',
visitTypeUuid: currentVisit?.visitType?.uuid ?? '',
visitUuid: currentVisit?.uuid ?? '',
formUuid: enrollment?.discontinuationFormUuid,
additionalProps:
{ enrollmentDetails: { dateEnrolled: new Date(enrollment.dateEnrolled), uuid: enrollment.enrollmentUuid } } ??
Expand All @@ -113,13 +116,18 @@ const ProgramEnrollment: React.FC<ProgramEnrollmentProps> = ({ enrollments = [],
launchPatientWorkspace('patient-form-entry-workspace', {
workspaceTitle: enrollment?.enrollmentFormName,
mutateForm: () => {
mutate((key) => true, undefined, {
revalidate: true,
});
mutate(
(key) =>
typeof key === 'string' && key.startsWith('/ws/rest/v1/kenyaemr/patientHistoricalEnrollment?patientUuid='),
undefined,
{ revalidate: true },
);
},
formInfo: {
encounterUuid: enrollment?.enrollmentEncounterUuid,
formUuid: enrollment?.enrollmentFormUuid,
visitTypeUuid: currentVisit?.visitType?.uuid ?? '',
visitUuid: currentVisit?.uuid ?? '',
additionalProps:
{ enrollmentDetails: { dateEnrolled: new Date(enrollment.dateEnrolled), uuid: enrollment.enrollmentUuid } } ??
{},
Expand Down
2 changes: 2 additions & 0 deletions packages/esm-pharmacy-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"contact": "Contact",
"countyDistrict": "County District",
"dateMapped": "Date Mapped",
"enroll": "Enroll new body",
"name": "NAME",
"noCommunityPharmacyToList": "No Community Pharmacies to list.",
"noPharmacyPatients": "No Pharmacy Patients to list.",
Expand All @@ -17,6 +18,7 @@
"pharmacies": "Phamacies",
"pharmacy": "Commity pharmacy",
"pharmacyPatients": "Pharmacy Patients",
"pharmacySummary": "Pharmacy Summary",
"pharmacyUsers": "Pharmacy Users",
"sex": "Sex",
"stateProvince": "State province",
Expand Down

0 comments on commit afe6d23

Please sign in to comment.