Skip to content

Commit

Permalink
Add. inventory item by drug Id URL (#54)
Browse files Browse the repository at this point in the history
Co-authored-by: deeptirawat1510 <[email protected]>
  • Loading branch information
yenugukeerthana and deeptirawat1510 authored Oct 19, 2023
1 parent a74303f commit 85fa8af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/service/save-receipt.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
getRequest,
stockOperationURL,
stockOperationTypeURL,
inventoryItemByDrugIdURL,
} from '../utils/api-utils';
import { getFormattedDate } from '../utils/date-utils';

Expand All @@ -12,8 +13,7 @@ const saveReceipt = async (items, outwardNumber, destinationUuid) => {
const itemsArray = [];
await Promise.all(
items.map(async (item) => {
const itemName = encodeURIComponent(item.item);
const response = await getRequest(`/openmrs/ws/rest/v2/inventory/item?v=full&q=${itemName}`);
const response = await getRequest(inventoryItemByDrugIdURL(item.itemId));
const itemUuid = response.results[0]?.uuid;

itemsArray.push({
Expand Down Expand Up @@ -50,8 +50,7 @@ const inwardSaveReceipt = async (items, institutionId, stockInwardDate, destinat
const itemsArray = [];
await Promise.all(
items.map(async (item) => {
const itemName = encodeURIComponent(item.item);
const response = await getRequest(`/openmrs/ws/rest/v2/inventory/item?v=full&q=${itemName}`);
const response = await getRequest(inventoryItemByDrugIdURL(item.itemId));
const itemUuid = response.results[0]?.uuid;
itemsArray.push({
item: itemUuid,
Expand Down
1 change: 1 addition & 0 deletions src/utils/api-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const dispenseConceptURL = '/openmrs/ws/rest/v1/concept?q=Dispensed&limit
export const stockOperationURL = "/openmrs/ws/rest/v2/inventory/stockOperation"
export const stockOperationTypeURL = (stockOperationType) => `/openmrs/ws/rest/v2/inventory/stockOperationType?v=full&q=${stockOperationType}`
export const inventoryItemByNameURL = (itemName) => `/openmrs/ws/rest/v2/inventory/item?v=full&q=${itemName}`
export const inventoryItemByDrugIdURL = (drugId) => `/openmrs/ws/rest/v2/inventory/item?v=full&drugId=${drugId}`
export const sessionURL = '/openmrs/ws/rest/v1/session?v=custom:(uuid)'
export const stockTakeURL = '/openmrs/ws/rest/v2/inventory/inventoryStockTake'
export const getAllPatient = (locationUuid,inputValue) => `/openmrs/ws/rest/v1/bahmni/search/patient/lucene?filterOnAllIdentifiers=true&identifier=${inputValue}&loginLocationUuid=${locationUuid}&q=${inputValue}`
Expand Down

0 comments on commit 85fa8af

Please sign in to comment.