-
Notifications
You must be signed in to change notification settings - Fork 246
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 46990a4
Showing
14 changed files
with
147 additions
and
136 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
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], | ||
); | ||
}; |
126 changes: 67 additions & 59 deletions
126
packages/esm-patient-orders-app/src/hooks/useOrderStockInfo.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,63 +1,71 @@ | ||
// import { useState, useEffect } from 'react'; | ||
// import { OrderStockData } from '../types/order'; // Adjust based on path | ||
import { type OrderStockData } from '../types/order'; | ||
|
||
export const useOrderStockInfo = (code: string) => { | ||
// const [stock, setStock] = useState<OrderStockData | null>(null); | ||
// | ||
// useEffect(() => { | ||
// const fetchStock = async () => { | ||
// const response = await fetch(`http://localhost:8080/odoo/R4/InventoryItem?code=${code}`); | ||
// const data: OrderStockData = await response.json(); | ||
// setStock(data.entry[0]); // Get the first entry | ||
// }; | ||
// | ||
// fetchStock(); | ||
// }, [code]); | ||
import useSWR from 'swr'; | ||
import { fhirBaseUrl } from '@openmrs/esm-framework'; | ||
import { useMemo } from 'react'; | ||
|
||
return { | ||
resourceType: 'Bundle', | ||
id: '73e12fd2-b13c-4675-b7f4-704dff90bb1d', | ||
meta: { | ||
lastUpdated: '2024-09-10T10:56:28.983+03:00', | ||
}, | ||
type: 'searchset', | ||
link: [ | ||
{ | ||
relation: 'self', | ||
url: 'http://localhost:8080/odoo/R4/InventoryItem?code=af3fce1f-dcb1-4f76-ad4c-b8ebda43070c', | ||
}, | ||
], | ||
entry: [ | ||
{ | ||
resource: { | ||
resourceType: 'InventoryItem', | ||
id: 'af3fce1f-dcb1-4f76-ad4c-b8ebda43070c', | ||
meta: { | ||
profile: ['http://hl7.org/fhir/StructureDefinition/InventoryItem'], | ||
}, | ||
status: 'active', | ||
code: [ | ||
{ | ||
coding: [ | ||
{ | ||
system: 'https://fhir.openmrs.org/concept-system/inventory-item', | ||
code: 'af3fce1f-dcb1-4f76-ad4c-b8ebda43070c', | ||
display: 'Vitamine B-Complex Injection', | ||
}, | ||
], | ||
}, | ||
], | ||
name: [ | ||
{ | ||
name: 'Vitamine B-Complex Injection', | ||
export const useOrderStockInfo = (orderItemUuid: string) => { | ||
const { data, isLoading } = useSWR( | ||
orderItemUuid ? `${fhirBaseUrl}/ChargeItemDefinition?code=${orderItemUuid}` : null, | ||
async (): Promise<OrderStockData> => { | ||
return new Promise((resolve, reject) => { | ||
setTimeout(() => { | ||
resolve({ | ||
resourceType: 'Bundle', | ||
id: '73e12fd2-b13c-4675-b7f4-704dff90bb1d', | ||
meta: { | ||
lastUpdated: '2024-09-10T10:56:28.983+03:00', | ||
}, | ||
], | ||
netContent: { | ||
value: 220.0, | ||
unit: 'Ampule(s)', | ||
}, | ||
}, | ||
}, | ||
], | ||
}; | ||
type: 'searchset', | ||
link: [ | ||
{ | ||
relation: 'self', | ||
url: 'http://localhost:8080/odoo/R4/InventoryItem?code=af3fce1f-dcb1-4f76-ad4c-b8ebda43070c', | ||
}, | ||
], | ||
entry: [ | ||
{ | ||
resource: { | ||
resourceType: 'InventoryItem', | ||
id: 'af3fce1f-dcb1-4f76-ad4c-b8ebda43070c', | ||
meta: { | ||
profile: ['http://hl7.org/fhir/StructureDefinition/InventoryItem'], | ||
}, | ||
status: 'active', | ||
code: [ | ||
{ | ||
coding: [ | ||
{ | ||
system: 'https://fhir.openmrs.org/concept-system/inventory-item', | ||
code: 'af3fce1f-dcb1-4f76-ad4c-b8ebda43070c', | ||
display: 'Vitamine B-Complex Injection', | ||
}, | ||
], | ||
}, | ||
], | ||
name: [ | ||
{ | ||
name: 'Vitamine B-Complex Injection', | ||
}, | ||
], | ||
netContent: { | ||
value: 220.0, | ||
unit: 'Ampule(s)', | ||
}, | ||
}, | ||
}, | ||
], | ||
}); | ||
}, 3000); | ||
}); | ||
}, | ||
); | ||
|
||
return useMemo( | ||
() => ({ | ||
data, | ||
isLoading, | ||
}), | ||
[data, isLoading], | ||
); | ||
}; |
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