Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
reagan-meant committed Oct 3, 2024
1 parent 43c9beb commit 141d4d1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
11 changes: 7 additions & 4 deletions packages/esm-patient-search-app/src/mpi/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { capitalize } from 'lodash-es';
import { type SearchedPatient } from '../types';
import { getCoreTranslation } from '@openmrs/esm-framework';
export function inferModeFromSearchParams(searchParams: URLSearchParams) {
return searchParams.get('mode')?.toLowerCase() === 'external' ? 'external' : 'internal';
}
Expand Down Expand Up @@ -28,11 +29,13 @@ export function mapToOpenMRSPatient(fhirPatients: Array<any>): Array<SearchedPat
})),
age: null,
birthdate: fhirPatient.birthDate,
gender: capitalize(fhirPatient.gender),
dead: !fhirPatient.active,
deathDate: '',
gender: getCoreTranslation(fhirPatient.gender),
dead: fhirPatient.deceasedBoolean,
deathDate: fhirPatient.deceasedDateTime,
personName: {
display: `${fhirPatient.name[0].family} ${fhirPatient.name[0].given[0]}`,
display: fhirPatient.name[0].text
? fhirPatient.name[0].text
: `${fhirPatient.name[0].family} ${fhirPatient.name[0].given[0]}`,
givenName: fhirPatient.name[0].given[0],
familyName: fhirPatient.name[0].family,
middleName: fhirPatient.name[0].given[1],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { render, screen } from '@testing-library/react';
import { getDefaultsFromConfigSchema, useConfig } from '@openmrs/esm-framework';
import { type PatientSearchConfig, configSchema } from '../config-schema';
import PatientSearchButton from './patient-search-button.component';
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import { MemoryRouter, Route, Routes } from 'react-router-dom';

const mockUseConfig = jest.mocked(useConfig<PatientSearchConfig>);

Expand Down Expand Up @@ -39,11 +39,11 @@ describe('PatientSearchButton', () => {
const user = userEvent.setup();

render(
<BrowserRouter>
<MemoryRouter>
<Routes>
<Route path="/" element={<PatientSearchButton />} />
</Routes>
</BrowserRouter>,
</MemoryRouter>,
);
const searchButton = screen.getByLabelText('Search Patient Button');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useCallback, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useConfig, useDebounce } from '@openmrs/esm-framework';
import { useSearchParams } from 'react-router-dom';
import AdvancedPatientSearchComponent from '../patient-search-page/advanced-patient-search.component';
import Overlay from '../ui-components/overlay';
import PatientSearchBar from '../patient-search-bar/patient-search-bar.component';
import { type PatientSearchConfig } from '../config-schema';
import { inferModeFromSearchParams } from '../mpi/utils';
import { useSearchParams } from 'react-router-dom';

interface PatientSearchOverlayProps {
onClose: () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,17 @@ export const SearchResultsEmptyState: React.FC<CommonProps> = ({ inTabletOrOverl
<p>
{t(
'trySearchFromClientRegistry',
"You can try searching using the patient's unique ID number or search the external MPI",
"Try searching using the patient's unique ID number or search the external registry",
)}
</p>
</div>
<Button
kind="ghost"
renderIcon={'Search'}
onClick={(e) => {
e.preventDefault();
doMPISearch(searchTerm);
}}>
{`${t('search', 'Search')} ${'MPIs'}`}
{`${t('search', 'Search')} ${'External Registry'}`}
</Button>
</>
)}
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-patient-search-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"searchResultsCount_one": "{{count}} search result",
"searchResultsCount_other": "{{count}} search results",
"sex": "Sex",
"trySearchFromClientRegistry": "You can try searching using the patient's unique ID number or search the external MPI",
"trySearchFromClientRegistry": "Try searching using the patient's unique ID number or search the external registry",
"trySearchWithPatientUniqueID": "Try to search again using the patient's unique ID number",
"unknown": "Unknown",
"yearOfBirth": "Year of Birth"
Expand Down

0 comments on commit 141d4d1

Please sign in to comment.