@openmrs/esm-patient-search-app 9.2.1-pre.7038 → 9.2.1-pre.7042

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.
@@ -234,9 +234,9 @@
234
234
  "entry": false,
235
235
  "recorded": false,
236
236
  "reason": "reused as split chunk (cache group: default)",
237
- "size": 318958,
237
+ "size": 319918,
238
238
  "sizes": {
239
- "javascript": 318958
239
+ "javascript": 319918
240
240
  },
241
241
  "names": [],
242
242
  "idHints": [],
@@ -250,7 +250,7 @@
250
250
  "auxiliaryFiles": [
251
251
  "1804.js.map"
252
252
  ],
253
- "hash": "d23fc771d3e93124",
253
+ "hash": "9c618c4bcc979a13",
254
254
  "childrenByOrder": {}
255
255
  },
256
256
  {
@@ -825,9 +825,9 @@
825
825
  "initial": false,
826
826
  "entry": false,
827
827
  "recorded": false,
828
- "size": 76578,
828
+ "size": 77538,
829
829
  "sizes": {
830
- "javascript": 76578
830
+ "javascript": 77538
831
831
  },
832
832
  "names": [],
833
833
  "idHints": [],
@@ -841,7 +841,7 @@
841
841
  "auxiliaryFiles": [
842
842
  "4946.js.map"
843
843
  ],
844
- "hash": "7ea5c774b3a48b63",
844
+ "hash": "b10f2ed29529255d",
845
845
  "childrenByOrder": {}
846
846
  },
847
847
  {
package/dist/routes.json CHANGED
@@ -1 +1 @@
1
- {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":">=2.2.0"},"pages":[{"component":"root","route":"search"}],"extensions":[{"name":"patient-search-icon","component":"patientSearchIcon","slot":"top-nav-actions-slot","order":10},{"name":"patient-search-button","component":"patientSearchButton","slot":"patient-search-button-slot","offline":true},{"name":"patient-search-bar","component":"patientSearchBar","slot":"patient-search-bar-slot","offline":true}],"workspaces":[{"component":"patientSearchWorkspace","groups":["ward-patient-admission-requests"],"name":"patient-search-workspace","title":"searchPatient","type":"patient-search-workspace","width":"narrow"}],"version":"9.2.1-pre.7038"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":">=2.2.0"},"pages":[{"component":"root","route":"search"}],"extensions":[{"name":"patient-search-icon","component":"patientSearchIcon","slot":"top-nav-actions-slot","order":10},{"name":"patient-search-button","component":"patientSearchButton","slot":"patient-search-button-slot","offline":true},{"name":"patient-search-bar","component":"patientSearchBar","slot":"patient-search-bar-slot","offline":true}],"workspaces":[{"component":"patientSearchWorkspace","groups":["ward-patient-admission-requests"],"name":"patient-search-workspace","title":"searchPatient","type":"patient-search-workspace","width":"narrow"}],"version":"9.2.1-pre.7042"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-patient-search-app",
3
- "version": "9.2.1-pre.7038",
3
+ "version": "9.2.1-pre.7042",
4
4
  "description": "Patient search microfrontend for O3",
5
5
  "browser": "dist/openmrs-esm-patient-search-app.js",
6
6
  "main": "src/index.ts",
@@ -73,4 +73,41 @@ describe('CompactPatientBanner', () => {
73
73
  expect(screen.getByRole('img')).toBeInTheDocument();
74
74
  // expect(screen.getByRole('heading', { name: /Smith, John Doe/ })).toBeInTheDocument();
75
75
  });
76
+
77
+ it('handles an array of valid patients', () => {
78
+ const multiplePatients: Array<SearchedPatient> = [
79
+ ...patients,
80
+ {
81
+ ...patients[0],
82
+ uuid: 'test-patient-uuid-2',
83
+ person: {
84
+ ...patients[0].person,
85
+ personName: {
86
+ display: 'Doe, Jane',
87
+ givenName: 'Jane',
88
+ middleName: '',
89
+ familyName: 'Doe',
90
+ },
91
+ },
92
+ },
93
+ ];
94
+
95
+ render(
96
+ <PatientSearchContext.Provider value={{}}>
97
+ <CompactPatientBanner patients={multiplePatients} />
98
+ </PatientSearchContext.Provider>,
99
+ );
100
+
101
+ expect(screen.getAllByRole('img')).toHaveLength(2);
102
+ });
103
+
104
+ it('renders empty state when patients array is empty', () => {
105
+ render(
106
+ <PatientSearchContext.Provider value={{}}>
107
+ <CompactPatientBanner patients={[]} />
108
+ </PatientSearchContext.Provider>,
109
+ );
110
+
111
+ expect(screen.queryByRole('img')).not.toBeInTheDocument();
112
+ });
76
113
  });
@@ -79,7 +79,13 @@ export function useInfinitePatientSearch(
79
79
  openmrsFetch,
80
80
  );
81
81
 
82
- const mappedData = data?.flatMap((res) => res.data?.results ?? []) ?? null;
82
+ // Filter out null patients and patients with null person property to prevent errors
83
+ // when components access patient.person properties. This filtering happens at the source
84
+ // (in the hook) to ensure all consumers receive clean, valid data.
85
+ const mappedData =
86
+ data
87
+ ?.flatMap((res) => res.data?.results ?? [])
88
+ ?.filter((patient): patient is SearchedPatient => patient !== null && patient.person !== null) ?? null;
83
89
 
84
90
  return useMemo(
85
91
  () => ({
@@ -203,7 +209,13 @@ export function useRestPatients(
203
209
  },
204
210
  );
205
211
 
206
- const mappedData = data?.flatMap((res) => res.data) ?? null;
212
+ // Filter out null patients and patients with null person property to prevent errors
213
+ // when components access patient.person properties. This filtering happens at the source
214
+ // (in the hook) to ensure all consumers receive clean, valid data.
215
+ const mappedData =
216
+ data
217
+ ?.flatMap((res) => res.data)
218
+ ?.filter((patient): patient is SearchedPatient => patient !== null && patient.person !== null) ?? null;
207
219
 
208
220
  return useMemo(
209
221
  () => ({