Skip to content

Commit

Permalink
Add back ShouldBillPatient
Browse files Browse the repository at this point in the history
  • Loading branch information
ODORA0 committed Feb 12, 2024
1 parent 877c20e commit 593b78c
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions src/billing-form/billing-checkin-form.component.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, useState } from 'react';
import { Dropdown, InlineLoading, InlineNotification } from '@carbon/react';
import { useTranslation } from 'react-i18next';
import { showSnackbar } from '@openmrs/esm-framework';
import { showSnackbar, useConfig } from '@openmrs/esm-framework';
import { useCashPoint, useBillableItems, createPatientBill } from './billing-form.resource';
import VisitAttributesForm from './visit-attributes/visit-attributes-form.component';
import styles from './billing-checkin-form.scss';
Expand All @@ -20,22 +20,31 @@ const BillingCheckInForm: React.FC<BillingCheckInFormProps> = ({ patientUuid, se
const { lineItems, isLoading: isLoadingLineItems, error: lineError } = useBillableItems();
const [attributes, setAttributes] = useState([]);
const [paymentMethod, setPaymentMethod] = useState<any>();
const { patientCatergory, catergoryConcepts } = useConfig();
let lineList = [];

const handleCreateBill = useCallback((createBillPayload) => {
createPatientBill(createBillPayload).then(
() => {
showSnackbar({ title: 'Patient Bill', subtitle: 'Patient has been billed successfully', kind: 'success' });
},
(error) => {
showSnackbar({
title: 'Patient Bill Error',
subtitle: 'An error has occurred while creating patient bill',
kind: 'error',
});
},
);
}, []);
const shouldBillPatient =
attributes.find((item) => item.attributeType === patientCatergory.paymentDetails)?.value ===
catergoryConcepts.payingDetails;

const handleCreateBill = useCallback(
(createBillPayload) => {
shouldBillPatient &&
createPatientBill(createBillPayload).then(
() => {
showSnackbar({ title: 'Patient Bill', subtitle: 'Patient has been billed successfully', kind: 'success' });
},
(error) => {
showSnackbar({
title: 'Patient Bill Error',
subtitle: 'An error has occurred while creating patient bill',
kind: 'error',
});
},
);
},
[shouldBillPatient],
);

const handleBillingService = ({ selectedItem }) => {
const cashPointUuid = cashPoints?.[0]?.uuid ?? '';
Expand Down Expand Up @@ -102,7 +111,7 @@ const BillingCheckInForm: React.FC<BillingCheckInFormProps> = ({ patientUuid, se
return (
<section className={styles.sectionContainer}>
<VisitAttributesForm setAttributes={setAttributes} setPaymentMethod={setPaymentMethod} />
{
{shouldBillPatient && (
<>
<div className={styles.sectionTitle}>{t('billing', 'Billing')}</div>
<div className={styles.sectionField}></div>
Expand All @@ -115,7 +124,7 @@ const BillingCheckInForm: React.FC<BillingCheckInFormProps> = ({ patientUuid, se
titleText={t('billableService', 'Billable service')}
/>
</>
}
)}
</section>
);
};
Expand Down

0 comments on commit 593b78c

Please sign in to comment.