-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b19c67
commit a2c05fd
Showing
17 changed files
with
259 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 59 additions & 52 deletions
111
packages/esm-patient-orders-app/src/hooks/useOrderPrice.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,62 @@ | ||
// import { useState, useEffect } from 'react'; | ||
// import { OrderPriceData } from '../types/order'; // Adjust based on path | ||
import { type OrderPriceData } from '../types/order'; | ||
import { fhirBaseUrl } from '@openmrs/esm-framework'; | ||
import useSWR from 'swr'; | ||
import { useMemo } from 'react'; | ||
|
||
export const useOrderPrice = (code: string) => { | ||
// const [price, setPrice] = useState<OrderPriceData | null>(null); | ||
// | ||
// useEffect(() => { | ||
// const fetchPrice = async () => { | ||
// const response = await fetch(`http://localhost:8080/odoo/R4/ChargeItemDefinition?code=${code}`); | ||
// const data: OrderPriceData = await response.json(); | ||
// setPrice(data.entry[0]); // Get the first entry | ||
// }; | ||
// | ||
// fetchPrice(); | ||
// }, [code]); | ||
|
||
return { | ||
resourceType: 'Bundle', | ||
id: '4c2b7e55-b7b3-4ae2-a144-99ea1d01a21a', | ||
meta: { | ||
lastUpdated: '2024-09-11T18:17:57.249+03:00', | ||
}, | ||
type: 'searchset', | ||
link: [ | ||
{ | ||
relation: 'self', | ||
url: 'http://localhost:8080/odoo/R4/ChargeItemDefinition?code=af3fce1f-dcb1-4f76-ad4c-b8ebda43070c', | ||
}, | ||
], | ||
entry: [ | ||
{ | ||
resource: { | ||
resourceType: 'ChargeItemDefinition', | ||
id: 'af3fce1f-dcb1-4f76-ad4c-b8ebda43070c', | ||
name: 'Vitamine B-Complex Injection', | ||
status: 'active', | ||
date: '2024-09-03T13:59:50+03:00', | ||
propertyGroup: [ | ||
{ | ||
priceComponent: [ | ||
{ | ||
type: 'base', | ||
amount: { | ||
value: 1.08, | ||
currency: 'USD', | ||
}, | ||
}, | ||
], | ||
export const useOrderPrice = (orderItemUuid: string) => { | ||
const { data, isLoading } = useSWR( | ||
orderItemUuid ? `${fhirBaseUrl}/ChargeItemDefinition?code=${orderItemUuid}` : null, | ||
async (): Promise<OrderPriceData> => { | ||
return new Promise((resolve, reject) => { | ||
setTimeout(() => { | ||
resolve({ | ||
resourceType: 'Bundle', | ||
id: '4c2b7e55-b7b3-4ae2-a144-99ea1d01a21a', | ||
meta: { | ||
lastUpdated: '2024-09-11T18:17:57.249+03:00', | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
}; | ||
type: 'searchset', | ||
link: [ | ||
{ | ||
relation: 'self', | ||
url: 'http://localhost:8080/odoo/R4/ChargeItemDefinition?code=af3fce1f-dcb1-4f76-ad4c-b8ebda43070c', | ||
}, | ||
], | ||
entry: [ | ||
{ | ||
resource: { | ||
resourceType: 'ChargeItemDefinition', | ||
id: 'af3fce1f-dcb1-4f76-ad4c-b8ebda43070c', | ||
name: 'Vitamine B-Complex Injection', | ||
status: 'active', | ||
date: '2024-09-03T13:59:50+03:00', | ||
propertyGroup: [ | ||
{ | ||
priceComponent: [ | ||
{ | ||
type: 'base', | ||
amount: { | ||
value: 1.08, | ||
currency: '$', | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
}); | ||
}, 3000); | ||
}); | ||
}, | ||
); | ||
|
||
return useMemo( | ||
() => ({ | ||
data, | ||
isLoading, | ||
}), | ||
[data, isLoading], | ||
); | ||
}; |
Oops, something went wrong.