Skip to content
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

(chore) O3-2120: Move OpenMRS ID patient search identifier to defaultIdentifierTypes #1061

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,11 @@ const AppointmentsTable: React.FC<AppointmentsTableProps> = ({ appointments, isL
itemText={t('editAppointments', 'Edit appointment')}
size={responsiveSize}
onClick={() =>

launchWorkspace('edit-appointments-form', {
patientUuid: matchingAppointment.patient.uuid,
appointment: matchingAppointment,
context: 'editing',
})

}
/>
</OverflowMenu>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,17 @@ const CompactPatientBanner = forwardRef<HTMLDivElement, CompactPatientBannerProp
return (
<div ref={ref}>
{fhirPatients.map((patient, index) => {
const patientIdentifiers = patients[index].identifiers.filter((identifier) =>
config.defaultIdentifierTypes.includes(identifier.identifierType.uuid),
const preferredIdentifier = patients[index].identifiers.find((identifier) => identifier.preferred);

const configuredIdentifiers = patients[index].identifiers.filter(
(identifier) =>
!identifier.preferred && config.defaultIdentifierTypes.includes(identifier.identifierType.uuid),
);

const patientIdentifiers = preferredIdentifier
? [preferredIdentifier, ...configuredIdentifiers]
: configuredIdentifiers;

const patientName = displayName(patient);

return (
Expand All @@ -120,19 +128,9 @@ const CompactPatientBanner = forwardRef<HTMLDivElement, CompactPatientBannerProp
<div className={styles.demographics}>
{getGender(patient.gender)} <span className={styles.middot}>&middot;</span> {age(patient.birthDate)}
<span className={styles.middot}>&middot;</span>
{config.defaultIdentifierTypes.length ? (
<>
{patientIdentifiers.length > 1 ? (
<DefaultIdentifiers identifiers={patientIdentifiers} />
) : (
<FallbackIdentifier patient={patients[index]} identifierName={config.defaultIdentifier} />
)}
</>
) : (
<>
<span className={styles.middot}>&middot;</span> {patients[index].identifiers?.[0]?.identifier}
</>
)}
{patientIdentifiers.map((identifier) => (
<IdentifierTag identifier={identifier} />
))}
</div>
</div>
</ClickablePatientContainer>
Expand Down Expand Up @@ -189,20 +187,4 @@ const IdentifierTag: React.FC<IdentifierTagProps> = ({ identifier }) => {
);
};

const DefaultIdentifiers: React.FC<IdentifiersProps> = ({ identifiers }) => {
return (
<>
{identifiers.map((identifier) => (
<IdentifierTag identifier={identifier} />
))}
</>
);
};

const FallbackIdentifier: React.FC<CustomIdentifierProps> = ({ patient, identifierName }) => {
const identifier = patient.identifiers.find((identifier) => identifier.identifierType.display === identifierName);

return identifier ? <IdentifierTag identifier={identifier} /> : null;
};

export default CompactPatientBanner;
14 changes: 6 additions & 8 deletions packages/esm-patient-search-app/src/config-schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Type, validators } from '@openmrs/esm-framework';

export const configSchema = {
search: {
patientResultUrl: {
Expand Down Expand Up @@ -41,15 +42,12 @@ export const configSchema = {
_elements: {
_type: Type.UUID,
},
_description:
'A list of identifier types to be displayed in the patient search results as banner tags. If no defaultIdentifierTypes are provided, the defaultIdentifier will be displayed.',
_description: 'A list of identifier types to be displayed in the patient search results as banner tags.',
// These values correspond to the Patient Clinic Number and National Unique Patient Identifier (NUPI) identifier types respectively
_default: ['b4d66522-11fc-45c7-83e3-39a1af21ae0d', 'f85081e2-b4be-4e48-b3a4-7994b69bb101'],
},
defaultIdentifier: {
_type: Type.String,
_description: 'Identifer type to be displayed when no defaultIdentifierTypes are provided. Default is OpenMRS ID.',
_default: 'OpenMRS ID',
_default: [
// This UUID is for the OpenMRS ID identifier
'05a29f94-c0ed-11e2-94be-8c13b969e334',
],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we shouldn't be hardcoding any identifier uuids here but this should come from the ref app configuration, but I know there's not agreement on that (and that this is existing code, not a change introduced as part of this code)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mogoodrich for the feedback.
The only uuid introduced is one for the OpenMRS ID, that's the last in the list.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the other identifiers then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, these first two identifiers are Palladium-specific. Those are the Patient Clinic Number and the NUPI number. They should be provided via distro configuration instead of being hardcoded in the Patient Search config schema. @donaldkibet, can @usamaidrsk proceed to remove them from here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the config file there is this comment, for the first two.

These values correspond to the Patient Clinic Number and National Unique Patient Identifier (NUPI) identifier types respectively

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @denniskigen ! In fairness to @usamaidrsk looks like those two identifiers constants existed prior to this PR, but if they are implementation-specific, they definitely should be removed as defaults. @donaldkibet

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks right @mogoodrich

},
};

Expand Down
4 changes: 4 additions & 0 deletions packages/esm-patient-search-app/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export interface Identifier {
identifierType: OpenmrsResource;
location: OpenmrsResource;
uuid: string;
preferred: boolean;
}

export interface Address {
preferred: boolean;
voided: boolean;
Expand All @@ -36,6 +38,7 @@ export interface Address {
postalCode: string;
stateProvince: string;
}

export interface FHIRPatientType {
id: string;
identifier: Array<FHIRIdentifier>;
Expand Down Expand Up @@ -77,6 +80,7 @@ export interface FHIRPatientSearchResponse {
resource: FHIRPatientType;
}>;
}

export interface PatientSearchResponse {
data?: Array<SearchedPatient>;
isLoading: boolean;
Expand Down