Skip to content

Commit

Permalink
Remove hardcoded shouldBillPatient logic in billing checkin form base…
Browse files Browse the repository at this point in the history
…d on the visit attributes component
  • Loading branch information
ODORA0 committed Feb 23, 2024
1 parent dbe02e2 commit d8152dd
Showing 1 changed file with 16 additions and 25 deletions.
41 changes: 16 additions & 25 deletions src/billing-form/billing-checkin-form.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,22 @@ 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 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 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 handleBillingService = ({ selectedItem }) => {
const cashPointUuid = cashPoints?.[0]?.uuid ?? '';
Expand Down Expand Up @@ -111,7 +102,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 @@ -124,7 +115,7 @@ const BillingCheckInForm: React.FC<BillingCheckInFormProps> = ({ patientUuid, se
titleText={t('billableService', 'Billable service')}
/>
</>
)}
}
</section>
);
};
Expand Down

0 comments on commit d8152dd

Please sign in to comment.