Skip to content

Commit

Permalink
(fix): Follow-Up PR: Resolve 404 Error Caused by Conflicting UUIDs in…
Browse files Browse the repository at this point in the history
… Mortuary esm (#537)

* (fix) fixed 404 Error on the conflicting uuids

* (feat) updated the translations and discharged name

* (fix) fixed the PR suggestion
its-kios09 authored Jan 13, 2025
1 parent 49dde77 commit 380a213
Showing 11 changed files with 88 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -16,13 +16,10 @@ interface AvailableCompartmentProps {
}

const AvailableCompartment: React.FC<AvailableCompartmentProps> = ({ patientInfo, index }) => {
const patientUuid = patientInfo?.patient?.uuid;
const { t } = useTranslation();
const { isLoading, error, person } = usePerson(patientInfo.uuid);
const {
data: activeDeceased,
error: isActiveError,
isLoading: isActiveLoading,
} = useActiveMorgueVisit(patientInfo?.uuid);
const { isLoading, error, person } = usePerson(patientInfo?.person?.uuid);
const { data: activeDeceased, error: isActiveError, isLoading: isActiveLoading } = useActiveMorgueVisit(patientUuid);

const startVisitDate = activeDeceased?.[0]?.startDatetime;

@@ -72,7 +69,7 @@ const AvailableCompartment: React.FC<AvailableCompartmentProps> = ({ patientInfo
<span className={styles.viewDetails}>
<ConfigurableLink
className={styles.viewDetailsLink}
to={`\${openmrsSpaBase}/patient/${patientInfo.uuid}/chart/deceased-panel`}>
to={`\${openmrsSpaBase}/patient/${patientUuid}/chart/deceased-panel`}>
<View size={20} />
</ConfigurableLink>
</span>
6 changes: 3 additions & 3 deletions packages/esm-morgue-app/src/config-schema.ts
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ export const configSchema = {
morgueDepartmentServiceTypeUuid: {
_type: Type.String,
_description: ' UUID for morgue department service type',
_default: 'd7bd4cc0-90b1-4f22-90f2-ab7fde936727',
_default: '030bb7ab-9aea-454a-aa17-96abf17727c7',
},
insurancepaymentModeUuid: {
_type: Type.String,
@@ -71,7 +71,7 @@ export const configSchema = {
policeIDNumber: {
_type: Type.String,
_description: 'UUID for police id number concept',
_default: '8d488d02-d1d8-41a5-8219-61f4fc5dbeb0',
_default: '163084AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
},
encounterProviderRoleUuid: {
_type: Type.UUID,
@@ -81,7 +81,7 @@ export const configSchema = {
dischargeAreaUuid: {
_type: Type.String,
_description: 'UUID for discharge area concept',
_default: '89ebccf1-4cca-4195-aeff-3e75fdf976b4',
_default: '734f9526-84db-4002-9d98-58da580e501f',
},
adminUuid: {
_type: Type.String,
13 changes: 9 additions & 4 deletions packages/esm-morgue-app/src/hook/useMorgue.resource.ts
Original file line number Diff line number Diff line change
@@ -84,12 +84,17 @@ export const useDeceasedPatient = (searchTerm?: string) => {
try {
setIsLoadingStatus(true);
const status = await Promise.all(
paginatedData?.map((data) => {
return getMorguePatientStatus(data?.uuid, morgueVisitTypeUuid, morgueDischargeEncounterTypeUuid);
}),
paginatedData.map((data) =>
getMorguePatientStatus(data.person?.uuid, morgueVisitTypeUuid, morgueDischargeEncounterTypeUuid),
),
);

setDeceasedPatient(paginatedData?.map((patient, index) => ({ ...patient, status: status[index] })));
setDeceasedPatient(
paginatedData.map((patient, index) => ({
...patient,
status: status[index],
})),
);
} catch (error) {
setStatusError(error);
} finally {
42 changes: 25 additions & 17 deletions packages/esm-morgue-app/src/tables/discharge-queue.component.tsx
Original file line number Diff line number Diff line change
@@ -51,23 +51,31 @@ export const DischargedBodies: React.FC<DischargedProps> = ({ isLoading, decease

const dischargedDeceased = deceasedPatients?.filter((patient) => patient?.status === 'discharged') || [];

const rows = dischargedDeceased.map((patient) => ({
id: patient.uuid,
name: (
<ConfigurableLink
style={{ textDecoration: 'none', maxWidth: '50%' }}
to={patientChartUrl}
templateParams={{ patientUuid: patient?.person?.uuid }}>
{patient.person.display?.toUpperCase()}
</ConfigurableLink>
),
gender: patient.person.gender,
age: patient?.person?.age,
identifier: patient?.identifiers[0]?.identifier,
deathDate: new Date(patient.person.deathDate).toLocaleString(),
causeOfDeath: patient.person.causeOfDeath?.display,
status: <Tag type="magenta">{patient.status}</Tag>,
}));
const rows = dischargedDeceased.map((patient, index) => {
const openMrsId =
patient?.patient?.identifiers
?.find((id) => id.display.startsWith('OpenMRS ID'))
?.display.split('=')[1]
?.trim() || '--';

return {
id: `${patient?.patient?.uuid}`,
name: (
<ConfigurableLink
style={{ textDecoration: 'none', maxWidth: '50%' }}
to={patientChartUrl}
templateParams={{ patientUuid: patient?.person?.uuid }}>
{patient?.person?.person?.display?.toUpperCase()}
</ConfigurableLink>
),
gender: patient?.person?.person?.gender || '--',
age: patient?.person?.person?.age || '--',
identifier: openMrsId,
deathDate: formatDateTime(patient?.person?.person?.deathDate) || '--',
causeOfDeath: patient?.person?.person?.causeOfDeath?.display || '--',
status: <Tag type="magenta">{patient?.status || '--'}</Tag>,
};
});

return <GenericTable rows={rows} headers={genericTableHeader} title={dischargedInLine} />;
};
43 changes: 28 additions & 15 deletions packages/esm-morgue-app/src/tables/waiting-queue.component.tsx
Original file line number Diff line number Diff line change
@@ -50,16 +50,24 @@ export const WaitingQueue: React.FC<WaitingQueueProps> = ({ isLoading, deceasedP

const awaitingPatients = deceasedPatients?.filter((patient) => patient?.status === 'awaiting') || [];

const rows = awaitingPatients.map((patient) => ({
id: patient.uuid,
name: patient.person.display?.toUpperCase(),
gender: patient.person.gender,
age: patient?.person?.age,
identifier: patient?.identifiers[0]?.identifier,
deathDate: patient.person.deathDate ? new Date(patient.person.deathDate).toLocaleString() : t('nullDate', '--'),
causeOfDeath: patient.person.causeOfDeath?.display,
status: <Tag type="magenta">{patient.status}</Tag>,
}));
const rows = awaitingPatients.map((patient, index) => {
const openMrsId =
patient?.patient?.identifiers
?.find((id) => id.display.startsWith('OpenMRS ID'))
?.display.split('=')[1]
?.trim() || t('missingIdentifier', '--');

return {
id: `${patient?.patient?.uuid}`,
name: toUpperCase(patient?.person?.person?.display || '--'),
gender: patient?.person?.person?.gender || '--',
age: patient?.person?.person?.age || '--',
identifier: openMrsId,
deathDate: formatDateTime(patient?.person?.person?.deathDate) || '--',
causeOfDeath: patient?.person?.person?.causeOfDeath?.display || '--',
status: <Tag type="magenta">{patient?.status || '--'}</Tag>,
};
});

const handleAdmissionForm = (patientUuid: string) => {
launchWorkspace('patient-additional-info-form', {
@@ -68,11 +76,16 @@ export const WaitingQueue: React.FC<WaitingQueueProps> = ({ isLoading, deceasedP
});
};

const actionColumn = (row) => (
<OverflowMenu size="sm" flipped>
<OverflowMenuItem itemText={t('admit', 'Admit')} onClick={() => handleAdmissionForm(row.id)} />
</OverflowMenu>
);
const actionColumn = (row) => {
return (
<OverflowMenu size="sm" flipped>
<OverflowMenuItem
itemText={t('admitToMorgue', 'Admit to morgue')}
onClick={() => handleAdmissionForm(row.id)}
/>
</OverflowMenu>
);
};

return <GenericTable rows={rows} headers={genericTableHeader} actionColumn={actionColumn} title={waitingInLine} />;
};
4 changes: 4 additions & 0 deletions packages/esm-morgue-app/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -41,6 +41,10 @@ export interface DeceasedInfo {
uuid: string;
status?: string;
display: string;
patient: {
uuid: string;
display: string;
};
identifiers: Array<{
identifier: string;
uuid: string;
6 changes: 3 additions & 3 deletions packages/esm-morgue-app/translations/en.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"admissionForm": "Admission form",
"admit": "Admit",
"admitted": "Admitted Bodies",
"admitted": "Admitted",
"admitToMorgue": "Admit to morgue",
"allocation": "Allocation",
"allocations": "Allocation",
"causeOfDeath": "Cause of death: ",
"dischargeBodies": "Discharged bodies",
"discharged": "Discharged",
"empty": "Empty",
"errorMessage": "Error",
"missingIdentifier": "--",
"mortuary": "Mortuary",
"mortuaryManagement": "Mortuary management",
"noAdmittedBodies": "There are no admitted bodies",
"noDeceasedPersons": "There are no deceased persons on the waiting list",
"noResultFound": "Sorry, no results found",
"noWaitingList": "Waiting List",
"nullDate": "--",
"pullingCompartment": "Pulling compartments data.....",
"searchForADeceased": "Try to search again using the deceased patient's unique ID number",
"waitingInLine": "Waiting In Line",
6 changes: 3 additions & 3 deletions packages/esm-patient-clinical-view-app/src/config-schema.ts
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ export const configSchema = {
htsReferral: '9284828e-ce55-11e9-a32f-2a2ae2dbcce4',
clinicalEncounterFormUuid: 'e958f902-64df-4819-afd4-7fb061f59308',
peerCalendarOutreactForm: '7492cffe-5874-4144-a1e6-c9e455472a35',
autopsyFormUuid: '62d2c083-70af-4403-a5c4-6147507e1528',
autopsyFormUuid: '523c711f-f3ef-4723-b4dc-89efa572153f',
},
},
defaulterTracingEncounterUuid: {
@@ -253,12 +253,12 @@ export const configSchema = {
morgueVisitTypeUuid: {
_type: Type.String,
_description: ' UUID for morgue visit',
_default: '6307dbe2-f336-4c11-a393-50c2769f455a',
_default: '02b67c47-6071-4091-953d-ad21452e830c',
},
morgueDischargeEncounterUuid: {
_type: Type.String,
_description: ' UUID for morgue discharge encounter uuid',
_default: 'd618f40b-b5a3-4f17-81c8-2f04e2aad58e',
_default: '3d618f40b-b5a3-4f17-81c8-2f04e2aad58e',
},
inPatientForms: {
_type: Type.Array,
Original file line number Diff line number Diff line change
@@ -5,8 +5,7 @@ import { Visit } from '../../types';

export const useActiveMorgueVisit = (uuid: string) => {
const { morgueVisitTypeUuid } = useConfig<ConfigObject>();
const customRepresentation = `custom:(uuid,display,startDatetime,stopDatetime)`;
const url = `${restBaseUrl}/visit?v=${customRepresentation}&includeInactive=false&totalCount=true&visitType=${morgueVisitTypeUuid}&q=${uuid}`;
const url = `${restBaseUrl}/visit?v=full&includeInactive=false&totalCount=true&visitType=${morgueVisitTypeUuid}&q=${uuid}`;

const { data, error, isLoading } = useSWR<FetchResponse<{ results: Visit[] }>>(url, openmrsFetch);

Original file line number Diff line number Diff line change
@@ -22,6 +22,8 @@ const MortuarySummary: React.FC = () => {
const { person, isLoading } = usePerson(patientUuid);
const { activeVisit, isLoading: isActiveLoading } = useActiveMorgueVisit(patientUuid);
const startDate = activeVisit?.startDatetime;
const compartment = activeVisit?.encounters[0]?.location?.display;

if (isLoading || isActiveLoading) {
return (
<InlineLoading
@@ -55,7 +57,7 @@ const MortuarySummary: React.FC = () => {
</div>
<div className={styles.wrapMetrics}>
<span className={styles.metricLabel}>{t('compartment', 'Compartment')}</span>
<span className={styles.metricValue}>C1</span>
<span className={styles.metricValue}>{compartment}</span>
</div>
</div>
</div>
5 changes: 5 additions & 0 deletions packages/esm-patient-clinical-view-app/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -242,11 +242,16 @@ export interface Encounter {
uuid: string;
display: string;
encounterDatetime: string;
location: {
uuid: string;
display: string;
};
}

export interface Visit {
uuid: string;
display?: string;
startDatetime: string;
stopDatetime?: string;
encounters;
}

0 comments on commit 380a213

Please sign in to comment.