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

feat: KHP3 follow up changes on the providers: Filters, UI #552

Merged
merged 8 commits into from
Jan 17, 2025
Merged
1 change: 0 additions & 1 deletion packages/esm-billing-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
"errorOnLine": "Error on line",
"errorRetrievingHIESubscription": "Error retrieving HIE subscription",
"exemptionCategory": "Exemption category",
"exemptionSchema": "Exemption Schema",
"facility": "Facility",
"failedBillPayment": "Bill payment failed",
"failure": "Error loading intervensions",
Expand Down
43 changes: 3 additions & 40 deletions packages/esm-providers-app/src/component/providers.component.tsx
Original file line number Diff line number Diff line change
@@ -1,53 +1,16 @@
import React from 'react';
import { ProvidersHeader } from '../header/providers-header.component';
import { ContentSwitchTabs } from '../content-switcher/content-switcher.component';
import { useProviders } from '../table/provider-data-table.resource';
import dayjs from 'dayjs';
import { ConfigObject } from '../config-schema';
import { useConfig } from '@openmrs/esm-framework';
import { Overview } from '../overview/overview.component';

const ProvidersComponent: React.FC = () => {
const { provider, error, isLoading } = useProviders();
const { licenseNumberUuid, licenseExpiryDateUuid, providerNationalIdUuid } = useConfig<ConfigObject>();

const activeProviders = provider.filter((provider) => {
const licenseAttr = provider.attributes.find((attr) => attr.attributeType.uuid === licenseNumberUuid);
const expiryAttr = provider.attributes.find((attr) => attr.attributeType.uuid === licenseExpiryDateUuid);
const nationalId = provider.attributes.find((attr) => attr.attributeType.uuid === providerNationalIdUuid);
const licenseExpiryDate = expiryAttr ? dayjs(expiryAttr.value) : null;

return nationalId && licenseAttr && licenseExpiryDate && licenseExpiryDate.isAfter(dayjs());
});

const expiredProviders = provider.filter((provider) => {
const expiryAttr = provider.attributes.find((attr) => attr.attributeType.uuid === licenseExpiryDateUuid);
const licenseExpiryDate = expiryAttr ? dayjs(expiryAttr.value) : null;

return licenseExpiryDate && licenseExpiryDate.isBefore(dayjs());
});

const missingNationalId = provider.filter((provider) => {
const nationalId = provider.attributes.find((attr) => attr.attributeType.uuid === providerNationalIdUuid);
return !nationalId;
});
const missingLicenseOrExpiry = provider.filter((provider) => {
const licenseAttr = provider.attributes.find((attr) => attr.attributeType.uuid === licenseNumberUuid);
const expiryAttr = provider.attributes.find((attr) => attr.attributeType.uuid === licenseExpiryDateUuid);
const nationalId = provider.attributes.find((attr) => attr.attributeType.uuid === providerNationalIdUuid);

return nationalId && (!licenseAttr || !expiryAttr);
});
const summarize = {
all: provider.length,
active: activeProviders.length,
expired: expiredProviders.length,
missingNationalId: missingNationalId.length,
missingLicenseOrExpiry: missingLicenseOrExpiry.length,
};
return (
<div className={`omrs-main-content`}>
<ProvidersHeader title={'Providers'} summarize={summarize} />
<ContentSwitchTabs />
<ProvidersHeader />
<Overview />
its-kios09 marked this conversation as resolved.
Show resolved Hide resolved
</div>
);
};
Expand Down
6 changes: 6 additions & 0 deletions packages/esm-providers-app/src/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ export const configSchema = {
_description: 'UUID for provider licensing body',
_default: 'bcaaa67b-cc72-4662-90c2-e1e992ceda66',
},
providerHieFhirReference: {
_type: Type.String,
_description: 'UUID for provider hie fhir reference',
_default: '67b94e8e-4d61-4810-b0f1-d86497f6e553',
},
defaultPrimaryFacility: {
_type: Type.String,
_description: 'Default facility for a provider',
Expand Down Expand Up @@ -64,6 +69,7 @@ export interface ConfigObject {
nationalIDUuid: string;
passportNumberUuid: string;
licenseExpiryDateUuid: string;
providerHieFhirReference: string;
licenseBodyUuid: string;
providerNationalIdUuid: string;
licenseNumberUuid: string;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,53 +1,18 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { Calendar, Location } from '@carbon/react/icons';
import { useSession, formatDate } from '@openmrs/esm-framework';
import { useSession, formatDate, PageHeader } from '@openmrs/esm-framework';
import styles from './providers-header.scss';
import ProvidersIllustration from './providers-illustration.component';
import { MetricCard } from './providers-metrics.component';

interface ProviderHeaderProps {
title: string;
summarize: {
all: number;
active: number;
expired: number;
missingNationalId: number;
missingLicenseOrExpiry: number;
};
}
export const ProvidersHeader: React.FC<ProviderHeaderProps> = ({ title, summarize }) => {
export const ProvidersHeader: React.FC = () => {
const { t } = useTranslation();
const userSession = useSession();
const userLocation = userSession?.sessionLocation?.display;

return (
<div className={styles.header__section__container}>
<div className={styles.left__justified__items}>
<ProvidersIllustration />
<div className={styles.page__label}>
<p className={styles.page__name}>{title}</p>
<p>{t('providerManagement', 'Providers Management')}</p>
</div>
<>
<div className={styles.header}>
<PageHeader title={t('providerManagement', 'Providers Management')} illustration={<ProvidersIllustration />} />
</div>
<div className={styles.metrics__header}>
<MetricCard label={t('all', 'All')} value={summarize.all} />
<MetricCard label={t('actives', 'Active')} value={summarize.active} />
<MetricCard label={t('expiredlscs', 'Expiring license(s)')} value={summarize.expired} />
<MetricCard label={t('missingLicenses', 'Missing license(s)')} value={summarize.missingLicenseOrExpiry} />
<MetricCard label={t('missingNational', 'Missing national id')} value={summarize.missingNationalId} />

<div className={styles.warp__metrics}>
<div className={styles.metricLocationDate}>
<span className={styles.location}>
<Location size={16} /> {userLocation}
</span>
<span className={styles.date}>
<Calendar size={16} /> {formatDate(new Date(), { mode: 'standard' })}
</span>
</div>
</div>
</div>
</div>
</>
);
};
111 changes: 6 additions & 105 deletions packages/esm-providers-app/src/header/providers-header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,117 +2,18 @@
@use '@carbon/type';
@use '@carbon/colors';

.header__section__container {
.header {
@include type.type-style('body-compact-02');
color: colors.$gray-70;
height: layout.$spacing-12;
background-color: white;
border: 1px solid colors.$gray-20;
border-left: 0;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: layout.$spacing-01;
margin-right: 0;
overflow-x: hidden;
padding: 0 layout.$spacing-05;
}

.left__justified__items {
display: flex;
flex-direction: row;
align-items: center;
margin-left: layout.$spacing-04;
}

.page__name {
@include type.type-style('heading-04');
}

.page__labels {
margin-left: 1rem;

p:first-of-type {
margin-bottom: layout.$spacing-02;
}
background: white;
border: 1px solid colors.$gray-20;
}

.svg__container svg {
.svgContainer svg {
width: layout.$spacing-10;
height: layout.$spacing-10;
margin-right: layout.$spacing-03;
margin-left: layout.$spacing-06;
fill: var(--brand-03);
}

.metrics__header {
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
gap: layout.$spacing-06;
flex-wrap: wrap;
padding: layout.$spacing-04 layout.$spacing-05 0 0;
margin-right: layout.$spacing-09;
width: auto;
height: auto;
}

.warp__metrics {
width: auto;
height: auto;
flex-grow: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
gap: layout.$spacing-03;
padding: 0;
min-width: layout.$spacing-12;
}

.metric__label {
flex-grow: 0;
font-family: IBMPlexSans;
font-size: layout.$spacing-04;
line-height: layout.$spacing-06;
letter-spacing: layout.$spacing-01;
color: colors.$gray-70;
text-align: left;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.metric__value {
flex-grow: 0;
font-size: layout.$spacing-06;
line-height: layout.$spacing-06;
text-align: left;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.metricLocationDate {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
gap: layout.$spacing-05;
width: auto;
}

.location,
.date {
display: flex;
align-items: center;
font-size: layout.$spacing-05;
line-height: layout.$spacing-06;
text-align: left;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.location {
margin-bottom: layout.$spacing-02;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { MedicalStaff } from '@carbon/pictograms-react';

const ProvidersIllustration: React.FC = () => {
return (
<div className={styles.svg__container}>
<MedicalStaff className={styles.icon__overiders} />
<div className={styles.svgContainer}>
<MedicalStaff className={styles.iconOveriders} />
</div>
);
};
Expand Down

This file was deleted.

Loading
Loading