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

KHP3-6174 - (feat) added a UI for the showing prices #273

Merged
merged 11 commits into from
Jul 17, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import { useBillableItem } from '../useBillableItem';
import { useTranslation } from 'react-i18next';
import { InlineLoading } from '@carbon/react';
import PriceInfoOrder from './price-info-order.componet';

type ImagingOrderProps = {
order: {
testType?: {
label: string;
conceptUuid: string;
};
};
};

const ImagingOrder: React.FC<ImagingOrderProps> = ({ order }) => {
const { t } = useTranslation();
const { billableItem, isLoading, error } = useBillableItem(order?.testType?.conceptUuid);

if (isLoading) {
return (
<InlineLoading
status="active"
iconDescription={t('loading', 'Loading')}
description={t('loadingData', 'Loading data...')}
/>
);
}

return <PriceInfoOrder billableItem={billableItem} error={error} />;
};

export default ImagingOrder;
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import { convertToCurrency } from '../../../helpers';
import { useBillableItem } from '../useBillableItem';
import { useTranslation } from 'react-i18next';
import { InlineLoading } from '@carbon/react';
import PriceInfoOrder from './price-info-order.componet';

type LabOrderProps = {
order: {
Expand All @@ -12,23 +14,20 @@ type LabOrderProps = {
};

const LabOrder: React.FC<LabOrderProps> = ({ order }) => {
// TODO: Implement logic to display whether the lab order service is available to ensure clinicians can order the service

const { billableItem, error, isLoading } = useBillableItem(order?.testType?.conceptUuid);

const billItems = billableItem?.servicePrices
.map((servicePrice) => `${servicePrice?.paymentMode?.name} - ${convertToCurrency(servicePrice?.price)}`)
.join(' ');
const { t } = useTranslation();
const { billableItem, isLoading, error } = useBillableItem(order?.testType?.conceptUuid);

if (isLoading) {
return null;
}

if (error) {
return null;
return (
<InlineLoading
status="active"
iconDescription={t('loading', 'Loading')}
description={t('loadingData', 'Loading data...')}
/>
);
}

return <p>{billItems}</p>;
return <PriceInfoOrder billableItem={billableItem} error={error} />;
};

export default LabOrder;
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React from 'react';
import { convertToCurrency } from '../../../helpers';
import { useTranslation } from 'react-i18next';
import styles from './price-info-order.scss';
import {
StructuredListWrapper,
StructuredListHead,
StructuredListRow,
StructuredListCell,
StructuredListBody,
Tile,
InlineNotification,
} from '@carbon/react';

type PriceInfoOrderProps = {
billableItem: any;
error?: boolean;
};

const PriceInfoOrder: React.FC<PriceInfoOrderProps> = ({ billableItem, error }) => {
const { t } = useTranslation();

if (error || !billableItem) {
return (
<InlineNotification
kind="info"
title={t('noprice', 'No price found')}
subtitle={t('noInfo', 'Please contact the cashier')}
lowContrast
/>
);
}

return (
<Tile id="" className={styles.prices}>
<div className={styles.listContainer}>
<StructuredListWrapper isCondensed>
<StructuredListHead>
<StructuredListRow head>
<StructuredListCell head className={styles.cell}>
{t('paymentMethods', 'Payment methods')}
</StructuredListCell>
<StructuredListCell head className={styles.cell}>
{t('prices', 'Prices(Ksh)')}
</StructuredListCell>
</StructuredListRow>
</StructuredListHead>
<StructuredListBody>
{billableItem.servicePrices.map((priceItem) => (
<StructuredListRow key={priceItem.uuid}>
<StructuredListCell className={styles.cell}>{priceItem.paymentMode.name}</StructuredListCell>
<StructuredListCell className={styles.cell}>{convertToCurrency(priceItem.price)}</StructuredListCell>
</StructuredListRow>
))}
</StructuredListBody>
</StructuredListWrapper>
</div>
</Tile>
);
};

export default PriceInfoOrder;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@use '@carbon/styles/scss/type';
@use '@carbon/styles/scss/spacing';
@use '@carbon/layout';
@use '@carbon/colors';

.prices {
justify-content: center;
align-items: center;
margin: layout.$spacing-03;
}

.listContainer {
display: flex;
flex-direction: column;
align-items: center;
}

.cell {
padding: spacing.$spacing-05;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import { useBillableItem } from '../useBillableItem';
import { useTranslation } from 'react-i18next';
import { InlineLoading } from '@carbon/react';
import PriceInfoOrder from './price-info-order.componet';

type ProcedureOrderProps = {
order: {
testType?: {
label: string;
conceptUuid: string;
};
};
};

const ProcedureOrder: React.FC<ProcedureOrderProps> = ({ order }) => {
const { t } = useTranslation();
const { billableItem, isLoading, error } = useBillableItem(order?.testType?.conceptUuid);

if (isLoading) {
return (
<InlineLoading
status="active"
iconDescription={t('loading', 'Loading')}
description={t('loadingData', 'Loading data...')}
/>
);
}

return <PriceInfoOrder billableItem={billableItem} error={error} />;
};

export default ProcedureOrder;
6 changes: 6 additions & 0 deletions packages/esm-billing-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import InitiatePaymentDialog from './invoice/payments/initiate-payment/initiate-
import DrugOrder from './billable-services/billiable-item/drug-order/drug-order.component';
import LabOrder from './billable-services/billiable-item/test-order/lab-order.component';
import TestOrderAction from './billable-services/billiable-item/test-order/test-order-action.component';
import PriceInfoOrder from './billable-services/billiable-item/test-order/price-info-order.componet';
import ProcedureOrder from './billable-services/billiable-item/test-order/procedure-order.component';
import ImagingOrder from './billable-services/billiable-item/test-order/imaging-order.component';

const moduleName = '@kenyaemr/esm-billing-app';

Expand Down Expand Up @@ -52,5 +55,8 @@ export const requirePaymentModal = getSyncLifecycle(RequirePaymentModal, options
export const visitAttributeTags = getSyncLifecycle(VisitAttributeTags, options);
export const initiatePaymentDialog = getSyncLifecycle(InitiatePaymentDialog, options);
export const labOrder = getSyncLifecycle(LabOrder, options);
export const priceInfoOrder = getSyncLifecycle(PriceInfoOrder, options);
export const procedureOrder = getSyncLifecycle(ProcedureOrder, options);
export const imagingOrder = getSyncLifecycle(ImagingOrder, options);
export const drugOrder = getSyncLifecycle(DrugOrder, options);
export const testOrderAction = getSyncLifecycle(TestOrderAction, options);
16 changes: 15 additions & 1 deletion packages/esm-billing-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@
"component": "labOrder",
"slot": "top-of-lab-order-form-slot"
},
{
"name": "procedure-order-billable-item",
"component": "procedureOrder",
"slot": "top-of-procedure-order-form-slot"
},
{
"name": "imaging-order-billable-item",
"component": "imagingOrder",
"slot": "top-of-imaging-order-form-slot"
},
{
"name": "price-info-order",
"component": "priceInfoOrder"
},
{
"name": "drug-order-billable-item",
"component": "drugOrder",
Expand All @@ -97,4 +111,4 @@
"order": 0
}
]
}
}
1 change: 1 addition & 0 deletions packages/esm-billing-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"lineItems": "Line items",
"loading": "Loading",
"loadingBillingServices": "Loading billing services...",
"loadingData": "Loading data...",
"loadingDescription": "Loading",
"makeclaims": "Make Claims",
"manageBillableServices": "Manage billable services",
Expand Down
2 changes: 2 additions & 0 deletions packages/esm-pharmacy-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"contact": "Contact",
"countyDistrict": "County District",
"dateMapped": "Date Mapped",
"enroll": "Enroll new body",
"name": "NAME",
"noCommunityPharmacyToList": "No Community Pharmacies to list.",
"noPharmacyPatients": "No Pharmacy Patients to list.",
Expand All @@ -17,6 +18,7 @@
"pharmacies": "Phamacies",
"pharmacy": "Commity pharmacy",
"pharmacyPatients": "Pharmacy Patients",
"pharmacySummary": "Pharmacy Summary",
"pharmacyUsers": "Pharmacy Users",
"sex": "Sex",
"stateProvince": "State province",
Expand Down
Loading