Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add. inventory item by drug Id URL #54

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading