@act-registry/esm-act-app 1.0.1-pre.516 → 1.0.1-pre.521

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/1804.js +1 -1
  2. package/dist/1804.js.map +1 -1
  3. package/dist/2143.js +1 -1
  4. package/dist/2143.js.map +1 -1
  5. package/dist/2325.js +1 -1
  6. package/dist/2325.js.map +1 -1
  7. package/dist/2744.js +1 -1
  8. package/dist/2744.js.map +1 -1
  9. package/dist/2749.js +1 -1
  10. package/dist/2749.js.map +1 -1
  11. package/dist/4376.js +1 -1
  12. package/dist/4376.js.map +1 -1
  13. package/dist/5117.js +1 -1
  14. package/dist/5117.js.map +1 -1
  15. package/dist/5174.js +1 -1
  16. package/dist/5174.js.map +1 -1
  17. package/dist/7909.js +1 -1
  18. package/dist/7909.js.map +1 -1
  19. package/dist/8759.js +1 -1
  20. package/dist/8759.js.map +1 -1
  21. package/dist/9523.js +1 -1
  22. package/dist/9523.js.map +1 -1
  23. package/dist/act-registry-esm-act-app.js +1 -1
  24. package/dist/routes.json +1 -1
  25. package/package.json +1 -1
  26. package/src/cardiac-tests/cardiac-test-form-entry.test.ts +15 -0
  27. package/src/clinical-flags/clinical-flags.component.tsx +1 -1
  28. package/src/clinical-flags/clinical-flags.test.tsx +1 -1
  29. package/src/config-schema.ts +1 -1
  30. package/src/consultations/chart-pages.test.tsx +7 -6
  31. package/src/consultations/consultation-card.component.tsx +6 -9
  32. package/src/consultations/patient-details.resource.ts +46 -11
  33. package/src/consultations/repeated-lists.component.tsx +10 -6
  34. package/src/consultations/repeated-lists.test.tsx +24 -15
  35. package/src/routes.json +11 -0
  36. package/src/screen-positive/screen-positive-diagnosis.test.tsx +9 -43
  37. package/src/screen-positive/screen-positive.component.tsx +10 -63
  38. package/src/screen-positive/screen-positive.test.tsx +7 -22
  39. package/translations/en.json +0 -4
@@ -103,7 +103,7 @@ function serve({
103
103
  if (url.includes(`encounterType=${config.inrReviews.encounterType}`)) {
104
104
  return { data: { results: inr, totalCount: inr.length } };
105
105
  }
106
- if (url.includes(`encounterType=${diagnosisConcepts.encounterType}`)) {
106
+ if (url.includes(`encounterType=${diagnosisConcepts.encounterTypes.patientInformation}`)) {
107
107
  return { data: { results: patientInformation, totalCount: patientInformation.length } };
108
108
  }
109
109
  if (url.includes('encounterType=')) {
@@ -250,7 +250,7 @@ describe('chart pages by role', () => {
250
250
  expect(screen.queryByRole('button', { name: 'Edit last consultation' })).not.toBeInTheDocument();
251
251
  });
252
252
 
253
- it("shows the diagnosis with Update diagnosis, which opens the patient's Patient Information", async () => {
253
+ it('shows the diagnosis, from a Patient Information too, with Update diagnosis, which edits the last consultation', async () => {
254
254
  serve({
255
255
  consultations: [consultation('new', '2026-04-01')],
256
256
  patientInformation: [
@@ -273,14 +273,15 @@ describe('chart pages by role', () => {
273
273
  'Rheumatic Heart Disease/Rheumatic Fever (RHD B)',
274
274
  );
275
275
  await userEvent.click(await screen.findByRole('button', { name: /Update diagnosis/ }));
276
- expect(openForm).toHaveBeenCalledWith(config.patientInformationForm);
276
+ expect(openForm).toHaveBeenCalledWith(config.consultations.form, undefined, 'new');
277
277
  expect(useOpenFormInVisit).toHaveBeenCalledWith('winnie');
278
278
  });
279
279
 
280
- it('offers Record diagnosis when there is none, and nothing to a user who may not record Patient Information', async () => {
281
- serve({ consultations: [consultation('new', '2026-04-01')] });
280
+ it('offers Record diagnosis when there is none, which starts a consultation, and nothing to a user who may not record one', async () => {
281
+ serve();
282
282
  const { unmount } = renderIn(<ConsultationCard patientUuid="winnie" />);
283
- expect(await screen.findByRole('button', { name: /Record diagnosis/ })).toBeInTheDocument();
283
+ await userEvent.click(await screen.findByRole('button', { name: /Record diagnosis/ }));
284
+ expect(openForm).toHaveBeenCalledWith(config.consultations.form);
284
285
  unmount();
285
286
 
286
287
  serve({ consultations: [consultation('new', '2026-04-01')], mayEnter: false });
@@ -2,11 +2,9 @@ import React from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import { Button, SkeletonText } from '@carbon/react';
4
4
  import { AddIcon, CardHeader, EditIcon, formatDate, parseDate, useConfig } from '@openmrs/esm-framework';
5
- import { useMayEnterForm } from '../access/may-enter-form';
6
5
  import { type Config } from '../config-schema';
7
6
  import { useNextCardiologyVisit } from '../patient-status/cardiology.resource';
8
7
  import { daysUntil } from '../patient-status/due-tone';
9
- import { useOpenFormInVisit } from '../visits/open-form-in-visit';
10
8
  import { useStartConsultation } from './consultations.component';
11
9
  import { useConsultations } from './consultations.resource';
12
10
  import { useLatestDiagnosis, usePersonDetails } from './patient-details.resource';
@@ -19,16 +17,15 @@ import styles from '../styles/summary-card.scss';
19
17
  */
20
18
  export default function ConsultationCard({ patientUuid }: { patientUuid: string }) {
21
19
  const { t } = useTranslation();
22
- const { contactCard, patientInformationForm } = useConfig<Config>();
20
+ const { contactCard } = useConfig<Config>();
23
21
  const { consultations, isLoading } = useConsultations(patientUuid);
24
22
  const { nextDue } = useNextCardiologyVisit(patientUuid);
25
23
  const { diagnosis, isLoading: diagnosisLoading } = useLatestDiagnosis(patientUuid);
26
24
  const { attributes } = usePersonDetails(patientUuid);
27
25
  const start = useStartConsultation(patientUuid);
28
- // Patient Information holds one record per patient, so this edits the latest rather than adding one (AR-150).
29
- const mayUpdateDiagnosis = useMayEnterForm(patientInformationForm);
30
- const { open: openForm, isOpening } = useOpenFormInVisit(patientUuid);
31
26
  const [last] = consultations;
27
+ // The clinician records the diagnosis on the consultation (AR-167): the latest one, edited, or a first one.
28
+ const updateDiagnosis = () => (last ? start.edit(last.uuid) : start.start());
32
29
 
33
30
  const fields = [
34
31
  {
@@ -94,14 +91,14 @@ export default function ConsultationCard({ patientUuid }: { patientUuid: string
94
91
  {t('edit', 'Edit')}
95
92
  </Button>
96
93
  )}
97
- {field.id === 'diagnosis' && mayUpdateDiagnosis && (
94
+ {field.id === 'diagnosis' && start && (
98
95
  <Button
99
96
  kind="ghost"
100
97
  size="sm"
101
98
  className={styles.fieldAction}
102
99
  renderIcon={(props) => <EditIcon size={16} {...props} />}
103
- disabled={isOpening}
104
- onClick={() => openForm(patientInformationForm)}
100
+ disabled={start.isOpening}
101
+ onClick={updateDiagnosis}
105
102
  >
106
103
  {diagnosis ? t('updateDiagnosis', 'Update diagnosis') : t('recordDiagnosis', 'Record diagnosis')}
107
104
  </Button>
@@ -1,5 +1,5 @@
1
1
  import useSWR from 'swr';
2
- import { type FetchResponse, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
2
+ import { type FetchResponse, openmrsFetch, parseDate, restBaseUrl } from '@openmrs/esm-framework';
3
3
  import {
4
4
  answersIn,
5
5
  answerText,
@@ -27,9 +27,15 @@ export function usePersonDetails(patientUuid: string | null) {
27
27
  return { attributes, village: data?.data?.preferredAddress?.cityVillage ?? null, error, isLoading };
28
28
  }
29
29
 
30
- /** The Patient Information questions a diagnosis reads. */
30
+ /**
31
+ * The questions a diagnosis reads. A clinician records it on the RHD Consultation Visit (AR-167); one a Patient
32
+ * Information recorded before then still counts, so both encounter types are read.
33
+ */
31
34
  export const diagnosisConcepts = {
32
- encounterType: 'ffdc883f-f99f-496a-83f9-2c3c581e1af0',
35
+ encounterTypes: {
36
+ consultation: 'c2503561-c00d-5460-8157-43d594472b4a',
37
+ patientInformation: 'ffdc883f-f99f-496a-83f9-2c3c581e1af0',
38
+ },
33
39
  group: '594b4495-36dc-52a6-9810-15a9e2e2dcb9',
34
40
  category: '1a5aa050-661d-5e89-95d7-c1eba476df22',
35
41
  active: 'b1b5d279-8013-5ae4-83a7-0f2bd9bc8457',
@@ -43,12 +49,28 @@ export const diagnosisConcepts = {
43
49
  ],
44
50
  };
45
51
 
52
+ /** The patient's consultations and Patient Information together, newest first. */
53
+ function useDiagnosisEncounters(patientUuid: string | null) {
54
+ const consultations = useChartEncounters(patientUuid, diagnosisConcepts.encounterTypes.consultation);
55
+ const information = useChartEncounters(patientUuid, diagnosisConcepts.encounterTypes.patientInformation);
56
+ const tag = (list: Array<ChartEncounter>, onConsultation: boolean) =>
57
+ list.map((encounter) => ({ ...encounter, onConsultation }));
58
+ const encounters = [...tag(consultations.encounters, true), ...tag(information.encounters, false)].sort(
59
+ (a, b) => parseDate(b.encounterDatetime).getTime() - parseDate(a.encounterDatetime).getTime(),
60
+ );
61
+ return {
62
+ encounters,
63
+ error: consultations.error ?? information.error,
64
+ isLoading: consultations.isLoading || information.isLoading,
65
+ };
66
+ }
67
+
46
68
  /**
47
- * The diagnosis of the patient's latest Patient Information, as the registry reads it: the first Diagnosis with a
48
- * Category, and its details in name order. Null with none.
69
+ * The diagnosis of the patient's latest consultation or Patient Information that records one, as the registry reads
70
+ * it: the first Diagnosis with a Category, and its details in name order. Null with none.
49
71
  */
50
72
  export function useLatestDiagnosis(patientUuid: string | null) {
51
- const { encounters, error, isLoading } = useChartEncounters(patientUuid, diagnosisConcepts.encounterType);
73
+ const { encounters, error, isLoading } = useDiagnosisEncounters(patientUuid);
52
74
  const group = encounters
53
75
  .flatMap((encounter) => answersIn(encounter.obs, diagnosisConcepts.group))
54
76
  .find((one) => answersIn(one.groupMembers, diagnosisConcepts.category).length);
@@ -65,8 +87,10 @@ export function useLatestDiagnosis(patientUuid: string | null) {
65
87
 
66
88
  export interface DiagnosisRow {
67
89
  key: string;
68
- /** The Patient Information that records it, which Edit reopens. */
90
+ /** The consultation or Patient Information that records it, which Edit reopens. */
69
91
  encounterUuid: string;
92
+ /** Whether a consultation records it; otherwise a Patient Information from before AR-167. */
93
+ onConsultation: boolean;
70
94
  diagnosis: string;
71
95
  active: string;
72
96
  started: string | null;
@@ -74,7 +98,12 @@ export interface DiagnosisRow {
74
98
  }
75
99
 
76
100
  /** One Diagnosis answer group as a table row: the category with its details, and its status and dates. */
77
- export function toDiagnosisRow(group: GroupedObs, key: string, encounterUuid: string): DiagnosisRow {
101
+ export function toDiagnosisRow(
102
+ group: GroupedObs,
103
+ key: string,
104
+ encounterUuid: string,
105
+ onConsultation = true,
106
+ ): DiagnosisRow {
78
107
  const one = (concept: string) => answersIn(group.groupMembers, concept)[0]?.value;
79
108
  const category = answerText(one(diagnosisConcepts.category));
80
109
  const details = (group.groupMembers ?? [])
@@ -84,6 +113,7 @@ export function toDiagnosisRow(group: GroupedObs, key: string, encounterUuid: st
84
113
  return {
85
114
  key,
86
115
  encounterUuid,
116
+ onConsultation,
87
117
  diagnosis: details.length ? `${category} (${details.join(', ')})` : category,
88
118
  active: answerText(one(diagnosisConcepts.active)),
89
119
  started: one(diagnosisConcepts.started) ? String(one(diagnosisConcepts.started)) : null,
@@ -91,16 +121,21 @@ export function toDiagnosisRow(group: GroupedObs, key: string, encounterUuid: st
91
121
  };
92
122
  }
93
123
 
94
- /** Every Diagnosis with a Category in the patient's latest Patient Information that has one; earlier records are superseded. */
124
+ /**
125
+ * Every Diagnosis with a Category in the patient's latest consultation or Patient Information that has one; earlier
126
+ * records are superseded.
127
+ */
95
128
  export function useDiagnoses(patientUuid: string | null) {
96
- const { encounters, error, isLoading } = useChartEncounters(patientUuid, diagnosisConcepts.encounterType);
129
+ const { encounters, error, isLoading } = useDiagnosisEncounters(patientUuid);
97
130
  const withCategory = (encounter: ChartEncounter) =>
98
131
  answersIn(encounter.obs, diagnosisConcepts.group).filter(
99
132
  (group) => answersIn(group.groupMembers, diagnosisConcepts.category).length,
100
133
  );
101
134
  const latest = encounters.find((encounter) => withCategory(encounter).length);
102
135
  const diagnoses = latest
103
- ? withCategory(latest).map((group, index) => toDiagnosisRow(group, `${latest.uuid}-${index}`, latest.uuid))
136
+ ? withCategory(latest).map((group, index) =>
137
+ toDiagnosisRow(group, `${latest.uuid}-${index}`, latest.uuid, latest.onConsultation),
138
+ )
104
139
  : [];
105
140
  return { diagnoses, error, isLoading };
106
141
  }
@@ -17,7 +17,7 @@ import { type Config } from '../config-schema';
17
17
  import { useOpenFormInVisit } from '../visits/open-form-in-visit';
18
18
  import Consultations, { useStartConsultation } from './consultations.component';
19
19
  import { useConsultations } from './consultations.resource';
20
- import { useDiagnoses } from './patient-details.resource';
20
+ import { type DiagnosisRow, useDiagnoses } from './patient-details.resource';
21
21
  import { toListedItems } from './repeated-lists.resource';
22
22
  import styles from '../cardiac-tests/cardiac-tests.scss';
23
23
 
@@ -77,14 +77,18 @@ export function CompactTable<Row extends { key: string }>({
77
77
  }
78
78
 
79
79
  /**
80
- * Every diagnosis the patient's Patient Information records, as a table, with Edit, which reopens that Patient
81
- * Information, for a user who may record it.
80
+ * Every diagnosis the patient's latest consultation records, as a table, with Edit, which reopens that consultation,
81
+ * for a user who may record one. A diagnosis a Patient Information recorded before AR-167 is listed until a
82
+ * consultation records one, and its Edit reopens that Patient Information.
82
83
  */
83
84
  export function Diagnoses({ patientUuid }: { patientUuid: string }) {
84
85
  const { t } = useTranslation();
85
- const { patientInformationForm } = useConfig<Config>();
86
+ const { consultations, patientInformationForm } = useConfig<Config>();
86
87
  const { diagnoses, error, isLoading } = useDiagnoses(patientUuid);
87
- const mayEdit = useMayEnterForm(patientInformationForm);
88
+ const mayEditConsultation = useMayEnterForm(consultations.form);
89
+ const mayEditInformation = useMayEnterForm(patientInformationForm);
90
+ const formOf = (one: DiagnosisRow) => (one.onConsultation ? consultations.form : patientInformationForm);
91
+ const mayEdit = diagnoses.every((one) => (one.onConsultation ? mayEditConsultation : mayEditInformation));
88
92
  const { open, isOpening } = useOpenFormInVisit(patientUuid);
89
93
  const title = t('diagnoses', 'Diagnoses');
90
94
  type Row = (typeof diagnoses)[number];
@@ -104,7 +108,7 @@ export function Diagnoses({ patientUuid }: { patientUuid: string }) {
104
108
  interpolation: { escapeValue: false },
105
109
  })}
106
110
  disabled={isOpening}
107
- onClick={() => open(patientInformationForm, undefined, one.encounterUuid)}
111
+ onClick={() => open(formOf(one), undefined, one.encounterUuid)}
108
112
  />
109
113
  ),
110
114
  },
@@ -94,7 +94,7 @@ function serve({
94
94
  if (url.includes(`encounterType=${config.consultations.encounterType}`)) {
95
95
  return { data: { results: consultations, totalCount: consultations.length } };
96
96
  }
97
- if (url.includes(`encounterType=${diagnosisConcepts.encounterType}`)) {
97
+ if (url.includes(`encounterType=${diagnosisConcepts.encounterTypes.patientInformation}`)) {
98
98
  return { data: { results: patientInformation, totalCount: patientInformation.length } };
99
99
  }
100
100
  if (url.includes('/form/')) {
@@ -140,16 +140,14 @@ describe('the Consultation visits page tables', () => {
140
140
  expect(rows[1]).toHaveTextContent(/Congenital.*No/);
141
141
  });
142
142
 
143
- it('shows only the diagnoses of the latest Patient Information', async () => {
143
+ it('shows only the diagnoses of the latest consultation or Patient Information that records one', async () => {
144
144
  const diagnosis = (name: string) =>
145
145
  obs(diagnosisConcepts.group, null, [obs(diagnosisConcepts.category, coded(name, name))]);
146
146
  const record = (uuid: string, date: string, name: string) =>
147
147
  ({ uuid, encounterDatetime: `${date}T09:00:00.000+0300`, obs: [diagnosis(name)] }) as ChartEncounter;
148
148
  serve({
149
- patientInformation: [
150
- record('older', '2025-03-01', 'Congenital'),
151
- record('latest', '2026-03-01', 'Rheumatic Heart Disease'),
152
- ],
149
+ consultations: [record('latest', '2026-03-01', 'Rheumatic Heart Disease'), consultation('bare', '2026-04-01')],
150
+ patientInformation: [record('older', '2025-03-01', 'Congenital')],
153
151
  });
154
152
 
155
153
  renderIn(<Diagnoses patientUuid="winnie" />);
@@ -182,13 +180,30 @@ describe('the Consultation visits page tables', () => {
182
180
  ).toBeInTheDocument();
183
181
  });
184
182
 
185
- it("reopens a diagnosis's Patient Information, and an item's latest consultation, from its Edit", async () => {
183
+ it("reopens a diagnosis's consultation, and an item's latest consultation, from its Edit", async () => {
186
184
  const item = (list: string, name: string) => obs(list, null, [obs(list, coded(name, name))]);
185
+ const diagnosis = obs(diagnosisConcepts.group, null, [obs(diagnosisConcepts.category, coded('rhd', 'RHD'))]);
187
186
  serve({
188
187
  consultations: [
189
- consultation('new', '2026-04-01', [item(c.allergy, 'Penicillin')]),
188
+ consultation('new', '2026-04-01', [item(c.allergy, 'Penicillin'), diagnosis]),
190
189
  consultation('old', '2025-10-01', [item(c.allergy, 'Penicillin'), item(c.complication, 'Stroke')]),
191
190
  ],
191
+ });
192
+
193
+ renderIn(<ConsultationsPage patientUuid="winnie" />);
194
+
195
+ await userEvent.click(await screen.findByRole('button', { name: 'Edit RHD' }));
196
+ expect(openForm).toHaveBeenLastCalledWith(config.consultations.form, undefined, 'new');
197
+ await userEvent.click(
198
+ await screen.findByRole('button', { name: /^Edit Penicillin in the consultation of .*Apr.*2026$/ }),
199
+ );
200
+ expect(openForm).toHaveBeenLastCalledWith(config.consultations.form, undefined, 'new');
201
+ await userEvent.click(screen.getByRole('button', { name: /^Edit Stroke in the consultation of .*Oct.*2025$/ }));
202
+ expect(openForm).toHaveBeenLastCalledWith(config.consultations.form, undefined, 'old');
203
+ });
204
+
205
+ it("reopens the Patient Information that recorded a diagnosis before AR-167, from its Edit", async () => {
206
+ serve({
192
207
  patientInformation: [
193
208
  {
194
209
  uuid: 'pi',
@@ -198,16 +213,10 @@ describe('the Consultation visits page tables', () => {
198
213
  ],
199
214
  });
200
215
 
201
- renderIn(<ConsultationsPage patientUuid="winnie" />);
216
+ renderIn(<Diagnoses patientUuid="winnie" />);
202
217
 
203
218
  await userEvent.click(await screen.findByRole('button', { name: 'Edit RHD' }));
204
219
  expect(openForm).toHaveBeenLastCalledWith(config.patientInformationForm, undefined, 'pi');
205
- await userEvent.click(
206
- await screen.findByRole('button', { name: /^Edit Penicillin in the consultation of .*Apr.*2026$/ }),
207
- );
208
- expect(openForm).toHaveBeenLastCalledWith(config.consultations.form, undefined, 'new');
209
- await userEvent.click(screen.getByRole('button', { name: /^Edit Stroke in the consultation of .*Oct.*2025$/ }));
210
- expect(openForm).toHaveBeenLastCalledWith(config.consultations.form, undefined, 'old');
211
220
  });
212
221
 
213
222
  it('shows the tables without Edit to a user who may not record the forms', async () => {
package/src/routes.json CHANGED
@@ -984,6 +984,12 @@
984
984
  "width": "extra-wide",
985
985
  "canMaximize": true
986
986
  },
987
+ {
988
+ "name": "act-cardiac-test-form-entry",
989
+ "group": "patient-chart",
990
+ "width": "extra-wide",
991
+ "canMaximize": true
992
+ },
987
993
  {
988
994
  "name": "act-update-patient-status",
989
995
  "group": "patient-chart"
@@ -1054,6 +1060,11 @@
1054
1060
  "component": "@openmrs/esm-patient-forms-app#exportedPatientFormEntryWorkspace",
1055
1061
  "window": "act-screen-positive-form-entry"
1056
1062
  },
1063
+ {
1064
+ "name": "act-cardiac-test-form-entry-workspace",
1065
+ "component": "@openmrs/esm-patient-forms-app#exportedPatientFormEntryWorkspace",
1066
+ "window": "act-cardiac-test-form-entry"
1067
+ },
1057
1068
  {
1058
1069
  "name": "act-vitals-form-workspace",
1059
1070
  "component": "@openmrs/esm-patient-vitals-app#vitalsBiometricsFormWorkspace",
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { beforeEach, describe, expect, it, vi } from 'vitest';
3
3
  import { render, screen, within } from '@testing-library/react';
4
4
  import userEvent from '@testing-library/user-event';
5
- import { fetchCurrentPatient, launchWorkspace2, openmrsFetch, saveVisit } from '@openmrs/esm-framework';
5
+ import { navigate, openmrsFetch } from '@openmrs/esm-framework';
6
6
  import routes from '../routes.json';
7
7
  import { signInWith } from '../access/sign-in.test-helper';
8
8
  import { useReportDataset } from '../reports/report-dataset.resource';
@@ -16,25 +16,21 @@ vi.mock('../access/may-enter-form', () => ({
16
16
  }));
17
17
  vi.mock('@openmrs/esm-framework', async (importOriginal) => ({
18
18
  ...(await importOriginal<object>()),
19
- fetchCurrentPatient: vi.fn(),
19
+ navigate: vi.fn(),
20
20
  }));
21
21
  vi.mock('../reports/report-dataset.resource', () => ({ useReportDataset: vi.fn() }));
22
22
 
23
- const informationForm = { uuid: 'a6646c51-130d-3b59-a442-959bea93487d', display: 'RHD Patient Information' };
24
- const fhirPatient = { resourceType: 'Patient', id: 'patient-2' };
25
23
  const mutate = vi.fn();
26
24
 
27
- async function enterDiagnosis(name: string) {
25
+ async function recordDiagnosis(name: string) {
28
26
  const row = screen.getByRole('row', { name: new RegExp(`${name}\\b`) });
29
- await userEvent.click(within(row).getByRole('button', { name: 'Enter diagnosis' }));
27
+ await userEvent.click(within(row).getByRole('button', { name: 'Record diagnosis' }));
30
28
  }
31
29
 
32
- describe('Screen positive, Enter diagnosis', () => {
30
+ describe('Screen positive, Record diagnosis', () => {
33
31
  beforeEach(async () => {
34
32
  window.getOpenmrsSpaBase = () => '/openmrs/spa/';
35
33
  await signInWith(['App: act.screenPositive', 'Add Encounters']);
36
- vi.mocked(fetchCurrentPatient).mockResolvedValue(fhirPatient as never);
37
- vi.mocked(openmrsFetch).mockResolvedValue({ data: informationForm } as never);
38
34
  vi.mocked(useReportDataset).mockReturnValue({
39
35
  columns: [],
40
36
  rows: screenPositiveRows,
@@ -44,42 +40,12 @@ describe('Screen positive, Enter diagnosis', () => {
44
40
  });
45
41
  });
46
42
 
47
- it('opens the form that recorded the Screen + to edit, beside the list, starting no visit', async () => {
43
+ it("opens the patient's Consultation visits page, where Start consultation records the diagnosis", async () => {
48
44
  render(<ScreenPositive />);
49
45
 
50
- await enterDiagnosis('Patient 2');
46
+ await recordDiagnosis('Patient 2');
51
47
 
52
- await vi.waitFor(() => expect(launchWorkspace2).toHaveBeenCalled());
53
- expect(vi.mocked(openmrsFetch).mock.calls[0][0]).toContain(informationForm.uuid);
54
- expect(saveVisit).not.toHaveBeenCalled();
55
- expect(launchWorkspace2).toHaveBeenCalledWith(
56
- 'act-screen-positive-form-entry-workspace',
57
- { form: informationForm, encounterUuid: 'information-2' },
58
- { patient: fhirPatient, patientUuid: 'patient-2', visitContext: null, mutateVisitContext: mutate },
59
- );
60
- });
61
-
62
- it('opens the same form again for a second click, so the open form is not replaced', async () => {
63
- render(<ScreenPositive />);
64
-
65
- await enterDiagnosis('Patient 2');
66
- await enterDiagnosis('Patient 2');
67
-
68
- await vi.waitFor(() => expect(launchWorkspace2).toHaveBeenCalledTimes(2));
69
- const [first, second] = vi.mocked(launchWorkspace2).mock.calls as unknown as Array<[string, { form: object }]>;
70
- expect(second[1].form).toBe(first[1].form);
71
- });
72
-
73
- it('tries again on a later click after opening failed', async () => {
74
- vi.mocked(fetchCurrentPatient).mockRejectedValueOnce(new Error('forbidden'));
75
- render(<ScreenPositive />);
76
-
77
- await enterDiagnosis('Patient 2');
78
- await vi.waitFor(() => expect(vi.mocked(fetchCurrentPatient)).toHaveBeenCalledTimes(1));
79
- await enterDiagnosis('Patient 2');
80
-
81
- await vi.waitFor(() => expect(launchWorkspace2).toHaveBeenCalledTimes(1));
82
- expect(vi.mocked(fetchCurrentPatient)).toHaveBeenCalledTimes(2);
48
+ expect(navigate).toHaveBeenCalledWith({ to: '/openmrs/spa/patient/patient-2/chart/act-consultations' });
83
49
  });
84
50
 
85
51
  it('offers no action for a Screen + recorded without a form', () => {
@@ -94,7 +60,7 @@ describe('Screen positive, Enter diagnosis', () => {
94
60
  render(<ScreenPositive />);
95
61
 
96
62
  expect(
97
- within(screen.getByRole('row', { name: /Patient 2\b/ })).queryByRole('button', { name: 'Enter diagnosis' }),
63
+ within(screen.getByRole('row', { name: /Patient 2\b/ })).queryByRole('button', { name: 'Record diagnosis' }),
98
64
  ).not.toBeInTheDocument();
99
65
  expect(openmrsFetch).not.toHaveBeenCalled();
100
66
  });
@@ -1,4 +1,4 @@
1
- import React, { useMemo, useRef, useState } from 'react';
1
+ import React, { useMemo, useState } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import {
4
4
  Button,
@@ -11,22 +11,18 @@ import {
11
11
  TableHead,
12
12
  TableHeader,
13
13
  TableRow,
14
- Tag,
15
14
  } from '@carbon/react';
16
15
  import {
17
16
  CardiologyPictogram,
18
17
  ConfigurableLink,
19
- fetchCurrentPatient,
20
18
  formatDate,
21
19
  isDesktop,
22
- launchWorkspace2,
23
- showSnackbar,
20
+ navigate,
24
21
  useConfig,
25
22
  useLayoutType,
26
23
  UserHasAccess,
27
24
  } from '@openmrs/esm-framework';
28
25
  import { MayEnterForm } from '../access/may-enter-form';
29
- import { fetchForm } from '../flag-gaps/flag-gaps.resource';
30
26
  import { ActPageHeader } from '../act-page-header/act-page-header.component';
31
27
  import { type Config } from '../config-schema';
32
28
  import { patientChartUrl } from '../patient-chart-url';
@@ -58,45 +54,17 @@ const sortValues: Record<string, (row: ReportRow) => SortValue> = {
58
54
  patient: reportText('full_name'),
59
55
  screened: (row) => String(row.screen_date ?? '').slice(0, 10) || null,
60
56
  screeningSite: reportText('screening_site'),
61
- status: reportText('follow_up_status'),
62
57
  };
63
58
 
64
- const statusTags = { 'Not contacted': 'warm-gray', 'Echo booked': 'blue', Urgent: 'red' } as const;
65
-
66
- const screenPositiveFormEntryWorkspace = 'act-screen-positive-form-entry-workspace';
67
-
68
59
  export function ScreenPositiveTable() {
69
60
  const { t } = useTranslation();
70
61
  const { screenPositive } = useConfig<Config>();
71
62
  const desktop = isDesktop(useLayoutType());
72
63
  const { rows, isLoading, error, mutate } = useReportDataset(screenPositive.report);
73
- // Same objects on a second click, so the open workspace does not prompt to close the form.
74
- const loaded = useRef(new Map<string, Promise<[Awaited<ReturnType<typeof fetchForm>>, fhir.Patient]>>());
75
- // Opens the form that recorded the Screen + to edit, where its Diagnosis Details take the patient off the list,
76
- // as ACT 2.0's row opened the patient form.
77
- const enterDiagnosis = async (row: ReportRow) => {
78
- const patientUuid = String(row.patient_uuid);
79
- const encounterUuid = String(row.encounter_uuid);
80
- if (!loaded.current.has(encounterUuid)) {
81
- loaded.current.set(
82
- encounterUuid,
83
- Promise.all([fetchForm(String(row.form_uuid)), fetchCurrentPatient(patientUuid)]),
84
- );
85
- }
86
- try {
87
- const [form, patient] = await loaded.current.get(encounterUuid);
88
- // An edit loads its encounter's own visit, so the list passes none.
89
- // Both form engines report a save through mutateVisitContext, which evaluates the list again.
90
- launchWorkspace2(
91
- screenPositiveFormEntryWorkspace,
92
- { form, encounterUuid },
93
- { patient, patientUuid, visitContext: null, mutateVisitContext: mutate },
94
- );
95
- } catch (e) {
96
- loaded.current.delete(encounterUuid);
97
- showSnackbar({ kind: 'error', title: t('couldNotOpenForm', 'Could not open the form'), subtitle: e?.message });
98
- }
99
- };
64
+ // The diagnosis is recorded on the RHD Consultation Visit (AR-167), so the row opens the patient's Consultation
65
+ // visits page, where Start consultation records it; the saved consultation takes the patient off the list.
66
+ const recordDiagnosis = (row: ReportRow) =>
67
+ navigate({ to: `${window.getOpenmrsSpaBase()}patient/${String(row.patient_uuid)}/chart/act-consultations` });
100
68
  const [filters, setFilters, filtersPending] = useScreenPositiveFilters();
101
69
  const clinicKind = useSessionClinicKind();
102
70
  const [sort, setSort] = useState<ColumnSort | null>(null);
@@ -116,11 +84,6 @@ export function ScreenPositiveTable() {
116
84
  />
117
85
  );
118
86
  const text = (column: string) => (row: ReportRow) => String(row[column] ?? '');
119
- const statusLabel = {
120
- 'Not contacted': t('notContacted', 'Not contacted'),
121
- 'Echo booked': t('echoBooked', 'Echo booked'),
122
- Urgent: t('urgent', 'Urgent'),
123
- };
124
87
  const columns: Array<{ key: string; header: string; render: (row: ReportRow) => React.ReactNode }> = [
125
88
  {
126
89
  key: 'patient',
@@ -136,23 +99,7 @@ export function ScreenPositiveTable() {
136
99
  },
137
100
  { key: 'screened', header: t('screened', 'Screened'), render: screenDate },
138
101
  { key: 'screeningSite', header: t('screeningSite', 'Screening site'), render: text('screening_site') },
139
- {
140
- key: 'status',
141
- header: t('status', 'Status'),
142
- render: (row) => {
143
- const status = String(row.follow_up_status ?? '');
144
- return status in statusTags ? (
145
- <Tag
146
- as="span"
147
- size="sm"
148
- type={statusTags[status]}
149
- className={status === 'Not contacted' ? styles.notContacted : undefined}
150
- >
151
- {statusLabel[status]}
152
- </Tag>
153
- ) : null;
154
- },
155
- },
102
+ // The follow-up status column went with the question, which AR-167 took off Patient Information.
156
103
  ];
157
104
 
158
105
  // Where the session location's kind cannot be read, opening on every clinic would show patients not its own.
@@ -217,8 +164,8 @@ export function ScreenPositiveTable() {
217
164
  <TableCell>
218
165
  {row.form_uuid && (
219
166
  <MayEnterForm formUuid={String(row.form_uuid)}>
220
- <Button kind="ghost" size="sm" onClick={() => enterDiagnosis(row)}>
221
- {t('enterDiagnosis', 'Enter diagnosis')}
167
+ <Button kind="ghost" size="sm" onClick={() => recordDiagnosis(row)}>
168
+ {t('recordDiagnosis', 'Record diagnosis')}
222
169
  </Button>
223
170
  </MayEnterForm>
224
171
  )}
@@ -245,7 +192,7 @@ export default function ScreenPositive() {
245
192
  <p className={styles.description}>
246
193
  {t(
247
194
  'diagnosisToConfirmDescription',
248
- 'Screen-positive patients whose diagnosis has no details yet. Enter diagnosis takes a patient off this list.',
195
+ 'Screen-positive patients with no diagnosis yet. Record diagnosis opens their Consultation visits, where a saved consultation with a diagnosis takes them off this list.',
249
196
  )}
250
197
  </p>
251
198
  <ScreenPositiveTable />
@@ -54,19 +54,19 @@ describe('Diagnosis to confirm', () => {
54
54
  render(<ScreenPositive />);
55
55
 
56
56
  expect(screen.getByRole('heading', { name: 'Diagnosis to confirm' })).toBeInTheDocument();
57
- expect(screen.getByText(/Enter diagnosis takes a patient off this list\./)).toBeInTheDocument();
57
+ expect(screen.getByText(/Record diagnosis opens their Consultation visits/)).toBeInTheDocument();
58
58
  });
59
59
 
60
- it('lists each patient with their age and sex, the date of positive screen, screening site and follow-up status', () => {
60
+ it('lists each patient with their age and sex, the date of positive screen and screening site', () => {
61
61
  dataset({ rows: screenPositiveRows });
62
62
 
63
63
  render(<ScreenPositive />);
64
64
 
65
- expect(columnHeaders()).toEqual(['Patient', 'Screened', 'Screening site', 'Status', '']);
65
+ expect(columnHeaders()).toEqual(['Patient', 'Screened', 'Screening site', '']);
66
66
  const cells = within(screen.getByRole('row', { name: /Patient 2\b/ }))
67
67
  .getAllByRole('cell')
68
68
  .map((cell) => cell.textContent);
69
- expect(cells).toEqual(['Patient 29 M', '17-Sept-2026', 'Layibi College', 'Echo booked', 'Enter diagnosis']);
69
+ expect(cells).toEqual(['Patient 29 M', '17-Sept-2026', 'Layibi College', 'Record diagnosis']);
70
70
  });
71
71
 
72
72
  it('sorts by any column, the date of positive screen by its day, then returns to the report order', async () => {
@@ -112,28 +112,13 @@ describe('Diagnosis to confirm', () => {
112
112
  expect(screen.queryByRole('table')).not.toBeInTheDocument();
113
113
  });
114
114
 
115
- it.each([
116
- ['Patient 1', 'Not contacted', 'notContacted'],
117
- ['Patient 2', 'Echo booked', 'cds--tag--blue'],
118
- ['Patient 3', 'Urgent', 'cds--tag--red'],
119
- ])("tags %s's follow-up status %s", (name, status, colour) => {
120
- dataset({ rows: screenPositiveRows });
121
-
122
- render(<ScreenPositive />);
123
-
124
- const tag = within(screen.getByRole('row', { name: new RegExp(`${name}\\b`) })).getByText(status);
125
- // The tag has no role, so it is found around its label.
126
- // eslint-disable-next-line testing-library/no-node-access
127
- expect(tag.closest('.cds--tag')).toHaveClass(colour);
128
- });
129
-
130
- it('leaves the site and status empty for a patient with neither recorded', () => {
115
+ it('leaves the site empty for a patient with none recorded', () => {
131
116
  dataset({ rows: screenPositiveRows });
132
117
 
133
118
  render(<ScreenPositive />);
134
119
 
135
120
  const cells = within(screen.getByRole('row', { name: /Patient 4\b/ })).getAllByRole('cell');
136
- expect([cells[2].textContent, cells[3].textContent]).toEqual(['', '']);
121
+ expect(cells[2]).toHaveTextContent('');
137
122
  });
138
123
 
139
124
  it("links each patient's name to their chart", () => {
@@ -230,7 +215,7 @@ describe('Diagnosis to confirm', () => {
230
215
  const { rerender } = render(<ScreenPositive />);
231
216
 
232
217
  const { skeleton, rows, columns } = tableSkeleton();
233
- expect({ rows, columns }).toEqual({ rows: 10, columns: 5 });
218
+ expect({ rows, columns }).toEqual({ rows: 10, columns: 4 });
234
219
  expect(skeleton.className.includes('cds--data-table--compact')).toBe(compact);
235
220
  dataset({ rows: screenPositiveRows });
236
221
  rerender(<ScreenPositive />);