|
Last change
on this file since f05de05 was f05de05, checked in by MBK <marija.karapandzova@…>, 4 months ago |
|
Add pages and routing for lab tests, procedures and billing with api services
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | import apiClient from './api';
|
|---|
| 2 |
|
|---|
| 3 | const ENDPOINT = '/billing';
|
|---|
| 4 |
|
|---|
| 5 | export const billingService = {
|
|---|
| 6 | getAllBillings: () => apiClient.get(ENDPOINT),
|
|---|
| 7 |
|
|---|
| 8 | getBillingById: (id) => apiClient.get(`${ENDPOINT}/${id}`),
|
|---|
| 9 |
|
|---|
| 10 | getBillingHistoryForPatient: (patientId) => apiClient.get(`${ENDPOINT}/patient/${patientId}`),
|
|---|
| 11 |
|
|---|
| 12 | getBillingDetail: (id) => apiClient.get(`${ENDPOINT}/${id}/detail`),
|
|---|
| 13 |
|
|---|
| 14 | generateBillingRecord: (billing) => apiClient.post(ENDPOINT, billing),
|
|---|
| 15 |
|
|---|
| 16 | updatePaymentStatus: (id, paymentData) => apiClient.patch(`${ENDPOINT}/${id}/payment-status`, paymentData),
|
|---|
| 17 |
|
|---|
| 18 | downloadInvoicePDF: async (billId) => {
|
|---|
| 19 | try {
|
|---|
| 20 | const response = await apiClient.get(`${ENDPOINT}/${billId}/invoice-pdf`, {
|
|---|
| 21 | responseType: 'blob'
|
|---|
| 22 | });
|
|---|
| 23 | // Create a blob URL and download
|
|---|
| 24 | const url = window.URL.createObjectURL(new Blob([response.data]));
|
|---|
| 25 | const link = document.createElement('a');
|
|---|
| 26 | link.href = url;
|
|---|
| 27 | link.setAttribute('download', `invoice-${billId}.pdf`);
|
|---|
| 28 | document.body.appendChild(link);
|
|---|
| 29 | link.click();
|
|---|
| 30 | link.parentNode.removeChild(link);
|
|---|
| 31 | window.URL.revokeObjectURL(url);
|
|---|
| 32 | } catch (error) {
|
|---|
| 33 | throw error;
|
|---|
| 34 | }
|
|---|
| 35 | },
|
|---|
| 36 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.