-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(feat) HIE-9: Add MPI workflows to OpenMRS frontend #1313
base: main
Are you sure you want to change the base?
Conversation
Size Change: -122 kB (-1.85%) Total Size: 6.5 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more nit-picky comments. I can review more later.
_default: null, | ||
_description: 'Identifier type uuid of OpenMRS to map the identifier system', | ||
}, | ||
identifierTypeName: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just be fetched from the backend, not part of the configuration.
const [patient, setPatient] = useState<fhir.Patient>(null); | ||
const [isLoading, setIsLoading] = useState(false); | ||
|
||
let url = `${fhirBaseUrl}/Patient/${patientId}/$cr`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just calculate this in the useEffect()
hook where you use it. E.g.,
useEffect(() => {
if (patientId) {
const url = `${fhirBaseUrl}/Patient/${patientId}/$cr`;
setIsLoading(true);
openmrsFetch(url).then((response) => {
if (response.data) {
setPatient(response.data);
setIsLoading(false);
}
});
}
}, [patientId, url]);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
if (patientId && url) { | ||
setIsLoading(true); | ||
openmrsFetch(url).then((response) => { | ||
if (response.status == 200 && response.data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to check the response status. openmrsFetch does this for you.
useEffect(() => { | ||
if (patientId && url) { | ||
setIsLoading(true); | ||
openmrsFetch(url).then((response) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not necessary, but you might consider using using SWR instead of doing all of this. That handles most of the isLoading
and can cache results.
if (response.status == 200 && response.data) { | ||
setPatient(response.data); | ||
setIsLoading(false); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think setIsLoading()
needs to be unconditionally set to false
once the request is done; otherwise you'll display a loading spinner endlessly if the request isn't successful.
export function getIdentifierFieldValuesFromFhirPatient( | ||
patient: fhir.Patient, | ||
identifierConfig, | ||
): { [key: string]: any } { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be better typed than it is like this.
patient: fhir.Patient, | ||
identifierConfig, | ||
): { [key: string]: any } { | ||
const identifiers: { [key: string]: any } = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also be an explicit type. Don't. use any
if you can avoid it.
@@ -0,0 +1,45 @@ | |||
import capitalize from 'lodash-es/capitalize'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import capitalize from 'lodash-es/capitalize'; | |
import { capitalize } from 'lodash-es'; |
import capitalize from 'lodash-es/capitalize'; | ||
|
||
export function inferModeFromSearchParams(searchParams: URLSearchParams) { | ||
return searchParams?.get('mode')?.toLowerCase() == 'external' ? 'external' : 'internal'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return searchParams?.get('mode')?.toLowerCase() == 'external' ? 'external' : 'internal'; | |
return searchParams.get('mode')?.toLowerCase() === 'external' ? 'external' : 'internal'; |
return searchParams?.get('mode')?.toLowerCase() == 'external' ? 'external' : 'internal'; | ||
} | ||
|
||
export function mapToOpenMRSPatient(fhirPatients: any): any { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also benefit from explicit types on both sides. Presumable fhirPatients
is a fhir.Bundle
and each entry is a fhir.Patient
or similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's also an OpenMRS patient type in core that can be the return type.
b14aa33
to
31fc392
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small things, but basically LGTM
})), | ||
age: null, | ||
birthdate: fhirPatient.birthDate, | ||
gender: capitalize(fhirPatient.gender), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than this, it would actually be better to do: getCoreTranslations(fhirPatient.gender)
age: null, | ||
birthdate: fhirPatient.birthDate, | ||
gender: capitalize(fhirPatient.gender), | ||
dead: !fhirPatient.active, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems wrong or, at the very least, very specific. dead
corresponds to FHIR's deceasedBoolean
(and deathDate
with deceasedDateTime
). active === false
just means "this patient record is no longer actively used in this system".
dead: !fhirPatient.active, | ||
deathDate: '', | ||
personName: { | ||
display: `${fhirPatient.name[0].family} ${fhirPatient.name[0].given[0]}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always dislike inferring what the display should be for a name, since this is very location-sensitive, e.g., how its written, how it's formatted etc. I'd prefer that we either pull from the name[0].text
first.
render(<PatientSearchButton />); | ||
|
||
render( | ||
<BrowserRouter> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably better to use a MemoryBrowser in tests.
@@ -5,6 +5,8 @@ import AdvancedPatientSearchComponent from '../patient-search-page/advanced-pati | |||
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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor, but this import should come before all relative imports.
kind="ghost" | ||
renderIcon={'Search'} | ||
onClick={(e) => { | ||
e.preventDefault(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the preventDefault()
call here?
Do we expect users to know what "MPI" means? I would think "Check for national chart" or "Search health exchange" would be easier for providers/users to understand. |
@bmamlin How about 'Search External Registry' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So high-level we should probably have a configuration option to enable / disable the CR feature (actually ideally, this would be a feature flag for now).
Otherwise, I think it's fine.
@@ -35,6 +36,8 @@ export const patientSearchBar = getSyncLifecycle(patientSearchBarComponent, opti | |||
export function startupApp() { | |||
defineConfigSchema(moduleName, configSchema); | |||
|
|||
registerFeatureFlag('mpiFlag', 'MPI Service', 'Enables the Master Patient Index workflows'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should've said this: our preferred means of registering feature flags is via routes.json
. Basically add the same properties, but to a featureFlag
definition there.
Could you move this along, @reagan-meant? |
@denniskigen are you available to review? |
Requirements
Summary
Screenshots
mpi.mov
Related Issue
https://openmrs.atlassian.net/browse/HIE-9
Other