Skip to content
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
2 changes: 1 addition & 1 deletion packages/esm-audit-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ for information about how to provide configuration files.
| ----------------------- | -------------------------------------------------- | -------------------------------------------------- |
| `patientSearchPageSize` | `10` | Patients per page of search results. |
| `encountersPageSize` | `10` | Encounters per page of a patient's encounter list. |
| `patientChartUrl` | `${openmrsSpaBase}/patient/${patientUuid}/chart` | Where the patient's name in the encounter audit links to. |
| `patientDashboardUrl` | `${openmrsBase}/pihcore/router/programDashboard.page?patientId=${patientUuid}` | Where the patient's name in the encounter audit links to. Points at the OpenMRS 2.x clinician dashboard, so it is a full page load. |
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,17 @@ function obsRowsFor(conceptName: string): Array<HTMLElement> {

describe('<EncounterAudit />', () => {
beforeEach(() => {
mockUseConfig.mockReturnValue({ patientChartUrl: '${openmrsSpaBase}/patient/${patientUuid}/chart' });
mockUseConfig.mockReturnValue({
patientDashboardUrl: '${openmrsBase}/pihcore/router/programDashboard.page?patientId=${patientUuid}',
});
mockRestApi();
});

it('summarises how the encounter was recorded', async () => {
renderEncounterAudit();

expect(await screen.findByText('CDI Klinik Ekstèn Jeneral')).toBeInTheDocument();
expect(screen.getByRole('link', { name: 'Y2AHXV - Dave TestPatient' })).toHaveAttribute(
'href',
'/openmrs/spa/patient/patient-1/chart',
);
expect(screen.getByText('Y2AHXV - Dave TestPatient')).toBeInTheDocument();
expect(screen.getByText('Y2AHXV')).toBeInTheDocument();
expect(screen.getByText('COVID19 Admission v1.0')).toBeInTheDocument();
expect(screen.getByText('Clinic or Hospital Visit')).toBeInTheDocument();
Expand Down Expand Up @@ -231,6 +230,17 @@ describe('<EncounterAudit />', () => {
expect(screen.getByText('Entered on the wrong patient')).toBeInTheDocument();
});

/**
* The OpenMRS 2.x clinician dashboard is outside this app, so this is a full page load rather
* than a route within the SPA.
*/
it("links the patient's name at the legacy clinician dashboard", async () => {
renderEncounterAudit();

const link = await screen.findByRole('link', { name: 'Y2AHXV - Dave TestPatient' });
expect(link).toHaveAttribute('href', '/openmrs/pihcore/router/programDashboard.page?patientId=patient-1');
});

it('walks back up to the patient the encounter belongs to', async () => {
const onBackToEncounters = renderEncounterAudit();
await screen.findByText('CDI Klinik Ekstèn Jeneral');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,16 @@ export default function EncounterAudit({ encounterUuid, onBackToEncounters }: En
);
}

/**
* Where the back button goes when the trail was entered by linking straight to an encounter, and
* what the patient's name links out to.
*/
const patientUuid = encounter.patient?.uuid;
const summaryRows: Array<SummaryRow> = [
{
label: t('patient', 'Patient'),
value: patientUuid ? (
<ConfigurableLink to={config.patientChartUrl} templateParams={{ patientUuid }}>
<ConfigurableLink to={config.patientDashboardUrl} templateParams={{ patientUuid }}>
{encounter.patient?.display}
</ConfigurableLink>
) : (
Expand Down
11 changes: 6 additions & 5 deletions packages/esm-audit-app/src/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ export const configSchema = {
_default: 10,
_validators: [validators.inRange(1, 100)],
},
patientChartUrl: {
patientDashboardUrl: {
_type: Type.String,
_description:
'The URL of the patient chart to link to from the audit trail. May contain the ' +
'template variables ${openmrsSpaBase}, ${openmrsBase} and ${patientUuid}.',
_default: '${openmrsSpaBase}/patient/${patientUuid}/chart',
"The dashboard the patient's name in the encounter audit links to. This is the OpenMRS 2.x " +
'clinician dashboard rather than a page in this app, so it is a full page load. May contain ' +
'the template variables ${openmrsBase}, ${openmrsSpaBase} and ${patientUuid}.',
_default: '${openmrsBase}/pihcore/router/programDashboard.page?patientId=${patientUuid}',
_validators: [validators.isUrlWithTemplateParameters(['patientUuid'])],
},
};

export interface Config {
patientSearchPageSize: number;
encountersPageSize: number;
patientChartUrl: string;
patientDashboardUrl: string;
}
Loading